// JavaScript Document
function validaEnquete(){
	var controle = 0;
	for (i=0;i<document.enquete.elements.length;i++){
		if (document.enquete.elements[i].type == "radio"){
			if (document.enquete.elements[i].checked == true){
				controle++;
			}
		}
	}
	if (controle <= 0){
		alert("Selecione uma das opções");
		return false;
	}else{
		postaForm('enquete');
	}
}

function validaNews (nForm) {
	var Form = formPeloNome(nForm);
	if((Form.newsNome.value == "") || (Form.newsNome.value == "Digite seu nome")) {
		alert("Campo obrigatorio!");
		Form.newsNome.focus();
		return false;
	}
	if((Form.newsEmail.value == "") || (Form.newsEmail.value == "Digite seu e-mail")){
		alert("Campo obrigatorio!");
		Form.newsEmail.focus();
		return false;
	}
	if(!checkemail(Form.newsEmail.value)){
		return false;
	}
	abrePopUp('/cadastro/envia.asp?nm='+Form.newsNome.value+'&em='+Form.newsEmail.value);
}

function validaRestrita (nForm) {
	var Form = formPeloNome(nForm);
	if((Form.nome.value == "") || (Form.nome.value == "Nome")) {
		alert("Campo obrigatorio!");
		Form.nome.focus();
		return false;
	}
	if((Form.senha.value == "") || (Form.senha.value == "Senha")){
		alert("Campo obrigatorio!");
		Form.senha.focus();
		return false;
	}
	//abrePopUp('/restrita/');
	alert('Usuário inválido.');
}

function validaWebMail (nForm) {
	var Form = formPeloNome(nForm);
	if((Form.userid.value == "") || (Form.userid.value == "Digite seu login")) {
		alert("Campo obrigatorio!");
		Form.userid.focus();
		return false;
	}
	if(!checkemail(Form.userid.value)){
		return false;
	}
	if((Form.password.value == "") || (Form.password.value == "Digite sua senha")){
		alert("Campo obrigatorio!");
		Form.password.focus();
		return false;
	}
	postaForm(nForm)
	return true;
}

function abre_webmail(){
	if (validaWebMail('painel_webmail')){
		document.painel_webmail.userid.value=document.painel_webmail.userid.value;
		document.painel_webmail.action='http://pop.cootrafe.org.br/cgi-bin/webmail/webmail.pl'; 
		//document.painel_webmail.action='http://pop.easysystem.com.br/cgi-bin/webmail/webmail.pl';
		document.painel_webmail.target='_blank'; 
		document.painel_webmail.submit();
		document.painel_webmail.login.value=''; 
		document.painel_webmail.password.value='';
	}
}

function validaLivro(){
	if(document.getElementById('texto').value==''){
		alert("Campo Obrigatório!")
		document.getElementById('texto').focus();
		document.getElementById('texto').style.background='#EFFCE4';
		return false
	}
	if(document.getElementById('nome').value==''){
		alert("Campo Obrigatório!")
		document.getElementById('nome').focus();
		document.getElementById('nome').style.background='#EFFCE4';
		return false
		}	
		else{
		retorna();
	}
}

function retorna(){
	var nome  = document.getElementById('nome').value;
	var texto = document.getElementById('texto').value;
	var icone = document.getElementById('icone').value;

	if(icone == ''){
		icone = 'teeth_smile.gif'
		}

	document.getElementById('GN').value = nome;
	document.getElementById('GT').value = texto;
	document.getElementById('GI').value = icone
	
	lform.submit();
}

// Valida Formulário de envio de contato
function validaForm(){
	
if(document.form.nome.value==''){
	alert("Campo Obrigatório!")
	document.form.nome.focus();
	document.form.nome.style.background='#FFFFE5';
	return false
	}
if(document.form.email.value==''){
	alert("Campo Obrigatório!")
	document.form.email.focus();
	document.form.email.style.background='#FFFFE5';
	return false		
}else{
	 if(checkemail(document.form.email.value)==false){
	  return false     
	  }
}
if(document.form.assunto.value==''){
	alert("Campo Obrigatório!")
	document.form.assunto.focus();
	document.form.assunto.style.background='#FFFFE5';
	return false
	}

if(document.form.mensagem.value==''){
	alert("Campo Obrigatório!")
	document.form.mensagem.focus();
	document.form.mensagem.style.background='#FFFFE5';
	return false
	}
postaForm('form');
} 	 


