// Documento JavaScript
<!--
// FUNÇÃO QUE VALIDA O FORMULÁRIO PARA ASSOCIAR-SE AO SITE
function validarAssociar(){
	d = document.formAssociar; // atalho para o formulário
	
	// Valida nome
	if (d.nome.value == ""){
		alert("Você Deve Preencher o Campo 'Nome'");
		d.nome.focus();
		return false;
	}
	
	// Valida Data de Nascimento
	if (d.data_nasc.value == ""){
		alert("Você Deve Preencher o Campo 'Data de Nascimento'");
		d.data_nasc.focus();
		return false;
	}
	
	// Valida Data de Nascimento
	if (d.data_nasc.value == ""){
		alert("Você Deve Preencher o Campo 'Data de Nascimento'");
		d.data_nasc.focus();
		return false;
	}
	
	 erro=0;
	 nasce = d.data_nasc.value;
	 hoje = new Date();
	 anoAtual = hoje.getFullYear();
	 barras = nasce.split("/");
	 if (barras.length == 3){
			   dia = barras[0];
			   mes = barras[1];
			   ano = barras[2];
			   resultado = (!isNaN(dia) && (dia > 0) && (dia < 32)) && (!isNaN(mes) && (mes > 0) && (mes < 13)) && (!isNaN(ano) && (ano.length == 4) && (ano <= anoAtual && ano >= 1900));
			   if (!resultado) {
						 alert("Formato de data invalido!");
						 d.data_nasc.focus();
						 return false;
			   }
	 } else {
			   alert("Formato de data invalido!");
			   d.data_nasc.focus();
			   return false;
	 }
	
	//validar email
	 if (d.email.value == ""){
			   alert("Você Deve Preencher o Campo 'E-mail'");
			   d.email.focus();			   
			   return false;
	 }
         
	 //validar email(verificao de endereco eletrônico)
	 parte1 = d.email.value.indexOf("@");
	 parte2 = d.email.value.indexOf(".");
	 parte3 = d.email.value.length;
	 if (!(parte1 >= 3 && parte2 >= 6 && parte3 >= 9)) {
			   alert ("O campo 'E-mail' deve conter um endereco eletrônico válido");
			   d.email.focus();
			   return false;
	 }
	 
	 // Valida Telefone Residencial
	if (d.ddd_res.value == ""){
		alert("Você Deve Preencher o Campo 'Telefone' com um DDD");
		d.ddd_res.focus();
		return false;
	}		 
	
	if (d.tel_res.value == ""){
		alert("Você Deve Preencher o Campo 'Telefone'");
		d.tel_res.focus();
		return false;
	}
	
	 // Valida RG
	if (d.rg.value == ""){
		alert("Você Deve Preencher o Campo 'RG'");
		d.rg.focus();
		return false;
	}		 
	
	if (d.orgao_exp.value == ""){
		alert("Você Deve Preencher o Campo 'òrgão Expedidor' do seu RG");
		d.orgao_exp.focus();
		return false;
	}
	
	 //validar CPF
           if (d.cpf.value == ""){
                     alert("Você Deve Preencher o Campo 'CPF'");
                     d.cpf.focus();
                     return false;
           }
		   
  
    cpf2 = d.cpf.value;
	erro = new String;
	if (cpf2.length < 11) erro += "São necessários 11 dígitos para verificação do CPF! "; 
	var nonNumbers = /\D/;
	if (nonNumbers.test(cpf2)) erro += "A verificação de CPF suporta apenas números! "; 
		if (cpf2 == "00000000000" || cpf2 == "11111111111" || cpf2 == "22222222222" || cpf2 == "33333333333" || cpf2 == "44444444444" || cpf2 == "55555555555" || cpf2 == "66666666666" || cpf2 == "77777777777" || cpf2 == "88888888888" || cpf2 == "99999999999"){
			erro += "Número de CPF inválido!"
   		}
    var a = [];
    var b = new Number;
    var c = 11;
    for (i=0; i<11; i++){
		 a[i] = cpf2.charAt(i);
		 if (i < 9) b += (a[i] * --c);
   }	
  if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
   b = 0;
   c = 11;
   for (y=0; y<10; y++) b += (a[y] * c--); 
   if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
   if ((cpf2.charAt(9) != a[9]) || (cpf2.charAt(10) != a[10])){
		   erro +="Dígito verificador com problema!";
   }
   if (erro.length > 0){
		   alert(erro);
		   d.cep.focus();
		   return false;
   }

	
 	//validar cidade
   if (d.cidade.value == ""){
			 alert("Você Deve Preencher o Campo 'Cidade'");
			 d.cidade.focus();
			 return false;
   }
   
   //validar estado
   if (d.uf.value == ""){
			 alert("Você Deve Escolher um valor para o Campo 'UF'");
			 d.uf.focus();
			 return false;
   }
   
    // Valida Igreja
	if (d.igreja.value == ""){
		alert("Você Deve Preencher o Campo 'Igreja'");
		d.igreja.focus();
		return false;
	}
	
	return true;
}

// FUNÇÃO QUE VALIDA O FORMULÁRIO PARA INSCREVER-SE NA CONSULTA
function validarInscricao(){
	d = document.formInscricao; // atalho para o formulário
	
	// Valida nome
	if (d.nome.value == ""){
		alert("Você Deve Preencher o Campo 'Nome'");
		d.nome.focus();
		return false;
	}
	
	// Valida Data de Nascimento
	if (d.data_nasc.value == ""){
		alert("Você Deve Preencher o Campo 'Data de Nascimento'");
		d.data_nasc.focus();
		return false;
	}
	
	// Valida Data de Nascimento
	if (d.data_nasc.value == ""){
		alert("Você Deve Preencher o Campo 'Data de Nascimento'");
		d.data_nasc.focus();
		return false;
	}
	
	 erro=0;
	 nasce = d.data_nasc.value;
	 hoje = new Date();
	 anoAtual = hoje.getFullYear();
	 barras = nasce.split("/");
	 if (barras.length == 3){
			   dia = barras[0];
			   mes = barras[1];
			   ano = barras[2];
			   resultado = (!isNaN(dia) && (dia > 0) && (dia < 32)) && (!isNaN(mes) && (mes > 0) && (mes < 13)) && (!isNaN(ano) && (ano.length == 4) && (ano <= anoAtual && ano >= 1900));
			   if (!resultado) {
						 alert("Formato de data invalido!");
						 d.data_nasc.focus();
						 return false;
			   }
	 } else {
			   alert("Formato de data invalido!");
			   d.data_nasc.focus();
			   return false;
	 }
	
	//validar email
	 if (d.email.value == ""){
			   alert("Você Deve Preencher o Campo 'E-mail'");
			   d.email.focus();			   
			   return false;
	 }
         
	 //validar email(verificao de endereco eletrônico)
	 parte1 = d.email.value.indexOf("@");
	 parte2 = d.email.value.indexOf(".");
	 parte3 = d.email.value.length;
	 if (!(parte1 >= 3 && parte2 >= 6 && parte3 >= 9)) {
			   alert ("O campo 'E-mail' deve conter um endereco eletrônico válido");
			   d.email.focus();
			   return false;
	 }
	 
	 // Valida Telefone Residencial
	if (d.ddd_res.value == ""){
		alert("Você Deve Preencher o Campo 'Telefone' com um DDD");
		d.ddd_res.focus();
		return false;
	}		 
	
	if (d.tel_res.value == ""){
		alert("Você Deve Preencher o Campo 'Telefone'");
		d.tel_res.focus();
		return false;
	}
	
	 // Valida RG
	if (d.rg.value == ""){
		alert("Você Deve Preencher o Campo 'RG'");
		d.rg.focus();
		return false;
	}		 
	
	if (d.orgao_exp.value == ""){
		alert("Você Deve Preencher o Campo 'òrgão Expedidor' do seu RG");
		d.orgao_exp.focus();
		return false;
	}
	
	 //validar CPF
           if (d.cpf.value == ""){
                     alert("Você Deve Preencher o Campo 'CPF'");
                     d.cpf.focus();
                     return false;
           }
		   
  
    cpf2 = d.cpf.value;
	erro = new String;
	if (cpf2.length < 11) erro += "São necessários 11 dígitos para verificação do CPF! "; 
	var nonNumbers = /\D/;
	if (nonNumbers.test(cpf2)) erro += "A verificação de CPF suporta apenas números! "; 
		if (cpf2 == "00000000000" || cpf2 == "11111111111" || cpf2 == "22222222222" || cpf2 == "33333333333" || cpf2 == "44444444444" || cpf2 == "55555555555" || cpf2 == "66666666666" || cpf2 == "77777777777" || cpf2 == "88888888888" || cpf2 == "99999999999"){
			erro += "Número de CPF inválido!"
   		}
    var a = [];
    var b = new Number;
    var c = 11;
    for (i=0; i<11; i++){
		 a[i] = cpf2.charAt(i);
		 if (i < 9) b += (a[i] * --c);
   }	
  if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
   b = 0;
   c = 11;
   for (y=0; y<10; y++) b += (a[y] * c--); 
   if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
   if ((cpf2.charAt(9) != a[9]) || (cpf2.charAt(10) != a[10])){
		   erro +="Dígito verificador com problema!";
   }
   if (erro.length > 0){
		   alert(erro);
		   d.cep.focus();
		   return false;
   }

	
 	//validar cidade
   if (d.cidade.value == ""){
			 alert("Você Deve Preencher o Campo 'Cidade'");
			 d.cidade.focus();
			 return false;
   }
   
   //validar estado
   if (d.uf.value == ""){
			 alert("Você Deve Escolher um valor para o Campo 'UF'");
			 d.uf.focus();
			 return false;
   }  

}
// FUNÇÃO PARA VALIDAR STROCAS DE SENHAS

function validarSenha(){
	d = document.formTrocarSenha; // atalho para o formulário
	
		// Valida Senha
	if (d.senha.value == ""){
		alert("Você deve digitar uma nova senha");
		d.senha.focus();
		return false;
	}
	
	// Valida Contra-Senha
	if (d.senha_conf.value == ""){
		alert("Você deve redigitar sua nova senha");
		d.senha_conf.focus();
		return false;
	}
	
	// Verificar senhas
	if (d.senha.value != d.senha_conf.value){
		alert("As senhas que você digitou são diferentes.\nPor favor, digite-as novamente");
		d.senha.value = "";
		d.senha_conf.value = "";
		d.senha.focus();
		return false;
	}
	
	return true;
}
// FUNÇÃO PARA PRÉ-CARREGAR AS IMAGENS DO MENU
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// FUNÇÃO PARA RESTAURAR A IMAGEM ALTERADA DO MENU
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

// FUNÇÃO PARA ALTERAR IMAGEM DO MENU
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function abrirFotoDivulgacao(Id){
	URL='popup_agenda.php?id='+Id;
	j=window.open(URL,'Imagem','menubar=no,scrollbars=no,resizable=no,width=5,height=5');
}

function abrirFotoRetiro(Id){
	URL='popup_retiro.php?id='+Id;
	j=window.open(URL,'Imagem','menubar=no,scrollbars=no,resizable=no,width=5,height=5');
}

// Script usado pra fazer a busca na biblia pela pagina principal
var no = /\D{1,}/;
expressao = "";
function livroSelect(myForm) {
   if (!no.test(myForm.lvBiblia.value)) {
    	expressao = "Testamento ou Livro\n"
   }   	
   if (!expressao){
       return true
   }
   else {
        expressao = "Informe:\n\n" + expressao
        alert(expressao)
        expressao=""
        return false
   }
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


// esconde os banners flutuantes
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


// FUNÇÃO QUE MOSTRA O CAMPO OUTROS GRUPOS

function mostraGrupo(valor){
	if (valor == "Outro"){		
		document.getElementById('grupoTxt').style.display = 'inline';
		document.getElementById('grupoInput').style.display = 'inline';
		
	}else{	
		document.getElementById('grupoTxt').style.display = 'none';
		document.getElementById('grupoInput').style.display = 'none';
	}
}

// FUNÇÃO QUE MOSTRA O CAMPO VALOR EM MANTENEDOR

function mostraMantenedor(valor){
	if (valor == "s"){		
		document.getElementById('mantenedorTr').style.display = 'inline';		
	}
	
	if (valor == "n"){	
		document.getElementById('mantenedorTr').style.display = 'none';
	}
}
// FUNÇÃO PARA ABRIR UMA POPUP COM A GALERIA DE FOTOS
function abrirgaleria(id)
{
 window.open("popup_galeria.php?id_evento="+id,"","resizable=no,toolbar=no,status=no,menubar=no,scrollbars=no,width=740,height=500");
}


// FUNÇÃO PARA ABRIR UMA PÁGINA DE UM SELECT
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//-->

