var content_height = 0;
function expand_content() {
  if (content_height == 0) {
    content_height = $('#content').height();
  } else {
    $('#content').height(content_height);
  }
  var extra_room = $(document).height() - $('#main').height();
  if (extra_room > 0) {
    // workaround for now
    if ($("#links").length > 0) {
        $('#content').height(content_height + extra_room - 5);
    } else {
        $('#content').height(content_height + extra_room);
    }
  }
}

var hysteresis = function() {
  var delay = 200;
  var executionTimer;
  return function() {
    if (!!executionTimer) {
      clearTimeout(executionTimer);
    }
    executionTimer = setTimeout(expand_content, delay);
  };
}();

$(window).load(expand_content);
$(window).resize(hysteresis);

