$(document).ready(function(){
	//configura png transparente					   
	$('div#general').pngFix( );
	//controla o subemnu do menu principal
	$('#menu li').hover(
		function(){
			$(this).find('.submenu').fadeIn();
		},
		function(){
			$(this).find('.submenu').fadeOut('fast');
		}
	);
	//controla os cliques nas abas da caixa de atalho para serviços 
/*	var idFirst = $('#boxControls a:first').attr('id').substr(2,10);
	var idLast = idFirst;
	$('#boxControls a').click(function(){
		var idClick = $(this).attr('id').substr(2,10);
		if(idClick != idFirst){
			$('#bt'+idClick).parent().addClass('boxControlsUP');
		}else{
			$('#bt'+idClick).parent().removeClass('boxControlsUP');
		}
		if(idClick != idLast){
			$('#box'+idLast).hide();
		}
		$('#box'+idClick).show();
		idLast = idClick;
		return false;
	});*/
	//controla navegacao unidades
	$('.listaUnidades li:first a').addClass('unUp');
	$('.listaUnidades li:first .subcidade').show();
	$('.listaUnidades>li>a').click(function(){
		$('.unUp').parent().find('.subcidade').hide();
		$('.unUp').removeClass('unUp');		
		$(this).addClass('unUp');
		$(this).parent().find('.subcidade').fadeIn();
		return false;
	});
	//aplica um estilo de destaque caso a url do link seja igual a url do browser 
	if($('body').attr('id')!='home'){
		$('ul.menucontent>li').each(function(index){
			var hrefAtual = $('a',this).attr('href');		
			if(discoverAtualFileMainMenu(hrefAtual)==discoverAtualFileMainMenu(window.location.href)){
				$('a',this).addClass('mncontUp');
			}else{
				$('a',this).remove('mncontUp');
			}
		});
	}
	//retorna somente a page
	function discoverAtualFileMainMenu(hrefAtual){		
		if((hrefAtual.lastIndexOf(".php")+5) == (hrefAtual.lastIndexOf("/")+1)){
			urlFinal = hrefAtual.substring(hrefAtual.lastIndexOf(".php")+5,hrefAtual.length)
		}else{
			urlFinal = hrefAtual.substring(hrefAtual.lastIndexOf(".php")+5,hrefAtual.lastIndexOf("/")+1)
		}
		return urlFinal;
	}

})

function inputFocus(inputObj,inputValue){
	if (inputObj.value.toUpperCase() == inputValue.toUpperCase()) {
		//remove valor inicial
		inputObj.value = "";
	}
}
function inputBlur(inputObj,inputValue){
	if (inputObj.value.trim() == "") {
		//insere novamente valor inicial pois estava vazio
		inputObj.value = inputValue;
	}
}
