function skin_grow_cms_page_columns(num_columns, col_ids) {
  var setHeight = function(el, val) { el.style.height = val ? val + 'px' : ''; },
    absOffY = function(el) { return el.absoluteOffset()[1]; },
    contentEl = $('content'),
    col1El = $('col1'),
    innerColEls = col_ids.collect(function(c) { return $('col_'+num_columns+'_'+c); });
  
  if(innerColEls.include(null))
    innerColEls = [];
  
  setHeight(col1El);
  setHeight(contentEl);
  innerColEls.each(function(c) { setHeight(c); });
  
  if(innerColEls.length > 0) {
    var height = innerColEls.collect(function(c) { return c.getHeight(); }).max();
    innerColEls.each(function(c) { setHeight(c, height); });
  }
  
  var bodyHeight = $(document.body).getHeight(),
    viewportHeight = document.viewport.getHeight(),
    col1Height = col1El.getHeight();
  
  if(viewportHeight >= bodyHeight || viewportHeight < col1Height + absOffY(col1El)) {
    var contentHeight = contentEl.getHeight(),
      pad = bodyHeight - contentHeight;
    setHeight(contentEl, [col1Height, viewportHeight - pad, contentHeight].max());
  }
  setHeight(col1El, contentEl.getHeight() + absOffY(contentEl) - absOffY(col1El));
  
  return false;
}

function skin_grow_message_columns() {
  try { skin_grow_left_right_margins(); } catch(err) {}
  var col1_el = $('col1');
  if(col1_el) {
    var cols = [col1_el, $('col2')];
  } else if($('widecol')) {
    var cols = [$('widecol')];
  } else {
    return false;
  }
  try {
    var height = document.viewport.getHeight() - 65;
    if(cols[0]) {
      height -= cols[0].cumulativeOffset()[1];
    }
  } catch(err) {}
  cols.each(function(col) {
    try {
      col.style.height = '';
      col_height = col.getHeight();
      height = (col_height > height ? col_height : height);
    } catch(err) {}
  });
  try {
    if(col1_el)
      col1_el.setStyle({marginTop:'-10px', borderTopWidth:'0px', height:height + 5 + 'px'});
    $('content').style.height = height + 30 +'px';
  } catch(err) {}
}

function skin_grow_calendar_columns() {
  skin_grow_left_right_margins();
}

function skin_grow_left_right_margins() {
  var width = document.viewport.getDimensions().width;
  var left = Math.min(5,(Math.pow(width,5) / 327680000000000));
  $('frame').style.left = left + 'em';
  document.body.style.paddingRight = Math.max(1,(left/5)*7) + 'em';
}
