﻿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
	window.document.IB2000.TPCONTA.value = IB2000Form.TPCONTA.value

	if(IB2000Form.AGN.value != '' && IB2000Form.CTA.value != '' && IB2000Form.DIGCTA.value != '' && IB2000Form.TPCONTA.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.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=0,location=1,directories=0,status=1,menubar=0,scrollbars=0,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=0,location=1,directories=0,status=1,menubar=0,scrollbars=0,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=0,location=1,directories=0,status=1,menubar=0,scrollbars=0,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=0,location=1,directories=0,status=1,menubar=0,scrollbars=0,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);
		return false;	
	}
	else
	{
		if (parseInt(Digit) == 13)
		{
			if(VerificaLogin() == true)
			{IB2000Open(window.document.FormIB2001);}
			else
			{ValidaLogin(campo);}
		}		
	}
}

function DVFoco(valor)
{
    switch (valor) {
    	case 1 : {parent.conteudo.ConteudoPrincipal.focus(); break;}
    	case 2 : {parent.conteudo.MenuDeServicos.focus(); break;}
    	case 3 : {parent.conteudo.MenuPrincipal.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)
{
	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();
				}
			}
		}	
	}
}
	
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() 
{

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; 
	}
}
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