/* Acme Profiling Technology (APT™) ©2001-2004 Acme Express, Inc. All rights reserved. */
var vFramesToResize		= document.getElementsByTagName("IFRAME").length;

/**************************************************************
 * Resize all the IFrames on this page
 **************************************************************/
function resizeIFrames()
{
	var conScrollBar			= 20;
	var conResizeVariance		= 5;

	for (var vFrame=0; vFrame < document.getElementsByTagName("IFRAME").length; vFrame++)
	{
		var objIFrame 			= document.getElementsByTagName("IFRAME")[vFrame];
		var objFrame			= window.frames[vFrame];
		var objBody				= objFrame.document.body;

		if ((objBody != null) && (objIFrame.style.display != 'none') && (objIFrame.scrolling != 'no'))
		{
			var bWidthPct		= (objIFrame.style.width.indexOf('%') > -1);
			var bHeightPct		= (objIFrame.style.height.indexOf('%') > -1);

			var nWidth			= objBody.scrollWidth;
			var nSaveWidth		= objIFrame.clientWidth;

			var nHeight			= objBody.scrollHeight;
			var nSaveHeight		= objIFrame.clientHeight;

			var nCount			= 0;

			while (isVariance(nWidth, nSaveWidth) || isVariance(nHeight, nSaveHeight))
			{
				if (nWidth != nSaveWidth)
				{
					if (bWidthPct)
						nSaveWidth				= nWidth;
					else
					{
						nSaveWidth				= nWidth;
						nWidth					= objBody.scrollWidth;
						if (bHeightPct)
							nWidth			   += conScrollBar;
						objIFrame.style.width	= nWidth;
					}
				}

				if (nHeight != nSaveHeight)
				{
					if (bHeightPct)
						nSaveHeight				= nHeight;
					else
					{
						nSaveHeight				= nHeight;
						nHeight					= objBody.scrollHeight;
						if (bWidthPct)
							nHeight			   += conScrollBar;
						objIFrame.style.height	= nHeight;
					}
				}
				nCount++;
				if (nCount > 10)
					break;
			}

			var bScroll	= (((objIFrame.scrolling == 'auto') && (objIFrame.clientHeight <= conScrollBar)) ||
						   ((objIFrame.scrolling == 'auto') && (objIFrame.clientHeight <= conScrollBar)));		//> (shut up NoteTab Pro)

			if (bScroll)
				objIFrame.style.width			= objBody.scrollWidth + conScrollBar;

			if (bScroll)
				objIFrame.style.height			= objBody.scrollHeight + conScrollBar;

			objIFrame.style.visibility			= 'visible';
		}
	}
	resizeParentIFrames();
}

function isVariance(nSize1, nSize2)
{
	var conVariance		= 20;

	if (nSize1 > nSize2)
		return true;
	else
		return ((nSize2 - nSize1) > conVariance);
}

/**************************************************************
 * General load function
 **************************************************************/
function window_Enable()
{
	vItem				= document.getElementsByTagName('BODY');
	var vBody			= vItem[0];
	vBody.style.cursor	= "auto";		// reset cursor to ready state
	resizeIFrames();					// resize all IFrames
}

/**************************************************************
 * General load function
 **************************************************************/
function window_Wait()
{
	vItem				= document.getElementsByTagName('BODY');
	var vBody			= vItem[0];
	vBody.style.cursor	= "wait";		// set cursor to wait
}

/**************************************************************
 * General window_onLoad
 **************************************************************/
function window_onLoad() {window_Enable();}

/**************************************************************
 * Resize all Parent IFrames
 **************************************************************/
function resizeParentIFrames()
{
	if (window.parent != window.self)
	{
		try 		{parent.resizeIFrames();}
		catch(e)	{}
	}
}
