// JavaScript Document
function showDiv(nomediv, nomebotao){
	var whodiv = document.getElementById(nomediv);
	var whobotao = document.getElementById(nomebotao);
	whodiv.style.visibility="visible";
	whodiv.style.display="";
	whobotao.style.visibility="hidden";
	redimensiona();
}
function isEmpty(s){
	if (s == null || s.length == 0)
		return true;
	// The test returns true if there is at least one non-
	// whitespace, meaning the string is not empty. If the
	// test returns true, the string is empty.
		return !/\S/.test(s);
	}
	//
function looksLikeEmail(field){
	var s = field.value;
	if (isEmpty(s)){
		field.focus();
		return false;
	}
	if (/[^@]+@\w+/.test(s))
		return true;
		field.focus();
		return false;
}
function checaCampos(status){
	var status = true;
	//campo de aviso
	var v = document.getElementById('validator');
	// mensagem
	var m = document.getElementById('mensagem');
	// usuario
	var r = document.getElementById('nomeusu');
	// email usuario
	var er = document.getElementById('emailusu');
	if (isEmpty(r.value)){
		v.value= "Preeencha o campo SEU NOME!";
	} else if (isEmpty(er.value)){
		v.value= "Preeencha o campo SEU EMAIL!";
	}
	//checa campos de email e destinatario
	for (i=1;i<=10;i=i+1){
		//destinatario
		d = document.getElementById('nomedestino'+i);
		//email
		e = document.getElementById('emaildestino'+i);
		// checa campos de mail
		if (!isEmpty(e.value) && !looksLikeEmail(e)){
			v.value='Preencha os campos de email corretamente!';
			status=false;
		}
		if (!isEmpty(e.value) && looksLikeEmail(e) && isEmpty(d.value)){
			v.value='Todos os campos precisam ser preenchidos!';
			status=false;
		}
	}
	if (isEmpty(m.value)){
			v.value='Preencha todos os campos corretamente !';
		status=false;
	}
	if(status == false){
		return false;
	}else{
		return true;
	}
}
