/*  
 * windowFunctionLib.js
 *
 * This file contains general functions for opening/closing windows with JavaScript
 *
 */


function openBasicNewWindow(newURL) {
	// opens a new window containing the URL defined in the 
	// "newURL" variable
	
	/*
		Required Parameter(s):
		newURL = URL for the new window
	*/
	
	// define the attributes for this window
	var newWindowAttributes = "toolbar=no,location=no,scrollbars=no,resizable=yes";

	// open the new window with the attributes defined above
	newWindow = window.open(newURL, 'newWindow', newWindowAttributes);

	// make sure the new window appears on top
	newWindow.focus();
}

function openAdvancedNewWindow(newURL, intHeight, intWidth, intX, intY) {
	/*
		Required Parameter(s):
		newURL = URL for the new window
		
		Optional Parameter(s):
		intHeight = height of the window in pixels
		intWidth = width of the window in pixels
		intX = This allows a new window to be created at a specified number of pixels from the left side of the screen.
		intY = This allows a new window to be created at a specified number of pixels from the top of the screen.
	*/
	
	// define the attributes for this window
	var newWindowAttributes = "toolbar=no,location=no,scrollbars=yes,resizable=yes";
	if (intHeight) {
		newWindowAttributes = newWindowAttributes + ",height=" + intHeight;
	}
	if (intWidth) {
		newWindowAttributes = newWindowAttributes + ",width=" + intWidth;
	}
	if (intX) {
		// screenX = param for netscape, left = param for IE
		newWindowAttributes = newWindowAttributes + ",left=" + intX + ",screenX=" + intX;
	}
	if (intY) {
		// screenY = param for netscape, top = param for IE
		newWindowAttributes = newWindowAttributes + ",top=" + intY + ",screenY=" + intY;
	}
	
	// open the new window with the attributes defined above
	newWindow = window.open(newURL, 'newWindow', newWindowAttributes);

	// make sure the new window appears on top
	newWindow.focus();
	
	// close the window after X number of seconds
	//closeWindowInXSeconds(intSecondsToClose);
}

function closeWindow() {
	// this function works in conjunction with the above openBasicNewWindow
	// function and will close the "newWindow" object
	
	if (newWindow && !newWindow.closed) {
		newWindow.close();
	}
}

function closeWindowInXSeconds(intSeconds) {
	intMilliSeconds = intSeconds * 1000; // translate to milliseconds
	
	// close the open window after a certain amount of time (in milliseconds)
	self.setInterval('closeWindow()', intMilliSeconds)
}
