//<!-- -->
//Função para determinar se data passada é maior que a data atual
function ValidaDataAtual(mes,dia,ano){
  var datacomparada = new Date(mes + "/" + dia + "/" + ano);
  var dataatual = new Date();
  if(datacomparada > dataatual){
    return false;
  }else{
    return true;
  }
}

var bLock = false;

function fncLock(){
  if(bLock == false){
    document.body.id = 'idUnicoDoAguarde'
    window.open ('BRRPopAguarde.asp','','channelmode=no, directories=no, width=361, height=90, top=' + parseInt((screen.height / 2) - 50) + ', left=' + parseInt((screen.width / 2) - 180) + ', location=no, menubar=no, resizable=no, scrollbars=no, status=no, titlebar=no, toolbar=no')
    bLock = true;
    return true;
  }else{
    return false;
  }
}

function PedeSenha(e,t){
  if(e == ""){return false}
  var ret = window.showModalDialog ("BRRPedeSenha.asp?CodParametro=" + e + "&texto=" + t,"TelaDeSenha","dialogTop:100px;dialogHeight:500px;dialogWidth:450px;center:yes")
  return ret;
}

function TeclaValor(e)
{
	if (document.all) // Internet Explorer
		var tecla = event.keyCode;
	else if(document.layers) // Nestcape
		var tecla = e.which;
		if (tecla > 47 && tecla < 58) // numeros de 0 a 9
			return true;
		else
			{	if ((tecla == 44 & e.value.indexOf(",")==-1))
					return true;
				if (tecla != 8) // backspace
					event.keyCode = 0;
					//return false;
				else
					return true;
			}
}
	
function fncCompletaData(obj){
	if(obj.value.length == 1){
		obj.value = "0" + obj.value
	}
}

VerifiqueTAB=true;
function Mostra(quem, tammax) {
		if ( (quem.value.length == tammax) && (VerifiqueTAB) && (document.selection.createRange().text.length == 0)) {
			var i=0,j=0, indice=-1;			
			for (i=0; i<document.forms.length; i++) {
				for (j=0; j<document.forms[i].elements.length; j++) {
					if (document.forms[i].elements[j].name == quem.name) {
						indice=i;
						break;
					}
				}
				if (indice != -1)
			         break;
			}
			for (i=0; i<=document.forms[indice].elements.length; i++) {
				if (document.forms[indice].elements[i].name == quem.name) {
					while ( (document.forms[indice].elements[(i+1)].type == "hidden") &&
							(i < document.forms[indice].elements.length) ) {
								i++;
					}
					document.forms[indice].elements[(i+1)].select();
					VerifiqueTAB=false;					
					break;
				}
			}
		}	
VerifiqueTAB=true;	
}

function PararTAB(quem) 
{ 
   VerifiqueTAB=false; 
} 

function FormataNumero(valor){
	var getvalor = valor + ""
	
	if(getvalor.indexOf(".")==-1){
	getvalor+=",00"
	}else{

	getvalor = getvalor.substring(0,getvalor.indexOf(".") + 3)
	}
	if(getvalor.substring(getvalor.indexOf(".")).length==2){
		getvalor +="0"
	}
	getvalor = getvalor.replace(".",",")


	return getvalor

}

function FormataNumeroCalc(valor){
	var result;
	var valOpera = valor.toString();
	var parte1,parte2
	
  if (valOpera.indexOf(".")== -1 && valOpera.indexOf(",") == -1){
    return valOpera + ".00";
  }else{
    valOpera = valOpera + "00"
    valOpera = valOpera.substring(0,valOpera.indexOf(".")+3)
  }
	
	valOpera = valOpera.replace(",","");
	valOpera = valOpera.replace(".","");

	parte1 = valOpera.slice(0,valOpera.length-2)
	parte2 = "." + valOpera.slice(valOpera.length-2,valOpera.length)

  return parte1 + parte2;
	return result;
}

function FormataNumero2(valor){
  var Inteiro;
  var Decimal;
  
  Inteiro = valor.substring(valor.length -3,5)//valor.indexOf(".");
  //Inteiro = valor.replace(/\,/g,''.'');

return Inteiro;
}

function FormataNumeroBr(valor){
	var getvalor = valor + ""
	
	if(getvalor.indexOf(".")==-1){
	   getvalor += ",00"
	} else {
       getvalor = getvalor.substring(0,getvalor.indexOf(".") + 3)
	}
	if(getvalor.substring(getvalor.indexOf(".")).length==2){
		getvalor +="0"
	}
	getvalor = getvalor.replace(".",",")

    var pos = getvalor.indexOf(",") - 3
    while ( pos > 0) {    
       getvalor = getvalor.substr(0, pos) + "." + getvalor.substr(pos)
       pos = getvalor.indexOf(".") - 3
    }

	return getvalor

}
function ChecarTAB() 
{ 
   VerifiqueTAB=true; 
} 
	
function prcValidaData(mes, dia, ano) {
	var retval = false;
	if (parseInt(mes,10) > 0 && parseInt(mes,10) <= 12)
	{
		mes = parseInt(mes,10);
		if (parseInt(ano,10) >= 0000)
		{
			if ((parseInt(ano,10) % 4) == 0)
			{
				bissexto = 1;
			}
			else
			{
				bissexto = 0;
			}
			dia = parseInt(dia,10);
			if (((mes==1 || mes==3 || mes==5 || mes==7 || mes==8 || mes==10 || mes==12) && (dia >= 1 && dia <= 31)) ||
				((mes==4 || mes==6 || mes==9 || mes==11) && (dia >= 1 && dia <= 30)) ||
				(mes==2 && dia >= 1 && dia <= (28 + bissexto)))
			{
				retval=true;
			}
		}
	}
	return retval;
}


function verifica_mail(campo) //função que verifica se o email é válido
	{
	   returnVal = true;
	   if (campo.value != "")
	   {
	         if (campo.value.indexOf("@") == -1){
	            alert("e-mail inválido.");
				returnVal = false;
				campo.focus();
		  		campo.select();
	         }
	         else if(campo.value.indexOf(".") == -1){
	            	alert("Campo e-mail inválido.");
	             	returnVal = false;
					campo.focus();
					campo.select();
	       	}
			else if(campo.value.indexOf("@.") != -1){
	            	alert("Campo e-mail inválido.");
	             	returnVal = false;
					campo.focus();
					campo.select();
			}
			else if(campo.value.indexOf("www.") != -1){
	            	alert("Campo e-mail inválido.");
	             	returnVal = false;
					campo.focus();
					campo.select();
			}
			else if(campo.value.indexOf("@@") != -1){
	            	alert("Campo e-mail inválido.");
	             	returnVal = false;
					campo.focus();
					campo.select();
			}
			else if(campo.value.indexOf("..") != -1){
	            	alert("Campo e-mail inválido.");
	             	returnVal = false;
					campo.focus();
					campo.select();
			}
		}
		return returnVal;
	}
	
//CRIADA POR INGRID GOMES EM 22/05/2006
function TravaOutrosCaracteres(e)//função que não deixa incluir nenhum caracter inválido no campo
{
	if (document.all) // Internet Explorer
		var tecla = event.keyCode;
	else if(document.layers) // Nestcape
		var tecla = e.which;
	
	if(!(tecla >= 33 && tecla <= 64) && !(tecla >= 91 && tecla <= 96) && !(tecla >= 123 && tecla <= 126) && tecla != 162 && tecla != 163 && tecla != 167 && tecla != 168 && tecla != 170 && tecla != 172 && tecla != 176 && tecla != 180 && tecla != 186 && tecla != 192 && tecla != 193 && tecla != 200 && tecla != 201 && tecla != 204 && tecla != 205 && tecla != 210 && tecla != 211 && tecla != 224 && tecla != 225 && tecla != 228 && !(tecla >= 232 && tecla <= 237) && tecla != 242 && tecla != 243 && tecla != 249 && tecla != 250)
		return true;
	else
	{
	  if (tecla != 8) // backspace
	   event.keyCode = 0;
	  else
	   return true;
	}
}

function TravaEndereco(e)//função que não deixa incluir nenhum caracter inválido no campo endereço.
{
	if(document.all) // Internet Explorer
		var tecla = event.keyCode;
	else if(document.layers) // Nestcape
		var tecla = e.which;
	
	if(!(tecla >= 33 && tecla <= 43) && tecla != 46 && !(tecla >= 58 && tecla <= 64) && !(tecla >= 91 && tecla <= 96) && !(tecla >= 123 && tecla <= 126) && tecla != 162 && tecla != 163 && tecla != 167 && tecla != 168 && tecla != 170 && tecla != 172 && tecla != 176 && tecla != 180 && tecla != 186 && tecla != 192 && tecla != 193 && tecla != 200 && tecla != 201 && tecla != 204 && tecla != 205 && tecla != 210 && tecla != 211 && tecla != 224 && tecla != 225 && tecla != 228 && !(tecla >= 232 && tecla <= 237) && tecla != 242 && tecla != 243 && tecla != 249 && tecla != 250)
		return true;
	else
	{
	  if(tecla != 8) // backspace
	   event.keyCode = 0;
	  else
	   return true;
	}
}

function Tecla(e) //função que só permite que digite números de 0 a 9
	{		
		if (document.all) // Internet Explorer
			var tecla = event.keyCode;
		else if(document.layers) // Nestcape
			var tecla = e.which;
			if (tecla > 47 && tecla < 58) // numeros de 0 a 9
				return true;
			else
				{
					if (tecla != 8) // backspace
						event.keyCode = 0;
					else
						return true;
				}
	}
	

function TravaPlic(e)//função que não deixa incluir Plic (')
{
	if (document.all) // Internet Explorer
	 var tecla = event.keyCode;
	else if(document.layers) // Nestcape
	var tecla = e.which;
	if (tecla != 39 && tecla!=34) // diferente de plic (') ou aspas (")
	 return true;
	else
	 {
	  if (tecla != 8) // backspace
	   event.keyCode = 0;
	   //return false;
	  else
	   return true;
	 }
}

function TeclaMoney(obj,e)
{
	if (document.all) // Internet Explorer
		var tecla = event.keyCode;
	else if(document.layers) // Nestcape
		var tecla = e.which;
		//document.selection.createRange().text.length;
		if (tecla==44 && (obj.value.search(",") != -1 || obj.value.length == 0 || document.selection.createRange().text.length == obj.value.length)) //verifica se já tem (,) e se já tem algum número digitado
			return false;
		if ((tecla > 47 && tecla < 58) || tecla == 44) // numeros de 0 a 9 ou ,
			return true;
		else
			{
				if (tecla != 8) // backspace
					event.keyCode = 0;
					//return false;
				else
					return true;
			}
}
function fncLTrim(pObjTexto) //função que verifica se tem espaço a esquerda
 {
  while(''+pObjTexto.value.charAt(0)==' '){
   pObjTexto.value=pObjTexto.value.substring(1,pObjTexto.value.length);
   }
   if (pObjTexto.value != '')
   {
	   return true;
	}
  pObjTexto.focus()
 }

/*Funcao que valida data
//recebe valor dia,mes,ano
returno true se data for valida e false se data for invalida
*/
function fncValidaData(dia,mes,ano) {
	
	if(dia.length==1)
		return false
		
	if(mes.length==1)
		return false
	
	
	if (parseInt(mes,10) > 0 && parseInt(mes,10) <= 12)
	{
		mes = parseInt(mes,10);
		if (parseInt(ano,10) >= 0000)
		{
			if ((parseInt(ano,10) % 4) == 0)
			{
				bissexto = 1;
			}
			else
			{
				bissexto = 0;
			}
			dia = parseInt(dia,10);
			if (((mes==1 || mes==3 || mes==5 || mes==7 || mes==8 || mes==10 || mes==12) && (dia >= 1 && dia <= 31)) ||
				((mes==4 || mes==6 || mes==9 || mes==11) && (dia >= 1 && dia <= 30)) ||
				(mes==2 && dia >= 1 && dia <= (28 + bissexto)))
			{
				return   true
			}
			
				
		}
		
	}return false
}

function fncValidaTamanhoData(dia,mes,ano){
	
	var datacomparada = new Date(mes + "/" + dia + "/" + ano )

	var datainicial = new Date("01/01/1900")
	var datafinal	= new Date("06/06/2079")
	
	if((datacomparada < datainicial) || ( datacomparada > datafinal)){
		return false
	}
	else if(ano.length < 4){
		return false
	}
	else{
		return true
	}

	

}
function fncValidaDataInicialFinal(pdatainicio,pdatafim){
//data inicio	MM/DD/YYYY
//data fim		MM/DD/YYYY

	var datainicio = new Date(pdatainicio)
	var datafim = new Date(pdatafim)

	if(datainicio > datafim){
		return false
	}
	else{
		return true
	}

}


//Funcao para validar DDD
//Chamar funcao no evento onKeyUp
//ex: onKeyUp="return fncValidaDDD(this);"
function fncValidaDDD(obj){
	var dddinvalido = "0-00-1-2-3-4-5-6-7-8-9-10-20-23-25-26-28-29-36-39-40-50-52-56-57-58-59-60-64-67-70-72-76-80-87-89-90-93-94-97-99"
	if((dddinvalido.indexOf(obj.value)!=-1) && (obj.value !="") &&(obj.value.length>=2)){
		alert("DDD inválido!")
		obj.select()
		return false
	}
	else{return true}
}

//Funcao para validar Telefone
//Chamar funcao no evento onBlur
//ex: onBlur="return fncValidaTelefone(this)"
function fncValidaTelefone(obj){
	if ((obj.value.length < 7) && (obj.value !="")){
		alert("Telefone inválido!")
		obj.select()
		return false
	}else{return true}
	

}

//Funcao que valida o CNPJ
function val_cnpj(strCNPJ){
	
			numero = strCNPJ;
			dig_1 = 0;
			dig_2 = 0;
			controle_1 = 5;
			controle_2 = 6;
		    
			if (numero.length != 14)
			{
				alert("CNPJ inválido !");						
				return false;
			}
			else
			{
				
				for ( i=0 ; i < 12 ; i++)
				{
					//alert(parseFloat(numero.substring(i, i+1)))
					dig_1 = dig_1 + parseFloat(numero.substring(i, i+1) * controle_1);
					
					controle_1 = controle_1 - 1;
					if (i == 3)
					{
						controle_1 = 9;
					}
				}
				resto = dig_1 % 11;
				dig_1 = 11 - resto;
				
				
				if ((resto == 0) || (resto == 1))
				{
					dig_1 = 0;
				}
				for ( i=0 ; i < 12 ; i++)
				{
					dig_2 = dig_2 + parseInt(numero.substring(i, i+1) * controle_2);
					controle_2 = controle_2 - 1;
					if (i == 4)
					{
						controle_2 = 9;
					}
				}
				dig_2 = dig_2 + (2 * dig_1);
				resto = dig_2 %11;
				dig_2 = 11 - resto;
				if ((resto == 0) || (resto == 1))
				{
					dig_2 = 0;
				}
				dig_ver = (dig_1 * 10) + dig_2;
				
				if (dig_ver != parseFloat(numero.substring(numero.length-2, numero.length)))
				{
					alert("CNPJ inválido !");				
					return false;
				}
			}
		    
			return true;
}

//funcao que valida CPF
function val_cpf(strCPF)
{
  dig_1 = 0;
  dig_2 = 0;
  controle_1 = 10;
  controle_2 = 11;
  lsucesso = 1;
  numero = strCPF;
  if (numero.length != 11) {
     alert("CPF inválido!");     
     return false;
  }
  else 
  {
     for ( i=0 ; i < 9 ; i++) {
        dig_1 = dig_1 + parseInt(numero.substring(i, i+1) * controle_1);
	    controle_1 = controle_1 - 1;
     }
	
	
     resto = dig_1 % 11;
     dig_1 = 11 - resto;
     if ((resto == 0) || (resto == 1)) {
	  dig_1 = 0;
     }
     for ( i=0 ; i < 9 ; i++) {
	    dig_2 = dig_2 + parseInt(numero.substring(i, i + 1) * controle_2);
        controle_2 = controle_2 - 1;
     }
     dig_2 = dig_2 + 2 * dig_1;
     resto = dig_2 % 11;
     dig_2 = 11 - resto;
     if ((resto == 0) || (resto == 1)) {
        dig_2 = 0;
     }
     dig_ver = (dig_1 * 10) + dig_2;
     if (dig_ver != parseFloat(numero.substring(numero.length-2,numero.length))) {
	    alert("CPF inválido");	    
 	    return false;
	}
  }
  return true;	
}	


// limita a quantidade de caracteres digitados num text area em TAM caracteres.
// atualiza o total parcial no div que foi passado como parametro.
// obj se refere ao text area propriamente dito
function FncLimitaTextArea(obj, tam, div){  

    div.innerHTML = obj.value.length + " - " + tam
	if(obj.value.length >= tam){
		obj.value = obj.value.slice(0,tam)
		div.innerHTML = tam + " - " + tam
		alert("limite de texto é de " + tam + " caracteres.")		
	}
}

function currencyFormat(fld, milSep, decSep, e) {
var sep = 0;
var key = '';
var i = j = 0;
var len = len2 = 0;
var strCheck = '0123456789';
var aux = aux2 = '';
var whichCode = (window.Event) ? e.which : e.keyCode;

if (whichCode == 13) return true;  // Enter

key = String.fromCharCode(whichCode);  // Get key value from key code

if (strCheck.indexOf(key) == -1) return false;  // Not a valid key

len = fld.value.length;
for(i = 0; i < len; i++)
   if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
   
aux = '';
for(; i < len; i++)
   if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
   
aux += key;
len = aux.length;
if (len == 14) return false; //trava em 14 digitos, tamanho maximo na marlin
if (len == 0) fld.value = '';
if (len == 1) fld.value = '0'+ decSep + '0' + aux;
if (len == 2) fld.value = '0'+ decSep + aux;
if (len > 2) {
   aux2 = '';
   for (j = 0, i = len - 3; i >= 0; i--) {
      if (j == 3) {
        aux2 += milSep;
        j = 0;
      }
      aux2 += aux.charAt(i);
      j++;
   }

   fld.value = '';
   len2 = aux2.length;
   for (i = len2 - 1; i >= 0; i--)
      fld.value += aux2.charAt(i);
   fld.value += decSep + aux.substr(len - 2, len);
}

return false;
}



/*Função que tem por objetivo Não permitir a entrada de Valor menor que zero e com mais de duas casa decimais.   */


function VerificaValor(pValor) {
  var Valor = pValor.value
  
  if (FormataNumeroCalc(Valor.replace(",",".")) <= 0) 
  {	
     alert('Digite um Valor maior do que zero!');
     pValor.focus();
     return false;
  } 
  
   
  if (Valor.indexOf(",") != -1){
    if ((Valor.indexOf(",")+1) == (Valor.length)){
        alert("Valor inválido! Digite somente uma ou duas casas decimais.")
        pValor.focus();
        return false
    }
    if(Valor.substr(Valor.indexOf(",")+1).length > 2){
        alert("Valor inválido! Digite somente uma ou duas casas decimais.")
        pValor.focus();
        return false
    }    
  }
 
 
  return true;
 
}

//Criado por Agnaldo Alves
//Sequencia de numeros separados por virgula
//nao deixa que usuario digite uma virgula logo apos a outra e nem comece na caixa de texto
//com o valor de virgula
function fncSequenciaNumSeparados(obj,e)
{
	
	if (document.all) // Internet Explorer
		var tecla = event.keyCode;
	else if(document.layers) // Nestcape
		var tecla = e.which;
					
		var TeclaUlt = obj.value.substr(obj.value.length-1,obj.value.length)//Recebe a ultima tecla digitada
		
		//Verifica se a o primeiro caracter não pode ser virgula
		if (tecla == 44 && obj.value.length == 0 ){
			return false;
		}
		
		//Verifica se o caracter anterior é a virgula.
				
		if (tecla == 44 && TeclaUlt == ","){
			return false;
		}
		
		//  || document.selection.createRange().text.length == obj.value.length)) //verifica se já tem (,) e se já tem algum número digitado
		
		if ((tecla > 47 && tecla < 58) || tecla == 44) // numeros de 0 a 9 ou ,
			return true;
		else
			{
				if (tecla != 8) // backspace
					event.keyCode = 0;
					//return false;
				else
					return true;
			}
	
}


/*
Descrição: Função que ira carregar uma pagina (popup) contendo a imagem do cheque
Utilização: Colocar no evento onClick do objeto image
==> Exemplo:  <img src="../img/BrrBotVerImg.gif" onClick="fncVisualizarImagem('422000600010002065300003754850')" style="cursor:hand">
                 
Retorno:-

*/
function fncVisualizarImagem(cmc7){
	window.open("../Script/BRRVisualizarImagemCheque.asp?pCMC7=" + cmc7,"BRRVisualizarImagemCheque","top=10,left=50,width=800,height=700")
	
}

/**************************************************************/
/* Funções desenvolvidas em EXPRESSÃO REGULAR                 */  
/* Autor:Cristiano Romeu (cristianorf@hotmail.com)            */
/* Data:07/06/2002                                            */
/* Empresa:Marlin                                             */                                             
/**************************************************************/
 
/*
Descrição: Função que só permite a digitação de numeros
Utilização: Colocar no evento onkeypress do objeto de texto
==> Exemplo: <input type=text name=txtobj onkeyup="fncDigNum(this)" onkeypress="fncDigNum(this)">
Retorno:-
*/
function fncDigNum(obj) {if(!/[0-9]/.test(String.fromCharCode (event.keyCode))) event.keyCode = 0;obj.value = obj.value.replace(/[^0-9]/gi,"")}
 
/*
Descrição: Função para validar e-mail
Desenvolvida por: Cristiano ROmeu
Utilização: chamar a funcao em um botao seja por href ou submit, ou ainda dentro de outra funcao
não esquecendo de passar a referencia do objeto de texto a ser validado
==> Exemplo: <input type=submit onclick="return fncValidaEmail(form1.txtnumeros)" id=submit1 name=submit1>
Retorno: true ou false 
*/
function fncValEmail(obj){if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(obj.value))return false}
 
/*
Descrição: Função que não permite a digitação de plic e nem aspas
Utilização: Colocar no evento onkeypress e no onkeyup do objeto de texto
não esquecendo de passar como referencia o objeto de texto
==> Exemplo: <input type=text name=txtobj onkeypress="fncTravaPlic(this)" onkeyup="fncTravaPlic(this)">
Retorno:-
*/ 
function fncTravaPlic(obj) {if(!/[^"']/.test(String.fromCharCode (event.keyCode))) event.keyCode = 0;obj.value = obj.value.replace(/["']/gi,"")}


/*
Descrição: Função que valida um caminho de arquivo txt, normalmente utilizado para importação de arquivo
Utilização: colocar no evento onclick no botão de importação, ou em outro botão, passando como parâmetro o caminho do arquivo

==> Exemplo: 

function fncImportar(){
	if(!fncValidaCaminhoArquivoTXT(form1.myfile.value)){
		alert("Nome inválido de arquivo!")
		return false
	}
}

Retorno:-false se nome do arquivo não for válido.
*/ 
function fncValidaCaminhoArquivoTXT(Caminho){
	if(!/[\\a-zA-Z]*\.[tT][xX][tT]/.test(Caminho)){
		return false
	}else{
		return true
	}
}



function fncTabulacao(obj,passo) {
	VerifiqueTAB=true;

	var lPasso
	if (passo == null){
		lPasso = 1
	}else{
		lPasso = passo
	}

	var tecla = event.keyCode
	if (tecla == 13) {
//		if ( (VerifiqueTAB) && (document.selection.createRange().text.length == 0)) { 
   			var i=0,j=0, indice=-1;
   			// Verifica qtos formularios tem na página.
			for (i=0; i < document.forms.length; i++) {
				for (j=0; j < document.forms[i].elements.length; j++) {
					if (document.forms[i].elements[j].name == obj.name) {
   						indice=i; 
   						break; 
					} 
				}
				
				if (indice != -1) break; 
			} 

			// Contador com os campos existem no Formulario que está sendo varrido.
			for (i=0; i < (document.forms[indice].elements.length-1); i++) {
				if (document.forms[indice].elements[i].name == obj.name) { 
					if (i < (document.forms[indice].elements.length-1)) {
				
						if (document.forms[indice].elements[(i+1)].type == "hidden") i++;
						
						if (document.forms[indice].elements[(i)].type == "text") {
							if (document.forms[indice].elements[(i+1)].type == "text") {
								document.forms[indice].elements[(i+lPasso)].select();
							} else {
								document.forms[indice].elements[(i+lPasso)].focus();
							}
						} else {
							document.forms[indice].elements[(i+lPasso)].focus();
						}

					}
					
					VerifiqueTAB = false;
					break;
				}
			}
			VerifiqueTAB = true;
		}
//	}
}


function fcnEnviaNumOperacao(obj,form){
	var tecla = event.keyCode
	if (tecla == 13) {
		if (obj.value == "") {
			alert("Informe o número da Operação");
			obj.focus();
			return false;}
		else {
		  if(fncLock()==false){return false;}
			form.submit();}
	}
}


/***********************************************************************************************
Criado por Marcelo Oliveira
Validar para Num. Duplicata alguns caracteres permitido.
***********************************************************************************************/
function fncNumDuplicata(e){
	var tecla = event.keyCode;
	//alert(tecla);
	
	if ((tecla==32 || tecla==44 || tecla==45 || tecla==46 || tecla==95) || (tecla>=65 && tecla<=90) || (tecla>=47 && tecla<=58) || (tecla>=97 && tecla<=122)) {
		return true;
	}else{
		event.keyCode = 0;
	}
	
}


/* ***************************************************************
	CRIADO POR André Luiz Guimarães Machado
	Esta função exibe o arquivo de ajuda passando parâmetros.
	Estes parâmetros dizem respeito a página de origem.

   *************************************************************** */

	function ajudaOnLine(pagina){
		window.open("BRRAjudaDocumento.asp?ArqOrigem="+pagina,"ajuda","width=600; height=526; top = 0; left=0; menubar=0; status=no; scrollbar = yes;");
	}


function AbrePop(windowURL, windowName, windowWidth, windowHeight) {
	var win = null;
  var esquerda = (screen.width - windowWidth)/2;
  var topo = (screen.height - windowHeight)/2;	
	win=window.open(windowURL,windowName,'height=' + windowHeight + ', width=' + windowWidth + ', top=' + topo + ', left=' + esquerda + ',dependent=yes, toolbar=0, location=0, directories=0, status=0, menuBar=0, scrollBars=0, resizable=0');
	win.window.focus();

}

//troca cor celula
//Specify highlight behavior. "TD" to highlight table cells, "TR" to highlight the entire row:
var highlightbehavior="TD"

var ns6=document.getElementById&&!document.all
var ie=document.all

function changeto(e,highlightcolor){
source=ie? event.srcElement : e.target
if (source.tagName=="TABLE")
return
while(source.tagName!=highlightbehavior && source.tagName!="HTML")
source=ns6? source.parentNode : source.parentElement
if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
source.style.backgroundColor=highlightcolor
}

function contains_ns6(master, slave) { //check if slave is contained by master
while (slave.parentNode)
if ((slave = slave.parentNode) == master)
return true;
return false;
}

function changeback(e,originalcolor){
if (ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")||source.tagName=="TABLE")
return
else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore"))
return
if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source)
source.style.backgroundColor=originalcolor
}

//Removes leading whitespaces
function LTrim(value){
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

//Removes ending whitespaces
function RTrim(value){
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

// Removes leading and ending whitespaces
function trim(value){
	return LTrim(RTrim(value));
}

//função para pegar a data limite para lançamentos sem senha (Parametro 59)
function DataMinima(dias){
  var data = new Date();
  var hoje = new Date();
  hoje.setDate(data.getDate());
  hoje.setMonth(data.getMonth());
  hoje.setFullYear(data.getFullYear());
  var i = 1;
  while(i<=dias){
    if((hoje.getDay() != 0) && (hoje.getDay() != 6)){
      i++;		  
    }
    hoje.setDate(hoje.getDate() - 1);
  }
  var dia = hoje.getDate() + 1;
  var mes = hoje.getMonth() + 1;
  var ano = hoje.getFullYear();
  if(dia < 10)
    dia = "0" + dia;      
  if(mes < 10)
    mes = "0" + mes;

  var a = dia + "/" + mes + "/" + ano;
  return a;
}


//função para pegar a data limite para lançamentos futuros (Parametro 70)
function DataMaxima(dias){		  
  var data = new Date();
  var hoje = new Date();
  hoje.setDate(data.getDate());
  hoje.setMonth(data.getMonth());
  hoje.setFullYear(data.getFullYear());
  
  var i = 1;
  while(i<=dias){
    if((hoje.getDay() != 0) && (hoje.getDay() != 6)){
      i++;		  
    }
    hoje.setDate(hoje.getDate() + 1);
  }
  
  var dia = hoje.getDate() - 1; //tira um porque o dia de hoje conta.
  var mes = hoje.getMonth() + 1;
  var ano = hoje.getFullYear();
  if(dia < 10)
    dia = "0" + dia;      
  if(mes < 10)
    mes = "0" + mes;

  var a = dia + "/" + mes + "/" + ano;
  return a;
}

//função que faz a validação da data limite
//parametros: data do formulario concatenada(yyyymmdd, dataMaxima, dataMinima)
function DataLimite(valorData,max,min){
  var data = valorData;
  var dataMaxima = DataMaxima(max);
  var dataMinima = DataMinima(min);

  if(parseInt(dataMaxima.split("/")[2].toString()+dataMaxima.split("/")[1].toString()+dataMaxima.split("/")[0].toString())<
    parseInt(data)){
      alert('Data Limite(' + max + ' dias): ' + dataMaxima);
      return false;
  }
  if(parseInt(dataMinima.split("/")[2].toString()+dataMinima.split("/")[1].toString()+dataMinima.split("/")[0].toString())>
    parseInt(data)){
      alert('Data Limite(' + min + ' dias): ' + dataMinima);
      return false;
  }
  return true;
}