//iFrame Resizing   MAG20080211

//Create a global array variable to hold all of our iFrames
var frameArray = new Array();

//Create a global variable for a given iFrame
function setGVars(name, h, w, b, r)
{
	//Loop through 5 times to find the first empty array element and load the iFrame name into that element
	var y=0; 
	for (y=0; y<5; y++) 
	{
	 	// If there is not already an iFrame with this name, create an array element for it and add a height and width only if the provided values are numeric
		if (!(frameArray[y]))
		{
			frameArray[y] = new Array(5)
			frameArray[y][0] = name;
			if (!(isNaN(h))) {	frameArray[y][1] = h;  }
			if (!(isNaN(w))) {	frameArray[y][2] = w;  }
			if (!(isNaN(b))) {	frameArray[y][3] = b;  }
			if (!(isNaN(r))) {	frameArray[y][4] = r;  }
			break;
		}
	}
} // setGVars

//For each iFrame in the global array variable, reset the height and width using the sizing criteria provided
function resizeFrame()  
{
  //Determine the Height and Width of the window
	if (document.body.clientHeight) { height=document.body.clientHeight; } else { height=600 }
	if (document.body.clientWidth) { width=document.body.clientWidth; } else { height=800 }

	//Loop through all the iFrames in the global array and resize them according to the sizing criteria
	var y=0; 
	for (y=0; y<frameArray.length; y++) 
	{ 
		//Use the stored value for height if one was provided, otherwise resize with window
		if ((frameArray[y][1]) && (frameArray[y][1] != ''))
		{
			document.getElementById(frameArray[y][0]).style.height = frameArray[y][1]+"px";
		} else {
			document.getElementById(frameArray[y][0]).style.height = parseInt(height-document.getElementById(frameArray[y][0]).offsetTop)-frameArray[y][3]+"px";
		}
		
		//Use the stored value for width if one was provided, otherwise resize with window
		if ((frameArray[y][2]) && (frameArray[y][2] != ''))
		{
			document.getElementById(frameArray[y][0]).style.width = frameArray[y][2]+"px";
		} else {
			document.getElementById(frameArray[y][0]).style.width = parseInt(width-document.getElementById(frameArray[y][0]).offsetLeft)-frameArray[y][4]+"px";
		}

	}
} // resizeFrame
