// this array should be inline with the <iframe> tag html
// var iframeids=["", ""];  // 0 = iframe id; 1 = DOM object in iframe to grab inner height;

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
  resizeIframe(iframeids[0], iframeids[1]);
}

function resizeIframe(frameid, innerObjectId) {
  var currentfr=document.getElementById(frameid);
  if (currentfr && !window.opera) {
    if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) { //ns6 syntax
      var myheight = currentfr.contentDocument.getElementById(innerObjectId).offsetHeight;
      // debug:
      myheight = myheight+20;  // attempt to correct a Safari z-index problem?
      currentfr.style.height = myheight+'px';
    } else if (currentfr.Document && currentfr.Document.body.scrollHeight) { //ie5+ syntax
      var myheight = currentfr.Document.body.scrollHeight;
      myheight = myheight+20;
      currentfr.style.height = myheight+'px';
    }
    /*
    if (currentfr.addEventListener) {
      currentfr.addEventListener("load", readjustIframe, false);
    } else if (currentfr.attachEvent) {
      currentfr.detachEvent("onload", readjustIframe); // Bug fix line
      currentfr.attachEvent("onload", readjustIframe);
    }
    */
  }
}

function readjustIframe(loadevt) {
  var crossevt=(window.event)? event : loadevt
  var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
  if (iframeroot) resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
  if (document.getElementById) document.getElementById(iframeid).src = url;
}

function goResizeIframe() {
  // note, commented out code is used for maintain state (if the iframe should only move once...)
  //if (window.addEventListener)
  //   window.addEventListener("load", resizeCaller, false)
  // else if (window.attachEvent)
  //  window.attachEvent("onload", resizeCaller)
  // else
  //  window.onload=resizeCaller
	resizeCaller();
}
