// JavaScript Document

function openAjax() {

var ajax;

try{
    ajax = new XMLHttpRequest();
}
catch(ee){
    try{
        ajax = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            ajax = new ActiveXObject("Microsoft.XMLHTTP");
        }
		catch(E){
            ajax = false;
        }
    }
}
return ajax;
}




function OcultarGlobal(campo) {

	divAgenda  = document.getElementById(campo);
	divAgenda.style.visibility = "hidden";

}

function MsgGlobal(texto, campo) {

	divAgenda  = document.getElementById(campo);
	divAgenda.style.visibility = "visible";
	divAgenda.innerHTML = texto;


}



function validaUsuario() {
	
	if (document.FormCadastro.nome.value == ""){ 
		MsgGlobal("O campo NOME não está preenchido", "LocalAdvertencias"); 
		document.FormCadastro.nome.focus(); 
		document.FormCadastro.nome.style.background="#D2E9FF";
		return (false); 
	}


	if (document.FormCadastro.email.value == ""){ 
		MsgGlobal("O campo E-MAIL não está preenchido", "LocalAdvertencias"); 
		document.FormCadastro.email.focus(); 
		document.FormCadastro.email.style.background="#D2E9FF";
		return (false); 
	}

		parte1=document.FormCadastro.email.value.indexOf("@");
		parte2=document.FormCadastro.email.value.indexOf(".");
		parte3=document.FormCadastro.email.value.length;

	
	if(!(parte1>=3 && parte2 >= 6 && parte3 >= 9)) {
		MsgGlobal("O campo E-MAIL não está preenchido corretamente", "LocalAdvertencias"); 
		document.FormCadastro.email.focus(); 
		document.FormCadastro.email.style.background="#D2E9FF";
		return (false); 
	}


	if (document.FormCadastro.ddd.value == ""){ 
		MsgGlobal("O campo TELEFONE não está preenchido", "LocalAdvertencias"); 
		document.FormCadastro.ddd.focus(); 
		document.FormCadastro.ddd.style.background="#D2E9FF";
		return (false); 
	}

	if (document.FormCadastro.telefone.value == ""){ 
		MsgGlobal("O campo TELEFONE não está preenchido", "LocalAdvertencias"); 
		document.FormCadastro.telefone.focus(); 
		document.FormCadastro.telefone.style.background="#D2E9FF";
		return (false); 
	}

	if (document.FormCadastro.senha.value == ""){ 
		MsgGlobal("O campo SENHA não está preenchido", "LocalAdvertencias"); 
		document.FormCadastro.senha.focus(); 
		document.FormCadastro.senha.style.background="#D2E9FF";
		return (false); 
	}

	if (document.FormCadastro.re_senha.value == ""){ 
		MsgGlobal("O campo CONFIRMAÇÃO DE SENHA não está preenchido", "LocalAdvertencias"); 
		document.FormCadastro.re_senha.focus(); 
		document.FormCadastro.re_senha.style.background="#D2E9FF";
		return (false); 
	}


	if (document.FormCadastro.senha.value != document.FormCadastro.re_senha.value){ 
		MsgGlobal("A SENHA e a CONFIRMAÇÃO DE SENHA não estão iguais", "LocalAdvertencias"); 
		document.FormCadastro.re_senha.focus(); 
		document.FormCadastro.re_senha.style.background="#D2E9FF";
		return (false); 
	}

}




function validaLogin() {
	
	if (document.FormLogin.email.value == ""){ 
		MsgGlobal("O campo E-MAIL não está preenchido", "LocalAdvertencias"); 
		document.FormLogin.email.focus(); 
		document.FormLogin.email.style.background="#D2E9FF";
		return (false); 
	}

		parte1=document.FormLogin.email.value.indexOf("@");
		parte2=document.FormLogin.email.value.indexOf(".");
		parte3=document.FormLogin.email.value.length;

	
	if(!(parte1>=3 && parte2 >= 6 && parte3 >= 9)) {
		MsgGlobal("O campo E-MAIL não está preenchido corretamente", "LocalAdvertencias"); 
		document.FormLogin.email.focus(); 
		document.FormLogin.email.style.background="#D2E9FF";
		return (false); 
	}

	if (document.FormLogin.senha.value == ""){ 
		MsgGlobal("O campo SENHA não está preenchido", "LocalAdvertencias"); 
		document.FormLogin.senha.focus(); 
		document.FormLogin.senha.style.background="#D2E9FF";
		return (false); 
	}

}



function validaNoticiaEmail() {
	
	if (document.FormEmail.seu_nome.value == ""){ 
		MsgGlobal("O campo SEU NOME não está preenchido", "LocalAdvertencias"); 
		document.FormEmail.seu_nome.focus(); 
		document.FormEmail.seu_nome.style.background="#D2E9FF";
		return (false); 
	}

	if (document.FormEmail.seu_email.value == ""){ 
		MsgGlobal("O SEU E-MAIL não está preenchido", "LocalAdvertencias"); 
		document.FormEmail.seu_email.focus(); 
		document.FormEmail.seu_email.style.background="#D2E9FF";
		return (false); 
	}


		parte1=document.FormEmail.seu_email.value.indexOf("@");
		parte2=document.FormEmail.seu_email.value.indexOf(".");
		parte3=document.FormEmail.seu_email.value.length;

	
	if(!(parte1>=3 && parte2 >= 6 && parte3 >= 9)) {
		MsgGlobal("O SEU E-MAIL não está preenchido corretamente", "LocalAdvertencias"); 
		document.FormEmail.seu_email.focus(); 
		document.FormEmail.seu_email.style.background="#D2E9FF";
		return (false); 
	}


	if (document.FormEmail.email1.value == ""){ 
		MsgGlobal("O E-MAIL DO DESTINATÁRIO não está preenchido", "LocalAdvertencias"); 
		document.FormEmail.email1.focus(); 
		document.FormEmail.email1.style.background="#D2E9FF";
		return (false); 
	}


		parte1=document.FormEmail.email1.value.indexOf("@");
		parte2=document.FormEmail.email1.value.indexOf(".");
		parte3=document.FormEmail.email1.value.length;

	
	if(!(parte1>=3 && parte2 >= 6 && parte3 >= 9)) {
		MsgGlobal("O E-MAIL DO DESTINATÁRIO não está preenchido corretamente", "LocalAdvertencias"); 
		document.FormEmail.email1.focus(); 
		document.FormEmail.email1.style.background="#D2E9FF";
		return (false); 
	}

}



function ehNumerico(teclapres){
   if((teclapres.keyCode >= 48 && teclapres.keyCode <= 57) || (teclapres.keyCode >= 96 && teclapres.keyCode <= 105))
      return true;
   else
      return false;   
}





function ehNumericoPlus(teclapres){
   if (ehNumerico(teclapres) || teclapres.keyCode == 8 ||
       teclapres.keyCode == 37 || teclapres.keyCode == 39 ||
       teclapres.keyCode == 46 || teclapres.keyCode == 9)
      return true;
   else
      return false;   		
}




function FormataTelefone(campo,tammax,teclapres) {
	if (!ehNumericoPlus(teclapres)) {
	   teclapres.returnValue = false;
	   return;  
	}   
	
	var tecla = teclapres.keyCode;
	vr = campo.value;
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 13){
	  tam = vr.length + 1 ; 

 	  if (tecla == 8 ){	
 	  	tam = tam - 1 ; 
 	  }
	  if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 4 ){ 
	 		campo.value = vr ; 
	 	}
	 	if ( (tam > 8) && (tam <= 13) ){
	 		campo.value = vr.substr( 0, tam - 8 ) + '-' + vr.substr( tam - 8, tam ) ; 
	 	}
	 	if ( (tam > 1) && (tam <= 13) ){
	 		campo.value = vr.substr( 0, tam - 1 ) + '-' + vr.substr( tam - 1, tam ) ; 
	 	}
	 	if ( (tam > 4) && (tam <= 13) ){
	 		campo.value = vr.substr( 0, tam - 4 ) + '-' + vr.substr( tam - 4, tam ) ; 
	 	}
	 	
	  }
	}
}



function FormataNumero(campo,tammax,teclapres) {
	if (!ehNumericoPlus(teclapres)) {
	   teclapres.returnValue = false;
	   return;  
	}   
}


function Popup(url, nome, x, y) {

window.open( url, nome, 'scrollbars=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=yes, copyhistory=no, height='+ x +', width='+ y +', top='+(screen.height - x)/2+', left='+(screen.width - y)/2);
	
}

function PopupForum(url, nome, x, y) {

window.open( url, nome, 'scrollbars=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no, copyhistory=no, height='+ x +', width='+ y +', top='+(screen.height - x)/2+', left='+(screen.width - y)/2);
	
}


function ValidaEnquete() {

   marcado = -1
   
   for (i=0; i< document.FormEnquete.enquete.length; i++) {
      if (document.FormEnquete.enquete[i].checked) {
         marcado = i
         resposta = document.FormEnquete.enquete[i].value
      }
   }
   
   if (marcado == -1) {
   
      CaixaAlerta("2", "Selecione uma opção para votar !!!");
      document.FormEnquete.enquete[0].focus();
      return false;
	  
   }
   
      return true;
	  
} 



function ValidaBusca() {
	
	if (document.FormBusca.valor.value.length < 3){ 
		alert("Sua busca deve conter pelo menos 3 caracteres"); 
		document.FormBusca.valor.focus(); 
		document.FormBusca.valor.style.background="#D2E9FF";
		return (false); 
	}

}


function validaContato() {
	
	if (document.FormContato.nome.value == ""){ 
		CaixaAlerta("2", "O campo NOME não está preenchido");
		document.FormContato.nome.focus(); 
		document.FormContato.nome.style.background="#D2E9FF";
		return (false); 
	}

	if (document.FormContato.email.value == ""){ 
		CaixaAlerta("2", "O campo E-MAIL não está preenchido");
		document.FormContato.email.focus(); 
		document.FormContato.email.style.background="#D2E9FF";
		return (false); 
	}

		parte1=document.FormContato.email.value.indexOf("@");
		parte2=document.FormContato.email.value.indexOf(".");
		parte3=document.FormContato.email.value.length;

	
	if(!(parte1>=3 && parte2 >= 6 && parte3 >= 9)) {
		CaixaAlerta("2", "O campo E-MAIL não está preenchido corretamente");
		document.FormContato.email.focus(); 
		document.FormContato.email.style.background="#D2E9FF";
		return (false); 
	}

	if (document.FormContato.aabb.value == ""){ 
		CaixaAlerta("2", "O campo AABB COMUNIDADE não está preenchido");
		document.FormContato.aabb.focus(); 
		document.FormContato.aabb.style.background="#D2E9FF";
		return (false); 
	}

	if (document.FormContato.ddd.value == ""){ 
		CaixaAlerta("2", "O campo TELEFONE não está preenchido");
		document.FormContato.ddd.focus(); 
		document.FormContato.ddd.style.background="#D2E9FF";
		return (false); 
	}

	if (document.FormContato.telefone.value == ""){ 
		CaixaAlerta("2", "O campo TELEFONE não está preenchido");
		document.FormContato.telefone.focus(); 
		document.FormContato.telefone.style.background="#D2E9FF";
		return (false); 
	}


	if (document.FormContato.comentarios.value == ""){ 
		CaixaAlerta("2", "O COMENTÁRIO não está preenchido");
		document.FormContato.comentarios.focus(); 
		document.FormContato.comentarios.style.background="#D2E9FF";
		return (false); 
	}

}



function validaIdentidade() {
	
	if (document.FormIdentidade.nome.value == ""){ 
		CaixaAlerta("2", "O campo NOME não está preenchido"); 
		document.FormIdentidade.nome.focus(); 
		document.FormIdentidade.nome.style.background="#D2E9FF";
		return (false); 
	}

	if (document.FormIdentidade.email.value == ""){ 
		CaixaAlerta("2", "O campo E-MAIL não está preenchido"); 
		document.FormIdentidade.email.focus(); 
		document.FormIdentidade.email.style.background="#D2E9FF";
		return (false); 
	}

		parte1=document.FormIdentidade.email.value.indexOf("@");
		parte2=document.FormIdentidade.email.value.indexOf(".");
		parte3=document.FormIdentidade.email.value.length;

	
	if(!(parte1>=3 && parte2 >= 6 && parte3 >= 9)) {
		CaixaAlerta("2", "O campo E-MAIL não está preenchido corretamente"); 
		document.FormIdentidade.email.focus(); 
		document.FormIdentidade.email.style.background="#D2E9FF";
		return (false); 
	}

	if (document.FormIdentidade.ddd.value == ""){ 
		CaixaAlerta("2", "O campo TELEFONE não está preenchido"); 
		document.FormIdentidade.ddd.focus(); 
		document.FormIdentidade.ddd.style.background="#D2E9FF";
		return (false); 
	}

	if (document.FormIdentidade.prefixo.value == ""){ 
		CaixaAlerta("2", "O campo TELEFONE não está preenchido"); 
		document.FormIdentidade.prefixo.focus(); 
		document.FormIdentidade.prefixo.style.background="#D2E9FF";
		return (false); 
	}

	if (document.FormIdentidade.sufixo.value == ""){ 
		CaixaAlerta("2", "O campo TELEFONE não está preenchido"); 
		document.FormIdentidade.sufixo.focus(); 
		document.FormIdentidade.sufixo.style.background="#D2E9FF";
		return (false); 
	}


	if (document.FormIdentidade.comentarios.value == ""){ 
		CaixaAlerta("2", "A DESTINAÇÃO não está preenchida"); 
		document.FormIdentidade.comentarios.focus(); 
		document.FormIdentidade.comentarios.style.background="#D2E9FF";
		return (false); 
	}

}



function FormataData(campo, tammax, teclapres) {
    
    if (!ehNumericoPlus(teclapres)) {
	   teclapres.returnValue = false;
	   return;  
	}   
			
	var tecla = teclapres.keyCode;
	vr = campo.value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length + 1;

	if ( tecla != 9 && tecla != 8 ){
		if ( tam > 2 && tam < 5 )
			campo.value = vr.substr( 0, tam - 2  ) + '-' + vr.substr( tam - 2, tam );
		if ( tam >= 5 && tam <= 10 )
			campo.value = vr.substr( 0, 2 ) + '-' + vr.substr( 2, 2 ) + '-' + vr.substr( 4, 4 ); 
	}
	
	
}


function FormataCep(campo,tammax,teclapres) {
	if (!ehNumericoPlus(teclapres)) {
	   teclapres.returnValue = false;
	   return;  
	}   
	
	var tecla = teclapres.keyCode;
	vr = campo.value;
	vr = vr.replace( "-", "" );
	vr = vr.replace( ".", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){
	  tam = vr.length + 1 ; 

 	  if (tecla == 8 ){	tam = tam - 1 ; }
		
	  if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 3 ){ 
	 		campo.value = vr ; }
	 	if ( (tam > 3) && (tam <= 6) ){
	 		campo.value = vr.substr( 0, tam - 3 ) + '-' + vr.substr( tam - 3, tam ) ; }
	 	if ( (tam >= 7) && (tam <= 8) ){
	 		campo.value = vr.substr( 0, tam - 6 ) + '' + vr.substr( tam - 6, 3 ) + '-' + vr.substr( tam - 3, tam ) ; }
	  }		
	}
}





function validaTrocaSenha() {
	
	if (document.FormSenha.senha.value == ""){ 
		alert("O campo SENHA não está preenchido"); 
		document.FormSenha.senha.focus(); 
		document.FormSenha.senha.style.background="#D2E9FF";
		return (false); 
	}


	if (document.FormCadastro.nova_senha.value == ""){ 
		alert("O campo NOVA SENHA não está preenchido"); 
		document.FormCadastro.nova_senha.focus(); 
		document.FormCadastro.nova_senha.style.background="#D2E9FF";
		return (false); 
	}

	if (document.FormCadastro.redigite.value == ""){ 
		alert("O campo NOVA SENHA não está preenchido");
		document.FormCadastro.redigite.focus(); 
		document.FormCadastro.redigite.style.background="#D2E9FF";
		return (false); 
	}


	if (document.FormCadastro.senha.value != document.FormCadastro.re_senha.value){ 
		alert("A SENHA e a CONFIRMAÇÃO DE SENHA não estão iguais"); 
		document.FormCadastro.re_senha.focus(); 
		document.FormCadastro.re_senha.style.background="#D2E9FF";
		return (false); 
	}

}

//-->