// Copyright Apposite
// site: http://apposite.nl

//Goes threw the childs of apropriate DIV parent.
//Gets the offsetHeight en sets the heights correctly to highest value
var maxHeight = 300;


function checkHeight()
{	var child;

	//search
	//checkChildNodes("content", "true");
	
	checkChildNodes("main", "true");
	checkChildNodes("menu_vert", "true");
	
	//set correct height

	var mainOffset = document.getElementById("content").offsetHeight;
	
	//if(document.getElementById("main").offsetHeight > mainOffset)
	//	mainOffset = document.getElementById("main").offsetHeight;
	
	/*if(document.getElementById("content").offsetHeight > mainOffset)
		mainOffset = document.getElementById("content").offsetHeight;*/
	//alert( document.getElementById("content").offsetHeight+ "  vs. "+maxHeight);
	
	if(mainOffset > maxHeight)
		maxHeight = mainOffset;

	//document.getElementById("content").style.height=maxHeight+"px";
	/*document.getElementById("main").style.height=maxHeight+"px";
	document.getElementById("menu_vert").style.height=maxHeight+"px";*/
		
	checkStyleAndMaxHeight(document.getElementById("content"), maxHeight);
	checkStyleAndMaxHeight(document.getElementById("main"), maxHeight);
	checkStyleAndMaxHeight(document.getElementById("menu_vert"), maxHeight);	
	
}

function checkStyleAndMaxHeight(obj, maxHeight)
{
	obj.style.height=maxHeight+"px";
	//alert(obj.offsetHeight+" en maxHeight ="+maxHeight);
	if(parseInt(obj.offsetHeight) > parseInt(maxHeight))
	{	var difference = (obj.offsetHeight)-(maxHeight);
		obj.style.height = (maxHeight-difference)+"px";
	}	
	
}
function checkChildNodes(parentDiv, count)
{
	var height = 0;	
	var parent = document.getElementById(parentDiv);
	var child;
	
	var size = parent.childNodes.length;
	//alert("checkChildNodes"+size);

	for(var i =0; i < size; i++)
	{  	child = parent.childNodes[i];
	
		if(count)
		{	if(!isNaN(child.offsetHeight))
				height += child.offsetHeight;
		}else
		{
			if(child.offsetHeight > maxHeight)
				maxHeight = child.offsetHeight;
		}	
	}
		
	if(height > maxHeight)
	{	parent.style.height=height+"px";
		maxHeight = height;
	}
	//else
	//	parent.style.height=maxHeight+"px";
	
}
function setHomeHeight()
{
	maxHeight = 900; 
	
	document.getElementById("maincenter").style.height=maxHeight+"px";
	document.getElementById("mainright").style.height=maxHeight+"px";
	document.getElementById("mainleft").style.height=maxHeight+"px";
	
	
	
	document.getElementById("maincenter").style.height=maxHeight+"px";
	document.getElementById("mainright").style.height=maxHeight+"px";
	document.getElementById("mainleft").style.height=maxHeight+"px";
	
	checkStyleAndMaxHeight(document.getElementById("maincenter"), maxHeight);
	checkStyleAndMaxHeight(document.getElementById("mainright"), maxHeight);
	checkStyleAndMaxHeight(document.getElementById("mainleft"), maxHeight);	
}
