// Catarinense Spa
// Acídio Alan
// Produzido por A2C - Internet para Negócios
// www.a2c.com.br

function removeSpaces(string) {
	var tstring = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++)
	tstring += splitstring[i];
	return tstring;
}

function ValidContato() {
	var form = document.getElementById("form-contato");
	var nome = document.getElementById("nome");
	var email = document.getElementById("email");
	var cidade = document.getElementById("cidade");
	var empresa = document.getElementById("empresa_contato");
	var telefone = document.getElementById("telefone");
	var id_estado = document.getElementById("id_estado");
	var sexo = document.getElementById("sexo");
	var dt_nascimento = document.getElementById("dt_nascimento");
	var mensagem = document.getElementById("mensagem");
	var button = document.getElementById("button-contato");
	
	// Regra para a validação de e-mail.
	var reEmail = /^[\w-]+(\.[\w-]+)*@(([\w-]{2,63}\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;

	if(removeSpaces(nome.value) == "") {
		alert("O campo nome é obrigatório.");
		nome.focus();
		return
	}
	if(email.value == "") {
		alert("O campo e-mail é obrigatório.");
		email.focus();
		return;
	} else {
		valid_email = reEmail.exec(email.value)
		if(valid_email == null) {
			alert("E-mail inválido!");
			email.focus();
			return
		}
	}
	if(sexo.value == "") {
		alert("O campo sexo é obrigatório.");
		sexo.focus();
		return
	}
	if(sexo.value == "") {
		alert("O campo sexo é obrigatório.");
		sexo.focus();
		return
	}
	if(empresa.value == "") {
		alert("O campo empresa é obrigatório.");
		empresa.focus();
		return
	}
	if(telefone.value == "") {
		alert("O campo telefone é obrigatório.");
		telefone.focus();
		return
	}
	if(mensagem.value == "") {
		alert("O campo mensagem é obrigatório.");
		mensagem.focus();
		return
	}

if(removeSpaces(mensagem.value) == "") {
		alert("O campo mensagem é obrigatório.");
		mensagem.focus();
		return
	}
	form.submit();
}