﻿$(function () {
    $("#facebook_foot img").hover(
    function () {
        $(this).attr('src', '/Content/FeynmanGroup/Images/facebook_foot_on.png');
    },
    function () {
        $(this).attr('src', '/Content/FeynmanGroup/Images/facebook_foot_off.png');
    })
});

$(function () {
    $("img#ms_footer").hover(
    function () {
        $(this).attr('src', '/Content/FeynmanGroup/Images/ms_color_40.png');
    },
    function () {
        $(this).attr('src', '/Content/FeynmanGroup/Images/ms_grey_40.png');
    })
});

$(function () {
    $("img#cisco_footer").hover(
    function () {
        $(this).attr('src', '/Content/FeynmanGroup/Images/cisco_color_40.png');
    },
    function () {
        $(this).attr('src', '/Content/FeynmanGroup/Images/cisco_grey_40.png');
    })
});

$(function () {
    $("img#dell_footer").hover(
    function () {
        $(this).attr('src', '/Content/FeynmanGroup/Images/dell_color_40.png');
    },
    function () {
        $(this).attr('src', '/Content/FeynmanGroup/Images/dell_grey_40.png');
    })
});

$(document).ready(function () {
    $("#left_col a").hover(
    function () {
        $(this).parent("li").not(".active").css('background', 'url("/Content/FeynmanGroup/Images/selected_5.png") repeat-y');
    }, function () {
        $(this).parent("li").not(".active").css('background', 'none');
    });
});

var navTimer = null;
var original = null;
var arrowHover = false ;

$(document).ready(function () {

    $("#nav_arrow").css("visibility", "hidden");

    if ($("#submenu").length) {
        // The submenu already exists. Save it for later.
        original = $("#submenu").html();
    }

    $("#main_nav ul li").hover(function () {
        clearTimeout(navTimer);

        // There are two cases:
        // 1. When #submenu_content contains a menu (interior pages).
        // 2. When #submenu_content contains news (index/wide pages).

        // Hide everything.
        $("#submenu_content").children().hide();

        if (original == null) {
            // The submenu does not exist.  We must create one and hide the rest.
            $("#submenu").remove();
            $("#submenu_content").append('<div id="submenu"><ul></ul></div>');
        }

        // Insert new content (transplant the submenu).
        $("#submenu ul").html($(this).find("ul").html());
        $("#submenu ul ul").remove();
        $("#submenu li").removeClass("active");
        $("#submenu li a").css("color", "inherit");

        // Apply formatting. Magic Margin algorithm borrowed from 'TopSubNavigation' view.
        var magic_number = 700;
        var chars = $("#submenu ul").text();
        var char_count = chars.length;
        var magic_margin = parseInt(magic_number / char_count);

        $("#submenu ul li").each(function () {
            $(this).css("margin", "0 " + magic_margin + "px");
        });
        $("#submenu ul li:first").css("margin-left", "0");
        $("#submenu ul li:last").css("margin-right", "0");

        // Show the submenu (we hid it earlier).
        $("#submenu").show();

        // The new submenu might not have existed until we created it, so we gotta apply the hover now.
        $("#submenu").hover(function () {
            clearTimeout(navTimer);
        }, function () {
            clearTimeout(navTimer);
            navTimer = setTimeout('switch_back();', 250);
        });

        $("#submenu a").hover(function () {
            $(this).css("color", "#56ACFC");
        }, function () {
            $(this).css("color", "inherit");
        });

    }, function () {
        clearTimeout(navTimer);
        navTimer = setTimeout('switch_back();', 250);
    });

});

function switch_back() {

    if (original != null) {
        $("#submenu").html(original);
    } else {
        $("#submenu").remove();
    }
    $("#submenu_content").children().not("style").show();
    clearTimeout(navTimer);
}


$(document).ready(function () {
    
    var inNav = false;

    $("#main_nav li").hover(function () {
        $("#submenu_box").addClass("ui-widget-header2");
         inNav = true;
    }, function () {
        $("#submenu_box").removeClass("ui-widget-header2");

    });

    $(document).bind("mousemove", function (e) {

        var xLeft = parseInt($("#header").position().left);
        var xRight = parseInt($("#header").position().left) + 620;

        if (e.pageX < xLeft || e.pageX > xRight || e.pageY < 92 || e.pageY > 163) {
            $("#submenu_box").removeClass("ui-widget-header2");
            inNav = false;
        }
        else {
            if(inNav == true)
               $("#submenu_box").addClass("ui-widget-header2");
        }
    });
});
