// JavaScript Document

function checkformulier(){
	if (document.contactform.naam.value == "") { alert("Vul uw naam in."); document.contactform.naam.focus(); return (false); }
	if (document.contactform.adres.value == "") { alert("Vul uw adres in."); document.contactform.adres.focus(); return (false); }
	if (document.contactform.postcode.value == "") { alert("Vul uw postcode in."); document.contactform.postcode.focus(); return (false); }
	if (document.contactform.plaats.value == "") { alert("Vul uw plaats in."); document.contactform.plaats.focus(); return (false); }
	if (document.contactform.tel.value == "") { alert("Vul uw telefoonnummer in."); document.contactform.tel.focus(); return (false); }
	
	if (document.contactform.email.value == "") { alert("Vul uw email in."); document.contactform.email.focus(); return (false); }
	if (document.contactform.email.value != "") { ValidateForm(); }	
	if (document.contactform.bericht.value == "") { alert("Vul uw bericht in."); document.contactform.bericht.focus(); return (false); }
document.contactform.submit();
}

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("Ongeldig emailadres!")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Ongeldig emailadres!")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Ongeldig emailadres!")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Ongeldig emailadres!")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Ongeldig emailadres!")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Ongeldig emailadres!")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Ongeldig emailadres!")
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var emailID=document.contactform.email
	
	/*if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}*/
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	//return true
 }
