jQuery(document).ready(function(){
	// Retirando valor padrao de campos de busca
	jQuery('.retirar-valor').each(function(){
		jQuery(this).attr('vlr', jQuery(this).val());
		jQuery(this).focus(function(){
			if(jQuery(this).val() == jQuery(this).attr('vlr')){jQuery(this).val('');}
			jQuery(this).blur(function(){if(jQuery(this).val()==''){jQuery(this).val(jQuery(this).attr('vlr'));}});
		});
	});
	
	// Estilizando o file input
	var txt = jQuery('input#txt-falso');
	var btn = jQuery('input#btn-falso');
	jQuery('input#file-original').each(function(){
		jQuery(this).css({'width':jQuery(btn).width()});
		jQuery(this).css({'height':jQuery(btn).height()});
		jQuery(this).parent().css({'position':'relative'});
		jQuery(this).css({'position':'absolute','float':'right','opacity':'0','cursor':'pointer'});
		var of = jQuery(btn).offset();
		jQuery(this).offset({'top':of.top,'left':of.left});
		jQuery(this).change(function()
		{
			jQuery(txt).val(jQuery(this).val());
		});
	});
	
	jQuery('form.ouvidoria').submit(function(){
		var retorno = true;
		jQuery('form.ouvidoria input[type="text"]').each(function(){
			if(jQuery(this).val()=='')
			{
				var c = jQuery(this);
				jAlert('Campos obrigatórios do formulário não foram preenchidos.','Tommasi Laboratório', function(){
					jQuery(c).focus();
				});
				retorno = false
				return false;
			}
		});
		return retorno;
	});
	
	jQuery('form.fale-conosco').submit(function(){
		var retorno = true;
		jQuery('form.fale-conosco input[type="text"]').each(function(){
			if(jQuery(this).val()=='')
			{
				var c = jQuery(this);
				jAlert('Campos obrigatórios do formulário não foram preenchidos.','Tommasi Laboratório', function(){
					jQuery(c).focus();
				});
				retorno = false
				return false;
			}
		});
		return retorno;
	});
	
});


// Inicia os elementos
$(document).ready(function(){

	// Máscaras do formulário.
	$("[title='data']").mask("99/99/9999");
	$("[title='telefone']").mask("(99) 9999-9999");
	$("[title='celular']").mask("(99) 9999-9999");
	$("[title='cpf']").mask("999.999.999-99");
	$("[title='cep']").mask("99999-999");
	
	
	$('.acoesBarra a').click(
	
		function() {
			
			//alert($(".acoesBarra a").css('backgroundImage'));
			//if($(".cabecalho").css("marginTop") == "-299px")
			
			if($(".cabecalho").css("marginTop") == "-330px"){
				$(".cabecalho").animate({ marginTop: "+=299px"}, 800 ); 
				$(".expandirBarra").html('recolher');
				$(".acoesBarra a").css('backgroundImage','url("http://www.tommasi.com.br/Imagens/estrutura/btTopoMinimizar.png")');
			}else{
				$(".cabecalho").animate({ marginTop: "-=299px"}, 800 ); 
				$(".expandirBarra").html('expandir');
				$(".acoesBarra a").css('backgroundImage','url("http://www.tommasi.com.br/Imagens/estrutura/btTopoExpandir.png")');	
			}
		}
	);

	
});

