var urlAplicacao = "/petrossite/servicos/HotsiteAnaparPrev/Executaveis/AnaparPrev.exe"



  function ValidarForm(form){
    form.action = "";
	campoCPF     = new String(form.elements["CPF_LOGON"].value);
//    campoMat  = new String(form.elements["MATSIN_LOGON"].value);
//    campoNasc = new String(form.elements["DTNASC_LOGON"].value);  
  
    if (form.elements["ID_PJ_LOGON"].value == ""){
        window.alert("Empresa não informada.");
        form.elements["ID_PJ_LOGON"].focus();
	    return false;
    }else{
        if (campoCPF.length!=11){
            window.alert("CPF incorreto ou não informado.");
            form.elements["CPF_LOGON"].focus();
			return false;
        }else{
            form.action = "autenticador.asp"
          //form.submit();
    	    return true;
            }
        }            
    }
            
/*		}
		else if (campoNasc.length!=10){ 
      window.alert("Data Nascimento incorreta ou não informada.");
      form.elements["DTNASC_LOGON"].focus();
			return false;
    }
		else if (campoMat.length!=5){ 
      window.alert("Matricula incorreta ou não informada.");
      form.elements["MATSIN_LOGON"].focus();
			return false;*/
	
  function formEnter( form )
	{
	  var Evento = window.event?window.event:Event;
	  if (Evento.keyCode == 13) {
  		if (ValidarForm(form)){
				form.submit();
			} else { return false; }
		}
	}

//Funçao para compor barras na data
function valida_data(){
	DTNASC = new String(document.pi_inscricao.NASCIMENTO.value);
	tamDTNASC = DTNASC.length;
	if((tamDTNASC == 2)||(tamDTNASC == 5))
		{
	 		document.pi_inscricao.NASCIMENTO.value = document.pi_inscricao.NASCIMENTO.value + "/";
		}
}

function valida_data2(){
	DTNASC = new String(document.pi_inscricao.DT_EMISSAO_RG.value);
	tamDTNASC = DTNASC.length;
	if((tamDTNASC == 2)||(tamDTNASC == 5))
		{
	 		document.pi_inscricao.DT_EMISSAO_RG.value = document.pi_inscricao.DT_EMISSAO_RG.value + "/";
		}
}

function Acentuacao(valorcampo) {

	answer = new Array();
	entry = valorcampo
	
	if (entry != "") {
	
		for (var i=0; i<entry.length; i++){
		if (entry.charAt(i) == "Â") { answer = answer + "A"; }
		else
		if (entry.charAt(i) == "â") { answer = answer + "a"; }
		else
		if (entry.charAt(i) == "À") { answer = answer + "A"; }
		else
		if (entry.charAt(i) == "à") { answer = answer + "a"; }
		else
		if (entry.charAt(i) == "Á") { answer = answer + "A"; }
		else
		if (entry.charAt(i) == "á") { answer = answer + "a"; }
		else
		if (entry.charAt(i) == "Ã") { answer = answer + "A"; }
		else
		if (entry.charAt(i) == "ã") { answer = answer + "a"; }
		else
		if (entry.charAt(i) == "É") { answer = answer + "E"; }
		else
		if (entry.charAt(i) == "é") { answer = answer + "e"; }
		else
		if (entry.charAt(i) == "Ê") { answer = answer + "E"; }
		else
		if (entry.charAt(i) == "ê") { answer = answer + "e"; }
		else
		if (entry.charAt(i) == "Í") { answer = answer + "I"; }
		else
		if (entry.charAt(i) == "í") { answer = answer + "i"; }
		else
		if (entry.charAt(i) == "Ó") { answer = answer + "O"; }
		else
		if (entry.charAt(i) == "ó") { answer = answer + "o"; }
		else
		if (entry.charAt(i) == "Ô") { answer = answer + "O"; }
		else
		if (entry.charAt(i) == "ô") { answer = answer + "o"; }
		else
		if (entry.charAt(i) == "Õ") { answer = answer + "O"; }
		else
		if (entry.charAt(i) == "õ") { answer = answer + "o"; }
		else
		if (entry.charAt(i) == "Ú") { answer = answer + "U"; }
		else
		if (entry.charAt(i) == "ú") { answer = answer + "u"; }
		else
		if (entry.charAt(i) == "Ü") { answer = answer + "U"; }
		else
		if (entry.charAt(i) == "ü") { answer = answer + "u"; }
		else
		if (entry.charAt(i) == "Ç") { answer = answer + "C"; }
		else
		if (entry.charAt(i) == "ç") { answer = answer + "c"; }
		else{ answer = answer + entry.charAt(i); }
		}
		entry =  answer.toUpperCase();
		GuardaValor(entry)
	}
	else {
	GuardaValor(entry)
	}
}

function GuardaValor(entry){
return entry
}

function vogalAcentuada(s)
{
ls = s.toLowerCase();
if ((ls.indexOf("á")>=0) || (ls.indexOf("à")>=0) || (ls.indexOf("ã")>=0) || (ls.indexOf("â")>=0) || (ls.indexOf("é")>=0) || (ls.indexOf("í")>=0) || (ls.indexOf("ó")>=0) || (ls.indexOf("õ")>=0) || (ls.indexOf("ô")>=0) || (ls.indexOf("ú")>=0) || (ls.indexOf("ü")>=0))
return true;
}

function checkmail(email)
{
var s = new String(email);
if (s=="")
return true;
// { } ( ) < > [ ] | \ /
if ((s.indexOf("{")>=0) || (s.indexOf("}")>=0) || (s.indexOf("(")>=0) || (s.indexOf(")")>=0) || (s.indexOf("<")>=0) || (s.indexOf(">")>=0) || (s.indexOf("[")>=0) || (s.indexOf("]")>=0) || (s.indexOf("|")>=0) || (s.indexOf("\"")>=0) || (s.indexOf("/")>=0) )
return false;
if (vogalAcentuada(email))
return false;
// & * $ % ? ! ^ ~ ` ' "
if ((s.indexOf("&")>=0) || (s.indexOf("*")>=0) || (s.indexOf("$")>=0) || (s.indexOf("%")>=0) || (s.indexOf("?")>=0) || (s.indexOf("!")>=0) || (s.indexOf("^")>=0) || (s.indexOf("~")>=0) || (s.indexOf("`")>=0) || (s.indexOf("'")>=0) )
return false;
// , ; : = #
if ((s.indexOf(",")>=0) || (s.indexOf(";")>=0) || (s.indexOf(":")>=0) || (s.indexOf("=")>=0) || (s.indexOf("#")>=0) )
return false;
// procura se existe apenas um @
if ( (s.indexOf("@") < 0) || (s.indexOf("@") != s.lastIndexOf("@")) )
return false;
// verifica se tem pelo menos um ponto após o @
if (s.lastIndexOf(".") < s.indexOf("@"))
return false;
return true;
}

function VerificaCampos(){

// verificação modificação CEPs
if (document.pi_inscricao.CEP_RES.value != document.pi_inscricao.CEP_RES_ORI.value)
{
  alert("Você alterou o campo CEP residencial,\nportanto, deve clicar no botão 'atualizar' antes de prosseguir.");
	document.pi_inscricao.CEP_RES.focus();
	return;
}

if (document.pi_inscricao.CEP_COM.value != document.pi_inscricao.CEP_COM_ORI.value)
{
  alert("Você alterou o campo CEP comercial,\nportanto, deve clicar no botão 'atualizar' antes de prosseguir.");
	document.pi_inscricao.CEP_COM.focus();
	return;
}

if (document.pi_inscricao.NOME.value == ""){	
	alert ("O campo Nome deve ser preenchido!");
	return document.pi_inscricao.NOME.focus();
}

if (document.pi_inscricao.NASCIMENTO.value == ""){	
	alert ("O campo Data de Nascimento deve ser preenchido!");
	return document.pi_inscricao.NASCIMENTO.focus();
}
	
if (document.pi_inscricao.SEXO.value == ""){	
	alert ("O campo SEXO deve ser preenchido!");
	return document.pi_inscricao.SEXO.focus();
}
	
if (document.pi_inscricao.NACIONALIDADE.value == "-1"){	
	alert ("O campo NACIONALIDADE deve ser preenchido!");
	return document.pi_inscricao.NACIONALIDADE.focus();
}

if (document.pi_inscricao.NACIONALIDADE.value == "BRA")
{
  if (document.pi_inscricao.NATURALIDADE.value == "-1"){	
  	alert ("O campo NATURALIDADE deve ser preenchido!");
  	return document.pi_inscricao.NATURALIDADE.focus();
  }
}

if (document.pi_inscricao.NUM_RG_CRM.value == ""){	
	alert ("O campo NÚMERO DO RG ou CRM deve ser preenchido!");
	return document.pi_inscricao.NUM_RG_CRM.focus();
}

if (document.pi_inscricao.DT_EMISSAO_RG.value == ""){	
	alert ("O campo DATA DE EMISSÃO DO RG ou CRM deve ser preenchido!");
	return document.pi_inscricao.DT_EMISSAO_RG.focus();
}

if (document.pi_inscricao.ORGAO_RG.value == ""){	
	alert ("O campo ÓRGÃO DE EMISSÃO DO RG ou CRM deve ser preenchido!");
	return document.pi_inscricao.ORGAO_RG.focus();
}

if (document.pi_inscricao.UF_RG.value == "-1"){	
	alert ("O campo UF do RG ou CRM deve ser preenchido!");
	return document.pi_inscricao.UF_RG.focus();
}

if (document.pi_inscricao.ESTADOCIVIL.value == "-1" || document.pi_inscricao.ESTADOCIVIL.value == "9" ){	
	alert ("O campo ESTADO CIVIL deve ser preenchido!");
	return document.pi_inscricao.ESTADOCIVIL.focus();
}

if (document.pi_inscricao.CPF.value == ""){	
	alert ("O campo CPF deve ser preenchido!");
	return document.pi_inscricao.CPF.focus();
}

if (document.pi_inscricao.NOMEPAI.value == ""){	
	alert ("O campo NOME DO PAI deve ser preenchido!");
	return document.pi_inscricao.NOMEPAI.focus();
}

if (document.pi_inscricao.NOMEMAE.value == ""){	
	alert ("O campo NOME DO MAE deve ser preenchido!");
	return document.pi_inscricao.NOMEMAE.focus();
}

if (document.pi_inscricao.NUMERO_RES.value == ""){	
	alert ("O campo NÚMERO LOGRADOURO RESIDENCIAL deve ser preenchido!");
	return document.pi_inscricao.NUMERO_RES.focus();
}

if (document.pi_inscricao.CEP_RES.value == ""){	
	alert ("O campo CEP RESIDENCIAL deve ser preenchido!");
	return document.pi_inscricao.CEP_RES.focus();
}

if (document.pi_inscricao.PAIS_RES.value == "-1"){	
	alert ("O campo PAIS RESIDENCIAL deve ser preenchido!");
	return document.pi_inscricao.PAIS_RES.focus();
}

if (!checkmail(document.pi_inscricao.EMAIL_RES.value)){
	alert("Por favor, preencha corretamente o seu e-mail.");
    return document.pi_inscricao.EMAIL_RES.focus();
}

if (document.pi_inscricao.CEP_COM.value){

	if (document.pi_inscricao.CEP_COM.length < 8){	
		alert ("O campo CEP COMERCIAL não pode ter menos de 8 caracteres");
		return document.pi_inscricao.CEP_COM.focus();
	}

	if (document.pi_inscricao.LOGRADOURO_COM.value == ""){	
		alert ("O campo LOGRADOURO COMERCIAL deve ser preenchido!");
		return document.pi_inscricao.LOGRADOURO_COM.focus();
	}

	if (document.pi_inscricao.NUMERO_COM.value == ""){	
		alert ("O campo NÚMERO LOGRADOURO COMERCIAL deve ser preenchido!");
		return document.pi_inscricao.NUMERO_COM.focus();
	}
	
	if (document.pi_inscricao.BAIRRO_COM.value == ""){	
		alert ("O campo BAIRRO COMERCIAL deve ser preenchido!");
		return document.pi_inscricao.BAIRRO_COM.focus();
	}
	
	if (document.pi_inscricao.UF_COM.value == "-1"){	
		alert ("O campo UF COMERCIAL deve ser preenchido!");
		return document.pi_inscricao.UF_COM.focus();
	}
	
	if (document.pi_inscricao.CIDADE_COM.value == ""){	
		alert ("O campo CIDADE COMERCIAL deve ser preenchido!");
		return document.pi_inscricao.CIDADE_COM.focus();
	}

	if (document.pi_inscricao.CEP_COM.value == ""){	
		alert ("O campo CEP COMERCIAL deve ser preenchido!");
		return document.pi_inscricao.CEP_COM.focus();
	}

	if (document.pi_inscricao.PAIS_COM.value == "-1"){	
		alert ("O campo PAIS COMERCIAL deve ser preenchido!");
		return document.pi_inscricao.PAIS_COM.focus();
	}
	
}

if (document.pi_inscricao.TEL_RES.value == ""){	
	alert ("O campo TELEFONE RESIDENCIAL deve ser preenchido!");
	return document.pi_inscricao.TEL_RES.focus();
}

if (document.pi_inscricao.DDD_TEL_RES.value == ""){	
	alert ("O campo DDD do TELEFONE RESIDENCIAL deve ser preenchido!");
	return document.pi_inscricao.DDD_TEL_RES.focus();
}

if (document.pi_inscricao.DDD_TEL_RES.value == "00"){	
	alert ("O campo DDD do TELEFONE RESIDENCIAL não pode ser 0!");
	return document.pi_inscricao.DDD_TEL_RES.focus();
}

if (!checkmail(document.pi_inscricao.EMAIL_COM.value)){
	alert("Por favor, preencha corretamente o seu e-mail comercial.");
    return document.pi_inscricao.EMAIL_COM.focus();
}

if (document.pi_inscricao.DDD_TEL_COM.value == "00"){	
	alert ("O campo DDD DO TELEFONE COMERCIAL não pode ser 0!");
	return document.pi_inscricao.DDD_TEL_COM.focus();
}



//if (document.pi_inscricao.TEL_COM.value == ""){	
//	alert ("O campo TELEFONE COMERCIAL deve ser preenchido!");
//	return document.pi_inscricao.TEL_COM.focus();
//}
//else if (document.pi_inscricao.DDD_TEL_COM.value == ""){	
//	alert ("O campo DDD DO TELEFONE COMERCIAL também deve ser preenchido!");
//	return document.pi_inscricao.DDD_TEL_COM.focus();
//}

if (document.pi_inscricao.CEP_RES.length < 8){	
	alert ("O campo CEP RESIDENCIAL não pode ter menos de 8 caracteres");
	return document.pi_inscricao.CEP_RES.focus();
}









return VerificaCampos2();
}


function VerificaCampos2()
{
var valorcampo

do
	{
	valorcampo = document.pi_inscricao.NOME.value;
	Acentuacao(valorcampo);
	document.pi_inscricao.NOME.value = GuardaValor(entry);

	valorcampo = document.pi_inscricao.ORGAO_RG.value
	Acentuacao(valorcampo);
	document.pi_inscricao.ORGAO_RG.value = GuardaValor(entry);
	
	valorcampo = document.pi_inscricao.NOMEPAI.value;
	Acentuacao(valorcampo);
	document.pi_inscricao.NOMEPAI.value = GuardaValor(entry);

	valorcampo = document.pi_inscricao.NOMEMAE.value;
	Acentuacao(valorcampo);
	document.pi_inscricao.NOMEMAE.value = GuardaValor(entry);

	valorcampo = document.pi_inscricao.LOGRADOURO_RES.value;
	Acentuacao(valorcampo);
	document.pi_inscricao.LOGRADOURO_RES.value = GuardaValor(entry);

	valorcampo = document.pi_inscricao.COMPLEMENTO_RES.value;
	Acentuacao(valorcampo);
	document.pi_inscricao.COMPLEMENTO_RES.value = GuardaValor(entry);
		
	valorcampo = document.pi_inscricao.CIDADE_RES.value;
	Acentuacao(valorcampo);
	document.pi_inscricao.CIDADE_RES.value = GuardaValor(entry);

	valorcampo = document.pi_inscricao.BAIRRO_RES.value;
	Acentuacao(valorcampo);
	document.pi_inscricao.BAIRRO_RES.value = GuardaValor(entry);

	valorcampo = document.pi_inscricao.LOGRADOURO_COM.value;
	Acentuacao(valorcampo);
	document.pi_inscricao.LOGRADOURO_COM.value = GuardaValor(entry);
	
	valorcampo = document.pi_inscricao.COMPLEMENTO_COM.value;
	Acentuacao(valorcampo);
	document.pi_inscricao.COMPLEMENTO_COM.value = GuardaValor(entry);
	
	valorcampo = document.pi_inscricao.BAIRRO_COM.value;
	Acentuacao(valorcampo);
	document.pi_inscricao.BAIRRO_COM.value = GuardaValor(entry);

	valorcampo = document.pi_inscricao.CIDADE_COM.value;
	Acentuacao(valorcampo);
	document.pi_inscricao.CIDADE_COM.value = GuardaValor(entry);

	valorcampo = "";
//	Acentuacao(valorcampo);
	}
while (valorcampo!="");

//alert("Acabei!")
return proximoPasso('pi_inscricao', 'dependentes');
}

function verificaCEP(CEP)
{
  var numero;
	
  	if (typeof(CEP) == "string")
	{
	  if (CEP.length == 8)
	  {
	    numero = Number(CEP);
	    
	    if (isNaN(numero))
	    {
	      return false;
	    }
	    else
	    {
	      return true;
	    }
	  }
	  else
	  {
	    return false;
	  }
	}
	else if (typeof(CEP) == "number")
	{
	  return verificaCEP(String(CEP));
	}
}

function atualizaCEP(tipo)
{
  var CEP1;
	var CEP2;
  var objPAIS;
	var objCEP;
	var objCEP_ORI;
	
  switch (tipo)
	{
	  case "RES":
		{
		  objPAIS = document.pi_inscricao.PAIS_RES;
			objCEP = document.pi_inscricao.CEP_RES;
			objCEP_ORI = document.pi_inscricao.CEP_RES_ORI;
			break;
		}
		case "COM":
		{
		  objPAIS = document.pi_inscricao.PAIS_COM;
			objCEP = document.pi_inscricao.CEP_COM;
			objCEP_ORI = document.pi_inscricao.CEP_COM_ORI;
			break;
		}
	}
	
	if (!verificaCEP(objCEP.value))
	{
	  window.alert("CEP inválido.");
		objCEP.focus();
		return;
	}
	
  if (objCEP.value != objCEP_ORI.value)
  {
	  if (objPAIS.value != "BRA")
    {
      if (window.confirm("A validação de CEP só ocorre para casos dentro do Brasil.\nGostaria de mudar seu país?"))
  		{
  		  for (i=0; i<objPAIS.length; i++)
  			{
  			  if (objPAIS[i].value == "BRA")
  				{
  				  objPAIS[i].selected = true;
  				}
  				else
  				{
  				  objPAIS[i].selected = false;
  				}
  			}
  		}
  		else
  		{
		    return;
		  }
    }
    document.pi_inscricao.PASSO.value = 1;
    document.pi_inscricao.action = "inscricao";
    document.pi_inscricao.submit();
  }
}

function mudaPais()
{
  document.pi_inscricao.PASSO.value = 2;
	document.pi_inscricao.action = "inscricao";
	document.pi_inscricao.submit();
}


function abreBusca(tipo)
{
  switch(tipo)
	{
	  case "RES":
		{
		  objCEPtemp = document.pi_inscricao.CEP_RES;
			break;
		}
		case "COM":
		{
		  objCEPtemp = document.pi_inscricao.CEP_COM;
			break;
		}
	}
	
	window.open('/petrossite/servicos/HotsiteSimesp/servicos/consultacep/codigo/asp/montaconsultacep.asp','correios','toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,status=yes,resizable=yes,top=0,left=0,width=540,height=320,copyhistory=yes,maximized');
}

function busca_dados_cep(CEP)
{
	objCEPtemp.value = CEP;
	
	if (objCEPtemp.name == "CEP_RES")
	{
    atualizaCEP("RES");
	}
	else if (objCEPtemp.name == "CEP_COM")
	{
	  atualizaCEP("COM");
	}
}

function mudaDestinoCorresp(valor)
{
  var form;
  form = document.pi_inscricao;
	
  if (valor == "1")								//Trabalho
	{
		form.CEP_COM.style.background = "#FFFDEB";
		//form.LOGRADOURO_COM.style.background = "";
		form.NUMERO_COM.style.background = "#FFFDEB";
		form.PAIS_COM.style.background = "#FFFDEB";
		form.DDD_TEL_COM.style.background = "#FFFDEB";
		form.TEL_COM.style.background = "#FFFDEB";
	}
	else
	{
	  form.CEP_COM.style.background = "#FFFFFF";
		//form.LOGRADOURO_COM.style.background = "";
		form.NUMERO_COM.style.background = "#FFFFFF";
		form.PAIS_COM.style.background = "#FFFFFF";
		form.DDD_TEL_COM.style.background = "#FFFFFF";
		form.TEL_COM.style.background = "#FFFFFF";
	}
	
	form = null;
}

function validaNacionalidade()
{
  var valor;
	valor = document.pi_inscricao.NACIONALIDADE.value;
	
  if (valor != 'BRA')
	{
	  document.pi_inscricao.NATURALIDADE.style.background = "#FFFFFF";
		document.pi_inscricao.NATURALIDADE.disabled = true;
	}
	else
	{
	  document.pi_inscricao.NATURALIDADE.style.background = "#FFFDEB";
		document.pi_inscricao.NATURALIDADE.disabled = false;
	}
}

function proximoPasso(form, acao)
{
  //pi_inscricao.action = "pi_dependentes.asp";
  // Colocando o botao aguarde
  var formulario;
  formulario = document.getElementById(form);
  formulario.style.cursor = "wait";  
  document.getElementById("div_aguarde").style.display = "block";  
  document.getElementById("div_enviar" ).style.display = "none";  
  
  formulario.action = acao;
	formulario.submit();
}

function abrirJanela( nome, caminho )
{
  var scr_height, src_width;
  var win_height, src_width;
  var url, location, menubar, resizable, scrollbars, status, toolbar;
	  
  switch (nome)
  {
    case "formulario":
	{
	  src_height = 		screen.height;
	  src_width = 		screen.width;
	  win_height =		480;
	  win_width = 		690;
		  
	  //url = "<#CAMINHO>/formulario?PLANO_LOGON=<#PLANO_LOGON>&idpessoa=<#IDPESSOA>&idempresa=<#ID_EMPRESA>&idpj=<#ID_PJ>&acao=<#ACAO>";
		  
		  /* características */
		  
	  location = 		"no";
	  menubar = 	 "no";
	  resizable = 	   "no";
	  scrollbars =     "yes";
	  status =          "no";
	  toolbar =         "no";
	  break;
    }
	default:
	  return;  //sai da função
  }
	  
  window.open(caminho, "novaJanela", "top=" + (src_height - win_height) / 2 + ",left=" + (src_width - win_width) / 2 + "," +
  					  "height="+win_height+",width="+win_width+"," +
					  "location="+location+", menubar="+menubar+", resizable="+resizable+", scrollbars="+scrollbars+", status="+status+", toolbar="+toolbar);
}

function validarCamposContrib(){
	var prx = true;
	var cpValorContrib = document.getElementById("VALOR_CONTRIBUICAO");
	var cbDiaPagamento = document.getElementById("DIA_ARREC_PARTIC");
	var cbFormaPagamento = document.getElementById("COD_FORMA_PGTO")
	var cbBancoDebito = document.getElementById("BANCO_DEBITO")
	var cbAgenciaDebito = document.getElementById("AGENCIA_DEBITO")
	var cpContaDebito = document.getElementById("CONTA_DEBITO")
	
	if(cpValorContrib.value == "" || cpValorContrib.value == "0,00"){
		alert('Informe o valor da contribuição.');
		cpValorContrib.focus();
		prx = false;
	}
	if(cbDiaPagamento.value == ""){
		alert('Selecione o dia de Pagamento.');
		cbDiaPagamento.focus();
		prx = false;
	}
	if (cbFormaPagamento.value == "") {
		alert("Selecione a forma de pagamento.");
		cbFormaPagamento.focus()
		prx = false
		
	}
	
	if (cbFormaPagamento.value == "1") {
		if(cbBancoDebito.value == ""  || cbBancoDebito.value == "-1"  ){
		  alert("Selecione o Banco.");
		   cbBancoDebito.focus()
		    prx = false
		}
		else{
		  if (cbAgenciaDebito.value == ""){
		      alert("Selecione a Agencia.");
		      cbAgenciaDebito.focus();
		      prx = false
		  }
		  else{
		    if (cpContaDebito.value == "") {
			  alert("Informe a Conta Corrente.");
		      cpContaDebito.focus();
		      prx = false
			
			}
		  
		  }
		
		}
		
	}
	
	
	if(prx){
		proximoPasso('inscricao_contribuicao', 'confirma');
		
	}
}


function HabilitaAgenciaCC(){

var cbFormaPagamento = document.getElementById("COD_FORMA_PGTO");

if(cbFormaPagamento.value == "1") {
         document.getElementById("BancoDebito").style.display='block';
		 document.getElementById("AgenciaDebito").style.display='block';
		 document.getElementById("CCDebito").style.display='block'
		 document.getElementById("TabelaCC").style.display='block';
		
  }else{
         document.getElementById("BancoDebito").style.display='none';
		 document.getElementById("AgenciaDebito").style.display='none';
		 document.getElementById("CCDebito").style.display='none';
		 document.getElementById("TabelaCC").style.display='none';
  }

  }
function BancoChange() { 

var banco = document.getElementById("BANCO_DEBITO");
//Testa se Banco foi selecionado e carrega as Agencias 
       if (banco.value > 0) {	   
            carregaAgencias(banco.value)
			
        }
  }

function carregaAgencias(codBanco) {
        var fn = function(ajax) {    
            eval("var registro = " + ajax.responseText);
			
            montaComboAgencias(registro.listaAgencias);
        }
        var url = urlAplicacao + "/carregarAgencias?" + "codBanco=" + codBanco;
        respostaAjax(url, "get", fn);
 }

 
 function montaComboAgencias(listaAgencias) {
        var html = '<select name="AGENCIA_DEBITO" id="AGENCIA_DEBITO" class="camposPI">' +
                   '<option value=""></option>';
                          
         for (var i = 0; i < listaAgencias.length; i++) {
            html += '<option value="' + listaAgencias[i].CodAgencia + '"';            
            html += '>' + ReplaceAll(listaAgencias[i].NomeAgencia, "'", "")   + '</option>';
        }
        
        html += '</select>'

        $elem("CampoAgencia").innerHTML = html;
    }

	
	function ReplaceAll(strTarget, strChar, strNew)
{
	var arrRemoved = strTarget.split(strChar);
	
	return arrRemoved.join(strNew);
}
