window.name='banestes';


//INICIA O AUMENTO DAS LETRAS

var tagAlvo = new Array('ul', 'p', 'h2', 'dd','dt', 'li'); //pega todas as tags p//
 
// Especificando os possíveis tamanhos de fontes, poderia ser: x-small, small...
var tamanhos = new Array('95%','103%','107%','112%','115%');
var tamanhoInicial = 0;


 
function mudaTamanho( idAlvo,acao ){
	

  
  
  if (!document.getElementById) return
  var selecionados = null,tamanho = tamanhoInicial,i,j,tagsAlvo;
  
  if (tamanho < 1 && acao == -1 ) return;
  if (tamanho > 3 && acao == 1) return;
	
  tamanho += acao;
  tamanhoInicial = tamanho;
  
  
  if ( !( selecionados = document.getElementById( idAlvo ) ) ) selecionados = document.getElementsByTagName( idAlvo )[ 0 ];
  
  selecionados.style.fontSize = tamanhos[ tamanho ];
  
  for ( i = 0; i < tagAlvo.length; i++ ){
    tagsAlvo = selecionados.getElementsByTagName( tagAlvo[ i ] );
    for ( j = 0; j < tagsAlvo.length; j++ ) tagsAlvo[ j ].style.fontSize = tamanhos[ tamanho ];
  }
}

// ACABA O AUMENTA DAS LETRAS



var ns = (document.layers)? true:false;
var ie = (document.all)? true:false;			

function MostraDiv(id) {
	//Div Pai, onde v&atilde;o conter as divs a serem mostradas
	var divPai = document.getElementById("mostradivs");
	//Quantidade de divs dentro da div Pai.
	var qtdeDeDivs = divPai.getElementsByTagName("div").length;
	//Vari&aacute;vel para setar a div a ser mostrada.
	var divParaMostrar = document.getElementById(id);
	// Se a div ja estiver aberta, ela fecha
	if(divParaMostrar.className == 'show'){
		divParaMostrar.className = 'hide';
		return;
	}
	// Caso n&atilde;o, o loop varre todas as op&ccedil;ões e abre a igual ao ID
	var i = 1;
	while( i <= qtdeDeDivs){
		if(i == id){
			divParaMostrar.className = 'show';
		} else {
			document.getElementById(i).className = 'hide';
		}
		i = i + 1 ;
	}
}

function mostraDetalhes(c){
	if (document.getElementById(c).style.display == 'none'){
		document.getElementById(c).style.display = '';		
	}
	else {
		document.getElementById(c).style.display = 'none';
	}
}

// --------------------------------------------------------------------------------------------------

function checkcpf(cpf) { 
	var result = "";
	var OK = false;
	var temp = Limpa(cpf);
	if (temp.length>10){
		var work=temp.substring(0,(temp.length)-2)
		var resto = Resto(work);
		OK = (resto==eval(temp.charAt((temp.length)-2)));
		if (OK){
			work=work+resto;
			resto= Resto(work);
			OK = (resto==eval(temp.charAt((temp.length)-1)));
		}
	}
	if (OK){return true} else{return false};
}

function checkcnpj(cgc) {
	var temp = Limpa(cgc);
	
	dac1 = 0; dac2 = 0; dac = ""; dact = ""; sum = 0;
	dac  = temp.substring(temp.length-2, temp.length);
	temp = temp.substring(0,temp.length-2);
	
	for (i=temp.length-1, j=2; i >= 0 ; i--, j++){
		j = (j == 10) ? 2 : j; sum += (temp.substring(i, i+1) * j); }
		dac1 = ((sum * 10) % 11); dac1 = (dac1 == 10) ? 0 : dac1; sum = 0;
		
	for (i=temp.length-1, j=3; i >= 0 ; i--, j++){ 
		j = (j == 10) ? 2 : j; sum += (temp.substring(i, i+1) * j); }
		sum  += (dac1 * 2); dac2 = ((sum * 10) % 11); 
		dac2 = (dac2 == 10) ? 0 : dac2; dact = dac1+""+dac2;
	
	if (dact == dac) return true;
		else { return false; }
}

function Inverte(S){
	var temp="";
	for (var i=0; i<S.length; i++){
		temp=S.charAt(i)+temp
	}
	return temp
}
			
function Resto(S){
	var invertido = Inverte(S);
	var soma = 0;
	for (var i=0; i<invertido.length; i++){
		soma=soma+(i+2)*eval(invertido.charAt(i))
	}
	soma*=10;
	return ((soma % 11) % 10)
}

function testaBlur(){
	var list = document.name.cdnidrspnss;
	if (list.options[list.selectedIndex].value == 1){
		document.name.ttunrnss.blur();
	}
}
			
function limpaNossoNum(){
	if (document.name.cdnidrspnss.options[document.name.cdnidrspnss.selectedIndex].value == 1 ){
		document.name.ttunrnss.value = "";       
	}
}
			
function ValidaConteudo( el, event ){
	var key;

	if (isNav)
		key = String.fromCharCode( event.which );
	else
		key = String.fromCharCode( event.keyCode );

	if ( isNav && event.which == 8 )
		return true;

	if ( !ValidaChar( key ) )
		return false;

	return true;
}
			
function ValidaChar( caractere ){
	var strValidos = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz .,/:*-()*&%$!#<>?;"
	if ( strValidos.indexOf( caractere ) == -1 ){
		return false;
	}
	return true;
}

function Limpa(S){
	var temp = "";
	var digito = "";
	for (var i=0; i<S.length; i++){
		digito = S.charAt(i);
		if (digito==","){temp=temp+"."}
		else if (digito!=" "){temp=temp+digito}
	}
	return temp
}

function ResetForm() {
	var i=0;
	for(i=0; i<document.forms[0].elements.length; i++)
		document.forms[0].elements[i].value = "";
}

function checkmail(email) {
	var find_ponto=false;
	var find_arroba=false;
	var find_caracter=false;
  if ((email.charAt(0)==".")||(email.charAt(email.length-1)=="."))
	return (false & false & false);
  if ((email.charAt(0)=="@")||(email.charAt(email.length-1)=="@"))
	return (false & false & false);
	for (var i=0; i<email.length; i++) {
		if ((email.charAt(i)==":") ||
				(email.charAt(i)=="/") ||
				(email.charAt(i)==";"))
		return (false & false & false);
	else {
		if (email.charAt(i)=="@"){
			if (find_arroba==true)
				return (false & false & false);
			else {
				find_arroba=true;
				if ((email.charAt(i-1)==".")||(email.charAt(i+1)=="."))
					return (false & false & false);
				}
			}
			else if (email.charAt(i)==".") find_ponto=true;
			else if (email.charAt(i)!=" ") find_caracter=true;
		}    
	}
	return (find_ponto & find_arroba & find_caracter);
}

function goSite (dest) {
  if (dest != "") {
    document.location.href = dest;
  }
  return true;
}

//--------------------------------------------------------------------------------------------


function SomenteNumero(e){
    var tecla=(window.event)?event.keyCode:e.which;   
    if((tecla>47 && tecla<58)) return true;
    else{
    	if (tecla==8 || tecla==0) return true;
	else  return false;
    }
}




function loga()
{
	var sConta = document.lg.ct.value;
	var iMultiplicador = 2;
	var iSoma = 0;
	var iDigito = "";
	var iSomaNumeros = 0;

	if (isNaN(sConta))
	{
		alert("Somente números!");
		document.lg.ct.focus();
		return false;
	}
	else if (sConta.length == 0)
	{
		alert("Digite o número da conta!");
		document.lg.ct.focus();
		return false;		
	}
	else if (sConta.length < 2)
	{
		alert("Conta inválida!");
		document.lg.ct.focus();
		return false;		
	}
	else
	{
		if (((sConta.length-1) % 2) ==0 )
			iMultiplicador = 1;

		for (var i=0; i<sConta.length-1; i++)
		{
			iDigito = (iMultiplicador * parseInt(sConta.charAt(i)));

			if (iDigito > 9)
				iDigito = (parseInt(iDigito.toString().charAt(0)) + parseInt(iDigito.toString().charAt(1)));

			iSoma = iDigito;
		
			if (--iMultiplicador<1)
				iMultiplicador = 2;
			else
				iMultiplicador = 1;

			iSomaNumeros = iSomaNumeros + iSoma;
		}
		iSomaNumeros = iSomaNumeros % 10;

		if (iSomaNumeros != 0)
			iSomaNumeros = 10 - iSomaNumeros;

		if (iSomaNumeros != parseInt(sConta.charAt(sConta.length-1)))
		{
			alert("Conta inválida!");
			document.lg.ct.focus();
			return false;			
		}
		else
		{
			displayWindow('https://wwws.banestes.com.br/cgi-bin/IB_Login?ct='+document.lg.ct.value,'nomedajanela',800,520,'resizable=no,toolbar=no,scrollbars=yes,status=yes');
			document.lg.ct.value='';
			return false;
		}
	}
}

function EntrarIB(){	
	var tecla = window.event.keyCode ? window.event.keyCode : window.event.which ? window.event.which : window.event.charCode;	
	
	if(tecla == 13){            
		window.event.which = 9;
		window.event.keyCode =9;
		window.event.charCode = 9;
		loga();
	}
}

/*--------------------------------------------------------------------------------------------*/

function wait(msecs){
  var start = new Date().getTime();
  var cur = start
  while(cur - start < msecs){
    cur = new Date().getTime();
  } 
} 

function trocaChar(valor, char1, char2) {
  var valor2 = "";
  for (var i=0; i<valor.length; i++) {
	  if (valor.charAt(i) == char1) {
		  valor2 = valor2 + char2;
	  }
	  else {
		 if ((valor.charAt(i) >= 0) && (valor.charAt(i) <= 9)) {
			 valor2 = valor2 + valor.charAt(i);
		 }
	  }
  }
  return valor2;
}

function Money(valor) {
  var valor2 = "" + valor;
  var virgula = valor2.indexOf(".");
  if (virgula == -1) {
	 return valor;
  }
  else {
	 var valor3 = valor2.substring(0, (virgula + 3));
	 return trocaChar(valor3, ".", ",");
  }
}

function wait(msecs){
  var start = new Date().getTime();
  var cur = start
  while(cur - start < msecs){
    cur = new Date().getTime();
  } 
} 


function atualizaPercent()
{
  http_request = false;
  if (window.XMLHttpRequest) // Mozilla, Safari,...
  { 
	http_request = new XMLHttpRequest();
	if (http_request.overrideMimeType) 
	  http_request.overrideMimeType('text/xml'); //Caso ocorra erro pode ser removida
  }//if 
  else if (window.ActiveXObject)  // IE
  {
	try 
	{
	  http_request = new ActiveXObject("Msxml2.XMLHTTP");
	}//try 
	catch (e) 
	{
	  try 
	  {
		 http_request = new ActiveXObject("Microsoft.XMLHTTP");
	  } //try
	  catch (e) {}
	 }//catch
  }//else
  if (!http_request) 
  {
	return false;
  }
 
  http_request.onreadystatechange = trataRetorno;
  http_request.open('POST', '/cgi-bin/PercentEntrada', true);
  http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  
  conteudoRequisicao = "";
  myForm = document.forms[0];
  for(i = 0; i < myForm.elements.length; i++){
	  elementos = myForm.elements[i];
	  if(elementos.name != ""){
		conteudoRequisicao += elementos.name + "=" + escape(elementos.value) + "&";
	  }
  }
  conteudoRequisicao = conteudoRequisicao.substring(0, conteudoRequisicao.length -1);
  http_request.send(conteudoRequisicao);  
}

function trataRetorno() {
	if (http_request.readyState == 4){
		if (http_request.status == 200){
			if(http_request.responseText == 20){
				document.name.percent.value = "0.20";
				document.getElementById("Layer30").style.visibility = "hidden";
				document.getElementById("Layer20").style.visibility = "visible";
				MM_changeValor("0.20");
			} 
			else{
				document.name.percent.value = "0.30";
				document.getElementById("Layer20").style.visibility = "hidden";
				document.getElementById("Layer30").style.visibility = "visible";
				MM_changeValor("0.30");
			}
		} 
	}
}

function custom_print(){
	document.all("imprimir").style.visibility = 'hidden';
	window.print();
	document.all("imprimir").style.visibility = 'visible';
}

function toNumber(valor){
	valor = removeStr(valor,'.');
	valor = changeStr(valor, ',', '.');
	return valor;
}

function reload()	{
	window.location = window.location;
}

// Fun&ccedil;ões Macromedia -----------------------------------------------------------------------------------------------
function MM_changeValorCampo(){
  var percentual = document.name.percent.value;
  MM_changeValor(percentual);
}

function MM_changeValor(percentual) {
	//if (document.form.vlEntradaInteiro.value == "") {
	if (document.name.bem.options[document.name.bem.selectedIndex].value != "Equipamentos de Inform&aacute;tica"){ 
		if(document.name.vlBemInteiro.value != ''){
			var valor = (trocaChar(document.name.vlBemInteiro.value,",",".") * percentual) + 0.009999999;
			document.name.vlEntradaInteiro.value = Money(valor);
		 }
	  }
	//}
}

function displayWindow(theURL,winName,width,height,features) { 
	var window_width = width;
	var window_height = height;
	var newfeatures= features;
	var window_top = (screen.height-window_height)/2;
	var window_left = (screen.width-window_width)/2;
	newWindow=window.open(''+ theURL + '',''+ winName + '','width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + ',features=' + newfeatures + '');
	newWindow.focus();
}

function MM_displayWindow(theURL,winName,features) { //v2.0
  var window_width = 800;
  var window_height = 520;
  var newfeatures= features;
  var window_top = (screen.height-window_height)/2;
  var window_left = (screen.width-window_width)/2;
  features = features + ',width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left;
  window.open(theURL,winName,features);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_changeValorCampo(){
  var percentual = document.name.percent.value;
  MM_changeValor(percentual);
}

function MM_changeValor(percentual) {
//  if (document.form.vlEntradaInteiro.value == "") {
	  if (document.name.bem.options[document.name.bem.selectedIndex].value != "Equipamentos de Inform&aacute;tica")
	  { 
	     if(document.name.vlBemInteiro.value != '')
		 {
 		   var valor = (trocaChar(document.name.vlBemInteiro.value,",",".")
											 * percentual) + 0.009999999;
		   document.name.vlEntradaInteiro.value = Money(valor);
		 }
	  } 
//  }
}

	function MM_CheckFlashVersion(reqVerStr,msg){
		with(navigator){
			var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
			var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
			if (!isIE || !isWin){  
				var flashVer = -1;
				if (plugins && plugins.length > 0){
					var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
					desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
					if (desc == "") flashVer = -1;
					else{
						var descArr = desc.split(" ");
						var tempArrMajor = descArr[2].split(".");
						var verMajor = tempArrMajor[0];
						var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
						var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
						flashVer =  parseFloat(verMajor + "." + verMinor);
					}
				}
				// WebTV has Flash Player 4 or lower -- too low for video
				else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;
	
				var verArr = reqVerStr.split(",");
				var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
		
				if (flashVer < reqVer){
					if (confirm(msg))
						window.location = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
				}
			}
		} 
	}


function redireciona(url){
				location.href=url;
			}
