function Validar(theForm) {

	if (theForm.estado.value == "")
    	{
	    alert("Especifique seu estado.");
    	theForm.estado.focus();
	    return (false);
	  }  
	if (theForm.cidade.value == "")
    	{
	    alert("Especifique sua cidade.");
    	theForm.cidade.focus();
	    return (false);
	  }  
	time=new Date();
	diaAtual=time.getDate();
	mesAtual=time.getMonth();
	anoAtual=time.getYear();
	mesAtual=mesAtual+1;
	//alert(diaAtual+" "+mesAtual+" "+anoAtual);

  
  if ((theForm.ano.value == anoAtual)&&(theForm.mes.value < mesAtual))
  {
		alert("A Data de entrada informada não é válida!");
		theForm.dia.focus();
		return false;
  }

  if (((theForm.mes.value=="04") || (theForm.mes.value=="06") || (theForm.mes.value=="09") || (theForm.mes.value=="11")) && (theForm.dia.value=="31")) {


	if (theForm.mes.value=="04") {
		mostrames="abril";
	}
	else if (theForm.mes.value=="06") {
		mostrames="junho";
	}
	else if (theForm.mes.value=="09") {
		mostrames="setembro";
	}
	else if (theForm.mes.value=="11") {
		mostrames="novembro";
	}

	alert("Data inválida! "+mostrames+" tem somente 30 dias");
	theForm.dia.value="30";
	theForm.dia.focus();
	return false;

  }

if ((theForm.ano.value > theForm.anosaida.value))
  {
		alert("A Data informada não é válida!");
		theForm.ano.focus();
		return false;
  }
if ((theForm.ano.value == theForm.anosaida.value)&&(theForm.messaida.value < theForm.mes.value))
  {
		alert("A Data informada não é válida!");
		theForm.dia.focus();
		return false;
  }
if ((theForm.dia.value > theForm.diasaida.value) && (theForm.messaida.value <= theForm.mes.value) && (theForm.ano.value == theForm.anosaida.value) )
  {
		alert("A Data informada não é válida!");
		theForm.dia.focus();
		return false;
  }
if ((theForm.dia.value == theForm.diasaida.value) &&(theForm.mes.value == theForm.messaida.value) && (theForm.ano.value == theForm.anosaida.value) )
  {
		alert("A Data de saída informada não é válida!");
		theForm.diasaida.focus();
		return false;
  }
  return (true);
}

function validaCPF(cpfcompleto){
cpfcompleto=reservas.cpf.value;
//alert(cpfcompleto);
	if (cpfcompleto.length<3){
		return false;
	}else{
		valorTotal = 0;
		digitos = "";
		cpf = cpfcompleto.substring(0,cpfcompleto.length-2);
		cpf2 = cpfcompleto.substring(cpfcompleto.length-2,cpfcompleto.length);
		for(i = 0; i < 9; i++){
			valorTotal += parseInt(cpf.substring(i, i+1))*(10-i);
		}	
		valorTotal = valorTotal%11;
		if(valorTotal < 2)
			valorTotal = 0;
		else
			valorTotal = 11 - valorTotal;
		digitos += valorTotal.toString();
		valorTotal = 0;
		cpfInc = cpf+digitos;
		for(i = 0; i < 10; i++){
			valorTotal += parseInt(cpfInc.substring(i, i+1))*(11-i);
		}	
		valorTotal = valorTotal%11;
		if(valorTotal < 2)
			valorTotal = 0;
		else
			valorTotal = 11 - valorTotal;
	
		digitos += valorTotal.toString();
		if(digitos == cpf2)
			return true;
		else
			return false;
	}
}

//valida o segundo form

function validaFinal(motha) {
	
	if ((motha.nome.value == "") || (motha.email.value == "") || (motha.telefone.value == "") || (motha.endereco.value == "") || (motha.cpf.value == ""))
    	{
	    alert("Preencha os dados corretamente");
    	motha.nome.focus();
	    return false;
	 }  
	 
	 if (!(validaCPF(motha.cpf.value))) {
	 	alert("Preencha o CPF corretamente");
    	motha.cpf.focus();
	    return false;
	}
	return true;
}