//**   custom jquery function to fade in/out toggle
jQuery.fn.fadeToggle = function(speed, easing, callback) {
    return this.animate({ opacity: 'toggle' }, speed, easing, callback);
};


//** show / hide the product catalog flyout nav

var flyOutTime = -1;
var flyOut2 = -1;
var txtfocus = 0;
function HideContentLogin(d) {
   flyOut2 = window.setTimeout('HideContentLoginTimeOut("' + d + '")', 1000);
}

function HideContentLoginTimeOut(d) {
    if (flyOut2 > -1) {
        if (txtfocus == null || txtfocus != 1) {
            flyOut2 = $("#" + d + "").hide();
        }
    }
    //$("#" + d).hide();
}

$(document).ready
(
    function() 
    {
        $('#ctl00_MainNav_nav_txtUsername, #ctl00_MainNav_nav_txtPassword').focusout
        (
            function() 
            {
                txtfocus = 0; 
                HideContentLogin('dropdown');
            }
         ).focusin
         (
            function() 
            {
                txtfocus=1;
            }
         ).keypress
         (
            function(e) 
            { 
                var code = (e.keyCode ? e.keyCode : e.which);
                if (code == 13) 
                { //Enter keycode 
                    javascript: login('ctl00_MainNav_nav_txtUsername', 'ctl00_MainNav_nav_txtPassword', '/Pages/Ajax/iframelogin.aspx?site=/americas'); 
                    return false;
                }
            }
        );
    }
 );

function ShowContentLogin(d) {
    if (flyOut2 > -1) {
        window.clearTimeout(flyOut2);
        flyOut2 = -1;
    }

    $("#" + d).show();
}

function HideContent(d, notify) {
    if (flyOutTime == -1) {
        flyOutTime = window.setTimeout('$("#' + d + '").hide(); if (typeof (onHideContent) == "function") onHideContent();', 500);
    }
    //$("#" + d).hide();
    
}

function ShowContent(d, menu, notify) {
    if (flyOutTime > -1) {
        window.clearTimeout(flyOutTime);
        flyOutTime = -1;
    }

    $("#" + menu).show();
    var left = $("#" + d).offset().left + "px";
    var top = $("#" + d).offset().top + $("#" + d).outerHeight(true) + "px";
    $("#" + menu).css({ position: 'absolute', zIndex: 5000, left: left, top: top });

    if (notify && typeof (onShowContent) == 'function') onShowContent();
}

function ReverseContentDisplay(d) {
    if (d.length < 1) { return; }
    if (document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
    else { document.getElementById(d).style.display = "none"; }
}

function saveChoice(obj) {
    var checkBox = document.getElementById("rememberMe");
    var checkBox2 = document.getElementById("rememberMe2");
    if (checkBox.checked || checkBox2.checked)
    {
     var options = { path: '/', expires: 360 };
     jQuery.cookie("saveChoice", obj.href, options);
    }
    else {
     jQuery.cookie("saveChoice", null, options);
    }
    return true;
}

function saveChoice2(obj) {
    var checkBox = document.getElementById("rememberMe");
    var checkBox2 = document.getElementById("rememberMe2");
    if (checkBox.checked || checkBox2.checked)
    {
     var options = { path: '/', expires: 360 };
     jQuery.cookie("saveChoice", obj.href, options);
    }
    else {
     jQuery.cookie("saveChoice", null, options);
    }
    return true;
}
