/* VALIDA EMAILS DIGITADOS NOS FORMULARIOS */
function valida(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; }}
/* VALIDA EMAILS DIGITADOS NOS FORMULARIOS */
/*#########################################################################################################################*/
function Novo_comentario() {
var erros = 0;
var erro = "Preencha os campos vazios:\n";
var nform = document.commentform;
	if(nform.author.value == "") {
			erro += ".nome \n";
			erros++;
	}
	var email = document.getElementsByName('email')[0];
	if(!valida(email)) {
			erro += ".e.mail \n";
			erros++;
	}
	if(nform.comment.value == "") {
			erro += ".comentário \n";
			erros++;
	}
	if(nform.publicKey.value == "") {
			erro += ".código de segurança \n";
			erros++;
	}
	if (erros > 0) {
	var totalErros = "Erros encontrados: "+erros; 
	erro+= "\n"+totalErros
	alert(erro);
			return false;
	}
}
/*#########################################################################################################################*/
function novo_contato() {
var erros = 0;
var erro = "Preencha os campos vazios:\n";
var nform = document.frmContato;
	if(nform.nome.value == "") {
			erro += ".nome \n";
			erros++;
	}
	var email = document.getElementsByName('emailcontato')[0];
	if(!valida(email)) {
			erro += ".e.mail \n";
			erros++;
	}
	if(nform.mensagem.value == "") {
			erro += ".mensagem \n";
			erros++;
	}
	if (erros > 0) {
	var totalErros = "Erros encontrados: "+erros; 
	erro+= "\n"+totalErros
	alert(erro);
			return false;
	}
}
/*#########################################################################################################################*/
function Emailcompartilhe() {
var erros = 0;
var erro = "Preencha os campos vazios:\n";
var nform = document.frmEmail;
	var email = document.getElementsByName('emailenvia')[0];
	if(!valida(email)) {
			erro += ".e.mail \n";
			erros++;
	}
	if (erros > 0) {
	var totalErros = "Erros encontrados: "+erros; 
	erro+= "\n"+totalErros
	alert(erro);
			return false;
	}
}

