var closetimer;
var hoverMenu = false;

function closeMenus()
{
		$(".submenu").hide();
		if(closetimer)
		{
				window.clearTimeout(closetimer);
				closetimer = null;
		}			
}

$(document).ready(function() {
				
	$("#menu > ul > li > a").mouseover(function()
	{	
		if ($(this).attr("section") == "46")
		{
			$(".submenu").show();
		}	
	});
	
	$(".submenu").mouseover(function()
	{
		if(closetimer)
		{
				window.clearTimeout(closetimer);
				closetimer = null;
		}	
		
		hoverMenu = true;
		
	});
	
	$(".submenu").mouseout(function() {
			if (hoverMenu) {					 
				if(closetimer)
				{
					window.clearTimeout(closetimer);
					closetimer = null;
				}				
				closetimer = window.setTimeout(closeMenus, 500);	
			}
											 
	});
	
	$("#menu > ul > li > a").click(function()
	{
		if ($(this).attr("section") == "46")
		return false;
	});
	
	$("#menuMain > li").mouseover(function() {
							$(this).addClass("ativo");		  
									  
	});
	
	$("#menuMain > li").mouseout(function() {
							$(this).removeClass("ativo");		  
									  
	});	
				  
});
