function getFirstBoxChild(box) {
   if (!box.hasChildNodes) { return false; }
   var i = 0;

   var child = box.childNodes[i];
   var childtype = child.nodeName;
   childtype = childtype.toLowerCase();
   
   while (child.nodeType != 1 || (childtype == 'img')) {
      i++;
      child = box.childNodes[i];
      childtype = child.nodeName;
      childtype = childtype.toLowerCase();
   }
   
   if (child.nodeType == 1 & childtype != 'img') { return child; }
   else { return false; }
}

function initEqualBoxes() {
   var divClassName = "smallbox";
   var divChangeHeight = 3;
   
   var boxes = $$('.' + divClassName);
   var boxesRow = new Array();

   if (!boxes || (boxes && boxes.length <= 1)) { return 0; }
   
   var siblingBox = boxes[0] ;
   while (siblingBox.nodeType == 1 && siblingBox.className == divClassName) {
      boxesRow.push(siblingBox);
      
      siblingBox = siblingBox.nextSibling;
      while (siblingBox.nodeType!=1) { siblingBox = siblingBox.nextSibling; }
   }
   
   if (!boxesRow || (boxesRow && boxesRow.length <= 1)) { return 0; }
   
   for (var i=0; i<=boxesRow.length; i+=2) {
      var box1 = boxesRow[i];
      var box2 = boxesRow[i+1];
     
      if (box1 && box1 !== undefined) { box1 = box1.getElementsByClassName("content")[0]; }
      if (box2 && box2 !== undefined) { box2 = box2.getElementsByClassName("content")[0]; }
      if (box1 && box1 !== undefined) { box1 = getFirstBoxChild(box1); }
      if (box2 && box2 !== undefined) { box2 = getFirstBoxChild(box2); }
      
      if (box1 && box2 && box1 !== undefined && box2 !== undefined) {
         var height1 = box1.offsetHeight;
         var height2 = box2.offsetHeight;
         
         finalheight = (height1 > height2) ? height1 : height2;
         box1.style.height = finalheight+'px';
         box2.style.height = finalheight+'px';
      }
   }
}

window.addEvent('load',function(){
	initEqualBoxes();
});