
var maxHeight = 350;
var arr= new Array(2);
var arr_nr = 0;
function checkHeight()
{	var child;
	var rightColl = null;
	var leftColl = null;
	
	//alert(document.getElementById("main").offsetHeight);
	//search
	if(arr_nr <= 2)
	{	try
		{	var test = document.getElementById("mainleft").offsetHeight
			//checkChildNodes("mainleft", "true");
			leftColl = true;
			arr_nr++;
			arr.push("mainleft");
		}catch(error){}
		try{	arr.push("maincenter");	arr_nr++; }catch(error){}
		
		try
		{	var test = document.getElementById("mainright").offsetHeight;
			//checkChildNodes("mainright", "true");
			rightColl = true;	
			arr_nr++;
			arr.push("mainright");
		}catch(error){}
			
		//checkChildNodes("maincenter", "true");

		setAllDivs(arr);
	}
	
}

function checkChildNodes(parentDiv, count)
{
	var height = 0;	
	var parent = document.getElementById(parentDiv);
	var child;
	
	var size = parent.childNodes.length;
	
	if(parent.style.height != "" && parent.style.height != null)
		 parent.style.height = parent.offsetHeight;
	
	if(parent.offsetHeight > parent.style.height)
	{
		for(var i =0; i < size; i++)
		{  	child = parent.childNodes[i];
			
			if(count)
			{	if(!isNaN(child.offsetHeight))
					height += child.offsetHeight;
				//alert("count True :: child "+child+" offsetheight:"+child.offsetHeight+"height:"+height)
			}else
			{
				if(child.offsetHeight > maxHeight)
					maxHeight = child.offsetHeight;
			}
		}		
	}else if(arr.length == 1 && parent.style.height > maxHeight)
	{
		height = parent.offsetHeight;
	}else
	{ 	height = maxHeight;		
	}
	setToMaxAndCheck(parent, height)
		
}
function setAllDivs(arr)
{
	var divArrays = arr;
	for(var i = 0; i < divArrays.length; i++)
	{
		try{
			//komt hij niet
			setToMaxAndCheck(document.getElementById(divArrays[i]), document.getElementById(divArrays[i]).offsetHeight);
		}catch( error){}
	}
	for(var i = 0; i < divArrays.length; i++)
	{
		try	{	setToMax((divArrays[i])); }	catch(error){}
	}
	
}
function setToMaxAndCheck(idObj, heightV)
{
	var par= idObj;
	
	if(heightV > maxHeight)
	{	par.style.height=heightV+"px";
		maxHeight = heightV;
	}
	else
		par.style.height=maxHeight+"px";
	
	//alert("setToMaxAndCheck :: idObj ="+idObj.style.height+" height::"+maxHeight);
}
function setToMax(idName)
{
	var parent = document.getElementById(idName);
	parent.style.height=maxHeight+"px";
	
	//alert("setToMax :: idName ="+idName+" height::"+maxHeight);
}
