// JavaScript Document

function getId(id)
{
	return document.getElementById(id);
}

function mostraId(id)
{
	$("#"+id).show("fast");
}

function escondeId(id)
{
	$("#"+id).hide("fast");
}

function mostraEscondeId(id)
{
	if(getId(id).style.display=='none')
	{
		$("#"+id).show("fast");
	}
	else
	{
		$("#"+id).hide("fast");
	}
}

function checkMail(mail){
	var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
	if(typeof(mail) == "string"){
			if(er.test(mail)){ return true; }
	}else if(typeof(mail) == "object"){
			if(er.test(mail.value)){
									return true;
							}
	}else{
			return false;
			}
}

//==========================================================
// CONTATO

function enviaContato()
{
	var nome = document.getElementById('nome');
	var email = document.getElementById('email');
	var telefone = document.getElementById('telefone');
	var cidade = document.getElementById('cidade');
	var estado = document.getElementById('estado');
	var subject = document.getElementById('assunto');	
	
	var mensagem = document.getElementById('mensagem');
	
	if(nome.value=='')
	{
		alert("Verifique o campo 'Nome'.");
		nome.focus();
		return false;
	}
	if(!checkMail(email.value))
	{
		alert("Verifique seu 'Email'.");
		email.focus();
		return false;
	}
	if(cidade.value=='')
	{
		alert("Preencha sua 'Cidade'.");
		cidade.focus();
		return false;
	}
	if(mensagem.value=='')
	{
		alert("Preencha o campo 'Mensagem'.");
		mensagem.focus();
		return false;
	}
	
	mostraId('enviando');
	xajax_enviaContato(nome.value, email.value, telefone.value, cidade.value, '', subject.value, mensagem.value);
}

//=======================================================

