function check_cpf (numcpf)
{
 numcpf = numcpf.replace(/[^0-9]/g,'');
 if (numcpf == '11111111111' || numcpf == '00000000000' || numcpf == '22222222222' || numcpf == '33333333333' || numcpf == '44444444444' || numcpf == '55555555555' || numcpf == '66666666666' || numcpf == '77777777777' || numcpf == '88888888888' || numcpf == '99999999999') {
  return false;
 }
 x = 0;
 soma = 0;
 dig1 = 0;
 dig2 = 0;
 texto = "";
 numcpf1="";
 len = numcpf.length; x = len -1;
 // var numcpf = "12345678909";
 for (var i=0; i <= len - 3; i++) {
  y = numcpf.substring(i,i+1);
  soma = soma + ( y * x);
  x = x - 1;
  texto = texto + y;
 }
 dig1 = 11 - (soma % 11);
 if (dig1 == 10) dig1=0 ;
 if (dig1 == 11) dig1=0 ;
 numcpf1 = numcpf.substring(0,len - 2) + dig1 ;
 x = 11; soma=0;
 for (var i=0; i <= len - 2; i++) {
  soma = soma + (numcpf1.substring(i,i+1) * x);
  x = x - 1;
 }
 dig2= 11 - (soma % 11);
 if (dig2 == 10) dig2=0;
 if (dig2 == 11) dig2=0;
 //alert ("Digito Verificador : " + dig1 + "" + dig2);
 if ((dig1 + "" + dig2) == numcpf.substring(len,len-2)) {
  return true;
 }
 //alert ("Numero do CPF inválido !!!");
 //document.form1.cpf.select();
 //document.form1.cpf.focus();
 return false;
}


function isNum(campo,caractere) {
	if ((campo.name == 'tel_res') || (campo.name == 'tel_cel') || (campo.name == 'tel_com') || (campo.name == 'tel_rec'))
		var strValidos = '0123456789- '
	else if ((campo.name == 'hp_sal1') || (campo.name == 'hp_sal2'))
		var strValidos = '0123456789,'
	else
		var strValidos = '0123456789'
    if ( strValidos.indexOf( caractere ) == -1 )
		return false;
	return true;
}

function validaTecla(campo, event) {
	var BACKSPACE =  8;
	var key;
	var tecla;
	CheckTAB = true;
	if (navigator.appName.indexOf('Netscape') != -1)
		tecla = event.which;
	else
		tecla = event.keyCode;
	key = String.fromCharCode( tecla);
	if ( tecla == 13 )
		return true;
	if ( tecla == BACKSPACE )
		return true;
	return ( isNum(campo,key));
}

function formata(frm) {
	if ((frm.value.length==2)|| (frm.value.length==5))
		frm.value+='/';
}

function formatacep(frm) {
	if ((frm.value.length==5))
		frm.value+='-';
}

function ContemDominio(StrDado, Dominio)
  {					
  var i, j;
  if (StrDado != "")
    {
    for (i=0; i<StrDado.length; i++)
      {
      for (j=0; j<Dominio.length; j++)
        {
        if (StrDado.substr(i,1) == Dominio.substr(j,1)) return true;
        }
      }
    }
  return false;
  }

function ValidaEMail(EMail)	
  {
  if (EMail.indexOf("@") <= 2) return false;
  if (EMail.indexOf(".") < 0) return false;
  if (ContemDominio(EMail, " ;,:/$!#%^&*()+[]{}|\\~`'\"")) return false;
  return true;
}



