/*********************************************************************
 This is used by http://inside.lcra.org to allow auto-resizing
 of frames. This is not expected to work on every browser on the
 internet - just the current Internet Explorer and current Firefox -
 so this should not be used for public sites without intensive
 verification.
 
 Do not change this file. Just enter the following code for the pages 
   containing the iframe:
 1 Set framesToResize to include all the ids of frames on the page
   that you want resized:
     framesToResize=["MyFrame"];
 2 If you have minimum sizes for any frames, set those:
     framesToResizeMinHeights=[100];
 3 Invoke resizeFramesSetup during the onload event. This has already
   been done for one of the site templates. 
     <body onload="resizeFramesSetup();">
 ********************************************************************/

framesToResize=[];
framesToResizeMinHeights=[];
function resizeFramesSetup() {
  if (framesToResize!=null){
    for (var i=0; i<framesToResize.length; i++){
      var rszFrame=document.getElementById(framesToResize[i]);
      if (rszFrame==null)
        alert("No such frame "+framesToResize[i]);
      else {
        if (rszFrame.addEventListener)
          rszFrame.addEventListener("load", resizeFrames, false);
        else 
        if (rszFrame.attachEvent)
          rszFrame.attachEvent("onload", resizeFrames);
        else 
        if (document.getElementById)
          rszFrame.onload=resizeFrames;
      }
    }          
    resizeFrames();
  }
}
function resizeFrames(){
  //This is actually slightly repetitious; each resizable frame invokes this method
  //once, so the #  of resizings=# of frames ** 2. So 2 frames causes 4 resizings, 
  //3 frames causes 9, 4 causes 16, etc. Not a big deal though.
  if (framesToResize!=null)
    for (var i=0; i<framesToResize.length; i++){
      var rszFrame=document.getElementById(framesToResize[i]);
      if (rszFrame==null)
        alert("No such frame "+framesToResize[i]);
      else {
        minHeight=0;
        if (i<framesToResizeMinHeights.length)
          minHeight=framesToResizeMinHeights[i];
        var aScrollHeight=rszFrame.contentWindow.document.body.scrollHeight+7;
        if (aScrollHeight>minHeight)
          minHeight=aScrollHeight;
        rszFrame.style.height=minHeight+"px";
      }
    }          
}
