function limita(campotexto, limitador)
{
	if (campotexto.value.length > limitador)
		campotexto.value = campotexto.value.substring(0, limitador);
}
function abre_foto(janela)
{
	window.open("foto.asp?foto="+janela,"popup","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=390,height=291,top=150 left=150")
}
function popup_up(pagina,targ,largura,altura)
{
	esquerda = (screen.width - largura - 10)/2;
	topo = screen.height - 59;
	topo = (topo - altura)/2;
	param = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" + largura + ",height=" + altura + ",top=" + topo + ",left=" + esquerda;
	window.open(pagina,targ,param);
}

function popup(pagina,targ,largura,altura,esquerda,topo,scrollbars)
{
	if (scrollbars == null || scrollbars == '')
	{
		scrollbars = '0';
	}
	if (esquerda == null || esquerda == '')
	{
		esquerda = (screen.width - largura - 10)/2;
	}
	if (topo == null || topo == '')
	{
		topo = (screen.height - altura - 57)/2;
	}
//	param = "fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0";
//	win = window.open("",targ,param);
//	win.moveTo(esquerda,topo);
//	win.resizeTo(largura,altura);
//	param = "fullscreen=1"
	param = "fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=" + scrollbars + ",resizable=0,width=" + largura + ",height=" + altura + ",top=" + topo + ",left=" + esquerda;
	win = window.open(pagina,targ,param);
	return win;
}

function Money_2_Java(num)
{
	novo_num = num;
	for(z=0;novo_num.lastIndexOf(".")>-1;z++)
	{
		ult_ponto = novo_num.lastIndexOf(".");
		novo_num = novo_num.substring(0,ult_ponto) + novo_num.substring(ult_ponto+1,novo_num.length);
	}
	ult_virg = novo_num.lastIndexOf(",");
	if (ult_virg > -1)
	{
		novo_num = novo_num.substring(0,ult_virg) + "." + novo_num.substring(ult_virg+1,novo_num.length);
	}
	return novo_num
}

function NumJava_2_Money(num)
{
	virg = false;
	novo_num = "";
	num = "" + num
	if (num.lastIndexOf(".") == -1)
	{
		virg = true;
		ponto = 0
	}
	for(i=0;i<num.length;i++)
	{
		if(num.substring(num.length-i-1,num.length-i) == ".")
		{
			if (!virg)
			{
				virg = true;
				ponto = 0;
				novo_num = "," + novo_num;
			}
		}
		else
		{
			if(virg)
			{
				if (ponto == 3 && num.substring(num.length-i-1,num.length-i) != "-")
				{
					ponto = 0
					novo_num = "." + novo_num
				}
				ponto = ponto + 1
			}
			novo_num = num.substring(num.length-i-1,num.length-i) + novo_num;
		}
	}
	if (novo_num.lastIndexOf(",") == -1)
	{
		novo_num = novo_num + ",00";
	}
	else if(novo_num.lastIndexOf(",") == novo_num.length - 2)
	{
		novo_num = novo_num + "0";
	}
	return novo_num
}

function mascaradata(S,campo)
{
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++)
	{
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=8)
		{
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = "/"+ S.charAt(0) + S.charAt(1) + S.charAt(2) + S.charAt(3)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"/"+ S.charAt(1) + S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = "/"+ S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"/"+ S.charAt(1) + S.charAt(2) +"/"+ S.charAt(3) + S.charAt(4) + S.charAt(5)+ S.charAt(6)}}
			if (numero == 8 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) +"/"+ S.charAt(4) + S.charAt(5) + S.charAt(6)+ S.charAt(7)}}
		}
	}
    campo.value = temp;
}

function mascaradatahora(S,campo)
{
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++)
	{
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=14)
		{
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"/"+ S.charAt(1) + S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = "/"+ S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"/"+ S.charAt(1) + S.charAt(2) +"/"+ S.charAt(3) + S.charAt(4) + S.charAt(5)+ S.charAt(6)}}
			if (numero == 8 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) +"/"+ S.charAt(4) + S.charAt(5) + S.charAt(6)+ S.charAt(7)}}
			if (numero == 9 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) +" "+ S.charAt(3) + S.charAt(4) + ":" + S.charAt(5) + S.charAt(6) + ":" + S.charAt(7)+ S.charAt(8)}}
			if (numero == 10 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) + S.charAt(3) +" "+ S.charAt(4) + S.charAt(5) + ":" + S.charAt(6) + S.charAt(7) + ":" + S.charAt(8)+ S.charAt(9)}}
			if (numero == 11 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "/" + S.charAt(1) + S.charAt(2) + S.charAt(3) + S.charAt(4) + " " + S.charAt(5) + S.charAt(6) + ":" + S.charAt(7) + S.charAt(8) + ":" + S.charAt(9)+ S.charAt(10)}}
			if (numero == 12 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "/" + S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5) + " " + S.charAt(6) + S.charAt(7) + ":" + S.charAt(8) + S.charAt(9) + ":" + S.charAt(10)+ S.charAt(11)}}
			if (numero == 13 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "/" + S.charAt(1) + S.charAt(2) + "/" + S.charAt(3) + S.charAt(4) + S.charAt(5) + S.charAt(6) + " " + S.charAt(7) + S.charAt(8) + ":" + S.charAt(9) + S.charAt(10) + ":" + S.charAt(11)+ S.charAt(12)}}
			if (numero == 14 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "/" + S.charAt(2) + S.charAt(3) + "/" + S.charAt(4) + S.charAt(5) + S.charAt(6) + S.charAt(7) + " "+ S.charAt(8) + S.charAt(9) + ":" + S.charAt(10) + S.charAt(11) + ":" + S.charAt(12)+ S.charAt(13)}}
		}
	}
    campo.value = temp;
}

function mascaradatahora2(S,campo)
{
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++)
	{
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=14)
		{
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"/"+ S.charAt(1) + S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = "/"+ S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"/"+ S.charAt(1) + S.charAt(2) +"/"+ S.charAt(3) + S.charAt(4) + S.charAt(5)+ S.charAt(6)}}
			if (numero == 8 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) +"/"+ S.charAt(4) + S.charAt(5) + S.charAt(6)+ S.charAt(7)}}
			if (numero == 9 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) +"/"+ S.charAt(4) + S.charAt(5) + S.charAt(6)+ S.charAt(7) +" " + S.charAt(8)}}
			if (numero == 10 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) +"/"+ S.charAt(4) + S.charAt(5) + S.charAt(6)+ S.charAt(7) +" " + S.charAt(8) + S.charAt(9)}}
			if (numero == 11 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) +"/"+ S.charAt(4) + S.charAt(5) + S.charAt(6)+ S.charAt(7) +" " + S.charAt(8) + S.charAt(9) + ":" + S.charAt(10)}}
			if (numero == 12 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) +"/"+ S.charAt(4) + S.charAt(5) + S.charAt(6)+ S.charAt(7) +" " + S.charAt(8) + S.charAt(9) + ":" + S.charAt(10) + S.charAt(11)}}
			if (numero == 13 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) +"/"+ S.charAt(4) + S.charAt(5) + S.charAt(6)+ S.charAt(7) +" " + S.charAt(8) + S.charAt(9) + ":" + S.charAt(10) + S.charAt(11)+ ":" + S.charAt(12)}}
			if (numero == 14 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"/"+ S.charAt(2) + S.charAt(3) +"/"+ S.charAt(4) + S.charAt(5) + S.charAt(6)+ S.charAt(7) +" " + S.charAt(8) + S.charAt(9) + ":" + S.charAt(10) + S.charAt(11)+ ":" + S.charAt(12) + S.charAt(13)}}
		}
	}
    campo.value = temp;
}

function mascarahora(S,campo)
{
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++)
	{
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=5)
		{
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 3 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + ":" + S.charAt(1)+ S.charAt(2)}}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + ":" + S.charAt(2)+ S.charAt(3)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + ":" + S.charAt(1) + S.charAt(2) + ":" + S.charAt(3)+ S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + ":" + S.charAt(2) + S.charAt(3) + ":" + S.charAt(4)+ S.charAt(5)}}
		}
	}
    campo.value = temp;
}

function mascaracep(S,campo)
{
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++)
	{
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=6)
		{
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 3 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "-" + S.charAt(1) + S.charAt(2) + S.charAt(3)}}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "-" + S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) + "-" + S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "." + S.charAt(1) + S.charAt(2) + S.charAt(3) + "-" + S.charAt(4) + S.charAt(5) + S.charAt(6)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "." + S.charAt(2) + S.charAt(3) + S.charAt(4) + "-" + S.charAt(5) + S.charAt(6) + S.charAt(7)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}

function mascarafone(S,campo)
{
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++)
	{
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=10)
		{
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"-"+ S.charAt(1) + S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"-"+ S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) +"-"+ S.charAt(3) + S.charAt(4) + S.charAt(5)+ S.charAt(6)}}
			if (numero == 8 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) + S.charAt(3) +"-"+ S.charAt(4) + S.charAt(5) + S.charAt(6) + S.charAt(7)}}
			if (numero == 9 ){if (Digitos.indexOf(digito)>=0){temp = "(" + S.charAt(0) + S.charAt(1) + ") " + S.charAt(2) + S.charAt(3) + S.charAt(4) +"-"+ S.charAt(5) + S.charAt(6) + S.charAt(7)+ S.charAt(8)}}
			if (numero == 10 ){if (Digitos.indexOf(digito)>=0){temp = "(" + S.charAt(0) + S.charAt(1) + ") " + S.charAt(2) + S.charAt(3) + S.charAt(4) + S.charAt(5) +"-"+ S.charAt(6) + S.charAt(7) + S.charAt(8)+ S.charAt(9)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}

function mascaranumero(S,campo)
{
	var Digitos = "0123456789";
	S = limpa_string(Money_2_Java(S));
	ini_z = false
	sem_zero = ""
	for (var i=0; i<S.length; i++)
	{
		if (ini_z == true || S.charAt(i) != "0")
		{
			ini_z = true;
			sem_zero = sem_zero + S.charAt(i);
		}
	}
	S = sem_zero;
	a_virg = "";
	numero = 0;
   	for (var i=0; i<S.length - 2; i++)
	{
	  	numero = numero + 1;
	  	digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0)
		{
			a_virg = a_virg + digito
		}
	}
	if (S.length == 1)
	{
		temp = "0.0" + S
		temp = NumJava_2_Money(temp);
	}
	else if (S.length == 2)
	{
		temp = "0." + S
		temp = NumJava_2_Money(temp);
	}
	else if (S.length > 2)
	{
		temp = a_virg + "." + S.charAt(S.length-2) + S.charAt(S.length-1);
		temp = NumJava_2_Money(temp);
	}
	else
	{
		temp = S;
	}
	if (eval(Money_2_Java(temp)) == 0)
	{
		temp = "";
	}
	if(temp=="")
	{
		temp = "0,00"
	}
    campo.value = temp;
}

function mascaranumero2(S,campo)
{
	var Digitos = "0123456789";
	S = limpa_string(Money_2_Java(S));
	ini_z = false
	sem_zero = ""
	for (var i=0; i<S.length; i++)
	{
		if (ini_z == true || S.charAt(i) != "0")
		{
			ini_z = true;
			sem_zero = sem_zero + S.charAt(i);
		}
	}
	S = sem_zero;
	a_virg = "";
	numero = 0;
   	for (var i=0; i<S.length - 2; i++)
	{
	  	numero = numero + 1;
	  	digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0)
		{
			a_virg = a_virg + digito
		}
	}
	temp = S;
	if (eval(Money_2_Java(temp)) == 0)
	{
		temp = "";
	}
    campo.value = temp;
}

function mascaracpfcnpj(S,campo)
{
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++)
	{
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=13)
		{
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 2 ){temp = "-" + S.substring(S.length-2,S.length)}
			if (numero == 3 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"-"+ S.charAt(1) + S.charAt(2)}}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "-" + S.charAt(2) + S.charAt(3)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = "."+S.charAt(0) + S.charAt(1) + S.charAt(2) + "-" + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3) + "-" + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4) + "-" + S.charAt(5)+ S.charAt(6)}}
			if (numero == 8 ){if (Digitos.indexOf(digito)>=0){temp = "."+S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5) + "-" + S.charAt(6)+ S.charAt(7)}}
			if (numero == 9 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6) + "-" + S.charAt(7)+ S.charAt(8)}}
			if (numero == 10){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4) +"."+ S.charAt(5) + S.charAt(6) + S.charAt(7) + "-" + S.charAt(8)+ S.charAt(9)}}
			if (numero == 11){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5) +"."+ S.charAt(6) + S.charAt(7) + S.charAt(8) + "-" + S.charAt(9) + S.charAt(10)}}
			if (numero == 12){if (Digitos.indexOf(digito)>=0){temp = "." + S.charAt(0) + S.charAt(1) + S.charAt(2) + "." + S.charAt(3) + S.charAt(4) + S.charAt(5) + "/" +  S.charAt(6) + S.charAt(7) + S.charAt(8) + S.charAt(9) + "-" + S.charAt(10) + S.charAt(11)}}
			if (numero == 13){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "." +  S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6) +"/"+ S.charAt(7) + S.charAt(8) + S.charAt(9) + S.charAt(10) +"-"+ S.charAt(11) + S.charAt(12)}}
			if (numero == 14){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "." + S.charAt(2) + S.charAt(3) + S.charAt(4) + "." + S.charAt(5) + S.charAt(6) + S.charAt(7) + "/" + S.charAt(8) + S.charAt(9) + S.charAt(10) + S.charAt(11) +"-"+ S.charAt(12) + S.charAt(13)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}

function mascaracnpjcol(S,campo)
{
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
	var dig = "";
	var espaco;
	var numero;
	numero = 0;
	espaco = 0;
	S = limpa_string(S);	
   	for (var i=0; i<S.length; i++)
	{
	  	numero = numero + 1;
	  	digito = S.charAt(i);
  		if (i<=11)
		{
			if (Digitos.indexOf(digito)>=0){temp = temp + digito}
			if (numero == 2 ){temp = "-" + S.substring(S.length-2,S.length)}
			if (numero == 3 ){if (Digitos.indexOf(digito)>=0){temp = "." + S.charAt(0) + S.charAt(1) + S.charAt(2)}}
			if (numero == 4 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3)}}
			if (numero == 5 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4)}}
			if (numero == 6 ){if (Digitos.indexOf(digito)>=0){temp = "."+S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5)}}
			if (numero == 7 ){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) +"."+ S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6)}}
			if (numero == 8){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) +"."+ S.charAt(2) + S.charAt(3) + S.charAt(4) +"."+ S.charAt(5) + S.charAt(6) + S.charAt(7)}}
			if (numero == 9){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + S.charAt(2) +"."+ S.charAt(3) + S.charAt(4) + S.charAt(5) +"."+ S.charAt(6) + S.charAt(7) + S.charAt(8)}}
			if (numero == 10){if (Digitos.indexOf(digito)>=0){temp = "." + S.charAt(0) + S.charAt(1) + S.charAt(2) + "." + S.charAt(3) + S.charAt(4) + S.charAt(5) + "/" +  S.charAt(6) + S.charAt(7) + S.charAt(8) + S.charAt(9)}}
			if (numero == 11){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + "." +  S.charAt(1) + S.charAt(2) + S.charAt(3) +"."+ S.charAt(4) + S.charAt(5) + S.charAt(6) +"/"+ S.charAt(7) + S.charAt(8) + S.charAt(9) + S.charAt(10)}}
			if (numero == 12){if (Digitos.indexOf(digito)>=0){temp = S.charAt(0) + S.charAt(1) + "." + S.charAt(2) + S.charAt(3) + S.charAt(4) + "." + S.charAt(5) + S.charAt(6) + S.charAt(7) + "/" + S.charAt(8) + S.charAt(9) + S.charAt(10) + S.charAt(11)}}
		}
	}
//	document.formulario.CGC.value = temp;
    campo.value = temp;
}

function limpa_string(S)
{
	// Deixa so' os digitos no numero
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";
   	for (var i=0; i<S.length; i++)
	{
      digito = S.charAt(i);
      if (Digitos.indexOf(digito)>=0){temp=temp+digito}
   	}
   return temp
}

function limpa_string_virg(S){
	// Deixa so' os digitos no numero
	var Digitos = "0123456789,.";
	var temp = "";
	var digito = "";
   	for (var i=0; i<S.length; i++)
	{
      digito = S.charAt(i);
      if (Digitos.indexOf(digito)>=0){temp=temp+digito}
   	}
   return temp
}

function valida_CPF(s){
	var i;
	s = limpa_string(s);
	var c = s.substr(0,9);
	var dv = s.substr(9,2);
	var d1 = 0;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(10-i);
	}
	if (d1 == 0) return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}
	d1 *= 2;
	for (i = 0; i < 9; i++)
	{
		d1 += c.charAt(i)*(11-i);
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
   return true;
}
function valida_CGC(s)
{
	var i;
	s = limpa_string(s);
	var c = s.substr(0,12);
	var dv = s.substr(12,2);

	var d1 = 0;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+(i % 8));
	}
	if (d1 == 0)
		return false;
	d1 = 11 - (d1 % 11);
	if (d1 > 9)
		d1 = 0;
	if (dv.charAt(0) != d1)
	{
		return false;
	}
	d1 *= 2;
	for (i = 0; i < 12; i++)
	{
		d1 += c.charAt(11-i)*(2+((i+1) % 8));
	}
	d1 = 11 - (d1 % 11);
	if (d1 > 9) d1 = 0;
	if (dv.charAt(1) != d1)
	{
		return false;
	}
	return true;
}
function ltrim(string)
{
	inicio = false;
	nova_string = "";
	for (x=0;x<string.length;x++)
	{
		if (string.charAt(x) != " ")
		{
			inicio = true;
			nova_string = nova_string + string.charAt(x);
		}
		else if(inicio)
		{
			nova_string = nova_string + string.charAt(x);
		}
	}
	return nova_string
}

function rtrim(string)
{
	inicio = false;
	nova_string = "";
	for (x = string.length - 1;x>=0;x--)
	{
		if (string.charAt(x) != " ")
		{
			inicio = true;
			nova_string = string.charAt(x) + nova_string;
		}
		else if(inicio)
		{
			nova_string = string.charAt(x) + nova_string;
		}
	}
	return nova_string
}

function trim(string)
{
	return ltrim(rtrim(string))
}
function MM_preloadImages()
{ //v3.0
	var d=document;
	if(d.images)
	{
		if(!d.MM_p)
			d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
		for(i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0)
			{
				d.MM_p[j]=new Image;
				d.MM_p[j++].src=a[i];
			}
	}
}
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];
		}
}