function checkInput() {
	var Naam = document.form1.fNaam.value;
	var Wachtwoord = document.form1.fWachtwoord.value;
	var Email = document.form1.fEmail.value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	var code = document.form1.fCode.value;

	if (!Naam) {
		alert("U bent vergeten uw naam in te vullen!");
		return false;
	}
	if (!filter.test(Email)){
		alert("U moet een geldig e-mail adres invullen!");
		return false;
	}
	if (Wachtwoord.length < 5){
		alert("U moet minimaal een wachtwoord van vijf karakters invullen!");
		return false;
	}
	makeRequest('/class/challenge.php?fCode='+code+'');
	return false;
}

function enforcechar(what,limit){
	if (what.value.length >= limit){
		return false;
	}
}

// Ajax
var xhr = false;
var textRequest = true;

function makeRequest(url) {
	if (window.XMLHttpRequest) {
		xhr = new XMLHttpRequest();
	}else{
		if (window.ActiveXObject) {
			try {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) { }
		}
	}

	if (xhr) {
		xhr.onreadystatechange = showContents;
		xhr.open("GET", url, true);
		xhr.send(null);
	}else{
		// document.getElementById("output").innerHTML = "Sorry, but I couldn't create an XMLHttpRequest";
	}
}

function showContents() {
	if (xhr.readyState == 4) {
		if (xhr.status == 200) {
			// var outMsg = (textRequest) ? xhr.responseText : xhr.responseXML;
			if(xhr.responseText && xhr.responseText == 'good'){
				document.form1.submit();
			}else{
				alert('De ingevoerde code is niet juist!');
				return false;
			}
		}else{
			// var outMsg = "There was a problem with the request " + xhr.status;
		}
		// document.getElementById("output").innerHTML = outMsg;
	}
}

