// JavaScript Document
//document.lastID = 0;

$(document).ready(function(){
window.dropShowing = false;
window.timerOn = false;

	$('#mainNav li').mouseenter(function(){
		var thisItemId = $(this).attr('id');
		var thisItemDropId = "D"+thisItemId.charAt(1) ;
		if (window.timerOn == true){clearTimeout(rolloutTimer);}
		rolloutTimer=setTimeout("drop('"+thisItemId+"','"+thisItemDropId+"');", 10);
	});

	$('#mainNav li').mouseleave(function(){
		var thisItemId = $(this).attr('id');
		var thisItemDropId = "D"+thisItemId.charAt(1);
		rolloutTimer=setTimeout("closeDrop('"+thisItemDropId+"');", 10);
		window.timerOn = true;
		
	});
	
	$('#menuDropDown').mouseenter(function(){
		if (window.timerOn == true){clearTimeout(rolloutTimer);}
	});
	
	$('#menuDropDown').mouseleave(function(){
		if (window.timerOn == true){
		rolloutTimer=setTimeout("closeDrop('"+window.currentDrop+"');", 150);}
	});
	

});

	function closeDrop(subId){
		//$("#menuDropDown").css('display','none');
		$("#"+subId).css('display','none');
		window.timerOn = false;
		window.dropShowing = false;
		$("#"+window.currentHover+" a").removeClass("hover");
	}	

	function drop(id,subId) {
	
		window.currentSection = id;
		window.currentSubSection = subId;
		
		var navItemOffset=$("#"+id).offset();
		var navItemHeight=$("#"+id).height();
		
		if(window.dropShowing == true){
			closeDrop(window.currentDrop);
			//$("#"+window.currentHover).removeClass("hover");
		}
		
			window.currentDrop = currentSubSection;
			window.currentHover = currentSection;
			//
			
			$("#menuDropDown").css({'display':'block','left':navItemOffset.left,'top':navItemOffset.top + navItemHeight});
			$("#"+subId).css('display','block');
			$("#"+window.currentHover+" a").addClass("hover");
			window.dropShowing = true;
		
    }

