/******************************************************************************** Funcoes genericas para validacao                                          **** Com VerificaENTER e VerificaLimpar inclusos                               ********************************************************************************//******************************************************************************** Funcoes auxiliares                                                        ********************************************************************************/// Retorna so numeros da stringfunction SoNumeros( campo ){   return campo.value.replace( /\D/g, "" );}// Retorna so letras e numeros da stringfunction SoLetrasNumeros( Campo ){   return Campo.value.replace( /\W|\_/g, "" );}// Retorna so letras da stringfunction SoLetras( Campo ){   return Campo.value.replace( /[^A-Za-z]/g, "" );}// Coloca pontos de milhar nos valores numericosfunction ColocaPontos( Valor ){   if( Valor.length <= 3 )      return Valor;   else      return( ColocaPontos( Valor.substr( 0, Valor.length - 3 ) ) + "." + Valor.substr( Valor.length - 3, 3 ) );}// Verificando se o campo so tem zerosfunction CampoZerado( Valor ){   if( parseFloat( Valor ) == 0 ) return true;   return false;}function VerificaTamanho( Campo, DescCampo, tamMax ){   if( Campo.value.length > tamMax )   {      alert( DescCampo + " permite no máximo " + tamMax + " caracteres. \nOs caracteres excedentes serão truncados." );      Campo.value = Campo.value.substring( 0, tamMax );      return false;   }   return true;}// Funcao para jogar o focofunction Foco( Campo ){   if( !Campo.disabled && Campo.type != "hidden" )      Campo.focus();}// Funcao que joga o foco para o outro campo caso a string seja do tamanho desejado// Colocar no evento onKeyUpvar verTab = true;function SoltaTecla( Valor, Tamanho, CampoJogarFoco ){   if( Valor.length == Tamanho && verTab )   {      Foco( CampoJogarFoco );      verTab = false;   }   return true;}// Funcao para retornar o tabfunction PressionaTecla(){   verTab = true;}// Funcao que calcula o modulo 11function Modulo11( Valor, PesoInicio, PesoFim ){   var i, soma, mult, aux;   soma = 0;   mult = PesoInicio;   for( i = Valor.length - 1; i >= 0; i-- )   {      soma += parseInt( Valor.substr( i, 1 ), 10 ) * mult;      if( PesoInicio < PesoFim )      {         if( mult == PesoFim )            mult = PesoInicio - 1;         mult++;      }      else      {         if( mult == PesoFim )            mult = PesoInicio + 1;         mult--;      }   }   aux = 11 - ( soma % 11 );   return ( ( aux >= 10 ) ? 0 : aux );}// Verifica se so tem numerosfunction EhNumero( Campo, DescCampo, NaoTirarStrings ){   var aux = Campo.value.replace( /\s/g, "" );   if( aux == "" )   {      Campo.value = "";      return true;   }   if( typeof NaoTirarStrings == "undefined" || !NaoTirarStrings )      aux = aux.replace( /\s|\/|\.|\,|\-/g, "" );   if( isNaN( aux ) )   {      alert( DescCampo );      Foco( Campo );      return false;   }   return true;}function ColocaZeros( Valor, Qtde ){   var aux, i;   aux = "";   for( i = 1; i <= Qtde; i++ )      aux += "0";   return aux + Valor;}// Funcao para validar os enderecosfunction ValidaEndereco( Campo, DescCampo, TipoIdent ){   with( document )   {      // Tipo de Logradouro      if( !CampoPreenchido( CIF[ "e" + Campo + "TpLogradouro" ], "Tipo de Logradouro do Endereço " + DescCampo + " deve ser informado." ) ) return false;      // Nome do Logradouro      if( !CampoPreenchido( CIF[ "e" + Campo + "NmLogradouro" ], "Nome do Logradouro do Endereço " + DescCampo + " deve ser informado." ) ) return false;      // Numero do Logradouro      if( !CampoPreenchido( CIF[ "e" + Campo + "NrLogradouro" ], "Número do Logradouro do Endereço " + DescCampo + " deve ser informado." ) ) return false;      // Bairro      if( !CampoPreenchido( CIF[ "e" + Campo + "Bairro" ], "Bairro do Endereço " + DescCampo + " deve ser informado." ) ) return false;      // Municipio      if( !CampoPreenchido( CIF[ "e" + Campo + "Municipio" ], "Município do Endereço " + DescCampo + " deve ser informado." ) ) return false;      // UF      if( !CampoPreenchido( CIF[ "e" + Campo + "UF" ], "UF do Endereço " + DescCampo + " deve ser informado." ) ) return false;      // CEP      if( !CampoPreenchido( CIF[ "e" + Campo + "CEP" ], "CEP do Endereço " + DescCampo + " deve ser informado." ) ) return false;      // SERPRO      if( !CampoPreenchido( CIF[ "e" + Campo + "SERPRO" ], "As informações de endereço " + DescCampo + " estão incompletas. Preencha o CEP novamente." ) ) return false;      // Por: Joseane Cristine Mota      // Em.: 08/06/2005      // Baixa - Telefone de Guarda de Documentos é obrigatório      if ( Campo == "Guarda" ){        if( !CampoPreenchido( CIF[ "e" + Campo + "DDDFone" ], "DDD do Telefone " + DescCampo + " deve ser informado." ) ) return false;      }      // Telefone      if( CIF[ "e" + Campo + "DDDFone" ].value == "" ^ CIF[ "e" + Campo + "NrFone" ].value == "" )      {         if( CIF[ "e" + Campo + "DDDFone" ].value == "" )         {            alert( "DDD do Telefone deve ser informado." );            rsAux = "DDDFone";         }         else         {            alert( "Número do Telefone deve ser informado." );            rsAux = "NrFone";         }         Foco( CIF[ "e" + Campo + rsAux ] );         return false;      }      // Fax      if( CIF[ "e" + Campo + "DDDFax" ].value == "" ^ CIF[ "e" + Campo + "NrFax" ].value == "" )      {         aux = ( TipoIdent == 1 ) ? "Celular" : "Fax";         if( CIF[ "e" + Campo + "DDDFax" ].value == "" )         {            alert( "DDD do " + aux + " deve ser informado." );            rsAux = "DDDFax";         }         else         {            alert( "Número do " + aux + " deve ser informado." );            rsAux = "NrFax";         }         Foco( CIF[ "e" + Campo + rsAux ] );         return false;      }   } // with   // Se chegou aqui tudo ok   return true;} // function// Funcao para testar se o campo eh vaziofunction CampoPreenchido( Campo, Mensagem ){   if( Trim( Campo.value ) == "" )   {      alert( Mensagem );      Foco( Campo );      return false;   }   return true;}// Funcao para fazer o trim de um valorfunction Trim( Valor ){   return Valor.replace( /^\s*/, "" ).replace( /\s*$/, "" );}// Funcao que joga o foco para o outro campo caso a string seja do tamanho desejado// Colocar no evento onKeyUpvar verTab = true;function SoltaTecla( Valor, Tamanho, CampoJogarFoco ){   if( Valor.length == Tamanho && verTab )   {      Foco( CampoJogarFoco );      verTab = false;   }   return true;}// Funcao para retornar o tabfunction PressionaTecla(){   verTab = true;}// Funcao para jogar o foco para o primeiro elemento do formulario naum disabledfunction JogaFocoPrimeiro( Formulario ){   for( var i = 0; i < Formulario.elements.length; i++ )      if( !Formulario.elements[ i ].disabled && ( Formulario.elements[ i ].type == "text" || Formulario.elements[ i ].type == "textarea" || Formulario.elements[ i ].type == "select-one" ) )      {         Formulario.elements[ i ].focus();         Formulario.elements[ i ].select();         break;      }}// Funcao para ver se o campo existe no formulariofunction ExisteCampo( Campo ){   return ( Campo == null ) ? false : true;}// Funcao para ver se o campo esta vaziofunction EstaVazio( Campo, Mensagem ){   if( Trim( Campo.value ) == "" )   {      alert( Mensagem );      Foco( Campo );      return true;   }   return false;}// funcao para vericar se os blocos foram alteradosfunction Modificado( Tipo, CampoModificado ){   var i, expr, aux, aux2;   var Diferente = false;   with( document )   {      eval( "expr = /^e" + Tipo + "\\w*Orig$/" );      // Para todos os elementos do form      for( i = 0; i < CIF.elements.length; i++ )      {         aux = CIF.elements[ i ].name;         // Verificando se o campo acaba com Orig         if( expr.test( aux ) )         {            // aqui se achou            if( Trim( CIF[ aux ].value ) != Trim( CIF[ aux.replace( /Orig$/, "" ) ].value ) )            {               Diferente = true;               break;            } // if         } // if expr.test      } // for      aux = ( Diferente )?"1":"0";      CIF[ "e" + CampoModificado + "Modificado" ].value = aux;      return true;   } // with} // functionfunction RetornaTipoCampo( Valor ){   var SemNum = Array( "Est", "Cor", "Ins", "Cont" );   var ComNum = Array( "Soc", "Proc" );}// Funcao para verificar qdo Enter eh pressionadofunction VerificaENTER(){   if( window.event.keyCode == 13 )   {      if( document.forms[ "CIF" ] != null )         Foco( document.CIF.b1 );      window.event.cancelBubble = true;      window.event.returnValue  = false;   }}// Funcao para verificar qdo ESC eh pressionadofunction VerificaLimpar(){   if( window.event.srcElement.name == "b2" )   {      if( document.forms[ "CIF" ] != null )         document.CIF.reset();      window.event.cancelBubble = true;      window.event.returnValue = false;   }}// Funcao para dar submit em um janelafunction AbrirNaJanela( formulario, nomeJanela, largura, altura ){   // Pegando todos os estados dos campos   var vet = new Array( formulario.length );   var aux, aux2, i;   for( i = 0; i < formulario.length; i++ )   {      vet[ i ] = formulario[ i ].disabled;      formulario[ i ].disabled = false;   }   window.open( 'Carga.html', nomeJanela,'toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=' + largura + ',height=' + altura + ',top=40,left=40');   aux = formulario.target;   formulario.target = nomeJanela;   formulario.submit();   // Recuperando os estados dos campos   for( i = 0; i < formulario.length; i++ )      formulario[ i ].disabled = vet[ i ];   formulario.target = aux;}// Funcao para habilitar os campos e dar o submitfunction SubmitForm( formulario, nomeJanela ){   // Pegando todos os estados dos campos   var vet = new Array( formulario.length );   for( i = 0; i < formulario.length; i++ )   {      vet[ i ] = formulario[ i ].disabled;      formulario[ i ].disabled = false;   }   if( typeof nomeJanela != "undefined" && nomeJanela != "" ) formulario.target = nomeJanela;   formulario.submit();   // Recuperando os estados dos campos   for( i = 0; i < formulario.length; i++ )      formulario[ i ].disabled = vet[ i ];}/******************************************************************************** Funcoes de formatacao                                                     ********************************************************************************/// Formata cnpj xx.xxx.xxx/xxxx-xxfunction FormataCNPJ( Campo ){   var aux     = SoNumeros( Campo );   Campo.value = aux.substr( 0, 2 ) + "." + aux.substr( 2, 3 ) + "." + aux.substr( 5, 3 ) + "/" + aux.substr( 8, 4 ) + "-" + aux.substr( 12, 2 );}// Formata cpf xxx.xxx.xxx-xxfunction FormataCPF( Campo ){   var aux     = SoNumeros( Campo );   Campo.value = aux.substr( 0, 3 ) + "."      + aux.substr( 3, 3 ) + "."      + aux.substr( 6, 3 ) + "-"      + aux.substr( 9, 2 );}// Formata comprovante xxx.xxx.xxx-xxfunction FormataComprovante( Campo ){   var aux     = SoNumeros( Campo );   if( aux.length != 11 ) return false;   Campo.value = aux.substr( 0, 3 ) + "." + aux.substr( 3, 3 ) + "." + aux.substr( 6, 3 ) + "-" + aux.substr( 9, 2 );}// Formata data xx/xx/xxxxfunction FormataData( Campo ){   var aux     = SoNumeros( Campo );   Campo.value = aux.substr( 0, 2 ) + "/" + aux.substr( 2, 2 ) + "/" + aux.substr( 4, 4 );}// Formata data parcial xx/xxxxfunction FormataDataParcial( Campo ){   var aux     = SoNumeros( Campo );   Campo.value = aux.substr( 0, 2 ) + "/" + aux.substr( 2, 4 );}// Formata fone [xx]xx-xxxxfunction FormataFoneFax( Campo ){   var aux     = SoNumeros( Campo );   Campo.value = aux.substr( 0, aux.length - 4 ) + "-" + aux.substr( aux.length - 4, 4 );}// Formata CRC xx-xxxxxx/x-xfunction FormataCRC( Campo ){   var aux     = SoLetrasNumeros( Campo );   Campo.value = aux.substr( 0, 2 ) + "-" + aux.substr( 2, 6 ) + "/" + aux.substr( 8, 1 ) + "-" + aux.substr( 9, 1 );}// Formata CadICMS xxxxxxxx-xxfunction FormataCadICMS( Campo ){   var aux     = SoNumeros( Campo );   Campo.value = aux.substr( 0, 8 ) + "-" + aux.substr( 8, 2 );}// Formata Jucepar xx/xxxxxx-xfunction FormataProtocoloJUCEPAR( Campo ){   var aux     = SoNumeros( Campo );   Campo.value = aux.substr( 0, 2 ) + "/" + aux.substr( 2, 6 ) + "-" + aux.substr( 8, 2 );}// Formata valores xx.xxx,xxfunction FormataValor( Campo, TirarDecimal, DecimalZerado, TirarPontos ){   var decimal, inteira;   var valorAux = Campo.value.replace( /\.|\s/g, "" ).replace( /\,/g, "." );   var pos = valorAux.indexOf( "." );   // Guardando as casa decimais e a parte inteira   if( pos != -1 )   {      inteira = valorAux.substr( 0, pos );      decimal = valorAux.substr( pos + 1, valorAux.length - pos - 1 );      inteira = ( inteira == "" ) ? "0" : inteira;      if( decimal.length > 2 )      {         if( decimal.charAt( 2 ) > 5 )         {            decimal = parseInt( decimal.substr( 0, 2 ), 10 ) + 1;            if( decimal == 100 )            {               inteira = ( parseInt( inteira ) + 1 ).toString();               decimal = "00";            }            if( decimal.toString().length == 1 )               decimal = "0" + decimal;         }         else            decimal = decimal.substr( 0, 2 );      }      if( decimal.length == 1 ) decimal += "0";      if( decimal.length == 0 ) decimal = "00";   }   else   {      decimal = "00";      inteira = valorAux;   }   if( DecimalZerado )      decimal = "00";   if( !TirarPontos )      inteira = ColocaPontos( inteira );   valorAux = inteira;   if( !TirarDecimal )      valorAux += "," + decimal;   Campo.value = valorAux;}function FormataCred( Campo ){   var aux     = SoNumeros( Campo );   Campo.value = aux.substr( 0, 7 ) + "-" + aux.substr( 7, 2 );}function FormataGeral( Campo, Casas ){   var aux     = SoNumeros( Campo );   Campo.value = aux.substr( 0, aux.length - Casas ) + "-" + aux.substr( aux.length - Casas, Casas );}// Formata CNAEF xxxx-x/xxfunction FormataCNAEF( Campo ){   var aux     = SoNumeros( Campo );   Campo.value = aux.substr( 0, 4 ) + "-" + aux.substr( 4, 1 ) + "/" + aux.substr( 5, 2 );}function FormataDIDSI( Campo ){   var aux     = SoNumeros( Campo );   Campo.value = aux.substr( 0, aux.length - 1 ) + "-" + aux.substr( aux.length - 1, 1 );}/******************************************************************************** Funcoes de validacao                                                      ********************************************************************************/// Valida CNPJfunction ValidaInscricaoCNPJ( Campo ){   if( !EhNumero( Campo, 'Inscrição CNPJ Inválida.' ) ) return false;   var aux = SoNumeros( Campo );   if( aux != "" )   {      if( !CNPJOk( aux ) )      {         alert( "Inscrição CNPJ Inválida." );         Foco( Campo );         return false;      }      FormataCNPJ( Campo );      return true;   }   return false;}// Valida CPFfunction ValidaInscricaoCPF( Campo ){   if( !EhNumero( Campo, 'Inscrição CPF Inválida.' ) ) return false;   var aux = SoNumeros( Campo );   if( aux != "" )   {      if( CampoZerado( aux ) || !CPFOk( aux ) )      {         alert( "Inscrição CPF Inválida." );         Foco( Campo );         return false;      }      FormataCPF( Campo );      return true;   }   return false;}// Valida nosso numerofunction ValidaNossoNumero( Campo ){   if( !EhNumero( Campo, 'Nosso Número Inválido.' ) ) return false;   var aux = SoNumeros( Campo );   if( aux != "" )   {      if( CampoZerado( aux ) || !NossoNumeroOk( aux ) )      {         alert( "Nosso Número Inválido." );         Foco( Campo );         return false;      }      return true;   }   return false;}// Valida datafunction ValidaData( Campo, Referencia, Igual ){   /* Referencia      0 ou nada -> naum valida      1         -> Data maior que a data atual      2         -> Data menor que a data atual      3         -> Data naum pode ser superior a um mes da data atual      4         -> Data naum pode ser maior que o ultimo dia do mes      5         -> Data naum pode ser maior que a data atual e menor que 5 anos atras      6         -> Data no formato ddmmaa   */   if( !EhNumero( Campo, 'Data Inválida.' ) ) return false;   var DataAtual, auxData, aux2;   var aux = SoNumeros( Campo );   var Operador = ( Igual ) ? "=" : "";   if( aux != "" )   {      if( !DataOk( aux, Referencia ) )      {         alert( "Data Inválida." );         Foco( Campo );         return false;      }      DataAtual = new Date();      DataAtual.setHours( 0, 0, 0, 0 );      if( Referencia == 6 )      {         aux2 = parseInt( aux.substr( 4, 2 ), 10 );         if( aux2 > 80 )            aux2 = "19" + aux2;         else            if( aux2 < 10 )               aux2 = "200" + aux2;            else               aux2 = "20" + aux2;      }      else         aux2 = aux.substr( 4, 4 );      aux2 = parseInt( aux2, 10 );      auxData = new Date( aux2, aux.substr( 2, 2 ) - 1, aux.substr( 0, 2 ), 0, 0, 0 );      if( Referencia == 1 && eval( "auxData <" + Operador + " DataAtual" ) )      {         alert( "Data deve ser posterior à Data Atual." );         Foco( Campo );         return false;      }      if( Referencia == 2 && eval( "auxData >" + Operador + "DataAtual" ) )      {         alert( "Data não deve ser posterior à Data Atual." );         Foco( Campo );         return false;      }      if( Referencia == 4 )      {         aux  = DataAtual.getMonth() + 1;         aux2 = "31";         if( aux == 2 )            aux2 = ( DataAtual.getFullYear() % 4 == 0 ) ? "29" : "28";         if( aux == 4 || aux == 6 || aux == 9 || aux == 11 )            aux2 = "30";         DataAtual.setDate( aux2 );         if( DataAtual < auxData )         {            alert( "Data não pode ser maior que o último dia do mês atual" );            Foco( Campo );            return false;         }      }      if( Referencia == 5 )      {         if( eval( "auxData >" + Operador + "DataAtual" ) )         {            alert( "Data não deve ser posterior à Data Atual." );            Foco( Campo );            return false;         }         if( auxData.getFullYear() < DataAtual.getFullYear() - 5 )         {            alert( "Data não deve ser inferior a 5 anos do ano atual." );            Foco( Campo );            return false;         }      } // if( Referencia == 5 )      if( Referencia != 6 )         FormataData( Campo );      return true;   }   return false;}// Valida a data no formato mmaaaafunction ValidaDataParcial( Campo, Referencia ){   /* Referencia      0 ou nada -> naum valida      1         -> Data maior que a data atual      2         -> Data menor que a data atual      3         -> Data naum pode ser superior a um mes da data atual      4         -> Data naum pode ser maior que o ultimo dia do mes      5         -> Data naum pode ser maior que o mes atual e menor que 5 anos atras   */   if( !EhNumero( Campo, 'Data Inválida.' ) ) return false;   var DataAtual, auxData;   var aux = SoNumeros( Campo );   if( aux.length == 5 )      aux = "0" + aux;   if( aux != "" )   {      if( !DataParcialOk( aux ) )      {         alert( "Data Inválida." );         Foco( Campo );         return false;      }      DataAtual = new Date();      // Criando a data no formato de 01mmaaaa      auxData = new Date( aux.substr( 2, 4 ), aux.substr( 0, 2 ) - 1, 1, 0, 0, 0 );      // Agora para a data atual      DataAtual.setDate( 1 );      // Zerando as horas      DataAtual.setHours( 0, 0, 0, 0 );      if( Referencia == 1 && DataAtual > auxData )      {         alert( "Data deve ser maior que a Data Atual." );         Foco( Campo );         return false;      }      if( Referencia == 2 && DataAtual < auxData )      {         alert( "Data deve ser menor que a Data Atual." );         Foco( Campo );         return false;      }      // Dividindo por 1000ms * 60s * 60m * 24h = 86400000 teremos em dias      if( Referencia == 3 && ( ( auxData - DataAtual ) / 86400000 > 31 ) )      {         alert( "Data não pode ser superior a um mês da Data Atual" );         Foco( Campo );         return false;      }      if( Referencia == 5 )      {         if( DataAtual < auxData )         {            alert( "Data não pode ser superior ao mês atual." );            Foco( Campo );            return false;         }         DataAtual.setFullYear( DataAtual.getFullYear() - 5 );         DataAtual.setMonth( 0 );         if( DataAtual > auxData )         {            alert( "Data não pode ser menor que 5 anos do ano atual" );            Foco( Campo );            return false;         }      }      FormataDataParcial( Campo );      return true;   }}// Valida fonesfunction ValidaFoneFax( Campo, DescCampo ){   var aux, rsAux, EhDDD;   var valorAux = Campo.value.replace( /\s|\-/g, "" );   EhDDD = ( Campo.name.indexOf( "DDD" ) != -1 ) ? true : false;   aux = SoNumeros( Campo );   if( parseInt( aux, 10 ) <= 0 )   {      alert( DescCampo + " Informado deve ser diferente de 0 (zero)." );      Foco( Campo );      return false;   }   if( EhDDD && aux.substr( 0, 1 ) == "0" )   {      alert( DescCampo + " Informado não deve começar com 0 (zero)." );      Foco( Campo );      return false;   }   if( EhDDD && ( ( aux.length != 0 && aux.length != 2 ) || isNaN( valorAux ) ) )   {      alert( DescCampo + " Informado deve possuir 2 dígitos numéricos." );      Foco( Campo );      return false;   }//   if( !EhNumero( Campo, DescCampo + ' Inválido.' ) ) return false;   if( !EhDDD )   {      if( aux.length != 0 || isNaN( valorAux ) )      {         if( ( aux.length != 7 && aux.length != 8 ) || isNaN( valorAux ) )         {            alert( DescCampo + " Informado deve possuir entre 7 e 8 dígitos numéricos." );            Foco( Campo );            return false;         }         FormataFoneFax( Campo );      }      return true;   }   else // eh ddd      return true;   return false;}// Valida valoresfunction ValidaValor( Campo, DescCampo, TirarDecimal, DecimalZerado, TirarPontos ){   if( !EhNumero( Campo, DescCampo + ' Inválido.' ) ) return false;   var aux = Campo.value.replace( /\.|\,/g, "" );   aux = SoNumeros( Campo );   if( aux != "" )   {      if( aux <= 0 )      {         alert( DescCampo + " Informado deve ser diferente de 0 (zero)." );         Foco( Campo );         return false;      }      FormataValor( Campo, TirarDecimal, DecimalZerado, TirarPontos );      return true;   }   return false;}// Valida Numerosfunction ValidaNumero( Campo, DescCampo ){   if( !EhNumero( Campo, DescCampo + ' Inválido.' ) ) return false;   var aux = Campo.value;   aux = SoNumeros( Campo );   if( aux != "" )   {      return true;   }   return false;}// Valida Juceparfunction ValidaProtocoloJUCEPAR( Campo ){   if( !EhNumero( Campo, 'Protocolo da JUCEPAR Inválido.' ) ) return false;   var aux = SoNumeros( Campo );   if( aux != "" )   {      if( CampoZerado( aux ) || !ProtocoloJUCEPAROk( aux ) )      {         alert( "Protocolo da JUCEPAR Inválido." );         Foco( Campo );         return false;      }      FormataProtocoloJUCEPAR( Campo );      return true;   }   return false;}// Valida NIREfunction ValidaNIRE( Campo ){   if( !EhNumero( Campo, 'NIRE Inválido.' ) ) return false;   var aux = SoNumeros( Campo );   if( aux != "" )   {      if( CampoZerado( aux ) || !NIREOk( aux ) )      {         alert( "NIRE Inválido." );         Foco( Campo );         return false;      }//    FormataNIRE( Campo );      return true;   }   return false;}// Valida CRCfunction ValidaInscricaoCRC( Campo, ValidarTodosTipos ){   var aux = SoLetrasNumeros( Campo );   if( aux != "" )   {      if( !CRCOk( aux, ValidarTodosTipos ) )      {         alert( "Inscrição CRC Inválida." );         Foco( Campo );         return false;      }      FormataCRC( Campo );      return true;   }   return false;}// Valida Cad.ICMSfunction ValidaInscricaoCadICMS( Campo ){   if( !EhNumero( Campo, 'Inscrição Cad.ICMS/PR Inválida.' ) ) return false;   var aux = SoNumeros( Campo );   if( aux != "" )   {      if( CampoZerado( aux ) || !CadICMSOk( aux ) )      {         alert( "Inscrição Cad.ICMS/PR Inválida." );         Foco( Campo );         return false;      }      FormataCadICMS( Campo );      return true;   }   return false;}// Funcao para validar emailfunction ValidaEmail( Campo ){   var aux = Campo.value.replace( /\s/g, "" );   if( aux != "" )   {      // Valida aux ate do tipo joao.bla-@ddd-abc.com.br      expr = /^(\w|\-)(\w|\.\w|\-)*@\w(\w|\-\w)*(\.\w(\w|\-\w)*)+$/      if( !aux.match( expr ) )      {         alert( "E-Mail Inválido." );         Foco( Campo );         return false;      }      Campo.value = aux;      return true;   }   return true;}// Funcao para validar o renavamfunction ValidaRenavam( Campo ){   if( !EhNumero( Campo, 'Código RENAVAM inválido.' ) ) return false;   var aux = SoNumeros( Campo );   if( aux != "" )   {      if( CampoZerado( aux ) || !RenavamOk( aux ) )      {         alert( "Código RENAVAM inválido." );         Foco( Campo );         return false;      }      Campo.value = ColocaZeros( aux, 9 - aux.length );      FormataGeral( Campo, 1 );      return true;   }   return false;}function ValidaPlacaRenavam( Campo ){   // Campo no formato: LLLNNNNPR   var aux =  SoLetrasNumeros( Campo ).toUpperCase();   if( aux != "" )   {      expr = /^[A-Z]{3}\d{4}PR$/      if( !expr.test( aux ) )      {         alert( "Número do Renavam inválido." );         Foco( Campo );         return false;      }      return true;   }   return false;}// Funcao para validar a cnaeffunction ValidaCNAEF( Campo ){   if( !EhNumero( Campo, 'CNAE-Fiscal inválida.' ) ) return false;   var aux = SoNumeros( Campo );   if( aux != "" )   {      if( CampoZerado( aux ) || !CNAEFOk( aux ) )      {         alert( "CNAE-Fiscal inválida." );         Foco( Campo );         return false;      }      FormataCNAEF( Campo );      return true;   }   return false;}// Funcao para validar o comprovantefunction ValidaComprovante( Campo ){   if( !EhNumero( Campo, 'Número do Pedido inválido.' ) ) return false;   var aux = SoNumeros( Campo );   if( aux != "" )   {      if( CampoZerado( aux ) || !ComprovanteOk( aux ) )      {         alert( "Número do Pedido inválido." );         Foco( Campo );         return false;      }      FormataComprovante( Campo );      return true;   }   return false;}// Valida Credfunction ValidaCred( Campo, Tipo ){   /* Tipos      1 - Credencial      2 - Transferencia      3 - Apropriacao      4 - Liquidação de Débitos      5 - Habilitação de Pedidos   */   mensagem = "";   switch( Tipo )   {      case 1: mensagem = "Número do Credenciado inválido."; break;      case 2: mensagem = "Número do Certificado de Transferência inválido."; break;      case 3: mensagem = "Número do Certificado de Apropriação inválido."; break;      case 4: mensagem = "Número do Certificado de Liquidação de Débitos inválido."; break;      case 5: mensagem = "Número do Certificado de Habilitação de Pedidos inválido."; break;      default: mensagem = "Número inválido.";   }   if( !EhNumero( Campo, mensagem ) ) return false;   var aux = SoNumeros( Campo );   if( aux != "" )   {      if( CampoZerado( aux ) || !CredOk( aux, Tipo ) )      {         alert( mensagem );         Foco( Campo );         return false;      }      FormataCred( Campo );      return true;   }   return false;}// Valida DI - Declaração de Importaçãofunction ValidaDI( Campo ){   if( !EhNumero( Campo, 'Número da DI (Declaração de Importação) inválido.' ) ) return false;   var aux = SoNumeros( Campo );   if( aux != "" )   {      aux = ColocaZeros( aux, 12-aux.length );      if( CampoZerado( aux ) || !DIOk( Campo ) )      {         alert( "Número da DI (Declaração de Importação) inválido." );         Foco( Campo );         return false;      }      FormataDIDSI( Campo );      return true;   }   return false;}// Valida DSI - Decaração Simplificada de Importaçãofunction ValidaDSI( Campo ){   if( !EhNumero( Campo, 'Número da DSI (Declaração Simplificada de Importação) inválido.' ) ) return false;   var aux = SoNumeros( Campo );   if( aux != "" )   {      aux = ColocaZeros( aux, 12-aux.length );      if( CampoZerado( aux ) || !DSIOk( Campo ) )      {         alert( "Número da DSI (Declaração Simplificada de Importação) inválido." );         Foco( Campo );         return false;      }      FormataDIDSI( Campo );      return true;   }   return false;}/******************************************************************************** Funcoes de verificacao de consistencia                                    ********************************************************************************/// Valida CNPJfunction CNPJOk( Valor ){   if( Valor.length != 14 )      return false;   if( Valor.substr( 8, 4 ) == "0000" || Valor.substr( 8, 4 ) == "9999" )      return false;   // Verificando o digito verificador   if( Modulo11( Valor.substr( 0, 12 ), 2, 9 ) != Valor.substr( 12, 1 ) || Modulo11( Valor.substr( 0, 13 ), 2, 9 ) != Valor.substr( 13, 1 ) )      return false;   return true;}// Valida CPFfunction CPFOk( Valor ){   if( Valor.length != 11 )      return false; //  expr = /0{11}|1{11}|2{11}|3{11}|4{11}|5{11}|6{11}|7{11}|8{11}|9{11}/ //  if( Valor.match( expr ) ) //     return false;   // Verificando o digito verificador   if( Modulo11( Valor.substr( 0, 9 ), 2, 11 ) != Valor.substr( 9, 1 ) || Modulo11( Valor.substr( 0, 10 ), 2, 11 ) != Valor.substr( 10, 1 ) )      return false;   return true;}// Valida CadICMSfunction CadICMSOk( Valor ){   if( Valor.length != 10 )      return false;   // Verificando o digito verificador   if( Modulo11( Valor.substr( 0, 8 ), 2, 7 ) != Valor.substr( 8, 1 ) || Modulo11( Valor.substr( 0, 9 ), 2, 7 ) != Valor.substr( 9, 1 ) )      return false;   return true;}// Valida datafunction DataOk( Valor, Referencia ){   // Referencia = 6 -> Data no formato ddmmaa   var dataAtual = new Date();   var dia, mes, ano;   if( Valor.length == 8 || ( Referencia == 6 && Valor.length == 6 ) )   {      dia = parseInt( Valor.substr( 0, 2 ), 10 );      mes = parseInt( Valor.substr( 2, 2 ), 10 );      if( Referencia == 6 )      {         aux = parseInt( Valor.substr( 4, 2 ), 10 );         if( aux > 80 )            aux = "19" + aux;         else            if( aux < 10 )               aux = "200" + aux;            else               aux = "20" + aux;      }      else         aux = Valor.substr( 4, 4 );      ano = parseInt( aux, 10 );      if( dia < 1 || dia > 31 )         return false;      if( mes < 1 || mes > 12 )         return false;      if( ( mes == 4 || mes == 6 || mes == 9 || mes == 11 ) && dia > 30 )         return false;      if( mes == 2 )      {         if( ano % 4 == 0 && dia > 29 )            return false;         if( ano % 4 != 0 && dia > 28 )            return false;      }      dataAtual.setHours( 0, 0, 0, 0 );      var dataInformada = new Date( ano, mes - 1, dia, 0, 0, 0, 0 );      // Cem anos antes      if( dataInformada < dataAtual.setFullYear( dataAtual.getFullYear() - 100 ) )         return false;      // Cem anos depois      if( dataInformada > dataAtual.setFullYear( dataAtual.getFullYear() + 200 ) )         return false;      return true;   } // length   return false;}// Valida a data parcialfunction DataParcialOk( Valor ){   var mes, ano;   if( Valor.length == 6 )   {      mes = parseInt( Valor.substr( 0, 2 ), 10 );      ano = parseInt( Valor.substr( 2, 4 ), 10 );      if( mes < 1 || mes > 12 )         return false;      if( ano < 1901 || ano > 2100 )         return false;      return true;   } // length   return false;}// Valida Fonesfunction FoneFaxOk( Valor ){   if( Valor.length != 6 && Valor.length != 7 && Valor.length != 8 )      return false;   if( parseFloat( Valor ) == 0 )      return false;   return true;}// Valida Juceparfunction ProtocoloJUCEPAROk( Valor ){   if( Valor.length != 9 )      return false;   // Verificando o digito verificador   if( Modulo11( Valor.substr( 0, 8 ), 2, 9 ) != Valor.substr( 8, 1 ) )      return false;   return true;}// Valida NIREfunction NIREOk( rsNumero ){   if( rsNumero.length != 11 ) return false;   var rsPos, rsFator, rsNIRE, rsTotal;   var rsOk = false;   rsNIRE  = "";   rsFator = 2;   rsTotal = 0;   rsPos   = 9;   do   {      rsTotal += ( rsNumero.substr( rsPos, 1 ) ) * rsFator;      rsFator++;      if( rsFator > 10 )         rsFator = 2;      rsPos--;   }while( rsPos >= 0 );   rsTotal = 11 - ( rsTotal % 11 );   rsNIRE = ( rsTotal > 9 ) ? ( rsTotal - 10 ) : rsTotal;   if( rsNIRE == rsNumero.substr( 10, 1 ) )      rsOk = true;   return( rsOk );}// Valida CRCfunction CRCOk( Valor, ValidarTodosTipos ){   var vSit;   if( Valor.length != 10 )      return false;   // alterado 14/01/2004   if( typeof ValidarTodosTipos == "undefined" || !ValidarTodosTipos )      vSit = new Array( "O", "", "", "P" )   else      vSit = new Array( "O", "T", "S", "P", "K" );//   var vSit = new Array( "O", "P" );   var vUF1 = new Array( "AC","AL","AM","AP","BA","CE","CF","DF","ES","FR","GB","GO","MA","MG",                         "MS","MT","NI","PA","PB","PE","PF","PI","PJ","PR","RJ","RN","RO","RR",                         "RS","SC","SE","SP","TO","LG","NR" );   var vUF2 = new Array( "26","09","01","25","11","05","24","21","12","99","22","20","03","18",                         "23","19","98","02","07","08","50","04","51","15","13","06","29","27",                         "17","16","10","14","28","30","21" );   var i;   var uf     = Valor.substr( 0, 2 ).toUpperCase();   var numero = Valor.substr( 2, 6 ).toUpperCase();   var sit    = Valor.substr( 8, 1 ).toUpperCase();   var numMod = "1"   var soma, mult, aux;   var encontrou;   encontrou = false;   for( i = 0; i < vUF1.length; i++ )      if( vUF1[ i ] == uf )      {         numMod += vUF2[ i ];         encontrou = true;         break;      }   if( !encontrou )      return false;   numMod += numero;   encontrou = false;   for( i = 0; i < vSit.length; i++ )      if( vSit[ i ] == sit )      {         numMod += ( i + 1 );         encontrou = true;         break;      }   if( !encontrou )      return false;   soma = 0;   mult = 2;   for( i = numMod.length - 1; i >= 0; i-- )   {      soma += parseInt( numMod.substr( i, 1 ), 10 ) * mult;      if( mult == 10 )         mult = 2;      mult++;   }   aux = 11 - ( soma % 11 );   if( aux >= 10 ) aux = 0;   if( aux != Valor.substr( 9, 1 ) )      return false;   return true;}function RenavamOk( Valor ){   if( Valor == "" ) return false;   if( CampoZerado( Valor ) ) return false;   if( Valor.length > 9 )      return false;   if( Valor.length < 9 )      Valor = ColocaZeros( Valor, 9 - Valor.length );   // Verificando o digito verificador   if( Modulo11( Valor.substr( 0, 8 ), 2, 9 ) != Valor.substr( 8, 1 ) )      return false;   return true;}// Valida Nosso Numerofunction NossoNumeroOk( Valor ){   if( Valor.length != 16 )      return false;   var aux = Valor;   // Verificando o digito verificador   if( Modulo11( aux.substr( 0, 15 ), 2, 9 ) != aux.substr( 15, 1 ) )      return false;   return true;}// Valida CNAEFfunction CNAEFOk( Valor ){   if( Valor.length != 7 )      return false;   var aux = Valor;   // Verificando o digito verificador   if( Modulo11( aux.substr( 0, 4 ), 2, 9 ) != aux.substr( 4, 1 ) )      return false;   return true;}// Valida Comprovantefunction ComprovanteOk( Valor ){   if( Valor.length != 11 )      return false;   var aux = Valor;   aux = ColocaZeros( Valor, 2 );   aux = aux.substr( 5, 1 ) + aux;   // Verificando o digito verificador   if( Modulo11( aux.substr( 0, 12 ), 2, 9 ) != aux.substr( 12, 1 ) || Modulo11( aux.substr( 0, 13 ), 2, 9 ) != aux.substr( 13, 1 ) )      return false;   return true;}// Valida credencial, habilitação, apropriacao e transferenciafunction CredOk( Valor, Tipo ){   /* Tipos      1 - Credencial      2 - Transferencia      3 - Apropriacao      4 - Liquidação de Débitos      5 - Habilitação de Pedidos   */   if( Valor.length > 9 ) return false;   if( Valor.length < 9 )      Valor = ColocaZeros( Valor, 9 - Valor.length );   switch( Tipo )   {      case 1: if( Valor.substr( 0, 1 ) != "0" ) return false; break;      case 2: if( Valor.substr( 0, 1 ) != "7" ) return false; break;      case 3: if( Valor.substr( 0, 1 ) != "8" ) return false; break;      case 4: if( Valor.substr( 0, 1 ) != "9" ) return false; break;      case 5: if( Valor.substr( 0, 1 ) != "6" ) return false; break;      default: return false;   }   // Verificando o digito verificador   if( Modulo11( Valor.substr( 0, 7 ), 2, 7 ) != Valor.substr( 7, 1 ) )      return false;   // Digito auxiliar   var aux = Modulo11( Valor.substr( 0, 8 ), 5, 3 );   var aux2 = Valor.substr( 0, 8 ) + aux;   // Verificando o segundo digito   if( Modulo11( aux2, 2, 9 ) != Valor.substr( 8, 1 ) )      return false;   return true;}//********************function FormataValorCadicms( Campo ){//formata o cadicms enquanto o usuario digita//chamar no evento onKeyUp   var valor   = SoNumeros( Campo );   var retorno = "";   var decimal, inteira;   if( valor != "" )      valor = parseFloat( valor ).toString();   else   {      Campo.value = "";      return;   }   if( valor.length > 2 )   {      retorno = ColocaPontos( valor.substr( 0, valor.length - 2 ) ) + "," + valor.substr( valor.length - 2, 2 );   }   else   {      if( valor.length == 2 ) retorno = "0" + "," + valor;      if( valor.length == 1 && valor != "0" ) retorno = "0,0" + valor;      if( valor.length == 0 || valor == "0" ) retorno = "";   }   Campo.value = retorno;}//*********function MascaraCadicms(campo, event){/* mascara: 99999999-99   funcao que mascara o cadicms enquanto o usuario digita   campo deve estar alinhado a direita -> style="text-align: right;"   chamar no evento onKeyUp e maxlength="11" */var tecla= event.keyCode;var valor  = SoNumeros(campo); // variável recebe valor do campo/*Bloqueia teclas diferentes de numéricas, e que seja != de backspace*/if (tecla == 9) { // se for igual a tab, retorna falso   return false;} else if (tecla != 8 && ((tecla < 48) || (tecla > 57)) && ((tecla < 96) || (tecla > 105))){   tecla = 0;   campo.value = valor;//.substr(0, valor.length-1);}if (valor.length > 10)   {   valor = valor.substr(0, 10);   }if (valor.length > 2)   {   var digito = valor.substr(valor.length-2); //pega digito verificador   campo.value = valor.substr(0, valor.length-2) + "-" + digito;   }else   {   campo.value = valor;   }}//***function MascaraCpf(campo, event){/* mascara: 999.999.999-99   funcao que mascara o CPF enquanto o usuario digita   campo deve estar alinhado a direita -> style="text-align: right;"   chamar no evento onKeyUp e maxlength="14" */var tecla= event.keyCode;var valor  = SoNumeros(campo); // variável recebe valor do campo/*Bloqueia teclas diferentes de numéricas, e que seja != de backspace*/if (tecla == 9) { // se for igual a tab, retorna falso   return false;} else if (tecla != 8 && ((tecla < 48) || (tecla > 57)) && ((tecla < 96) || (tecla > 105))){   tecla = 0;   campo.value = valor;//.substr(0, valor.length-1);}if (valor.length > 11)   {   valor = valor.substr(0, 11);   }if (valor.length > 5)//6 a 11 digitos   {   campo.value = ColocaPontos(valor.substr(0, valor.length-2)) + "-" + valor.substr(valor.length-2);   }else   if (valor.length > 2) //3 a 5 digitos      {      campo.value = valor.substr(0, valor.length-2) + "-" + valor.substr(valor.length-2);      }}//****function MascaraCnpj(campo, event){/* mascara: 99.999.999/9999-99   funcao que mascara o CNPJ enquanto o usuario digita   campo deve estar alinhado a direita -> style="text-align: right;"   chamar no evento onKeyUp e maxlength="18" */var tecla= event.keyCode;var valor  = SoNumeros(campo); // variável recebe valor do campo/*Bloqueia teclas diferentes de numéricas, e que seja != de backspace*/if (tecla == 9) { // se for igual a tab, retorna falso   return false;} else if (tecla != 8 && ((tecla < 48) || (tecla > 57)) && ((tecla < 96) || (tecla > 105))){   tecla = 0;   campo.value = valor;//.substr(0, valor.length-1);}if (valor.length > 14)   {   valor = valor.substr(0, 14);   }if (valor.length > 6)//7 a 14 digitos   {   campo.value = ColocaPontos(valor.substr(0, valor.length-6))+ "/" +    valor.substr(valor.length-6, 4) + "-" + valor.substr(valor.length-2);   }else   if (valor.length > 2) //3 a 6 digitos      {      campo.value = valor.substr(0, valor.length-2) + "-" + valor.substr(valor.length-2);      }}//****function MascaraCrc(campo, event){/* mascara: UF-999999/X-9   funcao que mascara o CRC do contabilista enquanto o usuario digita   campo deve estar alinhado a direita -> style="text-align: right;"   chamar no evento onKeyUp e maxlength="13" */var tecla= event.keyCode;var valor  = SoLetrasNumeros(campo); // variável recebe valor do campo/*Bloqueia telcas que seja != de backspace*/if (tecla == 9) { // se for igual a tab, retorna falso   return false;} else if (tecla != 8 ){ //&& ((tecla < 48) || (tecla > 57)) && ((tecla < 96) || (tecla > 105))   tecla = 0;   campo.value = valor;//.substr(0, valor.length-1);}if (valor.length > 11)   {   valor = valor.substr(0, 11);   }if (valor.length > 8)//9 e 10 digitos   {   var uf = "";   if (valor.length == 9)  uf = valor.substr(0, 1);   if (valor.length == 10) uf = valor.substr(0, 2);   campo.value = uf.toUpperCase() + "-" + valor.substr(valor.length-8, 6)+ "/" +    valor.substr(valor.length-2,1).toUpperCase() + "-" + valor.substr(valor.length-1);   }else   {   if (valor.length > 2) //3 a 8 digitos      {      campo.value = valor.substr(0, valor.length-2)+ "/" +       valor.substr(valor.length-2,1) + "-" + valor.substr(valor.length-1);      }   else      {      if (valor.length > 1) //2o digito         {         campo.value = valor.substr(valor.length-2, 1) + "-" + valor.substr(valor.length-1);         }      }   }}//***function MascaraComprovante(campo, event){/* mascara: 99999999.9.999999   funcao que mascara o Comprovante enquanto o usuario digita   campo deve estar alinhado a direita -> style="text-align: right;"   chamar no evento onKeyUp e maxlength="18" */var tecla= event.keyCode;var valor  = SoNumeros(campo); // variável recebe valor do campo/*Bloqueia teclas diferentes de numéricas, e que seja != de backspace*/if (tecla == 9) { // se for igual a tab, retorna falso   return false;} else if (tecla != 8 && ((tecla < 48) || (tecla > 57)) && ((tecla < 96) || (tecla > 105))){   tecla = 0;   campo.value = valor;//.substr(0, valor.length-1);}if (valor.length > 15)   {   valor = valor.substr(0, 15);   }if (valor.length > 7)//8 a 15 digitos   {   campo.value = valor.substr(0, valor.length-7)+ "." +    valor.substr(valor.length-7, 1) + "." + valor.substr(valor.length-6);   }else   if (valor.length > 6) //7 digito      {      campo.value = valor.substr(0, 1) + "." + valor.substr(valor.length-6);      }}//****function MascaraNumTAP(campo, event){/* mascara: 99.999999-9   funcao que mascara o cadicms enquanto o usuario digita   campo deve estar alinhado a direita -> style="text-align: right;"   chamar no evento onKeyUp e maxlength="11" */var tecla= event.keyCode;var valor  = SoNumeros(campo); // variável recebe valor do campo/*Bloqueia teclas diferentes de numéricas, e que seja != de backspace*/if (tecla == 9) { // se for igual a tab, retorna falso   return false;} else if (tecla != 8 && ((tecla < 48) || (tecla > 57)) && ((tecla < 96) || (tecla > 105))){   tecla = 0;   campo.value = valor;//.substr(0, valor.length-1);}if (valor.length > 9)   {   valor = valor.substr(0, 9);   }if (valor.length > 7) //8 e 9 digitos   {   campo.value = valor.substr(0, valor.length-7) + "." +      valor.substr(valor.length-7, 6) + "-" +      valor.substr(valor.length-1);   }else   if (valor.length > 1)      {      var digito = valor.substr(valor.length-1); //pega digito verificador      campo.value = valor.substr(0, valor.length-1) + "-" + digito;      }   else      {      campo.value = valor;      }}//***//Declaração de Importaçãofunction DIOk( Campo ){   var Valor = SoNumeros( Campo );   if( Valor == "" ) return false;   if( Valor.length > 10 ) return false;   if( Valor.length < 10 )      Valor = ColocaZeros( Valor, 10 - Valor.length );   // Concatenando 2 ao valor (RV)   Valor = "2" + Valor   if( Modulo11( Valor.substr( 0, 10 ), 2, 9 ) != Valor.substr( 10, 1 ) )      return false;   FormataDIDSI( Campo );   return true;}//Declaração Simplificada de Importaçãofunction DSIOk( Campo ){   var Valor = SoNumeros( Campo )   if( Valor == "" ) return false;   if( Valor.length > 10 ) return false;   if( Valor.length < 10 )      Valor = ColocaZeros( Valor, 10 - Valor.length );   // Concatenando 2 ao valor (RV)   Valor = "4" + Valor   if( Modulo11( Valor.substr( 0, 10 ), 2, 9 ) != Valor.substr( 10, 1 ) )      return false;   FormataDIDSI( Campo );   return true;}// Valida AIDFfunction ValidaAIDF( Campo ){   if( !EhNumero( Campo, 'Número da AIDF Inválido.' ) ) return false;   var aux = SoNumeros( Campo );   if( aux != "" )   {      if( CampoZerado( aux ) || !AIDFOk( Campo ) )      {         alert( "Número da AIDF Inválido." );         Foco( Campo );         return false;      }      FormataCadICMS( Campo );      return true;   }   return false;}function AIDFOk( Campo ){   var Valor = SoNumeros( Campo );   //Valor = '1' + Valor   Valor = '1' + ColocaZeros( Valor, 10 - Valor.length );   if( Valor.length != 11)      return false;   // Verificando o digito verificador   if( Modulo11( Valor.substr( 0, 9 ), 2, 11 ) != Valor.substr( 9, 1 ) || Modulo11( Valor.substr( 0, 10 ), 2, 11 ) != Valor.substr( 10, 1 ) )      return false;   return true;}/** * Script para permitir validacao do formulario no mozilla. * Serao executados todos os "onblur" dos campos. *  * @author Pablo Jose Almeida da Guia * @version 1.0.0 2004-12-29 * @param form referencia para o formulario * @return true ou false */function runBlurs(form) {	var i, bOut = true;	for (i=0; i<form.length; i++) {		var element = form.elements[i];		if (!element.disabled && element.onchange != null) {			var str = "" + element.onchange;			var bReturn = true;			if (str.indexOf("function") > -1) {				str = str.substr(str.indexOf("{") + 2, 						str.length - str.indexOf("{") 						- (str.length - str.lastIndexOf("}")) - 2);				while (str.charAt(0) == " " || str.charAt(0) == "\r" 						|| str.charAt(0) == "\n" || str.charAt(0) == "\t") {					str = str.substr(1);				}				if (str.indexOf("return") == 0)					str = str.substr(6);								}			str = "bReturn = " + str;			while (/this/.test(str)) {				str = str.replace("this", "element");			}			eval(str);			if (bReturn == false) {				return false;			}		}	}	return true;}function ValidaRenavamLocal( Campo ){   var aux;   with( Campo.form )   {      aux = SoLetras( Campo );      if( aux != "" )      {         if( ValidaPlacaRenavam( Campo ) )         {            Campo.value = Trim( Campo.value ).toUpperCase();            return true;         }         return false;      }      else         return ValidaRenavam( Campo );   }}function ServIPVA(){   with( document.getElementById("frmIVA") )   {      var leftPos = 0;      var topPos = 0;      var numrenavam;      // Verificando o renavam      if( EstaVazio( eRenavam, "Número do Renavam deve ser informado." ) ) return false;      if( !ValidaRenavamLocal( eRenavam ) ) return false;      if( screen )      {         // centralizar a tela         leftPos = screen.width / 2;         leftPos = leftPos - ( 700 / 2);         topPos = screen.height / 2;         topPos = ( topPos - ( 600 / 2 ) ) / 2;      }      numrenavam = eRenavam.value;     // parc= 'http://10.14.1.66:8088';      parc='https://www.arinternet.pr.gov.br';      window.open( parc + '/_c_ipva2.asp?eUser=&eRenavam='+numrenavam+'&eDatapag='+                   eDiaPg.value + eMesAnoPg.value+'&eNumImage='+eNumImage.value,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,'+                   'resizable=yes,width=700,height=600,top='+topPos+',left='+leftPos );      window.location.reload( false );      eNumImage.value = "";      //loadImageIpva = 0;      //document.getElementById("IMGIPVA").src = "https://www.fazenda.pr.gov.br/images/a.gif";      return false;   } // with( document.frmIVA )} // function SendForm()function ServCND(){with( document.getElementById("frmCND") ){   var numero  = SoNumeros(eNumero);   var user    = eUser.value;   var msg  = "";   var erro = false;   if (numero == "")   {      erro = true;      msg  = "É necessário preencher o Número da Certidão";   }      if (erro)   {      alert(msg);   }   else   {      if( screen )      {         // centralizar a tela         leftPos = screen.width / 2;         leftPos = leftPos - ( 700 / 2);         topPos = screen.height / 2;         topPos = ( topPos - ( 600 / 2 ) ) / 2;      }            window.open('https://www.arinternet.pr.gov.br/outros/_d_confcert2.asp?eUser='+user+'&eNumero='+numero,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700,height=600,top='+topPos+',left='+leftPos);   } } return false;}function ServCAD(){with(document.getElementById("frmCAD")) {  var cadicms  = SoNumeros(eInscricao);  var numcnpj  = "";  var user     = eUser.value;  var seq      = eSEQ.value;  var NumImage = eNumImage.value;  var msg  = " ";  var erro = false;  if (!CNPJOk(cadicms) && !CadICMSOk(cadicms)){    alert("Por favor, preencha somente números de \"Inscrição CNPJ\" ou \"Inscrição Estadual\".");    eInscricao.focus();    return false;  }  else if ((cadicms == "")){    alert("Por favor, preencha o campo com a \"Inscrição CNPJ\" ou \"Inscrição Estadual\".");    eInscricao.focus();    return false;  }  else if(CNPJOk(cadicms)){	numcnpj = cadicms;	cadicms = "";  }   if( screen )   {      // centralizar a tela      leftPos = screen.width / 2;      leftPos = leftPos - ( 700 / 2);      topPos = screen.height / 2;      topPos = ( topPos - ( 600 / 2 ) ) / 2;   }   //   window.open('https://www.arinternet.pr.gov.br/cadicms/_c_cadicms2.asp?eUser='+user+'&eNumImage='+NumImage+'&eCad='+cadicms+'&eCNPJ='+numcnpj+'&eSEQ='+seq+'&ePagOrigem=sefa','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700,height=600,top='+topPos+',left='+leftPos);  //B1.disabled = true;  document.location.reload();  return false;  }}function ServPAF(){with(document.getElementById("frmPAF")){ var paf  = ePAF.value; var user = eUser.value; var tam  = paf.length; var msg  = " "; var erro = false; if (tam < 6)    {erro = true;     msg  = "O Número do processo deve possuir 7 ou 8 dígitos"    } if (erro)    {alert(msg);    } else    {if( screen )      {         // centralizar a tela         leftPos = screen.width / 2;         leftPos = leftPos - ( 700 / 2);         topPos = screen.height / 2;         topPos = ( topPos - ( 600 / 2 ) ) / 2;      }     formulario = document.getElementById("frmPAF");	formulario.action = 'http://www.fazenda.pr.gov.br/consulta_processos/consulta/consulta';	campoPAF = document.createElement('input');	campoPAF.setAttribute('name','data[Consulta][protocolo]');	campoPAF.setAttribute('id','ConsultaProtocolo');	campoPAF.setAttribute('type','hidden');	campoPAF.setAttribute('value',paf);//	campoPAF.setAttribute('value',formulario.ePAF.value);	formulario.appendChild(campoPAF);	formulario.submit();    } return false;}}function AtualizarPag(){  window.location.reload();}
