// JavaScript Document

function matchHeight()
{
//alert("matching heights");
	var divs,contDivs,maxHeight,divHeight,d, hstr="",str = "";

	// get all <div> elements inthe document
	divs=document.getElementsByTagName('div');
	contDivs=[];
	// initialize maximum height value
	maxHeight=0;
	// iterate over all <div> elements in the document
	for(var i=0;i<divs.length;i++)
	{
		
		// make collection with <div> elements with class attribute 'heightAdjusted'
		if(/\bheightAdjusted\b/.test(divs[i].className))
		{
			
			d=divs[i];
			contDivs[contDivs.length]=d;
			// determine height for <div> element
			if(d.offsetHeight){
				divHeight=d.offsetHeight;
			}
			else if(d.style.pixelHeight){
				divHeight=d.style.pixelHeight;
			}
			hstr +=  "\ndivID: " + divs[i].getAttribute("id") + "- scrollHeight: " + d.scrollHeight
														   + " style.pixelHeight: " + d.style.pixelHeight	
														   + " offsetHeight: " + d.offsetHeight	
  													       + " clientHeight: " + d.clientHeight	
														   + "offsetParent: " + d.offsetParent.getAttribute("id")
															+ "\n";
			
			str += "divID: " + divs[i].getAttribute("id") + "- height: " + divHeight + "\n";
			// calculate maximum height
			maxHeight=Math.max(maxHeight,divHeight) - 40;
		}
	}
	//alert(str + "maxheight: " + maxHeight + hstr);
	
	// assign maximum height value to all of heightAdjusted <div> elements

	for(var i=0;i<contDivs.length;i++){
		
		contDivs[i].style.height=maxHeight;
		var ht = "" + maxHeight + "px";
		contDivs[i].style.minHeight = ht; // seem to need this for firefox
		
	}
	
}

// execute function when page loads

window.onload=evenOutColumns;

function evenOutColumns()
{
	if(document.getElementsByTagName){
		matchHeight();
	}
}