<!--
/*
   Script:					Biblioteca.js

   Author:					Carsale
							www.carsale.com.br
							
   Description:			    Generic validation routine.

   Funções de Validação:	Validar(obj)
							IsDate_OK(obj)
							IsTime_OK(obj)
							IsCPF_OK(obj)
							IsCGC_OK(obj)
							IsEmail_OK(obj)
							IsPercent_OK(obj)
							IsCurrency_OK(obj)
							IsInteger_OK(obj)
							IsNumber_OK(obj)
							IsPlaca_OK(obj)  // Marcio
							
   Funções de Inclusão		Formatar(obj,teclapres)
   de Mascara:              FormatDate(obj,teclapres)
            				FormatTime(obj,teclapres)	
							FormatCPF(obj,teclapres)	
							FormatInscEst(obj,teclapres)
							FormatPercent(obj,teclapres)	
							FormatCurrency(obj,teclapres)
							FormatInteger(obj,teclapres)
							FormatNumeric(obj,teclapres,tamanho,CasasDecimais)
							
							
   Funções Gerais:			RemoveMask(sInStr)
							IsLeapYear(Year)
							DaysInMonth(argMonth, argYear)	
							VerifyRequiredFields(form)	
							IsRequerido(obj)	
							SetarStatus(obj)
							LimparStatus()
   
*/
  
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////  FUNÇÕES DE VALIDAÇÃO  ///////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////

// Constantes para os ACTIONS
taNEW_RECORD =0;
taSEARCH =1;
taUPDATE =2;
taINSERT =3;
taDELETE =4;
taREFRESH =5;


// Determina qual rotina de validação será executada
function Validar(obj)
{
 var Resultado, ObjName, Flag, TipoMascara, IsRequerido;
 ObjName = obj.name;
 Flag = ObjName.substr(5,1);
 Flag = Flag.toUpperCase();
 TipoMascara = ObjName.substr(6,1);
 TipoMarcara = TipoMascara.toUpperCase;
 
 
 
 switch (TipoMascara)
 {
   // Placa do Carro
   case 'L':{ 
              Validacao = IsPlaca_OK(obj);
              return Validacao;
            }

   // Percentual
   case 'P':{ 
              Validacao = IsPercent_OK(obj);
              return Validacao;
            }
   // Currency	 
   case 'C':{ 
              Validacao = IsCurrency_OK(obj);
              return Validacao;
            }
   // CPF            
   case 'F':{ 
              Validacao = IsCPF_OK(obj);
              return Validacao;
            }
   // Inscrição Estadual / CGC         
   case 'E':{ 
              Validacao = IsCGC_OK(obj);
              return Validacao;
            }     
   // E-Mail
   case 'M':{ 
              Validacao = IsEmail_OK(obj);
              return Validacao;
            }
   // Inteiro         
   case 'I':{ 
              Validacao = IsInteger_OK(obj);
              return Validacao;
            }
   // Data         
   case 'D':{ Validacao = IsDate_OK(obj);
              return Validacao;
            }
   // Time              
   case 'T':{ Validacao = IsTime_OK(obj);
              return Validacao;
            }
   // Nada, Senha         
   default :{ Validacao = true;
              return Validacao;
            }							 			
 }
}

// Valida a data.
function IsDate_OK(obj)
{
  /* Dimas: 20/03/3001 
    Estava ocorrendo um erro muito estranho ao ser dado um parseint quando o mes era 09, ele retornava como 0.
    Como WorkAround removi os parseint e a comparacao esta sendo feita correta agora.
  */

   // Se o campo está vazio não faz a validação.	
   if (obj.value == '')   
   {
     Validacao = true;
     return true;
   } 

   var data = obj.value;
   var valor = data+''; 
   var dia = valor.substr(0,2);
   var mes = valor.substr(3,2);
   var ano = valor.substr(6,4);
 
 
   if ( (valor.length < 10) || (ano < 1900) || (mes>12) || (mes<1) || (dia>31) || (dia <0) || (dia > DaysInMonth(mes, ano)) )
   {
     obj.focus(); 
     obj.select();
     alert('A data informada '+ valor + ' não está correnta \nFormato deve ser DD/MM/AAAA. e maior que 1900 !!!.');
	 Validacao = false;
     return false;
   }
   else 
   { 
     Validacao = true;
     return true;
   }
}

// Valida o horário.
function IsTime_OK(obj)
{
	
   // Se o campo está vazio não faz a validação.	
   if (obj.value == '')   
   {
     Validacao = true;
     return true;
   }

   var horario = obj.value;
   var hora = horario.substr(0,2);
   var minuto = horario.substr(3,2);
 
   if ( (horario.length < 5) || (hora < 0) || (hora > 23) || (minuto < 0) || (minuto > 59))
   {
     obj.focus(); 
     obj.select();
     alert('A hora informada '+ horario + ' não está correnta \nFormato deve ser hh:mm.');
	 Validacao = false;
     return false;
   }
   else 
   {
     Validacao = true;
     return true;
   }
}

// Valida o CPF
function IsCPF_OK(obj)
{
   // Copyright 1997 by Marcio Braga and Waldeck Schützer.
   
   // Se o campo está vazio não faz a validação.	
   if (obj.value == '')   
   {
     Validacao = true;
     return true;
   }
   var s;
   s = new String(obj.value);
   s = RemoveMask(s);   
   
   var a, b, m, i, l;
   l = s.length;
   
   if ( s=='11111111111' || s=='22222222222' ||
        s=='33333333333' || s=='44444444444' ||
        s=='55555555555' || s=='66666666666' ||
        s=='77777777777' || s=='88888888888' ||
        s=='99999999999' || parseFloat(s) == 0 )
   {
        obj.focus(); 
		obj.select();
		alert (obj.value+"\nO CPF acima não é válido. Por favor digite novamente.");
		Validacao = false;
        return false;
   }
                
                
   a = 0; b = 0; m = 2;
   if (l < 3) { obj.focus(); 
				obj.select();
				alert (obj.value+"\nO CPF acima não é válido. Por favor digite novamente.");
				Validacao = false;
                return false;}
   for(i=l-3; i>=0; i--) {
      a += parseInt( s.charAt(i), 10 ) * m;
      m++;
   }
   m = 2;
   for(i=l-2; i>=0; i--) {
      b += parseInt(s.charAt(i), 10 ) * m;
      m++;
   }
   a = ((a * 10) % 11) % 10;
   b = ((b * 10) % 11) % 10;
   
   if (a==parseInt(s.charAt(l-2),10) && b==parseInt(s.charAt(l-1),10))
   {
     Validacao = true;
     return true;
   }
   else
   { 
     obj.focus();
     obj.select();
     alert (obj.value+"\nO CPF acima não é válido. Por favor digite novamente.");
	 Validacao = false;
     return false;  
   }  
}

// Valida o CGC.
function IsCGC_OK(obj)
{
   // Copyright 1997 by Marcio Braga and Waldeck Schützer.
   
   // Se o campo está vazio não faz a validação.	
   if (obj.value == '')   
   {
     Validacao = true;
     return true;
   }
   
   var s;
   s = new String(obj.value);
   s = RemoveMask(s);   
   
   var a, b, m, i, l;
   l = s.length;
   
   if ( parseInt(s) == 0 )
   {
        obj.focus(); 
		obj.select();
		alert (obj.value+"\nO CPF acima não é válido. Por favor digite novamente.");
		Validacao = false;
        return false;
   }
     
   a = 0; b = 0; m = 2;
   if (l < 3) { obj.focus();
				obj.select();
				alert (obj.value+"\nO CGC acima não é válido. Por favor digite novamente.");
				Validacao = false;
                return false;}
   for (i=l-3; i>=0; i--) {
      a += parseInt( s.charAt(i), 10 ) * m;
      m = 2 + ((m - 1) % 8);
   }
   m = 2;
   for(i=l-2; i>=0; i--) {
      b += parseInt( s.charAt(i), 10 ) * m;
      m = 2 + ((m - 1) % 8);
   }
   a = ((a * 10) % 11) % 10;
   b = ((b * 10) % 11) % 10;
   
   if (a==parseInt(s.charAt(l-2),10) && b==parseInt(s.charAt(l-1),10))
   {
     Validacao = true;
     return true;
   }
   else
   {
     obj.focus();
     obj.select();
     alert (obj.value+"\nO CGC acima não é válido. Por favor digite novamente.");
	 Validacao = false;
     return false;
   }  
}

// Valida a placa
function IsPlaca_OK(obj)
{
  if (obj.value.length ==0)
  {
      validacao = true;
	  return true;
  }

  texto = obj.value.toUpperCase();

  for (var i=0;i<3;i++)
  {
    ch = texto.substring(i,i+1);
    if (!(ch >= 'A' && ch <='Z'))
    {
      validacao = false;
	  alert('Placa '+texto + ' inválida !')
      obj.focus();
      obj.select();
      return false;
    }
  }

  for (var i=3;i<=6;i++)
  {
    ch = texto.substring(i,i+1);
    if (!(ch >= '0' && ch <='9'))
    {
      validacao = false;
 	  alert('Placa '+texto + ' inválida !')
      obj.focus();
      obj.select();
	  return false;
    }
  }
  obj.value = texto;
  validacao = true;
  return true;
}

// Valida o e-mail.
function IsEmail_OK(obj)
{
   // Copyright 1997 by Marcio Braga and Waldeck Schützer.
   
   // Se o campo está vazio não faz a validação.	
   if (obj.value == '')   
   {
     Validacao = true;
     return true;
   }
    
    var checkString = obj.value;
    var newstr = "";
    var at = false;
    var dot = false;
    var space = false;

     // IF EMAIL ADDRESS HAS A '@' CHARACTER
    if (checkString.indexOf("@") != -1)
	   {
         at = true;
       }
    else if (checkString.indexOf(".") != -1)
	   {
         dot = true;
       }
    // PARSE REMAINDER OF STRING
    for (var i = 0; i < checkString.length; i++)
	    {
         ch = checkString.substring(i, i + 1)
         if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")
                || (ch == "@") || (ch == ".") || (ch == "_")
                || (ch == "-") || (ch >= "0" && ch <= "9")) 
			{
              newstr += ch;
              if (ch == "@")
			     {
                    at=true;
                 }
              if (ch == ".") 
			     {
                    dot=true;
                 }
            }
         else if (true)
           space = true;
            
        }
    
	if ((at == true) && (dot == true) && (space == false))
	{    Validacao = true;
         return true;
    }
    else 
	   {
         obj.focus();
         obj.select();
         alert (checkString+"\nO email acima não está informado de maneira correta.");
		 Validacao = false;
         return false;
       }
}

// Valida a porcentagem
function IsPercent_OK(obj)
{
  Validacao = IsNumber_OK(obj,true);
  return Validacao;
}

// Valida o currency
function IsCurrency_OK(obj)
{
  Validacao = IsNumber_OK(obj,true);
  return Validacao;
}

// Valida o número inteiro
function IsInteger_OK(obj)
{
  Validacao = IsNumber_OK(obj,false);
  return Validacao;
}

// Valida um número
function IsNumber_OK(obj,hasdecimal)
{
 if (obj.value == '')
 {
   Validacao = true;
   return true;
 }

 var value,i,num;
 
 value = obj.value;
 
 for (i = 0; i <= value.length - 1; i++) 
 {
   if (( (value.charAt(i) != '.')   && 
         (value.charAt(i) != ',')   &&
         (value.charCodeAt(i) < 48) ||
         (value.charCodeAt(i) > 57)  )
       || 
         (value.charAt(i) == ',' && !hasdecimal))
       {
         alert(value+'\n O valor acima não é um número válido !!!');
         obj.focus();
         obj.select();
		 Validacao = false;
         return false;
       }
 }

 Validacao = true;
 return true;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////  FUNÇÕES DE INCLUSÃO DE MÁSCARA  /////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////

// Determina qual rotina de formatação de máscara será executada
function Formatar(obj,teclapres)
{
 var ObjName, Flag, TipoMascara, IsRequerido;
 ObjName = obj.name;
 Flag = ObjName.substr(5,1);
 Flag = Flag.toUpperCase();
 TipoMascara = ObjName.substr(6,1);
 TipoMarcara = TipoMascara.toUpperCase;
 
 if (obj.value.length == 1)
 {
   Status = false;
   Validacao = true;
 }  
 
 if ((!Status) && (Validacao))
 {
 switch (TipoMascara)
 {
   case 'P': return FormatPercent(obj,teclapres);      // Percentual
   case 'C': return FormatCurrency(obj,teclapres);     // Currency	
   case 'F': return FormatCPF(obj,teclapres);          // CPF
   case 'E': return FormatInscEst(obj,teclapres);      // Inscrição Estadual / CGC
   case 'I': return FormatInteger(obj,teclapres);      // Inteiro
   case 'D': return FormatDate(obj,teclapres);         // Data
   case 'T': return FormatTime(obj,teclapres);         // Time
   default : return true;							   // Nada, Senha			
 }
 }
}


// Coloca a máscara de data no preenchimento
function FormatDate(obj,teclapres) {
 var tecla = teclapres.keyCode;
 vr = obj.value;


 if (obj.value.length == 1)
 {
   Status = false;
   Validacao = true;
 }  
 
 // checa se vai ser colocada a máscara
 if ((!Status) && (Validacao))
 {
 
    if ( vr.length < 10 ) {
 
    retorno = '' ;
    for (i = 0 ; i < vr.length ; i++) {
      if (!isNaN(vr.substr(i,1)) ) {
          retorno = retorno + vr.substr(i,1) ;} 
    }
    
    vr = retorno ;
 
 tam = vr.length + 1;
 
 if ( tecla != 9 && tecla != 8 ){
  if ( tam == 3)
   vr = vr.substr( 0, tam - 1 ) + '/' + vr.substr( tam - 1, tam );
  else if ( tam > 3 && tam < 5 )
      vr = vr.substr( 0, 2 ) + '/' + vr.substr( 2, tam ); 
  else if ( tam >= 5 && tam <= 8 )
   vr = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 4 ); }
  
 obj.value = vr ;
  } 
}  
}


// Coloca a máscara de Hora no preenchimento
function FormatTime(obj,teclapres){
 var tecla = teclapres.keyCode;
 vr = obj.value;

 if (obj.value.length == 1)
 {
   Status = false;
   Validacao = true;
 }  
 
 // checa se vai ser colocada a máscara
 if ((!Status) && (Validacao))
 {
    retorno = '' ;
    for (i = 0 ; i < vr.length ; i++) {
      if (!isNaN(vr.substr(i,1)) ) {
          retorno = retorno + vr.substr(i,1) ;} 
    }
    
    vr = retorno ;
 
    if ( vr.length < 4 ) {
 
 retorno = '';
 
 tam = vr.length + 1;
 
 if ( tecla != 9 && tecla != 8 ){
        for (i = vr.length ; i > 0 ; i--) { 
          retorno = vr.substr(i-1,1) + retorno ;
          if (retorno.length==2) { retorno = retorno.substr(0,1) + ':' + retorno.substr(1,2); }    
        }
    }    
 obj.value = retorno ;  
  } 
}
}




// Coloca a máscara de CPF no preenchimento
function FormatCPF(obj,teclapres) {
 var tecla = teclapres.keyCode;
 vr = obj.value;
 
 if (obj.value.length == 1)
 {
   Status = false;
   Validacao = true;
 }  
 
 // checa se vai ser colocada a máscara
 if ((!Status) && (Validacao))
 {

    retorno = '' ;
    for (i = 0 ; i < vr.length ; i++) {
      if (!isNaN(vr.substr(i,1)) ) {
          retorno = retorno + vr.substr(i,1) ;} 
    }
    
      
    vr = retorno ;
 
    if ( vr.length < 11 ) {
 
 tam = vr.length + 1;
 
 if ( tecla != 9 && tecla != 8 ){
        retorno = '' ;
      
        for (i = vr.length ; i > 0 ; i--) { 
          retorno = vr.substr(i-1,1) + retorno ;
          if (retorno.length==2) { retorno = retorno.substr(0,1) + '-' + retorno.substr(1,1); }    
          if (retorno.length==6) { retorno = retorno.substr(0,1) + '.' + retorno.substr(1,5); }    
          if (retorno.length==10) { retorno = retorno.substr(0,1) + '.' + retorno.substr(1,9); }    
       }
       obj.value = retorno;
    }   
}  

}
}


 
// Coloca a máscara de CNPJ no preenchimento
function FormatInscEst(obj,teclapres) {
 var tecla = teclapres.keyCode;
 vr = obj.value;

 if (obj.value.length == 1)
 {
   Status = false;
   Validacao = true;
 }  
 
 // checa se vai ser colocada a máscara
 if ((!Status) && (Validacao))
 {
 
    retorno = '' ;
    for (i = 0 ; i < vr.length ; i++) {
      if (!isNaN(vr.substr(i,1)) ) {
          retorno = retorno + vr.substr(i,1) ;} 
    }
    
      
    vr = retorno ;
 
    if ( vr.length < 15 ) {
 
 tam = vr.length + 1;
 
 if ( tecla != 9 && tecla != 8 ){
        retorno = '' ;
      
        for (i = vr.length ; i > 0 ; i--) { 
          retorno = vr.substr(i-1,1) + retorno ;
          if (retorno.length==2) { retorno = retorno.substr(0,1) + '-' + retorno.substr(1,1); }    
          if (retorno.length==7) { retorno = retorno.substr(0,1) + '/' + retorno.substr(1,6); }    
          if (retorno.length==11) { retorno = retorno.substr(0,1) + '.' + retorno.substr(1,10); }    
          if (retorno.length==15) { retorno = retorno.substr(0,1) + '.' + retorno.substr(1,14); }    
       }
       obj.value = retorno;
    }   
}  
} 
}

 
// Coloca a máscara de Percentual no preenchimento
function FormatPercent(obj,teclapres) {FormatNumeric(obj,teclapres,6,2);}
 
// Coloca a máscara de Currency no preenchimento
function FormatCurrency(obj,teclapres) {FormatNumeric(obj,teclapres,17,2);}
 
// Coloca a máscara de Interiro no preenchimento
function FormatInteger(obj,teclapres) {FormatNumeric(obj,teclapres,17,0);}
  
// Coloca a máscara de Numero no preenchimento
function FormatNumeric(obj,teclapres,tamanho,CasasDecimais){
 var tecla = teclapres.keyCode;
 vr = obj.value;
 CasasSeparador = 3 ; 
 Retorno = '' ;
 decimal = '';

// Incrementa a variável CountDeleteKey se a tecla delete (cod. 46) ou a tecla backspace (cod.8) foi pressionada.
// Enquanto a variável CountDeleteKey for maior que zero a variável status será true, ou seja
// estará desabilitada a formatação de máscara.
// Esta verificação é feita para que se possa corrigir um valor sem que se tente colocar a máscara.
//CountDeleteKey = 0;
if ((CountDeleteKey > 0)&&(CountMascaraKey == 0))
   Status = true;
 else 
   Status = false;        
 if ((tecla == 46) || (tecla == 8))
 {
   //CountDeleteKey = CountDeleteKey + 1;  
   //if (obj.value.substr(obj.value.length-1,1) == ',')
   //  CountMascaraKey = CountMascaraKey + 1;
 }  
 else if ((CountDeleteKey > 0))
 {
   //CountDeleteKey = CountDeleteKey - 1;  
   // if (obj.value.substr(obj.value.length-2,1) == ',')
   // {
   //   CountMascaraKey = CountMascaraKey - 1;
   //   CountDeleteKey = CountDeleteKey - 1;
   // }
 }    
   

 if (obj.value.length == 1)
 {
   Status = false;
   Validacao = true;
   CountDeleteKey = 0;
   CountMascaraKey = 0;
 }
      
 
 // checa se vai ser colocada a máscara
 if ((!Status) && (Validacao) && (obj.value.length < obj.maxLength))
 {
 
    if ( vr.length < tamanho ) {
 
    retorno = '' ;
    for (i = 0 ; i < vr.length ; i++) {
      if (!isNaN(vr.substr(i,1)) ) {
          retorno = retorno + vr.substr(i,1) ;} 
    }
    
    vr = retorno ;
 
 
      if ( vr.length > 2 && CasasDecimais > 0 ) {
          decimal = vr.substr(vr.length-1,CasasDecimais-1);
          vr = vr.substr(0,vr.length-1);
      }
 
 
   tam = vr.length + 1;
   quebra = 0 ;
  
      for (i = 1 ; i <= vr.length ; i++) { 
         if ( CasasDecimais == 0 ) {if (i/3 == Math.round(i/3)) { quebra = 1; } else { quebra = 0; }}
         if ( quebra == 1 ) {
             Retorno =  vr.substr(vr.length-i,1) + '.' + Retorno;}
         else {Retorno = vr.substr(vr.length-i,1) + Retorno }
         if ( CasasDecimais > 0 ) {if (i/3 == Math.round(i/3)) { quebra = 1; } else { quebra = 0; }}
      }
    
      //if ( tecla != 9 && tecla != 8 ){
      if ( (tecla >= 48 && tecla <= 57) || (tecla >= 96 && tecla <= 105) ){
        if (tam>2) {
           if (CasasDecimais > 0 ) {obj.value = Retorno + ',' + decimal;} else {obj.value = Retorno;}
        } else { obj.value = Retorno } }
   }     
}
}


 
 
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////  FUNÇÕES GERAIS  /////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////

// Pega apenas os numeros digitados.
function RemoveMask (sInStr)
{
  // Copyright 1997 by Marcio Braga and Waldeck Schützer.
  var result = '';
  for (i=0;i < sInStr.length;i++)
  {
    if ((sInStr.charAt(i) >='0') && (sInStr.charAt(i) <= '9')) result += sInStr.charAt(i);
  }
  return result;
}


// Verifica se o ano é bissexto.
function IsLeapYear(Year)
{
  return ((Year % 4 == 0) && (Year % 100 != 0)) || (Year % 400 == 0) 
}

// Retorna a quantidade de dias em um determinado mês levando em
// consideração os anos bissextos.
function DaysInMonth(argMonth, argYear) {
    var year = Number(argYear);
	switch (Number(argMonth)) {
		case 1:		// Jan
		case 3:		// Mar
		case 5:		// May
		case 7:		// Jul
		case 8:		// Aug
		case 10:		// Oct
		case 12:		// Dec
			return 31;
			break;
		
		case 4:		// Apr
		case 6:		// Jun
		case 9:		// Sep
		case 11:		// Nov
			return 30;
			break;
		
		case 2:		// Feb
			if (IsLeapYear(year))
				return 29
			else
				return 28
			break;
		
		default:
			return 0;
	}
}

//Marcio Araraquara
function VerifyRequiredFields(form)						
{
  if ((form.$ACTION.value == taUPDATE) || (form.$ACTION.value == taINSERT))
  {
    for (i=0;i<form.length-1;i++) 
	{
     //if (IsRequerido(form.item(i)) && (form.item(i).value == ''))
     if (IsRequerido(form.item(i)) && IsNull(form.item(i)))
      { 
            if (typeof(form.item(i).rotulo) == 'undefined')
               rotulo= form.item(i).name.substr(8,form.item(i).name.length-8)
			else
              rotulo = form.item(i).rotulo;

			alert(rotulo+"\nCampo requerido !!!.\n Por favor não deixe em branco.");
            form.item(i).focus();
            return false;   
      } 
     }
   }
  return true;
}

function IsRequerido(obj)
{
  Flag = obj.name.substr(5,1);
  Flag = Flag.toUpperCase();
  // Retorna true se o campo é requerido.
  return ( (Flag == 'R') && (obj.name.substr(1,3) == 'FLD') ) ;
}

function SaltaCampo (obj,teclapres){
	var tecla = teclapres.keyCode;
	vr = obj.value;
	if( tecla == 109 || tecla == 188 || tecla == 110 || tecla == 111 || tecla == 223 || tecla == 108 ){
		obj.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;	


       var formulario = obj.form;

		  
	 	//if (tecla != 0 && tecla != 9 && tecla != 16 && tecla != )
	 	  if (tecla > 47 && tecla < 127)
			if ( tam == obj.maxLength )	
			{
			  for(i=0;i<formulario.length-1;i++)
			    if (formulario[i].name == obj.name)
			       formulario[i+1].focus() ;	
			}       
			
	}
}

var Status = false;
var Validacao = true;
var CountDeleteKey = 0;
var CountMascaraKey = 0;

function SetarStatus(obj)
{
  Status = false;
  if(obj.value.length > 0)
    Status = true; 
  return true;  
}

function LimparStatus()
{
  CountDeleteKey = 0;
  CountMascaraKey = 0;
  Status = false;
  return true;
}

function IsNull(obj)
{
  if (obj.type == 'select-one')
    return (obj.selectedIndex == 0);
  else if (obj.type == 'checkbox')
    return (!obj.checked) ;
  else if (obj.type == 'radio')   
    return (!obj.checked);
  else
     return (obj.value == '');
}

janela=null;

function openwindow()
{
  if (janela && !janela.closed) janela.focus();
  janela = window.open("",'Janela','left=200,top=10,width=530,height=400,scrollbars=yes,location=no,status=yes,toolbar=no,menubar=no,resizable=no'); 
}

/*function pesquisa()
{
    document.forms[0].$ACTION.value = taSEARCH;
    document.forms[0].submit();
}*/

//-->