﻿function onSilverlightPluginError(errMsg)
{
    // log the error with ajax
    ajax("WebControls/js/ajax.aspx?call=logger", errMsg, null);

    // try to hide the silverlight app with the no silverlight version
    try
    {
        document.getElementById("divSilverlight").className = "silverlightHide";
        document.getElementById("divNoSilverlight").className = "showItem";
    }
    catch(err) {}
}
function onSilverlightPluginLoaded(sender)
{
    // *******************************************************************
    // REMOVE THIS FUNCTION AFTER GOING LIVE WITH NEW HOME PAGE LAYOUT
    // *******************************************************************
    // prevents the flicker in the top background image of the xaml, so we only cover up the html background under the home page banner
    // once silverlight is completely loaded
    document.getElementById("divSilverlight").style.top = "0px";
}
function adjustStyleAfterLoad(browser)
{
    document.getElementById("divSilverlight").style.top = (browser == "firefox") ? "0px" : "3px";
}
function addMouseWheelEvent()
{
    window.onmousewheel = document.onmousewheel = onMouseWheel;
    if (window.addEventListener)
    {
        window.addEventListener("DOMMouseScroll", onMouseWheel, false);
    }
}
function onMouseWheel(event)
{
    var delta = 0;
    if (!event) // For IE.
        event = window.event;

    if (event.wheelDelta)
    { //IE/Opera.
        delta = event.wheelDelta / 120;
        // In Opera 9, delta differs in sign as compared to IE.
        if (window.opera)
        {
            delta = -delta;
        }
    }
    else if (event.detail)
    { // Mozilla case.
        // In Mozilla, sign of delta is different than in IE.
        // Also, delta is multiple of 3.
        delta = -event.detail / 3;
        //Sign is only reversed in windows FF
        if (navigator.userAgent.indexOf("Macintosh") != -1)
            delta = -delta;
    }

    // If delta is nonzero, handle it.
    // Basically, delta is now positive if wheel was scrolled up,
    // and negative, if wheel was scrolled down.
    if (delta)
    {
        var slApp = document.getElementById("slApp");
        slApp.Content.ProductShots.ZoomArea_MouseWheel(delta);
    }

    // Prevent default actions caused by mouse wheel.
    if (event.preventDefault)
    {
        event.preventDefault();
    }
    event.returnValue = false;
}