

// producao
var urlIB_Banespa = "https://netbanking2.banespa.com.br";
var urlIB_Santander = "https://netbanking2.banespa.com.br";


// desenvolvimento
//var urlIB_Banespa   = "https://srvnetbanpi3";  // desenvolvimento
//var urlIB_Santander = "https://srvnetbanpi3";

// prova integrada HG
//var urlIB_Banespa   = "http://bsbrsp2304";  // prova integrada HG
//var urlIB_Santander = "http://bsbrsp2304";  // prova integrada HG

// homologacao HK
//var urlIB_Banespa   = "http://netbankinghk";  // homologacao HK
//var urlIB_Santander = "http://netbankinghk";  // homologacao HK



var tempoMenu = 1000;
function fecharFrame(){
document.getElementById('acessar').style.display = 'none';
return;
}
menuTimer = null;
function escondeMenu(){
	menuTimer = setTimeout("fecharFrame()",tempoMenu)
}

function mantemMenu(){
	if (menuTimer != null){
		clearTimeout(menuTimer);
		menuTimer = null;
	}
}
//------------------ funcao novo netbanking (Projeto Sevilha) ---------------------------------->
		function onEnviarIB(){
			var frm = document.frmnetbanking;
			var agencia;
			var conta;


			if(frm.txtAgencia.value=="" || JustNumber(frm.txtAgencia.value)<=0){
				alert("Por favor, preencha corretamente o número da Agência.");
				frm.txtAgencia.focus();
				return;
			}
			
			preencheZeros(frm.txtAgencia, 4);

				if(frm.txtContaLeft.value=="" || JustNumber(frm.txtContaLeft.value)<=0){
					alert("Por favor, preencha corretamente o número da Conta.");
					frm.txtContaLeft.focus();
					return;
				}
				if(frm.txtContaMid.value=="" || JustNumber(frm.txtContaMid.value)<=0){
					alert("Por favor, preencha corretamente o número da Conta.");
					frm.txtContaMid.focus();
					return;
				}
				if(frm.txtContaRight.value==""){
					alert("Por favor, preencha corretamente o número da Conta.");
					frm.txtContaRight.focus();
					return;
				}
				preencheZeros(frm.txtContaLeft, 2);
				preencheZeros(frm.txtContaMid, 6);
				preencheZeros(frm.txtContaRight, 1);
				agencia = frm.txtAgencia.value;
				conta	= frm.txtContaLeft.value + frm.txtContaMid.value + frm.txtContaRight.value;
				
				if(!CheckDigitoBNP(agencia, conta)){
					alert("Conta informada inválida.");
					frm.txtAgencia.focus();
					return;
				}

					
				if(frm.txtAgencia.value < 1000){
//					var strURL='https://netbanking2.banespa.com.br/default.asp?txtAgencia=' + agencia + '&txtConta=' + conta;
					var strURL= urlIB_Banespa + '/default.asp?txtAgencia=' + agencia + '&txtConta=' + conta + '&oA=site';
				}else{
//					var strURL='https://www.santandernet.com.br/default.asp?txtAgencia=' + agencia + '&txtConta=' + conta;
					var strURL= urlIB_Santander + '/default.asp?txtAgencia=' + agencia + '&txtConta=' + conta + '&oA=site';
				}
//				window.open(strURL, "IBSantanderBanespa", "toolbar=yes,status=yes,menubar=yes,scrollbars=auto,resizable=yes,width=790,height=450,top=0,left=0");
				window.open(strURL, "_top");
					
//				frm.reset();
//				return;
		}

		function onEnter(theKey){
			if (theKey == 13) onEnviarIB();
			return;
		}

		function onTrocaFoco(origem, destino, tamanho, theKey){
			var objOrigem = eval('document.frmnetbanking.' + origem);
			var objDestino = eval('document.frmnetbanking.' + destino);
			if(((theKey>=96 && theKey<=105) || (theKey>=48 && theKey<=57)) && objOrigem.value.length >= tamanho){
				objDestino.focus();
			}
			return;
		}

		function MMS_GetKeyEvent(evt){
			var KeyPressed;
			if ("NETSCAPE" != window.navigator.appName.toUpperCase()){
                KeyPressed = event.keyCode;
			}else{
				KeyPressed = evt.which;
			}
			return KeyPressed;
		}

		function preencheZeros (field, size){
			while (field.value.length < size) field.value = '0' + field.value;
		}
		function JustNumber(What) {
			var WhatClean = '';
			for (var i = 0; (i <= (What.length - 1)); i++) {
				for (var j = 0; ((j <= 9) && (true)); j++) {
					if (What.charAt(i) == '' + j) {
						WhatClean += What.charAt(i);
						break;
					}
				}
			}
			return WhatClean;
		}

		function CheckDigitoBNP(auxAgencia, auxConta) {
		//<%'FORMATO AGÊNCIA(4) CONTA(8) DIGITO(1)%>

			var auxPeso = new Array("9","7","3","1","9","7","1","3","1","9","7","3");
			var cont = 0;
			var soma = 0;
			var digito = 0;
			var auxRet = false;
			var auxAgenciaConta = auxAgencia.toString() + auxConta.toString();
			for(cont=0 ; cont<12 ; cont++){
				soma = soma + ((auxAgenciaConta.substring(cont,cont+1) * auxPeso[cont]) % 10);
			}
			digito = ( 10 - (soma % 10) ) % 10;
			if (digito==auxAgenciaConta.substring(12,13)) auxRet = true;
			return auxRet;
		}



function onInibeTudoSobre(strLink){
var iWidth = 650;
var iHeight = 450;
var iLeft;
var strFeatures;
var strURL;
var strTipo;

switch  (strLink) {
	case '1': //Nova Forma de Acessar
		strURL = '/portal/gsb/script/tudosobre/pf_principal.htm?novaforma';
		strTipo = 'TudoSobre';
		iWidth = 663;
		iHeight = 484;
		strFeatures = 'status=no,menubar=no,scrollbars=no,resizable=no,width=' + iWidth + ',height=' + iHeight + ',top=0,left=' + iLeft
		break;
	case '2': //Primeiro Acesso
		strURL = '/portal/gsb/script/tudosobre/pf_principal.htm?comoacessar';
		strTipo = 'TudoSobre';
		iWidth = 673;
		iHeight = 484;
		strFeatures = 'status=no,menubar=no,scrollbars=no,resizable=no,width=' + iWidth + ',height=' + iHeight + ',top=0,left=' + iLeft
		break;
	case '3': //Suporte
		strURL = '/portal/gsb/script/tudosobre/pf_principal.htm?superlinha';
		strTipo = 'TudoSobre';
		iWidth = 663;
		iHeight = 484;
		strFeatures = 'status=no,menubar=no,scrollbars=no,resizable=no,width=' + iWidth + ',height=' + iHeight + ',top=0,left=' + iLeft
		break;
	case '4': //Nome de Acesso e Senha
		strURL = '/portal/gsb/script/tudosobre/pf_principal.htm?senhadeacesso';
		strTipo = 'TudoSobre';
		iWidth = 663;
		iHeight = 484;
		strFeatures = 'status=no,menubar=no,scrollbars=no,resizable=no,width=' + iWidth + ',height=' + iHeight + ',top=0,left=' + iLeft
		break;
	case '5': //Segurança
		strURL = '/portal/gsb/script/tudosobre/pf_principal.htm?seguranca';
		strTipo = 'TudoSobre';
		iWidth = 663;
		iHeight = 484;
		strFeatures = 'status=no,menubar=no,scrollbars=no,resizable=no,width=' + iWidth + ',height=' + iHeight + ',top=0,left=' + iLeft
		break;	    
	case '6': //Perguntas Freqüentes
		strURL = '/portal/gsb/script/tudosobre/pf_principal.htm?faq';
		strTipo = 'TudoSobre';
		iWidth = 663;
		iHeight = 484;
		strFeatures = 'status=no,menubar=no,scrollbars=no,resizable=no,width=' + iWidth + ',height=' + iHeight + ',top=0,left=' + iLeft
		break;
	case '7': //Tudo Sobre o Internet Banking
		strURL = '/portal/gsb/script/tudosobre/pf_principal.htm';
		strTipo = 'TudoSobre';
		iWidth = 663;
		iHeight = 484;
		strFeatures = 'status=no,menubar=no,scrollbars=no,resizable=no,width=' + iWidth + ',height=' + iHeight + ',top=0,left=' + iLeft
		break;
	case '8': //Novo número de Conta
		strURL = '/portal/gsb/script/conversao_conta_corrente/mostravalidaconta.jsp';
		strTipo = 'TudoSobre';
		iWidth = 620;
		iHeight = 320;
		strFeatures = 'status=no,menubar=no,scrollbars=no,resizable=no,width=' + iWidth + ',height=' + iHeight + ',top=0,left=' + iLeft
		break;		
	}
	
	iLeft = (window.screen.width - iWidth) / 2; 
	window.open(strURL, strTipo, strFeatures);
}
function onMostraTudoSobre(){
document.getElementById('acessar').style.display = 'block';
return;
}

//------------------ fim da funcao netbanking (Site santanderbanespa.com.br) ---------------------------------->