// JavaScript Document
function validaEnquete(){
	debugger;
	var controle = 0;
	for (i=0;i<document.FRMenquete.elements.length;i++){
		if (document.FRMenquete.elements[i].type == "radio"){
			if (document.FRMenquete.elements[i].checked == true){
				controle++;
			}
		}
	}
	if (controle <= 0){
		alert("Selecione uma das opções");
		return false;
	}else{
		postaForm('FRMenquete');
	}
}

function validaInspecao(frmDados){
	if(frmDados.txtData.value == "") {
		alert("Campo obrigatorio!");
		frmDados.txtData.focus();
		return false;
	}
	if(frmDados.txtNumero.value == "") {
		alert("Campo obrigatorio!");
		frmDados.txtNumero.focus();
		return false;
	}
	if(frmDados.txtCliente.value == "") {
		alert("Campo obrigatorio!");
		frmDados.txtCliente.focus();
		return false;
	}
	if(frmDados.txtEmpreendimento.value == "") {
		alert("Campo obrigatorio!");
		frmDados.txtEmpreendimento.focus();
		return false;
	}
	if(!checkemail(frmDados.txtEmail.value)){
		return false;
	}
	if(frmDados.txtUnidade.value == "") {
		alert("Campo obrigatorio!");
		frmDados.txtUnidade.focus();
		return false;
	}
	if(frmDados.idEquipamento.value == 0) {
		alert("Campo obrigatorio!");
		frmDados.idEquipamento.focus();
		return false;
	}
	if(frmDados.txtIdentificacao.value == "") {
		alert("Campo obrigatorio!");
		frmDados.txtIdentificacao.focus();
		return false;
	}
	if(frmDados.idGrauInspecao.value == 0) {
		alert("Campo obrigatorio!");
		frmDados.idGrauInspecao.focus();
		return false;
	}
	if(frmDados.idTipoInspecao.value == 0) {
		alert("Campo obrigatorio!");
		frmDados.idTipoInspecao.focus();
		return false;
	}
	if(frmDados.idExecutante.value == 0) {
		alert("Campo obrigatorio!");
		frmDados.idExecutante.focus();
		return false;
	}
}

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 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 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();
}

function validaBusca (nForm) {
	var Form = formPeloNome(nForm);
	if((Form.txtBusca.value == "") || (Form.txtBusca.value == "Texto")) {
		alert("Informe o texto a ser pesquisado!");
		Form.txtBusca.focus();
		return false;
	}
	postaForm(nForm)
	return true;
}

function validaRestrita (nForm) {
	var Form = formPeloNome(nForm);
	if(Form.txtUser.value == "") {
		alert("Informe o Usuário!");
		Form.txtUser.focus();
		return false;
	}
	if(Form.txtPass.value == "") {
		alert("Informe a Senha!");
		Form.txtPass.focus();
		return false;
	}
	postaForm(nForm)
	return true;
}

// Valida Formulário de envio de contato
function validaForm(frm){

if((frm.nome.value=='') || (frm.nome.value=='Nome')){
	alert("Campo Obrigatório!")
	frm.nome.focus();
	frm.nome.style.background='#FFFFE5';
	return false
	}
if((frm.email.value=='') || (frm.email.value=='E-mail')){
	alert("Campo Obrigatório!")
	frm.email.focus();
	frm.email.style.background='#FFFFE5';
	return false		
}else{
	 if(checkemail(frm.email.value)==false){
	  return false     
	  }
}
if((frm.assunto.value=='') || (frm.assunto.value=='Assunto')){
	alert("Campo Obrigatório!")
	frm.assunto.focus();
	frm.assunto.style.background='#FFFFE5';
	return false
	}

if((frm.mensagem.value=='') || (frm.mensagem.value=='Mensagem')){
	alert("Campo Obrigatório!")
	frm.mensagem.focus();
	frm.mensagem.style.background='#FFFFE5';
	return false
	}
} 	 

// Valida Formulário de envio de comentario
function validaComentario(){
if((document.frmComment.nome.value=='') || (document.frmComment.nome.value=='Nome')){
	alert("Campo Obrigatório!")
	document.frmComment.nome.focus();
	document.frmComment.nome.style.background='#FFFFE5';
	return false
	}
if((document.frmComment.texto.value=='') || (document.frmComment.texto.value=='Mensagem')){
	alert("Campo Obrigatório!")
	document.frmComment.texto.focus();
	document.frmComment.texto.style.background='#FFFFE5';
	return false
	}
postaForm('frmComment');
return true;
} 	 

// Valida Formulário de busca
function validaBusca (nForm) {
	var Form = formPeloNome(nForm);
	if((Form.txtBusca.value == "") || (Form.txtBusca.value == "Texto")) {
		alert("Informe o texto a ser pesquisado!");
		Form.txtBusca.focus();
		return false;
	}
	postaForm(nForm);
	return true;
}

