function validateContactForm(form){
	var voornaam           = form.voornaam;
	var achternaam         = form.achternaam;
	var email              = form.email;
	var gelegenheid        = form.gelegenheid;
	var gelegenheid_anders = form.gelegenheid_anders;
	var locatie            = form.locatie;
	//var locatie_anders     = form.locatie_anders;
	var deelnemers         = form.deelnemers;
	var oSelect		   	   = document.getElementById('locatie');
	var sLocatie           = oSelect.options[oSelect.selectedIndex].text;
	
	if(!isEmpty(gelegenheid_anders) || gelegenheid.selectedIndex != 0){
		if(locatie.selectedIndex != 0){
			if(sLocatie!='Anders' || !isEmpty(form.locatie_anders)){
				if(!isEmpty(deelnemers, 'Het veld Aantal deelnemers is verplicht') && isNumeric(deelnemers, 'U dient een getal op te geven voor Aantal deelnemers')){
					if(!isEmpty(voornaam, 'Het veld Voornaam is verplicht')){
						if(!isEmpty(achternaam, 'Het veld Achternaam is verplicht')){
							if(!isEmpty(email, 'Het veld Email is verplicht')){
								if(emailValidator(email, 'Ongeldig email adres')){
									return true;	
								}	
							}
						}	
					}
				}
			}
			else{ alert("U moet een plaatsnaam opgeven voor locatie 'Anders'");}
		}
		else{ alert("U moet een locatie selecteren"); locatie.focus();}
	}
	else{ alert("U moet een gelegenheid selecteren of invullen"); gelegenheid.focus();}
	return false;
}

function isEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		if(isEmpty.arguments.length == 2) alert(helperMsg);
		//elem.focus(); // set the focus to this input
		return true;
	}
	return false;
}

function isNumeric(elem, helperMsg){
	var numericExpression = /^[1-9][0-9]*$/;
	if(elem.value.match(numericExpression)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function isAlphabet(elem, helperMsg){
	var alphaExp = /^[a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function isAlphanumeric(elem, helperMsg){
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function lengthRestriction(elem, min, max){
	var uInput = elem.value;
	if(uInput.length >= min && uInput.length <= max){
		return true;
	}else{
		alert("Please enter between " +min+ " and " +max+ " characters");
		elem.focus();
		return false;
	}
}

function emailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function handleLocatieChanged(){
	var oSelect = document.getElementById('locatie');
	if(oSelect){
		var selectedIndex = oSelect.selectedIndex;
		var sLabel = oSelect.options[selectedIndex].text;
		if(sLabel == 'Anders'){
			document.getElementById('locatie_anders').style.display='';	
		}else{
			document.getElementById('locatie_anders').style.display='none';	
		}	
	}	
}
