Array.prototype.contains = function (element) {
	for (var i = 0; i < this.length; i++) {
		if (this[i] == element) {
			return true;
		}
	}
	return false;
};




function validate(lang) {
	
	// 0.	Taal
	switch(lang) {
		case "nl":
			var remark_txt = "OPMERKING: ";
			var verplicht_txt = "* = verplichte velden";
			break;
		case "fr":
			var remark_txt = "REMARQUE: ";
			var verplicht_txt = "* = champs obligatoires";
			break;
	}
	
	
	// 1.	Settings
	x = document.getElementById("frmNuytten");
	errormessage = "";
	submitOK = "True";
	
	
	// 2.	Values
	bedrijf = x.bedrijf.value;
	bedrijf = bedrijf.replace(/\s+$|^\s*/gi, "");
	naam = x.naam.value;
	naam = naam.replace(/\s+$|^\s*/gi, "");
	voornaam = x.voornaam.value;
	voornaam = voornaam.replace(/\s+$|^\s*/gi, "");
	functie = x.functie.value;
	functie = functie.replace(/\s+$|^\s*/gi, "");
	straat = x.straat.value;
	straat = straat.replace(/\s+$|^\s*/gi, "");
	postcode = x.postcode.value;
	postcode = postcode.replace(/\s+$|^\s*/gi, "");
	plaats = x.plaats.value;
	plaats = plaats.replace(/\s+$|^\s*/gi, "");
	land = x.land.value;
	land = land.replace(/\s+$|^\s*/gi, "");
	tel = x.tel.value;
	tel = tel.replace(/\s+$|^\s*/gi, "");
	fax = x.fax.value;
	fax = fax.replace(/\s+$|^\s*/gi, "");
	email = x.email.value;
	email = email.replace(/\s+$|^\s*/gi, "");
	boodschap = x.boodschap.value;
	boodschap = boodschap.replace(/\s+$|^\s*/gi, "");
	
	
	// 3.	Set stripped values in textfields
	x.bedrijf.value = bedrijf;
	x.naam.value = naam;
	x.voornaam.value = voornaam;
	x.functie.value = functie;
	x.straat.value = straat;
	x.postcode.value = postcode;
	x.plaats.value = plaats;
	x.land.value = land;
	x.tel.value = tel;
	x.fax.value = fax;
	x.email.value = email;
	x.boodschap.value = boodschap;
	
	
	// 4.	Control content
	if (naam == "" || voornaam == "" || straat == "" || postcode == "" || plaats == "" || tel == "" || email == "" || boodschap == "") {
		submitOK = "False";
	}
	
	
	// 5.	Evaluate submitOK
	if(submitOK == "False") {
		alert(remark_txt + "\n" + verplicht_txt);
		return false;
	}
	else {
		return true;
	}
	
}
