function getElementsByClass(sTagName, sClassName, oParent) {
  var aInElements;
  var aOutElements = new Array();
  aInElements = oParent.getElementsByTagName(sTagName);
  for(var i=0;i<aInElements.length;i++) {
    if(aInElements[i].className.match(sClassName)) {
      aOutElements.push(aInElements[i]);
    }
  }
  return(aOutElements);
}

function resizeBoxen() {
  var aBoxen, iMaxCols, oParentDiv, iRowHeight=0, iRowPos=0, iRowStart=0, iCurrentCols;
  if(document.getElementById('colMain')) {
    iMaxCols = 3;
    oParent = document.getElementById('colMain');
  } else if(document.getElementById('colLeft')) {
    iMaxCols = 2;
    oParent = document.getElementById('colLeft');
  } else {
    return;
  }
  aBoxen = getElementsByClass('div', /^box[123]col$/, oParent);
  for(var i=0;i<aBoxen.length;i++) {
    iCurrentCols = parseInt(aBoxen[i].className.substr(3,1));
    if((iRowPos+iCurrentCols) > iMaxCols) {
      for(var j=iRowStart;j<i;j++) {
        aBoxen[j].style.height = iRowHeight+'px';
      }
      iRowHeight = 0;
      iRowStart = i;
      iRowPos = iCurrentCols;
      iRowHeight = aBoxen[i].offsetHeight;
    } else {
      iRowPos += iCurrentCols;
      if(aBoxen[i].offsetHeight > iRowHeight) {
        iRowHeight = aBoxen[i].offsetHeight;
      }
    }
  }
  for(var j=iRowStart;j<i;j++) {
    aBoxen[j].style.height = iRowHeight+'px';
  }
}
