// resize_iframe.js by Craig
// Note, these functions are based on ones found on the Web, but unfortunately I've lost the source URL
// Version 1.0
//
// This array should be above the <iframe> tag in the HTML document:
// var iframeids=["", ""];  // 0 = iframe id; 1 = DOM object in iframe to grab inner height;
//
// TODO: this only supports one iframe per HTML page since the iframeids array above is static

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;
      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';
    }
  }
}

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;
}
