﻿$(document).ready(function() {


    //Calls an external script to preload css images
    //
    //This is not normally recommended due to image sizes, but this site
    //is very image light.  This partially negates the lack of use of CSS sprites,
    //and is intended to ensure that hover states are preloaded.
    $.preloadCssImages();


    //DROPDOWNS
    //
    $(".menu li").hover(    //When mouseover a menu item...
                function() {
                    //If there are items in the dropdown...
                    if ($(this).children("ul").children().length > 0) {
                        //Show the dropdown
                        $(this).children("ul").show();
                        //Keep the top menu item lit
                        $(this).children("a").addClass("hovered");
                    }
                },
    //On mouseout...
                function() {
                    //Hide the dropdown
                    $(this).children("ul").hide();
                    //Darken top nav item

                    $(this).children("a").removeClass("hovered");
                }
            );

    //MENU FIX FOR IE LAST-CHILD
    //
    //The last child pseudo-class is only in the CSS3 specification and is
    //not supported by IE < 9, so add a standard CSS class instead
    //
    //Additionally, to promote consistency, non-ie browsers also use this method


    $(".menu li:last-child").children("a").addClass('last-child')


    //POPOUTS
    //
    $("li.level1").hover(    //When mouseover a menu item...
                function() {

                    if ($(this).children().children("ul").children().length > 0) {
                        //Show the dropdown
                        $(this).children(".leftsubmenu").show();

                    }
                },
    //On mouseout...
                function() {

                    $(this).children(".leftsubmenu").hide();
                }
            );

    //ACTIVE MENU ITEMS...

    $(".active").fadeTo(0, 0.6);





});
