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 getactivenavitem() {
	var allnavitems = document.getElementById("nav").getElementsByTagName("a");
	for (var i = 0; i < allnavitems.length; i++) {
		if (allnavitems[i].className == 'nav nc') {
			return allnavitems[i];
		}
	}
	return null;
}
function adjustsubnav() {
	var plpos;
	var navpos = findPosition(document.getElementById("nav"));
	activenavitem = getactivenavitem();
	var elpos  = findPosition(activenavitem);
	plpos = elpos[0] - navpos[0] - 40;
	plpos = Math.max(0,plpos);
	var onelineheight = parseInt(getComputedCSSValue(document.getElementById("subnav"),'height'));
	document.getElementById("subnav").style.paddingLeft = plpos + 'px';
	if (isNaN(onelineheight)) onelineheight = 14;
	if (onelineheight == 0)	  onelineheight = 14;
	while (document.getElementById("subnav").offsetHeight > (onelineheight+8)) {
//	while (document.getElementById("subnav").offsetHeight > (onelineheight+6)) {
//	while (document.getElementById("subnav").offsetHeight > (onelineheight+4)) {
		plpos -= 5;
		document.getElementById("subnav").style.paddingLeft = plpos + 'px';
	}
	subnavcurrentpl = plpos;
}
function getObjectHeight(obj)  {
    var elem = getRawObject(obj);
    var result = 0;
    if (elem.offsetHeight) {
        result = elem.offsetHeight;
    } else if (elem.clip && elem.clip.height) {
        result = elem.clip.height;
    } else if (elem.style && elem.style.pixelHeight) {
        result = elem.style.pixelHeight;
    }
    return parseInt(result);
}
function adjustHeight(ie6) {
	var currWindowHeight = getWindowHeight();
	var cbOffsetTop = document.getElementById("contentbody").offsetTop;
	if (ie6) {
		document.getElementById("content").style.height = (currWindowHeight - 32);
	}
	else {
		document.getElementById("content").style.height = (currWindowHeight - 14) + 'px';
	}
	document.getElementById("contentbody").style.height = (currWindowHeight - cbOffsetTop - 28) + 'px';
	var currSH = document.getElementById("contenttablediv1").scrollHeight;
	if (ie6) {
		document.getElementById("contenttable").style.marginTop = '20px';
		document.getElementById("contenttable").style.marginTop = '4px';
		// hack to make sure the white content part is displayed correctly:
		document.getElementById("content").style.marginTop = '-14px';
		document.getElementById("content").style.paddingBottom = '14px';
	}
	if ((currSH + cbOffsetTop) > (currWindowHeight - 14)) {
		document.getElementById("content").style.height = (currSH + cbOffsetTop) + 'px';
		document.getElementById("contentbody").style.height = (currSH - 14) + 'px';
		if (ie6) {
			document.getElementById("content").style.height = (currSH + cbOffsetTop) + 'px';
			document.getElementById("contentbody").style.height = (currSH - 8) + 'px';
		}
	}
	document.getElementById("contenttablediv1").style.top = (document.getElementById("contentbody").offsetTop + 10) + 'px';
	activenavitem = getactivenavitem();
	// safari seems to need a timeout here... prevent too long html at wrong position...
	document.getElementById("subnav").style.visibility = 'hidden';
//	document.getElementById("subnav").style.paddingLeft = subnavcurrentpl + 'px';
	setTimeout('restoresubnavcurrentpage()',5);
}
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 findPosition(oElement) {
	if (typeof(oElement.offsetParent) != 'undefined' ) {
		for (var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent) {
			posX += oElement.offsetLeft;
			posY += oElement.offsetTop;
		}
		return [posX, posY];
	}
	else {
		return [oElement.x, oElement.y];
	}
}
function getcurrentpos(e) {
	try {
		if (!e) e = window.event;
		var thepos = findPosition(document.getElementById("nav"));
		mousepos = (e.clientX - thepos[0]);
	} catch(e) {};
}
function restoresubnavcurrentpage() {
	document.getElementById("subnav").innerHTML = subnavcurrentpage;
	document.getElementById("subnav").style.visibility = 'visible';
}
function restoresubnavcurrentpageoutofnavs1() {
	document.getElementById("subnav").style.paddingLeft = subnavcurrentpl + 'px';
	setTimeout('restoresubnavcurrentpageoutofnavs2()',50);
}
function restoresubnavcurrentpageoutofnavs2() {
	document.getElementById("subnav").innerHTML = subnavcurrentpage;
	document.getElementById("subnav").style.visibility = 'visible';
}
function outofnavs(e) {
	if (! e.relatedTarget) return;
	var out = true;
	if (e.relatedTarget.id && (e.relatedTarget.id == 'nav' || e.relatedTarget.id == 'subnav')) {
		return;
	}
	if (e.relatedTarget.parentNode.id && (e.relatedTarget.parentNode.id == 'nav' || e.relatedTarget.parentNode.id == 'subnav')) {
		return;
	}
	if (e.relatedTarget.parentNode.parentNode.id && (e.relatedTarget.parentNode.parentNode.id == 'nav' || e.relatedTarget.parentNode.parentNode.id == 'subnav')) {
		return;
	}
//alert('outofnavs');
	// firefox seems to need a time out here; prevent too long html at wrong position...
	if (document.getElementById("subnav").innerHTML != subnavcurrentpage) {
		document.getElementById("subnav").style.visibility = 'hidden';
		document.getElementById("subnav").style.paddingLeft = '0px';
		document.getElementById("subnav").innerHTML = '&nbsp;';
		setTimeout('restoresubnavcurrentpageoutofnavs1()',50);
	}
}
function outofnavs2() {
	var e = window.event;
	if (! e.toElement) return;	// preventing object vereist
	if (e.toElement.id && (e.toElement.id == 'nav' || e.toElement.id == 'subnav' || e.toElement.id == 'containerfortheheader2'))
		return;
	e.cancelBubble = true;
	if (e.toElement.parentNode && e.toElement.parentNode.id && (e.toElement.parentNode.id == 'nav' || e.toElement.parentNode.id == 'subnav'))
		return;
	if (e.toElement.parentNode.parentNode && e.toElement.parentNode.parentNode.id && (e.toElement.parentNode.parentNode.id == 'nav' || e.toElement.parentNode.parentNode.id == 'subnav'))
		return;
//alert('outofnavs2');
	document.getElementById("subnav").innerHTML = subnavcurrentpage;
	document.getElementById("subnav").style.paddingLeft = subnavcurrentpl + 'px';
}
function outofnavs3() { // for subnav
	var e = window.event;
	if (! e.toElement) return;	// preventing object required
	if (e.toElement.id && (e.toElement.id == 'nav' || e.toElement.id == 'subnav'))
		return;
	e.cancelBubble = true;
	if (e.toElement.parentNode.id && (e.toElement.parentNode.id == 'nav' || e.toElement.parentNode.id == 'subnav'))
		return;
	if (e.toElement.parentNode.parentNode.id && (e.toElement.parentNode.parentNode.id == 'nav' || e.toElement.parentNode.parentNode.id == 'subnav'))
		return;
// alert('outofnavs3');
	document.getElementById("subnav").innerHTML = subnavcurrentpage;
//alert(document.getElementById("subnav").style.paddingLeft + ' vs ' + subnavcurrentpl)
	document.getElementById("subnav").style.paddingLeft = subnavcurrentpl + 'px';
}
function miout(el) {
	el.style.textDecoration = 'none';
}
function miover(el) {
	// if we mouseover the navitem that is the parent of the currentpage and
	// the subnav is already visible, do nothing
	if (el == activenavitem && (document.getElementById("subnav").innerHTML == subnavcurrentpage)) return;
	var plpos;
	var navpos = findPosition(document.getElementById("nav"))
	var elpos  = findPosition(el)
	plpos = elpos[0] - navpos[0] - 40;
	plpos = Math.max(0,plpos);
	// if we mouseover the navitem that is the parent of the currentpage and
	// the subnav is no longer visible (due to hovering another navitem item,
	// we make it visible again...
	var onelineheight = parseInt(getComputedCSSValue(document.getElementById("subnav"),'height'));
	document.getElementById("subnav").style.paddingLeft = plpos + "px";
	if (el == activenavitem)
		document.getElementById("subnav").innerHTML = subnavcurrentpage;
	else
		document.getElementById("subnav").innerHTML = navarray[el.innerHTML];
//	if (document.all && ! window.opera) {
		// hack to prevent overflow
		// 20080229 is this still needed...
//		if (plpos > 50)
//			document.getElementById("subnav").style.paddingLeft = (plpos-50) + "px";
//		return;
//	}
//	onelineheight = 14;
	if (isNaN(onelineheight)) onelineheight = 14;
	var maxloop = 0;
	while (document.getElementById("subnav").offsetHeight > (onelineheight+8) && maxloop < 20) {
//	while (document.getElementById("subnav").offsetHeight > (onelineheight+6)) {
//	while (document.getElementById("subnav").offsetHeight > (onelineheight+4)) {
		plpos -= 5;
		document.getElementById("subnav").style.paddingLeft = plpos + 'px';
		maxloop++;
	}
}
function getComputedCSSValue(daElement,daProperty) {
	if (document.defaultView && document.defaultView.getComputedStyle) {
		return document.defaultView.getComputedStyle(daElement,'').getPropertyValue(daProperty);
	}
	else if (document.all) {
		return daElement.currentStyle[daProperty];
	}
}
function initLinks() {
	try {
	for (i in document.links) {
		var link = document.links[i];
		if (link.rel && link.rel.indexOf('external')!=-1) {
			link.onclick = onExternalLinkActivate;
			link.onkeypress = onExternalLinkActivate;
		}
	}
	} catch(e) {}
}
function onExternalLinkActivate() {
	window.open(this.href);
	return false;
}
function sendcontactform(theform) {
	var msg = '';
	if (theform.elements['c[name]'].value == '')
		msg += 'Naam is nog niet ingevuld.\n';
	if (theform.elements['c[email]'].value == '')
		msg += 'E-mail is nog niet ingevuld.\n';
	if (theform.elements['c[msg]'].value == '')
		msg += 'Bericht is nog niet ingevuld.\n';
	if (msg != '') {
		alert (msg);
		return false;
	}
	return true;
//	theform.reset();
}
