function Janela (theURL,winName,features)
{
        var newWind = window.open(theURL,winName,features);
        if (newWind.opener == null)
        {
                newWind.opener = self;
        }
}
// format valores no formulario cpf
function ativa_campo(obj)
{
  	if (navigator.appName=="Netscape"&&parseFloat(navigator.appVersion)<=5)
  	{
  		
  	}
  	else
  	{
		if (obj.id=='E') 
			obj.style.background = '#F0F0FF';
		else
			obj.style.background = '#F0F0FF';
		//proximo_erro(obj);
		//visi('T',false,0,0);
	}	
}	
function desativa_campo(obj)
{
  	if (navigator.appName=="Netscape"&&parseFloat(navigator.appVersion)<=5)
  	{
  		
  	}
  	else
  	{
		if (obj.id=='E') 
			obj.style.background = '#E8E8FF';
		else
			obj.style.background = '#E8E8FF';
		//proximo_erro(obj);
		//visi('T',false,0,0);
	}	
}	


function FormataCPF(pForm,pCampo,pTamMax,pPos1,pPos2,pPosTraco,pTeclaPres)
{
	var wTecla, wVr, wTam;	
	var nerros=true;
	
    wTecla = pTeclaPres.keyCode;
	wVr = pForm[pCampo].value;
	wVr = wVr.toString().replace( "-", "" );
	wVr = wVr.toString().replace( ".", "" );
	wVr = wVr.toString().replace( ".", "" );
	wVr = wVr.toString().replace( "/", "" );
	wTam = wVr.length ;
	
	if (wTam < pTamMax && wTecla != 8) 
	{ 
	   wTam = wVr.length + 1 ; 
	}

	if (wTecla == 8 ) 
	{ 
	   wTam = wTam - 1 ; 
	}
			
	if ( wTecla == 8 || wTecla == 88 || (wTecla >= 48 && wTecla <= 57) || (wTecla >= 96 && wTecla <= 105) )
	{
		if ( wTam <= 2 )
		{
	 		pForm[pCampo].value = wVr ;
		}
		if (wTam > pPosTraco && wTam <= pTamMax) 
		{
	       wVr = wVr.substr(0, wTam - pPosTraco) + '-' + wVr.substr(wTam - pPosTraco, wTam);
		}
		if ( wTam == pTamMax)
		{
		      wVr = wVr.substr( 0, wTam - pPos1 ) + '.' + wVr.substr(wTam - pPos1, 3) + '.' + wVr.substr(wTam - pPos2, wTam);
		}
		pForm[pCampo].value = wVr;
		pForm[pCampo].value = toInteger(pForm[pCampo].value);
		nerros=true;
	}
	else
	{
		
		pForm[pCampo].value = toInteger(pForm[pCampo].value);
		nerros = false;
		
		
	}

	if (wTecla == 9) nerros = true;
	return nerros;
}

// format valores no formulario

function FormataValorDisplay(pForm, pCampo, pTamMax, pVirgula) 
{
	wVr = pForm[pCampo].value;
	wVr = wVr.toString().replace( "/", "" );
	wVr = wVr.toString().replace( "/", "" );
	wVr = wVr.toString().replace( ",", "" );
	wVr = wVr.toString().replace( ".", "" );
	wVr = wVr.toString().replace( ".", "" );
	wVr = wVr.toString().replace( ".", "" );
	wVr = wVr.toString().replace( ".", "" );
	wTam = wVr.length;

      if (pVirgula == 1) {
		if ( wTam <= 2 ){ 
	 		pForm[pCampo].value = wVr ; }
	 	if ( (wTam > 2) && (wTam <= 5) ){
		   pForm[pCampo].value = wVr.substr( 0, wTam - 2 ) + ',' + wVr.substr( wTam - 2, wTam ) ; }
	 	if ( (wTam >= 6) && (wTam <= 8) ){
    	   pForm[pCampo].value = wVr.substr( 0, wTam - 5 ) + '.' + wVr.substr( wTam - 5, 3 ) + ',' + wVr.substr( wTam - 2, wTam ) ; }
	 	if ( (wTam >= 9) && (wTam <= 11) ) {
	 		pForm[pCampo].value = wVr.substr( 0, wTam - 8 ) + '.' + wVr.substr( wTam - 8, 3 ) + '.' + wVr.substr( wTam - 5, 3 ) + ',' + wVr.substr( wTam - 2, wTam ) ; }
	 	if ( (wTam >= 12) && (wTam <= 14) ){
	 		pForm[pCampo].value = wVr.substr( 0, wTam - 11 ) + '.' + wVr.substr( wTam - 11, 3 ) + '.' + wVr.substr( wTam - 8, 3 ) + '.' + wVr.substr( wTam - 5, 3 ) + ',' + wVr.substr( wTam - 2, wTam ) ; }
	 	if ( (wTam >= 15) && (wTam <= 17) ){
	 		pForm[pCampo].value = wVr.substr( 0, wTam - 14 ) + '.' + wVr.substr( wTam - 14, 3 ) + '.' + wVr.substr( wTam - 11, 3 ) + '.' + wVr.substr( wTam - 8, 3 ) + '.' + wVr.substr( wTam - 5, 3 ) + ',' + wVr.substr( wTam - 2, wTam ) ;}
     } else { 
		if ( wTam <= 3 ){ 
	 		pForm[pCampo].value = wVr ; }
	 	if ( (wTam > 3) && (wTam <= 6) ){
		   pForm[pCampo].value = wVr.substr( 0, wTam - 3 ) + '.' + wVr.substr( wTam - 3, wTam ) ; }
	 	if ( (wTam >= 7) && (wTam <= 9) ) {
    	   pForm[pCampo].value = wVr.substr( 0, wTam - 6 ) + '.' + wVr.substr( wTam - 6, 3 ) + '.' + wVr.substr( wTam - 3, wTam ) ; }
	 	if ( (wTam >= 10) && (wTam <= 12) ) {
	 		pForm[pCampo].value = wVr.substr( 0, wTam - 9 ) + '.' + wVr.substr( wTam - 9, 3 ) + '.' + wVr.substr( wTam - 6, 3 ) + '.' + wVr.substr( wTam - 3, wTam ) ; }
	 	if ( (wTam >= 13) && (wTam <= 15) ){
	 		pForm[pCampo].value = wVr.substr( 0, wTam - 12 ) + '.' + wVr.substr( wTam - 12, 3 ) + '.' + wVr.substr( wTam - 9, 3 ) + '.' + wVr.substr( wTam - 6, 3 ) + '.' + wVr.substr( wTam - 3, wTam ) ; }
	 	if ( (wTam >= 16) && (wTam <= 18) ){
	 		pForm[pCampo].value = wVr.substr( 0, wTam - 15 ) + '.' + wVr.substr( wTam - 15, 3 ) + '.' + wVr.substr( wTam - 12, 3 ) + '.' + wVr.substr( wTam - 9, 3 ) + '.' + wVr.substr( wTam - 6, 3 ) + '.' + wVr.substr( wTam - 3, wTam ) ;}
	 }
}
function FormataCEP(pForm, pCampo) 
{
	pTamMax = 8
	wVr = pForm[pCampo].value;
	wVr = wVr.toString().replace( "/", "" );
	wVr = wVr.toString().replace( "/", "" );
	wVr = wVr.toString().replace( ",", "" );
	wVr = wVr.toString().replace( ".", "" );
	wVr = wVr.toString().replace( ".", "" );
	wVr = wVr.toString().replace( ".", "" );
	wVr = wVr.toString().replace( ".", "" );
	wTam = wVr.length;

     	if ( wTam <= 2 ){ 
	 		pForm[pCampo].value = wVr ; }
	 	if ( (wTam > 3) && (wTam <= 6) ){
		   pForm[pCampo].value = wVr.substr( 0, wTam - 3 ) + '-' + wVr.substr( wTam - 3, wTam ) ; }
	 	if ( (wTam >= 7) && (wTam <= 8) ){
    	   pForm[pCampo].value = wVr.substr( 0, wTam - 6 ) + '.' + wVr.substr( wTam - 6, 5 ) + '-' + wVr.substr( wTam - 3, wTam ) ; }
	 
}

//verifica cpf
function VCPF(pForm, pCampo)
 {
	var wVr, wVrCPF, wVrSEQ, wTam, wSoma, wSoma2, i, j, wDig1, wDig2,aux,
	    wVETOR_CC = new Array(11),
	    wVETOR_PESO = new Array(11);
 	var Erro = false;
	wVrCPF = pForm[pCampo].value;
	aux = pForm[pCampo].value;
	
  
	wVr= aux.toString().substring(0,3) + aux.toString().substring(4,7) + aux.toString().substring(8,11) + aux.toString().substring(12,14) ;     
//	wVr = wVr.toString().replace(".","");
//	wVr = wVr.toString().replace(".","");
//	wVr = wVr.toString().replace(".","");
//	wVr = wVr.toString().replace("-","");
	wTam = wVr.length + 1;

    if (wTam < 11) {
	  alert("Nº de dígitos do CPF menor que o normal. Redigite !!!");
	  pForm[pCampo].value = "";
	  pForm[pCampo].focus();
	  return false;
	}
    
	for (i = 0; i < wVr.length; i++) {
	   if (isNaN(parseInt(wVr.charAt(i))) ) {
  	     alert("O CPF contém dígitos inválidos. Corrija-o !!!");
	     pForm[pCampo].value = "";
	     pForm[pCampo].focus();
	     return false;
	   }
	}
	
	//comentado abaixo por claudio para testes
	//if (wVr == '11111111111' || wVr == '22222222222' || wVr == '33333333333' || wVr == '44444444444' || wVr == '55555555555' || 
	//    wVr == '66666666666' || wVr == '77777777777' || wVr == '88888888888' || wVr == '99999999999') {
  	//     alert("CPF Inválido. Redigite-o !!!");
	//     pForm[pCampo].value = "";
	//     pForm[pCampo].focus();
	//     return false;
    //	}
    
    wSoma = 0;
	wSoma2 = 0;
    j = 2;
    for (i = 0; i < 11; i++) {
	   wVETOR_CC[i] = wVr.charAt(i);
	   wVETOR_PESO[i] = j;
	   j++; 
	} 
    i = 0;	  
    while (i < 9)  {
	   i++;
	   if (i < 10) {
          wSoma += wVETOR_CC[9 - i] * wVETOR_PESO[i - 1]; }
	   wSoma2 += wVETOR_CC[10 - i] * wVETOR_PESO[i - 1];
	}
	wDig1 = (wSoma * 10) % 11;
	wDig2 = (wSoma2 * 10) % 11;
	if (wDig1 == 10) { 
	    wDig1 = 0;
	}	
	if (wDig2 == 10) { 
	    wDig2 = 0;
	}		
    if (parseInt(wVr.charAt(9)) != wDig1 || parseInt(wVr.charAt(10)) != wDig2) {
  	     alert("CPF com Dígito Verificador inválido. Redigite-o !!!");
//	     pForm[pCampo].value = "";
	     pForm[pCampo].focus();
	     return false;
    }	
    pForm[pCampo].value = wVrCPF;
//    pForm[pCampo + 1].value = wVrSEQ;

	return true;  // VerificaChaveAcesso(pForm, 1, 2, 3);
}



function FormataCGC(pForm,pCampo,pTeclaPres){
	var wTecla, wVr, wTam;	

	wTecla = pTeclaPres.keyCode;

	
	wVr = pForm[pCampo].value;
	wVr = wVr.toString().replace( "-", "" );
	wVr = wVr.toString().replace( ".", "" );
	wVr = wVr.toString().replace( ".", "" );
	wVr = wVr.toString().replace( "/", "" );
	wTam = wVr.length ;

	if (wTam < 14 && wTecla != 8) { 
	   wTam = wVr.length + 1 ; 
	}

	if (wTecla == 8 ) { 
	   wTam = wTam - 1 ; 
	}

	if ( wTecla == 8 || wTecla == 88 || wTecla >= 48 && wTecla <= 57 || wTecla >= 96 && wTecla <= 105 ){
		if ( wTam <= 2 ){
	 		pForm[pCampo].value = wVr ;
		}
		if (wTam > 2 && wTam <= 14) {
		   wVr = wVr.substr(0, wTam - 2) + '-' + wVr.substr(wTam - 2, wTam);
		}
		if ( wTam == 14){
	       wVr = wVr.substr( 0, wTam - 12 ) + '.' + wVr.substr(wTam - 12, 3) + '.' + wVr.substr(wTam - 9, 3) + "/" + wVr.substr(wTam - 6, wTam);
		}
		pForm[pCampo].value = wVr;
	
	}

}


/*function VCGC(pForm, pCampo)
{ 
//= pForm[pCampo].value.toString().substring(0,15)
// pForm[pCampo].value.toString().substring(16, 2);
	var Numero; 
	var Digito; 
	var CNPJ ,aux = pForm[pCampo].value

	//Numero = Numero.replace(".","");
	//Numero = Numero.replace(".","");
	//Numero = Numero.replace("/","");
	//Numero = Numero.replace("-","");

	Numero = aux.toString().substring(0,2) + aux.toString().substring(3,6) + aux.toString().substring(7,10) + aux.toString().substring(11,15);
	CNPJ= aux.toString().substring(0,2) + aux.toString().substring(3,6) + aux.toString().substring(7,10) + aux.toString().substring(11,15) + aux.toString().substring(16,18);
	Digito=aux.toString().substring(16,18);

//	CNPJ = CNPJ.replace(".","");
//	CNPJ = CNPJ.replace(".","");
//	CNPJ = CNPJ.replace("/","");
//	CNPJ = CNPJ.replace("-","");

	var CGC = Numero;
	var peso1 = ('543298765432');
	var peso2 = ('654329876543');
	var soma1 = 0;
	var soma2 = 0;
	var digito1 = 0;
	var digito2 = 0;
          
	 if (CNPJ == '00000000000000'){
	 	alert("CNPJ Inválido. Redigite!");
		pForm[pCampo].value = "";
	  	pForm[pCampo].focus();
	  	return false;
	 } 
	 
	 if ((Numero.length + Digito.length + 1 > 1) && (Numero.length + Digito.length + 1 < 15)) 
	 {
	  alert("Nº de dígitos do CNPJ menor que o normal. Redigite !!!");
	  pForm[pCampo].value = "";
	  pForm[pCampo].focus();
	  return false;
	 }	
 
 	if (Numero.length + Digito.length + 1 > 1){
 		 
		 for (i = 1; i < 12 - Numero.length + 1; i++) 
		 {
		  CGC = eval("'" + 0 + CGC + "'")
		 }
		    
		 for (i = 1; i < CGC.length+1; i++) 
		 {
		  soma1 += CGC.substring(i, i-1) * peso1.substring(i, i-1);
		 } 
		
		 soma1 %= 11;
		
		 if (soma1  < 2) 
		 {
		  digito1 = 0;
		 }
		 else 
		 {
		  digito1 = 11 - soma1; 
		 }
		
		 for (i = 1; i < CGC.length+1; i++) 
		 {
		  soma2 += CGC.substring(i, i-1) * peso2.substring(i, i-1);
		 } 
		 
		 soma2 += digito1 * 2 
		 soma2 %= 11;
		
		 if (soma2  < 2) 
		 {
		  digito2 = 0;
		 }
		 else 
		 {
		  digito2 = 11 - soma2; 
		 }
		
		 if (eval("'" + digito1 + digito2 + "'") != Digito)
		 {
		 // alert("CNPJ inválido. Redigite !!!");
//		  pForm[pCampo].value = "";
//		  pForm[pCampo].focus();
		  return false;
		 }
		 else 
		 {
		  return true;
		 }
	}
}
*/
// Formata Data
function FormataData(pForm, pCampo,pTeclaPres) {
	var wTecla = pTeclaPres.keyCode;
	wVr = pForm[pCampo].value;
	wVr = wVr.replace( ".", "" );
	wVr = wVr.replace( "/", "" );
	wVr = wVr.replace( "/", "" );
	wTam = wVr.length + 1;

	if ( wTecla != 9 && wTecla != 8 ){
		if ( wTam > 2 && wTam < 5 )
			pForm[pCampo].value = wVr.substr( 0, wTam - 2  ) + '/' + wVr.substr( wTam - 2, wTam );
		if ( wTam >= 5 && wTam <= 10 )
			pForm[pCampo].value = wVr.substr( 0, 2 ) + '/' + wVr.substr( 2, 2 ) + '/' + wVr.substr( 4, 4 ); 
	}			
}


//Formatar Telefone
function FormataTEL(pForm, pCampo, pTeclaPres) {
	var wTecla = pTeclaPres.keyCode;
	var wTam;
	wVr = pForm[pCampo].value;
	wVr = wVr.replace( ".", "" );
//	wVr = wVr.replace( "(", "" );
//	wVr = wVr.replace( ")", "" );
	wVr = wVr.replace( "-", "" );
	wVr = wVr.replace( "/", "" );
	wTam = wVr.length + 1;

	if ( wTecla != 9 && wTecla != 8 ){
		if ( wTam > 0 && wTam < 2 ) 
			pForm[pCampo].value = '(' ;
		if ( wTam > 3 && wTam < 5 ) 
			pForm[pCampo].value = wVr.substr( 0, 8 ) + ')' + wVr.substr( 8, 4 );
		if ( wTam > 7 && wTam < 9 ) 
			pForm[pCampo].value = wVr.substr( 0, 8 ) + '-' + wVr.substr( 8, 4 );
		if ( wTam > 11)
			pForm[pCampo].value = wVr.substr( 0, 8 ) + '-' + wVr.substr( 8, 4 ); 
	}			
}

// 
function CampoUpcase (pForm, pCampo, pOperacao) {
   if (pOperacao == "+") {
     pForm[pCampo].value = pForm[pCampo].value.toUpperCase();
   } else {
     pForm[pCampo].value = pForm[pCampo].value.toLowerCase();
   }
}

//
function FormataCEP(pForm, pCampo, pTeclaPres) {
	var wTecla = pTeclaPres.keyCode;
	var wTam;
	wVr = pForm[pCampo].value;
	wVr = wVr.replace( ".", "" );
	wVr = wVr.replace( "-", "" );
	wVr = wVr.replace( "/", "" );
	wTam = wVr.length + 1;

	if ( wTecla != 9 && wTecla != 8 ){
		if ( wTam > 2 && wTam < 6 )
			pForm[pCampo].value = wVr.substr( 0, wTam - 2  ) + '.' + wVr.substr( wTam - 2, wTam );
		if ( wTam >= 6 && wTam <= 9 )
			pForm[pCampo].value = wVr.substr( 0, 2 ) + '.' + wVr.substr( 2, 3 ) + '-' + wVr.substr( 5, 3 ); 
	}			
}



//email
function VerificaEmail(pcampo)  { 

	  pcampo.value = pcampo.value.toLowerCase();					
      	  parametro = pcampo.value;								
	  teste_parametro = "false"; 
	  tamanho_parametro = parametro.length;
	  aposicao = 0; //posicao @
	  pposicao = 0; //poiscao ponto
	  narrobas = 0; // numero de @
	  for (i = 0; i < tamanho_parametro; i++) { /*verifica se existe espaco em branco */
		   if (parametro.charAt(i) == "@") {
		  	     narrobas = narrobas + 1
				 aposicao = i;
		   }
		   if (parametro.charAt(i) == ".") {
		  	     
				 pposicao = i;
		   }
		   
	   }
	   if (aposicao > 0 && aposicao+1 < pposicao && narrobas<2){
     	   teste_parametro = "true"; 
	   }	   
      	  
	  for (i = 0; i < tamanho_parametro; i++) { /*verifica se existe espaco em branco */
		   if (parametro.charAt(i) == " ") {
		  	     teste_parametro = "false"; 
		   }
	   }
		
	   if (tamanho_parametro < 5) {
	   	  teste_parametro = "false"; /*tamanho minimo*/
	   }
	  
			
	   if (parametro.charAt(0) == " " || parametro.charAt(1) == " ") { /*Primeiros chars em branco */
			  teste_parametro = "false"; 
	   }
				
		
		if (teste_parametro == "false" && tamanho_parametro != 0 ) { /*Existe algum problema no preenchiento do nome */
			alert("E-mail inválido!");
			pcampo.focus();
			return false;
		} else {
			return true;
		}
}



function LTrim(str)
/***
        PURPOSE: Remove leading blanks from our string.
        IN: str - the string we want to LTrim

        RETVAL: An LTrimmed string!
***/
{
        var whitespace = new String(" \t\n\r");

        var s = new String(str);

        if (whitespace.indexOf(s.charAt(0)) != -1) {
            // We have a string with leading blank(s)...

            var j=0, i = s.length;

            // Iterate from the far left of string until we
            // don't have any more whitespace...
            while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
                j++;


            // Get the substring from the first non-whitespace
            // character to the end of the string...
            s = s.substring(j, i);
        }

        return s;
}

function RTrim(str){

        var whitespace = new String(" \t\n\r");

        var s = new String(str);

        if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
             var i = s.length - 1;   

            while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
                i--;

            s = s.substring(0, i+1);
        }

        return s;
}

function Trim(str)
{
        return RTrim(LTrim(str));
}


function toInteger(checkString)
{
 var newString = "";    
 var count = 0;         
    for (i = 0; i < checkString.length; i++) {
        ch = checkString.substring(i, i+1);
        if (ch >= "0" && ch <= "9") 
        {
            newString += ch;
        }
        else
        {
         if (ch == "-") newString += ch;
         if (ch == ".") newString += ch;
         if (ch == "/") newString += ch;
        }
    }
    
    return newString; //checkString;
}


function soNumero(texto)
{
	if (isNaN(texto.value)) 
	{
		texto.value="";
		return false;
	}else
		return true;
}



var keyCodigo = 0;
function soNumeroPress(evento){

	if (keyCodigo == 0){
		keyCodigo = evento.keyCode;
	}
	if ((keyCodigo == 8 || keyCodigo == 13 || keyCodigo == 9 || keyCodigo == 71 || keyCodigo == 46 || keyCodigo  == 37  || keyCodigo  == 39) || (keyCodigo >= 48 && keyCodigo <= 57) || (keyCodigo >= 96 && keyCodigo <= 105)) 
	{
		VerifiqueTAB=true; 

		return true;

	} else 
	{
		   if (detectar('B')=="NP")
			{
			 return true;
			}	
		   else	 	
			return false;
	}
}

function soNumeroDown(evento){

//alert(keyCodigo);
	keyCodigo = evento.keyCode;
	if ((keyCodigo == 8 || keyCodigo == 13 || keyCodigo == 9 || keyCodigo == 46) || (keyCodigo >= 48 && keyCodigo <= 57) || (keyCodigo >= 96 && keyCodigo <= 105) ){ 
		VerifiqueTAB=true; 
		
		return true;

	} else {
		   if (detectar('B')=="NP")
			{
			 return true;
			}	
		   else	 	
			return false;


	}

}


VerifiqueTAB=true;
function Mostra(quem, tammax) {
	if ( (quem.value.length == tammax) && (VerifiqueTAB) ) {
		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)].focus();
				VerifiqueTAB=false;
				break;
			}
		}
	}
}

//<!-- -->

function PararTAB() 
{ 
   VerifiqueTAB=false; 
} 

//<!-- -->

function ChecarTAB(evento) 
{ 
   var voltar=false;
   
   VerifiqueTAB=true; 
   keyCodigo = evento.keyCode;
   
   if ((keyCodigo == 8 || keyCodigo == 13 || keyCodigo == 9 || keyCodigo == 71 ) || (keyCodigo >= 48 && keyCodigo <= 57) || (keyCodigo >= 96 && keyCodigo <= 103) ) 
   {
	voltar=true;
    } 
    else 
    {
	   if (detectar('B')=="NP") voltar=true;
	   else	voltar=false;

    }
	return voltar;
} 

var detect = navigator.userAgent.toLowerCase();
var thestring;	
var versao = parseFloat(navigator.appVersion);

function detectar(tipo)
{ 
	var OS,browser,version,total;
	var retorno
	if (checkIt('konqueror'))
	{
		browser = "Konqueror";
		OS = "Linux";
	}
	else if (checkIt('omniweb')) browser = "OmniWeb"
	else if (checkIt('opera')) browser = "Opera"
	else if (checkIt('webtv')) browser = "WebTV";
	else if (checkIt('icab')) browser = "iCab"
	else if (checkIt('msie')) browser = "IE"
	else if (!checkIt('compatible'))
	{
		browser = "NP"
		version = detect.charAt(8);
	}
	else browser = "An unknown browser";

	
	
	if (!version) version = detect.charAt(place + thestring.length);
	
	if (!OS)
	{
		if (checkIt('linux')) OS = "Linux";
		else if (checkIt('x11')) OS = "Unix";
		else if (checkIt('mac')) OS = "Mac"
		else if (checkIt('win')) OS = "Windows"
		else OS = "an unknown operating system";
	}
	
	if (tipo=='B')
	  retorno = browser
 	else if (tipo=='O') retorno = OS

    return retorno 	
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

	function mOvr(src, cursor, color) {
		if (!src.contains(event.fromElement)) {
			src.style.cursor = cursor;
			src.bgColor = color;
			src.style.fontWeight = 'Normal';
		}
	}

	function mOut(src, cursor, color) {
		if (!src.contains(event.toElement))	{
			src.style.cursor = cursor;
			src.bgColor = color;
			src.style.fontWeight = 'Normal';
		}
	}
	  
	function Ativa_pg(pagina) {
		window.location.href=pagina;
	}

	function abre_copa(arq,alt,lag) {
		if(navigator.appName=="Microsoft Internet Explorer") {
			window.open(arq,'Condi','fullscreen=0,channelmode=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=' + lag + ',height=' + alt + ',top=10,left=10');
		} else {
			window.open(arq,'Condi','location=0,fullscreen=0,menubar=0,toolbar=0,status=0,screenX=10,screenY=10,resizable=0,width=' + lag + ',height=' + alt);
		}
	}


	function abre(arq,alt,lag) {
		if(navigator.appName=="Microsoft Internet Explorer") {
			window.open(arq,'Condi','fullscreen=0,channelmode=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=' + lag + ',height=' + alt + ',top=100,left=100');
		} else {
			window.open(arq,'Condi','location=0,fullscreen=0,menubar=0,toolbar=0,status=0,screenX=100,screenY=100,resizable=1,width=' + lag + ',height=' + alt);
		}
	}
	
	function abre_em(arq,alt,lag,esq,topo) {
		if(navigator.appName=="Microsoft Internet Explorer") {
			window.open(arq,'Condi','fullscreen=0,channelmode=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=' + lag + ',height=' + alt + ',left='+esq+',top='+topo);
		} else {
			window.open(arq,'Condi','location=0,fullscreen=0,menubar=0,toolbar=0,status=0,screenX=100,screenY=100,resizable=1,width=' + lag + ',height=' + alt);
		}
	}
	
	function abre_full(arq) {
		if(navigator.appName=="Microsoft Internet Explorer") {
			window.open(arq,'n_win');
		} else {
			window.open(arq,'n_win');
		}
	}
	function abre2(arq,alt,lag) {
		if(navigator.appName=="Microsoft Internet Explorer") {
			window.open(arq,'Condi','fullscreen=0,channelmode=0,toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,menubar=0,width=' + lag + ',height=' + alt + ',top=10,left=10');
		} else {
			window.open(arq,'Condi','location=0,fullscreen=0,menubar=0,toolbar=0,status=0,screenX=0,screenY=0,scrollbars=1,resizable=1,width=' + lag + ',height=' + alt);
		}
	}
	
	function abre_status(arq,alt,lag) {
		if(navigator.appName=="Microsoft Internet Explorer") {
			window.open(arq,'autod','fullscreen=0,channelmode=0,toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=0,menubar=0,width=' + lag + ',height=' + alt + ',top=10,left=10');
		} else {
			window.open(arq,'autod','location=0,fullscreen=0,menubar=0,toolbar=0,status=0,screenX=0,screenY=0,scrollbars=0,resizable=0,width=' + lag + ',height=' + alt);
		}
	}
	
	function openlink(URL,w,h)
	{
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
		settings = 'toolbar=0,scrollbars=0,location=0,status=0,menubar=0,resizable=0,width='+w+',height='+h+',left='+LeftPosition+',top='+TopPosition+''
		day = new Date();
		id = day.getTime();
		eval("page" + id + " = window.open(URL, '"+id+"',settings);");
	}


	function textCounter(field, countfield, maxlimit) {
	/*
	USE:
	<textarea name=message wrap=physical cols=28 rows=4 onKeyDown="textCounter(this.form.message,this.form.remLen,125);" onKeyUp="textCounter(this.form.message,this.form.remLen,125);"></textarea>
	*/
	if (field.value.length > maxlimit) 
		field.value = field.value.substring(0, maxlimit);
	else 
		countfield.value = maxlimit - field.value.length;
}



<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function close_window() {
    window.close();
}
function Data() {
	alert("Informe a data de nascimento do declarante, com dois algarismos para o dia, dois para o mês e quatro para o ano. Formato: dd/mm/aaaa");
}
//
function CPF() {
	alert("Informe o número de inscrição no Cadastro de Pessoas Físicas - CPF, inclusive os algarismos dos dígitos verificadores. Não são necessários os separadores do número.");
}


//Função para Cálculo do Digito do CPF/CNPJ

function DigitoCPFCNPJ(numCIC) {
var numDois = numCIC.substring(numCIC.length-2, numCIC.length);
var novoCIC = numCIC.substring(0, numCIC.length-2);
switch (numCIC.length){
case 11 :
numLim = 11;
break;
case 14 :
numLim = 9;
break;
default : return false;
}
var numSoma = 0;
var Fator = 1;
for (var i=novoCIC.length-1; i>=0 ; i--) {
Fator = Fator + 1;
if (Fator > numLim) {
Fator = 2;
}
numSoma = numSoma + (Fator * Number(novoCIC.substring(i, i+1)));
}
numSoma = numSoma/11;
var numResto = Math.round( 11 * (numSoma - Math.floor(numSoma)));
if (numResto > 1) {
numResto = 11 - numResto;
}
else {
numResto = 0;
}
//-- Primeiro dígito calculado. Fará parte do novo cálculo.

var numDigito = String(numResto);
novoCIC = novoCIC.concat(numResto);
//--
numSoma = 0;
Fator = 1;
for (var i=novoCIC.length-1; i>=0 ; i--) {
Fator = Fator + 1;
if (Fator > numLim) {
Fator = 2;
}
numSoma = numSoma + (Fator * Number(novoCIC.substring(i, i+1)));
}
numSoma = numSoma/11;
numResto = numResto = Math.round( 11 * (numSoma - Math.floor(numSoma)));
if (numResto > 1) {
numResto = 11 - numResto;
}
else {
numResto = 0;
}
//-- Segundo dígito calculado.
numDigito = numDigito.concat(numResto);
if (numDigito == numDois) {
return true;
}
else {
return false;
}
}




//-- Retorna uma string apenas com os números da string enviada
function ApenasNum(strParm) {
strParm = String(strParm);
var chrPrt = "0";
var strRet = "";
var j=0;
for (var i=0; i < strParm.length; i++) {
chrPrt = strParm.substring(i, i+1);
if ( chrPrt.match(/\d/) ) {
if (j==0) {
strRet = chrPrt;
j=1;
}

else {
strRet = strRet.concat(chrPrt);
}
}
}
return strRet;
}
//--< Fim da Função >--

//-- Somente aceita os caracteres válidos para CPF e CNPJ.
function PreencheCIC(objCIC) {
var chrP = objCIC.value.substring(objCIC.value.length-1, objCIC.value.length);

if ( !chrP.match(/[0-9]/) && !chrP.match(/[\/.-]/) ) {
objCIC.value = objCIC.value.substring(0, objCIC.value.length-1);
return false;
}
return true;
}
//--< Fim da Função >--

function FormataCIC (numCIC) {
numCIC = String(numCIC);
switch (numCIC.length){
case 11 :
return numCIC.substring(0,3) + "." + numCIC.substring(3,6) + "." + numCIC.substring(6,9) + "-" + numCIC.substring(9,11);
case 14 :
return numCIC.substring(0,2) + "." + numCIC.substring(2,5) + "." + numCIC.substring(5,8) + "/" + numCIC.substring(8,12) + "-" + numCIC.substring(12,14);
default : 
alert("Tamanho incorreto do CPF!");
return "";
}
}

//-- Remove os sinais, deixando apenas os números e reconstroi o CPF ou CNPJ, verificando a validade
//-- Recebe como parâmetros o número do CPF ou CNPJ, com ou sem sinais e o atualiza com sinais é validado.
function ConfereCIC(objCIC) {
if (objCIC.value == null) {
alert("Preenchimento obrigatório do CPF ou CNPJ");
return false;
}
var strCPFPat = /^\d{3}\.\d{3}\.\d{3}-\d{2}$/;
var strCNPJPat = /^\d{2}\.\d{3}\.\d{3}\/\d{4}-\d{2}$/;

numCPFCNPJ = ApenasNum(objCIC.value);

if (!DigitoCPFCNPJ(numCPFCNPJ)) {
alert("Atenção o Dígito verificador do CPF ou CNPJ é inválido!");
return false;
}

objCIC.value = FormataCIC(numCPFCNPJ);

if (objCIC.value.match(strCNPJPat)) {
return true;
}
else if (objCIC.value.match(strCPFPat)) {
return true;
}
else {
alert("Digite um CPF ou CNPJ válido!");
return false;
}
}
<!-- Begin
function check_date(field){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = "/";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(2,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(0,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
      DateField.value = day + seperator + month + seperator + year;
   }
   /* Error-message if err != 0 */
   else {
      alert("Data Incorreta!");
      DateField.select();
	  DateField.focus();
   }
}
//  End -->
//Fim da Função para Cálculo do Digito do CPF/CNPJ


function ajustar_data(input , evento)

{
         var BACKSPACE=  8; 
         var DEL=  46; 
         var FRENTE=  39; 
         var TRAS=  37; 
         var key; 
         var tecla; 
         var strValidos = "0123456789" ;
         var temp;
         tecla= (evento.keyCode ? evento.keyCode: evento.which ? evento.which : evento.charCode)
         //alert(tecla)
         if (( tecla == BACKSPACE )||(tecla == DEL)||(tecla == FRENTE)||(tecla == TRAS)) {
             return true; 
             }
         if ( tecla == 13 )     return false; 
         if ((tecla<48)||(tecla>57)){
		    return false;
		    }
         key = String.fromCharCode(tecla); 
         input.value = input.value+key;
         temp="";
         for (var i = 0; i<input.value.length;i++ )
             {
               if (temp.length==2) temp=temp+"/";
               if (temp.length==5) temp=temp+"/";
               if ( strValidos.indexOf( input.value.substr(i,1) ) != -1 ) {
                  temp=temp+input.value.substr(i,1);
               }   
             }
         input.value = temp.substr(0,10);
         return false;
	//
}
//-------------------------------
function ajustar_cpf(input , evento)
{
         var BACKSPACE=  8; 
         var DEL=  46; 
         var FRENTE=  39; 
         var TRAS=  37; 
         var key; 
         var tecla; 
         var strValidos = "0123456789" ;
         var temp;
         tecla= (evento.keyCode ? evento.keyCode: evento.which ? evento.which : evento.charCode)
         if (( tecla == BACKSPACE )||(tecla == DEL)||(tecla == FRENTE)||(tecla == TRAS)) {
             return true; 
             }
         if ( tecla == 13 )     return false; 
         if ((tecla<48)||(tecla>57)){
		    return false;
		    }

         key = String.fromCharCode(tecla); 
         input.value = input.value+key;
         temp="";
         for (var i = 0; i<input.value.length;i++ )
             {
               if (temp.length==3) temp=temp+".";
               if (temp.length==7) temp=temp+".";
               if (temp.length==11) temp=temp+"-";
               if ( strValidos.indexOf( input.value.substr(i,1) ) != -1 ) {
                  temp=temp+input.value.substr(i,1);
               }   
             }
         input.value = temp.substr(0,14);
         return false;
}

function ChamaAjuda(objeto)
{
	var strLink = objeto.href;
	if (document.declaracao.Exterior[0].checked)
	{
		strLink = strLink.replace("INSTRUCOES","INSTRUCOES_EX");
		objeto.href = strLink;
	}
	else
	{
		strLink = strLink.replace("INSTRUCOES_EX","INSTRUCOES");
		objeto.href = strLink;
	}
}

function validaCPF(rcpf1,rcpf2,c) {
  d1 = 0;
  for (i=0;i<9;i++) 
    d1 += rcpf1.charAt(i)*(10-i);
  d1 = 11 - (d1 % 11);
  if (d1>9) d1 = 0;
  
  if (rcpf2.charAt(0) != d1) 
    return false;
  
  d1 *= 2;
  for (i=0;i<9;i++) 
    d1 += rcpf1.charAt(i)*(11-i);
  d1 = 11 - (d1 % 11);
  if (d1>9) d1 = 0;
  
  if (rcpf2.charAt(1) != d1) 
    return false;
  return true;
}
//-------------------------------

