// JavaScript Document

$(function() 
{
	//start the 2nd level nav with opacity set to 0. (100% tranparency)
	$('#globalNav ul li ul').css("opacity", "0");
		var keepOn = false; //determine when to change the opacity of the 2nd level nav
		//if the globalNav is hovered over
		$('#globalNav ul li.hasHover').mouseover(function(){
			//change the opacity of the 2nd level nav so it can be seen
			$(this).children("ul").stop().animate({"opacity": "1"});
			//IE 6 does not allow hover on a li, so this class is added in ie6.css
			$(this).children("ul").addClass("hover");
		});
		//check to see if the second level nav has lost focus
		$('#globalNav ul li.hasHover ul').mouseout(function(){
			keepOn = false;
			//check to see if the cursor has left the li
			$(this).children("li").mouseover(function(){
				$(this).parent().addClass("hover");
				keepOn = true;
			});
			//check to see if the cursor has left the li span
			$(this).children("li span").mouseover(function(){
				$(this).parent().parent().addClass("hover");
				keepOn = true;
			});
			//check to see if the cursor has left the li span a
			$(this).children("li span a").mouseover(function(){
				$(this).parent().parent().parent().addClass("hover");
				keepOn = true;
			});
			//make sure none of the items have lost focus. 
			//If the mouse is away from all componentes, then change the opacity so the 2nd level nav can not be seen.
			if(keepOn == false){
				$(this).removeClass("hover");
				$(this).stop().animate({"opacity": "0"});
			}
		 });
		//if the mouse is not over the global nav, then we should not see the 2nd level nav
		$('#globalNav ul li.hasHover').mouseout(function(){
		 	$(this).children("ul").stop().animate({"opacity": "0"});
			$(this).children("ul").removeClass("hover");
		 });
		
});


