// JavaScript Document

$(document).ready(function(){ 

// Topmenu Functions ********************************************************************************************************** 
  	
    $("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger on top menu when js is enabled (Adds empty span tag after ul.subnav*)
  
	
	// Submenu Level 1 Mouseover Event ****************************************************************************************
	$("ul.topnav li a").mouseover(function() { //When  mouse over event is triggered
		$(this).addClass("subhover");//add class "subhover" and then show submenu
        
		//Following events are applied to the subnav itself (moving subnav up and down)  
        $(this).parent().find("ul.subnav").slideDown(400).show(); //Drop down the subnav on mouseover
  
        $(this).parent().hover(function() {
        }, function(){  
            $(this).parent().find("ul.subnav").slideUp(400); //When the mouse hovers out of the subnav, move it back up
			$(this).parent().find("a.subhover").removeClass("subhover");// remove subhover styling of first topmenu <a> tag
        });  
    });  
	//**************************************************************************************************************************
	
	// Submenu Level 2 Mouseover Event *****************************************************************************************
	$("ul.topnav li ul.subnav a").mouseover(function() { //When mouse over is fired...  
		//Following events are applied to the subnav itself (moving subnav up and down)  
        $(this).parent().find("ul.subnav-menu").slideDown(400).show(); //Drop down the subnav on mouseover  
  
        $(this).parent().hover(function() {  
        }, function(){  
            $(this).parent().find("ul.subnav-menu").slideUp(400); //When the mouse hovers out of the subnav, move it back up  
        });   
    }); 
	// ************************************************************************************************************************** 
	
// Sidebar Navigation Functions *************************************************************************************************
   
   // Submenu Level 1 Mouseover Event ****************************************************************************************
	$("ul.sidenav li a").mouseover(function() { //When  mouse over event is triggered
		$(this).addClass("subhover");//add class "subhover" and then show submenu
        
		//Following events are applied to the subnav itself (moving subnav up and down)  
        $(this).parent().find("ul.sb-subnav").slideDown(400).show(); //Drop down the subnav on mouseover
  
        $(this).parent().hover(function() {
        }, function(){  
            $(this).parent().find("ul.sb-subnav").slideUp(400); //When the mouse hovers out of the subnav, move it back up
			$(this).parent().find("a.sb-subhover").removeClass("subhover");// remove subhover styling of first topmenu <a> tag
        });  
    });
	
	// Submenu Level 2 Mouseover Event *****************************************************************************************
	$("ul.sidenav li ul.sb-subnav a").mouseover(function() { //When mouse over is fired...  
		//Following events are applied to the subnav itself (moving subnav up and down)  
        $(this).parent().find("ul.sb-subnav-menu").slideDown(400).show(); //Drop down the subnav on mouseover  
  
        $(this).parent().hover(function() {  
        }, function(){  
            $(this).parent().find("ul.sb-subnav-menu").slideUp(400); //When the mouse hovers out of the subnav, move it back up  
        });   
    }); 
	// **************************************************************************************************************************   
});
