jQuery(document).ready(function() {

	var lang = jQuery("body").attr("class");
	var over_flag = "_on"
	
	jQuery('#busca .caixa').hint();	
	
	function escondeSubs(){
		jQuery("#menu .btn_sub").removeClass("aberto");
		jQuery("#menu .submenu").hide();
	};
	
	function mostraSub(elemento){
		elemento.parent().find(".submenu").css('display','block');
		elemento.parent(".sub").addClass("aberto");
	};
	
	function menuHover(elemento, acao){
		if (elemento.is(".submenu")){
			var imagemObj = elemento.prev(".btn_sub").find("img");
		} else {
			var imagemObj = elemento.find("img");
		}
		if (acao == "over"){
			var imagemSrc = imagemObj.attr("src").split(".");
			imagemObj.attr("src",imagemSrc[0] + over_flag + "." + imagemSrc[1]);
		} else {
			var imagemSrc = imagemObj.attr("src").split(over_flag);
			imagemObj.attr("src",imagemSrc[0] + imagemSrc[1]);
		}
	};
	
	// popup dos submenus
	jQuery("#menu .btn_sub, #menu .submenu")
	.hover(
		function () {
			mostraSub(jQuery(this));
			menuHover(jQuery(this), "over");
		}, 
		function () {
			escondeSubs();
			menuHover(jQuery(this), "out");
		}
	)
	
	jQuery("#acesso").click(function() {
		jQuery("#box-acesso").show();
	})
	.mouseleave(function(){
		jQuery("#box-acesso").hide();
	});

	jQuery("#box-acesso").hover(function() {
	/**/
	}, function(){
		jQuery(this).hide();
	})

	
});
