// JavaScript Document

$(function() {
	//main navigation item
	$("#theMenu ul.topnav li a.mainNavLinks").mouseover(function() { //When mouse is over the trigger...

		$(this).parent().find("ul.subnav").show(); //look for this element's parent within the trigger object

		$(this).parent().hover(function() {
			// do nothing
		}, function(){ // execute the following code when the mouse leaves the trigger
			$(this).parent().find("ul.subnav").hide(); //hide the sub navigation when the mouse leaves the trigger
		});
	});
	
	// subnav items
	$("ul.subnav").hover(function() {
		$(this).parent().find("a.mainNavLinks").addClass("top-nav-hover");
	}, function() {
		$(this).parent().find("a.mainNavLinks").removeClass("top-nav-hover");
	});
	
	//sub-subnav items
	$("ul.subnav li a.subNavLinks").mouseover(function() { //When trigger is clicked...

		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.sub-subnav").show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
			// do nothing
		}, function(){ // execute the following code when the mouse leaves the trigger
			$(this).parent().find("ul.sub-subnav").hide(); //When the mouse hovers out of the subnav, move it back up
		});
	});
	
	$("ul.sub-subnav").hover(function() {
		$(this).parent().find("a.subNavLinks").addClass("subNavLinksHover");
	}, function() {
		$(this).parent().find("a.subNavLinks").removeClass("subNavLinksHover");
	});
	
	if (window.navigator.appName == "Microsoft Internet Explorer" && document.documentMode != 8)
	{
		//this eliminates the spaces between each list item
		$("div#theMenu ul.topnav li.dd-menu ul.subnav li").css({"float":"left"}); 
		$("div#theMenu ul.topnav li.dd-menu").css("z-index","99999");
		
	}
});

function setCurrentPageIndicator(pageTitle,searchFor,navItem)
{
	if (pageTitle.search(searchFor))
	{
		$("#nav"+navItem).addClass("currentPage");
	}
}
