function dg(elem) {
	return document.getElementById(elem);
}
function checkEmptyField(fieldName) {
	var emptyString = /^\s*$/ ;
	if(emptyString.test(document.getElementById(fieldName).value)) {
		document.getElementById(fieldName).className = "textbox_error";
		return true;
	} else {
		document.getElementById(fieldName).className = "textbox";
		return false;
	}
}
function checkEmailField(fieldName) {
	var emailString = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
	if(!emailString.test(document.getElementById(fieldName).value)) {
		document.getElementById(fieldName).className = "textbox_error";
		return true;
	} else {
		document.getElementById(fieldName).className = "textbox";
		return false;
	}
}
function checkPCField(fieldName) {
	var postcode = document.getElementById(fieldName).value;
	postcode = postcode.toUpperCase();
	postcode = postcode.replace(" ","");
	var postcodeString = /^[1-8]{1}[0-9]{3}[A-Z]{2}$/;
	if(!postcodeString.test(postcode)) {
		document.getElementById(fieldName).className = "textbox_error";
		return true;
	} else {
		document.getElementById(fieldName).className = "textbox";
		return false;
	}
}
function isNumberKey(evt) {
	var charCode = (evt.which) ? evt.which : evt.keyCode;
	if (charCode > 31 && (charCode < 48 || charCode > 57)) {
		return false;
	}
	return true;
}
function changePlaats() {
	var plaats = document.getElementById("plaats").value;
	document.location = "/Woning-Huren/Pagina-1/"+plaats+"/";
}
function popUpWoningtracker(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=570,left = 390,top = 195');");
}
function popUpReageer(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=325,height=400,left = 290,top = 155');");
}
function popUpTipEenVriend(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=325,height=310,left = 290,top = 155');");
}
function popUpPrintversie(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=500,left = 290,top = 155');");
}
function ccForm() {
	var aantal_fouten = 0;
	var focusveld = "";
	var code = dg("code").value;
	if(code.toUpperCase() != "HHPM") {
		aantal_fouten++;
		focusveld = "code";
		dg("code").className = "textbox_error";
	} else {
		dg("code").className = "textbox";
	}
	if(checkEmptyField("vh_opmerking")) { aantal_fouten++; focusveld = "vh_opmerking"; }
	if(checkEmptyField("vh_plaats")) { aantal_fouten++; focusveld = "vh_plaats"; }
	if(checkEmptyField("vh_telefoonnummer")) { aantal_fouten++; focusveld = "vh_telefoonnummer"; }
	if(checkEmptyField("vh_mailadres")) { aantal_fouten++; focusveld = "vh_mailadres"; }
	else if(checkEmailField("vh_mailadres")) { aantal_fouten++; focusveld = "vh_mailadres"; }
	if(checkEmptyField("vh_naam")) { aantal_fouten++; focusveld = "vh_naam"; }
	if(focusveld != "") {
		dg(focusveld).focus();
	}
	return aantal_fouten == 0;
}
function verhuurForm() {
	var aantal_fouten = 0;
	var focusveld = "";
	var code = dg("code").value;
	if(code.toUpperCase() != "HHPM") {
		aantal_fouten++;
		focusveld = "code";
		dg("code").className = "textbox_error";
	} else {
		dg("code").className = "textbox";
	}
	if(checkEmptyField("vh_opmerking")) { aantal_fouten++; focusveld = "vh_opmerking"; }
	if(checkEmptyField("vh_plaats")) { aantal_fouten++; focusveld = "vh_plaats"; }
	if(checkEmptyField("vh_telefoonnummer")) { aantal_fouten++; focusveld = "vh_telefoonnummer"; }
	if(checkEmptyField("vh_mailadres")) { aantal_fouten++; focusveld = "vh_mailadres"; }
	else if(checkEmailField("vh_mailadres")) { aantal_fouten++; focusveld = "vh_mailadres"; }
	if(checkEmptyField("vh_naam")) { aantal_fouten++; focusveld = "vh_naam"; }
	if(focusveld != "") {
		dg(focusveld).focus();
	}
	return aantal_fouten == 0;
}
function cleanForm() {
	var aantal_fouten = 0;
	var focusveld = "";
	var code = dg("code").value;
	if(code.toUpperCase() != "HHPM") {
		aantal_fouten++;
		focusveld = "code";
		dg("code").className = "textbox_error";
	} else {
		dg("code").className = "textbox";
	}
	if(checkEmptyField("ct_bericht")) { aantal_fouten++; focusveld = "ct_bericht"; }
	if(checkEmptyField("ct_email")) { aantal_fouten++; focusveld = "ct_email"; }
	else if(checkEmailField("ct_email")) { aantal_fouten++; focusveld = "ct_email"; }
	if(checkEmptyField("ct_phone")) { aantal_fouten++; focusveld = "ct_phone"; }
	if(checkEmptyField("ct_plaats")) { aantal_fouten++; focusveld = "ct_plaats"; }
	if(checkEmptyField("ct_adres")) { aantal_fouten++; focusveld = "ct_adres"; }
	if(checkEmptyField("ct_naam")) { aantal_fouten++; focusveld = "ct_naam"; }
	if(focusveld != "") {
		dg(focusveld).focus();
	}
	return aantal_fouten == 0;
}
function contactForm() {
	var aantal_fouten = 0;
	var focusveld = "";
	var code = dg("code").value;
	if(code.toUpperCase() != "HHPM") {
		aantal_fouten++;
		focusveld = "code";
		dg("code").className = "textbox_error";
	} else {
		dg("code").className = "textbox";
	}
	if(checkEmptyField("ct_bericht")) { aantal_fouten++; focusveld = "ct_bericht"; }
	if(checkEmptyField("ct_email")) { aantal_fouten++; focusveld = "ct_email"; }
	else if(checkEmailField("ct_email")) { aantal_fouten++; focusveld = "ct_email"; }
	if(checkEmptyField("ct_phone")) { aantal_fouten++; focusveld = "ct_phone"; }
	if(checkEmptyField("ct_naam")) { aantal_fouten++; focusveld = "ct_naam"; }
	if(focusveld != "") {
		dg(focusveld).focus();
	}
	return aantal_fouten == 0;
}
function klachtForm() {
	var aantal_fouten = 0;
	var focusveld = "";
	var code = dg("code").value;
	if(code.toUpperCase() != "HHPM") {
		aantal_fouten++;
		focusveld = "code";
		dg("code").className = "textbox_error";
	} else {
		dg("code").className = "textbox";
	}
	if(checkEmptyField("ct_bericht")) { aantal_fouten++; focusveld = "ct_bericht"; }
	if(checkEmptyField("ct_email")) { aantal_fouten++; focusveld = "ct_email"; }
	else if(checkEmailField("ct_email")) { aantal_fouten++; focusveld = "ct_email"; }
	if(checkEmptyField("ct_phone")) { aantal_fouten++; focusveld = "ct_phone"; }
	if(checkEmptyField("ct_plaats")) { aantal_fouten++; focusveld = "ct_plaats"; }
	if(checkEmptyField("ct_pc")) { aantal_fouten++; focusveld = "ct_pc"; }
	if(checkEmptyField("ct_nummer")) { aantal_fouten++; focusveld = "ct_nummer"; }
	if(checkEmptyField("ct_straat")) { aantal_fouten++; focusveld = "ct_straat"; }
	if(checkEmptyField("ct_naam")) { aantal_fouten++; focusveld = "ct_naam"; }
	if(focusveld != "") {
		dg(focusveld).focus();
	}
	return aantal_fouten == 0;
}
function inschrijfForm() {
	var aantal_fouten = 0;
	var focusveld = "";

	if(dg("voorwaardenGelezen").checked == false) {
		aantal_fouten++;
		dg("voorwaarden_box").style.border = "1px solid red";
	} else {
		dg("voorwaarden_box").style.border = "";
	}
	if(dg("selectPlaats1").value == "") {
		aantal_fouten++;
		dg("plaats1_box").style.border = "1px solid red";
	} else {
		dg("plaats1_box").style.border = "";
	}
	if(checkEmptyField("salaris")) { aantal_fouten++; focusveld = "salaris"; }
	if(checkEmptyField("emailAdres")) { aantal_fouten++; focusveld = "emailAdres"; }
	else if(checkEmailField("emailAdres")) { aantal_fouten++; focusveld = "emailAdres"; }
	if(checkEmptyField("telefoonMobiel")) { aantal_fouten++; focusveld = "telefoonMobiel"; }
	if(checkEmptyField("geboorteplaats")) { aantal_fouten++; focusveld = "geboorteplaats"; }
	if(checkEmptyField("geboortedatum")) { aantal_fouten++; focusveld = "geboortedatum"; }
	if(checkEmptyField("woonplaats")) { aantal_fouten++; focusveld = "woonplaats"; }
	if(checkEmptyField("postcode")) { aantal_fouten++; focusveld = "postcode"; }
	if(checkEmptyField("straat")) { aantal_fouten++; focusveld = "straat"; }
	if(checkEmptyField("achternaam")) { aantal_fouten++; focusveld = "achternaam"; }
	if(checkEmptyField("voorletters")) { aantal_fouten++; focusveld = "voorletters"; }

	if(focusveld != "") {
		dg(focusveld).focus();
	}
	return aantal_fouten == 0;
}
