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

function manipulateDomForJelle() {
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
	
	// add class no-margin to first, 5th, 9th, .. li in #beelden if it's there
		if ($('beelden')){
			var oul = $('beelden');
			for(var i=0; i <= oul.getElementsByTagName('li').length; i = i+4){
				if (oul.getElementsByTagName('li')[i]){
					var oli = oul.getElementsByTagName('li')[i];
				  $(oli).addClassName('no-margin');
				}
			}
		}

  // put busy state where needed
		var curloc = document.location.href
		//eventuele trailing slash weghalen
    curloc = curloc.lastIndexOf("/")==curloc.length-1 ? curloc.substring(0, curloc.length-1) : curloc;
		// first off; the redenen li's on waarom-arthus
		if($('nav-tre')){
			var links = $('nav-tre').getElementsByTagName('a');
			for(var i=0; i < links.length; i++){
				if(links[i].href == curloc){
					$($(links[i]).ancestors()[0]).addClassName('busy');
				}
			}
		}
		// next; the nav-sec for projecten
		if($('nav-sec')){
			var links = $('nav-sec').getElementsByTagName('a');
			for(var i=0; i < links.length; i++){
				if(links[i].href == curloc){
					$($(links[i]).ancestors()[0]).addClassName('busy');
				}
			}
		}
	
	
	
	// now un-duplicate the projecten nav;
//		if($('nav-sec') && curloc.split('/')[4]==('project'||'projet')){
//			// per ul werken omdat er eenzelfde plaats kan zijn in actueel en in ontwikkeling
//			var uls = $('nav-sec').getElementsByTagName('ul');
//			for(var i=0; i < uls.length; i++){
//				var links = uls[i].getElementsByTagName('a');
//				var newlinks = new Array();
//				for(var c=0; c < links.length; c++){
//					var plaats = links[c].childNodes[0].nodeValue;
//					// make a new array, with index by plaats
//					if(newlinks[plaats]){
//						newlinks[plaats].push(links[c]);
//					}                
//					else{            
//						newlinks[plaats] = new Array(1);
//						newlinks[plaats][0] = links[c];
//					}
//				} // for links
//				
//				// build up the new ul;
//				var new_Ul = document.createElement("ul");
//				for(x in newlinks){
//					if(x=='each'){break;} // i don't know what it does in there either.. 
//				  var links_for_this_plaats = newlinks[x];
//					if(links_for_this_plaats.size() > 1){
//						// several links for this, build sub-ul
//						var new_SubUl = document.createElement("ul");
//						// add li's to this for each link
//						for(link in links_for_this_plaats){
//							var new_Li = document.createElement("li");
//							var tn = document.createTextNode(links_for_this_plaats[link]);
//							new_Li.appendChild(tn);
//							new_SubUl.appendChild(new_Li);
//							var ulCont = document.createElement("li");
//							ulCont.appendChild(new_SubUl);
//						}
//						new_Ul.appendChild(ulCont);
//					}
//					else{
//						// just make an li with this link in it
//						var new_Li = document.createElement("li");
//						new_Ul.appendChild(new_Li);
//						new_Li.appendChild(links_for_this_plaats[0]);
//					}
//				} // for link in newlinks
//				uls[i].ancestors()[0].replaceChild(new_Ul, uls[i]);
//			} // for uls
//		}
		
		
	
}

addLoadEvent(manipulateDomForJelle);
