/**
 * Fixes the height of the scrollable container div.
 * It needs to be 100% less the height of the top bar in order to fill
 * the remainder of the client window.
 */
var ContainerHeightFixer = {

  CONTAINER_ID : "outer_container",
  TOP_BAR_HEIGHT : 21,
  
  init : function() {
  
    var _this = this;
    window.onresize = function() {
      _this.applyFix();
    };
    this.applyFix();
  
  },
  
  applyFix : function() {
  
    try {

      var clientHeight = this.getClientHeight();
      var newContainerHeight = clientHeight - this.TOP_BAR_HEIGHT;
      var containerDiv = document.getElementById( this.CONTAINER_ID );
      
      containerDiv.style.height = newContainerHeight + "px";
      
    } catch( err ) {
      // Ignore errors - better for the div just to have the wrong height    
    }
      
  },

  getClientHeight : function() {  

    if (window.innerHeight) {
      return window.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
      return document.documentElement.clientHeight;
    } else if (document.body) {
      return document.body.clientHeight;
    }
    
  }
  
}

