jQuery(document).ready(function() {
  var colHeight = 0;
  var colLeft = jQuery('#bodyColumnLeft');
  var colCenter = jQuery('#bodyColumnCenter');
  var colRight = jQuery('#bodyColumnRight');
  var colCount = 0;
  if(colLeft && (colLeft.length > 0)) {
    colCount++;
    colLeft.addClass('pageRowBox');
    colLeft.html('<div class="bodyColumnPadder">'+colLeft.html()+'</div>');
    if(colLeft.height() > colHeight) {
      colHeight = colLeft.height();
    }
  } else {
    colLeft = null;
  }
  if(colCenter && (colCenter.length > 0)) {
    colCount++;
    colCenter.addClass('pageRowBox');
    colCenter.html('<div class="bodyColumnPadder">'+colCenter.html()+'</div>');
    if(colCenter.height() > colHeight) {
      colHeight = colCenter.height();
    }
  } else {
    colCenter = null;
  }
  if(colRight && (colRight.length > 0)) {
    colCount++;
    colRight.addClass('pageRowBox');
    colRight.html('<div class="bodyColumnPadder">'+colRight.html()+'</div>');
    if(colRight.height() > colHeight) {
      colHeight = colRight.height();
    }
  } else {
    colRight = null;
  }
  if(colCount == 3) {
    colCenter.css('margin-left', '17px');
  }
  if(colLeft) {
    colLeft.height(colHeight);
  }
  if(colCenter) {
    colCenter.height(colHeight);
  }
  if(colRight) {
    colRight.height(colHeight);
  }


  var boxList = jQuery('.pageRowBox');
  jQuery.each(boxList, function(index, item) {
    var jItem = jQuery(item);
    var boxH = jItem.find('.BOXHEADER');
    if(boxH.length > 0) {
      var boxHItem = jQuery(boxH[0]);
      var boxHText = boxHItem.text();
      boxH.remove();
      var newHeader = jQuery('<div></div>').addClass('pageBoxHeader').text(boxHText);
      newHeader.appendTo(jItem);
    }
  });


  var colHeight = 0;
  if(colLeft) {
    if(colLeft.height() > colHeight) {
      colHeight = colLeft.height();
    }
  }
  if(colCenter) {
    if(colCenter.height() > colHeight) {
      colHeight = colCenter.height();
    }
  }
  if(colRight) {
    if(colRight.height() > colHeight) {
      colHeight = colRight.height();
    }
  }
  if(colLeft) {
    colLeft.height(colHeight);
  }
  if(colCenter) {
    colCenter.height(colHeight);
  }
  if(colRight) {
    colRight.height(colHeight);
  }


  var aReplace = jQuery('.SEARCHBOX');
  jQuery.each(aReplace, function(index, item) {
    var jItem = jQuery(item);
    var jParent = jItem.parent();
    var sHTML = '<input type="input" name="search" id="searchField" class="SMALL" />';
    var frm = jQuery('<form></form>');
    frm.addClass('searchForm');
    frm.attr('method', 'post');
    frm.attr('action', '/?page=search');
    frm.html(sHTML);
    jItem.remove();
    frm.appendTo(jParent);
  });

  var spanAdd = '&raquo; ';
  var aList = jQuery('.submenuleft-item a,.submenuleft-item span');
  jQuery.each(aList, function(index, item) {
    var jItem = jQuery(item);
    jItem.html(spanAdd+jItem.html());
  });
});
