function formataData(id,valor){
	var d1,d2,d3;
	if(valor){
	  d1 = valor.substring(0,2);
	  d2 = valor.substring(2,4);
	  d3 = valor.substring(4,8);
	  data = d1+"/"+d2+"/"+d3;
	  if(data.length==10){
	     document.getElementById(id).value = data;
	  }else{
	     document.getElementById(id).value = '';
	  }
	}
}
function formataData2(id,valor){
	var d1,d2,d3,b1,b2;
	if(valor){
	  d1 = valor.substring(0,2);
	  d2 = valor.substring(3,5);
	  d3 = valor.substring(6,10);
	  document.getElementById(id).value = d1+d2+d3;
	}
}

function Teclas(id,valor){
	if(valor.length==2){
		if(id=='DataChegada1'){
  			document.getElementById('DataChegada2').focus();
		}else if(id=='DataChegada2'){
		    document.getElementById('DataChegada3').focus();
		}else if(id=='DataSaida1'){
		    document.getElementById('DataSaida2').focus();
		}else if(id=='DataSaida2'){
		    document.getElementById('DataSaida3').focus();
		}
  	}else if(valor.length==4){
		if(id=='DataChegada3'){
		    document.getElementById('DataSaida1').focus();
		}	
	}
}

function Ano(valor,id){
    data = new Date();
	if(valor.length<4 || valor<data.getYear()){
	   alert('O "Ano" está incorreto');
	   document.getElementById(id).value="";
	   document.getElementById(id).focus();
	}
}

function ValidaEmail(){
		var nome,email,telefone,endereco,bairro,cidade,estado,cep;
		nome = eval('document.getElementById("Nome")');
		email = eval('document.getElementById("Email")');
		telefone = eval('document.getElementById("Telefone")');
		endereco = eval('document.getElementById("Endereco")');
		bairro = eval('document.getElementById("Bairro")');
		cidade = eval('document.getElementById("Cidade")');
		estado = eval('document.getElementById("Estado")');
		cep = eval('document.getElementById("Cep")');
		sexo = eval('document.getElementById("Sexo")');
		
	    m = email.value;
		if(!nome.value){
		   alert('O campo "Nome" precisa ser preenchido corretamente'); 
		   nome.focus();
		}else if(!email.value || m.indexOf('@')<3 || m.indexOf('.com')<3){
		   alert('O campo "Email" está incorreto'); 
		   email.focus();
		}else if(!telefone.value){
		   alert('O campo "Telefone" está incorreto'); 
		   telefone.focus();
		}else if(!sexo.value){
		   alert('O campo "Sexo" está incorreto'); 
		   sexo.focus();
		}else if(!endereco.value){
		   alert('O campo "Endereço" está incorreto'); 
		   endereco.focus();
		}else if(!bairro.value){
		   alert('O campo "Bairro" está incorreto'); 
		   bairro.focus();
		}else if(!cidade.value){
		   alert('O campo "Cidade" está incorreto'); 
		   cidade.focus();
		}else if(!estado.value){
		   alert('O campo "Estado" está incorreto'); 
		   estado.focus();
		}else if(!cep.value){
		   alert('O campo "Cep" está incorreto'); 
		   cep.focus();
		
		}else{
		   document.getElementById('FormAtelier').submit();
		}
}
