// JavaScript Document

function toggle( targetId ){
	if (document.getElementById){
		target = document.getElementById( targetId );
		
		if (target.style.display == "none"){
			target.style.display = "";
		} else {
			target.style.display = "none";
		}
	}
}

function getYearDate() {

	var d = new Date();
	document.write(d.getFullYear());
}

function isValidEmail(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		return false
	 }

	 return true					
}

function verifyNewsletter() {
	
	var themessage = "U moet de volgende verplichte velden invoeren: ";
	if (document.signupNewsletter.email.value=="") {
		themessage = themessage + " - E-mail";
	} else if (!isValidEmail(document.signupNewsletter.email.value)) {
		themessage = themessage + " - E-mail";
	}
	
	//alert if fields are empty and cancel form submit
	if (themessage == "U moet de volgende verplichte velden invoeren: ") {
		document.signupNewsletter.submit();
	}
	else {
		alert(themessage);
		return false;
	}
	
}

function verifyMail(language) {
	
	if (language=="nl") {
	
		var themessage = "U moet de volgende verplichte velden invoeren: ";
		if (document.mailSend.name.value=="") {
			themessage = themessage + " - Naam";
		}
		if (document.mailSend.email.value=="") {
			themessage = themessage + " -  E-mail";
		}
		if (document.mailSend.message.value=="") {
			themessage = themessage + " -  Bericht";
		}
		if (document.mailSend.security_code.value=="") {
			themessage = themessage + " -  Beveiligingscode";
		}
		
		//alert if fields are empty and cancel form submit
		if (themessage == "U moet de volgende verplichte velden invoeren: ") {
			document.mailSend.submit();
		}
		else {
			alert(themessage);
			return false;
		}
		
	} else if (language=="en") {
	
		var themessage = "The following fields are required: ";
		if (document.mailSend.name.value=="") {
			themessage = themessage + " - Name";
		}
		if (document.mailSend.email.value=="") {
			themessage = themessage + " -  Email";
		}
		if (document.mailSend.message.value=="") {
			themessage = themessage + " -  Message";
		}
		if (document.mailSend.security_code.value=="") {
			themessage = themessage + " -  Security code";
		}
		
		//alert if fields are empty and cancel form submit
		if (themessage == "The following fields are required: ") {
			document.mailSend.submit();
		}
		else {
			alert(themessage);
			return false;
		}
	
	}
}

function verifyEvent() {
	
	var themessage = "U moet de volgende verplichte velden invoeren: ";
	if (document.eventForm.surname.value=="") {
		themessage = themessage + " - Voornaam";
	}
	if (document.eventForm.lastname.value=="") {
		themessage = themessage + " -  Achternaam";
	}
	if (document.eventForm.address.value=="") {
		themessage = themessage + " -  Adres";
	}
	if (document.eventForm.zip.value=="") {
		themessage = themessage + " -  Postcode";
	}
	if (document.eventForm.city.value=="") {
		themessage = themessage + " - Plaats";
	}
	if (document.eventForm.phone.value=="") {
		themessage = themessage + " - Telefoon";
	}
	if (document.eventForm.email.value=="") {
		themessage = themessage + " - E-mail";
	}
	
	//alert if fields are empty and cancel form submit
	if (themessage == "U moet de volgende verplichte velden invoeren: ") {
		document.eventForm.submit();
	}
	else {
		alert(themessage);
		return false;
	}
		
}