<!--
// PEGA O VALOR ESCOLHIDO NO RADIO DA TABELA DE AGENCIAS E ATRIBUI AO CAMPO HIDDEM

function enviaForm(form){
    if (document.getElementById('cidade').value == ""){
        return false;
    }
    // SUBMETE O FORMUL�RIO 'FORM1'
    document.form1.action='para_voce.asp';
    document.getElementById('form1').submit();
}

// 'FORM1' DE PESSOA JUR�DICA
function enviaForm2(form){
    if (document.getElementById('cidade').value == ""){
        return false;
    }
    // SUBMETE O FORMUL�RIO 'FORM1' DE PESSOA JUR�DICA
    document.form1.action='para_sua_empresa.asp';
    document.getElementById('form1').submit();
}

function selecionado(q){
    // TESTA SE ESTA SELECIONADO E N�O FAZ NADA SE N�O ESTIVER
    if (document.getElementById('cidade').value == ""){
        return false;
    }else{
    // ATRIBUI O VALOR ESCOLHIDO NA TABELA DE AGENCIAS A CAMPO 'BESTA'
    document.getElementById('besta').value = q.value;
    
}
}
// ESCREVE NA TELA A AGENCIA ESCOLHIDA PELO USU�RIO
function enviar(){
    // TESTA SE ESTA SELECIONADO E SE N�O ESTIVER DISPARA O ALERT
    if (document.getElementById('Age').value == '') {
        alert('Selecione uma ag�ncia.');
    } else {
    // ESCREVE O VALOR DO CAMPO Age NA DIV DE ID AgBox
    window.document.all['AgBox'].innerHTML = document.getElementById('Age').value;
    window.document.all['besta'].innerHTML = document.getElementById('Age').value;
    // ESCONDE A TABELA COM OS RESULTADOS
    document.getElementById('frm').style.display = 'none';
}
}
/*
// PERMITE SOMENTE A DIGITA��O DE CARACTERES NUM�RICOS NO CAMPO
function SomenteNumeros(input){
// SE AS TECLAS DIGITADAS FOREM MENORES QUE A TECLA 48 E MAIORES QUE A TECLA 57 RETORNA FALSE E N�O FAZ NADA
if ((event.keyCode<48)||(event.keyCode>57))
    event.returnValue = false;
}
// CRIA A M�SCAR DE ACORDO COM A ESTRUTURA PASSADA NO CAMPO 'sMASK'
function mask(objeto, sMask, evtKeyPress) {
var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

if(document.all) {
nTecla = evtKeyPress.keyCode; }
else if(document.layers) {
nTecla = evtKeyPress.which;
}
/
// CODIGO DE LOUCO SEM COMENT�RIOS...
sValue = objeto.value;

sValue = sValue.toString().replace( "-", "" );
sValue = sValue.toString().replace( "-", "" );
sValue = sValue.toString().replace( ".", "" );
sValue = sValue.toString().replace( ".", "" );
sValue = sValue.toString().replace( "/", "" );
sValue = sValue.toString().replace( "/", "" );
sValue = sValue.toString().replace( ":", "" );
sValue = sValue.toString().replace( ":", "" );
sValue = sValue.toString().replace( "(", "" );
sValue = sValue.toString().replace( "(", "" );
sValue = sValue.toString().replace( ")", "" );
sValue = sValue.toString().replace( ")", "" );
sValue = sValue.toString().replace( " ", "" );
sValue = sValue.toString().replace( " ", "" );
fldLen = sValue.length;
mskLen = sMask.length;

i = 0;
nCount = 0;
sCod = "";
mskLen = fldLen;

while (i <= mskLen) {
bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))
bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

if(bolMask){
sCod += sMask.charAt(i);
mskLen++;
}else{
sCod += sValue.charAt(nCount);
nCount++;
}

i++;
}

objeto.value = sCod;

if (nTecla != 8) { // backspace
if (sMask.charAt(i-1) == "9") {
return ((nTecla > 47) && (nTecla < 58));
}else{
return true;
}
}else{
return true;
}
}
*/
//-------------------------------------------------------------------------
//Funcoes de verifica��o
//-------------------------------------------------------------------------

function EhIgual(campo) { // Verifica se todos os valores s�o iguais
    var i = 0
    var j = 1
    var igual = true;
    // Todos os caracteres devem ser diferentes
    while (i < campo.length-1 && igual == true) {
        while (j < campo.length && igual == true) {
            if (campo.charAt(i) != campo.charAt(j)) {
                igual = false;
            }
            else j++;
        }
        i++;
    }
    return igual;
}

function EhNumero(campo) { // Verifica se o valor � n�merico e diferente de zero e n�o � tudo igual
    var i
    var digitos = "0123456789,."
    var zero = "0"	
    
    // Todos os caracteres devem ser digitos
    for (i=0; i < campo.length; i++) {
        if (digitos.indexOf(campo.charAt(i)) < 0 ) {
            return false;	
        }
    }
    return true;
}
//Verifica a consistencia do CPF
function check_cpf(numcpf, msg) {
    if(!msg){
        msg = 'CPF inválido!';
    }
    if (EhIgual(numcpf)==true) { 
        alert (msg); 
        return false; 
    }
    x=0; soma=0; dig1=0; dig2=0; texto=""; numcpf1="";
    len = numcpf.length; x = len -1;
    for (var i=0; i <= len - 3; i++) {
        y = numcpf.substring(i,i+1); soma = soma + ( y * x);
        x = x - 1; texto = texto + y;
    }
    dig1 = 11 - (soma % 11);
    if (dig1 == 10) dig1=0 ; if (dig1 == 11) dig1=0 ;
    numcpf1 = numcpf.substring(0,len - 2) + dig1 ;
    x = 11; soma=0;
    for (var i=0; i <= len - 2; i++) {
        soma = soma + (numcpf1.substring(i,i+1) * x); x = x - 1;
    }
    dig2= 11 - (soma % 11);
    if (dig2 == 10) dig2=0; if (dig2 == 11) dig2=0;
    if ((dig1 + "" + dig2) == numcpf.substring(len,len-2)) {
        return true;
    }
    alert(msg);
    return false;
}

function Confirma() {
    
    /*Tipo de conta
    if(document.form1.tipoconta.value.length < 1) {
    alert("Por favor, escolha o tipo de conta que deseja abrir."); 
    document.form1.tipoconta[0].focus();
    return false;
    }	
    
    //Nome do 1� Titular."
    //document.form1.nome1.value = Trim(document.form1.nome1.value);
    if (document.form1.nome1.value.length < 3) { 
    alert("Por favor, informe o Nome do 1� Titular corretamente."); 
    document.form1.nome1.focus(); 
    return false; 
    }
    if ((document.form1.sexo1[0].checked == false)&&(document.form1.sexo1[1].checked == false)){ 
    alert("Por favor, informe o Sexo do 1� Titular."); 
    return false; 
    }
    if(document.form1.cpf1.value.length < 11) {
    alert("Por favor, preencha o CPF."); 
    document.form1.cpf1.focus(); 
    return false;
    }
    
    if(document.form1.cpf1.value.length > 0) {
    if (!check_cpf(document.form1.cpf1.value)) {
    document.form1.cpf1.focus(); 
    return false;
    }
    }
    
    //Nome do 2� Titular."
    //document.form1.nome2.value = Trim(document.form1.nome2.value);
    if (document.form1.nome2.value.length > 0){ 
    if (document.form1.nome2.value.length < 3){ 
    alert("Por favor, informe o Nome do 2� Titular Corretamente."); 
    document.form1.nome2.focus(); return false; 
    }
    if ((document.form1.sexo2[0].checked == false)&&(document.form1.sexo2[1].checked == false)){ 
    alert("Por favor, informe o Sexo do 2� Titular."); 
    return false; 
    }
    }*/
    //CPF do 2� Titular."
    if(document.form1.nome2.value.length > 0)
        {
            if (!check_cpf2(document.form1.cpf2.value)) {
                document.form1.cpf2.focus(); return false;
            }
        }
        var cpf1 = document.getElementById('cpf').value;
        var cpf2 = document.getElementById('cpf2titular').value;
        if (cpf1 == cpf2){
            alert("Os n�meros de CPF s�o iguais, por favor corriga seus dados.");
            return false;
        }
        
        //Verifica��o de e-mail
        /*if(document.form1.email.value.length == "") {
        alert("Por favor, preencha o E-mail."); 
        document.form1.email.focus(); 
        return false;
        }
        if(document.form1.email.value.length > 0) {
        i = document.form1.email.value.indexOf("@")
        j = document.form1.email.value.indexOf(".", i)
        k = document.form1.email.value.indexOf(",")
        kk = document.form1.email.value.indexOf(" ")
        jj = document.form1.email.value.lastIndexOf(".") + 1
        len = document.form1.email.value.length
        
        if((i > 0) && (j > (1 + 1)) && (k == -1) && (kk == -1) && (len -jj >= 2) && (len - jj <= 3)) {
        }else {
        alert("Por favor, entre com e-mail v�lido.\n" + document.form1.email.value + " � �nvalido.")
        return false
        }
        }
        //DDD
        //document.form1.ddd1.value = Trim(document.form1.ddd1.value);
        
        if ((document.form1.ddd1.value.length < 2) || (!EhNumero(document.form1.ddd1.value)) ) {
        alert("Por favor, Preencha o DDD."); 
        document.form1.ddd1.focus(); return false; 
        }
        
        //Telefone
        //document.form1.telefone1.value = Trim(document.form1.telefone1.value);
        if (document.form1.telefone1.value.length < 8){
        alert("N�mero de telefone para contato inv�lido!"); 
        document.form1.telefone1.focus(); return false; 
        }
        if ((document.form1.telefone1.value == "") || (parseInt(document.form1.ddd1.value) < 1) || (parseInt(document.form1.telefone1.value) < 1)){
        alert("Por favor, informe um n�mero de telefone v�lido!"); 
        document.form1.telefone1.focus(); return false; 
        }
        
        //Agencia
        //document.getElementById('Age').value = Trim(document.getElementById('Age').value);
        if (document.getElementById('besta').value.length < 1) { 
        //if (document.getElementById('Age').value.length < 1) { 
        alert("Por favor, Escolha uma das Ag�ncias da lista."); 
        return false; 
        }
        
        //Rendimento
        if (document.getElementById('rendimento').value.length < 1){
        alert("Rendimento inv�lido!"); 
        document.form1.rendimento[0].focus();
        return false;
        }
        */
        
        //document.form1.submit();
        return true;
    }
    
    
    
    
    
    // MENU DE SALTO DREAMWEAVER
    function MM_jumpMenuGo(selName,targ,restore){ //v3.0
        var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
    }
    
    
    // NOVOS JS
    //Libera os campos quando o radio conta conjunta é clicado
    function habilitarCampos(){
        var f = document.AberturaContaPFForm;
        f.nrCpf2.disabled = false;
        f.nmTitular2.disabled = false;
        f.cdSexo2[0].disabled = false;
        f.cdSexo2[1].disabled = false;
        document.getElementById('dvConjunta').style.display = 'block';
    }
    function desabilitarCampos(){
        var f = document.AberturaContaPFForm;
        f.nrCpf2.value="";
        f.nrCpf2.disabled = true;
        f.nmTitular2.value = "";
        f.nmTitular2.disabled = true;
        f.cdSexo2[0].checked = false;
        f.cdSexo2[1].checked = false;
        f.cdSexo2[0].disabled = true;
        f.cdSexo2[1].disabled = true;
        document.getElementById('dvConjunta').style.display = 'none';
    }
    var maskChars = ['.', '/', '-'];
    function removeMascara(str){
        for(var i = 0; i < maskChars.length; i++){
            while(str.indexOf(maskChars[i]) >= 0){
                str = str.replace(maskChars[i], '');
            }
        }
        return str;
    }
    //-->
    