/*********************************************************************************
Funções de formatação de campos
Atualização: 20/04/2001

Para utilizar estas funções anexar o arquivo 'mascaras.js'
Colocar no cabeçalho da página:

<SCRIPT LANGUAGE="Javascript" SRC="../Objectstore/General/mascaras.js"></SCRIPT>
*********************************************************************************/


NS = (document.layers) ? true : false;

/****************************************************************
Bloqueia digitação de caracter não permitido pelo tipo
------------------------------------------------
Função:		validaCaracter(campo, evt, tipo)
------------------------------------------------

=> campo  =	Tipo: String
		Nome do campo atual
=> tipo   =	Tipo: String
		Tipo do valor no campo [D=Data; V=Valor ; H=Hora]
=> evt    =	[event]
		O evento disparado para chamar a função 
		(tecla pressionada, por exemplo)

<Chamar no ONKEYPRESS do campo testando seu retorno>

Exemplo:	return validaCaracter('fldCPF',event, "V");

****************************************************************/

function validaCaracter(evt, tipo)
{
   var key;
   var keychar;
   if (!NS)
        key = evt.keyCode;
   else 
   	key = evt.which;

   keychar = String.fromCharCode(key);
   if ((key==null) || (key==0) || (key==8) || (key==9)|| (key==27))// ||  (key==13))
      return true;
   else if (tipo=="V" && (("0123456789").indexOf(keychar) > -1))
	   return true;
   else if (tipo=="D" && (("/0123456789").indexOf(keychar) > -1))
	   return true;
   else if (tipo=="H" && ((":0123456789").indexOf(keychar) > -1))
	   return true;
   
   return false;      
}






/************************************************************
Saltar para o próximo campo
--------------------------------------------------------
Função:		saltaCampo (campo,prox,tammax,teclapres)
--------------------------------------------------------

=> campo =	Tipo: String
		Nome do campo atual
=> prox  =	Tipo: String 
		Nome do próximo campo
=> tammax =	Tipo: int
		Tamanho máximo do campo atual
=> teclapres =	[event]
		O evento disparado para chamar a função 
		(tecla pressionada, por exemplo)

<Chamar no ONKEYUP do campo>

Exemplo:	saltaCampo('fldatual','fldprox',5,event);

************************************************************/

function saltaCampo (campo,prox,tammax,teclapres)
{
	var tecla = teclapres.keyCode;
	var ssCampo = eval("Page."+campo);
	var ssProx = eval("Page."+prox);
	vr = ssCampo.value
 	tam = vr.length;	

 	if (tecla != 0 && tecla != 9 && tecla != 16)
	{
		if(tecla == 13)
			ssProx.focus();
		else if ( tam == tammax )	
		{
			ssProx.focus() ;	
		}
	}
}

/**********************************************************
Formatar a data digitada
--------------------------------------------
Função:		formataData(Campo,Prox,tammax,teclapres)
-------------------------------------------- 

=> Campo =	Tipo: String
		Nome do campo de data
=> prox  =	Tipo: String 
		Nome do próximo campo
=> tammax =	Tipo: int [8]
		Tamanho máximo permitido 
=> teclapres =	Tipo: event [event]
		O evento disparado para chamar a função 
		(tecla pressionada, por exemplo)

<Chamar no ONKEYPRESS do campo>

Exemplo:	formataData('fldData',event);

Obs.: A data digitada aparecerá no formato: dd/mm/aaaa

**********************************************************/


function formataData(Campo,teclapres) 
{
	if(NS)
		var tecla = teclapres.which;
	else
		var tecla = teclapres.keyCode;

	campo = eval("Page."+Campo)
	vr = campo.value;

	if(NS)
	{
		var ult = vr.substring(0,1);
		vr = vr.substring(1,vr.length)+ult;
		vr = filtraCampo(vr);
	}	
	if(!NS)
	{
		vr = vr.replace( ".", "" );
		vr = vr.replace( "/", "" );
		vr = vr.replace( "/", "" );
		vr = vr.replace( "/", "" );
	}

	tam = vr.length +1;
	if ( tecla != 9 && tecla != 8 )
	{
		if ( tam > 2 && tam < 5 )
			campo.value = vr.substr( 0, tam - 2  ) + '/' + vr.substr(tam - 2, tam );
		if ( tam >= 5 && tam <= 10 )
			campo.value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 3 ); 
		return false;
	}
} 


/**********************************************************
Formatar a hora digitada
--------------------------------------------
Função:		formataHora(Campo,teclapres) 
--------------------------------------------

=> Campo =	Tipo: String
		Nome do campo de hora
=> teclapres =	[event]
		O evento disparado para chamar a função 
		(tecla pressionada, por exemplo)

<Chamar no ONKEYPRESS do campo

Exemplo:	formataHora('fldHora',event);


Obs.: A hora digitada aparecerá no formato: hh:mm
**********************************************************/

function formataHora(Campo,teclapres) 
{
	var tecla = teclapres.keyCode;
	campo = eval("Page."+Campo)
	vr = campo.value;
	vr = vr.replace( ":", "" );
	vr = vr.replace( ":", "" );

	tam = vr.length + 1;

	if ( tecla != 9 && tecla != 8 )
	{
		if ( tam > 2 && tam < 5 )
			campo.value = vr.substr( 0, tam - 2  ) + ':' + vr.substr(tam - 2, tam );
	}
}

/*
--------------------------------------------
Função:		formataDateTime(Campo,teclapres) 
--------------------------------------------

=> Campo =	Tipo: String
		Nome do campo de hora
=> teclapres =	[event]
		O evento disparado para chamar a função 
		(tecla pressionada, por exemplo)

<Chamar no ONKEYPRESS do campo

Exemplo:	formataDateTime('fldDateTime',event);


Obs.: A hora digitada aparecerá no formato: hh:mm
*********************************************************

function formataDateTime(Campo,teclapres) 
{
	campo = eval("Page."+Campo)
	var tecla = teclapres.keyCode;
	campo = eval("Page."+Campo)
	vr = campo.value;
	vr = vr.replace( ":", "" );
	vr = vr.replace( ":", "" );
	tam = vr.length + 1;
	if(!formataData(Campo,teclapres))
	{
		if ( tecla != 9 && tecla != 8 )
		{
			if ( tam > 13 && tam < 16 )
				campo.value = vr.substr( 0, tam - 13  ) + ':' + vr.substr(tam - 13, tam );
		}
	}
}
*/




/*****************************************************************
Formatar o CPF digitado
--------------------------------------------------
Função:		formataCpf(Campo,tammax,teclapres)
-------------------------------------------------- 

=> Campo =	Tipo: String
		Nome do campo atual
=> tammax =	Tipo: int [14]
		Tamanho máximo do campo atual
=> teclapres =	[event]
		O evento disparado para chamar a função 
		(tecla pressionada, por exemplo)

<Chamar no ONKEYPRESS do campo>

Exemplo:	formataCpf('fldCPF',14,event);

Obs: O CPF digitado aparecerá no seguinte formato: xxx.xxx.xxx-xx

****************************************************************/
function formataCPF(Campo,tammax,teclapres) 
{
	if(NS)
		var tecla = teclapres.which;
	else
		var tecla = teclapres.keyCode;

	campo = eval("Page."+Campo)
	vr = campo.value;

	if(NS)
	{
		var ult = vr.substring(0,1);
		vr = vr.substring(1,vr.length)+ult;
		vr = filtraCampo(vr);

	}	
	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( "-", "" );
		vr = vr.replace( "-", "" );
		vr = vr.replace( "-", "" );
		vr = vr.replace( "-", "" );
		vr = vr.replace( "-", "" );
	}

	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )
	{
		if ( tam <= 2 )
		{ 
	 		campo.value = vr ; 
		}
	 	if ( (tam > 2) && (tam <= 5) )
		{
	 		campo.value = vr.substr(0,tam - 2) + '-' + vr.substr( tam - 2, tam ); 		}
	 	if ( (tam >= 6) && (tam <= 8) )
		{
	 		campo.value = 	vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + 					'-' + vr.substr( tam - 2, tam ) ; 
		}
	 	if ( (tam >= 9) && (tam <= 11) )
		{
	 		campo.value = 	vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + 					'.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, 					tam ) ; 
		}
	 	if ( (tam >= 12) && (tam <= 14) )
		{
	 		campo.value = 	vr.substr(0,tam - 11) + '.' + vr.substr( tam - 11, 3 ) + 					'.' + vr.substr(tam - 8,3) + '.' + vr.substr(tam - 5,3) + 					'-' + vr.substr( tam - 2, tam ) ; 		}
	 	if ( (tam >= 15) && (tam <= 17) )
		{
	 		campo.value = 	vr.substr(0,tam - 14) + '.' + vr.substr( tam - 14, 3 ) + 					'.' + vr.substr(tam-11,3) + '.' + vr.substr(tam-8,3)+ 															'.' + vr.substr(tam-5,3) + '-' + vr.substr(tam-2,tam) ;
		}
	}		
}

/*****************************************************************
Formatar o CNPJ digitado
--------------------------------------------------
Função:		formataCNPJ(Campo,tammax,teclapres)
-------------------------------------------------- 

=> Campo =	Tipo: String
		Nome do campo atual
=> tammax =	Tipo: int [18]
		Tamanho máximo do campo atual
=> teclapres =	[event]
		O evento disparado para chamar a função 
		(tecla pressionada, por exemplo)

<Chamar no ONKEYPRESS do campo>

Exemplo:	formataCNJP('fldNPJ',18,event);

Obs: O CNPJ digitado aparecerá no seguinte formato: xx.xxx.xxx/xxxx-xx

****************************************************************/
function formataCNPJ(Campo,tammax,teclapres) 
{

	if(NS)
		var tecla = teclapres.which;
	else
		var tecla = teclapres.keyCode;

	var campo = eval("Page."+Campo)
	vr = campo.value;

	if(NS)
	{
		var ult = vr.substring(0,1);
		vr = vr.substring(1,vr.length)+ult;
		vr = filtraCampo(vr);

	}	
	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( ".", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( ".", "" );
		vr = vr.replace( "-", "" );
		vr = vr.replace( "-", "" );
		vr = vr.replace( "-", "" );
		vr = vr.replace( "-", "" );
		vr = vr.replace( "-", "" );
	}

	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
	 		campo.value = vr ; }
	 	if ( (tam > 2) && (tam <= 6) ){
	 		campo.value = vr.substr( 0, tam - 2 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 7) && (tam <= 9) ){
	 		campo.value = vr.substr( 0, tam - 6 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 10) && (tam <= 12) ){
	 		campo.value = vr.substr( 0, tam - 9 ) + '.' + vr.substr( tam - 9, 3 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 13) && (tam <= 14) ){
	 		campo.value = vr.substr( 0, tam - 12 ) + '.' + vr.substr( tam - 12, 3 ) + '.' + vr.substr( tam - 9, 3 ) + '/' + vr.substr( tam - 6, 4 ) + '-' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 15) && (tam <= 17) ){
	 		campo.value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + '-' + vr.substr( tam - 2, tam ) ;}
	}		
}



/***************************************************************************
 Validação de vagas - Específico para SigaeExecutora
----------------------------------------------------------------------------
Função:		validaVagas(Radio1, pos, campoPrin, Campo1, Campo2, Campo3)
---------------------------------------------------------------------------- 

=> Radio1 =	Tipo: String
		Nome radio button a ser validado
=> pos 	=	Tipo: int
		Posição do radio button na página
=> campoPrin =	Tipo: String
		Nome do campo que contém os valores que serão copiados
=> Campo1    =  Tipo: String
		Nome do primeiro campo que receberá o valor de campoPrin
=> Campo2    =  Tipo: String
		Nome do segundo campo que receberá o valor de campoPrin
=> Campo2    =  Tipo: String
		Nome do terceiro campo que receberá o valor de campoPrin

<Chamar no ONBLUR do campo>
<Chamar no ONCLICK dos radios>

Exemplo:	validaVaga('rb1',1,'fldPrin','fldCampo1','fldCampo2','fldCampo3');

*************************************************************************/

function validaVagas(Radio1, pos, campoPrin, Campo1, Campo2, Campo3)
{
	var rad1 = eval("Page."+Radio1);
	var campoprin = eval("Page."+campoPrin);
	var campo1 = eval ("Page."+Campo1);
	var campo2 = eval ("Page."+Campo2);
	var campo3 = eval ("Page."+Campo3);
	
	if(rad1[pos].checked)
	{
		campo1.value = campoprin.value;
		campo2.value = campoprin.value;
		campo3.value = campoprin.value;
		campo1.disabled = true;
		campo2.disabled = true;
		campo3.disabled = true;
		
	}
	else 
	{
		campo1.value = "";
		campo2.value = "";
		campo3.value = "";
		campo1.disabled = false;
		campo2.disabled = false;
		campo3.disabled = false;
	}

}


/*****************************************************************
Função para montar um campo CPF para gravação no banco
*****************************************************************/
function montaCPF(CampoVal, CampoGrav, tam)
{
	var campoval = eval("Page."+CampoVal);
	var campograv = eval("Page."+CampoGrav);
	var valcampo = campoval.value;
	var aux1, aux2, aux3;
	var index;
	tamval = valcampo.length

	if(tamval == tam)
	{
		index = valcampo.indexOf(".");
		aux1 = valcampo.substring(0,index)+valcampo.substring(index+1);
		index = aux1.indexOf(".");
		aux2 = aux1.substring(0,index)+aux1.substring(index+1); 					
		index = aux2.indexOf("-");
		aux3 = aux2.substring(0,index)+aux2.substring(index+1); 
		campograv.value=aux3;
	}	
	else
		campograv.value = "";				
}

/*****************************************************************
Função para montar um campo CNPJ para gravação no banco
*****************************************************************/
function montaCNPJ(CampoVal, CampoGrav, tam)
{
	var campoval = eval("Page."+CampoVal);
	var campograv = eval("Page."+CampoGrav);
	var valcampo = campoval.value;
	var aux1, aux2, aux3, aux4;
	var index;
	tamval = valcampo.length

	if(tamval == tam)
	{
		index = valcampo.indexOf(".");
		aux1 = valcampo.substring(0,index)+valcampo.substring(index+1);
		index = aux1.indexOf(".");
		aux2 = aux1.substring(0,index)+aux1.substring(index+1); 					
		index = aux2.indexOf("/");
		aux3 = aux2.substring(0,index)+aux2.substring(index+1); 
		index = aux3.indexOf("-");
		aux4 = aux3.substring(0,index)+aux3.substring(index+1); 
		campograv.value=aux4;
	}		
	else
		campograv.value = "";			
}


/*****************************************************************
Função para mostrar CNPJ formatado
*****************************************************************/
function mostraCNPJ(CNPJ)
{
	var cnpj  = eval("Page."+CNPJ);

	var aux1;
	var aux2;
	var aux3;
	var aux4;
	var aux5;
	var valcnpj = cnpj.value;
	
	aux5 = valcnpj.substring(12,valcnpj.length);
	aux4 = valcnpj.substring(8,12);
	aux3 = valcnpj.substring(5,8);
	aux2 = valcnpj.substring(2,5);
	aux1 = valcnpj.substring(0,2);

	valcnpj = aux1+"."+aux2+"."+aux3+"\/"+aux4+"-"+aux5;

	return valcnpj;

}

/***********************************************************************************
Filtra dados do campo - Utilizado apenas pelo Netscape
***********************************************************************************/
function filtraCampo(valor){
	var s = "";
	var cp = "";
	vr = valor;
	tam = vr.length;

	for (i = 0; i < tam ; i++) 
	{  
		if (vr.substring(i,i + 1) != "/" && vr.substring(i,i + 1) != "-" && 			vr.substring(i,i + 1) != "."  && vr.substring(i,i + 1) != "," )
		{
		 	s = s + vr.substring(i,i + 1);
		}
	}
	return s
}

/*******************************************************************
Não estão totalmente testadas
********************************************************************


function FormataValor(campo,tammax,teclapres) 
{
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( ".", "" );
	tam = vr.length;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
	 		document.form[campo].value = vr ; }
	 	if ( (tam > 2) && (tam <= 5) ){
	 		document.form[campo].value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 6) && (tam <= 8) ){
	 		document.form[campo].value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 9) && (tam <= 11) ){
	 		document.form[campo].value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 12) && (tam <= 14) ){
	 		document.form[campo].value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 15) && (tam <= 17) ){
	 		document.form[campo].value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ;}
	}		
	
}

function FormataDado(campo,tammax,pos,teclapres)
{
	var tecla = teclapres.keyCode;
	vr = document.form[campo].value;
	vr = vr.replace( "-", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length ;

	if (tam < tammax && tecla != 8)
	{ 
		tam = vr.length + 1 ; 
	}

	if (tecla == 8 )
	{ 
		tam = tam - 1 ; 
	}
			
	if 	(tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 
		&& tecla <= 105)
	{
		if ( tam <= 2 )
		{
	 		document.form[campo].value = vr ;
		}
		if ( tam > pos && tam <= tammax )
		{
			document.form[campo].value = vr.substr( 0, tam - pos ) + '-' + 
			vr.substr( tam - pos, tam );}
		}
}

function msgHelp(txt)
{
	if(!NS)
		help_IE.innerText = txt;
	else
	{
		document.helpNS1.document.helpNS2.document.write(txt)
		document.helpNS1.document.helpNS2.document.close()
//		thelength=document.cmarquee01.document.cmarquee02.document.width
	}

}
*************************************************************************************/

function inibeEnter(evt)
{
   var key;
   var keychar;
   if (!NS)
        key = evt.keyCode;
   else 
   	key = evt.which;

   keychar = String.fromCharCode(key);
   if ((key!=13))
      return true;
   
   return false;      
}

 function alteraCaracter(Campo)
 {   
   var campo;	   	
   var campoVal;
   
   if(eval("Campo"))	
	   campo = Campo;
   else	
	   campo = event.srcElement		
   if(campo==null)
	return;	

   campoVal = campo.value

   campoVal = retiraEspacos(campoVal);
   var ind;

   var Posic, Carac;
   var TempLog = ""; 
   for (var i=0; i < campoVal.length; i++)
   {
	Carac = campoVal.charAt (i);
	ind = Carac.charCodeAt();
	Posic = getTraducao(ind)
	   if (Posic > -1)   
		TempLog += String.fromCharCode (Posic);
	   else  
		TempLog += campoVal.charAt (i);	  	   
	if(ind == 32)
	{
		do
		{
			i++;
			Carac = campoVal.charAt (i);
			ind = Carac.charCodeAt();
		}
		while (i < campoVal.length && ind == 32 )
		i--;
	}		
   }
      campo.value = TempLog;

}

function retiraEspacos(campoVal)
{
	var i = 0;
	var strAux = campoVal;
	Carac = campoVal.charAt(i);
	ind = Carac.charCodeAt();
	if(ind == 32)
	{
		do
		{
			i++;
			Carac = campoVal.charAt (i);
			ind = Carac.charCodeAt();
		}
		while (i < campoVal.length && ind == 32 )
		strAux = campoVal.substring(i,campoVal.length)
	}		
	i = strAux.length
	Carac = strAux.charAt(i-1);
	ind = Carac.charCodeAt();
	if(ind == 32)
	{
		do
		{
			i--;
			Carac = strAux.charAt (i);
			ind = Carac.charCodeAt();
		}
		while (i > 0 && ind == 32)
		strAux = strAux.substring(0,i+1)
	}		
	return strAux;
}

function configCampos()
{
	var qtde = document.forms[0].length;
	var campo;
	for(i = 0; i < qtde; i++)
	{
		campo = document.forms[0].elements[i]
		if(campo.type == "text")
		{
			campo.onblur = alteraCaracter;
		}
	}	
}


function itemTraducao(orig, trad)
{
	this.original = orig;
	this.traducao = trad;
}

function getTraducao(orig)
{
	var i = 0;
	var tradOK = false;
	while(i<Traducao.length && !tradOK)
	{
		if(Traducao[i].original == orig)
		{
			return Traducao[i].traducao
			tradOK = true
		}
		i++;
	}
	return -1;
}


var Traducao = new Array();
Traducao[0] = new itemTraducao(225,65);
Traducao[1] = new itemTraducao(224,65);
Traducao[2] = new itemTraducao(228,65);
Traducao[3] = new itemTraducao(226,65);
Traducao[4] = new itemTraducao(227,65);
Traducao[5] = new itemTraducao(193,65);
Traducao[6] = new itemTraducao(192,65);
Traducao[7] = new itemTraducao(195,65);
Traducao[8] = new itemTraducao(194,65);
Traducao[9] = new itemTraducao(233,69);
Traducao[10] = new itemTraducao(234,69);
Traducao[11] = new itemTraducao(201,69);
Traducao[12] = new itemTraducao(202,69);
Traducao[13] = new itemTraducao(204,73);
Traducao[14] = new itemTraducao(205,73);
Traducao[15] = new itemTraducao(237,73);
Traducao[16] = new itemTraducao(243,79);
Traducao[17] = new itemTraducao(245,79);
Traducao[18] = new itemTraducao(244,79);
Traducao[19] = new itemTraducao(211,79);
Traducao[20] = new itemTraducao(212,79);
Traducao[21] = new itemTraducao(213,79);
Traducao[22] = new itemTraducao(250,85);
Traducao[23] = new itemTraducao(252,85);
Traducao[24] = new itemTraducao(218,85);
Traducao[25] = new itemTraducao(220,85);
Traducao[26] = new itemTraducao(231,67);
Traducao[27] = new itemTraducao(199,67);
Traducao[28] = new itemTraducao(97,65);
Traducao[29] = new itemTraducao(98,66);
Traducao[30] = new itemTraducao(99,67);
Traducao[31] = new itemTraducao(100,68);
Traducao[32] = new itemTraducao(101,69);
Traducao[33] = new itemTraducao(102,70);
Traducao[34] = new itemTraducao(103,71);
Traducao[35] = new itemTraducao(104,72);
Traducao[36] = new itemTraducao(105,73);
Traducao[37] = new itemTraducao(106,74);
Traducao[38] = new itemTraducao(107,75);
Traducao[39] = new itemTraducao(108,76);
Traducao[40] = new itemTraducao(109,77);
Traducao[41] = new itemTraducao(110,78);
Traducao[42] = new itemTraducao(111,79);
Traducao[43] = new itemTraducao(112,80);
Traducao[44] = new itemTraducao(113,81);
Traducao[45] = new itemTraducao(114,82);
Traducao[46] = new itemTraducao(115,83);
Traducao[47] = new itemTraducao(116,84);
Traducao[48] = new itemTraducao(117,85);
Traducao[49] = new itemTraducao(118,86);
Traducao[50] = new itemTraducao(119,87);
Traducao[51] = new itemTraducao(120,88);
Traducao[52] = new itemTraducao(121,89);
Traducao[53] = new itemTraducao(122,90);

// var Acentos = "áàãâÁÀÃÂéêÉÊíÍóõôÓÔÕúüÚÜçÇabcdefghijklmnopqrstuvxwyz";


/**************************************************************************************
FUNÇÃO PARA ABERTURA DE JANELA POPUP GENÉRICA
**************************************************************************************/

function abrirJanela(URL, tipo, w, h)
{
	var data = new Date()
	var win;
	tipo = new String(tipo);
	if (tipo == "P" && isNaN(w) && isNaN(h))
		win = window.open(URL,"win"+data.getSeconds(),"scrollbars=yes");
	else if (tipo == "IMP")
		win = window.open(URL,"win"+data.getSeconds(),"scrollbars=yes, menubar=yes");
	else if (tipo == "P")
		win = window.open(URL,"win"+data.getSeconds(),"scrollbars=yes, width="+w+", height="+h);
	else if (tipo == "N" || tipo == "undefined")
		win = window.open(URL,"win"+data.getSeconds(),"");
	win.moveTo(0,0);
	if(isNaN(w) && isNaN(h))
	{
		if (document.all) 
		{
			win.resizeTo(screen.availWidth,screen.availHeight);
		}
		else if (document.layers||document.getElementById) 
		{
			if (win.outerHeight<screen.availHeight||win.outerWidth<screen.availWidth)
			{
				win.outerHeight = screen.availHeight;
				win.outerWidth = screen.availWidth;
			}
		}
	}	
}

/**************************************************************************************
FUNÇÃO PARA ACERTO DE CARACTERES DA PESQUISA 
**************************************************************************************/

function acertarArgPesquisa(argumento)
{
	argumento = replaceArgumento("\"", argumento);
	argumento = replaceArgumento("\'", argumento);
	argumento = replaceArgumento("+", argumento);
	argumento = substringArgumento("\\-", argumento,2);
	argumento = substringArgumento("-\\", argumento,2);
	argumento = substringArgumento("&&", argumento,1);
	argumento = substringArgumento("||", argumento,1);
	argumento = substringArgumento("|%", argumento,2);
	argumento = substringArgumento("&%", argumento,2);
	argumento = substringArgumento("&|", argumento,2);
	argumento = substringArgumento("& &", argumento,2);
	argumento = substringArgumento("| |", argumento,2);
	argumento = substringArgumento("& %", argumento,2);
	argumento = substringArgumento("& |", argumento,2);
	argumento = substringArgumento("| %", argumento,2);
	argumento = substringArgumento("| &", argumento,2);
	argumento = substringArgumento("% &", argumento,2);
	argumento = substringArgumento("% |", argumento,2);
	argumento = substringArgumento("%|", argumento,2);
	argumento = substringArgumento("%&", argumento,2);
	argumento = substringArgumento("%%", argumento,1);
	argumento = substringArgumento("% %", argumento,1);


	argumento = substringArgumento("&", argumento,1);
	argumento = substringArgumento("|", argumento,1);
	argumento = substringArgumento("%", argumento,1);

	if(argumento.indexOf("&") == 0 || argumento.indexOf("&") == argumento.length)
		argumento = replaceArgumento("&", argumento);
	if(argumento.indexOf("|") == 0 || argumento.indexOf("|") == argumento.length)
		argumento = replaceArgumento("|", argumento);
	return argumento;
}

function replaceArgumento(caracter, argumento)
{
	var pos = argumento.indexOf(caracter);
	if(pos >= 0)
	{	
		do
		{	
			argumento = argumento.replace(caracter,"");
			pos = argumento.indexOf(caracter);
		}while(pos >= 0);
	}
	return argumento;
}

function substringArgumento(subs, argumento, tam)
{
	var pos = argumento.indexOf(subs);
	if(pos >= 0)
	{
		do
		{	
			argumento = argumento.substring(0, pos) + argumento.substring(pos+tam, argumento.length);
			pos = pos = argumento.indexOf(subs);
		}while(pos >= 0);
	}

	return argumento;
}
