

	// Force IE6 to cache background images
	try {
		document.execCommand('BackgroundImageCache', false, true);
	} catch(err) {}


	// standalone onDomReady function
	window.onDomReady = function(fn){
		window.__ondom_functionArray.push(fn);
	};
	(function(){
		window.__ondom_functionArray = [];
		function _runFunctions(){
			for (var i in window.__ondom_functionArray){
				(window.__ondom_functionArray[i])();
			}
		};
		var _khtml = /(WebKit|khtml)/i.test(navigator.userAgent);
		if(document.addEventListener && !_khtml){
			document.addEventListener('DOMContentLoaded', _runFunctions, false);
		}else if(_khtml){
			var _timer = setInterval(function(){
				if(/loaded|complete/.test(document.readyState)){
					clearInterval(_timer);
					_runFunctions();
				}
			}, 10);
		}else{
			document.write('<script id=__ie_ondom defer src=javascript:void(0)><\/script>');
			var script = document.getElementById('__ie_ondom');
			script.onreadystatechange = function(){
				if(this.readyState == 'complete'){
					_runFunctions();
				}
			};
		}
	})();


	// on dom ready
	onDomReady(function(){


		// check position of the footer; and make it happen every time the window resizes
		checkFooterPosition();
		addEvent(window, 'resize', checkFooterPosition);


		// make external links open in new window
		var externalLink, externalLinks = getElementsByClassName('extern', 'a');
		for (var i = 0; externalLink = externalLinks[i]; i++)
		{
			externalLink.target = '_blank';
		}


		// enable the print button
		if ($('print'))
		{
			$('print').onclick = function(){
				this.blur();
				window.print();
				return false;
			};
		}

		// enable the mail button
		if ($('mail'))
		{
			$('mail').onclick = function(){
				window.location = "mailto:?subject=mail van een vriend&body=" + escape("Onderstaande link lijkt me interessant voor jou:\n\n" + document.location.href);
				return false;
			};
		}


		// set search field cursor behavior
		// replace by clone to surely remove focus in IE
		if ($('searchValue'))
		{
			if (document.all)
			{
				var searchValueInput = $('searchValue').cloneNode(true), searchValueInputParent = $('searchValue').parentNode;
				searchValueInputParent.removeChild($('searchValue'));
				searchValueInputParent.appendChild(searchValueInput);
			}
			else
			{
				var searchValueInput = $('searchValue');
			}
			if (searchValueInput.value) searchValueInput.style.backgroundImage = 'url()';
			addEvent(searchValueInput, 'focus', function(){
				this.style.backgroundImage = 'url()';
			});
			addEvent(searchValueInput, 'blur', function(){
				if (!this.value) this.style.backgroundImage = 'url(images/inputCursor.gif)';
			});
		}


		var isGecko, menu = $('menu');
		// for gecko (firefox) add padding to the submenus
		if (isGecko = (navigator.product == 'Gecko' && !(navigator.userAgent.toLowerCase().indexOf(' applewebkit/') > -1) && !(!!window.opera)))
		{
			// add padding
			var subMenu, subMenus = getElementsByClassName('subItems', 'div', menu);
			for (var i = 0; subMenu = subMenus[i]; i++)
			{
				subMenu.style.paddingLeft = '8px';
			}
		}
		// get the active menu items
		var activeTopItem, activeSubItem, activeSubMenu;
		var defaultActiveTopItem, defaultActiveSubItem, defaultActiveSubMenu, defaultActiveItems = getElementsByClassName('active', 'a', menu);
		if (defaultActiveItems.length)
		{
			defaultActiveTopItem = defaultActiveItems[0];
			defaultActiveSubItem = defaultActiveItems[1];
			if (defaultActiveSubItem) activeSubMenu = defaultActiveSubMenu = defaultActiveSubItem.parentNode;
		}
		// make top menu items with submenus open it on mouseover (and close the active submenu)
		// and disable these items their link
		// make top menu items without submenus close the active submenu
		// also position the submenu to align them to their topItem
		var subMenu, menuItem, menuItems = menu.getElementsByTagName('a');
		var menuItemPosition, subMenuHeight, menuPosition, menuNumber = 0;
		for (var i = 0; menuItem = menuItems[i]; i++)
		{
			// top menu item
			if (menuItem.parentNode.tagName.toLowerCase() == 'td')
			{
				if (subMenu = getSubMenu(menuItem))
				{
					addEvent(menuItem, 'mouseover', (function (scope, menuItem, subMenu) {
						return function(e)
						{
							(function(){
								// menu item
								if (defaultActiveTopItem) removeClassName(defaultActiveTopItem, 'active');
								if (activeTopItem) removeClassName(activeTopItem, 'active');
								activeTopItem = menuItem;
								addClassName(menuItem, 'active');
								// sub menu
								if (activeSubMenu) activeSubMenu.style.display = 'none';
								if (activeSubItem) removeClassName(activeSubItem, 'active');
								(activeSubMenu = subMenu).style.display = 'block';
							}).call(scope);
						};
					})(this, menuItem, subMenu));

					menuItem.style.cursor = 'default';
					menuItem.onclick = function(){
						this.blur();
						return false;
					};

					// submenu position
					menuItemPosition = 24 * menuNumber;
					subMenuHeight = subMenu.getElementsByTagName('a').length * 17;
					if (menuItemPosition + subMenuHeight > 153) menuPosition = menuItemPosition - (menuItemPosition + subMenuHeight - 153);
					else menuPosition = menuItemPosition;
					subMenu.style.top = menuPosition + (menu.getElementsByTagName('a')[0].offsetTop / (isGecko ? 1 : 2)) + 'px';
				}
				else
				{
					addEvent(menuItem, 'mouseover', (function (scope, menuItem) {
						return function(e)
						{
							(function(){
								// menu item
								if (defaultActiveTopItem) removeClassName(defaultActiveTopItem, 'active');
								if (activeTopItem) removeClassName(activeTopItem, 'active');
								activeTopItem = menuItem;
								addClassName(menuItem, 'active');
								// sub menu
								if (activeSubMenu) activeSubMenu.style.display = 'none';
								activeSubMenu = null;
							}).call(scope);
						};
					})(this, menuItem));
				}

				menuNumber++;
			}
			// sub menu item
			else
			{
				addEvent(menuItem, 'mouseover', (function (scope, menuItem) {
					return function(e)
					{
						(function(){
							// menu item
							if (defaultActiveSubItem) removeClassName(defaultActiveSubItem, 'active');
							if (activeSubItem) removeClassName(activeSubItem, 'active');
							activeSubItem = menuItem;
							addClassName(menuItem, 'active');
						}).call(scope);
					};
				})(this, menuItem));
			}
		}
		// make the active submenu to disappear on mouseout of the menu
		// and show the default active menu if there is one
		addEvent(menu, 'mouseout', (function (scope, menuItem, subMenu) {
			return function(e)
			{
				(function(){
					if (!isDescendantOf((e.relatedTarget || e.toElement), menu))
					{
						if (activeSubMenu) activeSubMenu.style.display = 'none';
						if (activeTopItem) removeClassName(activeTopItem, 'active');
						if (activeSubItem) removeClassName(activeSubItem, 'active');
						if (defaultActiveTopItem) addClassName(defaultActiveTopItem, 'active');
						if (defaultActiveSubMenu)
						{
							defaultActiveSubMenu.style.display = 'block';
							activeSubMenu = defaultActiveSubMenu;
							addClassName(defaultActiveSubItem, 'active');
						}
						else
						{
							activeSubMenu = null;
						}
					}
				}).call(scope);
			};
		})(this, menuItem, subMenu));


	});


	// ensure that the footer is on the bottom of the page
	function checkFooterPosition()
	{
		if (!$('contentBg')) return;

		$('contentBg').style.paddingBottom = '0px';

		var documentScrollHeight  = getDocumentScrollHeight();
		var footerTop = $('footer').offsetTop;
		var delta = documentScrollHeight - (footerTop + 315);

		if (delta > 0) $('contentBg').style.paddingBottom = (parseInt(getComputedCssProperty($('contentBg'), 'paddingBottom', 'padding-bottom').replace('px')) + delta) + 'px';
	}



	// --- common functions ---


	compatMode = document.compatMode;
	userAgent = navigator.userAgent.toLowerCase();
	isOpera = (userAgent.indexOf('opera') > -1);
	isIE = (!isOpera && userAgent.indexOf('msie') > -1);

	// get the document's scroll height
	function getDocumentScrollHeight()
	{
		var scrollHeight = (compatMode != 'CSS1Compat' ? document.body.scrollHeight : document.documentElement.scrollHeight);

		return Math.max(scrollHeight, getViewportHeight());
	}
	// get the viewport's height
	function getViewportHeight()
	{
		var height = window.innerHeight;

		if ((compatMode || isIE) && !isOpera)
		{
			height = (compatMode == 'CSS1Compat' ? document.documentElement.clientHeight : document.body.clientHeight);
		}

		return height;
	}


	// get computed style property of an element
	// cssProperty is the javascript property notation (e.g. 'backgroundColor') and mozillaEquivalentCss is the CSS notation (e.g. 'background-color')
    function getComputedCssProperty(htmlElement, cssProperty, mozillaEquivalentCss)
	{
        if (arguments.length == 2) {
            mozillaEquivalentCss = cssProperty;
        }   
        if (htmlElement.currentStyle) {
            return htmlElement.currentStyle[cssProperty];
        }
        if (typeof(document.defaultView) == 'undefined') {
            return undefined;
        }
        if (document.defaultView === null) {
            return undefined;
        }
        var style = document.defaultView.getComputedStyle(htmlElement, null);
        if (typeof(style) == 'undefined' || style === null) {
            return undefined;
        }
        return style.getPropertyValue(mozillaEquivalentCss);
    }


	// get sub menu of menuTopItem
	function getSubMenu(menuTopItem)
	{
		while(menuTopItem.nextSibling)
		{
			if (menuTopItem.nextSibling.nodeType == 1 && menuTopItem.nextSibling.tagName.toLowerCase() == 'div')
			{
				return menuTopItem.nextSibling;
			}
			else if (menuTopItem.nextSibling.nodeType == 1 && menuTopItem.nextSibling.tagName.toLowerCase() == 'a')
			{
				return false;
			}
			 menuTopItem =  menuTopItem.nextSibling;
		}

		return false;
	}


	// very simple $ function
	function $(id)
	{
		return document.getElementById(id);
	}


	// get next element, optionally of specfic tagName
	function getNextElement(element, tagName)
	{
		while(element.nextSibling)
		{
			if (element.nextSibling.nodeType == 1 && (!tagName || element.nextSibling.tagName.toLowerCase() == tagName))
			{
				return element.nextSibling;
			}
			element = element.nextSibling;
		}

		return false;
	}


	// standalone getElementsByClassName function from http://www.robertnyman.com/index.php?p=256
	function getElementsByClassName(className, tagName, parent)
	{
		var
			testClass = new RegExp("(^|\\s)" + className + "(\\s|$)"),
			tagName = tagName || '*', parent = parent || document,
			elements = (tagName == '*' && parent.all)? parent.all : parent.getElementsByTagName(tagName),
			returnElements = [], current, length = elements.length;

		for(var i=0; i<length; i++){
			current = elements[i];
			if(testClass.test(current.className)){
				returnElements.push(current);
			}
		}

		return returnElements;
	}


	// check whether an element has a specific class
	function hasClassName(element, name)
	{
		var i, list = element.className.split(" ");

		for(i = 0; i < list.length; i++)
			if(list[i] == name)
				return true;

		return false;
	}


	// adds a className to an element
	function addClassName(element, className)
	{
		removeClassName (element, className);
		element.className = (element.className + ' ' + className).replace(/^\s+|\s+$/g, '');
	}


	// removes a className from an element
	function removeClassName(element, className)
	{
		element.className = element.className.replace(className, '').replace(/^\s+|\s+$/g, '');
	}


	// better addevent function
	function addEvent(element, type, fn)
	{
		if (element.addEventListener)
		{
			element.addEventListener(type, fn, false);
		}
		else if (element.attachEvent)
		{
			element['e' + type + fn] = fn;
			element[type + fn] = function() {
				element['e' + type + fn](window.event);
			};
			element.attachEvent('on' + type, element[type + fn]);
		}
	}


	// check whether a child element is contained by an ancestor element
	function isDescendantOf(child, parent, guaranteeDescendant)
	{
		if (guaranteeDescendant && child) child = child.parentNode;

		while (child)
		{
			if(child == parent) return true;

			child = child.parentNode;
		}

		return false;
	}


	// create cookie function from http://www.quirksmode.org/js/cookies.html
	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=/";
	}


	// read cookie function from http://www.quirksmode.org/js/cookies.html
	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}


	// erase cookie function from http://www.quirksmode.org/js/cookies.html
	function eraseCookie(name) {
		createCookie(name,"",-1);
	}


