// JavaScript Document v3.2
// updated: 19/03/2005

// Laatste toevoegingen:
// 10/03/2005 - Zoekwaarschuwing & fix voor fragment highlight.
// 15/04/2005 - Min-height simulatie als document minder dan 3 'item' divs telt.
// 22/07/2005 - Aanpassingen aan diverse routines, toevoeging van min-width simulatie & bannerroutine
// 30/08/2005 - Extra check op aanwezigheid table met class 'item' ivm paginahoogte+banners op detailpagina's en doelgroeppagina's


// check OS for pixel perfect placing
var detect = navigator.userAgent.toLowerCase();
var OS,browser,total,thestring;
var version = 0;
// variabele grens voor top menu; als er meer dan 9 submotieven komen dit getal vergroten.
var SafariMenuborder=220;

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
/***********************************************
BUG FIX MAC/SAFARI
***********************************************/
var safariLinkfix = 0;
if (OS == "Mac")
{
	if (browser == "Safari")
        {
        safariLinkfix = 102;
    }  
    leftdif=29;
    }else {
	leftdif=44;
}


/***********************************************
BASIC GET ID AND HIDE/SHOW LAYER
***********************************************/
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_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; }
}


/***********************************************
LINK SCRIPT
***********************************************/
function setLyr(obj,lyr)
{   var newX = findPosX(obj);
	var newY = findPosY(obj);
	var x = new getObj(lyr);
	x.style.top = newY + 'px';
	x.style.left = newX + 'px';
}
// set link layercolor to only to y position and totale screen width
function setlink(obj,lyr,linkCatagory)
{  // position layer
    var newX = 16;
	var newY = findPosY(obj);
	var x = new getObj(lyr);
	x.style.left = newX + 'px';
	// bug fix safari 

   var DoelTop = document.getElementById("doelnav");
   if ( DoelTop ){
      x.style.top = newY + 'px';
      }else{
        if(newY <SafariMenuborder){
		 x.style.top = newY + safariLinkfix + 'px';
           }else{
		 x.style.top = newY + 'px';
		}
}
   var s=linkCatagory;
   document.getElementById('link').className= s;
   //
   MM_showHideLayers('link','','show')
}


function findPosX(obj)
{   var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{ var curtop = 0;
	var printstring = '';
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			printstring += ' element ' + obj.tagName + ' has ' + obj.offsetTop;
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	//window.status = printstring;
	return curtop;
}

function getObj(name)
{
 if (document.getElementById)
 {
	   this.obj = document.getElementById(name);
	   this.style = document.getElementById(name).style;
 }
 else if (document.all)
 {
	   this.obj = document.all[name];
	   this.style = document.all[name].style;
 }
 else if (document.layers)
 {
	   if (document.layers[name])
	   {
	   	this.obj = document.layers[name];
	   	this.style = document.layers[name];
	   }
	   else
	   {
	    this.obj = document.layers.testP.layers[name];
	    this.style = document.layers.testP.layers[name];
	   }
 }
}
/***********************************************
 SUBMENU BUILDER
************************************************/
/***********************************************
* Contractible Headers script- � Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use. Last updated Oct 21st, 2003.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
/***********************************************
* Contractible Headers script- � Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use. Last updated Oct 21st, 2003.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var enablepersist="on" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="yes" //Collapse previously open content when opening present? (yes/no)
var ccollect=new Array()

if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switchcontent{display:none;}')
document.write('</style>')
}

function getElementbyClass(classname){
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
ccollect[inc++]=alltags[i]
}
}

function contractcontent(omit){
var inc=0;
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
backgroundresetter(inc)
inc++
}
}

function backgroundresetter(d){
var nonbox='nav0'+(d+1);
document.getElementById(nonbox).className="none";
}

function expandcontent(cid){
 var allBodys = document.getElementsByTagName("body");
 var firstBody = allBodys.item(0).id;
 var lastBody = allBodys.item(allBodys.length-1).id;
 var catagorie = firstBody;
//
if (typeof ccollect!="undefined"){
if (collapseprevious=="yes")
  contractcontent(cid)
  document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
//
 var cleanID=(cid.substr(3,5));
 document.getElementById(cleanID).className=catagorie;
}
}

function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block";
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
 var allBodys = document.getElementsByTagName("body");
 var firstBody = allBodys.item(0).id;
 var lastBody = allBodys.item(allBodys.length-1).id;
 var catagorie = firstBody;
 //
if ( returnvalue != "") {
 var cleanStoredID=(returnvalue.substr(3,5));
document.getElementById(cleanStoredID).className=catagorie;
}
return returnvalue;
}

function getselectedItem(){
selectedItem=get_cookie("navigation");

return selectedItem;

}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie="navigation="+selectedItem
}

function do_onload(){
getElementbyClass("switchcontent")
if (enablepersist=="on" && typeof ccollect!="undefined")
revivecontent()
}

//if (window.addEventListener)
//window.addEventListener("load", do_onload, false)
//else if (window.attachEvent)
//window.attachEvent("onload", do_onload)
//else if (document.getElementById)
//window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate

/* Fragment Highlight version 0.1 */

//*** This JavaScript highlight code is copyright 2003 by David Dorward; http://dorward.me.uk
//*** Re-use or modification permitted provided the previous line is included and
//*** modifications are indicated

/*********** Start of JavaScript Library *********/

//*** This JavaScript library is copyright 2002 by Gavin Kistner and Refinery; www.refinery.com
//*** Re-use or modification permitted provided the previous line is included

//Adds a new class to an object, preserving existing classes
function AddClass(obj,cName){ KillClass(obj,cName); return obj.className+=(obj.className.length>0?' ':'')+cName; }

//Removes a particular class from an object, preserving other existing classes.
function KillClass(obj,cName){ return obj.className=obj.className.replace(new RegExp("^"+cName+"\\b\\s*|\\s*\\b"+cName+"\\b",'g'),''); }

/*********** End of JavaScript Library ***********/

/* Fragment Highlight */

/* Indicates area that has been linked to if fragment identifiers have
 * been used. Especially useful in situations where a short fragment
 * is near the end of a page. */

var fragHLed = '';
var fragExclude = ('header');

Array.prototype.search = function(myVariable) { for(x in this) if(x == myVariable) return true; return false; }

/* Highlight link target if the visitor arrives at the page with a # */

function fragHLload() {
    fragHL(location.hash.substr(1));
}

/* Highlight link target from an onclick event after unhighlighting the old one */

function fragHL(frag) {
    if (fragHLed.length > 0 && document.getElementById(fragHLed)) {
	KillClass(document.getElementById(fragHLed),'fragment');
    }
    if (frag.length > 0 && document.getElementById(frag)) {
	fragHLed = frag;
	AddClass (document.getElementById(frag),'fragment');
    }
}

/* Add onclick events to all <a> with hrefs that include a "#"  */

function fragHLlink() {
	if (document.getElementsByTagName) {
	var an = document.getElementsByTagName('a');
	for (i=0; i<an.length; i++) {
		// 10/03/2005: Included extra check to skip '#' hrefs used in Dynamic Drive menus.
		alink = an.item(i).href;
		ahash = alink.substr(alink.indexOf('#'));
		if ((alink.indexOf('#') >= 0) && (ahash.length > 1)) {
			var fragment = ahash.substr(1);
			if (fragExclude.search(fragment)) {
				var evn = "fragHL('" + fragment + "')";
				var fun = new Function('e',evn);
				an.item(i).onclick = fun;
			}
		} 
	}
}
}


/***********************************************
// layer positioner script
***********************************************/
function getRealLeft(id) { 
var el = getElement(id); 
if (el) { 
xPos = el.offsetLeft; 
tempEl = el.offsetParent; 
while (tempEl != null) { 
xPos += tempEl.offsetLeft; 
tempEl = tempEl.offsetParent; 
} 
return xPos; 
} 
} 

function getRealTop(id) { 
var el = getElement(id); 
if (el) { 
yPos = el.offsetTop; 
tempEl = el.offsetParent; 
while (tempEl != null) { 
yPos += tempEl.offsetTop; 
tempEl = tempEl.offsetParent; 
} 
return yPos; 
} 
} 

function getRealRight(id) { 
return getRealLeft(id) + getElement(id).offsetWidth; 
} 

function getRealBottom(id) { 
return getRealTop(id) + getElement(id).offsetHeight; 
} 

// check OS for pixel perfect placing
isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
IEmac = ((document.all)&&(isMac)) ? true : false;
IE4plus = (document.all) ? true : false;

if (isMac){
	leftdif=29;
	} else {
	leftdif=44;
	}

function itemplacer(mover_id, fixer_id) { 
var el = getElement(mover_id); 
if (el) { 
var fix_top = getRealTop(fixer_id)-58; 
var fix_lt = getRealLeft(fixer_id)-leftdif; 
//
el.style.left = fix_lt + 'px'; 
el.style.top = fix_top + 'px';
} 
}

function getElement(id) { 
return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null; 
} 

/***********************************************
DIV RIGHT WIDTH 
***********************************************/
function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function setLayerWidth(){
	var desiredW= getWindowSize() - 31;
	MM_changeProp('logohover','','style.width',desiredW + 'px','DIV');
	MM_changeProp('link','','style.width',desiredW + 'px','DIV');

	// Toevoeging 22/07/2005: Beperk de breedte van de pagina-div als er een banner wordt getoond.
	if (banner_loaded) document.getElementById('pagina').style.width = (desiredW + 'px');
}

function getWindowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  // Toevoeging 22/07/2005: check op aanwezigheid banner; dan breedte van pagina zelf 
  // 150px kleiner maken bij grote schermbreedtes, of vaste minimale maat 780 bij kleine vensterbreedte.
  var newWidth;
  
  if (banner_loaded && document.compatMode && document.compatMode == 'CSS1Compat' && browser == 'Internet Explorer') {
    // IE in standards mode is toch net weer anders...
    newWidth = (myWidth > 970) ? (myWidth-150) : 820;
  } else if (banner_loaded) {
    // dan de Gecko's en IE5/Mac's met een banner.
    newWidth = (myWidth > 930) ? (myWidth-150) : 780;
  } else {
    // Geen banner, dan gewone oude routine.
    newWidth = myWidth;
  }
  
  return newWidth;
}



/////////////////////////////////////////////
//
//   ZOEKWAARSCHUWING v0.1
//
/////////////////////////////////////////////
//
//   WERKING & VOORWAARDEN
//   Wordt aangeroepen vanuit document om zoekwaarschuwing te includen, en
//   lift mee op de 'window.onload' van portal.js om het verschijnen/verbergen
//   mogelijk te maken. Zie wijziging in portal.js op regel #
//   
//   AANROEP FUNCTIE TBV INCLUDEN AFBEELDING
//   if (warning_loaded) { includeWarning({type},{width},{height},{alt}) }
//   
//   VARIABELEN
//   {type}    @string    {zoek|expzoek} geeft aan of het gewone (zoek) of
//                        uitgebreide (expzoek) zoekwaarschuwing is.
//   {width}   @integer   breedte van het plaatje.
//   {height}  @integer   hoogte van het plaatje.
//   {alt}     @string    alternatieve tekst voor in plaatje.
//
//   Overige gegevens (pad naar afbeelding op server, id) worden 
//   herleid uit de variabele {type}.
//
//   NB 1: geen van de functies heeft een test op volledige of juiste
//         doorgifte van variabelen. Goed de syntax checken van de
//         functie-oproepen dus!
//   NB 2: functie gaat uit van 'text/html' als content-type; 
//         document.write faalt bij content-type 'application/xhtml+xml'!
//
/////////////////////////////////////////////

var warning_loaded = false;  // vlag voor beschikbaarheid functie
var img_dir    = 'pix/';     // pad op server naar directory met afbeeldingen.
var base_class = 'warning';  // basis voor id, class en enkele tests.
var img_string = '';


// Basisfunctie om waarschuwingsafbeeldingen in document te schrijven.
// 
function includeWarning(type,width,height,alt) {
	// Bouw het [img] element op met gegeven globals en argumenten.
	img_string  = '<img src="' + img_dir + type + '_waarschuwing.gif" ';
	img_string += 'width="'    + width          + '" ';
	img_string += 'height="'   + height         + '" ';
	img_string += 'alt="'      + alt            + '" ';
	img_string += 'class="'    + base_class     + '" ';
	img_string += 'id="'       + base_class     + '-' + type + '" />';
	
	// Schrijf element in document.
	document.write(img_string);
}


// Toon een waarschuwing
// 
function showWarning(warning_type) {
	document.getElementById(base_class + '-' + warning_type).style.visibility = 'visible';
	if(warning_type.indexOf('exp') < 0) {
		document.getElementById('label-' + warning_type).className = base_class;
	} else {
		document.getElementById(warning_type).className = base_class;
	}
}


// Verberg de waarschuwingen bij sluiten uitgebreide zoekvenster.
//
function hideWarnings() {

   try {

   	document.getElementById(base_class + '-zoek').style.visibility = 'hidden';
	   document.getElementById('label-zoek').className = '';
	   document.getElementById(base_class + '-expzoek').style.visibility = 'hidden';
	   document.getElementById('expzoek').className = '';
	} catch (excep) {
	   // No more warnings in my life.
	}
}

// Check het basisformulier
// 
function checkZoek() {
	if (document.getElementById('z-invul').value == '') {
		showWarning('zoek');
		return false;
	}
	
	return true;
}


// Check het uitgebreide formulier
// 
function checkExpZoek() {
	var exp_box_ok = false;
	var exp_key_ok = false;
	var exp_form = document.getElementById('zoek02');
	var exp_fields = exp_form.getElementsByTagName('input');
	
	for (var i = 0; i < exp_fields.length; i++) {
		if (exp_fields[i].type == 'checkbox' && exp_fields[i].checked == true) {
			exp_box_ok = true;
		} else if (exp_fields[i].type == 'text' && exp_fields[i].value != '') {
			exp_key_ok = true;
		}
	}
	
	if (!(exp_box_ok || exp_key_ok)) {
		showWarning('expzoek');
	}
	return (exp_box_ok || exp_key_ok);
}


// Initialiseer de routines en hang ze aan de betreffende formulieren.
// 
function initWarnings() {
	if (document.getElementById && document.getElementsByTagName) {
		// Basis zoekveld
		if ((typeof(document.getElementById('normaal')) == 'object')
		 && (typeof(document.getElementById(base_class + '-zoek')) == 'object')) {
			document.getElementById('normaal').onsubmit = function() { return checkZoek() }
		}
		
		// Uitgebreid zoekveld
		if ((typeof(document.getElementById('zoek02')) == 'object')
		 && (typeof(document.getElementById(base_class + '-expzoek')) == 'object')) {
         try {
            document.getElementById('zoek02').onsubmit = function() { return checkExpZoek() }
         } catch (excep) {
            // Do nothing here.
         }
		}
	}
}

warning_loaded = true;       // alles bestaat, dus aanroepen kan.


/////////////////////////////////////////////
//
//   MIN-HEIGHT SIMULATIE v0.2
//
/////////////////////////////////////////////
//
//   WERKING & VOORWAARDEN
//   Checkt of voldoende content aanwezig is (aantal 'item' divs >= 3) en
//   lift mee op de 'window.onload' van portal.js. Bij onvoldoende content wordt aan
//   div met id 'content' een extra class meegegeven voor min-height simulatie.
//   
//   VARIABELEN
//   Niet van toepassing.
//
//   NB 1: class 'item' hoeft niet eerste of enige class van div te zijn.
//   NB 2: De class 'min' is niet meer nodig ivm dynamisch bekijken vereiste hoogte.
//
//   TOEVOEGING 22/07/2005
//   Extra functie getMenuHeight bepaalt maximale uitklaphoogte menu. Vervolgens kan
//   doMinHeight bepalen welke hoogte aan de content-div moet worden gegeven om eventuele
//   advertorials en/of banners de ruimte te geven.
//
/////////////////////////////////////////////

function doMinheight() {
	var finalHeight = 0;      // Resulterende hoogte, voorlopig nul.
	var advertHeight = 400;   // Drie advertorials van 6 regels tekst.
	var bannerHeight = 600;   // Banners zijn maximaal 120 x 600 pixels.
	
	// Tel aantal 'item' divs.
	var itemCount = 0; // Beginnen met 0 item divs.
	var allDivs = document.getElementsByTagName('div'); // Bouw array met alle divs in huidige document.
	
	for (var i = 0; i < allDivs.length; i++) {
		if (allDivs[i].className.indexOf('item') >= 0) itemCount++; // Check op aanwezigheid 'item' in attribuut 'class' van elke div.
	}
	

	// Serie checks voor het aanpassen van de hoogte van de pagina bij weinig content
	// of aanwezigheid van banner of advertorials.
	// Mogelijkheden:
	// 1) Pagina met banner/advertorial en table class=item        > geen hoogte aanpassing
	// 2) Pagina met banner/advertorial, geen table class=item     > hoogte aanpassen afhankelijk van banner/advertorial
	// 3) Pagina heeft geen banner/advertorial, wel weinig content > hoogte aanpassen door class aan contentdiv te hangen
	
	// Haal table op indien aanwezig en check op class 'item'.
	var allTables = document.getElementsByTagName('table') ? document.getElementsByTagName('table') : null;
	var itemTableExists = false;
	var itemTable;
	
	// Loop door alle table elementen op de pagina en zet de vlag 'itemTableExists' als de gezochte class inderdaad wordt gevonden.
	if (allTables) {
		for (var i = 0; i < allTables.length; i++) {
			if (allTables[i].className.indexOf('item') > -1) {
				itemTableExists = true;
				itemTable = allTables[i];
			}
		}
	}
	
	// Bepaal op welke wijze de paginahoogte wordt aangepast.
	if (!itemTableExists) {
		
		// Gezochte tabelclass bestaat niet, dus oude checks doorlopen.
		if ((document.getElementById('bannerscript') && itemCount < 2) || (document.getElementById('advertorials') && itemCount < 4)) {
			// 1: Wel adverts of banners, maar niet genoeg items om de 'main' div op te rekken naar voldoende hoogte.
			if (document.getElementById('bannerscript')) {
				finalHeight = bannerHeight;
			}
			
			if (document.getElementById('advertorials')) {
				finalHeight = advertHeight + getMenuHeight();  // Hoogte menu kan oplopen, dus dynamisch.
			}
	
			// En zet als laatste het betreffende style attribuut.
			if (document.getElementById('content')) {
				document.getElementById('content').style.height = finalHeight + 'px';
			} else if (document.getElementById('motiefnav')) {
				document.getElementById('motiefnav').style.height = finalHeight + 'px';
			} 
			
			// Omzeil renderbug in IE6/Win die de code wel correct doorloopt, maar footer niet opnieuw rendert.
			if (browser == 'Internet Explorer' && document.compatMode && document.compatMode == 'CSS1Compat') {
				document.getElementById('footer').style.visibility = 'hidden';
				document.getElementById('footer').style.visibility = 'visible';
			}
		} else if (itemCount < 3 && document.getElementById('content')) {
			// 2: Geen adverts of banners, maar wel te weinig items om menu te 'clearen'
			AddClass(document.getElementById('content'),'min');
		}
	} else {
		// Gezochte class is gevonden, dus we zitten op een detail of doelgroeppagina, dus padding zetten.
		var allTds = itemTable.getElementsByTagName('td');
		
		// Doorloop alle tabelcellen, en pas de padding toe op de cel met class 'img'.
		for (i = 0; i < allTds.length; i++) {
			if (allTds[i].className == 'img') {
				allTds[i].style.paddingBottom = '400px';
			}
		}
	}
}


function getMenuHeight() {
	// Bepaal eerst het maximum aantal menuitems dat op enig moment zichtbaar is.
	var navMenu = document.getElementById('subnav');
	var allMenus = navMenu.getElementsByTagName('ul');
	var menuCount = (allMenus.length - 1);                   // Lengte van hoofdmenu.
	var itemCount = 0;                                       // Zet teller submenulengte op nul.
	var paddingOffset = 55;                                  // Extra ruimte ivm padding.
	
	for (var i = 0; i < allMenus.length; i++) {
		if (allMenus[i].className == 'switchcontent') {      // Is dit een menuitem?
			var thisMenuLength = allMenus[i].getElementsByTagName('li').length;
			
			if (thisMenuLength > itemCount) {
				itemCount = thisMenuLength;                  // Langste submenu? Dan bijhouden.
			}
		}
	}
	
	// Bepaal de hoogte van een enkel menuitem.
	var itemHeight = 13;
	
	// Bereken de totalen.
	totalMenuCount = (menuCount+itemCount);
	totalMenuHeight = (totalMenuCount * itemHeight) + paddingOffset;

	return totalMenuHeight;
}


function doMinwidth() {
	var minWidth = 930;
  	
  	// Bouw de CSS op die nodig is om ruimte te houden bij kleinere vensterbreedten.
	if (browser == 'Internet Explorer' && OS != 'Mac') {
		// Zet voor IE een minimale breedte.
		document.getElementById('container').style.width = (((document.compatMode && document.compatMode=='CSS1Compat') ? document.documentElement.clientWidth : document.body.clientWidth) < minWidth ? (minWidth + "px") : "auto");
	} else if (document.getElementById('pagina').style.minWidth) {
		// En voor Gecko en Safari een min-width variant.
		document.getElementById('container').style.minWidth = (minWidth + "px");
	}
}


/////////////////////////////////////////////
//
//   BANNER INCLUDEN + POSITIONEREN v0.1
//
/////////////////////////////////////////////
//
//   WERKING & VOORWAARDEN
//   Plaats een banner iframe in de pagina en positioneer deze.
//   
//   AANROEP FUNCTIE TBV INCLUDEN AFBEELDING
//   includeBanner({url})
//   
//   VARIABELEN
//   {url}     @string    URL naar bannerdocument -- kan op eigen server, maar ook extern zijn.
//
/////////////////////////////////////////////

var banner_loaded;           // Vlag om bij te houden of een banner op de pagina staat.
var iframe_string = '';      // Nog niks geen iframe.
var iframe_width = 120;      // Breedte en hoogte voor iframe.
var iframe_height = 600;

function includeBanner(urlPath) {
	// Bouw het [iframe] element op met gegeven globals en argumenten.
	iframe_string  = '<div id="banner" style="position: relative;">';
	iframe_string += '<iframe src="' + urlPath       + '" ';
	iframe_string += 'width="'       + iframe_width  + '" ';
	iframe_string += 'height="'      + iframe_height + '" ';
	iframe_string += 'id="bannerframe" frameborder="0" marginwidth="0" marginheight="0" style="position: absolute; top: -1000px; left: -1000px; z-index: 100;">';
	iframe_string += '</iframe></div>';

	// Schrijf element in document.
	document.write(iframe_string);

	// Zet vlag 'banner aanwezig'.
	banner_loaded = true;
}


function moveBanner() {
	// Bereken horizontale plek van banner: verschilt tussen homepage en overige pagina's.
	var bannerPosX = 0, bannerPosY = 0;                 // Begin beide op nul.
	
	if (document.getElementById('kalender') || document.getElementById('motiefnav')) {
		bannerPosX = (getWindowSize() - 15);            // Breedte van scherm, minus linkermarge van 15px.
	} else if (document.getElementById('content') && document.getElementById('content').className.indexOf('detail') >= 0) {
		bannerPosX = (getWindowSize() - 15);      // Breedte van scherm, minus navigatiekolom en linkermarge van 15px.
	} else if (document.getElementById('content')) {
		bannerPosX = (getWindowSize() - 15 - 200);      // Breedte van scherm, minus navigatiekolom en linkermarge van 15px.
	} else if (document.getElementById('driekolom')) {
		bannerPosX = (getWindowSize() - 15);            // Breedte van scherm, minus linkermarge van 15px.
		bannerPosY = -8;                                // Iets omhoog ivm extra witruimte boven bannerdiv.
	}
	
	if (browser == 'Internet Explorer' && OS != 'Mac' && !document.compatMode) {
		bannerPosX += 31;                               // Correcties voor IE5.5+/win.
	}
	
	document.getElementById('bannerframe').style.left = bannerPosX + 'px';
	document.getElementById('bannerframe').style.top  = bannerPosY + 'px';
}


/////////////////////////////////////////////
//
//   EXPZOEK CHECKBOX TOGGLE
//
/////////////////////////////////////////////
//
//   WERKING & VOORWAARDEN
//   Lift mee op de 'window.onload' van portal.js om onclick events aan
//   categorie checkboxen te koppelen (alle vinkjes aan/uit in categorie).
//
/////////////////////////////////////////////
function initExpZoekform() {
	var exp_zoekform = (document.getElementById('expzoek')) ? document.getElementById('expzoek') : null;
	if (!exp_zoekform) return;
	
	var all_legends = exp_zoekform.getElementsByTagName('legend');
	for (i = 0; i < all_legends.length; i++ ) {
		var checkbox = all_legends[i].getElementsByTagName('input')[0];
		checkbox.onclick = toggleCheckbox;
	}
}

// Eigenlijke functie: toggle de onderliggende inputs op basis van categoriebox.
//
function toggleCheckbox() {
	var all_checkboxes = this.parentNode.parentNode.getElementsByTagName('input');
	
	for (i = 1; i < all_checkboxes.length; i++) {
		all_checkboxes[i].checked = all_checkboxes[0].checked;
	}
	
	return true;
}


/***********************************************
Startup script
***********************************************/
function initiateAll(){
   fragHLload();
   fragHLlink();
   if (warning_loaded) initWarnings();   // Toevoeging 10/03/2005: Init dynamische zoekwaarschuwingen.
   doMinheight();                        // Toevoeging 15/04/2005 + 22/07/2005: Init min-height simulatie voor korte pagina's.
   if (banner_loaded) moveBanner();      // Toevoeging 22/07/2005: Init bannerscript voor positioneren banners en regelen schermbreedte.
   if (banner_loaded) doMinwidth();      // Toevoeging 22/07/2005: Init min-width simulatie voor pagina's met banner.
   setLayerWidth();                      // Ombouw 19/07/2005: Aanroep naar setLayerWidth om getWindowSize ook los te kunnen aanroepen.
   initExpZoekform();                    // Toevoeging 06/12/2005: Init checkboxscript voor zoekform.
   do_onload();
}

/* Init the script */
window.onload = function() {
	initiateAll();
}

window.onresize = function() {
    setLayerWidth();
    if (banner_loaded) moveBanner();
}
