/**

//Bloco de código para esconder e mostra form - formatadadosie
var Ver4 = parseInt(navigator.appVersion) >= 4
var IE4 = ((navigator.userAgent.indexOf("MSIE") != -1) && Ver4)
var block = "formulario";
function esconde() {	document.form.style.visibility = "hidden" }
function mostra() { document.form.style.visibility = "visible" }
//Bloco de código para esconder e mostra form

function setHelp(txt) { help.innerText = txt ; }

function main(campofoco) {
	var i;
	if (campofoco == '') 
		return false;
	// verifica se existe mais de um formulário definido
	if(document.forms.length > 1)
		// se existir, percorre os elementos de todos os formulários
	   	for (i = 0; i < document.forms.length; i++)
	  		for (j = 0; j < document.forms[i].elements.length; j++)
			{
				if ( (campofoco == "senhaConta" || campofoco == "senhaAtual") && document.applets["tclJava"] )
					document.applets["tclJava"].setFocus();
			   	else if (campofoco == document.forms[i].elements[j].name)
					document.forms[i].elements[campofoco].focus();  
			}
	else if (document.forms.length == 1)
		   	for (i = 0; i < document.forms[0].elements.length; i++)
			{
				if ( (campofoco == "senhaConta" || campofoco == "senhaAtual") && document.applets["tclJava"] )
					document.applets["tclJava"].setFocus();
				else if (campofoco == document.forms[0].elements[i].name)
					document.forms[0].elements[campofoco].focus();  
			}
}  
   
function Apaga(){
	// verifica se existe mais de um formulário definido
	if(document.forms.length > 1)
		// se existir, percorre os elementos de todos os formulários
	   	for (i = 0; i < document.forms.length; i++)
	  		for (j = 0; j < document.forms[i].elements.length; j++)
			{
				var element = document.forms[i].elements[j];
				if(element.nodeName == "INPUT" && element.type == "text")
  				    element.value="";  
			}	
		// só existe um formulário cujos elementos são zerados
	else if (document.forms.length == 1)
		   	for (i = 0; i < document.forms[0].elements.length; i++)
			{
				var element = document.forms[0].elements[i];
				if(element.nodeName == "INPUT" && element.type == "text")
  				    element.value="";  
			}	
}

function FormataDado(campo,tammax,pos,teclapres){
	var tecla = teclapres.keyCode;
//	vr = document.form[campo].value;
	// ao invés de recuperar valor do campo utilizadno o form, vou
	// pegar pelo evento<b></b>
	vr = event.srcElement.value;
	vr = vr.replace( "-", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length ;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){ tam = tam - 1 ; }
			
	if ( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){
	 		// document.form[campo].value = vr ;
			event.srcElement.value = vr;

		}
		if ( tam > pos && tam <= tammax ){
			// document.form[campo].value = vr.substr( 0, tam - pos ) + '-' + vr.substr( tam - pos, tam );}
			event.srcElement.value = vr.substr( 0, tam - pos ) + '-' + vr.substr( tam - pos, tam );
		}
			
	}
	//alert ("campo: " + document.form[campo+1].name);
//	if ( !teclapres.shiftKey && tecla == 9 && document.form[campo+1].name == "senhaConta" && document.applets['tclJava'] ){
		//alert("aki 1");
//			document.applets['tclJava'].setFocus();
//	}
}

function FormataJuros(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = event.srcElement.value;

	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ",", "" );
	tam = vr.length;
	
	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
	 		event.srcElement.value = vr ; 
		}
	 	if ( tam > 2){
	 		event.srcElement.value = vr.substr( 0, tam - 4 ) + ',' + vr.substr( tam - 4, tam ) ; 
		}
	}
}

//Verificar se é numérico
function isNumeric( valor )
{
	for( var i = 0 ; i < valor.length ; i++ )
		if( (valor.charAt( i ) < "0") || (valor.charAt( i ) > "9") )
			return false;
	return true;
}

function SaltaCampo (campo,prox,tammax,teclapres){
	var tecla = teclapres.keyCode;
	vr = event.srcElement.value;
	if( tecla == 109 || tecla == 188 || tecla == 110 || tecla == 111 || tecla == 223 || tecla == 108 ){
		recuperaPai(event.srcElement.parentElement, "FORM")[campo].value = vr.substr( 0, vr.length - 1 ); }
	else{
	 	vr = vr.replace( "-", "" );
	 	vr = vr.replace( "/", "" );
	 	vr = vr.replace( "/", "" );
	 	vr = vr.replace( ",", "" );
	 	vr = vr.replace( ".", "" );
	 	vr = vr.replace( ".", "" );
	 	vr = vr.replace( ".", "" );
	 	vr = vr.replace( ".", "" );
	 	tam = vr.length;	
		
	 	if (tecla != 0 && tecla != 9 && tecla != 16 )
			if ( tam == tammax )	
			{
				if ( prox == "senhaConta" || (document.form.elements[prox] && document.form.elements[prox].name == "senhaConta") ) {
					if ( document.applets['tclJava'] )
						document.applets['tclJava'].setFocus();
					else if ( document.form.senhaConta )
						document.form.senhaConta.focus();
				}else
				//document.form[prox].focus() ;	
				recuperaPai(event.srcElement.parentElement, "form")[prox].focus();
			}
	}
}

function recuperaPai(elemento, nomeDoPai)
{
   while(elemento.tagName != "FORM") 
	   elemento = elemento.parentElement;
   return elemento;
   
}

function FormataMesAno(Campo,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.form[Campo].value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;

	if ( tecla != 9 && tecla != 8 ){
		if ( tam > 2 && tam < 7 )
			document.form[Campo].value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, tam ); }
}

function FormataData(Campo,teclapres) {
	var tecla = teclapres.keyCode;
//	vr = document.form[Campo].value;
	vr = event.srcElement.value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;

	if ( tecla != 9 && tecla != 8 ){
		if ( tam > 2 && tam < 5 )
		{
//			document.form[Campo].value = vr.substr( 0, tam - 2  ) + '/' + vr.substr( tam - 2, tam );
			event.srcElement.value = vr.substr( 0, tam - 2  ) + '/' + vr.substr( tam - 2, tam );
		}
		if ( tam >= 5 && tam <= 10 )
		{
//			document.form[Campo].value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 4 ); }
			event.srcElement.value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 4 );
		 }
	}

//	alert ("campo");
//	for (var ct = 0; ct < document.form.elements.length; ct++) {
//		if (document.form.elements[ct].name == document.form.elements[Campo].name) {
//			if ( !teclapres.shiftKey && tecla == 9 && document.form[ct+1].name == "senhaConta" && document.applets['tclJava'] ){
//				document.applets['tclJava'].setFocus();
//			}	
//		}
//	}
}

 function VerificaJava()
 	{
	if (navigator.javaEnabled())
		document.form.javas.value="sim"
	}

	

//Limitador de tamanho de texto para campos do tipo Textarea	
function limita(campo){
	if(document.forms.length > 1){
		var tamanho = document.form[1][campo].value.length;
		var tex=document.form[1][campo].value;
		if (tamanho>=1199){	document.form[1][campo].value=tex.substring(0,1199); }
		return true;
		}
	else{
		var tamanho = document.form[campo].value.length;
		var tex=document.form[campo].value;
		if (tamanho>=1199){	document.form[campo].value=tex.substring(0,1199); }
		return true;
		}
}

function contacampo(campo, tamtxt){
	if(document.forms.length > 1)
		document.form[1][tamtxt].value = 1200-document.form[1][campo].value.length;
	else	
		document.form[tamtxt].value = 1200-document.form[campo].value.length;
}
 
function FormataCpf(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	// vr = document.form[campo].value;
	vr = event.srcElement.value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
	 		event.srcElement.value = vr ; }
	 	if ( (tam > 2) && (tam <= 5) ){
	 		event.srcElement.value = vr.substr( 0, tam - 2 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 6) && (tam <= 8) ){
	 		event.srcElement.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 9) && (tam <= 11) ){
	 		event.srcElement.value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 12) && (tam <= 14) ){
	 		event.srcElement.value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 15) && (tam <= 17) ){
	 		event.srcElement.value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ;}
	}		
}

function FormataCgc(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	// vr = document.form[campo].value;
	vr = event.srcElement.value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
	 		event.srcElement.value = vr ; }
	 	if ( (tam > 2) && (tam <= 6) ){
	 		event.srcElement.value = vr.substr( 0, tam - 2 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 7) && (tam <= 9) ){
	 		event.srcElement.value = vr.substr( 0, tam - 6 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 10) && (tam <= 12) ){
	 		event.srcElement.value = vr.substr( 0, tam - 9 ) + '.' + vr.substr( tam - 9, 3 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 13) && (tam <= 14) ){
	 		event.srcElement.value = vr.substr( 0, tam - 12 ) + '.' + vr.substr( tam - 12, 3 ) + '.' + vr.substr( tam - 9, 3 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 15) && (tam <= 17) ){
	 		event.srcElement.value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ;}
	}		
}

//os métodos abaixo são utilizados na Applet do Teclado Virtual
function getSenha() {
	if ( document.applets['tclJava'] ){
		var senha = document.applets['tclJava'].getSenha();
		document.form['senhaConta'].value = senha;
	}
}

function enviaSub() {
	document.form.submit();
	return false;
}


function mudaFoco(campo)
{
	if(campo == "98") {
		//var nb = document.form.elements[document.form.elements.length - 1].name;
		//if(nb.indexOf(".x"))
		//	nb = nb.substring(0,nb.length-2);
		//document.form.elements[nb].focus();
		return;
	}
	if( (campo == "senhaConta" || (document.form.elements[campo] && document.form.elements[campo].name == "senhaConta")) && document.applets['tclJava'] )
		document.applets.tclJava.setFocus();
	else if (document.form.elements[campo])
		document.form.elements[campo].focus();
}

function mostraBalao(mst) {
	if (mst) {
		setHelp("Informe sua senha de 8 dígitos, clicando com o mouse no teclado virtual na tela");
		//document.all["balaoApplet"].style.visibility="visible";
	}
	else {
		setHelp("");
		//document.all["balaoApplet"].style.visibility="hidden";
	}
}

function teclaTab(teclaPress) {
	if(teclaPress.keyCode == 9)
		focaApplet();
}

function focaApplet() {
	if (document.applets['tclJava'] ) {
		document.applets.tclJava.setFocus();
	}
}
	
function focaApplet2(nomeApplet) {
	if (document.applets[nomeApplet] ) {
		document.applets[nomeApplet].setFocus();
	}
}

function focaApplet3(prox,teclapres) {
	var tecla = teclapres.keyCode;
	if ( !teclapres.shiftKey && tecla == 9 && document.form.elements[prox] && document.form.elements[prox].name == "senhaConta" && document.applets['tclJava'] )
		document.applets['tclJava'].setFocus();
}

function setaCod(numCod) {
	if (document.form.elements['numCod'])
		document.form.elements['numCod'].value = numCod;
}
*/

// Funções criados na IQualy para algumas validações.

/**
 * Essa função existe para retornar um campo a partir de uma string com
 * o ID do campo. Como podemos ter problemas de compatibilidade com getElementById,
 * separei ele em uma função. Assim, se precisar retornar o campo pelo ID usando
 * outras funções, basta modificar esta aqui e o resto vai funcionar.
 */
function Campo(nomeDoCampo) {
	return document.getElementById(nomeDoCampo);
}

function TipoBrowser(){
//    Usado para identificar o tipo do browser
    if (navigator.userAgent.indexOf("MSIE") != -1) {
            return "IE";
    } else {            
            return "NS";
    }
}		



function CampoAtual() {
	return window.event.srcElement;
}

function TeclaAtual() {
//	if(TipoBrowser()=="IE")
		return window.event.keyCode;
//	else
//		return window.event.charCode;
}

// Funções úteis //

function LimpaCampo(campo) {
	if (campo.value.length > 0)
		campo.value = '';
}

function Check(campoChecked, campoUnchecked) {
	campoChecked.checked = true;
	campoUnchecked.checked = false;
}

function SomenteNumeros() {
	var tecla = TeclaAtual();
	return TeclaNumerica(tecla) || TeclaDeControle(tecla)
}




function SomenteNumerosJaDigitados(objTextControl){

	var strValidNumber="1234567890";
	
	for (nCount=0; nCount < objTextControl.value.length + 1; nCount++) {
	
		strTempChar=objTextControl.value.substring(nCount - 1,nCount);
	
		if (strValidNumber.indexOf(strTempChar,0)==-1) {
			objTextControl.value = objTextControl.value.substring(0,nCount - 1);
		}

	}
	
}


function TabParaProximoCampo(quantidadeDeCaracteres, proximoCampo) {
	if (proximoCampo == null || proximoCampo == 'undefined')  return true;

	if (CampoAtual().value.length >= quantidadeDeCaracteres 
		&& !TeclaDeControle(TeclaAtual())) {

			proximoCampo.focus();
	}
}

function SomenteNumerosETabParaProximoCampo(quantidadeDeCaracteres, proximoCampo) {
	if (SomenteNumeros()) {
		TabParaProximoCampo(quantidadeDeCaracteres, proximoCampo)
		return true;
	}
	return false;
}

function TeclaNumerica(tecla) {
	return (tecla >= 48 && tecla <= 57) || (tecla >= 96 && tecla <= 105);
}

function ZerosAEsquerda(valor, tamanhoTotalComZeros) {
}

/**
 * Teclas de controle são: Tab, Backspace, Del, Seta Esquerda, Seta Direita, Home, End, Ctrl+X, Ctrl+C, Ctrl+V, Ctrl+Ins, Shift+Ins e Shift+Del
 */
function TeclaDeControle(tecla) {
	return (EhTab(tecla)
			|| EhBackspace(tecla) 
			|| EhDelete(tecla)
			|| tecla == 37 
			|| tecla == 39 
			|| tecla == 36 
			|| tecla == 35);
}

function EhBackspace(tecla) {
	return tecla == 8;
}

function EhDelete(tecla) {
	return tecla == 46 ;
}

function EhTab(tecla) {
	return tecla == 9;
}

String.prototype.trim = function(){
	s = this.replace(/^\s*/,'').replace(/\s*$/, '');
	return s;
} 

String.prototype.isEmpty = function() {
	return this.trim().length == 0;
}

function FormataValorDefaultText(strNMCampo, formato, intOnFocus) {
	
	var strNull = '';
	
	if (intOnFocus == 1) {
		if (window.document.forms[0].elements[strNMCampo].value + '' == formato) {
			window.document.forms[0].elements[strNMCampo].value = '';
		}
	}
	
	if (intOnFocus == 0) {
		if (window.document.forms[0].elements[strNMCampo].value + '' == '') {	
			window.document.forms[0].elements[strNMCampo].value = formato;
		}
	}
		
}



function FormataNumeroCooperativa() {

	var tecla = TeclaAtual();
	var campo = CampoAtual();
	var tammax = 4;

	if (EhTab(tecla)) return true;	
	if (!SomenteNumeros()) return false;
	
	//Retira zeros à esquerda
	var vrNumber = Number(campo.value);
	var vr = String(vrNumber);
	var tam = vr.length;

	if (EhBackspace(tecla) && tam >= 0) {
		tam -= 2;
	}

	var zeros = "";
	for (var x = tam; x < tammax - 1; x++) {
		zeros += "0";
	}
	
	campo.value = zeros + vr;
}



function FormataContaCorrente() {
	var tecla = TeclaAtual();
	var campo = CampoAtual();
	
	if (TeclaDeControle(tecla) && !EhBackspace(tecla) && !EhDelete(tecla)) return;

	//Remove toda a formatação
	vrUnformatted = campo.value;
	vrUnformatted = vrUnformatted.replace("-", "");
	//Retira zeros à esquerda
	var vrNumber = Number(vrUnformatted);
	var vr = String(vrNumber);

	//Coloca formatação
	var zeros = "";
	for (var x = vr.length; x < 9; x++) {
		zeros += "0";
	}
	
	campo.value = zeros + vr.substr(0, vr.length - 1) + '-' + vr.substr(vr.length - 1, 1);
}



function FormataValor(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;

	if (EhTab(tecla)) return true;
	if ((tecla != 8) && !TeclaNumerica(tecla)) return false;
	
	vr = campo.value;

	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	tam = vr.length;

	if (tam >= tammax){ 
		vr = vr.substr(0,vr.length - 1);		
	}
	
	
	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
	 		campo.value = vr ; 
		}
	 	if ( (tam > 2) && (tam <= 5) ){
	 		campo.value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; 
		}
	 	if ( (tam >= 6) && (tam <= 8) ){
	 		campo.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; 
		}
	 	if ( (tam >= 9) && (tam <= 11) ){
	 		campo.value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; 
		}
	 	if ( (tam >= 12) && (tam <= 14) ){
	 		campo.value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; 
		}
	 	if ( (tam >= 15) && (tam <= 17) ){
	 		campo.value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ;
		}
	}		
		
}



//Temporario**************************
//************************************

function FormataValorTemp(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;

	if (EhTab(tecla)) return true;
	if ((tecla != 8) && !TeclaNumerica(tecla)) return false;
	
	vr = CampoAtual().value;

	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
	 		CampoAtual().value = vr ; 
		}
	 	if ( (tam > 2) && (tam <= 5) ){
	 		CampoAtual().value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; 
		}
	 	if ( (tam >= 6) && (tam <= 8) ){
	 		CampoAtual().value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; 
		}
	 	if ( (tam >= 9) && (tam <= 11) ){
	 		CampoAtual().value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; 
		}
	 	if ( (tam >= 12) && (tam <= 14) ){
	 		CampoAtual().value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; 
		}
	 	if ( (tam >= 15) && (tam <= 17) ){
	 		CampoAtual().value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ;
		}
	}		
}

//************************************
//************************************


function limpaCamposLogin() {
	document.forms[0].txtNumCooperativa.value = '';
	document.forms[0].txtNumContaCorrente.value = '';
	document.forms[0].txtNumControle.value = '';
	document.forms[0].txtNumCooperativa.focus();
}

function ValidaCamposLogin() {
	var strAux='';
	if (document.forms[0].txtNumCooperativa.value == '' || document.forms[0].txtNumCooperativa.value == '0000') {
		strAux = '-Informe o num. da Cooperativa.\n';
	}
	if (document.forms[0].txtNumContaCorrente.value == '' || document.forms[0].txtNumContaCorrente.value == '00000000-0' || document.forms[0].txtNumContaCorrente.value == '000000000-0') {
		strAux += '-Informe o num. de uma Conta Corrente.\n';
	}
	if (document.forms[0].txtNumControle.value == '' || document.forms[0].txtNumControle.value == '0') {
		strAux += '-Informe o Seq. Cartao, que e o numero fornecido no momento\ndo cadastramento da senha de acesso ao SicoobNet.\n';
	}
	
	if (strAux != '') {
		strAux = 'Campos Invalidos: \n' + strAux;
		alert(strAux);
		return false;
	}
	else {
		return true;
	}

}














//Campo numérico inteiro, funciona com qualquer navegador
function SomenteNumeros2(strNMCampo, ev) {
	var IN_VNIx=0;
	var ST_VNIDigitos = "0123456789";

	var letra = 0;
	
	if (ev.keyCode) {
		if (   ev.keyCode < 20 
			|| ev.keyCode == 35 
			|| ev.keyCode == 36 
		    || ev.keyCode == 37 
		    || ev.keyCode == 39 
		    || ev.keyCode == 38 
		    || ev.keyCode == 40 
		    || ev.keyCode == 46 
		    || ev.keyCode == 27) {
			return true;
		}
		letra = ev.keyCode;
	} else if (ev.which) {
		if (   ev.which < 20 
			|| ev.which == 35 
			|| ev.which == 36 
		    || ev.which == 37 
		    || ev.which == 39 
		    || ev.which == 38 
		    || ev.which == 40 
		    || ev.which == 46 
		    || ev.which == 27) {
			return true;
		}
		letra = ev.which;
	}
	
	letra = new String(letra);	
	letra = String.fromCharCode(letra);
	
	if( ST_VNIDigitos.indexOf(letra.substr(0, 1)) == -1 ) {
	
		for (var i = 0; i < window.document.forms[0].elements[strNMCampo].value.length + 1; i++) {
		
			strTempChar = window.document.forms[0].elements[strNMCampo].value.substring(i - 1, i);
		
			if (ST_VNIDigitos.indexOf(strTempChar,0)==-1) {
				window.document.forms[0].elements[strNMCampo].value = window.document.forms[0].elements[strNMCampo].value.substring(0,i - 1);
			}
			
		}		
	}
		
}


function FormataContaCorrente2(strNMCampo) {

	var vr = window.document.forms[0].elements[strNMCampo].value;
	vr = vr.replace("-", "");	
	vr = Number(vr);
	vr = String(vr);

	//Coloca formatação
	var zeros = "";
	for (var x = vr.length; x < 9; x++) {
		zeros += "0";
	}
	
	window.document.forms[0].elements[strNMCampo].value = zeros + vr.substr(0, vr.length - 1) + '-' + vr.substr(vr.length - 1, 1);
}


function FormataNumeroCooperativa2(strNMCampo) {

	var tammax = 4;

	//Retira zeros à esquerda
	var vrNumber = Number(document.forms[0].elements[strNMCampo].value);
	var vr = String(vrNumber);
	var tam = vr.length;
	var zeros = "";
	
	
	if (tam >= 0) {
		tam -= 2;
	}
	
	for (var x = (tam + 1); x < tammax - 1; x++) {
		zeros += "0";
	}
	
	document.forms[0].elements[strNMCampo].value = zeros + vr;
	
}

function validaFormOut(){
    var txtNumCooperativa = document.getElementById("txtNumCooperativa");
    var txtNumContaCorrente = document.getElementById("txtNumContaCorrente");
    
    if(txtNumCooperativa.value.length < 4){
        alert("Agência deve conter 4 dígitos.");
        txtNumCooperativa.focus();
        return false;
    }
    if(txtNumContaCorrente.value.length < 10){
        alert("Conta Corrente deve conter, pelo menos, 10 dígitos.");
        txtNumContaCorrente.focus();
        return false;
    }
    document.forms[0].submit();
}