﻿$(document).ready(function() {

    $("ul.topnav li a.Expertise").hover(function() { //When trigger is clicked...

        //Following events are applied to the subnav itself (moving subnav up and down)
        document.getElementById('Expertise').style.backgroundImage = "url(Images/menu-level1-expertise-over.png)";

       $(this).parent().hover(function() {
        }, function() {
        changeImage(document.getElementById("hidCurrentPageName").value);
        $('#nav>li>div').slideUp(500);
        });
    });

    

    $("ul.topnav li a.Clients").hover(function() { //When trigger is clicked...

        //Following events are applied to the subnav itself (moving subnav up and down)
    document.getElementById('Clients').style.backgroundImage = "url(Images/menu-level1-clients-over.png)";

        $(this).parent().hover(function() {
        }, function() {
        changeImage(document.getElementById("hidCurrentPageName").value);
        $('#nav>li>div').slideUp(500);
        });
    });

    $("ul.topnav li a.Careers").hover(function() { //When trigger is clicked...

        //Following events are applied to the subnav itself (moving subnav up and down)
    document.getElementById('Careers').style.backgroundImage = "url(Images/menu-level1-careers-over.png)";

       $(this).parent().hover(function() {
        }, function() {
        changeImage(document.getElementById("hidCurrentPageName").value);
        $('#nav>li>div').slideUp(500);
        });
    });

    $("ul.topnav li a.AboutUs").hover(function() { //When trigger is clicked...
    document.getElementById('AboutUs').style.backgroundImage = "url(Images/menu-level1-aboutus-over.png)";
            
        //Following events are applied to the subnav itself (moving subnav up and down)

        $(this).parent().hover(function() {
        }, function() {
        changeImage(document.getElementById("hidCurrentPageName").value);
        $('#nav>li>div').slideUp(500);
        });
    });
});


/*Function to drop submenu menu */
$(function() {
    $('#nav>li>div').hide();
    $('#nav>li').mouseover(function() {
        // create a reference to the active element (this)
    // so we don't have to keep creating a jQuery object
    $heading = $(this);
        // check to see if any sub menus are open
        if ($heading.siblings().find('div:visible').size() != 0) {
            // close open sub menus
            $heading.siblings().find('div:visible').slideUp(500, function() {
                // open current menu if it's closed
            $heading.find('div:hidden').slideDown(500);
        });
        }
        else {
            // open current menu if it's closed
            $heading.find('div:hidden').slideDown(500);
        }
    })
});
