// start info
if(typeof jsReport != 'undefined'){
	jsVersion = new Array(
	/*Name			=*/ 'Fold-out menu',
	/*Version 		=*/ '1.6',
	/*Date 			=*/ 20020124,
	/*Author		=*/ 'Maurice van Creij',
	/*ProjectCode	=*/ 'l3_foldoutmenu',
	/*Summary		=*/ 'Make space efficient floating menu\'s that fold-out over the content page.',
	/*Dependencies	=*/ new Array('foldout_document.js','foldout_frameset.js','framesync_menu.js','easylayers.js','content_ini.js','content_filter.js','browsercheck.js'),
	/*Browsers		=*/ new Array('NS','MO','IE'),
	/*Changes		=*/ new Array(
						'1.6: Added support for background-images and a remote control - framesync_menu.js',
						'1.5: Replaced custom functions with equivalents from easylayers.js',
						'1.4: Optimized the filtering of items in the "construction" phase. Issues, with the menu not always closing, appear to be solved.',
						'1.3: Added support for pre-generated menus in the frameset, simplified menu generation and more configuration constants',
					  	'1.2: Added an optional scroll-lock and edge-detection',
					  	'1.1: Reorganized to be independent from foldout_frameset.js, menu-calls are not compatible with 1.0',
					  	'1.0: A modular version was compiled from code-scraps'
					  	),
	/*Usage			=*/ new Array(
						'this goes in the content frame',
						'<script language="JavaScript" src="/~wmittens/includes/browsercheck.js" type="text/javascript"></script>',
						'<script language="JavaScript" src="/~wmittens/includes/content_filter.js" type="text/javascript"></script>',
						'<script language="JavaScript" src="/~wmittens/includes/foldout_document.js" type="text/javascript"></script>',
						'',
						'this, optionaly, goes in the top frame. Doing so will greatly speed up the loading of consecutive pages. Also it facilitates inter-frame function calls',
						'<script language="JavaScript" src="/~wmittens/includes/foldout_frameset.js" type="text/javascript"></script>',
						'',
						'this, also optionaly, goes in the top frame to generate the menus before they\'re needed',
						'<!-- pre-generate the menus (even more optional) -->',
						'	<script language="JavaScript" src="/~wmittens/includes/browsercheck.js" type="text/javascript"></script>',
						'	<script language="JavaScript" src="/~wmittens/includes/content_filter.js" type="text/javascript"></script>',
						'	<script language="JavaScript" src="/~wmittens/includes/foldout_document.js" type="text/javascript"></script>'
					  	)
	)
}else{
// end info


	// configuration constants
		// cosmetics
		var markEnable = 1; 		//1 activates the text and background marking (slower)
		var borderWidth = 1;
		var gridLines = 0;
	//	var classLo   = "menu"
		var subImg    = "pijl"
		var nosubImg  = "pijl_leeg"
		
		
		tableColours =	new Array(new Array("#DC8B00","#FFFFFF","#F7EEDD","#DC8B00","links"),//0textLoCol,1textHiCol,2backLoCol,3backHiCol,4MenuCSS
								new Array("#2F6400","#FFFFFF","#E6EED6","#2F6400","actueel"),
								new Array("#124B3E","#FFFFFF","#DFEDEA","#124B3E","themas"),
								new Array("#480049","#FFFFFF","#E5DFE2","#480049","bestuurders"),
								new Array("#DC8B00","#FFFFFF","#F7EEDD","#DC8B00","links")
								)
	
	//	var textHiCol = "#336699"
	//	var textLoCol = "#6699cc"
	//	var backLoCol = "#F3F9FF"
	//	var backHiCol = "#ddeeff"
	//	var borderCol = "#6699cc"
	
		var booHorizontal = false	// insanity
		var booBackImages = false	// doesn't work very well in mozilla yet
		if(booBackImages){
			var backLoImg = "back_p"
			var backHiImg = "back_a"
		}
		
		// dimensions
		var menuMinWidth = 150; 		// minimal menu width
		var menuMaxWidth = "100%"; 	// maximal menu width "100%" for free-sizing menus
		var menuHeight = 18;
		var iconWidth = 18;
		
		// position
		var menuAutoPos = false; 		// 'true' activates the menu position approximation (slower)
		var menuPosX = 4;
		var menuPosY = 4;
		var subMenuXShift = 4;
		var subMenuYShift = 4;
		var scrollLock = true;
		var edgeCompensation = false;
		
		// operation
		var noDelay = 0;			// 1 disables some wait-loops
		var menuCloseDelay = 1024;
		var menuShowDelay = 256;
		var menuPositionFrequency = 1; // Hz
		var imageFolder = "/images/"
		var imagePrefix = ""
		var imagePrefixpijl = "punt_"
		var imageSuffixpijl = "_klein"
		var imageSuffix = ".gif"
		var reportToFrameSet = true // set this to 'true' when foldout_frameset.js is available in the parent frame. This will greatly reduce loading times.
		var showRoot = false
		
 		// location of the 'brain-file'
		if(typeof parent.DBarray != 'undefined'){
			DBarray = parent.DBarray
		}
		
		var inits = 0
	
	
	// primary functions (functions that "do stuff")
		function cacheMenuImages(){
			if(booBackImages){
				cacheBackgroundImage('imgback0',imageFolder+imagePrefix+backLoImg+imageSuffix)
				cacheBackgroundImage('imgback1',imageFolder+imagePrefix+backHiImg+imageSuffix)
			}
		}
		
	
	// item highlighting functions
		function mark(markobj){
		actIndx = DBarray[markobj][11]
		var backHiCol = tableColours[actIndx][3]
		var textHiCol = tableColours[actIndx][1]
	
			if(markEnable!=0 && markobj!=0){
				if(booBackImages){
					setBackgroundImage('tb'+markobj,'imgback1')
				}else{
					setBackgroundColour('tb'+markobj,backHiCol)
				}
				setColour('ti'+markobj,textHiCol)
			}
		}
		
		function unmark(unmarkobj){
		actIndx = DBarray[unmarkobj][11]
		var backLoCol = tableColours[actIndx][2]
		var textLoCol = tableColours[actIndx][0]
		
			if(markEnable!=0 && unmarkobj!=0){
				if(booBackImages){
					setBackgroundImage('tb'+unmarkobj,'imgback0')
				}else{
					setBackgroundColour('tb'+unmarkobj,backLoCol)
				}
				setColour('ti'+unmarkobj,textLoCol)
			}
		}			
		
		// menu foldout/foldin functions
		// Shows a layer absolutely
		function show(obj) {	
			if (inits==1) {
				if(showRoot || obj>0){
					setVisibility('blockDiv'+obj,true)
				}
			}
		}
		
		// Hides a layer absolutely
		function hide(obj) {	
			if (inits==1) {
				setVisibility('blockDiv'+obj,false)
			}
		}
	
	
	// secondary functions (functions that "control" the primary functions)
		// item highlighting functions
		function unmarkAll(){
			if(n!=1 && markEnable!=0){
				for(var tellerA=1 ; tellerA < DBarray[0] ; tellerA++){
					unmark(DBarray[tellerA][0])
				}
			}
		}
		
		// don't unmark an item if it was highlighted prior
		function unmarkExclusive(unmarkItem){
			if(unmarkItem!=openMenu && noDelay==0){unmark(unmarkItem)}
		}
		
		// don't unmark an item if it was highlighted prior
		function markExclusive(markItem){
			if(noDelay==0){
				if(DBarray[markItem][1]==DBarray[openMenu][1]){unmark(openMenu)}
				mark(markItem)
			}
		}
		
		// menu foldout/foldin functions
		closeBranch = new Array(0,1); openMenu = 0;
		function showExclusive(showobj){
 			//trace the open menus back to the root
			openBranch = TraceBranch(showobj) 
//	alert(openBranch)
			//check if the menu's have changed
			if(openBranch[closeBranch.length-1] != closeBranch[closeBranch.length-1]){
				//close (only the changes to) the menu-branch
				for(tellerA = 0; tellerA < closeBranch.length; tellerA++){ 
					if(hasChild(closeBranch[tellerA])>0 && closeBranch[tellerA] != openBranch[tellerA])	{hide(closeBranch[tellerA])}
					if(closeBranch[tellerA] != 0 && closeBranch[tellerA] != openBranch[tellerA])			{unmark(closeBranch[tellerA])}
				}
			}
			//re-open the menu-branch
			for(tellerA = 0; tellerA < openBranch.length; tellerA++){ 
				//openMenu remembers the last opened menu
				if(hasChild(openBranch[tellerA])>0){show(openBranch[tellerA]);openMenu=openBranch[tellerA]}
				if(openBranch[tellerA] != 0){mark(openBranch[tellerA])}
			}
			// store the list of open menus for the next time
			closeBranch = openBranch 
			// lock the function up
			delayPoke = 1
		}
	
		// Hides all a layer absolutely
		function hideall() {	
			for (var tellerA=1; tellerA<DBarray.length; tellerA++){
				var block = DBarray[tellerA][0]
				if(hasChild(block)>0){hide(block);}
			}
			hide(0);
			unmarkAll();
			closeBranch = Array(0,1)
		}
		
		function aproximateMenuPos(){
			// for every item
			for (var tellerA = 1 ; tellerA < DBarray.length ; tellerA++){
				intItemIndex = DBarray[tellerA][0]
				// if an item has sub-items
				if(hasChild(intItemIndex)>0){
				// X
					// trace item's path back to the root
					arrRootPath = TraceBranch(intItemIndex)
					// it's vertical position is the length of the path * the minimalwidth + default-offsets
					DBarray[intItemIndex][6] = (arrRootPath.length-1)*(menuMinWidth+subMenuXShift)+menuPosX
				
				// Y
					// determine the parent of the item
					intParentIndex = DBarray[intItemIndex][1]
					// filter it's parent's children
					arrPeerItems = FilterContent(1,intParentIndex,0)
					// order the array
					arrContentOrder = FilterContent(1,intParentIndex,8)
					arrPeerItems = OrderContent(arrPeerItems,arrContentOrder)
					// count the position of the current child in the list
					intListPosition = isElementOfArray(intItemIndex,arrPeerItems)
					// it's vertical position is this position*lineheight + it's parent's position + default offset
					if(intParentIndex>0){
						DBarray[intItemIndex][7] = intListPosition * menuHeight + DBarray[intParentIndex][7] + +subMenuYShift
					}else{
						DBarray[intItemIndex][7] = intListPosition * menuHeight + menuPosY +subMenuYShift
					}
				}
			}
		}
			
		// menu layers creation
		function storeMenus(strMenu){
			// where to dump 80KB of generated menus?
			if(reportToFrameSet) parent.strMenu = strMenu
		}
		
		function retrieveMenus(){
		strMenu = -1
			// where to retrieve 80KB of generated menus?
			if(reportToFrameSet) strMenu = parent.strMenu
		return strMenu
		}
		
		function writeMenus(){
			strMenus = retrieveMenus()
			if(strMenus==-1){
				strMenu = generateMenus()
				storeMenus(strMenu)
			}
		document.writeln(strMenu)
		}
		
		
		function generateMenus(){
		if(menuAutoPos){aproximateMenuPos()}
		writeString = "\n"
	
			// writing all menu blocks
			for (var i=0 ;i<DBarray.length;i++){
				if(hasChild(i)>0){
					// filtering the needed items from the content_ini.js
					menuOrder = FilterContent(0,i,8)
					menuIndex = OrderContent(FilterContent(1,i,0),menuOrder)
					strClassbg = DBarray[i][2]

					if(i>0){
						intMenuPosX = DBarray[i][6]
						intMenuPosY = DBarray[i][7]
					}else{
						intMenuPosX = menuPosX
						intMenuPosY = menuPosY
					}
					
					// floating layer
					if 		(n==1)	{writeString = writeString+ "<layer name=\"blockDiv"+i+"\" pagex=\""+intMenuPosX+"\" pagey=\""+intMenuPosY+"\" z-index=\"20\" visibility=\"hide\">\n";}
					else if	(ie==1 || m==1){writeString = writeString+ "<DIV ID=\"blockDiv"+i+"\" STYLE=\"position:absolute; left:"+intMenuPosX+"px; top:"+intMenuPosY+"px; z-index:20; visibility:hidden;\" class=\"semitransparant\">\n";}
						
						// table in table for the border
						writeString = writeString+ "<table border=\"0\" cellspacing=\"0\" cellpadding=\""+borderWidth+"\">\n";
						writeString = writeString+ "<tr><td class=\"tab"+strClassbg+"\">\n";
						writeString = writeString+ "<table width=\""+menuMaxWidth+"\" border=\"0\" cellspacing=\""+gridLines+"\" cellpadding=\"0\">\n";
						if(booHorizontal){writeString = writeString + "<tr valign=\"middle\" height=\""+menuHeight+"\">\n"}
						
						//  writing all items in a block
						for(var tellerB=0; tellerB < menuIndex.length; tellerB++){ 
							// properties of the item to be written
							intItemID		= menuIndex[tellerB]
							strItemName		= DBarray[intItemID][10]
							strItemURL		= DBarray[intItemID][3]
							strItemTarget	= DBarray[intItemID][4]
						//	strItemIcon		= DBarray[intItemID][5]
							intSubMenus		= hasChild(intItemID)
							numberCol	= DBarray[intItemID][11]
							backLoCol	= tableColours[numberCol][2]
							classLo	= tableColours[numberCol][4]
							strItemIcon		= classLo
							
		//	alert(classLo)
							
							// (re)defining the building-blocks
								// general
								var lineMouseover 	= "onMouseOver=\"menuShouldNotclose();showExclusive("+intItemID+")\" onMouseOut=\"menuShouldClose()\""
							//	var lineIcon      	= "<img src=\""+imageFolder+imagePrefix+strItemIcon+".gif\" alt=\"\" align=\"left\" hspace=\"0\" vspace=\"0\" border=\"0\" width=\"12\" height=\""+menuHeight+"\">\n"
								var lineIcon      	= "<img src=\""+imageFolder+"spacing.gif\" alt=\"\" align=\"left\" hspace=\"0\" vspace=\"0\" border=\"0\" width=\"12\" height=\""+menuHeight+"\">\n"
								var linePijl      	= "<img src=\""+imageFolder+imagePrefixpijl+strItemIcon+imageSuffixpijl+".gif\" alt=\"\" align=\"left\" hspace=\"0\" vspace=\"0\" border=\"0\" width=\"13\">\n"
								if (n==1){
									var lineItem      	= "<span class=\""+classLo+"\">"+strItemName+"</span>\n"
								}else{
									var lineItem      	= "<span id=\"ti"+intItemID+"\">"+strItemName+"</span>\n"
								}
								var lineLinkend   	= "</a>"
								var lineCellEnd   	= "</nobr></td>\n"
								var strBackCol		= backLoCol
								var strClass		= classLo
								
								if(!booHorizontal){
									var lineCellWidth	= "<tr height=\"1\"><td bgcolor=\""+strBackCol+"\"><img src=\"/images/spacing.gif\" border=\"0\" width=\"148\" height=\"2\"></td></tr>\n"
									var lineStart 		= "<tr valign=\"middle\" height=\""+menuHeight+"\">\n"
									var lineCellSpace	= ""
									var lineEnd  		= "</tr>\n"
								}else{
									var lineStart 		= ""
									var lineCellWidth	= ""
									var lineCellSpace	= ""
									var lineEnd  		= ""
								}
								
								// in case of background images
								if(booBackImages){
									strBackImg  = "background=\""+imageFolder+imagePrefix+backHiImg+imageSuffix+"\""
								}else{
									strBackImg  = ""
								}
	

								// submenu indicators
								if(intSubMenus>0){
									lineArrow 	= "<img src=\""+imageFolder+imagePrefix+subImg+imageSuffix+"\" alt=\"\" border=\"0\" align=\"right\">\n"
								}else{
									lineArrow 	= "<img src=\""+imageFolder+imagePrefix+nosubImg+imageSuffix+"\" alt=\"\" border=\"0\" align=\"right\">\n"
								}
								
								// link specific
								if(strItemTarget=="_blank"){
									var lineCellStart 	= "<td nowrap onClick=\"w=window.open('"+strItemURL+"','pop"+tellerB+"','');w.focus()\" "+lineMouseover+" id=\"tb"+intItemID+"\" bgcolor=\""+strBackCol+"\" "+strBackImg+"><nobr>\n"
									var lineLinkstart 	= "<a href=\"javascript:w=window.open('"+strItemURL+"','pop"+tellerB+"','');w.focus()\" "+lineMouseover+" class=\""+strClass+"\">\n"
								}else if(strItemURL=="javascript:{}"){
									var lineCellStart 	= "<td nowrap onclick=\"noclose=1\" "+lineMouseover+" id=\"tb"+intItemID+"\" bgcolor=\""+strBackCol+"\" "+strBackImg+"><nobr>\n"
									var lineLinkstart 	= "<a href=\""+strItemURL+"\" onclick=\"noclose=1\" "+lineMouseover+" class=\""+strClass+"\">\n"
								}else{
									var lineCellStart 	= "<td nowrap onClick=\"document.location.href='"+strItemURL+"'\" "+lineMouseover+" id=\"tb"+intItemID+"\" bgcolor=\""+strBackCol+"\" "+strBackImg+"><nobr>\n"
									var lineLinkstart 	= "<a href=\""+strItemURL+"\" target=\""+strItemTarget+"\" "+lineMouseover+" class=\""+strClass+"\">\n"
								}

							// piecing together the items with the building-blocks
								writeString = writeString + ''
								+ lineCellWidth+lineStart
						//		+ lineCellStart+lineLinkstart+lineArrow+lineIcon+lineItem+'&nbsp;&nbsp;&nbsp;'
								+ lineCellStart+lineLinkstart+lineArrow+lineIcon+linePijl+lineItem
								+ lineLinkend+lineCellEnd
								+ lineEnd

						}
						// end table
						if(booHorizontal){writeString = writeString + "</tr>\n"}
						writeString = writeString+ "</table></td></tr></table>\n"
					// end floating layer
					if (n==1){writeString = writeString+ "</LAYER>\n\n";}else if (ie==1 || m==1){writeString = writeString+ "</DIV>\n\n";}
				}
			}
		return writeString
		}
		

	// Ternary functions (functions that "manage"the secondary functions)
		// locks layerblocks' vertical position
		function menuscrolllockinit() {
			// set "child-block"
			for (var tellerA=1; tellerA<DBarray.length; tellerA++){
				block = DBarray[tellerA][0]
				blockItems = hasChild(block)
				if (blockItems>0){
					// store the position in easylayer.js' cache
					intMenuWidth = menuMinWidth+(borderWidth*2)
					intMenuHeight = blockItems*menuHeight+(borderWidth*2)
					defineLayer("blockDiv"+block,true,DBarray[block][6],DBarray[block][7],20,intMenuWidth,intMenuHeight,1,'','',false,false,scrollLock,edgeCompensation)
					// update the position
					setPosition('blockDiv'+block,DBarray[block][6],DBarray[block][7],20,intMenuWidth,intMenuHeight,true,true)
				}
			}
			// set "home-block"
			blockItems = hasChild(0)
			// store the position in easylayer.js' cache
			intMenuWidth = menuMinWidth+(borderWidth*2)
			intMenuHeight = blockItems*menuHeight+(borderWidth*2)
			defineLayer("blockDiv0",true,menuPosX,menuPosY,20,intMenuWidth,intMenuHeight,1,'','',false,false,scrollLock,edgeCompensation)
			// update the position
			setPosition('blockDiv0',menuPosX,menuPosY,20,intMenuWidth,intMenuHeight,1,true,true)
			// report the menus functional
			inits=1;
			// activate easylayers.js' scroll-lock
			if(scrollLock){intRefreshrate=menuPositionFrequency;setScrollLock()}
		}

		var objTimeout0 = 0; var objTimeout1 = 0; var intPreviousRequest = -1
		function menuShouldOpen(setblock){
			if(inits==1){
				// disable the menu closing
				menuShouldNotclose();
				// open the new item after a delay
				if(noDelay==1){
					showExclusive(setblock)
				}else{
					//do not reset timeouts of the same request
					if(intPreviousRequest!=setblock){
						intPreviousRequest = setblock
						clearTimeout(objTimeout1)
						objTimeout1 = setTimeout('intPreviousRequest=-1;showExclusive('+setblock+')',menuShowDelay)
					}
				}
			}		
		}

		function menuShouldClose(){
			if(inits==1){
				// clear previous timeout
				clearTimeout(objTimeout0)
				// start new timeout
				objTimeout0 = setTimeout('menuWillClose()',menuCloseDelay)
			}
		}
		
		function menuShouldNotclose(){
			// clear current timeout
			clearTimeout(objTimeout0)
		}
		
		function menuWillClose(){
			// close all menus
			hideall()
			// reporting back if possible
			if(reportToFrameSet)parent.imenuHasClosed()
		}	
	
	
	
	// executed inline
		if(typeof strMenu != 'undefined'){
			// pre-generate menus, if the foldout_document.js is included in the frameset
			strMenu = generateMenus()
		}else{
			//closes the menu if you click anywhere but on it
			if (ns){ 
				document.captureEvents(Event.CLICK); 
				document.onClick = menuWillClose; 
			}else{
				document.onClick = menuWillClose;
			}
			// write the menus to the page
			writeMenus()
			cacheMenuImages()
			document.close()
			menuscrolllockinit()
			unmarkAll()
		}
	
	
}

