/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/
//Example use:
//<iframe id="myframe" src="test.asp" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:100%; display:none"></iframe>
//<a onclick="loadintoIframe('myframe', 'test.asp?num=<% response.write i %>');" style="cursor:pointer; text-decoration:underline;">

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
//var iframeids=["myframe"]

//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 resizeCaller()
{
	var dyniframe=new Array();
	for (i=0; i<iframeids.length; i++)
	{
		if (document.getElementById)
		{
			resizeIframe(iframeids[i]);
		}
		//reveal iframe for lower end browsers? (see var above):
		if ((document.all || document.getElementById) && iframehide=="no")
		{
			var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i]);
			tempobj.style.display="block";
		}
	}
}

function resizeIframe(frameid)
{
	var currentfr=document.getElementById(frameid);
	if (currentfr && !window.opera)
	{
		currentfr.style.display="block";
		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;
		}
		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, tempheight)
{
	if (document.getElementById)
	{
	   document.getElementById(iframeid).height=tempheight;
   	document.getElementById(iframeid).src=url;
	}
}

if (window.addEventListener)
{
	window.addEventListener("load", resizeCaller, false);
}
else if (window.attachEvent)
{
	window.attachEvent("onload", resizeCaller);
}
else
{
	window.onload=resizeCaller;
}













var IFrameObj; // our IFrame object
function callToServer(URL)
{
	if (!document.createElement)
	{
		return true
	}
	var IFrameDoc;
	if (!IFrameObj && document.createElement)
	{
		// create the IFrame and assign a reference to the
		// object to our global variable IFrameObj.
		// this will only happen the first time
		// callToServer() is called
		try
		{
			var tempIFrame=document.createElement('iframe');
			tempIFrame.setAttribute('id','RSIFrame');
			tempIFrame.style.border='0px';
			tempIFrame.style.width='0px';
			tempIFrame.style.height='0px';
			IFrameObj = document.body.appendChild(tempIFrame);

			if (document.frames)
			{
				// this is for IE5 Mac, because it will only
				// allow access to the document object
				// of the IFrame if we access it through
				// the document.frames array
				IFrameObj = document.frames['RSIFrame'];
			}
		}
		catch(exception)
		{
			// This is for IE5 PC, which does not allow dynamic creation
			// and manipulation of an iframe object. Instead, we'll fake
			// it up by creating our own objects.
			iframeHTML='\<iframe id="RSIFrame" style="';
			iframeHTML+='border:0px;';
			iframeHTML+='width:0px;';
			iframeHTML+='height:0px;';
			iframeHTML+='"><\/iframe>';
			document.body.innerHTML+=iframeHTML;
			IFrameObj = new Object();
			IFrameObj.document = new Object();
			IFrameObj.document.location = new Object();
			IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
			IFrameObj.document.location.replace = function(location)
			{
				this.iframe.src = location;
			}
		}
	}

	if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument)
	{
		// we have to give NS6 a fraction of a second
		// to recognize the new IFrame
		setTimeout('callToServer()',10);
		return false;
	}

	if (IFrameObj.contentDocument)
	{
		// For NS6
		IFrameDoc = IFrameObj.contentDocument;
	}
	else if (IFrameObj.contentWindow)
	{
		// For IE5.5 and IE6
		IFrameDoc = IFrameObj.contentWindow.document;
	}
	else if (IFrameObj.document)
	{
		// For IE5
		IFrameDoc = IFrameObj.document;
	}
	else
	{
		return true;
	}

	IFrameDoc.location.replace(URL);
	return false;
}

