// JavaScript Document

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

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 preloadIframe(frameid){
var currentfr=document.getElementById(frameid)

if (currentfr && !window.opera){
currentfr.height = 600;
//alert(currentfr.height);
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)

if (currentfr && !window.opera){
currentfr.style.display="block";

while(currentfr.readyState=="loading"){x++;};
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
}
}

function resizeIframe2(frameid){
var currentfr=document.getElementById(frameid)
var maxHeight = 600;

if (currentfr && !window.opera){
currentfr.style.display="block";
try{
while(currentfr.readyState=="loading"){x++;};
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) {//ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; 
currentfr.width = currentfr.contentDocument.body.offsetWidth+FFextraWidth; 
}
else if (currentfr.Document && currentfr.Document.body.scrollHeight) {//ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
currentfr.width = currentfr.Document.body.scrollWidth;
}
if (currentfr.height > maxHeight)
currentfr.height = maxHeight;
}
catch (err)
{}
}
}

function  isiFrameLoadComplete(iframeid){
 var pTar = document.getElementById(iframeid);

 if(pTar.readyState=="complete"){
  return true;
 }else{
  return false;
 }
 
}

function waitForLoad() {
	iframeid = "Content";
   preloadIframe(iframeid);
   if (isiFrameLoadComplete(iframeid)){
      resizeIframe(iframeid);
   } else {
      // THIS IS RECERSIVE!  
      // WE'LL KEEP SCHEDULING
// THE CHECK UNTIL isThePageLoaded()==true
      setTimeout('waitForLoad()', 10);
   }
}

function waitForLoad2() {
	iframeid = "Content";
   if (isiFrameLoadComplete(iframeid)){
      resizeIframe2(iframeid);
   } else {
      // THIS IS RECERSIVE!  
      // WE'LL KEEP SCHEDULING
// THE CHECK UNTIL isThePageLoaded()==true
      setTimeout('waitForLoad()', 10);
   }
}

function changeLinkHref(id,newHref,oldHref) {
  if (document.links.length > 0) {
    if (document.getElementById) {
      document.getElementById(id).href = newHref;
    }
    else if (document.all) {
      document.all[id].href = newHref;
    }
    else {
      var index = findLinkByHref(oldHref);
      if (index > -1)
        document.links[index].href = newHref;
    }
  }
}

