﻿// Menu Rollovers
$(document).ready(function () {

    // Set the inital highlighted state
    setNav(true);

    // Set the rollovers for the nav headings, use set nav to highlight the element under the mouse,
    // and unhighlight the base nav, on mouseout dehighlight the item that was under the mouse and 
    // highlight the base nav
    $('#home').hover(
        function () { setNav(false); $('#homeImg').attr('src', '../../Content/Images/navTop/topNavHome2.png'); },
        function () { $('#homeImg').attr('src', '../../Content/Images/navTop/topNavHome1.png'); setNav(true); }
    );

    $('#about').hover(
        function () { setNav(false); $('#aboutImg').attr('src', '../../Content/Images/navTop/topNavAbout2.png').attr('height', '23'); $('ul', this).stop().show(); },
        function () { $('ul', this).stop().hide(); $('#aboutImg').attr('src', '../../Content/Images/navTop/topNavAbout1.png').attr('height', '31'); setNav(true); }
    );

    $('#hospital').hover(
        function () { setNav(false); $('#yourHospitalImg').attr('src', '../../Content/Images/navTop/topNavYourHospital2.png'); },
        function () { $('#yourHospitalImg').attr('src', '../../Content/Images/navTop/topNavYourHospital1.png'); setNav(true); }
    );

    $('#partners').hover(
        function () { setNav(false); $('#partnersImg').attr('src', '../../Content/Images/navTop/topNavPartners2.png').attr('height', '23'); $('ul', this).stop().show(); },
        function () { $('ul', this).stop().hide(); $('#partnersImg', this).attr('src', '../../Content/Images/navTop/topNavPartners1.png').attr('height', '31'); setNav(true); }
    );

    $('#media').hover(
        function () { setNav(false); $('#mediaImg').attr('src', '../../Content/Images/navTop/topNavMedia2.png').attr('height', '23'); $('ul', this).stop().show(); },
        function () { $('ul', this).stop().hide(); $('#mediaImg').attr('src', '../../Content/Images/navTop/topNavMedia1.png').attr('height', '31'); setNav(true); }
    );

    $('#blog').hover(
        function () { setNav(false); $('#blogImg').attr('src', '../../Content/Images/navTop/topNavBlog2.png'); },
        function () { $('#blogImg').attr('src', '../../Content/Images/navTop/topNavBlog1.png'); setNav(true); }
    );
});

// Sets the navigation highlight
function setNav(set) {    
    switch ($('#navHeading').val()) {
        case 'home':
            // Highlight or dehighlight the image
            // set is whether this highlight should be highlighted
            if (set)
                $('#homeImg').attr('src', '../../Content/Images/navTop/topNavHome2.png'); 
            else
                $('#homeImg').attr('src', '../../Content/Images/navTop/topNavHome1.png');
            return;
        case 'about':
            if (set)
                $('#aboutImg').attr('src', '../../Content/Images/navTop/topNavAbout3.png');
            else
                $('#aboutImg').attr('src', '../../Content/Images/navTop/topNavAbout1.png');
            return;
        case 'hospital':
            if (set)
                $('#yourHospitalImg').attr('src', '../../Content/Images/navTop/topNavYourHospital2.png');
            else
                $('#yourHospitalImg').attr('src', '../../Content/Images/navTop/topNavYourHospital1.png');
            return;
        case 'partners':
            if (set)
                $('#partnersImg').attr('src', '../../Content/Images/navTop/topNavPartners3.png'); 
            else
                $('#partnersImg').attr('src', '../../Content/Images/navTop/topNavPartners1.png');
            return;
        case 'media':
            if (set)
                $('#mediaImg').attr('src', '../../Content/Images/navTop/topNavMedia3.png'); 
            else
                $('#mediaImg').attr('src', '../../Content/Images/navTop/topNavMedia1.png');
            return;
        case 'blog':
            if (set)
                $('#blogImg').attr('src', '../../Content/Images/navTop/topNavBlog2.png');                                            
            else
                $('#blogImg').attr('src', '../../Content/Images/navTop/topNavBlog1.png');
            return;
    }          
};
