		// Valida alguns campos
		var vRdCartao
			function recuperaEndereco(pCEP) {
				// CEP
				// var cpCEP = document.getElementById('strCep');
				// if (!isNotEmpty(cpCEP, 'CEP é obrigatório!')) return false;
				
				/* PARAMETROS =========================== */
				var pNomeFrame	= 'fraCep';
				var sPagina		= 'retornaEndereco.asp?';
				var sParametros	= 'cep='+ pCEP.value;
				//alert(sParametros);
				//return;
				//window.open(sPagina + sParametros, pNomeFrame, '', '');
				document.frmCadastro.strNrLograd.value='';
				document.frmCadastro.strCompLograd.value='';
				window.open('retornaEndereco.asp?'+ sParametros, pNomeFrame, '', '');
			}

			function veriFormNovo(parFrm) {
				
				
			 var intA;
			 var strObjNome;
			 var objAtual;		 
			 for(intA = 0; intA < parFrm.length; intA++)
			 {
			  objAtual   = parFrm.elements[intA];			  
			  //strObjNome = objAtual.name;
			  strObjNome = objAtual.id;
			  
			  if (objAtual.name == "strCPFCNPJ" && objAtual.value.length != 0)
			  {
					if(!isCPF(objAtual, "CPF inválido!")) return false;
			  }
			  
			  
			  if(objAtual.type == "checkbox" && strObjNome.charAt(0) == "k" && objAtual.checked == false)
			  {
			   alert('Campo obrigatório não preenchido.');
			   objAtual.style.backgroundColor='#ff0000';
			   objAtual.focus();
			   return false;
			  }			  



			  if(objAtual.type == "radio" && strObjNome.charAt(0) == "k" && objAtual.checked == false)
			  {

				 if (strObjNome == "k_intSexoM")
				 {
					if (document.frmCadastro.k_intSexoF.checked == false)
					{
						alert('Campo obrigatório não preenchido.');
						objAtual.style.backgroundColor='#ff0000';
						objAtual.focus();
						return false;
					}else{
						continue;
					}
				 }

				 if (strObjNome == "k_intSexoF")
				 {
					if (document.frmCadastro.k_intSexoM.checked == false)
					{
						alert('Campo obrigatório não preenchido.');
						objAtual.style.backgroundColor='#ff0000';
						objAtual.focus();
						return false;
					}else{
						continue;
					}
				 }
				 
				 if (strObjNome == "k_radCatAfil")
				 {
					if (document.frmCadastro.k_radCatAfil.checked == false)
					{
						alert('Campo obrigatório não preenchido.');
						objAtual.style.backgroundColor='#ff0000';
						//objAtual.focus();
						return false;
					}else{
						continue;
					}
				 }
				 
				 
				 
				 if (strObjNome == "k_vlrDoacao")
				 {
					if (objAtual.checked == false)
					{
						alert('Campo obrigatório não preenchido / doação.');
						objAtual.style.backgroundColor='#ff0000';
						//objAtual.focus();
						return false;
					}else{
						continue;
					}
				 }
			  }
			  
 			//Cláusula do banco Hsbc para não ser obrigatório o dígito da conta		
				if (strObjNome == "k_strBancoContaDig")
					{
			   				
						if ((frmCadastro.strBancoContaDig.value.length == 0) && (frmCadastro.strCodBanco.value == 399 ))
						{
							return true;
							
						}
					}


 			//Cláusula do banco Hsbc para não ser obrigatório o dígito da conta		
				if (strObjNome == "k_strBancoContaDig")
					{
			   				
						if ((frmCadastro.strBancoContaDig.value.length == 0) && (frmCadastro.strCodBanco.value == 399 ))
						{
							return true;
							
						}
					}			  

			//Cláusula código de segurança do cartão de crédito	
			//Alterado por Jadilson no dia 31/10/2007 - Verificação do cod segurança (quantidade) dos cartões
				if (strObjNome == "k_strNrCodigo")
					{
						//alert(vRdCartao);						
						if (vRdCartao == 53 && document.frmCadastro.k_strNrCodigo.value.length != 4) {
							alert('No American Express, são os 4\ndígitos acima do número do cartão!')
							document.frmCadastro.k_strNrCodigo.focus();
							return false;
						}
						// Tipo de Cartão com Cod Segurança - Outros
						if (vRdCartao != 53 && document.frmCadastro.k_strNrCodigo.value.length != 3) {
							alert('Digite somente os três últimos\nnúmeros no verso do cartão!')
							document.frmCadastro.k_strNrCodigo.focus();
							return false;
						}						
/*
						switch (vRdCartao)
							{	
							case 53 :
								if (document.frmCadastro.k_strNrCodigo.value.length != 4)
									{
									alert('No American Express, são os 4 dígitos acima do número do cartão.');
									break;
									//return false;
									}
							default :							
								if (document.getElementById("k_strNrCodigo").value.length != 3)
									{
									alert('Dígito de segurança inválido!');
									break;
									//return false;
									}
							
							}													
*/							
					}

			if(objAtual.type != "radio" && strObjNome.charAt(0) == "k" && objAtual.value.length == 0)
			  {
			   alert('Campo obrigatório não preenchido.');
			   objAtual.style.backgroundColor='#ff0000';
			   objAtual.focus();
			   return false;
			   			//}
			  }	
			 }
			 
		
			return true;
			 
			}

		
			function FeiraEvento(pCampo) {							
				var Icombo = pCampo.selectedIndex;							
				//alert(pCampo.selectedIndex);
				//alert(pCampo.options[Icombo].text);
				if(pCampo.options[Icombo].text == 'Feira ou Evento')	
					MostraCampo(true, 'QualEvento');
					//alert("MostraCombo");
				else {
					MostraCampo(false, 'QualEvento');
					//alert("EscondeCombo");
					document.frmCadastro.cboFeiraEvento.value = '';
				}
			}						

		
			function Qual(check) {
				MostraCampo(check.checked, 'QualONG');
				if (!check.checked) {
					MostraCampo(false, 'OutraONG');
					document.frmCadastro.cboOutraOng.value = '';
					document.frmCadastro.strOutraOng.value = '';
				}
			}

		
			function Outra(pCampo) {
				var Icombo = pCampo.selectedIndex ;
				if(pCampo.options[Icombo].text == 'OUTRA')
					MostraCampo(true, 'OutraONG');
				else {
					MostraCampo(false, 'OutraONG');
					document.frmCadastro.strOutraOng.value = '';
				}
			}
			
			function QualPagto(check, pCampo, pIdBanco, pIdAgBanco, pIdBancoNome, pDigito, pTipo, mdAgencia,utAgencia,mdCcorrente,utCcorrente,qtDigCartao, qtCodCartao) {
			//alert(qtCodCartao);
				var texto
				
				frm = document.frmCadastro;
				//MostraCampo(false, 'cartao');
				//MostraCampo(false, 'debito');
				//MostraCampo(false, 'outros');

				if (pTipo != 2)
				{
					//MostraCampo(check.checked, pCampo);
					//If criado por Wellington, para fazer a verificaçào do dígito de segurança do cartão de crédito visa/AMEX v= variável rd=radio Cartao = Cartão de crédito

					if(pCampo.toLowerCase() == 'cartao') {
						if (pIdBanco == '1' )
								{

									splitString = document.frmCadastro.radTipoPagto[0].value.split("|")
									vRdCartao = splitString[1]

															}else{
															vRdCartao=pIdBanco
								}					
						/*
						frm.strBancoAgencia.value = '';
						frm.strBancoAgenciaDig.value = '';
						frm.strBancoConta.value = '';
						frm.strBancoContaDig.value = '';
						*/
						//check, pCampo, pIdBanco, pIdAgBanco, pIdBancoNome, pDigito, pTipo, mdAgencia,utAgencia,mdCcorrente,utCcorrente,qtDigCartao
						
					
						texto = "<span id=cartao style=display:>"
						texto = texto + "<table class='tabelaSemborda' cellpadding='0' border=0 width='100%' cellspacing='0'>"
						texto = texto + "<tr><td style='background-color: #E6E6E6' class='p_tit_frm'>"
						texto = texto + "&nbsp;&nbsp;N&ordm; do Cart&atilde;o: </td><td style='background-color: #E6E6E6' class='p_tit_frm'><input type=text name=strNrCartao id=k_strNrCartao size="+qtCodCartao+" maxlength="+qtCodCartao+"'></td></tr>"
						texto = texto + "<tr><td style='background-color: #E6E6E6' class='p_tit_frm'>&nbsp;&nbsp;Validade:</td> "
						texto = texto + "<td style='background-color: #E6E6E6' class='p_tit_frm'><select name=dteValidadeMes id=k_dteValidadeMes>"
						texto = texto + "<option value=></option>"
						
						var i
						for (i=1;i<=12;i++) {
						if (i<=9)
							{
							texto = texto + "<option value='0"+i+"'>"+getMesExtenso(i-1)+"</option>"
							}else{
							texto = texto + "<option value='"+ i +"'>"+getMesExtenso(i-1)+"</option>"
							}
						}
						
						texto = texto + "</select> de "
						texto = texto + "<select name=dteValidadeAno id=k_dteValidadeAno>"
						texto = texto + "<option value=></option>"
						
						var j
						for (j=2007;j<=2020;j++) {
							texto = texto + "<option value='"+j+"'>"+j+"</option>"
						}						
						texto = texto + "</select></td></tr>"
						if (qtDigCartao != ""){
						texto = texto + "<tr><td style='background-color: #E6E6E6' class='p_tit_frm'>&nbsp;&nbsp;CV:</td>"
						texto = texto + "<td style='background-color: #E6E6E6' class='p_tit_frm'><input type=text name=strNrCodigo id=k_strNrCodigo size="+qtDigCartao+" maxlength="+qtDigCartao+"'></td></tr>"
						texto = texto + "<tr><td style='background-color: #E6E6E6' class='p_tit_frm' colspan=2 align=right>(os números no verso do cartão.)</td></tr></table>"
						
						}
						texto = texto + "</span>"
						
						document.getElementById('camposvlrcartao').innerHTML=texto;
						document.getElementById('camposvlrdebito').innerHTML="";
					}
								
					if(pCampo.toLowerCase() == 'debito') {
						/*
						frm.strNrCartao.value = '';
						frm.dteValidadeMes.value = '';
						frm.dteValidadeAno.value = '';
						frm.strNrCodigo.value = '';
						frm.debTipoPagto.value=pIdBanco;
						frm.strCodBanco.value=pIdAgBanco;
						frm.strBancoNome.value=pIdBancoNome;
						*/
						
							
						texto = "<span id=debito style=display:>"
						texto = texto + "<table width='100%'  class='tabelaSemborda' cellpadding='0' cellspacing='0'>"
						texto = texto + "<tr><td style='background-color: #E6E6E6' class='p_tit_frm'>"
						texto = texto + "Banco: </td>"
						texto = texto + "<td style='background-color: #E6E6E6' class='p_tit_frm'><input type=Text name=strCodBanco id=strCodBanco value="+pIdAgBanco+" size=4 readonly>&nbsp;"
						texto = texto + "<input type=Text name=strBancoNome id=strBancoNome value='"+pIdBancoNome+"' size=20 readonly></td></tr>"
						texto = texto + "<tr><td style='background-color: #E6E6E6' class='p_tit_frm'>Ag&ecirc;ncia:</td>"
						texto = texto + "<td style='background-color: #E6E6E6' class='p_tit_frm'><input type=text name=strBancoAgencia id=k_strBancoAgencia size='"+mdAgencia+"' maxlength='"+mdAgencia+"' onKeyPress='return(soNumeros(this,event));'>&nbsp;"
						if (utAgencia == 1)
						{
							texto = texto + "<input type=text name=strBancoAgenciaDig id=k_strBancoAgenciaDig size=1 maxlength=1 style=display:''>"
						}						
						texto = texto + "</td></tr><tr><td style='background-color: #E6E6E6' class='p_tit_frm'>Conta Corrente:</td>"
						texto = texto + "<td style='background-color: #E6E6E6' class='p_tit_frm'><input type=text name=strBancoConta id=k_strBancoConta size='"+mdCcorrente+"' maxlength='"+mdCcorrente+"' onKeyPress='return(soNumeros(this,event));'> "
						if ((utCcorrente == "True") || (utCcorrente == 1))
						{
						texto = texto + "<input type=text name='strBancoContaDig' id=k_strBancoContaDig size=1 maxlength=1>"
						}
						texto = texto + "</td></tr></table><input type='hidden' name='debTipoPagto' id='debTipoPagto' value="+pIdBanco+"><br>"
						texto = texto + "</span>"

						document.getElementById('camposvlrdebito').innerHTML=texto;
						document.getElementById('camposvlrcartao').innerHTML="";
									
						/*
						if (pDigito == 0)
						{
							document.getElementById('strBancoAgenciaDig').style.display = 'none';
						}else{	
							document.getElementById('strBancoAgenciaDig').style.display = '';
						}
						*/
									
					}
								
					if(pCampo.toLowerCase() == 'outros') {
						frm.cboOperadOutros.value = '';
					}						
				} else {
				
				//	frm.debTipoPagto.value= pIdBanco;
				
				}
			}
//fim da função QUAL




			function getMesExtenso(mes){
				return this.arrayMes[mes];
			}

			function construirArray(qtdElementos){
				this.length = qtdElementos
			}

			var arrayMes = new construirArray(12);
			arrayMes[0] = "Janeiro";
			arrayMes[1] = "Fevereiro";
			arrayMes[2] = "Março";		
			arrayMes[3] = "Abril";
			arrayMes[4] = "Maio";
			arrayMes[5] = "Junho";
			arrayMes[6] = "Julho";
			arrayMes[7] = "Agosto";
			arrayMes[8] = "Setembro";
			arrayMes[9] = "Outubro";
			arrayMes[10] = "Novembro";
			arrayMes[11] = "Dezembro";

			function Ajax() {
				var ajax = null;
				if (window.ActiveXObject) {
					try {
						ajax = new ActiveXObject("Msxml2.XMLHTTP");	
					} catch (ex) {
						try {
							ajax = new ActiveXObject("Microsoft.XMLHTTP");
						} catch(ex2) {
							alert("Seu browser não suporta Ajax.");
						}			
					}
				} else {
					if (window.XMLHttpRequest) {
						try {
							ajax = new XMLHttpRequest();	
						} catch(ex3) {
							alert("Seu browser não suporta Ajax.");
						}	
					}	
				}				
				return ajax;
			}
			
			function checkCNPJEmpresa() {
				
								
				if (document.frmCadastro.strCPFCNPJ.value.length != 0)
				{					
				//	document.frmCadastro.submit.disabled = true;
				//	var oAjax = Ajax();
				//	oAjax.onreadystatechange = function() {						
				//		if (oAjax.readyState == 4 && oAjax.status == 200) {
				//			if (oAjax.responseText == "true") {
				//				alert("CPF já cadastrado. Favor cadastrar outro CPF!");
				//				document.frmCadastro.strCPFCNPJ.style.backgroundColor='#ff0000';
				//				document.frmCadastro.strCPFCNPJ.focus();
				//				document.frmCadastro.submit.disabled = true;
				//				return false;
				//			} else {							
								if (document.frmCadastro.strCPFCNPJ.value.length == 11){			
									if(!isCPF(document.frmCadastro.strCPFCNPJ, "CPF inválido!")) return false;
								}else if (document.frmCadastro.strCPFCNPJ.value.length == 14){
									
									if(valida_cnpj(document.frmCadastro.strCPFCNPJ.value) == false){
										alert("CNPJ inválido!");
										document.frmCadastro.strCPFCNPJ.focus();
										return false;
									}
								}
							//	document.frmCadastro.submit.disabled = false;
								return true;
				//			}
				//		}
				//	}
					
				//	oAjax.open("GET", "VerifyCPF.asp?CPF="+document.frmCadastro.strCPFCNPJ.value+"&IdPessoa=0", true);
				//	oAjax.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=iso-8859-1");
				//	oAjax.send(null);
				} else {
				//	document.frmCadastro.submit.disabled = false;
				}
			}	
			
			function TipoPagtoVal(lId)
			{
				document.frmCadastro.IdTipoPagto.value = lId;
			}
			
function valida_cnpj(cnpj)
      {
	  
	  var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;
      digitos_iguais = 1;
      if (cnpj.length < 14 && cnpj.length < 15)
            return false;
      for (i = 0; i < cnpj.length - 1; i++)
            if (cnpj.charAt(i) != cnpj.charAt(i + 1))
                  {
                  digitos_iguais = 0;
                  break;
                  }
      if (!digitos_iguais)
            {
            tamanho = cnpj.length - 2
            numeros = cnpj.substring(0,tamanho);
            digitos = cnpj.substring(tamanho);
            soma = 0;
            pos = tamanho - 7;
            for (i = tamanho; i >= 1; i--)
                  {
                  soma += numeros.charAt(tamanho - i) * pos--;
                  if (pos < 2)
                        pos = 9;
                  }
            resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
            if (resultado != digitos.charAt(0))
                  return false;
            tamanho = tamanho + 1;
            numeros = cnpj.substring(0,tamanho);
            soma = 0;
            pos = tamanho - 7;
            for (i = tamanho; i >= 1; i--)
                  {
                  soma += numeros.charAt(tamanho - i) * pos--;
                  if (pos < 2)
                        pos = 9;
                  }
            resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
            if (resultado != digitos.charAt(1))
                  return false;
            return true;
            }
      else
            return false;
      } 

	
			
		
