
/* ===========================================================================
//	lib_popUp.js 
// ======================================================================== */


function popUp(url) {
	/* Assign height to params if passed, otherwise set to a little smaller than the screen width */
	var targetWidth;
	var targetHeight;
	if(arguments[1] != null)
		targetWidth = arguments[1];
	else
		targetWidth = screen.availWidth - 20;
	if (arguments[2] != null)
		targetHeight = arguments[2];
	else
		targetHeight = screen.availHeight - 40;
	
	var width = adjustXDimensionForPop(targetWidth);
	var height = adjustYDimensionForPop(targetHeight);
	
	// Set the position -- either the coordinates passed
	// to the function, or centered horizontally and 1/3
	// of the way down vertically (default)
	if(arguments[3] != null && arguments[4] != null) {
		xPos = arguments[3];
		yPos = arguments[4];
	} else {
		// Get screen size
		var windowWidth = screen.availWidth;
		var windowHeight = screen.availHeight;
		
		// Set proper position according to screen size
		var xPos = (windowWidth - width) / 2;
		var yPos = (windowHeight - height) / 3;
	}
	
	// Set proper position phrase
	var xPosPhrase = "left=" + xPos + ",screenX=" + xPos + ",";
	var yPosPhrase = "top=" + yPos + ",screenY=" + yPos + ",";
	
	// WINDOW NAME
	// Can be passed as a 5th parameter, or set 
	if (arguments[5] != null) myWin = arguments[5];
	else myWin = "window" + Math.floor (Math.random () * 11);
	
	// OPTIONS
	// If option name matches in 7th argument, that option is turned on
	// Else all options are by default off
	var scrollbars = 0;
	var toolbar = 0;
	var resizable = 0;
	var location = 0;
	var status = 0;
	var menu = 0;
	if(arguments[6] != null) {
		var options = arguments[6];
		if(options.indexOf("scroll") > -1) scrollbars = 1;
		if(options.indexOf("tool") > -1) toolbar = 1;
		if(options.indexOf("resiz") > -1) resizable = 1;
		if(options.indexOf("location") > -1) location = 1;
		if(options.indexOf("status") > -1) status = 1;
		if(options.indexOf("menu") > -1) menu = 1;
	}
	
	// Generate window.open statement
	eval (myWin + " = window.open ('" + url + "', '" + myWin + "',\"" + xPosPhrase + yPosPhrase + "width=" + width + ",height=" + height + ",resizable=" + resizable + ",toolbar=" + toolbar + ",menu=" + menu + ",location=" + location + ",status=" + status + ",scrollbars=" + scrollbars + "\")");
	eval ("thisWindow = " + myWin);
	
	// If Mac IE 4.5, the window got positioned in the upper left corner.  Move it
	if (isMacIE4) {
		thisWindow.moveTo (xPos, yPos);
	}
}




/* eof ==================================================================== */


