// JavaScript Document
jQuery(document).ready( function() {
	
	// hover no ul do menu - aqui e feita a troca das imagens do menu principal quando passamos o mouse por cima
	/*
	HOLLOVER BUTTOM IMAGES by berg - 
	essa função faz apaercer uma outra imagem quando passamos o mouse sobre uma imagem que tem a classe
	'imgSubmit'. obs.: o ID do elemente que usa a classe 'imgSubmit' deve ser o nome da imagem atual ex.:
	<img src='imagem.gif' class='imgSubmit' id='imagem' /> :)
	*/
	jQuery(".menuSubmit").hover( function() {
		var buttom_id = jQuery(this).attr("id");
		MM_swapImage(buttom_id, '', bloginfo['template_directory'] + '/imagens/menu/' + buttom_id + '_hover.gif', 1);
	},
		function() { MM_swapImgRestore(); }
	);
	
	// hover no li do menu - aqui e feita a troca das imagens do submenu quando passamos o mouse por cima
	//jQuery("#subHome").hover( function() { MM_swapImage('home','',bloginfo['template_directory']+'/imagens/menu/home2.gif',1); }, function() { MM_swapImgRestore(); });

	// show submenus - funcao para mostrar os submenus com efeito
	jQuery("#menu ul li").hover (
		function() {
			if( jQuery('ul', this).css('display')== "none" ) {
				var elementUl = jQuery('ul', this);
				jQuery("#ativa_sub").slideDown("fast", function(){
					if( (jQuery("#ativa_sub").css("display") != "none") && (jQuery("#menu ul li ul").css("display") == "none") ) {
						elementUl.slideDown("fast");
					}
				});
			}
		},
		function() {
			jQuery('ul', this).css('display', 'none');
			ocultarSub( jQuery('ul', this).css('display') );
		}
	);

});

function ocultarSub(elemento) {
	if( elemento == 'none' ) {
		jQuery("#ativa_sub").hide();
		jQuery("#menu ul li ul").hide();
	}
}
