var nomesf = new Array();
nomesf[0] = "frm_top";
nomesf[1] = "conteudo";
nomesf[2] = "barraBottom";
var nframes = 3;
var endsite = "http://www.bradesco.com.br/";
try {
    if (parent.parent.document.URL) {
        if (parent.frames.length > 0) {
            if (parent.frames.length != nframes) {
                //Quantidade de frames diferente do permitido.
                top.location.href = endsite;
            }
            for (x = 0; x < parent.parent.frames.length; x++) {
                if (nomesf[x] != parent.parent.frames[x].name) {
                    //Nome dos Frames
                    top.location.href = endsite;
                }
            }
        } else {
            if (parent.parent.document.URL.indexOf('/html/content/barra') > 0 || parent.parent.document.URL.indexOf('/html/content/home') > 0) {
                top.location.href = endsite;
            }
        }
    }
} catch (e) {
    var detect = navigator.userAgent.toLowerCase();
    if (detect.indexOf('mac') < 1) {
        //Catch caso carrege de um iframe
        top.location.href = endsite;
    }
}
var InternetBanking
var URL = parent.self.location.href;

var c = new Array();
c[0] = "www.bradesco.com.br";
c[1] = "d4312s022";
c[2] = "10.243.124.3";
c[3] = "200.155.82.1";
c[4] = "200.155.86.34";
c[5] = "www.bradesco.b.br";
c[6] = "wwwbradesco.com.br";
c[7] = "bancodesonhos";
c[8] = "bancodesonhos.com.br";
c[9] = "bradescoleasing.com.br";
c[10] = "www.bradescoleasing.com.br";
c[11] = "qa.loja1.walmart.com.br";
c[12] = "bradesco.com.br";

var localizado = 0;
for (f = 0; f <= 12; f++) {
    if (URL.indexOf(c[f]) > 1) {
        localizado = 1;
    }
}
if (localizado == 0) {
    top.self.location.href = 'http://www.bradesco.com.br';
}
if ((localizado == 1) && ((URL.indexOf(c[9]) > 0) || (URL.indexOf(c[10]) > 0))) {
    top.self.location.href = 'http://www.shopinvest.com.br/bradescoleasing/default.aspx';
}
function IB2000Open(IB2000Form) {
    window.document.IB2000.action = IB2000Form.action
    window.document.IB2000.AGN.value = IB2000Form.AGN.value
    window.document.IB2000.CTA.value = IB2000Form.CTA.value
    window.document.IB2000.DIGCTA.value = IB2000Form.DIGCTA.value    

    if (IB2000Form.AGN.value != '' && IB2000Form.CTA.value != '' && IB2000Form.DIGCTA.value != '') {
  
      //  InternetBanking = window.open("", "InternetBanking", "toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,screenX=0,screenY=0,left=0,top=0,width=765,height=528");
        window.document.IB2000.target='_top';
        window.document.IB2000.submit()
        IB2000Form.reset()
    }
    return false;
}

function IB2000OpenCadSenha() {
    if (navigator.appName.indexOf("Netscape") != -1)
        IB2K1CADSENHA = window.open("https://wwwss.bradesco.com.br/scripts/ib2k1.dll/CADSENHA/CONDUSO", "IB2K1CADSENHA", "toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,screenX=0,screenY=0,left=0,top=0,width=765,height=528");
    else
        IB2K1CADSENHA = window.open("https://wwwss.bradesco.com.br/scripts/ib2k1.dll/CADSENHA/CONDUSO", "IB2K1CADSENHA", "toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,screenX=0,screenY=0,left=0,top=0,width=765,height=528");
    return false;
}
function CadAltSenha() {
    if (navigator.appName.indexOf("Netscape") != -1)
        IB2K1CADSENHA = window.open("https://wwwss.bradesco.com.br/scripts/ib2k1.dll/CADSENHA/CONDUSO", "IB2K1CADSENHA", "toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,screenX=0,screenY=0,left=0,top=0,width=765,height=528");
    else
        IB2K1CADSENHA = window.open("https://wwwss.bradesco.com.br/scripts/ib2k1.dll/CADSENHA/CONDUSO", "IB2K1CADSENHA", "toolbar=1,location=1,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,screenX=0,screenY=0,left=0,top=0,width=765,height=528");
    return false;
}

function MM_openBrWindow(theURL, winName, features) { //v2.0
    window.open(theURL, winName, features);
}
function Apenas_Numeros(e, campo) {
    var msg = "Favor digitar somente caracteres numéricos";
    var monta = "";
    var NS = (navigator.appName == "Netscape")
    var Digit = parseInt(eval(((NS) ? "e.which" : "e.keyCode")))

    if (!(Digit > 47 && Digit < 58 || Digit == 8 || Digit == 0 || Digit == 13)) {
        alert(msg);
        monta = "document.FormIB2001." + campo + ".focus();";
        eval(monta);
        e.keyCode.returnValue = false;
        return false;
    }
    else {
        if (parseInt(Digit) == 13) {
            if (VerificaLogin() == true)
            { IB2000Open(window.document.FormIB2001); e.keyCode.returnValue = false; return false; }
            else
            { ValidaLogin(campo); e.keyCode.returnValue = false; return false; }
        }
    }
}

function DVFoco(valor) {
    switch (valor) {
        case 1: { if(document.all) { parent.conteudo.ConteudoPrincipal.focus();} else{ parent.conteudo.document.getElementById('ConteudoPrincipal').focus();}  break; }
        case 2: { if(document.all) { parent.conteudo.MenuDeServicos.focus();} else { parent.conteudo.document.getElementById('MenuDeServicos').focus();} break; }
        case 3: { if(document.all) { parent.conteudo.abraSuaConta.focus();} else { parent.conteudo.document.getElementById('abraSuaConta').focus();} break; }
      
    }
}

function VerificaLogin() {
    var valor = true;
    var Agencia = parseInt(document.FormIB2001.AGN.value);
    var Conta = parseInt(document.FormIB2001.CTA.value);
    var Digito = parseInt(document.FormIB2001.DIGCTA.value);

    if ((isNaN(Agencia) == true) || (isNaN(Conta) == true) || (isNaN(Digito) == true))
    { valor = false; }
    else {
        if (ValidaDigito() == true)
        { valor = true; }
        else
        { valor = false; }
    }
    return valor;
}
function ValidaLogin(campo) {
    //Habilitando  o código abaixo o acesso a area transacional fica indisponível
    //window.open("/msg/index.html","pop_indisponibilidade","width=750, height=528, top=0; left=0");

    //Para habilitar o acesso ao transacional basta retiara o comentário do if abaixo
    if (VerificaLogin() == true)
    { IB2000Open(window.document.FormIB2001); }
    else {
        var Agencia = parseInt(document.FormIB2001.AGN.value);
        var Conta = parseInt(document.FormIB2001.CTA.value);
        var Digito = parseInt(document.FormIB2001.DIGCTA.value);
        if (isNaN(Agencia) == true) {
            alert("Favor preencher o campo agência");
            document.FormIB2001.AGN.focus();
        }
        else {
            if (isNaN(Conta) == true) {
                if ((campo == "CTA") && (document.FormIB2001.CTA.value == ""))
                { alert("Favor preencher o campo conta"); }
                document.FormIB2001.CTA.focus();
            }
            else {
                if (isNaN(Digito) == true) {
                    if ((campo == "DIGCTA") && (document.FormIB2001.DIGCTA.value == ""))
                    { alert("Favor preencher o dígito de sua conta"); }
                    document.FormIB2001.DIGCTA.focus();
                }
                else {
                    alert("Informações inválidas. Por favor, verifique agência, conta e dígito");
                    document.FormIB2001.CTA.focus();
                }
            }
        }
    }
    //Fim do if que habilita o acesso a area transacional
}
function ValidaDigito() {
    var lsoma = 0;
    var ipeso = 2;
    var dv_informado = document.FormIB2001.DIGCTA.value;
    var dv_conta = document.FormIB2001.CTA.value;
    var tam = document.FormIB2001.CTA.value.length;
    var conta = new Array(tam);
    for (i = 0; i <= tam; i++)
    { conta[i] = dv_conta.substr(i, 1); }
    while (tam > 0) {
        digito = conta[--tam];
        if ((digito >= 0) && (digito <= 9)) {
            lsoma = lsoma + (digito - 0) * ipeso;
            ipeso = ipeso + 1;
            if (ipeso > 7)
            { ipeso = 2; }
        }
    }
    lsoma %= 11;
    lsoma = 11 - lsoma;
    if ((lsoma == 11) || (lsoma == 10))
    { lsoma = 0; }
    if (parseInt(dv_informado) == parseInt(lsoma))
    { RetDig = true; }
    else
    { RetDig = false; }
    return RetDig;
}
function Verificar() {
	
	if(window.event){
	    var ctrl = window.event.ctrlKey;
	    var tecla = window.event.keyCode;
	    if (ctrl && tecla == 67) { event.keyCode = 0; event.returnValue = false; }
	    if (ctrl && tecla == 86) { event.keyCode = 0; event.returnValue = false; }
	}
}

function checa_agencia(campo) {
    switch (campo) {
        case "AGN": 
            {
                if (document.FormIB2001.AGN.value.length == 4)
                { document.FormIB2001.CTA.focus(); }
                break;
            }
        case "CTA": 
            {
                if (document.FormIB2001.CTA.value.length == 7)
                { document.FormIB2001.DIGCTA.focus(); }
                break;
            }
    }
}

ns = document.layers ? 1 : 0;
ie = document.all ? 1 : 0;
oldId = "Layer1";

function ProcuraObjeto(n, d) {
    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 = ProcuraObjeto(n, d.layers[i].document);
    if (!x && document.getElementById) x = parent.conteudo.document.getElementById(n); return x;
}

function controle() {
    var i, p, v, obj, args = controle.arguments;

    for (i = 0; i < (args.length - 2); i += 3)
        if ((obj = ProcuraObjeto(args[i])) != null) {
        v = args[i + 2];

        if (obj.style) {
            obj = obj.style; v = (v == 'show') ? 'visible' : (v = 'hide') ? 'hidden' : v;
        }
        obj.visibility = v;
    }
}

var StatusFechaComoUsar = 0;

function estadoComoUsar(estado){

    if(estado==1){
    alert('ok');
      //  document.getElementById('Layer1').style.display='Block';
      
      
        document.getElementById('Layer1').style.visibility='visible';
    }else{
        //document.getElementById('Layer1').style.display='none';
        StatusFechaComoUsar=1
        
    }

}

function alteraEstadoComoUsar(estado){
     if(estado==1){
          
        StatusFechaComoUsar=0;
        document.getElementById('Layer1').style.visibility='visible';
    }else{
        document.getElementById('Layer1').style.display='none';
        StatusFechaComoUsar=0;
        
    }

}
function lyrVisual(id, estado) {
    try {
        if (navigator.appName == "Netscape") {
            opcao = (estado) ? "show" : "hide";
            controle(id, '', opcao);
        }
        else {
            opcao = (estado) ? "visible" : "hidden";
            parent.conteudo.document.all[oldId].style.visibility = "hidden";
            parent.conteudo.document.all[id].style.pixelTop = parent.conteudo.document.body.scrollTop;
            parent.conteudo.document.all[id].style.visibility = opcao;
            oldId = id.toString()
        }
    }
    catch (e)
	{ }
}

function mOut(src, clrIn) {
    if (!src.contains(event.toElement)) {
        src.style.cursor = 'default';
        src.bgColor = clrIn;
    }
}
function onMouseOut() {
    parent.lyrVisual('Layer1', 0)
}
var tempo
