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 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();
			return false;
		}
		else
		{
			if (isNaN(Conta)== true)
			{
				if((campo == "CTA") && (document.FormIB2001.CTA.value == ""))
				{alert("Favor preencher o campo conta");}
				document.FormIB2001.CTA.focus();
				return false;
			}
			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();
					return false;
				}
				else
				{
					alert("Informações inválidas. Por favor, verifique agência, conta e dígito");
					document.FormIB2001.CTA.focus();
					return false;
				}
			}
		}	
	}
}

function exibeValor(nomeCampo, lenCampo, controle)
{
	if ((nomeCampo.value.length == lenCampo) && (checarTabulacao))
	{	
		var i=0;
		for (i=0; i<document.forms[0].elements.length; i++)
		{
			if (document.forms[0].elements[i].name == nomeCampo.name)
			{
				while ((i+1) < document.forms[0].elements.length)
				{
					if (document.forms[0].elements[i+1].type != "hidden")
					{
						document.forms[0].elements[i+1].focus();
						break;
					}
				i++;
				}
				checarTabulacao=false;
				break;
			}
		}
	}
}
	
function stopTabCheck(nomeCampo)
{checarTabulacao=false;}

function startTabCheck()
{checarTabulacao=true;}

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;

	//Cria uma array 
	var conta = new Array(tam);
	
	//Desmembra o número
	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;}      
	
	//Verifica se o digito informado esta correto
	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;}
}

var InternetBanking

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 != '')
	{
	    //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 abrePopuphf()
{
	window.open('/br/hotsite/hiperfundo_ana/index.html', 'pophiper', 'width=779,height=436,top=0,left=10,scrollbars=0,menubar=0,toolbar=no,statusbar=no,resizable=no');
}

function hfundo()
{
	var path = top.location.href;
		
	path = path.toLowerCase();
	
	if (path.indexOf('hiperfundo')!=-1)
	{
		setTimeout("abrePopuphf()",1000);
	}	
}

function abrePopuphbroker()
{
	window.open('/br/hotsite/home_broker/homebroker.html', 'pophb', 'width=700,height=420,top=0,left=10,scrollbars=0,menubar=0,toolbar=no,statusbar=no,resizable=no');
}

function home_broker()
{
	var path = top.location.href;
		
	path = path.toLowerCase();
	
	if (path.indexOf('homebroker')!=-1)
	{
		setTimeout("abrePopuphbroker()",1000);
	}	
}

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;
		}
	}	
}

var nomesf = new Array();
nomesf[0] = "frm_top";
nomesf[1] = "frm_cont";
var nframes = 2;
var endsite = "http://www.shopcredit.com.br/";

try
{
	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.frames.length;x++)
		 {
		  if (nomesf[x] != parent.frames[x].name)
		    {
			//Nome dos Frames
			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;
	  }
}

//Define o Array de URLs válidas
var URL = parent.self.location.href;
var c = new Array();
c[0]="www.shopcredit.com.br";
c[1]="bdn01";
c[2]="10.241.7.2";
c[3]="200.246.208.5";
c[4]="200.173.18.5";
c[5]="200.232.57.5";
c[6]="200.205.78.5";
c[7]="200.155.100.225";
c[8]="200.212.135.225";
c[9]="200.246.236.135";
c[10]="labwshopinvest";
c[11]="shopcredit.com.br";
c[12]="d4312s027";

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.shopcredit.com.br';

}

