
var isEmail = function(iCampo, iNomeCampo) {
	var str = iCampo.value;
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	if ( (!r1.test(str) && r2.test(str)) ) {
		return true;
	} else {
		alert(iNomeCampo + ' inválido.'); return false;
	}
	return true;
}

var VerificaContatoFale = function(f) {
	
	if(f.Departamento.value=='' || f.Departamento.value=='Departamento (*)'){alert('Por favor, informe o departamento'); f.Departamento.focus(); return false;}
	if(f.Nome.value=='' || f.Nome.value=='Seu nome (*)'){alert('Por favor, informe seu nome'); f.Nome.focus(); return false;}
	if(f.Email.value==''){alert('Por favor, informe seu e-mail corretamente'); f.Email.focus(); return false;}
	if(isEmail(f.Email, 'E-mail')==false){f.Email.focus(); f.Email.select(); return false;}
	if(f.Assunto.value=='' || f.Assunto.value=='Assunto (*)'){alert('Por favor, informe o assunto'); f.Assunto.focus(); return false;}
	if(f.Texto.value=='' || f.Texto.value=='Mensagem (*)'){alert('Por favor, descreva o que deseja'); f.Texto.focus(); return false;}
	if(f.DDD.value=='DDD'){f.DDD.value='';}
	if(f.Telefone.value=='Telefone'){f.Telefone.value='';}
	if(f.Senha.value.toUpperCase()!=f.Imagem.value.toUpperCase()){
		alert('Por favor, digite o código de conferência corretamente');
		f.Senha.focus(); f.Senha.select(); return false;
	}
}

var VerificaContatoIndique = function(f) {
	if(f.NomeAmigo.value==''){alert('Informe o nome do seu amigo');f.NomeAmigo.focus();f.NomeAmigo.select();return false;}
	if(isEmail(f.EmailAmigo,'E-mail')==false){f.EmailAmigo.focus();f.EmailAmigo.select();return false;}
	
	if(f.Nome.value==''){alert('Informe seu nome');f.Nome.focus();f.Nome.select();return false;}
	if(isEmail(f.Email,'E-mail')==false){f.Email.focus();f.Email.select();return false;}
}
