
function bodyOnload() {
	initsite();
	addThumbEvents();
	startDropdown("collection");
}

addEvent(window,'load',bodyOnload);


//THUMBNAIL EVENTS
function addThumbEvents() {
	imgs = document.getElementsByTagName("img");
	for(i=0;i<imgs.length;i++) {
		if (imgs[i] && imgs[i].id && imgs[i].id.indexOf("foto") != -1) {
			addEvent(imgs[i],'mouseover',thumbMouseover);
		}
	}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function thumbMouseover(e) {
	obj = getEventObject(e);
	objgroot = document.getElementById('imgbig');
	if (obj && objgroot) {
		objgroot.src = obj.src.replace('/tn_','/');
	}
}


//DROP DOWN MENU
function startDropdown(menuid) {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById(menuid);
		if (navRoot) {
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over"; 
					}
					node.onmouseout=function() {
						this.className=this.className.replace(" over", "");
					}
				}
			}
		}
	}
}

//EVENT FUNCTIONS
function getEventObject(e) {
	if (window.event && window.event.srcElement) {
		return window.event.srcElement;
	}
	if (e && e.target) {
		return e.target;
	}
}
function addEvent(obj,event,func2run) {
	if (window.addEventListener) {
		obj.addEventListener(event,func2run,false);
	} else {
		if (window.attachEvent) {
			obj.attachEvent('on' + event,func2run);
		} else {
			eval("obj.on" + event + " = func2run;");
		}
	}
}

function fix_safari() {
	pimg = document.getElementById('pimg');
	pdetails = document.getElementById('pdetails');
	if (pimg && pdetails) {
		if (pimg.offsetHeight > pdetails.offsetHeight) {
			maxheight = pimg.offsetHeight;
		} else {
			maxheight = pdetails.offsetHeight;
		}
		pdetails.style.height = maxheight + 'px';
		pimg.style.height = maxheight + 'px';
		pdetails.style.backgroundColor='#FFF';
	}
	
	maintable = document.getElementById('maintable');
	contenttable = document.getElementById('contenttable');
	if (maintable && contenttable) {
		contenttable.style.height = maintable.offsetHeight + 'px';
	}
}

function initsite() {
    var agt=navigator.userAgent.toLowerCase();
    var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
	if (is_safari) { fix_safari();}
}

var arrrandom = new Array();
var randidx = 0;
var randnr = 0;
function rand (max) {
	if (randnr >= arrrandom[randidx].length) {
		randidx++;
		randnr = 0;
	}
	if (randidx >= arrrandom.length) {
		randidx = 0;
		randnr = 0;
	}
	nr = arrrandom[randidx][randnr];
	randnr++;
	
	return nr;
}

function overzicht_onover(link) {
	link.className = link.className + ' over';
}
function overzicht_onout(link) {
	link.className = link.className.replace('over','');
}

function persRubriekOver(link) {
	overzicht_onover(link);
}
function persRubriekOut(link) {
	overzicht_onout(link);
}
function persDocumentOver(tr) {
	overzicht_onover(tr);
}
function persDocumentOut(tr) {
	overzicht_onout(tr);
}

function openvenster(url,popup_width,popup_height,scrollbars) {
    var undefined;
    if (popup_width == undefined) popup_width=800;
    if (popup_height == undefined) popup_height=600;
    if (scrollbars == undefined) scrollbars='no';
    left_pos = (screen.availWidth/2) - (popup_width / 2);
    top_pos = (screen.availHeight/2) - (popup_height / 2);
    mywin = window.open(url,'popup','height=' + popup_height + ',left=' + left_pos + ',top=' +top_pos + ',width=' + popup_width + ',scrollbars=' + scrollbars);
    mywin.focus();
}

function openfotos(id) {
	openvenster('/nl/persfotos.htm?did='+id,1024,768,true);
}