var popUpWin=0;
function printPopUpWindow(URLStr, left, top, width, height){
	makeCookie('printNext',1,7,'/');
  if(popUpWin){
	if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin','toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}
// bepaalt hoogte contentcontainer

function setContentSize() {
	if (document.getElementById) {
		var windowHeight=getWindowHeight();
		if (windowHeight>0) {
// // // 			document.getElementById('scrollcontainer').style.height=(windowHeight-(document.getElementById('scrollcontainer').offsetTop))+'px';  // offset from top - footer - footerborder
			document.getElementById('scrollcontainer').style.height='600px';  // offset from top - footer - footerborder
		}
		var windowWidth=getWindowWidth();
		if (windowWidth>0) {
// // //			document.getElementById('scrollcontainer').style.width=(windowWidth-70)+'px';  // offset from top - footer - footerborder
			document.getElementById('scrollcontainer').style.width='800px';  // offset from top - footer - footerborder
		}
	}
}



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 getWindowWidth() {
	var windowWidth=0;
	if (typeof(window.innerWidth)=='number') {
		windowWidth=window.innerWidth;
	} else {
		if (document.documentElement&&
			document.documentElement.clientWidth) {
			windowWidth=document.documentElement.clientWidth;
		} else {
			if (document.body&&document.body.clientWidth) {
				windowWidth=document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}


/* Activating the submenu */

window.onLoadHandler=menuInit;
XBrowserAddHandler(window,"load","onLoadHandler");


function unsetAll(){
	makeCookie('navStateMain',-1,7,'/');
	makeCookie('navStateSub',-1,7,'/');
}

function mainClick(){
	//alert(this.getAttribute('href'));
	makeCookie('navStateMain',this.getAttribute('href'),7,'/');
}
function subClick(){
	if(this.getAttribute('href')=="javascript:void(0);"){
		makeCookie('navStateSub',-1,7,'/');
	} else {
		makeCookie('navStateSub',this.getAttribute('href'),7,'/');
		//alert(this.getAttribute('href'));
	}
}

function tellme(){
	a=readCookie('navStateMain');
	b=readCookie('navStateSub');
	c=readCookie('navStateSubEXP');
	document.body.innerHTML="<textarea>navStateMain:"  + a + "\nnavStateSub:"  + b + "\nnavStateSubEXP:" + c+"</textarea>";
	
}

function menuInit(){
	/* is this a new session?! */
	var lastSave=readCookie('saved_session');
	var current=readCookie('cur_session');
	if(lastSave!=current){
		makeCookie('navStateMain',-1,7,'/');
		makeCookie('navStateSub',-1,7,'/');
		makeCookie('navStateSubEXP',-1,7,'/');
		makeCookie('saved_session',current,7,'/');
	}
	
	/* activate the mainmenu */
	var mainItem = readCookie('navStateMain');
	var mainmenu=document.getElementById('mainmenu');
 	theAs=mainmenu.getElementsByTagName('A');
	for (ti=0;ti<theAs.length;ti++) {
		/* Each Item should have an extra clickHandler */
		theA=theAs[ti];
		theA.ClickHandler = mainClick;
		XBrowserAddHandler(theA,"click","ClickHandler");
		if(theA.getAttribute('href')==mainItem){
			theA.className='current';
		}
	}
		
	/* Expand (or collapse) the right submenu */
	var expandedItem = readCookie('navStateSubEXP');
	//alert(expandedItem);
	// Aan alle 'subs' li's een onclick function hangen.
	var menu=document.getElementById('submenu');
/*	theLIs=menu.getElementsByTagName('li');  // EK
	var re = new RegExp('"(.*)"');
	for (ti=0;ti<theLIs.length;ti++) {
        thisLI = theLIs[ti];
		thisLI.ClickHandler = liClicked;
		XBrowserAddHandler(thisLI,"click","ClickHandler");
		var childUL=thisLI.getElementsByTagName('ul');
		if(childUL.length>0){
			var identifier=thisLI.innerHTML;
			// Duhh   FF split op ul en IE op UL..
			var resultArray = identifier.split(/<ul>/i);
			//alert(resultArray[0]);
			
			// we willen vergelijken op de inhoud van de href!
			if(resultArray!=null){
				var m = re.exec(resultArray[0]);
			}
			var n = re.exec(expandedItem);		

			if(resultArray!=null && typeof(m[1])!=undefined && n!=null && typeof(n[1])!=undefined && n[1]==m[1]){
				thisLI.className='subsopen';
				//alert('gelijk');
			} else {
				thisLI.className='subs';
			}

		}
      }
*/ // EK	
	/* activate the submenu */
	var subItem = readCookie('navStateSub');
	//alert(subItem);
	var submenu=document.getElementById('submenu');
/*	theAs=submenu.getElementsByTagName('A');  // EK
	
	var subset=false;
	var reserve=-1;
	
/*	for (ti=0;ti<theAs.length;ti++) {
		/* Each Item should have an extra clickHandler * /
		theA=theAs[ti];
		if(theA.className!='subs' && theA.className!='subsopen'){ 
			theA.ClickHandler = subClick;
			XBrowserAddHandler(theA,"click","ClickHandler");
		}
		if(theA.getAttribute('href')==subItem){
			theA.className='current';
			subset=true;
		} 
		if(theA.getAttribute('href')==mainItem){
			reserve=ti;
		}
	}
	if(!subset && reserve>=0){
		theAs[reserve].className='current';
	}
	submenu.style.display='block';
// EK 
*/
}

function liClicked(){
var submenu=document.getElementById('submenu');
/* // EK 		if(this.getAttribute('href')!="javascript:void(0);" && this.getAttribute('href')!=null){
		submenu.style.display='none';
	}
	
	var currentstate=this.className;
	liCloser();
	if(currentstate=='subs'){
		this.className='subsopen';
		var identifier=this.innerHTML;
		var resultArray = identifier.split(/<ul>/i);
		var store=resultArray[0].replace(/class=\"(.*)\" /,'');
		if(resultArray!=null){
			makeCookie('navStateSubEXP',store,7,'/');
		}
	} else {
		makeCookie('navStateSubEXP','',7,'/');
	}
*/ // EK 	
}


function liCloser(){
	var menu=document.getElementById('submenu');
// //	theLIs=menu.getElementsByTagName('li');
	for (ti=0;ti<theLIs.length;ti++) {
        thisLI = theLIs[ti];
		if(thisLI.className=='subsopen'){
			thisLI.className='subs';
		}
    }
	theAs=menu.getElementsByTagName('A');
	for (ti=0;ti<theAs.length;ti++) {
		/* Each Item should have an extra clickHandler */
		theA=theAs[ti]; 
		if(theA.getAttribute('href')!="javascript:void(0);"){
			theA.className='';
		}
	}
	
}

function XBrowserAddHandler(target,eventName,handlerName) {
	if ( target.addEventListener ) { 
		target.addEventListener(eventName, function(e){target[handlerName](e);}, false);
	} else if ( target.attachEvent ) { 
		target.attachEvent("on" + eventName, function(e){target[handlerName](e);});
	} else { 
		var originalHandler = target["on" + eventName]; 
		if ( originalHandler ) { 
			  target["on" + eventName] = function(e){originalHandler(e);target[handlerName](e);}; 
		} else { 
			  target["on" + eventName] = target[handlerName]; 
		} 
	} 
}
function makeCookie(Name,Value,Expiry,Path,Domain,Secure) {
	if (Expiry != null) {
		var datenow = new Date();
		datenow.setTime(datenow.getTime() + Math.round(86400000*Expiry));
		Expiry = datenow.toGMTString();
	}
	Expiry = (Expiry != null) ? '; expires='+Expiry : '';
	Path = (Path != null)?'; path='+Path:'';
	Domain = (Domain != null) ? '; domain='+Domain : '';
	Secure = (Secure != null) ? '; secure' : '';
	document.cookie = Name + '=' + escape(Value) + Expiry + Path + Domain + Secure;
}

function readCookie(Name) {
	var cookies = document.cookie;
	if (cookies.indexOf(Name + '=') == -1){ return null; }
	var start = cookies.indexOf(Name + '=') + (Name.length + 1);
	var finish = cookies.substring(start,cookies.length);
	finish = (finish.indexOf(';') == -1) ? cookies.length : start + finish.indexOf(';');
	return unescape(cookies.substring(start,finish));
}
