var iframeName;
var iframeWindowElement;
var iframeWindowDiv;

var progressBarDiv;
var fadingDiv;
	
function init() {
	iframeName = "iframeWindow";
	iframeWindowElement = document.getElementById(iframeName);
	iframeWindowDiv = document.getElementById(iframeName + "Div");

	progressBarDiv = document.getElementById('progressBarDiv');
	fadingDiv = document.getElementById('fadingDiv');


	iframeWindowDiv.style.left = parseInt(getAbsolutePosition(document.getElementById('body_inner')).x) + 'px';
	iframeWindowDiv.style.top = parseInt(getAbsolutePosition(document.getElementById('body_inner')).y) + 'px';
}

var showIframeDiv = function() {

if(document.getElementsByTagName("object")!=null) {
  for(i=0; (flash = document.getElementsByTagName("object")[i]); i++) {
     flash.style.visibility = "hidden";
  }
}	
	progressBarDiv.style.display = "none";
	fadingDiv.style.display = "block";
	iframeWindowDiv.style.display = "block";
	
	var iframeWindowDocument = window.frames[iframeName].document;

	iframeWindowElement.style.height = getDocHeight(iframeWindowDocument) + 50 + "px";	
	var windowHeight = Math.max(document.documentElement.clientHeight, getDocHeight(document));
	fadingDiv.style.height = Math.max(iframeWindowDiv.offsetHeight + getAbsolutePosition(iframeWindowDiv).y + 40, windowHeight) + "px";
//	alert(iframeWindowDiv.offsetHeight + " " + windowHeight);
//	alert(iframeWindowDiv.offsetHeight + " " + iframeWindowElement.style.height);
}
function getDocHeight(doc) {
  var docHt = 0, sh, oh;
  if (doc.height) docHt = doc.height;
  else if (doc.body) {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
    if (sh && oh) docHt = Math.max(sh, oh);
  }
  return parseInt(docHt);
}

function hideUrlFrame() {
fadingDiv.style.display = "none";
iframeWindowDiv.style.display = "none";

if(document.getElementsByTagName("object")!=null) {
  for(i=0; (flash = document.getElementsByTagName("object")[i]); i++) {
     flash.style.visibility = "visible";
  }
}

}

function OpenUrlFrame() {		
	init();
	var url = OpenUrlFrame.arguments[0];

	progressBarDiv.style.display = "block";
	iframeWindowElement.src = url;	
	if(iframeWindowElement.addEventListener){ // Mozilla, Netscape, Firefox
		iframeWindowElement.addEventListener("load",showIframeDiv, false);		
		
	} else { // IE
		iframeWindowElement.attachEvent("onload", showIframeDiv);
	}	
}

function printIframe(iframeName) {
  window.frames[iframeName].focus();
  window.frames[iframeName].print();
}
