/*
	function that makes it possible to hide the loading box again when the page has fully loaded.
	created by Stefan Leever on 21-07-08
*/
var iFrame;

window.onload = function ()
{
		element = document.getElementById('onbeforeload');
		element.style.display = 'none';
		if (document.getElementById('layout') && document.getElementById('layout').nodeName == "DIV")
			var layoutLoad = document.getElementById('layout').innerHTML;
		if (layoutLoad != 'none')
			resizeIFrame(layoutLoad);
};

window.onresize = function()
{
		if (document.getElementById('layout') && document.getElementById('layout').nodeName == "DIV")
			var layoutLoad = document.getElementById('layout').innerHTML;
		if (layoutLoad != 'none')
			resizeIFrame(layoutLoad);
}

function getParent(element, classname) {
	var parent = element;
	do
	{
		parent = parent.parentNode;
	}
	while(parent.className != classname);
	return parent;
}

function getInternetExplorerVersion() {

    var rv = -1; // Return value assumes failure.

    if (navigator.appName == 'Microsoft Internet Explorer') {

        var ua = navigator.userAgent;

        var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");

        if (re.exec(ua) != null)

            rv = parseFloat(RegExp.$1);

    }

    return rv;

}

function resizeIFrame(layout)
{

	if (layout == '4') {
		subtractFromWidth 	= 15;
		subtractFromHeight 	= 0;
		lastAddition		= 0;
	}else if(layout == '4-1'){
		subtractFromWidth 	= 0;
		subtractFromHeight 	= -101;
		lastAddition	 	= 0;
	}else if(layout == '4-2'){
		subtractFromWidth 	= 200;
		subtractFromHeight 	= 40;
		lastAddition	 	= 0;
	}else if(layout == '4-2-hn'){
		subtractFromWidth 	= 200;
		subtractFromHeight 	= 40;
		lastAddition	 	= 0;
	}else if(layout == '6'){
		subtractFromWidth 	= 168;
		subtractFromHeight 	= 28;
		lastAddition	 	= 0;
	}else if(layout == '6-1'){
		subtractFromWidth 	= 168;
		subtractFromHeight 	= 28;
		lastAddition	 	= 0;
	}else if(layout == '1-1'){
		subtractFromWidth 	= 175;
		subtractFromHeight 	= 28;
		lastAddition	 	= 0;
	}else if(layout == '3-1'){
		subtractFromWidth 	= 495;
		subtractFromHeight 	= 28;
		lastAddition	 	= 0;
	}else if(layout == '7-1'){
		subtractFromWidth 	= 130;
		subtractFromHeight 	= 28;
		lastAddition	 	= 0;
	}else if(layout == '9'){
		subtractFromWidth 	= 190;
		subtractFromHeight 	= 28;
		lastAddition	 	= 0;
	}else{
		subtractFromWidth 	= 12;
		subtractFromHeight	= 0;
		lastAddition		= 0;
	}
	if (layout == '4' || layout == '3-2') {
		/* nothing here */
	}else if (layout == ''){
		var mainNav = document.getElementById('main-nav');
		if (!mainNav)
			return false;
		var pageNavigation = getParent(mainNav, 'page-navigation');
	}
	iFrame = document.getElementsByClassName('page-content');
	iFrame = iFrame[0];
	if (!iFrame)
		return false;
	if (iFrame.nodeName != 'IFRAME')
		return false;
		
	var x,y;
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	//calculate width:
	var width = x;
	if (pageNavigation) {
		width -= pageNavigation.offsetWidth;
	}
	
	filler = document.getElementById('filler');
	if (filler) {
		width -= filler.width+25;
	}
	
	pageNews = document.getElementsByClassName('news');
	pageNews = pageNews[0];
	
	if (pageNews) {
		width -= pageNews.offsetWidth;
	}
	
	iFrame.style.width = (width-subtractFromWidth)+'px';
	
	//calculate hight:
	var height = y;
	hilite = document.getElementsByClassName('hilites');
	hilite = hilite[0];
	pageFooter = document.getElementsByClassName('page-footer');
	pageFooter = pageFooter[0];
	pageHeader = document.getElementsByClassName('page-header');
	pageHeader = pageHeader[0];
	if (hilite && hilite.nodeName == 'DIV') {
		
		/**
		 *	create an exception here for vanderlaan because counting the hilites isn't
		 *	appropiate here. (01-09-08).		 
		 */		 		
	
		if (layout == '4-1') {
		height -= (hilite.offsetHeight);
		}
	}
	
	if (pageFooter) {
		height -= (pageFooter.offsetHeight);
	}
	
	if (subtractFromHeight != 0) {
		height -= subtractFromHeight;
	}
	
	if (pageHeader) {
		height -= pageHeader.offsetHeight;
	}
	
	iFrame.style.height = (height+lastAddition)+'px';
}
