//equalColumns script created by Kelsey Roach 2008.

// ===HOW TO USE===
// call this function on the page load and send 5 parameters. Each parameter is an element you would like to have the height altered for. If you want to check less than 5 elements, pass nulls in their place.
//EXAMPLE: <body onload="equalColumns('menu-wrapper', 'content-wrapper', '', '', '')">
//explanation: This will compare the elements 'menu-wrapper' and 'content-wrapper', determine which is the tallest, and set them equal to the tallest column., thus making them the same height.

function equalColumns(column01, column02, column03, column04, column05)
{
	var x = 0;
	var r = new Array(column01, column02, column03, column04, column05);
	
	//get and check heights
	for (i = 0; i < 5; i++)
	{	
		if (r[i] != "")
		{
			var y = document.getElementById(r[i]).offsetHeight;
		}
		
		if (y > x)
		{
			x = y;	
		}
	}
	
	//set heights
	for (i = 0; i < 5; i++)
	{
		//check if height exists and if so set the height of each element to the tallest
		if (r[i] == "")
		{
			//do nothing
		}
		else if (document.getElementById(r[i]).offsetHeight == x)
		{
			//do nothing
		}
		else
		{
			document.getElementById(r[i]).style.height = x + "px";
		}
		
		//compensate for any padding
		if (r[i] != "")
		{
			var k = document.getElementById(r[i])
			if (k.offsetHeight > x)
			{
				var rightHeight = (x - k.offsetHeight) + x
				k.style.height = rightHeight + "px";
			}
			else if (k.offsetHeight < x)
			{
				var rightHeight = (k.offsetHeight - x) + x
				k.style.height = rightHeight + "px";
			}
		}
	}
}