// MENSAGEM EM RODAPE
window.status ="2005 © Click Consorcio"
// -------------------------------------------------------------------------->
<!-- Hide
function ApagaLink(){
   window.status="2005 © Click Consorcio";
}
// -->
// -------------------------------------------------------------------------->
function BloqueiaTaclado(inpt)
	//{var tecla=window.event.keyCode;if (tecla==9 || tecla==16 || tecla==17 || tecla==18 || tecla==27 || tecla==91 || tecla==112 || tecla==115 || tecla==116 || tecla==121 || tecla==122)
	{var tecla=window.event.keyCode;if (tecla!=116)
	{alert('Facctor 8 Precoss Secure © 1999 - 2005'); 
	event.keyCode=0; 
	event.returnValue=false;
}
}
//-------------------------------------------------------
// FUNCIONA NAS MAIORIA DOS NAVEGADORES
function fFavoritos( bookmarkurl, bookmarktitle )
{
    if (window.sidebar) window.sidebar.addPanel(bookmarktitle, bookmarkurl,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',bookmarkurl);
        mbm.setAttribute('title',bookmarktitle);
        mbm.click();
    }
    else if(document.all){window.external.AddFavorite(bookmarkurl, bookmarktitle);}
}
//-------------------------------------------------------
// BLOQUEIA BOTAO DIREITO
var message="Protegido";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
// --> 
// -------------------------------------------------------------------------->
// PREENCHIMENTO DE CAMPO DE CEP

function PreencheCep(rua,bairro,uf,cidade){
	document.all.endereco.value = rua;
	document.all.bairro.value = bairro;
	document.all.uf.value = uf;
	document.all.cidade.value = cidade;
	if (rua.length > 0){document.all.numero.focus()};	
}
// -------------------------------------------------------------------------->
// PREENCHIMENTO DE CAMPO DE CEP

function PreencheCepPoup(rua,bairro,uf,cidade,cep){

	document.all.endereco.value = rua;
	document.all.bairro.value = bairro;
	document.all.uf.value = uf;
	document.all.cidade.value = cidade;
	document.all.cep.value = cep;

	if (rua.length > 0){document.all.numero.focus()};
	
}
// -------------------------------------------------------------------------->
// PREENCHIMENTO DE CAMPO DE CEP ADICIONAL
function PreencheCep2(rua,bairro,uf,cidade){

	document.all.endereco2.value = rua;
	document.all.bairro2.value = bairro;
	document.all.uf2.value = uf;
	document.all.cidade2.value = cidade;

	if (rua.length > 0){document.all.numero2.focus()};
	
}
// -------------------------------------------------------------------------->
function pressAcao() {	
	document.all.funcaoAcao.className="button2"
	}
// -------------------------------------------------------------------------->
// FUNCAO AUTOMATICA DE AUTO-TABULACAO DE CAMPO

<!-- Begin
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
var keyCode = (isNN) ? e.which : e.keyCode; 
var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
if(input.value.length >= len && !containsElement(filter,keyCode)) {
input.value = input.value.slice(0, len);
input.form[(getIndex(input)+1) % input.form.length].focus();
}
function containsElement(arr, ele) {
var found = false, index = 0;
while(!found && index < arr.length)
if(arr[index] == ele)
found = true;
else
index++;
return found;
}
function getIndex(input) {
var index = -1, i = 0, found = false;
while (i < input.form.length && index == -1)
if (input.form[i] == input)index = i;
else i++;
return index;
}
return true;
}

// -------------------------------------------------------------------------->
// MÁSCARA PARA CEP

function mascaraCep(objeto) 
{ 
var cep = ""; 
var tecla = window.event.keyCode; 
if (tecla != 8 && tecla != 46 && tecla != 37 && tecla != 39){ 
cep = cleanStr(objeto.value,"0123456789"); 
var tam = cep.length; 
if (tam > 4) cep = cep.substr(0,5) + "-" + cep.substr(5, tam); 
objeto.value = cep; 
} 
} 
// retira caracteres invalidos da string 

function cleanStr(str,validos) 
{ 
var i,temp = ""; 
for (i=0;i<str.length;i++){ 
if (validos.indexOf(str.charAt(i)) != -1){ 
temp += str.charAt(i); 
} 
} 
return temp; 
} 
// -------------------------------------------------------------------------->
// MÁSCARA PARA TELEFONE

function mascaraTelefone(campo) 
{ 
var fone = ""; 
var tecla = window.event.keyCode; 
if (tecla != 8 && tecla != 46 && tecla != 37 && tecla != 39){ 
fone = cleanStr(campo.value,"0123456789"); 
var tam = fone.length; 
if (tam > 3) fone = fone.substr(0,4) + "-" + fone.substr(4, tam); 
campo.value = fone; 
} 
} 
// retira caracteres invalidos da string 

function cleanStr(str,validos) 
{ 
var i,temp = ""; 
for (i=0;i<str.length;i++){ 
if (validos.indexOf(str.charAt(i)) != -1){ 
temp += str.charAt(i); 
} 
} 
return temp; 
} 

// -------------------------------------------------------------------------->
function mascaraData(campo) 
{ 
var data = ""; 
var tecla = window.event.keyCode; 
if (tecla != 8 && tecla != 46 && tecla != 37 && tecla != 39){ 
data = cleanStr(campo.value,"0123456789"); 
var tam = data.length; 
if (tam > 1) data = data.substr(0,2) + "/" + data.substr(2, tam); 
if (tam > 3) data = data.substr(0,5) + "/" + data.substr(5, tam); 
campo.value = data; 
} 
} 
// retira caracteres invalidos da string 
function cleanStr(str,validos) 
{ 
var i,temp = ""; 
for (i=0;i<str.length;i++){ 
if (validos.indexOf(str.charAt(i)) != -1){ 
temp += str.charAt(i); 
} 
} 
return temp; 
} 

// -------------------------------------------------------------------------->
function MascaraMoeda()
		{
			if((event.keyCode < 48) || (event.keyCode > 57))
			{
				event.returnValue = false;
			}
		}

		function troca(str,strsai,strentra)
		{
			while(str.indexOf(strsai)>-1)
			{
				str = str.replace(strsai,strentra);
			}
			return str;
		}
		
		function FormatarMoeda(campo,tammax,teclapres,caracter)
		{
			if(teclapres == null || teclapres == "undefined")
			{
				var tecla = -1;
			}
			else
			{
				var tecla = teclapres.keyCode;
			}

    		if(caracter == null || caracter == "undefined")
    		{
				caracter = ".";
    		}

    		vr = campo.value;
    		if(caracter != "")
    		{
				vr = troca(vr,caracter,"");
    		}
    		vr = troca(vr,"/","");
    		vr = troca(vr,",","");
    		vr = troca(vr,".","");

    		tam = vr.length;
    		if(tecla > 0)
    		{
				if(tam < tammax && tecla != 8)
				{
					tam = vr.length + 1;
				}
	    		
    			if(tecla == 8)
    			{
    				tam = tam - 1;
    			}
    		}
    		if(tecla == -1 || 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) + caracter + vr.substr(tam - 5, 3) + ',' + vr.substr(tam - 2, tam);
				}
    	 		if((tam >= 9) && (tam <= 11))
    	 		{
					campo.value = vr.substr(0, tam - 8) + caracter + vr.substr(tam - 8, 3) + caracter + vr.substr(tam - 5, 3) + ',' + vr.substr(tam - 2, tam);
				}
    	 		if((tam >= 12) && (tam <= 14))
    	 		{
					campo.value = vr.substr(0, tam - 11) + caracter + vr.substr(tam - 11, 3) + caracter + vr.substr(tam - 8, 3) + caracter + vr.substr(tam - 5, 3) + ',' + vr.substr(tam - 2, tam);
				}
    	 		if((tam >= 15) && (tam <= 17))
    	 		{
					campo.value = vr.substr(0, tam - 14) + caracter + vr.substr(tam - 14, 3) + caracter + vr.substr(tam - 11, 3) + caracter + vr.substr(tam - 8, 3) + caracter + vr.substr(tam - 5, 3) + ',' + vr.substr(tam - 2, tam);
				}
    		}
		}

// -------------------------------------------------------------------------->
// VALIDAR E-MAIL

function ValidaEmail(campo)
{
	if (campo.value == 0) {return false;}
	else if (/^([\w\.\-])+\@(([\w\-])+\.)+([\w ]{2,4})$/.test(campo.value) == false)
	{ 
	alert("E-mail inválido!");
	campo.value = "";
	campo.focus();
	return false;
}
}
// -------------------------------------------------------------------------->
// VALIDACAO CAMPO SEM ASPAS
// <HMTL> OnKeyPress="semTracos(This)"

function semAspas(campo)
	{var tecla=window.event.keyCode;if (tecla==32 || tecla==34 || tecla==39)
	{alert('Desculpe o sistema não suporta este caracter © 2005 Precoss'); 
	//campo.value = "";
	event.keyCode=0; 
	event.returnValue=false;
}
}
// -------------------------------------------------------------------------->
// VALIDACAO SEM TRACOS, PONTOS OU VIRGULAS
// <HMTL> OnKeyPress="semTracos(This)"

function semTracos(campo)
	{var tecla=window.event.keyCode;if (tecla==32 || tecla==44 || tecla==45 || tecla==46)
	{alert('Por favor, não use espaços, barras, virgulas ou pontos © 2005 Precoss'); 
	//campo.value = "";
	event.keyCode=0; 
	event.returnValue=false;
}
}
// -------------------------------------------------------------------------->
// VALIDACAO DE CNPJ

 function cgc(pcgc)
 {
 // verifica o tamanho
 if (pcgc.length != 14) {
  sim=false
  //alert ("Tamanho Invalido de CNPJ")
  }
 else {sim=true}

  if (!sim)  // verifica se e numero
  {
  alert("Valor não corresponde somente a dígitos");
  document.all.pcgc.value="";
  return;
  }else{
  for (i=0;((i<=(pcgc.length-1))&& sim); i++)
  {
   val = pcgc.charAt(i)
   if
((val!="9")&&(val!="0")&&(val!="1")&&(val!="2")&&(val!="3")&&(val!="4") &&
(val!="5")&&(val!="6")&&(val!="7")&&(val!="8")) {sim=false}
   }
   if (sim)  // se for numero continua
   {
    m2 = 2
    soma1 = 0
    soma2 = 0
    for (i=11;i>=0;i--)
    {
     val = eval(pcgc.charAt(i))
       // alert ("Valor do Val: "+val)
     m1 = m2
  if (m2<9) { m2 = m2+1}
  else {m2 = 2}
  soma1 = soma1 + (val * m1)
  soma2 = soma2 + (val * m2)
    }  // fim do for de soma

  soma1 = soma1 % 11
  if (soma1 < 2) {  d1 = 0}
   else { d1 = 11- soma1}

     soma2 = (soma2 + (2 * d1)) % 11
  if (soma2 < 2) { d2 = 0}
   else { d2 = 11- soma2}
        // alert (d1)
       // alert (d2)
    if ((d1==pcgc.charAt(12)) && (d2==pcgc.charAt(13)))
   {alert("Valor de CNPJ correto")}
   else {alert("Este CNPJ não é válido e não poderá ser registrado, confirme ou mantenha em branco")
  document.all.pcgc.value="";
  return;}

   }
 }

 }

// -------------------------------------------------------------------------->
// VALIDACAO DE CPF

 function cpf(pcpf)
 {

 if (pcpf.length != 11) {sim=false}
 else {sim=true}

  if (sim )  // valida o primeiro digito
  {
  for (i=0;((i<=(pcpf.length-1))&& sim); i++)
  {
   val = pcpf.charAt(i)
   if

 ((val!="9")&&(val!="0")&&(val!="1")&&(val!="2")&&(val!="3")&&(val!="4")

 &&    (val!="5")&&(val!="6")&&(val!="7")&&(val!="8")) {sim=false}
   }

   if (sim)
  {
    soma = 0
    for (i=0;i<=8;i++)
    {
     val = eval(pcpf.charAt(i))
     soma = soma + (val*(i+1))
    }

    resto = soma % 11
    if (resto>9) dig = resto -10
    else  dig = resto
    if (dig != eval(pcpf.charAt(9))) { sim=false }
   else   // valida o segundo digito
    {

     soma = 0
    for (i=0;i<=7;i++)
     {
     val = eval(pcpf.charAt(i+1))
      soma = soma + (val*(i+1))
    }

     soma = soma + (dig * 9)
    resto = soma % 11
     if (resto>9) dig = resto -10
     else  dig = resto
   if (dig != eval(pcpf.charAt(10))) { sim = false }
    else sim = true
   }
   }
  }

  if (sim) {
  }
  else 
  {
  alert("Valor invalido de CPF");
  document.all.pcpf.value="";
  return;
  }
}
// -------------------------------------------------------------------------->
