// Hide from JavaScript-challenged browsers

/*
 *	This script written by William R. Sutton, IV
 *	Permission granted for use by Nando Media.
 *
 *	William Sutton
 *	william@nando.net
 */

/*

	Function: 	openWindow()
	Parameter(s):	url, name, size, position, status, menubar
	Purpose:	Opens the Window at a particular url, with a particular
                        size, at a particular position

	Example:	<a href="javascript:openWindow('myURL', windowName, windowSize, windowPos, windowFeatures);">my link</a>

*/

function openWindow (windowURL, windowName, windowSize, windowPos, status, menubar, toolbar, scrollbars) {
	var windowURL		= openWindow.arguments[0];
	var windowName		= openWindow.arguments[1];
	var windowSize		= openWindow.arguments[2];
	var windowPos		= openWindow.arguments[3];
	var windowFeatures	= openWindow.arguments[4];

	
	// window sizing can come either as a s/m/l parameter (small, medium, large) or as a
	// WxH parameter (e.g., 800x600)
	var windowHeight;
	var windowWidth;
	
	if (windowSize == "s" || windowSize == "S") {
		windowWidth = 400;
		windowHeight = 200;
	} else if (windowSize == "m" || windowSize == "M") {
		windowWidth = 500;
		windowHeight = 300;
	} else if (windowSize == "l" || windowSize == "L") {
		windowWidth = 600;
		windowHeight = 400;
	} else {
		var sizeParms = windowSize.split('x', 2);
		windowWidth = sizeParms[0];
		windowHeight = sizeParms[1];
	}

	var windowTop;
	var windowLeft;

	var posParms = windowPos.split('x',2);
	windowTop = posParms[0];
	windowLeft = posParms[1];
	
	// all arguments are mandatory...if one is missing, spit out an error gracefully
	if (openWindow.arguments.length != 5) {
		alert ("There is a parameter missing from the function call.");
	}
	
	var features = "width=" + windowWidth + ",height=" + windowHeight + ",top=" + windowTop + ",left=" + windowLeft + "," + windowFeatures;
	window.open(windowURL,windowName,features);
}

