// JavaScript Document

function valida(form){
	var destinatario = form.destinatario;
	var emitente	 = form.emitente;
	var assunto		 = form.assunto;
	var mensagem	 = form.mensagem;
	if(ehVazio(destinatario.value)){
		alert('Preencha corretamente o campo em destaque!');
		destinatario.style.color = '#f00';
		return false;
	}
	
	if(!ehEmail(emitente.value)){
		alert('Preencha corretamente o campo em destaque!');
		emitente.select();
		emitente.style.borderColor = '#f00';
		return false;
	}
	
	if(ehVazio(assunto.value)){
		alert('Preencha corretamente o campo em destaque!');
		assunto.style.borderColor = '#f00';
		return false;
	}
	
	if(ehVazio(mensagem.value)){
		alert('Preencha corretamente o campo em destaque!');
		mensagem.style.borderColor = '#f00';
		return false;
	}
	
	return true;
}


function ehVazio(valor){
	if(valor == ''){
		return true;
	}else{
		return false;
	}	
}

function ehEmail(email){
	if(email == '' || email.indexOf('@') == -1 || email.indexOf('.') < 4){
		return false;
	}else{
		return true;
	}	
}













