function validaFormHome()
{
	var email = document.getElementById('email');
	var nome = document.getElementById('nomecompleto');
	
	if(nome.value == "")
	{
		alert("Digite seu nome!");
		nome.focus();
		return false;	
	}
	if(!mail(email.value))
	{
		alert("O email digitado é inválido!");
		email.focus();
		return false;	
	}
	else
	{
		return true;
	}
}

function mail(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string")
	{
        if(er.test(mail))
		{ 
			return true; 
		}
    }
	else if(typeof(mail) == "object")
	{
        if(er.test(mail.value))
		{
			return true;
        }
    }
	else
	{
		return false;
    }
}


function obj(el)
{
	return document.getElementById(el);	
}
// JavaScript Document
function validaForm(form)
{	
	msg = "ok";
	for(i=0;i<form.length;i++)
	{
		if((form[i].value == "") || (form[i].value.substring(0,1)==" "))
		{
			msg = "Todos os campos so obrigatórios";
		}
	}
	
	if(msg!="ok")
	{	
		alert(msg);
		return false;
	}
	else
	{	
		//var palavra = document.getElementById('palavra');
		//window.location.href=SITE+'pesquisa/&palavra='+palavra.value;
	}

	return false;
}

function FormataValor(id,tammax,teclapres) {

if(window.event) { // Internet Explorer
	var tecla = teclapres.keyCode;
}
else if(teclapres.which) { // Nestcape / firefox
	var tecla = teclapres.which;
}

vr = document.getElementById(id).value;
vr = vr.toString().replace( "/", "" );
vr = vr.toString().replace( "/", "" );
vr = vr.toString().replace( ",", "" );
vr = vr.toString().replace( ".", "" );
vr = vr.toString().replace( ".", "" );
vr = vr.toString().replace( ".", "" );
vr = vr.toString().replace( ".", "" );
tam = vr.length;

if (tam < tammax && tecla != 8){ tam = vr.length + 1; }
if (tecla == 8 ){ tam = tam - 1; }
if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
	if ( tam <= 2 ){
		document.getElementById(id).value = vr; }
	if ( (tam > 2) && (tam <= 5) ){
		document.getElementById(id).value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ); }
	if ( (tam >= 6) && (tam <= 8) ){
		document.getElementById(id).value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ); }
	if ( (tam >= 9) && (tam <= 11) ){
		document.getElementById(id).value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ); }
	if ( (tam >= 12) && (tam <= 14) ){
		document.getElementById(id).value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ); }
	if ( (tam >= 15) && (tam <= 17) ){
		document.getElementById(id).value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam );}
	}
}

function Formata_Telefone(objeto,tammax,teclapres)
{
	var tecla = teclapres.keyCode;
	vr = objeto.value;
	vr = vr.replace( "(", "" );
	vr = vr.replace( ")", "" );
	vr = vr.replace( " ", "" );
	vr = vr.replace( "-", "" );
	tam = vr.length;
	if (tam < tammax && tecla != 8) {
		tam = vr.length + 1 ;
	}
	if (tecla == 8 ) {
		tam = tam - 1 ;
	}
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) {
		if ( tam <= 4 ) { 
			objeto.value = vr ;
		}
		if ( (tam > 4) && (tam <= 8) ) {
			objeto.value = vr.substr(0,tam-4) + '-' + vr.substr( tam - 4, tam ) ;
		}
		if ( (tam >= 9) && (tam <= 10) ) {
			objeto.value = '(' + vr.substr(0,2) + ') ' + vr.substr(2,tam-6) + '-' + vr.substr(tam-4,tam) ;			
		}
	}		
}

function verifica(valor) {

// obtendo o cpf do input //
var cpf = valor;

// obtendo cada nmero do cpf //
pos1 = cpf.substring(0,1);
pos2 = cpf.substring(1,2);
pos3 = cpf.substring(2,3);
pos4 = cpf.substring(3,4);
pos5 = cpf.substring(4,5);
pos6 = cpf.substring(5,6);
pos7 = cpf.substring(6,7);
pos8 = cpf.substring(7,8);
pos9 = cpf.substring(8,9);
pos10 = cpf.substring(9,10);
pos11 = cpf.substring(10,11);

// somando todos os nmeros do cpf //
var soma = parseFloat(pos1) + parseFloat(pos2) + parseFloat(pos3) + parseFloat(pos4) + parseFloat(pos5) + parseFloat(pos6) + parseFloat(pos7) + parseFloat(pos8) + parseFloat(pos9) + parseFloat(pos10) + parseFloat(pos11);

// resto da soma dos nmeros do cpf dividido por 11 //
total = soma % 11;

// faz verificaes para definir validade do cpf //
if(total!= 0 || cpf==00000000000 || cpf==11111111111 || cpf==22222222222 || cpf==33333333333 || cpf==44444444444 || cpf==55555555555 || cpf==66666666666 || cpf==77777777777 || cpf==88888888888 || cpf==99999999999) {
alert("CPF Invlido, tente novamente !");
return false;
} else {
document.form.submit();
}

}
