
function getE(name) {
    if (document.getElementById)
        var elem = document.getElementById(name);
    else if (document.all)
        var elem = document.all[name];
    else if (document.layers)
        var elem = document.layers[name];
    return elem;
}

function OpenWindow(query, w, h, scroll) {
    var l = (screen.width - w) / 2;
    var t = (screen.height - h) / 2;

    winprops = 'resizable=0, height=' + h + ',width=' + w + ',top=' + t + ',left=' + l + 'w';
    if (scroll) winprops += ',scrollbars=1';
    var f = window.open(query, "_blank", winprops);
}

$(document).ready(function() {


    $("#navigation_dropdown_main_1").mouseover(function() {

        clearHighlight();

        $("#navigation_dropdown_1").fadeIn(300);
        $(this).addClass("navigation_on");


        $("#navigation_dropdown_2").fadeOut(300);
        $("#navigation_dropdown_3").fadeOut(300);
        $("#navigation_dropdown_4").fadeOut(300);

    });


    $("#navigation_dropdown_main_2").mouseover(function() {

        clearHighlight();

        $("#navigation_dropdown_2").fadeIn(300);
        $(this).addClass("navigation_on");

        $("#navigation_dropdown_1").fadeOut(300);
        $("#navigation_dropdown_3").fadeOut(300);
        $("#navigation_dropdown_4").fadeOut(300);


    });


    $("#navigation_dropdown_main_3").mouseover(function () {

        clearHighlight();

        $("#navigation_dropdown_3").fadeIn(300);
        $(this).addClass("navigation_on");

        $("#navigation_dropdown_1").fadeOut(300);
        $("#navigation_dropdown_2").fadeOut(300);
        $("#navigation_dropdown_4").fadeOut(300);


    });


    $("#navigation_dropdown_main_4").mouseover(function () {

        clearHighlight();

        $("#navigation_dropdown_4").fadeIn(300);
        $(this).addClass("navigation_on");

        $("#navigation_dropdown_1").fadeOut(300);
        $("#navigation_dropdown_2").fadeOut(300);
        $("#navigation_dropdown_3").fadeOut(300);


    });

    $("#navigation").mouseleave(function() {
        clearHighlightDropdown();
    });

    //When page loads...
    $(".home-page-product-grid").hide(); //Hide all content
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
    $(".home-page-product-grid:first").show(); //Show first tab content

    //On Click Event
    $("ul.tabs li").click(function () {

        $("ul.tabs li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".home-page-product-grid").hide(); //Hide all tab content

        var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active ID content
        return false;
    });


});

function clearHighlight() {
    $("#navigation > ul > li > a").each(function() {
        jQuery(this).removeClass("navigation_on");
    });
    $("#navigation > ul > li > p").each(function() {
        jQuery(this).removeClass("navigation_on");  
    }); 

    
}


function clearHighlightDropdown() {

    clearHighlight();

    $("#navigation_dropdowns > div").each(function() {
        $(this).fadeOut(300);
    });

}
