//funcao que formata o cpf
function mascara_cpf(cpf, form)
{
    var mycpf = '';

    mycpf = mycpf + cpf;
    if (mycpf.length == 3) {
        mycpf = mycpf + '.';
        form.cpf.value= mycpf;
    }
    if (mycpf.length == 7) {
        mycpf = mycpf + '.';
        form.cpf.value = mycpf;
    }
    if (mycpf.length == 11) {
        mycpf = mycpf + '-';
        form.cpf.value = mycpf;
    }
    if (mycpf.length == 14) {
    }
}

//funcao que formata o cnpj
function mascara_cnpj(cnpj, form)
{
    var mycnpj = '';
    mycnpj = mycnpj + cnpj;
    if (mycnpj.length == 2) {
        mycnpj = mycnpj + '.';
        form.cnpj.value = mycnpj;
    }
    if (mycnpj.length == 6) {
        mycnpj = mycnpj + '.';
        form.cnpj.value = mycnpj;
    }
    if (mycnpj.length == 10) {
        mycnpj = mycnpj + '/';
        form.cnpj.value = mycnpj;
    }
    if (mycnpj.length == 15) {
        mycnpj = mycnpj + '-';
        form.cnpj.value = mycnpj;
    }
    if (mycnpj.length == 18) {
    }
}

//funcao que formata o cep
function mascara_cep(cep, form)
{
    var mycep = '';
    mycep = mycep + cep;
    if (mycep.length == 2) {
        mycep = mycep + '.';
        form.cep.value = mycep;
    }
    if (mycep.length == 6) {
        mycep = mycep + '-';
        form.cep.value = mycep;
    }
    if (mycep.length == 10) {
    }
}

//funcao que formata telefone
function mascara_tel(num,tel, form)
{
    var mytel = '';
    mytel = mytel + tel;
    if (mytel.length == 1) {
        mytel = '(' + mytel;
	if (num == 1){
	   form.telefone.value = mytel;
	}
	if (num == 2){
	   form.celular.value = mytel;
	}
	if (num == 3){
	   form.fax.value = mytel;
	}
    }
    if (mytel.length == 3) {
        mytel = mytel + ')';
	if (num == 1){
	   form.telefone.value = mytel;
	}
	if (num == 2){
	   form.celular.value = mytel;
	}
	if (num == 3){
	   form.fax.value = mytel;
	}
    }
}

//funcao que formata inscricao
function mascara_ins(ins, form, tipo)
{
    var myins = '';
    myins = myins + ins;
	
    if (myins.length == 3){
	myins = myins + ".";
    }
    if (myins.length == 7){
	myins = myins + ".";
    }
    if (tipo == "mu"){
	if (myins.length == 11){
	    myins = myins + "-";
	}
    }
    if (tipo == "es"){
	if (myins.length == 11){
	    myins = myins + ".";
	}
	if (myins.length == 14){
	    myins = myins + "-";
	}
    }

    
    
}

//funcao que salta campo de data
function salta_campo(origem,destino,tam){
 
   if (origem.length == tam) {
	destino.focus();
   }
}
//funcao que mostra expressao em outro obj do form
function movein(menssagem){

	if (document.getElementById) {
		document.getElementById("expr").innerHTML=menssagem;
	}
	else{
		expr.innerHTML=menssagem;
	}
}

//funcao de manipulacao do menu
var ns6=document.getElementById&&!document.all?1:0



var head="display:''"

var folder=''



function expandit(curobj){

	folder=ns6?curobj.nextSibling.nextSibling.style:document.all[curobj.sourceIndex+1].style

	if (folder.display=="none") folder.display=""

	else folder.display="none"

}

function verifica(teclapres,pegaid)
{
 if(window.event){
    var tecla = teclapres.keyCode;
   }else  tecla = teclapres.which;	

if ((tecla==48)||(tecla==49)||(tecla==50)||(tecla==51)||(tecla==52)||(tecla==53)||(tecla==54)||(tecla==55)||(tecla==56)||(tecla==57)||(tecla==09)||(tecla==08)||(tecla==13)||(tecla==96)||(tecla==97)||(tecla==98)||(tecla==99)||(tecla==100)||(tecla==101)||(tecla==102)||(tecla==103)||(tecla==104)||(tecla==105)||(tecla==37)||(tecla==38)||(tecla==39)||(tecla==40)||(tecla==33)||(tecla==34)||(tecla==35)||(tecla==36)||(tecla==45)||(tecla==46)) {controle=1;}
  else {
   alert("Digite seu CPF ou CNPJ no login (apenas números)!");
   document.getElementById(pegaid).value = '';
  }

}

function verifica2(teclapres,pegaid)
{		
   if(window.event){
    var tecla = teclapres.keyCode;
   }else  tecla = teclapres.which;	

if ((tecla==48)||(tecla==49)||(tecla==50)||(tecla==51)||(tecla==52)||(tecla==53)||(tecla==54)||(tecla==55)||(tecla==56)||(tecla==57)||(tecla==09)||(tecla==08)||(tecla==96)||(tecla==97)||(tecla==98)||(tecla==99)||(tecla==100)||(tecla==101)||(tecla==102)||(tecla==103)||(tecla==104)||(tecla==105)||(tecla==37)||(tecla==38)||(tecla==39)||(tecla==40)||(tecla==33)||(tecla==34)||(tecla==35)||(tecla==36)||(tecla==45)||(tecla==46)) {controle=1;}
  else {
   alert("Por favor, digite apenas números!"); 
   document.getElementById(pegaid).value = '';
  }

}

function autentica(teclapres){
   if(window.event){
    var tecla = teclapres.keyCode;
   }else  tecla = teclapres.which;
   if (tecla==13) {xajax_inicia_session(xajax.getFormValues('form1'));}
}

function MascaraCEP(teclapres){
	
   if(window.event){
    var tecla = teclapres.keyCode;
   }else  tecla = teclapres.which;	
		
	
	if(tecla!=8){
	
	valor = document.getElementById("cep").value;
	if(valor.length==5 ){
		document.getElementById("cep").value = valor+"-";
	}
	
	}
}

function MascaraTelefone(campo, teclapres){
	
   if(window.event){
    var tecla = teclapres.keyCode;
   }else  tecla = teclapres.which;	 

	if(tecla!=8){
	
	valor = document.getElementById(campo).value;
	
	if(valor.length==0)
		document.getElementById(campo).value = "("+valor;
	else if(valor.length==3)
	    document.getElementById(campo).value= valor+")";
	else if(valor.length==8)    
	    document.getElementById(campo).value= valor+"-";
	}	    
	    
}

function MascaraCpf(campo, teclapres){
	
   if(window.event){
    var tecla = teclapres.keyCode;
   }else  tecla = teclapres.which;	 

	if(tecla!=8){
	
	valor = document.getElementById(campo).value;
	
	if(valor.length==3)
		document.getElementById(campo).value = valor+".";
	else if(valor.length==7)
	    document.getElementById(campo).value= valor+".";
	else if(valor.length==11)    
	    document.getElementById(campo).value= valor+"-";
	    
	}	    
	    
}

function FormataCNPJ(Campo, teclapres){

   if(window.event){
    var tecla = teclapres.keyCode;
   }else  tecla = teclapres.which;

   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);
      }
}

     //detect browser settings for showing and hiding DIVs

     isNS4 = (document.layers) ? true : false;

     isIE4 = (document.all && !document.getElementById) ? true : false;

     isIE5 = (document.all && document.getElementById) ? true : false;

     isNS6 = (!document.all && document.getElementById) ? true : false;

//=======================================================



