/*
Uses Mochikit, so mochikit needs to be included before this
Just apply the CSS class of 'matching-column' to your divs
*/

function getHeight(e) {
	if (e.offsetHeight) {
		return e.offsetHeight;
	} else if (e.pixelHeight) {
		return e.pixelHeight;
	}
}

function matchColumns(){
	contDivs = getElementsByTagAndClassName('div', 'matching-column');
	maxHeight=0;
	for (i=0;i<contDivs.length;i++) {
		maxHeight=Math.max(maxHeight,getHeight(contDivs[i]));
	}
	for (i=0;i<contDivs.length;i++) {
		if (getHeight(contDivs[i]) < maxHeight) {
			contDivs[i].style.height = maxHeight+'px';
		}
	}
}

function resizestuff() {
	contDivs = getElementsByTagAndClassName('div', 'matching-column');
	maxHeight=0;
	for (i=0;i<contDivs.length;i++) {
		if (contDivs[i].offsetHeight) {
			divHeight = contDivs[i].offsetHeight;
		} else if (contDivs[i].style.pixelHeight) {
			divHeight = contDivs[i].style.pixelHeight;
		}
		maxHeight=Math.max(maxHeight,divHeight);
	}
	for (i=0;i<contDivs.length;i++) {
		contDivs[i].style.height = 'auto';
	}
	matchColumns();
}

addLoadEvent(matchColumns);
// This breaks IE horribly:
//window.onresize=resizestuff;
