function isCpf(cpf) {
	 cpf = cpf;
	 erro = new String;
	 if (cpf.length < 11) erro += "Sao necessarios 11 digitos para verificacao do CPF! \n\n";
	 var nonNumbers = /\D/;
	 if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros! \n\n";
	 if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
			 erro += "Numero de CPF invalido!"
   }
   var a = [];
   var b = new Number;
   var c = 11;
   for (i=0; i<11; i++){
		   a[i] = cpf.charAt(i);
		   if (i < 9) b += (a[i] * --c);
   }
   if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
   b = 0;
   c = 11;
   for (y=0; y<10; y++) b += (a[y] * c--);
   if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
   if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
		   erro +="CPF inválido, Digito verificador com problema!";
   }
   if (erro.length > 0){
		   alert(erro);
		   return false;
   }
   return true;
}

// valida email
function validar(nform) {
	if (nform.nome.value == "") {
		alert("Informe seu Nome.");
		nform.nome.focus();
		nform.nome.select();
		return false;
	} 
	if (!isCpf(nform.cpf.value)) {
		//alert("Seu CPF deve possuir 18 caracteres Ex: 99999999999 .");
		nform.cpf.focus();
		nform.cpf.select();
		return false;
	}
	if (nform.endereco.value == "") {
		alert("Informe seu Endereço.");
		nform.endereco.focus();
		nform.endereco.select();
		return false;
	} 
	if (nform.bairro.value == "") {
		alert("Informe seu Bairro.");
		nform.bairro.focus();
		nform.bairro.select();
		return false;
	} 
	if (nform.cidade.value == "") {
		alert("Informe sua Cidade.");
		nform.cidade.focus();
		nform.cidade.select();
		return false;
	} 
	if (nform.uf.value == "") {
		alert("Informe seu Estado.");
		nform.uf.focus();
		nform.uf.select();
		return false;
	}
	if (nform.ddd1.value == "") {
		alert("Informe o código DDD de sua Cidade.");
		nform.ddd1.focus();
		nform.ddd1.select();
		return false;
	}
	if (nform.telefone1.value == "") {
		alert("Informe seu Telefone.");
		nform.telefone1.focus();
		nform.telefone1.select();
		return false;
	}
	if (!(nform.senha_form.value.length > 5)) {
		alert("Sua Senha deve possuir no mínimo 6 caracteres ou máximo de 10.");
		nform.senha_form.focus();
		nform.senha_form.select();
		return false;
	} 

	if (nform.repete_senha.value == nform.senha_form.value) {
	}else{
		alert("Senha não está confirmando.");
		nform.repete_senha.focus();
		nform.repete_senha.select();
		return false;
	} 	

		return true;
}
