function gotopage(url) {
	this.location.href = url;
}
// IE does not know hovering for non-A elements...
navHover = function() {
  if (! document.getElementById("navmenu")) return;
  var lis = document.getElementById("navmenu").getElementsByTagName("LI");
  for (var i=0; i<lis.length; i++) {
    lis[i].onmouseover=function() {
      this.className +=" navhover";
    }
    lis[i].onmouseout=function() {
      this.className = this.className.replace(new RegExp(" navhover\\b"), "");
    }
  }
}
if (window.attachEvent) window.attachEvent("onload", navHover);

function trim(str) {
	return str.replace(/^\s*|\s*$/g,"");
}
function validateEnrolForm1(theform) {
	var requiredfields = Array();
	// either companyname or first and last name should be entered
	if (theform.companyname.value == '') {
		requiredfields['firstname']	= 'voornaam';
		requiredfields['lastname']	= 'achternaam';
	}
	requiredfields['street']	= 'adres';
	requiredfields['postalcode']	= 'postcode';
	requiredfields['city']		= 'plaats';
//	requiredfields['phonenumber']	= 'telefoonnummer';
	requiredfields['email']		= 'e-mail-adres';
	var msg = '';
		
	for (i in requiredfields) {
		if (theform[i].value == '') {
			msg += "Het veld '" + requiredfields[i] + "' is niet ingevuld.\n";
		}
	}
	if (theform.homepage.value.match(/^http:\/\/(.*)/i)) {
		theform.homepage.value = RegExp.$1;
	}
	if (trim(theform.postalcode.value).match(/^(\d{4}) ?([A-Z]{2})$/i)) {
		theform.postalcode.value = trim(theform.postalcode.value);
		// allow entry nnnnxx and nnnn xx
		// konqueror does not understand RegExp.$1 etc.
		// form.postalcode.value = RegExp.$1 + ' ' + RegExp.$2.toUpperCase();
		if (theform.postalcode.value.substr(4,1) != ' ') {
			theform.postalcode.value = theform.postalcode.value.substr(0,4) + ' ' + theform.postalcode.value.substr(4,2).toUpperCase();
		}
		else {
			theform.postalcode.value = theform.postalcode.value.toUpperCase();
		}
	}
	else if (theform.postalcode.value != '') {
		msg += "Als postcode is ingevuld '" + theform.postalcode.value + "'. Dit is niet correct!\n";
	}
	if (theform.email.value != '' && theform.email.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1) {
		msg += "Het veld 'e-mail-adres' is niet correct ingevuld.\n";
	}
	if (msg != '') {
		msg = "Het formulier is nog niet volledig!\n\n" + msg
		alert(msg);
		return false;
	}
	return true;
}
function validateEnrolForm2(theform) {
	if (theform.capcha.value == '') {
		alert("Vul de getoonde code in!");
		return false;
	}
	return true;
}
function shownewsletterform() {
	document.getElementById('newslettercontent').style.display = 'none';
	document.getElementById('newsletterconfirmation').style.display = 'none';
	document.getElementById('newsletterform').style.display = 'block';
	setHeightForContent();
}
function validateNewsletterform(theform) {
	var msg = '';
	if (theform.email.value == '') {
		msg += "Het veld 'email' is niet ingevuld.\n";
	}
	else if (theform.email.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1) {
		msg += "Het veld 'email' is niet correct ingevuld.\n";
	}
	if (theform.capcha.value == '') {
		msg += "De code uit het plaatje is niet ingevuld.\n";
	}
	if (msg != '') {
		msg = "Het formulier is nog niet volledig!\n\n" + msg
		alert(msg);
		return false;
	}
	return true;
}
function getIframeDocument(theiframe) {
	if 	(theiframe.contentWindow)	return theiframe.contentWindow.document;
	else if (theiframe.contentDocument)	return theiframe.contentDocument;
}
/*
function showarea(area) {
	area = area.replace(/ /g, "_");
	var item = document.getElementById("themap");
	item.src = "../overzichtkaartjes/" + area + ".jpg";
	item.title = "Klik voor de detailkaart";
	item.alt = "Klik voor de detailkaart";
	item.onclick = function() { swaparea(this); }
	document.getElementById("instruction").innerHTML = 'Klik op de kaart voor de detailkaart';
}
function showareainframe(mapid,area) {
	var areaname = area;
	area = area.replace(/ /g, "_");

	var ifdoc = getIframeDocument(document.getElementById("mapholder"));
	if (ifdoc.getElementById("bigmap").style.display == 'none') {
		ifdoc.getElementById("bigmap").style.display = 'block';
	}

	if (ifdoc.getElementById("themap")) {
		ifdoc.getElementById("themap").style.display = 'none';
	}
	// if bigmap is displayed, then we highlight the area
	var item = ifdoc.getElementById("bigmap");
		
	var thetext;
	if (mapid == 0)	thetext = "Klik op een buurtnaam in het linkergedeelte";
	else		thetext = "Klik op de kaart om de detailkaart van '" + areaname + "' te zien";
	item.title = thetext;
	item.alt = thetext;
	document.getElementById("instruction").innerHTML = thetext;
	item.onclick = function() { swapareainframe(mapid); }
	var allimages = ifdoc.images;
	for (var i = 0; i < allimages.length; i++) {
		if (allimages[i].className == 'himap') {
			allimages[i].style.display = 'none';
		}
	}
	if (mapid > 0) {
		ifdoc.getElementById(area).style.display = 'inline';
		ifdoc.getElementById(area).onclick = function() { swapareainframe(mapid); }
		setHeightForContent();
	}
}
function swapareainframe(mapid) {
	var thelocation;
	if (document.getElementById("mapholder").contentWindow) {
		thelocation = document.getElementById("mapholder").contentWindow.location;
	}
	else if (document.getElementById("mapholder").contentDocument) {
		thelocation = document.getElementById("mapholder").contentDocument.location;
	}
	thelocation.href = "plattegrond_content.php?mapid=" + mapid;
	document.getElementById("instruction").innerHTML = "De locatiepunten worden weergegeven door paars-roze blokjes.<br/>Ga met je muis naar een locatiepunt voor een beschrijving.<br/>Klik op een locatiepunt om naar de persoonlijke pagina te gaan.<br/>Om je selectie te beperken of te veranderen kun je op een categorie klikken in het rechtergedeelte.<br/>Je kunt ook op een andere buurtnaam of op 'overzichtskaart' klikken in het linkergedeelte.";
}	
function swaparea(item) {
	if (item.src.match(/\/overzichtkaartjes\//)) {
		var newsrc = item.src.replace(/overzichtkaartjes/,'detailkaartjes');
		item.src = newsrc;
		item.title = "Klik voor de overzichtskaart";
		item.alt = "Klik voor de overzichtskaart";
		item.onclick = function() { swaparea(this); }
		document.getElementById("instruction").innerHTML = 'Klik op de kaart voor de overzichtskaart';
	}
	else if (item.src.match(/\/detailkaartjes\//)) {
		var newsrc = item.src.replace(/detailkaartjes/,'overzichtkaartjes');
		item.src = newsrc;
		item.title = "Klik voor de detailkaart";
		item.alt = "Klik voor de detailkaart";
		item.onclick = function() { swaparea(this); }
		document.getElementById("instruction").innerHTML = 'Klik op de kaart voor de detailkaart';
	}
}
*/
function highlight(item) {
	var theul = item;
	if (item.nodeName.toUpperCase() == 'LI') {
		theul = item.parentNode;
	}
	var lis = theul.getElementsByTagName('li');
	// reset all items first
	for (var i = 0; i < lis.length; i++) {
		lis[i].className = lis[i].className.replace(new RegExp(" ?navselected\\b"), "");
	}
	document.getElementById("maphelper").src = "plattegrond_sessionhelp.php?mapcatid=" + item.id.substr(3);
	item.className += ' navselected';
	document.getElementById("currentcategory").innerHTML = item.innerHTML
}
function setHeightForContent() {
	var minimum = getWindowHeight() - getComputedValue(document.getElementById('ciaow'),'height') - getComputedValue(document.getElementById('pageheader'),'height');
	if (window.opera) {
		minimum -= 10;
	}
	else if (document.all) {
		minimum -= 10;
	}
	else {
		minimum -= 24;
	}
	if (document.getElementById('subpageheader')) {
		minimum -= getComputedValue(document.getElementById('subpageheader'),'height')
	}
	if (document.getElementById('monthdays')) {
		minimum -= getComputedValue(document.getElementById('monthdays'),'height')
		// IE does not understand this, but does it wrong anyway...
		if (getComputedValue(document.getElementById('monthdays'),'border-top-width'))
			minimum -= getComputedValue(document.getElementById('monthdays'),'border-top-width')
	}
	if (document.getElementById('monthname')) {
		minimum -= getComputedValue(document.getElementById('monthname'),'height')
	}
	if (document.getElementById('mapholder')) {
		minimum -= getComputedValue(document.getElementById('mapholder'),'height')
	}
	var current = getComputedValue(document.getElementById('content'),'height');
	if (minimum > current) {
		document.getElementById("content").style.height = minimum + "px";
		return minimum;
	}
	return current;
}
function show_props2(obj, obj_name) {
	var result = ""
	for (var i in obj) {
		if (i)
			result += obj_name + "." + i + " = " + obj[i] + "<br />\n"
	}
	return result
}
function addDebug(str) {
	if (! document.getElementById("debug")) {
		var debugtocreate = document.createElement("div")
		debugtocreate.id = 'debug'
		document.body.appendChild(debugtocreate)
	}
	document.getElementById("debug").innerHTML += str + "<br>"
}
function setHeightForContentCorr(corr) {
	var minimum = setHeightForContent();
	document.getElementById("content").style.height = minimum + corr + "px";
}
function getWindowHeight() {
	var windowHeight=0;
	if (typeof(window.innerHeight)=='number') {
		windowHeight=window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body&&document.body.clientHeight) {
				windowHeight=document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function getComputedValue(el,prop) {
	try {
		if (document.defaultView && document.defaultView.getComputedStyle) {
			return parseInt(document.defaultView.getComputedStyle(el,'').getPropertyValue(prop))
		}
		else if (document.all) {
			if (el.currentStyle[prop] == 'auto') {
				return el.offsetHeight;
			}
			else {
				return parseInt(el.currentStyle[prop]);
			}
		}
	} catch(e) {}
}
/*
function restorecategories() {
	var alllis = document.getElementById("categories").getElementsByTagName("li");
	for (var i = 0; i < alllis.length; i++) {
		alllis.className = 'nav';
	}
	highlight(document.getElementById("allofthem"));
}
*/
function populateSelectbox(fields,optionsObject,categorypath,level,field) {
	var storedarray = Array();
	if (categorypath && categorypath.value) 
		storedarray = categorypath.value.split("|");
	storedarray = storedarray.slice(0,level);
	var selectedoptionsarray = Array();	// for the options indexes
	var count;
	var theobject = optionsObject;

	// now hide all the fields outside the storedarray 
	for (var i = storedarray.length; i < 10; i++) {	
		if (! fields[i]) break;
		fields[i].disabled = true;
		fields[i].parentNode.parentNode.style.display = 'none';
	}
	// and replace possible 'old' stored values by current ones from the form values
	if (field) {	// field is null upon load...
		for (var i = 0; i < fields.length; i++) {
			if (fields[i]) storedarray[i] = fields[i].value;
		}
		// and store the value from the field the call originates from
		storedarray.push(field.value);
	}
	for (var field = 0; field <= fields.length; field++) {
		if (storedarray.length >= field && (field == 0 || (theobject[selectedoptionsarray[field-1]] && theobject[selectedoptionsarray[field-1]][2].length > 0))) {
			count = 0;
			// an element can hold an array of elements in its second field
			if (field > 0) 
				theobject = theobject[selectedoptionsarray[field-1]][2];
			// reset options
			fields[field].options.length = 1;
			for (var i = 0; i < theobject.length; i++) {
				// fill options from the optionsobject
				fields[field].options[++count] = new Option(theobject[i][1], theobject[i][0]);
				// for the selected item, store its index
				if (theobject[i][0] == storedarray[field]) {
					fields[field].options[count].selected = 'selected';
					selectedoptionsarray.push(count-1);
				}
			}
			fields[field].disabled = false;
			// if there's nothing to show, don't show
			if (fields[field].options.length > 1) {
				try {
					fields[field].parentNode.parentNode.style.display = 'table-row';
				} catch(e) {
					// fallback for IE, which does not support table-row
					fields[field].parentNode.parentNode.style.display = 'inline';
				}
			}
		}
	}
	// genres should only be changed upon load (level=99) and when the cat[0] changes
	if (level == 99 || level == 0) {
		populateSelectbox2(fields[0].form.cat[0],fields[0].form.gen,genres);
	}
}
function populateSelectbox2(selectSource,selectToPopulate,optionsObject) {
	// I like 'select an option' as first element, so keep it
	if (!optionsObject || typeof optionsObject[selectSource.value] != 'object') {
		selectToPopulate.parentNode.parentNode.style.display = 'none';
		if (!optionsObject) return;
	}
	selectToPopulate.options.length = 1
	if (selectSource.value == '') {
		// no selection made
		selectToPopulate.disabled = true
		return;
	}
	var count = 1
	for (var i in optionsObject[selectSource.value]) {
		selectToPopulate.options[count++] = new Option(optionsObject[selectSource.value][i],i)
	}
	selectToPopulate.disabled = false;
	if (selectToPopulate.options.length > 1) {
		try {
			selectToPopulate.parentNode.parentNode.style.display = 'table-row';
		} catch(e) {
			// fallback for IE, which does not support table-row
			selectToPopulate.parentNode.parentNode.style.display = 'inline';
		}
	}
}
function getElementsByClassName(clsName,htmltag){ 
	var arr = new Array(); 
	var elems = document.getElementsByTagName(htmltag);
	for (var cls, i = 0; ( elem = elems[i]); i++){
		if (elem.className == clsName){
			arr[arr.length] = elem;
		}
	}
	return arr;
}
function newsletters(showthisone) {
	var currentlyloaded = document.getElementById('newsletteriframe').src
	if (currentlyloaded.match(showthisone) && document.getElementById('newslettercontent').style.display == 'block') {
		return;
	}
	document.getElementById("newsletteriframe").src = 'nieuwsbrief_' + showthisone + '.php';
	var allarrows = getElementsByClassName('arrow','img');
	for (i = 0; i < allarrows.length; i++) {
		allarrows[i].style.visibility = 'hidden';
	}
	document.getElementById("arrow_"+showthisone).style.visibility = 'visible';
	document.getElementById('newslettercontent').style.display = 'block';
	document.getElementById('newsletterconfirmation').style.display = 'none';
	document.getElementById('newsletterform').style.display = 'none';
}
function showimagemapforpeople(mapid,peopleid) {
	NewWindow('plattegrond_content.php?mapid='+mapid+'&peopleid='+peopleid,'plattegrond','600','600','no','center');
	return false;
}
function showimagemapforwoa(mapid,woaid) {
	NewWindow('plattegrond_content.php?mapid='+mapid+'&woaid='+woaid,'plattegrond','600','600','no','center');
	return false;
}
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}

// new map functions
function catmouseover(theli) {
//	ieresetlis("categories");
	theli.className += " navhover";
}
function ieresetlis(theid) {
	if (! document.getElementById(theid)) return;
	var lis = document.getElementById(theid).getElementsByTagName("li");
	for (var i=0; i<lis.length; i++) {
		lis[i].className = lis[i].className.replace(new RegExp(" ?navhover\\b"), "");
	}
}
function catmouseout(theli) {
	ieresetlis("categories");
}
function areamouseover(theid, area) {
	var alllis = document.getElementById("navmenub").getElementsByTagName("li");
	ieresetlis("navmenub");
	document.getElementById("map"+theid).className += " navhover";
	var ifdoc = getIframeDocument(document.getElementById("mapholder"));
	if (ifdoc.images && ifdoc.images.themap && ifdoc.images.themap.src.indexOf("overzicht.jpg") != -1) {
		var allimages = ifdoc.images;
		for (var i = 0; i < allimages.length; i++) {
			if (allimages[i].className == 'himap') {
				allimages[i].style.display = 'none';
			}
		}
		if (area != '') {
			ifdoc.getElementById(area.replace(/ /g, "_")).style.display = 'inline';
		}
	}
	if (document.getElementById("mapcurrent").innerHTML.indexOf(area) != -1) {
		document.getElementById("instruction").innerHTML = "Klik voor de overzichtskaart.";
		document.getElementById("instruction").style.visibility = 'visible';
	}
	else {
		document.getElementById("instruction").innerHTML = "Klik op de buurt/buurtnaam voor de kaart '" + area + "'.";
		document.getElementById("instruction").style.visibility = 'visible';
	}
}
function areamouseout(theid) {
	theid = "map" + theid;
	document.getElementById(theid).className = document.getElementById(theid).className.replace(new RegExp(" ?navhover\\b"), "");
	document.getElementById("instruction").innerHTML = "Klik op een andere buurtnaam voor een andere buurtplattegrond.";
	document.getElementById("instruction").style.visibility = 'visible';
}
function areaclick(mapid, area) {
	ieresetlis("navmenub");
	if (mapid == 0) {
		document.getElementById("areaname").innerHTML = "overzichtskaart";
	}
	else {
		document.getElementById("areaname").innerHTML = area;
	}
	var alllis = document.getElementById("navmenub").getElementsByTagName("li");
	for (var i = 0; i < alllis.length; i++) {
		if (trim(alllis[i].innerHTML) == trim(area)) {
			alllis[i].className += " navselected";
		}
		else {
			alllis[i].className = alllis[i].className.replace(new RegExp(" ?navselected\\b"), "");
		}
	}
	var thelocation;
	if (document.getElementById("mapholder").contentWindow) {
		thelocation = document.getElementById("mapholder").contentWindow.location;
	}
	else if (document.getElementById("mapholder").contentDocument) {
		thelocation = document.getElementById("mapholder").contentDocument.location;
	}
	thelocation.href = "plattegrond_content.php?mapid=" + mapid;
	if (mapid > 0) {
		document.getElementById("instructiondetail2").style.visibility = 'visible';
		//document.getElementById("instructiondetail3").style.visibility = 'visible';
	}
	else {
		document.getElementById("instructiondetail2").style.visibility = 'hidden';
		//document.getElementById("instructiondetail3").style.visibility = 'hidden';
	}
}
function areaclickf(mapid, area) {
	// called from within the map
	unhilitename(mapid);
	areaclick(mapid,area);
}
function maponload() {
	try {
		var alllis = parent.document.getElementById("categories").getElementsByTagName("li");
		for (var i = 0; i < alllis.length; i++) {
			if (alllis[i].className.match(/navselected/)) {
				parent.showdots(alllis[i].id.substr(3));
			}
		}
	} catch(e) {}
}
function hilitename(area) {
	var lis = parent.document.getElementById("navmenub").getElementsByTagName("li");
	for (var i = 0; i < lis.length; i++) {
		lis[i].className = lis[i].className.replace(new RegExp(" ?navhover\\b"), "");
		if (trim(lis[i].innerHTML) == trim(area)) {
			lis[i].className += " navhover";
		}
	}
}
function unhilitename(mapid) {
	parent.document.getElementById("map"+mapid).className = parent.document.getElementById("map"+mapid).className.replace(new RegExp(" ?navhover\\b"), "");
}
function showypos(el) {
	var daYPos = el.offsetTop;
	while(1) {
		if (!el.offsetParent) break;
		el = el.offsetParent;
		daYPos += el.offsetTop;
	}
	return daYPos;
}
