<!--
$(document).ready(function()
{	
	//ajuste layout
	h = document.getElementById("content").offsetHeight;
	document.getElementById("separador-coluna").style.height = h+"px";

	// mascaras	
	$('#telefone, #telefone_2, #fax').keyup(function(event){
		fmtTel(this, event);
	});
	
	$('#nome').keyup(function(event){
		fmtAlfa(this, event);
	});
	
	$('#estado').keyup(function(event){
		fmtUF(this, event);
	});
	
			
////////////////////////////////////////// Validação Formulário ///////////////////////////////////////////////////
	/*$('#enquete').bind("change", function(){
		if(($(this).attr('value')=='Outros'))
		{
			$('.onde').removeAttr('disabled');
			$('.onde').fadeIn();
		}
		else
		{
			$('.onde').attr("disabled","disabled");
			$('.onde').fadeOut();
		}
	});
	
	*/
	
	$("input, textarea, select, radio, checkbox").bind("focus", function(){
		$(this).removeClass("errorField");
	});
	
	$("#contactForm").bind("submit", function(evt){
		// evt.preventDefault();
		 form = $(this);
		 
		 var error = '';
		
		 if($("#setor").val() == "")
		 {
			error += ('\n Setor requerido');
			$("#setor").addClass("errorField");
		 }
	 
		 if($("#nome").val().length<3)
		 {
			error += ('\n Nome requirido');
			$("#nome").addClass("errorField");
		 }
		 
		 /*
		 if($("#empresa").val() == "")
		 {
			error += ('\n Empresa requirida');
			$("#empresa").addClass("errorField");
		 }
		*/
		  
		 if($("#email").val()=='')
		 {
			error += '\n E-mail requerido';
			$("#email").addClass("errorField");
		 }
		 else
		 {			 
			// Validação Email
			var reEmail = /^[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
			pStr = $("#email").val();
			if (!reEmail.test(pStr))
			{
			error += '\n E-mail inválido';
			$("#email").addClass("errorField");
			}
		 }
		 
		 if($("#telefone").val() =='')
		 {
			error += '\n Telefone requerido';
			$("#telefone").addClass("errorField");
		 }
		 else if($("#telefone").val().length<14)
		 {
			error += '\n Telefone inválido';
			$("#telefone").addClass("errorField");
		 }
		
		 if($("#cidade").val() == "")
		 {
			error += ('\n Cidade requirida');
			$("#cidade").addClass("errorField");
		 }
		 
		  if($("#uf").val() == "")
		 {
			error += ('\n Estado requirido');
			$("#uf").addClass("errorField");
		 }
		 
				 
		 if($("#mensagem").val().length<10)
		 {
			error += '\n Mensagem requerida';
			$("#mensagem").addClass("errorField");
		 }
			 
		 if(error!='')
		 {
			//$('#formulario').append('<div id="formStatus">'+error+'</div>');
			//$('#formStatus').fadeIn('fast');
			//$("#formStatus").mouseover(function(){
			//	$(this).fadeOut('fast');
			//});
			//alert('Erro(s) encontrado(s):\n'+error);
			alert("Atenção para o(s) iten(s) demarcados no formulário.");
			return false;
		 }
		 else
		 {
			if($(this).find("input[name=ajax]").attr("value")=="true"){				
				$.ajax({
					type: "POST",
					url: "/scripts/funcoes/envia.php",
					//cache: false,
					//dataType: "script"
					data: $("#contactForm").serialize(),
					
					beforeSend:  function(){
						$("#formulario").html('<div class="ajaxStatus"></div>');
					},				
					
					success: function(msg){
						$("#formulario").html(msg);
					},			
					
					error: function(msg){
						$("#formulario").html('<p>Arquivo não encontrado. Se o problema persistir contate-nos.</p>');
					}				 
				});
				return false;
			}
		}
	});

////////////////////////////////////////// Google Maps ///////////////////////////////////////////////////
	$('.ampliarMapa').click(function () {	
		$('#content').append('<div id="mapa"><iframe width="690" height="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com.br/maps?f=q&amp;source=s_q&amp;hl=pt-BR&amp;geocode=&amp;q=rotiv,+itu&amp;sll=-14.179186,-50.449219&amp;sspn=47.415388,92.988281&amp;ie=UTF8&amp;cid=4429253321214303448&amp;ll=-23.215633,-47.316914&amp;spn=0.075726,0.118446&amp;z=13&amp;iwloc=A&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com.br/maps?f=q&amp;source=embed&amp;hl=pt-BR&amp;geocode=&amp;q=rotiv,+itu&amp;sll=-14.179186,-50.449219&amp;sspn=47.415388,92.988281&amp;ie=UTF8&amp;cid=4429253321214303448&amp;ll=-23.215633,-47.316914&amp;spn=0.075726,0.118446&amp;z=13&amp;iwloc=A">Exibir no Google Maps</a></small><a href="#" class="removeMapa right"><b>Fechar[x]</b></a></div>');			
		
		$(".removeMapa").click(function () {
			$("#mapa").remove();
		});
		return false;
	});
});

////////////////////////////////////////// Definiçõe Máscaras ///////////////////////////////////////////////////
	function fmtUF(campo, e)
	{
		v = campo.value;    
		v = v.replace(/\d/g,"")
		campo.value = v.toUpperCase();
	}
		
	
	function fmtAlfa(campo, e)
	{
		v = campo.value;    
		v = v.replace(/\d/g,"")
		campo.value = v;
	}
	
	function fmtNum(campo, e)
	{
		v = campo.value;    
		v = v.replace(/\D/g,"")
		campo.value = v;
	}


	function fmtTel(campo, e)
	{
		v = campo.value;
		v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
		v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
		v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
		campo.value = v;
	}

-->
