﻿// JScript File for navigation

var imagePreload = new Image();
imagePreload.src= "/assets/images/menu-dropdown-arrow.gif";
var activeTab;
var animationTime = 100;
var nav = 
{
    init : function() 
    {
    $("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled 
    $("ul.subnav").parent().find("a").css("padding-right", "10px");
    $("ul.subnav").parent().next().css("margin-left", "-13px");
    

	    $("ul.topnav li span").click(function() { //When trigger is clicked...

		    //Following events are applied to the subnav itself (moving subnav up and down)
		    $(this).parent().find("ul.subnav").show(); //Drop down the subnav on click

		    $(this).parent().hover(function() {
		    }, function(){
			    $(this).parent().find("ul.subnav").hide(); 
		    });


		    }).hover(function() {
			    $(this).addClass("subhover"); 
			    $(this).parent().find("a").addClass("hover");
		    }, function(){	
			    $(this).removeClass("subhover"); 
			    $(this).parent().find("a").removeClass("hover");
	    });
	    $("ul.subnav").hover(
	        function() {
	            if ($(this).parent().find("span"))
	            {
	                $(this).parent().find("span").addClass("subhover");
	                $(this).parent().find("a").addClass("hover"); 
	            }
	            
	        },
	        function() {
	                $(this).parent().find("span").removeClass("subhover");
	                $(this).parent().find("a").removeClass("hover");	        
	        }
	    );
	    $("ul.topnav li a").hover(
	        function() {
	            
	            if ($(this).parent().find("ul.subnav"))
	            {
	                $(this).parent().find("span").addClass("subhover");
	            }
	        },
	        function() {
	        	if ($(this).parent().find("ul.subnav"))
	            {
	                $(this).parent().find("span").removeClass("subhover");
	            }
	        }
	    );
    }
}
$(function() {
    nav.init(); 
});