var FixHeight = Class.create({
  initialize: function(container, grow) {
    this.container = container;
    this.growElement = grow;
    
    this.changeHeight();
    Event.observe(window, 'resize', this.changeHeight.bindAsEventListener(this));
  },
  
  changeHeight: function() {
    var containerHeight = this.container.getHeight(),
        growElementHeight = this.growElement.getHeight(),
        documentHeight = document.viewport.getHeight(),
        correctedHeight;

    if (containerHeight < documentHeight) {
      correctedHeight = growElementHeight + (documentHeight - containerHeight);
      this.growElement.setStyle({ height: correctedHeight + 'px' });
    }
  }
});

document.observe('dom:loaded', function() {
  new FixHeight($('container'), $('grow'));
});

