var oActBlock;

function init()
{
	menuInitialiseren();
	SetBodyHeight();
}
function menuInitialiseren()
{
	sBlockId = readCookie('menuPCPO');
	if(sBlockId)
	{
		oActBlock = null;
		toggle(sBlockId)
	}
	else
	{ 
		oActBlock = null;
	}
}

function createCookie(name,value,days)
{
	document.cookie = name+"="+value;
}

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;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}

function toggle(sBlockId) // bijv toggle('scholen') voor <div id="scholen">
{ //Get block elements
	
	var oElement = document.getElementById(sBlockId);
	if(!oElement)
	{
		return;
	}

  //Als er een block zichtbaar is:
	if(oActBlock)
	{ //Hide de actieve blocken
		draw(oActBlock, 0);
	 
		//Toon eventueel het element wat zichtbaar moet worden
		//Als het een ander element is dan degene die zichtbaar was
		if(oElement != oActBlock)
		{
			draw(oElement, 1);
			oActBlock = oElement;
		}
		else 
		{
			oActBlock = null; 
		}
	}
	else
	{
		draw(oElement, 1);
		oActBlock = oElement;
	}
	createCookie('menuPCPO',sBlockId); 
}

function draw(oElem, bShow)
{    //Set parameters
	if(bShow)
	{
		sDis = "block"; sSrc = "../gfx/minus.gif";
	}
	else
	{
		sDis = "none"; sSrc = "../gfx/plus.gif";
	}
	
	//Find image
	
	//Set display
	oElem.style.display = sDis;
	SetBodyHeight();
}
function SetBodyHeight()
{
	var ContentWidth = 0; //Width of content area in Browser
	var ContentHeight = 0; //Height of content area in Browser
	var PageHeight = document.getElementById('holder').offsetHeight; //Height of content in page
	var left = document.getElementById('left').offsetHeight;
	var right = document.getElementById('right').offsetHeight;

	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	if (typeof window.innerWidth != 'undefined')
	{
		ContentWidth = window.innerWidth,
		ContentHeight = window.innerHeight
	}
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
	{
		ContentWidth = document.documentElement.clientWidth,
		ContentHeight = document.documentElement.clientHeight
	}
	// older versions of IE
	else
	{
		ContentWidth = document.getElementsByTagName('body')[0].clientWidth,
		ContentHeight = document.getElementsByTagName('body')[0].clientHeight
	}

	if(PageHeight < ContentHeight)
	{
		var extrasize = ContentHeight-PageHeight-56; // -56px height of footer
		if(left < right)
		{
			document.getElementById('left').style.height = PageHeight + extrasize + 'px';
		}
		else
		{
			document.getElementById('right').style.height = PageHeight + extrasize + 'px';
		}
	}
	else {/*do nothing*/}
}

/* hide div */
function HideContent(d)
{
	if(d.length < 1)
	{
		return;
	}
	document.getElementById(d).style.display = "none";
}

/* show div */
function ShowContent(d)
{
	if(d.length < 1)
	{
		return;
	}
	document.getElementById(d).style.display = "block";
}

/* show or hide divs */
function ReverseContentDisplay(d)
{
	//var div = document.getElementsByTagName(d);
	if(d.length < 1)
	{
		return;
	}
	if(document.getElementById(d).style.display == "none")
	{
		document.getElementById(d).style.display = "block";
	}
	else
	{
		document.getElementById(d).style.display = "none";
	}
}

function ReverseContentDisplayfitness(d)
{
	if(d.length < 1)
	{
		return;
	}
	var sportscholen = new Array('AadvanLoon','Wellnesslande','TopGym')
	for (var i=0; i<sportscholen.length; i++) // hide all divs
	{
		if (sportscholen[i] != d)
		{
			document.getElementById(sportscholen[i]).style.display = "none";
			document.getElementById(sportscholen[i] + '_a').className = "icon_plus";
		}
	}
	if(document.getElementById(d).style.display == "none")//show standard div
	{
		document.getElementById(d).style.display = "block";
		document.getElementById(d + '_a').className = "icon_min";
	}
	else
	{
		document.getElementById(d).style.display = "none";
		document.getElementById(d + '_a').className = "icon_plus";
	}
}

/* preload images */
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];
    	}
    }
}