function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function setMenuCookie(nr)
	{
	var today = new Date();
 	var expire = new Date();
 	expire.setTime(today.getTime() + 3600000*1);
 	document.cookie = "hoofdmenu="+escape(parseInt(nr)) + ";expires="+expire.toGMTString();
	}
	
function getMenuCookie()
	{
	var theCookie=""+document.cookie;
	var ind=theCookie.indexOf("hoofdmenu");
	if (ind==-1 || "hoofdmenu"=="") return ""; 
	var ind1=theCookie.indexOf(';',ind);
	if (ind1==-1) ind1=theCookie.length; 
	return unescape(theCookie.substring(ind+"hoofdmenu".length+1,ind1));
	}
function delMenuCookie()
	{
	var today = new Date();
	var expire = new Date();
 	expire.setTime(today.getTime() - 3600000*1);
	document.cookie = "hoofdmenu='';expires="+expire.toGMTString();
	
	}	


var kpArray=new Array();
function addNodeToKruimelpad(n)
	{
	if (!n) {return false;}
	if (n.childNodes && n.childNodes[0] && n.childNodes[0].nodeName=="A") 
		{
		kpArray.push(n.childNodes[0].cloneNode(true));
		}
	else if (
		n.parentNode &&
		n.parentNode.childNodes &&
		n.parentNode.childNodes[1] && 
		n.parentNode.childNodes[1].childNodes &&
		n.parentNode.childNodes[1].childNodes[1] &&
		n.parentNode.childNodes[1].childNodes[1].nodeName=="A")
			{kpArray.push(n.parentNode.childNodes[1].childNodes[1].cloneNode(true));}	
		
	else if (
		n.parentNode &&
		n.parentNode.parentNode && 
		n.parentNode.parentNode.childNodes[1] && 
		n.parentNode.parentNode.childNodes[1].childNodes && 
		n.parentNode.parentNode.childNodes[1].childNodes[0] && 
		n.parentNode.parentNode.childNodes[1].childNodes[0].nodeName=="A")
			{kpArray.push(n.parentNode.parentNode.childNodes[1].childNodes[0].cloneNode(true));}	
	//else if (n.childNodes[0].nodeName=="LI") {kpArray.push(n.childNodes[0].childNodes[0].cloneNode(true));}
	
	}

function defaultMenuOpen()
	{
	var trgt=document.getElementById("hoofdmenu_24_hoofdmenu");
	if (trgt)
		{
		toggleMenuItem(document.getElementById("hoofdmenu_24_hoofdmenu").childNodes[0]);
		kp=undefined;
		}
	}
		
function openHoofdmenu(i)
	{
	var kp=document.getElementById("kruimelpad");
	
	if (i=="index") 
		{
		defaultMenuOpen();return true;
		}
			
	var mid=getMenuCookie();
	
	pageLI=document.getElementById("hoofdmenu_"+String(i));
	if (mid!="" && mid!="-1")
		{
		pageLI=document.getElementById("hoofdmenu_"+String(i)+"_"+parseInt(mid));
		delMenuCookie();
		}
	
	if (pageLI) 
		{
		pageLI.className="activeitem";
		pageLI.style.display="block";
		addNodeToKruimelpad(pageLI);
		if (pageLI.childNodes.length>1 && pageLI.childNodes[1].nodeName=="UL") {pageLI.childNodes[1].style.display="block";}
		if (pageLI.childNodes.length>0 && pageLI.childNodes[0].nodeName=="UL") {pageLI.childNodes[0].style.display="block";}
		
		if (pageLI.parentNode && pageLI.parentNode.nodeName=="UL") 
			{
			pageLI.parentNode.style.display="block";
			}
		if (pageLI.parentNode.parentNode && pageLI.parentNode.parentNode.nodeName=="LI")
			{
			addNodeToKruimelpad(pageLI.parentNode.parentNode);
			}
		if (pageLI.parentNode.parentNode.parentNode && pageLI.parentNode.parentNode.parentNode.nodeName=="UL")
			{
			pageLI.parentNode.parentNode.parentNode.style.display="block";addNodeToKruimelpad(pageLI.parentNode.parentNode.parentNode);
			}
		
		kpArray = kpArray.reverse();
		if (kp && kpArray.length>0) {kp.innerHTML="<a href='/' class='first'>Home</a>";}
		for (x=0;x<kpArray.length;x++) 
			{

				if (kpArray.length>0 && kp) {var sep=document.createTextNode(" - ");kp.appendChild(sep);}
				//if (x==0) {kpArray[x].className="first";}
				if (kp) {kp.appendChild(kpArray[x]);}
				
				
			}	
		}
	else
		{
		defaultMenuOpen();return true;
		}
	}
function toggleMenuItem(el)
	{
	
	if (el.parentNode.childNodes[1].nodeName=="UL") 
		{
		if (el.parentNode.childNodes[1].style.display=="block")
			{el.parentNode.childNodes[1].style.display="none";}
		else
			{el.parentNode.childNodes[1].style.display="block";}
		}
	}
	
//Form checks
function MM_validateFormEN() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormNL.arguments;

  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);hr=args[i+1];o=val;

   // if (String(val.type)=="undefined") {val=getElementsByTagName(val);}
    if (val) { nm=val.name;T=val.type;

    if(val.length>0 && val[0].type=="radio") {T="radio";}

if ((val=val.value)!="" && T!="checkbox" && T!="radio") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+URLDecode(hr)+' must contain a valid e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+URLDecode(hr)+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+URLDecode(hr)+'must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') 
	{
	
	if (T=="checkbox" && o.checked==false) {errors += '- '+URLDecode(hr)+' is required\n'; }
	if (T=="radio" && getCheckedValue(o)==false) {errors += '- '+URLDecode(hr)+' is required\n'; }
	if (T!="checkbox" && T!="radio")
		{errors += '- '+URLDecode(hr)+' is required\n'; }
	}
}
  } if (errors) alert('The following information is incorrect:\n'+errors);

  document.MM_returnValue = (errors == '');
}

function MM_validateFormNL() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormNL.arguments;

  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);hr=args[i+1];o=val;

   // if (String(val.type)=="undefined") {val=getElementsByTagName(val);}
    if (val) { nm=val.name;T=val.type;

    if(val.length>0 && val[0].type=="radio") {T="radio";}

if ((val=val.value)!="" && T!="checkbox" && T!="radio") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+URLDecode(hr)+' moet een geldig e-mail adres bevatten.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+URLDecode(hr)+' moet een nummer bevatten.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+URLDecode(hr)+' moet een nummer tussen '+min+' en '+max+' bevatten.\n';
    } } } else if (test.charAt(0) == 'R') 
	{
	
	if (T=="checkbox" && o.checked==false) {errors += '- '+URLDecode(hr)+' is verplicht\n'; }
	if (T=="radio" && getCheckedValue(o)==false) {errors += '- '+URLDecode(hr)+' is verplicht!\n'; }
	if (T!="checkbox" && T!="radio")
		{errors += '- '+URLDecode(hr)+' ontbreekt\n'; }
	}
}
  } if (errors) alert('De volgende informatie is incorrect:\n'+errors);

  document.MM_returnValue = (errors == '');
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return false;
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return false;
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return false;
}

function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

function URLDecode(psEncodeString)
	{
	var lsRegExp = /\+/g;
	return unescape(String(psEncodeString).replace(lsRegExp, " "));
	}
			
