var steps=10;
var height=600;
var st=new Array();
for(x=0;x<steps+1;x++)
	{st.push(height/steps*x);}

var s;	
var where;
where=0;

function herinner()
	{
	v=getCookie("newlener");
	if (v!="" && v!=null && v!=undefined && v!=false)
		{
		document.getElementById("newlener").value=v;
		document.getElementById("remember").checked=true;
		}
	}

function checkCookie()
	{
	check=document.getElementById("remember").checked;
	if (check==true)
		{
		newval=document.getElementById("newlener").value;
		if (newval=="") {
			document.getElementById("remember").checked=false;
			alert("Vul a.u.b. eerst uw lenernummer in");
			}
		else
			{
			createCookie("newlener",newval,356);
			}
		}
	else
		{
		deleteCookie("newlener");
		}
	}

function recalcSt(n)
	{
	height=n;
	steps=10;
	st=new Array();
	for(x=0;x<steps+1;x++)
		{st.push(height/steps*x);}
	}

function moveDown()
	{
	document.getElementById("fotodoor").style.visibility="visible";
	str=st[where]+"px";
	
	i=document.getElementById("content").style.marginTop=str;
	i=document.getElementById("menu1").style.marginTop=str;
	i=document.getElementById("topright").style.marginTop=str;
	where++;
	if (where>steps) 
		{
		window.clearInterval(s);
		}
	}
	
function moveUp()
	{
	document.getElementById("fotodoor").style.visibility="hidden";
	if (where<0) {where=0;}
	if (where>st.length-1) {where=st.length-1;}
	str=st[where]+"px";
	if (st[where]<15) {str="15px";}
	i=document.getElementById("content").style.marginTop=str;
	i=document.getElementById("menu1").style.marginTop=str;
	i=document.getElementById("topright").style.marginTop=str;
	where--;
	if (where<0) 
		{
		window.clearInterval(s);
		where=0;
		window.scroll(0,0);
		}
	
	}
	
	
function vergroot(n)
	{
	if (n!=height) {recalcSt(n);}
	if (where==0) {s = window.setInterval("moveDown()", 10);}
	else {s = window.setInterval("moveUp()", 10);}
	}


function printMe()
	{
	//alert(window.opener.document.getElementById("tableMain").innerHTML);
	document.getElementById("content").innerHTML = window.opener.document.getElementById("text").innerHTML;
	return true;
	}

function printPage()
	{
	window.open("/printpage.htm","window","width=600,height=600,scrollbars=yes,resizable=yes,status=yes");
	}

function setFontSize(nr)
	{
	createCookie("fontsize",nr,356);
	history.go(0);
	}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function getCookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}	

function deleteCookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}


function URLDecode(psEncodeString)
{
  // Create a regular expression to search all +s in the string
  var lsRegExp = /\+/g;
  // Return the decoded string
  return unescape(String(psEncodeString).replace(lsRegExp, " "));
}
	
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function P7_autoLayers() { //v1.2 by PVII
 var g,b,k,f,args=P7_autoLayers.arguments;
 var a = parseInt(args[0]);if(isNaN(a))a=0;
 if(!document.p7setc) {p7c=new Array();document.p7setc=true;
  for (var u=0;u<10;u++) {p7c[u] = new Array();}}
 for(k=0; k<p7c[a].length; k++) {
  if((g=MM_findObj(p7c[a][k]))!=null) {
   b=(document.layers)?g:g.style;b.visibility="hidden";}}
 for(k=1; k<args.length; k++) {
  if((g=MM_findObj(args[k])) != null) {
   b=(document.layers)?g:g.style;b.visibility="visible";f=false;
   for(j=0;j<p7c[a].length;j++) {
    if(args[k]==p7c[a][j]) {f=true;}}
  if(!f) {p7c[a][p7c[a].length++]=args[k];}}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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 MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function zoneYellow(whichZone)
	{
	z = document.getElementById(whichZone);
	z.style.border='1px solid yellow';
	}
function zoneBlue(whichZone)
	{
	z = document.getElementById(whichZone);
	z.style.border='1px solid blue';
	}
function gotoPage(page)
	{
	//alert(document.location+"&zone="+whichZone);
	document.location=page;
	}
//alert(self.top.leftFrame.name);
//alert(window.parent.name);
//self.top.leftFrame.history.go(0); //refresh leftframe
PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;

function popImage (imageURL, caption) {

if (caption=="NL") {caption="Uitvergroting";}
if (caption=="EN") {caption="Large image";}


  var windowTop = 100;                // Top position of popup
  var windowLeft = 100                // Left position of popup
  var defaultWidth = 730;             // Default width (for browsers that cannot resize)
  var defaultHeight = 532;            // Default height (for browsers that cannot resize)
  var onLoseFocusExit = true;         // Set if window to exit when it loses focus
  var undefined;

  // Set up the window open options
  var Options = "width=" + defaultWidth + ",height=" + defaultHeight + ",top=" + windowTop + ",left=" + windowLeft + ",resizable"
  
  // Now write the HTML markup to the new window, ensuring that we insert the 
  // parameter URL of the image and the parameter description of the image in 
  // the right place.
  var myScript = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
    "<html>\n" + 
    "<head>\n" + 
    "<title>" + caption + "\</title>\n" +
    "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n" +
    "<meta http-equiv=\"Content-Language\" content=\"en-gb\">\n" +
    "<script language=\"JavaScript\" type=\"text/javascript\">\n" +
    "function resizewindow () {\n" +
    "  var width = document.myimage.width;\n" + 
    "  var height = document.myimage.height;\n";
  
  // Netscape  
  if (navigator.appName.indexOf("Netscape") != -1) {  
    myScript = myScript +  "  window.innerHeight = height;\n  window.innerWidth = width;\n"
  }
   
  // Opera 
  else if (navigator.appName.indexOf("Opera") != -1) {
    myScript = myScript +  "  window.resizeTo (width+12, height+31);\n"
  }
  
  // Microsoft 
  else if (navigator.appName.indexOf("Microsoft") != -1) { 
    myScript = myScript + "  window.resizeTo (width+12, height+31);\n" 
  }
  
  // Assume a frig factor for any other browsers
  else {
    myScript = myScript + "  window.resizeTo (width+14, height+34);\n"
  }
      
  myScript = myScript + "}\n" + "window.onload = resizewindow;\n" +
    "</script>\n</head>\n" + "<body ";
    
  // If the window is required to close when it loses focus.
  if (onLoseFocusExit) {myScript = myScript + "onblur=\"self.close()\" ";}
    
  myScript = myScript + "style=\"margin: 0px; padding: 0px;\">\n" +
    "<a href='javascript:window.close();'><img src=\"" + imageURL + "\" alt=\"" + caption + "\" title=\"" + caption + "\" name=\"myimage\" border='0'></a>\n" + 
    "</body>\n" +  "</html>\n";
        
  // Diagnostic - uncomment the next line if you wish to see the script generated.   
  //alert (myScript);
  
  // Create the popup window
  var imageWindow = window.open ("","imageWin",Options);
  imageWindow.document.write (myScript)
  imageWindow.document.close ();
  if (window.focus) imageWindow.focus();
  return false;
}

function goConfirm(msg,url)
	{
	if (msg==1)
		{msg = "Hiermee worden alle pagina's en menu's uit het geheugen gewist!";}
	if (msg==2)
		{msg = "Hiermee wordt de pagina permanent verwijderd!";}
	if (msg==3)
		{msg = "Hiermee wordt de backup permanent verwijderd!";}
	if (msg==4)
		{msg = "Hiermee wordt de pagina in het geheugen overschreven!";}
	if (msg==5)
		{msg = "Hiermee wordt dit onderdeel permanent verwijderd!";}
	if (msg==6)
		{msg = "Hiermee wordt dit onderdeel, inclusief de achterliggende pagina\n en eventuele submenu's, permanent verwijderd!";}
	ch = confirm ("Zeker weten?\n"+msg);

	
	if (ch==true)
		{window.document.location=url;}
	}
	
function MM_validateFormEN() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormEN.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+URLDecode(nm)+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+URLDecode(nm)+' 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(nm)+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+URLDecode(nm)+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\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]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+URLDecode(nm)+' moet een geldig e-mail adres bevatten.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+URLDecode(nm)+' 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(nm)+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+URLDecode(nm)+' ontbreekt\n'; }
  } if (errors) alert('De volgende informatie is incorrect:\n'+errors);

  document.MM_returnValue = (errors == '');
}


/* **********************************************************************************************8 */

	function getExtensionLess(inp)
		{
		if (inp==null) {alert("!!");return "";}
		uri = inp.split("/");
		filename =uri[uri.length-1];
		chunks=filename.split(".")
		extension =chunks[chunks.length-1];
		if(chunks.length==1) {return inp;}
		else
			{
			chunks.pop()
			without=chunks.join(".")
	
			uri.pop()
			uri.push(without)
			//alert(uri.join("/"));
			return uri.join("/");
			}
		}

	var aTreeMenu = new Array();
	var makeMenuParentsOpenMenu = true;
	var toAlter;
	var targetItem;

	var toAlter=location.href
		
		if (toAlter.indexOf("#")!=-1)
			{var toAlter= toAlter.substring(0,toAlter.indexOf("#"));}
		if (toAlter.indexOf("?")!=-1)
			{var toAlter= toAlter.substring(0,toAlter.indexOf("?"));}
			
		reg=new RegExp("-artikel-[0-9]{1,4}");
		b=toAlter.match(reg);
		reg2=new RegExp("-reactie-[0-9]{1,4}");
		b2=toAlter.match(reg2);
		
		if (b!=null)
			{var toAlter=toAlter.replace(b,"");}
		else if (b2!=null)
			{var toAlter=toAlter.replace(b2,"");}
		else
			{var toAlter=location.href;}
		
		//kap extensie eraf? -> JA!!!
		toAlter = getExtensionLess(toAlter)

	/**
	 * Run through the given list and check if a li node contains a ul node. 
	 * If this is true, create a clickable node to expand the ul
	 * @param object oTree
	 */
	function makeMenu(oTree){
		
		if (!oTree) {return true;}
		var oChilds = oTree.childNodes;
		
		var bLast = false;
		var aLastState = "";
		
		//dit is een hack om het menu goed te laten werken als er named href tags in de location.href zitten
		//er moet ook een check in voor -artikel-nr !!
		//en ook checken of het matcht ZONDER exensie (die choppen we er in de module af!)
		//volgorde is hier belangrijk!
		
		//alert(toAlter)
		// Iterate through every child
		
		for (var i=oChilds.length-1; i >= 0; i--){
		
			
			//alert(getExtensionLess(String(oChilds[i].firstChild)));
			//alert(getExtensionLess(String(oChilds[i].firstChild))+":::"+toAlter);
			if (getExtensionLess(String(oChilds[i].firstChild))==toAlter )
				{
				targetItem=oChilds[i];
				if(oChilds[i].firstChild.href.indexOf("#")==-1) //als dit niet gebeurt kleurt een pagina die niet in het menu voorkomt totaal blauw
					{oChilds[i].className='activeMenuItem';}
				} //hack om het actieve menu item weer te kunnen geven
			// Create a new submenu when the li element contains a ul element
			if(oChilds[i].nodeName == "LI" && hasSubmenu(oChilds[i])){
				
				// If this is the last node, give it a different class
				var sClassName = (arrayContains(aLastState, aTreeMenu.length))? " itemClose" : " itemClose";
				if(!bLast){
					oChilds[i].className += sClassName + "End";
					bLast = true;
				} else
					oChilds[i].className += sClassName;
				
				aTreeMenu[aTreeMenu.length] = oChilds[i];
					
				// If the boolean is set and the href of the firstChild A is '#'
				// the item opens and closes the menu
				
				
				
				if(makeMenuParentsOpenMenu && oChilds[i].firstChild.nodeName == "A"){
					
					if(oChilds[i].firstChild.href == location.href.replace("#","")+"#"){ //dit is de boosdoener
						
						oChilds[i].firstChild.href="javascript:void(0);";
						oChilds[i].firstChild.onclick = function(event){
							if(!event){
								//parentNode.parentNode omdat er h2 en h1 binnen de <a> zitten
								event = window.event;
								oObj = event.srcElement.parentNode.parentNode;
							} else
								oObj = event.target.parentNode.parentNode;
								
							event.cancelBubble = true;
							//gooi hier het menu dicht!
							//alert(oObj);
							closeMenu(oTree,oObj);
							switchClassname(oObj);
						};
					}
				}
				
				// Register the event handler for this node
				oChilds[i].onclick = function(event){ 
					if(!event){
						event = window.event;
						oObj = event.srcElement;
					} else
						oObj = event.target;
						
					event.cancelBubble = true;
					switchClassname(oObj);
				};
			} else if(oChilds[i].nodeName == "LI") {
				
				oChilds[i].className = "item " + oChilds[i].className;
				// If this is the last node, give it an extra class
				if(!bLast){
					oChilds[i].className += " endItem";
					bLast = true;
				}
			}
		}
		
	//if (openAt) {openParentNode(openAt);}
	}
	
	function closeMenu(menu,openItem)
		{
		//alert(openItem);
		var oChilds = menu.childNodes;
		
		for (var i=oChilds.length-1; i >= 0; i--)
			{
			if(oChilds[i])
				{
				//alert(oChilds[i]);
				if(oChilds[i].nodeName=="LI" && oChilds[i]!=openItem )
					{
					oChilds[i].className = oChilds[i].className.replace("itemOpen", "itemClose");
					//oObj.className = oObj.className.replace("itemOpen", "itemClose");
					}
				}
			}
		}
		
	/**
	 * Switch the classname of an object
	 * @param object oObj
	 */
	function switchClassname(oObj){
		
		if(oObj.className.indexOf("itemOpen") != -1){
			oObj.className = oObj.className.replace("itemOpen", "itemClose");
		} else if(oObj.className.indexOf("itemClose") != -1) {
			oObj.className = oObj.className.replace("itemClose", "itemOpen");
		}			
	
	}
	
	/**
	 * Checks if a list object contains a ul object
	 * @param object oList
	 * @return boolean
	 */
	function hasSubmenu(oList){
		var oMenuChilds = oList.childNodes;
		var bHasList = false;
		
		// Iterate through all the child nodes and search for a ul tag
		for(var j = 0; j < oMenuChilds.length; j++){
			if(oMenuChilds[j].nodeName == "UL") {
				makeMenu(oMenuChilds[j]);
				bHasList = true;
			}
		}
		return bHasList;
	}
	
	/**
	 * Finds the parent menu in which this item is placed and opens the menu
	 * @param object oItem
	 */
	function openParentNode(oItem){
	
		if(!oItem) {oItem=targetItem;}
		if(!oItem) {return;}
		if(oItem.parentNode.nodeName == "UL" && oItem.parentNode.parentNode.nodeName == "LI"){ //submenu open
		
			oMenu = oItem.parentNode.parentNode;
			oMenu.className = oMenu.className.replace("itemClose", "itemOpen");
			openParentNode(oMenu);
		}
		else if (oItem.parentNode.nodeName == "UL") //hoofditem
			{
			a=oItem.childNodes[0]; //link
			oItem.className = oItem.className.replace("itemClose", "itemOpen");

			//alert(oItem.className);
			
			}
	}
	
	
    
    /**
     * Checks if the needle exists in the haystack
     * @param array aSrc
     * @param string sNeedle
     * @return boolean
     */
    function arrayContains(aHayStack, sNeedle){
        for (var i = 0; i < aHayStack.length; i++) {
            if (aHayStack[i] == sNeedle)
            	return true;
        }
        return false;    	
    }
