﻿/* autos */

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("E-MAIL inválido!")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("E-MAIL inválido!")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("E-MAIL inválido!")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("E-MAIL inválido!")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("E-MAIL inválido!")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("E-MAIL inválido!")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("E-MAIL inválido!")
		    return false
		 }

 		 return true					
	}
	
	
function ValidateForm(){
    var nomeID=document.automovel.nome
	if ((nomeID.value==null)||(nomeID.value=="")){
		alert("Digite seu NOME!")
		nomeID.focus()
		return false
	}
	
	var emailID=document.automovel.email
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Digite seu E-MAIL!")
		emailID.focus()
		return false
	}
	
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	
	
	var cpfID=document.automovel.cpf
	if ((cpfID.value==null)||(cpfID.value=="")){
		alert("Digite seu CPF!")
		cpfID.focus()
		return false
	}
	
	var dddfoneID=document.automovel.dddfone
	if ((dddfoneID.value==null)||(dddfoneID.value=="")){
		alert("Digite seu DDD!")
		dddfoneID.focus()
		return false
	}
	
	var foneID=document.automovel.fone
	if ((foneID.value==null)||(foneID.value=="")){
		alert("Digite seu FONE!")
		foneID.focus()
		return false
	}
	
	var niverID=document.automovel.niver
	if ((niverID.value==null)||(niverID.value=="")){
		alert("Digite sua DATA DE NASCIMENTO!")
		niverID.focus()
		return false
	}
	
	var sexoID=document.automovel.sexo
	if ((sexoID.value==null)||(sexoID.value=="")){
		alert("Selecione seu SEXO!")
		sexoID.focus()
		return false
	}
	
	var civilID=document.automovel.civil
	if ((civilID.value==null)||(civilID.value=="")){
		alert("Selecione seu ESTADO CIVIL!")
		civilID.focus()
		return false
	}
	
	var marcaID=document.automovel.marca
	if ((marcaID.value==null)||(marcaID.value=="")){
		alert("Selecione a MARCA de seu veículo!")
		marcaID.focus()
		return false
	}

	var modeloID=document.automovel.modelo
	if ((modeloID.value==null)||(modeloID.value=="")){
		alert("Digite o nome do MODELO de seu veículo!")
		modeloID.focus()
		return false
	}








	
}
	
	


