pageLoaded = false;
hasFocus = false;
h = 0;
w = 0;
coorX = 0;
coorY = 0;
coorXo = 0; //check if there's still movement
// handy functions
if (!document.all) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;

function onBodyLoad(modus){
	if (modus == ''){
		MM_findObj('fotoband').removeChild[0];
	}
	h = document.body.clientHeight || window.innerHeight || document.body.offsetHeight;
	w = document.body.clientWidth || window.innerWidth || document.body.offsetWidth;
	if (modus == ''){
		togglemenu(0);
		MM_findObj('imgVOELEN').style.width = w/3;
		MM_findObj('imgDENKEN').style.width = w/3;
		MM_findObj('imgDOEN').style.width = w/3;
		loadfotoband();
	}else{
		if (!pageLoaded) setInterval('checkmenu();',100);
		if (MM_findObj('imgVOELEN')) MM_findObj('imgVOELEN').style.width = w*0.05;
		if (MM_findObj('imgDENKEN')) MM_findObj('imgDENKEN').style.width = w*0.05;
		if (MM_findObj('imgDOEN')) MM_findObj('imgDOEN').style.width = w*0.05;
	}
	if (findPosY(MM_findObj('endofcontent')) + 30 > h){ //30 = 14 + 2 x 8 (height + margins of a p)
		MM_findObj('pagebackgrounddiv').style.height = (findPosY(MM_findObj('endofcontent')) + 60) + 'px';
	}
	pageLoaded = true;
	//set cursor to first form field if there is one
	if (document.forms.length > 0){
		document.forms[0].elements[0].focus();
	}
	//load illustrations into a frame
	images = document.getElementsByTagName('IMG');
	for (ii = 0; ii < images.length; ii++){
		if (images[ii].className == 'illustration'){
			//remove old frame for resize, if exists
			if (MM_findObj('frame'+ii)){
				MM_findObj('pagebackgrounddiv').removeChild(MM_findObj('frame'+ii));
			}
			img = images[ii];
			imgwidth = img.offsetWidth;
			imgheight = img.offsetHeight;
			imgx = findPosX(img);
			imgy = findPosY(img);
			frame = document.createElement('DIV');
			frame.id = 'frame' + ii;
			frame.style.position = 'absolute';
			frame.style.top = parseInt(imgy) - 22 + 'px';
			frame.style.height = parseInt(imgheight) + 44 + 'px';
			frame.style.left = parseInt(imgx) - 22 + 'px';
			frame.style.width = parseInt(imgwidth) + 44 + 'px';
			frame.style.backgroundColor = '#666666';
			frame.style.filter = 'alpha(opacity=25)';
			frame.style.MozOpacity = 0.25;
			frame.style.opacity = 0.25;
			MM_findObj('pagebackgrounddiv').appendChild(frame);
		}
	}
	//load lighter background behind tableschemes
	tables = document.getElementsByTagName('TABLE');
	for (ii = 0; ii < tables.length; ii++){
		if (tables[ii].className == 'tablescheme'){
			//remove old frame for resize, if exists
			if (MM_findObj('table'+ii)){
				MM_findObj('pagebackgrounddiv').removeChild(MM_findObj('table'+ii));
			}
			tbl = tables[ii];
			tblwidth = tbl.offsetWidth;
			tblheight = tbl.offsetHeight;
			tblx = findPosX(tbl);
			tbly = findPosY(tbl);
			frame = document.createElement('DIV');
			frame.id = 'table' + ii;
			frame.style.position = 'absolute';
			frame.style.top = parseInt(tbly) + 'px';
			frame.style.height = parseInt(tblheight) + 'px';
			frame.style.left = parseInt(tblx) + 'px';
			frame.style.width = parseInt(tblwidth) + 'px';
			frame.style.backgroundColor = '#ffffff';
			frame.style.filter = 'alpha(opacity=20)';
			frame.style.MozOpacity = 0.2;
			frame.style.opacity = 0.2;
			MM_findObj('pagebackgrounddiv').appendChild(frame);
		}
	}
}

function togglemenu(which){
	if (pageLoaded){
		menuBackground = MM_findObj('menubackground');
		menuBackground.style.top = -400;
		MM_findObj('menu1').style.display = 'none';
		MM_findObj('imgVOELEN').src = 'img/VOELEN horizontaal.png';
		MM_findObj('menu2').style.display = 'none';
		MM_findObj('imgDENKEN').src = 'img/DENKEN horizontaal.png';
		MM_findObj('menu3').style.display = 'none';
		MM_findObj('imgDOEN').src = 'img/DOEN horizontaal.png';
		switch (which){
			case 1:
				MM_findObj('imgVOELEN').src = 'img/VOELEN horizontaal highlight.png';
				break;
			case 2:
				MM_findObj('imgDENKEN').src = 'img/DENKEN horizontaal highlight.png';
				break;
			case 3:
				MM_findObj('imgDOEN').src = 'img/DOEN horizontaal highlight.png';
				break;
		}
		if (which > 0){
			activeMenu = MM_findObj('menu'+which);
			activeMenu.style.display='block';
			menuBackground.style.left = findPosX(activeMenu);
			menuBackground.style.top = findPosY(activeMenu);
			menuBackground.style.width = activeMenu.offsetWidth;
			menuBackground.style.height = activeMenu.offsetHeight;
		}
	}
}
menuIsOn = false;
function checkmenu(){
	menuBackground = MM_findObj('menubackground');
	if (coorX < 8 + parseInt(menuBackground.style.width) && coorY < 20 + parseInt(menuBackground.style.height)){
		//keep menu
	}else if (menuIsOn){
		loosemenu();
	}
}
function loosemenu(){ //triggered by checkmenu which is started by onbodyload
	menuBackground = MM_findObj('menubackground');
	activeMenu = MM_findObj('menu');
	activeMenu.style.visibility='hidden';
	menuBackground.style.left = -400;
	menuBackground.style.top = -400;
	if (document.all){
		//MM_findObj('pagediv').style.filter = 'alpha(opacity:100)';
		MM_findObj('pagediv').style.filter = 'none';
	}else{
		MM_findObj('pagediv').style.MozOpacity = 1;
	}
	menuIsOn = false;
}
function showmenu(){
	if (document.location.search.toString().indexOf('movie=') != -1){
		document.body.style.cursor = 'wait';
		document.location.replace(document.location.href.substr(0,document.location.href.indexOf('?')));
	}else{
		if (pageLoaded){
			menuBackground = MM_findObj('menubackground');
			activeMenu = MM_findObj('menu');
			activeMenu.style.visibility='visible';
			menuBackground.style.left = findPosX(activeMenu);
			menuBackground.style.top = findPosY(activeMenu);
			menuBackground.style.width = activeMenu.offsetWidth;
			menuBackground.style.height = activeMenu.offsetHeight;
			if (document.all){
				MM_findObj('pagediv').style.filter = 'alpha(opacity:10)';
			}else{
				MM_findObj('pagediv').style.MozOpacity = 0.1;
			}
			menuIsOn = true;
		}
	}
}
function getMouseXY(e){
	if (pageLoaded){
		coorX = (e)?e.pageX:event.clientX + document.body.scrollLeft;
		coorY = (e)?e.pageY:event.clientY + document.body.scrollTop;
	}
}


function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
	else if (obj.x){
		curleft += obj.x;
	}
	return curleft;
}
function findPosY(obj){
	var curtop = 0;
	if (obj){
		if (obj.offsetParent){
			while (obj.offsetParent){
				curtop += obj.offsetTop;
				//curtop -= obj.scrollTop;
				obj = obj.offsetParent;
			}
		}
		else if (obj.y){
			curtop += obj.y;
		}
		return curtop;
	}
}
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function epost(who,ofwhat){
	monkeytail='@';
	document.location.href='mailto:'+who+monkeytail+ofwhat;
}



