
// width and height of stuff other than the name list on the page
var wOffset=0;
var hOffset=0;
var minHeight=0;
var minWidth=0;
var divObj; // object to resize
var divName='UNKNOWN_DIV';

var firstTime=true;

/*
  Make the div with the given ID grow as the window is resized.
  Params:
  - id: id of the div to resize
  - woff: width-offset to maintain from the right border (0 means all the way over)
  - hoff: height-offset to maintain from the bottom border (0 means all the way down)
  - minw: min width to resize div to (0 means shrink as small as needed)
  - minh: min height to resize div to (0 means shrink as small as needed)

  NOTE: only one div can be made resizable on a given page
 */
function makeDivResizable(id,woff,hoff,minw,minh)
{
  divName=id;
  wOffset=woff;
  hOffset=hoff;
  minWidth=minw;
  minHeight=minh;
  window.onresize=resizeDiv;
}

function resizeDiv()
{
  var ht;
  var wd;
 
  if(!divObj) divObj=getObject(divName);
  if(!divObj) return;

  if (window.innerHeight) // moz
  {
    ht = window.innerHeight;
    wd = window.innerWidth;
  }
  else if (window.document.body.clientHeight) // ie
  {
    ht = window.document.body.clientHeight;
    wd = window.document.body.clientWidth;
  }
  else return;

  var divTop = divObj.offsetTop;
  var divLeft = divObj.offsetLeft;

  // resize the namelist div based on the height of the window
  var newHeight=Math.max(minHeight, ht - divTop - hOffset);
  divObj.style.height = newHeight+'px';

  var newWidth = Math.max(minWidth, wd - divLeft - wOffset);
  divObj.style.width = newWidth+'px';

  if(firstTime) { firstTime=false; resizeDiv(); } // moz doesn't get it right until you resize again
}
