/**
 * pageScripts - Various JavaScript functions used by project pages
 * 				 on the www.schaubdesign.com webpage.
 *
 * Author: Bobby Rosenberger - R3 Consulting, Inc. - bobby@r3consulting.net
 */

// Window object used by picturePage.htm
var winObj;

// This function dynamically sets the height of a parent IFrame.
function setIFrameSize (theHeight) {
	
	var cFrame = parent.document.getElementById("centerFrame");
	cFrame.style.height = theHeight;

}

// Args Object used by the picturePage.htm
function args () {
	this.picture = "";
}

// This function opens a child window of dynamic height and
// width and passes it a picture name to display.
function showModal(pg, w, h, picName) {
	
	// Create new Args Object
	var theArgs = new args();
	
	// Set the picture attribute
	theArgs.picture = picName;
	
	var xMax;
	var yMax;
	
	// Find the coordinates to center the window.
	if (document.all) {
		xMax = screen.width;
		yMax = screen.height;
	} else {
		if (document.layers) {
			xMax = window.outerWidth;
			yMax = window.outerHeight;
		} else {
			xMax = 640;
			yMax = 480;
		}
	}
	
	var xOffset = (xMax - parseInt(w))/2;
	var yOffset = (yMax - parseInt(h))/2;
	
	// Construct the feature string.
	var winFeatures = "height=" + h +
		", width=" + w + "resizable=0, scrollbars=0, status=0, left = " + xOffset + ", top = " + yOffset +
		", screenX = " + xOffset + ", screenY = " + yOffset ;
	
	// Make sure the child window is closed
	if (winObj) {
		winObj.close();
		winObj = null;
	}

	// Open the child window.
	winObj = window.open(pg, "", winFeatures);
	
	// Set the args object on the child window.
	winObj.args = theArgs;
	
}
