function checkEmptyField(fieldName,classNameOk,classNameError) {
	var emptyString = /^\s*$/ ;
	var hightlightClass = "ui-state-error ui-corner-all";
	var normalClass = "ui-widget-content ui-corner-all";
	if(emptyString.test(document.getElementById(fieldName).value)) {
		document.getElementById(fieldName).className = classNameError;
		return true;
	} else {
		document.getElementById(fieldName).className = classNameOk;
		return false;
	}
}
function checkEmailField(fieldName,classNameOk,classNameError) {
	var emailString = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
	var hightlightClass = "ui-state-error ui-corner-all";
	var normalClass = "ui-widget-content ui-corner-all";
	if(!emailString.test(document.getElementById(fieldName).value)) {
		document.getElementById(fieldName).className = classNameError;
		return true;
	} else {
		document.getElementById(fieldName).className = classNameOk;
		return false;
	}
}
function validateBelterugForm() {
	var errs = 0;
	if(checkEmptyField("belterug_naam","inputbox","inputbox_error")) { errs += 1; }
	if(checkEmptyField("belterug_telefoon","inputbox","inputbox_error")) { errs += 1; }
	if(checkEmptyField("belterug_betreft","inputbox","inputbox_error")) { errs += 1; }
	if(!document.getElementById("dag1").checked && !document.getElementById("dag2").checked && !document.getElementById("dag3").checked && !document.getElementById("dag4").checked && !document.getElementById("dag5").checked && !document.getElementById("dag6").checked && !document.getElementById("dag7").checked) {
		errs += 1;
		document.getElementById("dag_td").style.border = "1px solid red";
	} else {
		document.getElementById("dag_td").style.border = "";
	}
	if(!document.getElementById("tijd1").checked && !document.getElementById("tijd2").checked && !document.getElementById("tijd3").checked) {
		errs += 1;
		document.getElementById("tijd_td").style.border = "1px solid red";
	} else {
		document.getElementById("tijd_td").style.border = "";
	}
	if(checkEmptyField("belterug_captcha_code","inputbox","inputbox_error")) { errs += 1; }
	return (errs==0);
};
function validateContactForm() {
	var errs = 0;
	if(checkEmptyField("contact_naam","inputbox","inputbox_error")) { errs += 1; }
	if(checkEmptyField("contact_telefoon","inputbox","inputbox_error")) { errs += 1; }
	if(checkEmptyField("contact_email","inputbox","inputbox_error")) { errs += 1; }
	else if(checkEmailField("contact_email","inputbox","inputbox_error")) { errs += 1; }
	if(checkEmptyField("contact_bericht","inputbox","inputbox_error")) { errs += 1; }
	if(checkEmptyField("contact_captcha_code","inputbox","inputbox_error")) { errs += 1; }
	return (errs==0);
};
function validateInfoForm() {
	var errs = 0;
	if(checkEmptyField("info_naam","inputbox","inputbox_error")) { errs += 1; }
	if(checkEmptyField("info_telefoon","inputbox","inputbox_error")) { errs += 1; }
	if(checkEmptyField("info_email","inputbox","inputbox_error")) { errs += 1; }
	else if(checkEmailField("info_email","inputbox","inputbox_error")) { errs += 1; }
	if(checkEmptyField("info_bericht","inputbox","inputbox_error")) { errs += 1; }
	if(checkEmptyField("info_captcha_code","inputbox","inputbox_error")) { errs += 1; }
	return (errs==0);
};
function validateOfferteForm() {
	var errs = 0;
	if(checkEmptyField("offerte_naam","inputbox","inputbox_error")) { errs += 1; }
	if(checkEmptyField("offerte_telefoon","inputbox","inputbox_error")) { errs += 1; }
	if(checkEmptyField("offerte_email","inputbox","inputbox_error")) { errs += 1; }
	else if(checkEmailField("offerte_email","inputbox","inputbox_error")) { errs += 1; }
	if(checkEmptyField("offerte_opmerking","inputbox","inputbox_error")) { errs += 1; }
	if(checkEmptyField("offerte_captcha_code","inputbox","inputbox_error")) { errs += 1; }
	return (errs==0);
};
function load() {
	var adres = "Graaf Ansfriedstraat 42, Kerkdriel";
	var naam = "Online Identity";
	if (GBrowserIsCompatible()) {
		var geocoder = new GClientGeocoder();
		geocoder.setBaseCountryCode("nl");

		var map = new GMap2(document.getElementById("google_map"));
		map.addControl(new GMapTypeControl());
		map.addControl(new GSmallMapControl());
		map.enableDoubleClickZoom();

		var icon = new GIcon();
		icon.image = "http://www.onlineidentity.nl/images/red_marker.gif";
		icon.iconSize = new GSize(18, 30);
		icon.iconAnchor = new GPoint(6, 20);
		icon.infoWindowAnchor = new GPoint(5, 1);
		showAddress(map,geocoder,adres,naam,icon);
	}
}
function showAddress(map,geocoder,adres,naam,icon) {
	geocoder.getLatLng(
		adres,
		function(point) {
			if (!point) {
				alert(adres + " niet gevonden");
			} else {
				var marker = new GMarker(point,icon);
				GEvent.addListener(marker,"click",function() {
					marker.openInfoWindowTabsHtml("<div class='markerPlanuwroute' style='color:#000000;'><form action='http://maps.google.nl/maps' method='get' target='_blank' class='markerPlanuwroute'><div class='markerPlanuwroute'>Plan uw route naar "+naam+"</div><label for='saddr'><b>Vertrekadres:</b></label><br /><input name='saddr' id='saddr' size='30' type='text'/><input value='Berekenen' type='submit' /><input name='daddr' value='"+adres+"' type='hidden'/><input name='hl' value='nl' type='hidden'/><address>Voorbeeld: Straat 1, Plaats</address></form></div>");
				});
				map.addOverlay(marker);
				map.setCenter(point, 13);
			}
		});
}
