var OVERFLOW_ELEMENT_TOP_OFFSET = 176;
var OVERFLOW_ELEMENT_LEFT_OFFSET = 176;
var OVERFLOW_ELEMENT_HORIZONTAL_PADDING = 23;

/* Vraag de clientarea van de browser op. Let op: dit script mag niet in
 * de HEAD van de pagina worden uitgevoerd. Op dat moment bestaat
 * 'document.body' namelijk nog niet.
 * Dus alleen na de BODY tag, op window.onload of op window.onresize.
*/
function getClientSize() {
	if (window.innerWidth){
		// gecko, opera
		return {width:window.innerWidth,height:window.innerHeight};
	} else if (document.documentElement.clientHeight) {
		// IE 6
		return {width:document.documentElement.clientWidth,height:document.documentElement.clientHeight};
	} else if (document.body) {
		// IE 5.x
		return {width:document.body.clientWidth,height:document.body.clientHeight};
	}
	return null;
}

function setOverflowElementSize(width, height)
{
	var overflowElement = document.getElementById('overflow');
	overflowElement.style.width = width + 'px';
	overflowElement.style.height = height + 'px';
}

function resizeOverflowElement(asStyle)
{
	var dw =  getClientSize();
	var newWidth = ( dw.width - OVERFLOW_ELEMENT_LEFT_OFFSET ) - OVERFLOW_ELEMENT_HORIZONTAL_PADDING;
	if ( newWidth < 0 ) newWidth = 0;
	//if ( newWidth > OVERFLOW_ELEMENT_MAX_WIDTH ) newWidth = OVERFLOW_ELEMENT_MAX_WIDTH;
	var newHeight = dw.height - OVERFLOW_ELEMENT_TOP_OFFSET;
	if ( newHeight < 0 ) newHeight = 0;

	if (!asStyle) {
		setOverflowElementSize(newWidth, newHeight);
	} else {
		return "#overflow{width:"+newWidth+"px;"+"height:"+newHeight+"px;}";
	}
}

window.onresize = function()
{
	resizeOverflowElement();
}


////////////////////////////////////////
function InitializeMenu()
	{
		if (document.all && document.getElementById)
		{
			var navRoot = document.getElementById("nav").getElementsByTagName('UL')[0];
			for (i=0; i<navRoot.childNodes.length; i++)
			{
				node = navRoot.childNodes[i];
				if (node.nodeName == "LI")
				{
					node.onmouseover=function()
					{
						this.className+=" over";
					}
					node.onmouseout=function()
					{
						this.className=this.className.replace(" over", "");
					}
				}
			}
		}
	}
