﻿/***************************************************
* VALIDAÇÃO DO FORM DE CONTATO
* AUTOR: ROGÉRIO ALMEIDA
* CRIAÇÃO: 26/01/2010
* VERSÃO: 1.0	
****************************************************/

$(document).ready(function() {
	$("form").submit(function() {
		var nome = jQuery.trim($("#nome").val());
		var tel = jQuery.trim($("#tel").val());
		var email = jQuery.trim($("#email").val());	
		var cidade = jQuery.trim($("#cidade").val());
		var uf   = jQuery.trim($("#uf").val());
		var mensagem = jQuery.trim($("#mensagem").val());
		var nota_site = $("input[name='nota_site']").is(':checked');
		var conheceu = $("input[name='conheceu']").is(':checked');
		
		if(nome != "" && tel != "" && email != "" && cidade != "" && uf != "" && mensagem != "" && nota_site != false && conheceu != false) {
			return true;
		}
		else 
		{
			if(nome == "") { alert("O campo Nome é de preenchimento obrigatório."); return false; $("#nome").focus(); }
			if(tel == "") { alert("O campo Telefone é de preenchimento obrigatório."); return false; $("#tel").focus(); }
			if(email == "") { alert("O campo Email é de preenchimento obrigatório."); return false; $("#email").focus(); }
			if(cidade == "") { alert("O campo Cidade é de preenchimento obrigatório."); return false; $("#cidade").focus(); }
			if(uf == "") { alert("O campo Estado é de preenchimento obrigatório."); return false; $("#uf").focus(); }
			if(mensagem == "") { alert("Qual mensagem deseja enviar?"); return false; $("#mensagem").focus(); }
			if(nota_site == false) { alert("Dê sua nota para o nosso site."); return false; }
			if(conheceu == false) { alert("Como conheceu nossa loja?"); return false; }  
		}
	});
	
	// Máscara
    $("#tel").mask("(99) 9999-9999");  
	
 });
