//--------------------------------
function fnc_MouseOver(Celula,Cor) {Celula.style.cursor = "hand"; Celula.bgColor = Cor; }
//--------------------------------

//---------------------------
function fnc_MouseOut(Celula) {Celula.style.cursor = "default"; Celula.bgColor = ""; }
//---------------------------

//--------------------------------
function fnc_MouseOver02(Celula) {Celula.style.cursor = "hand"; Celula.className = "CelulaSubTituloOver"; }
//--------------------------------

//---------------------------
function fnc_MouseOut02(Celula) {Celula.style.cursor = "default"; Celula.className = "CelulaSubTitulo"; }
//---------------------------

//----------------------------
function fnc_MouseOver03(Celula) {Celula.style.cursor = "hand";Celula.className="Label09";}
//----------------------------

//---------------------------
function fnc_MouseOut03(Celula) {Celula.style.cursor = "default";Celula.className="Label08";}
//---------------------------

//--------------------------
function fnc_OnClick(Celula) {Celula.children.tags("A")[0].click(); }
//--------------------------

//-------------------------------------
function fnc_DataInvalida(DataDigitada)
//-------------------------------------
 {
 Dia = DataDigitada.substr(0,2); Mes = DataDigitada.substr(3,2); Ano = DataDigitada.substr(6,4);
 
 DataNaoValida = isNaN(parseInt(Dia)) || isNaN(parseInt(Mes)) || isNaN(parseInt(Ano));
 
 DataNaoValida = DataNaoValida || (isNaN(parseInt(Dia.substr(1,1))) && Dia.substr(1,1) != "");
 DataNaoValida = DataNaoValida || (isNaN(parseInt(Mes.substr(1,1))) && Mes.substr(1,1) != "");
 DataNaoValida = DataNaoValida || (isNaN(parseInt(Ano.substr(1,1))) && Ano.substr(1,1) != "");
 DataNaoValida = DataNaoValida || (isNaN(parseInt(Ano.substr(2,1))) && Ano.substr(2,1) != "");
 DataNaoValida = DataNaoValida || (isNaN(parseInt(Ano.substr(3,1))) && Ano.substr(3,1) != "");
 
 DataNaoValida = DataNaoValida || (Dia > 31 || Mes > 12 || Ano < 1900);
 DataNaoValida = DataNaoValida || (Dia > 30 && (Mes == '04' || Mes == '06' || Mes == '09' || Mes == '11'));
 DataNaoValida = DataNaoValida || (Dia > 28 && Mes == 02 && Ano % 4 != 0);
 DataNaoValida = DataNaoValida || (Dia > 29 && Mes == 02 && Ano % 4 == 0);
 
 return DataNaoValida;
 }

//-------------------------------
function fnc_DataAtual()
//-------------------------------
 {
 var Data = new Date();
  
 DataAA = Data.getFullYear();
 DataMM = Data.getMonth() + 1;
 DataDD = Data.getDate();

 DataAA = DataAA.toString();
 DataMM = DataMM.toString();
 DataDD = DataDD.toString();

 if (DataDD.length == 1) {DataDD = "0" + DataDD;}
 if (DataMM.length == 1) {DataMM = "0" + DataMM;}

 Data = DataDD + "/" + DataMM + "/" + DataAA;

 return Data;

 }

//-------------------------------
function fnc_DataMaiorQueDataAtual(Data1,Data2)
//-------------------------------
 {
 // OBS.: Data1 deve ser maior que Data2
 Data1AA = Data1.substr(6,4);
 Data1MM = Data1.substr(3,2);
 Data1DD = Data1.substr(0,2);

 Data2AA = Data2.substr(6,4);   
 Data2MM = Data2.substr(3,2);   
 Data2DD = Data2.substr(0,2);   

 Data1 = Data1AA + Data1MM + Data1DD;
 Data2 = Data2AA + Data2MM + Data2DD;
  
 if (Data1 <= Data2)
	{
	return true;
	}

 }

//-----------------------
function fnc_Arred(valor)
//-----------------------
 {
 var aux = valor.toString();

 if (aux.indexOf(".") > -1)
  {
  if ((aux.length - (aux.indexOf(".") + 1)) >= 3)
   {
   if (aux.substr(aux.indexOf(".") + 3,1) >= 5)
	{
	valor = valor + 0.01;
	aux = valor.toString();
	aux = aux.substring(0,aux.indexOf(".") + 3);
	}
   else
	{
	aux = aux.substring(0,aux.indexOf(".") + 3);
	}
   }
  }

 return aux;
 }

//----------------------------
function fnc_FormataMoeda(Campo)
//----------------------------
 {
 var Valor, ValorDigitado, Tamanho;
	 Valor = Campo.value;
	 Tamanho = Campo.size;

   //Verifica o uso da tecla TAB
   if (event.keyCode == 9 || event.keyCode == 16)
	 {
	 Campo.focus();
	 }
   else
	 {

	 // Limpa zeros à esquerda
	 if (Valor.length < 6)
		{
		ValorDigitado = Valor.replace("0,00","").replace("0,0","").replace("0,","").replace(",","").replace(".","");
		}
	 else
		{
		ValorDigitado = Valor.replace(",","").replace(".","").replace(".","").replace(".","");
		}

	 // Verifica se não foram digitados caracteres alfabéticos
	 if (isNaN(ValorDigitado) || ValorDigitado.indexOf(".") != -1 || ValorDigitado.indexOf(" ") != -1)
		{
		Valor = Valor.substr(0,Valor.length-1);
		}
	 else
		{

		 // Exibe zeros à esquerda
		 if (ValorDigitado.length == 0)
			{
			Valor = "000";
			}
		 else if (ValorDigitado.length == 1)
			{
			Valor = "00" + ValorDigitado;
			}
		 else if (ValorDigitado.length == 2)
			{
			Valor = "0" + ValorDigitado;
			}
		 else
			{
			Valor = ValorDigitado;
			}
		 var i;

		 // Verifica a quantidade de dígitos
		 if (Valor.length >= 6 && Valor.length <= 8)
			{
			Valor = Valor.substr(0,Valor.length-5) + "." + Valor.substr(Valor.length-5,3) + "," + Valor.substr(Valor.length-2,2);
			}
		 else if (Valor.length >= 9 && Valor.length <= 11)
			{
			Valor = Valor.substr(0,Valor.length-8) + "." + Valor.substr(Valor.length-8,3) + "." + Valor.substr(Valor.length-5,3) + "," + Valor.substr(Valor.length-2,2);
			}
		 else if (Valor.length >= 12)
			{
			Valor = Valor.substr(0,Valor.length-11) + "." + Valor.substr(Valor.length-11,3) + "." + Valor.substr(Valor.length-8,3) + "." + Valor.substr(Valor.length-5,3) + "," + Valor.substr(Valor.length-2,2);
			}
		 else
			{
			Valor = Valor.substr(0,Valor.length-2) + "," + Valor.substr(Valor.length-2,2);
			}
		}
	 if (Valor == "0,00") {Valor = "";}
		 
	 Campo.value = Valor;
	 }

}

//-------------------------
function fnc_LimitaTexto(Campo,TamanhoMaximo)
//-------------------------
 {
 if (Campo.value.length >= TamanhoMaximo)
   {
   Campo.value = Campo.value.substr(0,TamanhoMaximo);
   }
 }

//-------------------------
function fnc_ZerosADireita(valor)
//-------------------------
 {
 if ( valor.indexOf(",") == -1 )
  {
  valor = valor + ",00";
  }
 else if ( valor.length - valor.indexOf(",") == 2 )
  {
  valor = valor + "0";
  }

 return valor;
 }

//----------------------------
function fnc_TotalDeHoras(HoraInicial,HoraFinal)
//----------------------------
 {
 if (HoraInicial == "99:99" || HoraFinal == "99:99")
	{
	document.write("00:00");
	return("");
	}

 var HI = HoraInicial.substr( 0, 2);
 var MI = HoraInicial.substr( 3, 2);
 var HF = HoraFinal.substr( 0, 2);
 var MF = HoraFinal.substr( 3, 2);
 var TotalHoras = 0;
 var TotalMinutos = 0;
 
 TotalHoras = HF - HI;

 if (MI > MF)
	{
	TotalMinutos = 60 - MI;
	TotalMinutos += Number(MF);
	TotalHoras -= 1;
	}
 else
	{
	TotalMinutos = MF - MI;
	}
 
 if (String(TotalHoras).length == 1)
	{
	TotalHoras = "0" + TotalHoras;
	}
 if (String(TotalMinutos).length == 1)
	{
	TotalMinutos = "0" + TotalMinutos;
	}

 document.write(TotalHoras + ":" + TotalMinutos);

 }

//-----------------------------------------
function fnc_Maiusculo(campo)
//-----------------------------------------
 {
 campo.value = campo.value.toUpperCase();
 }

//-----------------------------------------
function fnc_Minusculo(campo)
//-----------------------------------------
 {
 campo.value = campo.value.toLowerCase();
 }

//-------------------------
function fnc_FormataSP(campo)
//-------------------------
 {
 if (campo.value.substr(campo.value.length-1,1) ==  "/")
  {
  campo.value = campo.value.substr(0,campo.value.length-1);
  }
 else if (campo.value.length == 4 && event.keyCode != 8)
  {
  campo.value = campo.value + '/';
  }
 else if (campo.value.length == 5 && campo.value.substr(4,1) == '/' && event.keyCode == 8)
  {
  campo.value = campo.value.substr(0,4);
  }
 else if (campo.value.length >= 5 && campo.value.indexOf("/") == -1)
  {
  campo.value = campo.value.substr(0,4) + '/' + campo.value.substr(4,2);
  }

 }

//-------------------------
function fnc_FormataAtivo(campo)
//-------------------------
{
if (campo.value == '0-0' || campo.value == '')
 {
 campo.value = '';
 }
else
 {
 var Valor   = campo.value;
 var Tamanho = campo.value.length;
 var ZerosAEsquerda_Numero = '';
 var ZerosAEsquerda_SubNumero = '';
 var PosHifen,AtivoNumero,AtivoSubNumero,i;

 if (Valor.indexOf('-') == -1) {Valor = Valor + '-0';}

 PosHifen = Valor.indexOf('-');

 AtivoNumero	= Valor.substr(0,PosHifen);
 AtivoSubNumero = Valor.substr(PosHifen+1,Tamanho-(PosHifen+1));

 if (AtivoNumero.length > 6 || AtivoSubNumero.length > 3)
  {
  alert('Numero de ativo inválido.');
  campo.value = '';
  campo.focus();
  }
 else
  {
  if (AtivoSubNumero == '') {AtivoSubNumero = '0';}

  // Zeros à esquerda do Numero //
  for (i=1; i<=(6-AtivoNumero.length); i++)
   {
   ZerosAEsquerda_Numero = ZerosAEsquerda_Numero + '0';
   }

  // Zeros à esquerda do SubNumero //
  for (i=1; i<=(3-AtivoSubNumero.length); i++)
   {
   ZerosAEsquerda_SubNumero = ZerosAEsquerda_SubNumero + '0';
   }
  
  campo.value = ZerosAEsquerda_Numero + AtivoNumero + '-' + ZerosAEsquerda_SubNumero + AtivoSubNumero;
  }
 }

}

//-------------------------
function fnc_FormataData(campo)
//-------------------------
/*
* CÓDIGOS ASCII DAS TECLAS EM USO *
08 ==> BACKSPACE 
09 ==> TAB
16 ==> SHIFT
35 ==> END
36 ==> HOME
37 ==> CURSOR ESQ.
39 ==> CURSOR DIR.
46 ==> DELETE 
*/
 {
 if (event.keyCode != 8 && event.keyCode != 9 && event.keyCode != 16 && event.keyCode != 35 && event.keyCode != 36 && event.keyCode != 37 && event.keyCode != 39 && event.keyCode != 46)
  {
  if (campo.value.substr(campo.value.length-1,1) ==  "/" && campo.value.length != 3 && campo.value.length != 6)
   {
   campo.value = campo.value.substr(0,campo.value.length-1);
   }
  else if ((campo.value.length == 2 || campo.value.length == 5) && event.keyCode != 8)
   {
   campo.value = campo.value + '/';
   }
  else
   {
   if (campo.value.length >= 3 && campo.value.length <= 3 && campo.value.indexOf("/") == -1)
    {
    campo.value = campo.value.substr(0,2) + '/' + campo.value.substr(2,1);
    }
   else if (campo.value.length >= 6)
    {
    campo.value = campo.value.replace(/\//g,'');
    campo.value = campo.value.substr(0,2) + '/' + campo.value.substr(2,2) + '/' + campo.value.substr(4,4);
    
	if (campo.value.length == 8 && campo.value.substr(6,1) == '0')
	 {
	 campo.value = campo.value.substr(0,6) + '20' + campo.value.substr(6,2);
	 }	
	else if (campo.value.length == 8 && (campo.value.substr(6,1) == '8' || campo.value.substr(6,1) == '9'))
	 {
	 campo.value = campo.value.substr(0,6) + '19' + campo.value.substr(6,2);
	 }	

	}
   }
  }

 }

//-------------------------
function fnc_FormataHoraMinuto(campo)
//-------------------------
 {
 if (event.keyCode != 8 && event.keyCode != 9 && event.keyCode != 16 && event.keyCode != 35 && event.keyCode != 36 && event.keyCode != 37 && event.keyCode != 39 && event.keyCode != 46)
  {
  if (campo.value.substr(campo.value.length-1,1) ==  ":" && campo.value.length != 3)
   {
   campo.value = campo.value.substr(0,campo.value.length-1);
   }
  else if ((campo.value.length == 2) && event.keyCode != 8)
   {
   campo.value = campo.value + ':';
   }
  else if ((campo.value.length == 5) && event.keyCode != 8)
   {
    if (campo.value > "23:59" || campo.value < "00:00")
    {
	campo.value = "";
    }
   }
  }
 }

//-----------------------------------------
function fnc_ZerosAEsquerda(campo)
//-----------------------------------------
{
var Zeros = "";
var TamanhoDoCampo = campo.size;
var TamanhoDaString = campo.value.length;

if (TamanhoDaString != 0)
 {
 for (i=1; i<=(TamanhoDoCampo-TamanhoDaString); i++)
  {
  Zeros = Zeros + "0";
  }
 }

campo.value = Zeros + campo.value;
}

//-----------------------------------------
function fnc_PulaCampo(campo,proximo_campo)
//-----------------------------------------
{
if (campo.value.length == campo.size)
 {
 proximo_campo.focus();
 }

}

//---------------------------------
function MM_swapImgRestore() //v3.0
//---------------------------------
 {
 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
 }

//-------------------------------
function MM_findObj(n, d) //v4.01
//-------------------------------
  {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
  }

//----------------------------
function MM_swapImage()	//v3.0
//----------------------------
  {
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
  }

//---------------------------------------------------------------
function MM_reloadPage(init) //reloads the window if Nav4 resized
//---------------------------------------------------------------
  {
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
  }

//------------------------
function setSubMenus(name)
//------------------------
  {
  var status = document.getElementById(name).style.display;
  document.getElementById("Cen_sub").style.display = 'none';
  document.getElementById("Cha_sub").style.display = 'none';
  document.getElementById("Dat_sub").style.display = 'none';
  document.getElementById("Fal_sub").style.display = 'none';
  document.getElementById("For_sub").style.display = 'none';
  document.getElementById("Org_sub").style.display = 'none';
  document.getElementById("Rep_sub").style.display = 'none';
  document.getElementById("Sal_sub").style.display = 'none';
  document.getElementById("Sol_sub").style.display = 'none';
  document.getElementById("Tel_sub").style.display = 'none';

  if (status.indexOf("none") != -1)
	{
	document.getElementById(name).style.display = '';
	}
  else
	{
	document.getElementById(name).style.display = 'none';
	}
  }

//------------------------------------------
function fnc_Seleciona(Isto,Classe1,Classe2) {if (Isto.checked) {hL(Isto,Classe2);} else {dL(Isto,Classe1);}}
//------------------------------------------

//-------------------
function hL(E,Classe)
//-------------------
 {
 while (E.tagName != "TR") {E = E.parentElement;}
 E.className = Classe;
 }

//-------------------
function dL(E,Classe)
//-------------------
 {
 while (E.tagName != "TR") {E = E.parentElement;}
 E.className = Classe;
 }

//-----------------------
function fnc_bloqueiaPagina()
//-----------------------
 {
 // Bloqueia seleção de texto
	function nsel()
		{
		return false;
		}

 // Bloqueia ação do botão direito do mouse
	var mensagem="Você não tem acesso às propriedades desta página!";

	function clickIE()
		{
		if (document.all)
			{
			alert(mensagem);
			return false;
			}
		}
	function clickNS( e )
		{
		if (document.layers||(document.getElementById&&!document.all))
			{
			if (e.which==2||e.which==3)
				{
				alert(mensagem);
				return false;
				}
			}
		}
	if (document.layers)
		{
		document.captureEvents(Event.MOUSEDOWN);
		document.onmousedown=clickNS;
	    document.onselectstart=nsel;
		}
	else
		{
		document.onclick=clickNS;
		document.oncontextmenu=clickIE;
	    document.onselectstart=nsel;
		}
 }

//------------------------------
function fnc_bloqueiaImpressao()
//------------------------------
 {
 function keyIE()
	 {
	 if (event.keyCode == 17 || event.keyCode == 80)
		 {
		 alert("Esta é apenas uma visualização.\nPara impressão, utilize o botão 'Imprimir' na tela de consulta.");
		 return false;
		 }
	 }

 document.onkeydown=keyIE;

 }

 //--------------------------------------
 function fnc_NextField(obj, objNext, maxDig)
 //--------------------------------------
  {
  if (obj.value.length==maxDig)
	 objNext.focus()
  }

//---------------------------
function fnc_CNPJValido(CNPJ)
//---------------------------
 {  

 Aux = "";
 
 for (i=0;i<=CNPJ.length-1;i++)
  {
  if (CNPJ.substr(i,1) != "." && CNPJ.substr(i,1) != "-" && CNPJ.substr(i,1) != "/") {Aux = (Aux + CNPJ.substr(i,1));}
  }
  
 CNPJ = Aux;
 
 //alert(CNPJ.length); // Comentado pelo Leo dia 12/10
 
 if (CNPJ.length != 14 || CNPJ == "00000000000000")
  {
  return false;
  }
 else
  {
  DigitoVerificador = CNPJ.substring(0,12);
  
  s1 = 0;
  for (i=01; i<=04; i++) s1 = (s1 + (ValChar(DigitoVerificador.charAt(i-01)) * (06-i)));
  for (i=05; i<=12; i++) s1 = (s1 + (ValChar(DigitoVerificador.charAt(i-01)) * (14-i)));
  r1 = (s1 % 11);
  if   (r1 < 02) dv1 = (0); else dv1 = 11 - r1;

  s2 = dv1 * 2;
  for (i=01;i<=05;i++) s2 = (s2 + (ValChar(DigitoVerificador.charAt(i-01)) * (07-i)));
  for (i=06;i<=12;i++) s2 = (s2 + (ValChar(DigitoVerificador.charAt(i-01)) * (15-i)));
  r2 = (s2 % 11);
  if   (r2 < 02) dv2 = 0; else dv2 = 11 - r2;
  
  DigitoVerificador = "" + dv1 + dv2;
  
  if (CNPJ.substr(12,2) != DigitoVerificador) {return false;}
  }
  return true;
 }

function ValChar(ch)
 {
 if (ch=="0") {return(0);}
 if (ch=="1") {return(1);}
 if (ch=="2") {return(2);}
 if (ch=="3") {return(3);}
 if (ch=="4") {return(4);}
 if (ch=="5") {return(5);}
 if (ch=="6") {return(6);}
 if (ch=="7") {return(7);}
 if (ch=="8") {return(8);}
 if (ch=="9") {return(9);}
 return(10);
 }

//-------------------------
function fnc_CPFValido(CPF)
//-------------------------
 {

 p_CPF    = CPF;
 Soma     = 0;
 Digito01 = 0;
 Digito02 = 0;
 Texto    = "";
 p_CPF1   = "";
 
 Aux = "";
 
 for (i=0;i<=p_CPF.length-1;i++)
  {
  if (p_CPF.substr(i,1) != "." && p_CPF.substr(i,1) != "-") {Aux = (Aux + p_CPF.substr(i,1));}
  }
  
 p_CPF = Aux; 
  
 x = p_CPF.length - 1;

 if (p_CPF == 11111111111 || p_CPF == 22222222222 || p_CPF == 33333333333 || p_CPF == 44444444444 || p_CPF == 55555555555 || p_CPF == 66666666666 || p_CPF == 77777777777 || p_CPF == 88888888888 || p_CPF == 99999999999 || p_CPF == 00000000000) 
  {
  return false;
  }
	
 for (var i = 0; i <= 8; i++)
  {
  y     = p_CPF.substring(i,i + 1);
  Soma  = Soma + (y * x);
  x     = x - 1;
  Texto = Texto + y;
  }
  
 Digito01 = 11 - (Soma % 11);
  
 if (Digito01 == 10) Digito01 = 0;
 if (Digito01 == 11) Digito01 = 0;
  
 p_CPF1 = p_CPF.substring(0,9) + Digito01;
 x      = 11;
 Soma   = 0;
  
 for (i=0;i<=9;i++)
  {
  Soma = Soma + (p_CPF1.substring(i,i+1) * x);
  x    = x - 1;
  }
   
 Digito02 = 11 - (Soma % 11);
 
 if (Digito02 == 10) Digito02 = 0;
 if (Digito02 == 11) Digito02 = 0;
 
 if ((Digito01 + "" + Digito02) == p_CPF.substring(11,9)) {return true;}

 return false;
 }

//-------------------------------------------------
function fnc_EmailInvalido(EmailDigitado)
//-------------------------------------------------
 {
 if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(EmailDigitado) || EmailDigitado == '' ) {return false;}
 return true;
 }

//-----------------------------------------
function fnc_FormataCNPJ(Campo, teclapres){
//-----------------------------------------

	var tecla = teclapres.keyCode;

	var vr = new String(Campo.value);
	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 < 6)
			Campo.value = vr.substr(0, 2) + '.' + vr.substr(2, tam);
		if (tam >= 6 && tam < 9)
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,tam-5);
		if (tam >= 9 && tam < 13)
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,tam-8);
		if (tam >= 13 && tam < 15)
			Campo.value = vr.substr(0,2) + '.' + vr.substr(2,3) + '.' + vr.substr(5,3) + '/' + vr.substr(8,4)+ '-' + vr.substr(12,tam-12);
		}
}

//-----------------------------------------
function fnc_FormataCPF(Campo, teclapres){
//-----------------------------------------
	var tecla = teclapres.keyCode;
	
	var vr = new String(Campo.value);
	vr = vr.replace(".", "");
	vr = vr.replace(".", "");
	vr = vr.replace("-", "");

	tam = vr.length + 1;
	
	if (tecla != 9 && tecla != 8){
		if (tam > 3 && tam < 7)
			Campo.value = vr.substr(0, 3) + '.' + vr.substr(3, tam);
		if (tam >= 7 && tam <10)
			Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,tam-6);
		if (tam >= 10 && tam < 12)
			Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,3) + '-' + vr.substr(9,tam-9);
		}
}

//-----------------------------------------
function fnc_FormataCNPJCPF(campo,tipo)
//-----------------------------------------
 {
 if (tipo=="J")
  {
  campo.maxLength=18;
  campo.value="";
  }
 else
  {
  campo.maxLength=14;
  campo.value="";
  }
 }

//-----------------------------------------
function fnc_FormataTelefone(campo)
//-----------------------------------------
 {
 var vr = new String(campo.value);
 
 vr = vr.replace(".", "");
 vr = vr.replace(".", "");
 vr = vr.replace("-", "");

 campo.value = vr;
 }
 
