var formatEmail = /^[^@\s]+\@[^@\s]+\.[^@\s]+/;
var formatPhone = /^\d{2,4}[ -]{0,1}\d{6,8}$/;

function addFile(id) {
	document.form1.action = "add_image.php?id="+id;
	document.form1.submit();
}

function addUser() {
	document.form1.action = "add_user.php?";
	document.form1.submit();
}

function addJob(id) {
	document.form1.action = "add_job.php?id="+id;
	document.form1.submit();
}

function textboxFilled(Field) {
	var value = Field.value;
	if (value == "") {
		//alert(errorMessage);
		//Field.focus();
		return false;
	}
	return true;
}

function textareaFilled(Field) {
	var value = Field.value;
	if (value == "") {
		//alert(errorMessage);
		//Field.focus();
		return false;
	}
	return true;
}

function checkDay(dag) {
 
}



function finalSubmit() {
	document.form1.action = "bedankt.php";
	document.form1.submit();
}

function isValid(Field, format) {
	var value = Field.value;
	if (! format.test(value)) {
		//alert(errorMessage);
		//Field.focus();
		return false;
	}
	return true;
}
function checkValues() {
	
 var tweeVariatie = /^[0-2][0-9]$/;
 var twee = /^[3][0-1]$/;
 var een = /^[1-9]$/;
 
 var maandtweeVariatie = /^[0][0-9]$/;
 var maandtwee = /^[0-1][0-2]$/;
 var maandeen = /^[1-9]$/;
 
	errorMsg = "Alle velden moeten (correct) ingevuld worden.";
	error = 0;
	if (!textboxFilled(document.form1.naam)) {
		error = 1;
		document.getElementById("naamtxt").style.color = "#FF3333";
	}else {
		document.getElementById("naamtxt").style.color = "#606969";
	}
	if (!isValid(document.form1.email, formatEmail)) {
		error = 1;
		document.getElementById("emailtxt").style.color = "#FF3333";
	} else {
				document.getElementById("emailtxt").style.color = "#606969";
	}
	if (document.getElementById("recensie").value == "") {
		error = 1;
		document.getElementById("recensietxt").style.color = "#FF3333";
	}else {
		document.getElementById("recensietxt").style.color = "#606969";
	}
	
	
	
	if (document.getElementById("vestiging").value == "geen") {
		error = 1;
		document.getElementById("bezoektxt").style.color = "#FF3333";
	}else {
		document.getElementById("bezoektxt").style.color = "#606969";
	}
	

 
 if (document.getElementById("dag").value.match(twee)) {
	 		document.getElementById("datumtxt").style.color = "#606969";
 } 
 else if(document.getElementById("dag").value.match(een)) {
	 		document.getElementById("datumtxt").style.color = "#606969";
 }
  else if(document.getElementById("dag").value.match(tweeVariatie)) {
		document.getElementById("datumtxt").style.color = "#606969";	  
 }
 else {
	 		error = 1;
document.getElementById("datumtxt").style.color = "#FF3333";
 }
 
  if (document.getElementById("maand").value.match(maandtwee)) {
	 		document.getElementById("datumtxt").style.color = "#606969";
 } 
 else if(document.getElementById("maand").value.match(maandeen)) {
	 		document.getElementById("datumtxt").style.color = "#606969";
 }
  else if(document.getElementById("maand").value.match(maandtweeVariatie)) {
		document.getElementById("datumtxt").style.color = "#606969";	  
 }
 else {
	 		error = 1;
document.getElementById("datumtxt").style.color = "#FF3333";
 }
	
	

	if (document.getElementById("akkoord").checked == 1 ) {
		document.getElementById("akkoordtxt").style.color = "#606969";
		document.getElementById("akkoordtxt2").style.color = "#606969";
		
	}else {
		error = 1;
		document.getElementById("akkoordtxt").style.color = "#FF3333";
				document.getElementById("akkoordtxt2").style.color = "#FF3333";
	}
	
	if (error != 1) {
		finalSubmit();
	}
}