// JavaScript Document
// Author: Paintbox - Bruno Rossi
/*
###################################################
## Desenvolvimento do Script: PaintBox ##
## http://www.premioabrelpre.org.br    ##																							           
###################################################
*/
 function ValidaCpf()
 {
 
   if (checaCPF(document.form1.cpf.value))
   {  
  

   document.form1.Objeto.focus();
   }
   else
   {
          errors="1";
     if (errors) alert('Digite corretamente o CPF');
         document.MM_returnValue = (errors == '');
         
                 document.Fform1.cpf.focus();
   }
 }
 function checaCPF (CPF) {
    if (CPF.length != 11 || CPF == "00000000000" || CPF == "11111111111" ||
        CPF == "22222222222" ||    CPF == "33333333333" || CPF == "44444444444" ||
        CPF == "55555555555" || CPF == "66666666666" || CPF == "77777777777" ||
        CPF == "88888888888" || CPF == "99999999999")
        return false;
        soma = 0;
    for (i=0; i < 9; i ++)
        soma += parseInt(CPF.charAt(i)) * (10 - i);
        resto = 11 - (soma % 11);
    if (resto == 10 || resto == 11)
        resto = 0;
    if (resto != parseInt(CPF.charAt(9)))
        return false;
    soma = 0;
    for (i = 0; i < 10; i ++)
        soma += parseInt(CPF.charAt(i)) * (11 - i);
    resto = 11 - (soma % 11);
    if (resto == 10 || resto == 11)
        resto = 0;
    if (resto != parseInt(CPF.charAt(10)))
        return false;
        return true;
  } 
