/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

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("Het door u opgegeven emailadres klopt niet")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Het door u opgegeven emailadres klopt niet")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   alert("Het door u opgegeven emailadres klopt niet")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   alert("Het door u opgegeven emailadres klopt niet")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   alert("Het door u opgegeven emailadres klopt niet")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   alert("Het door u opgegeven emailadres klopt niet")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		   alert("Het door u opgegeven emailadres klopt niet")
		    return false
		 }

 		 return true					
	}

function ValidateNewsletterForm(){
	var emailID=document.mailinglist_signup.email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Vul uw emailadres in")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
 
 function ValidateCheckoutForm(){

	var voornaam=document.checkout.voornaam
	var achternaam=document.checkout.achternaam
	var straat=document.checkout.straat
	var huisnummer=document.checkout.huisnummer
	var postcode=document.checkout.postcode
	var woonplaats=document.checkout.woonplaats
	var telefoon=document.checkout.telefoon
	var emailID=document.checkout.email
	
	if ((voornaam.value==null)||(voornaam.value=="")){
		alert("Vul uw voornaam in")
		voornaam.focus()
		return false
	}
	
	if ((achternaam.value==null)||(achternaam.value=="")){
		alert("Vul uw achternaam in")
		achternaam.focus()
		return false
	}
	
	if ((straat.value==null)||(straat.value=="")){
		alert("Vul uw straatnaam in")
		straat.focus()
		return false
	}
	
	if ((huisnummer.value==null)||(huisnummer.value=="")){
		alert("Vul uw huisnummer in")
		huisnummer.focus()
		return false
	}
	
	
	if ((postcode.value.length=="6")||(postcode.value.length=="4")){
		// x
	} else {
		alert("Vul een geldige postcode in")
		postcode.focus()
		return false
	}
	
	if ((straat.value==null)||(straat.value=="")){
		alert("Vul uw straatnaam in")
		straat.focus()
		return false
	}
	
	if ((woonplaats.value==null)||(woonplaats.value=="")){
		alert("Vul uw woonplaats in")
		woonplaats.focus()
		return false
	}
	
	if ((telefoon.value==null)||(telefoon.value=="")){
		alert("Vul uw telefoon in")
		telefoon.focus()
		return false
	}
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Vul uw emailadres in")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
