/* The following code is based on that by Glenn Davis of Project Cool, Inc. who
released it for general use.
I have adapted it somewhat to make some extra functionality possible (and nothing
was taken out); I have not exactly "left all comments in place" as Glen requested,
but rewritten and extended them. I'm sure he'll agree with that.
I'm no JavaScript expert but you can reach me at webmaster@javawoman.com if
necessary.
To echo Glen Davis: if you use this code, please leave all comments in place so
that others may benefit as well.
Marjolein Katsma. 1998-08-05.
*/

/* First set default values for screen width and height - MK 1998-08-04 */
if ((parseInt(navigator.appVersion) >= 4 )) { 
	dwidth = screen.width;
	dheight = screen.height;
}
else {							// just some reasonable values
	dwidth = 400;
	dheight = 300;
}


/* the fuction openAWindow() opens a new window on the user's desktop.
	Arguments:
	pageToLoad -	The URL of a page to load in the browser window.
					This can be a relative URL or fully qualified.
	winName -		Name of the new window.
	width -			The horizontal size of the new window;
					use 0 to get full screen width or a default value
					(default added: MK 1998-08-04).
	height -		The vertical size of the new window;
					use 0 to get full screen height or a default value
					(default added: MK 1998-08-04).
	scroll -		Toggle scrollbars;
					1 = scrollbar; 0 = no scrollbar (added: MK 1998-08-04)
	center -		Toggle centering on 4.0 browsers;
					1 = centered window; 0 = no centering.
	xposition -		x position to open the window: only if center=0
					(added: MK 1998-12-10).
	yposition -		y position to open the window: only if center=0
					(added: MK 1998-12-10).

	Values in the "args" section below can all be toggled in the
	same fashion as the center toggle.  Just modify the appropriate
	value in the args section to be either 0 or 1.

	A call to this function might look like this:
	<a href="javascript:openAWindow('ice.html','ice',375,250,0,1)">Ice</a>

	The code that opens the window has a little extra so JavaScript code in the
	opened window can refer back to the object that opened it. Note: this is
	not a window name since an already-opened window can not be named after the
	fact. What this enables is to refer to the "opener" as an object and this
	will only work as long as *this* code is still present in the "opener"
	window; it doesn't matter if that is a different page with this same
	JavaScript in it, but it won't work if you've loaded another page that
	doesn't (referring to it will cause a "permission denied" error).
	
	VERSION:
	Only the code that refers to screen width and height (defaults for full width
	or height and centering) actually need JavaScript 1.2, which effectively means
	version 4 browsers. The rest will work with JavaScript 1.1 as well (Netscape 3)
	but full width/height or centering won't work, and NS3 has a problem with
	JavaScript inside table cells.
	Note also that object detection (of the form if (screen) {} ) of the screen
	object will not work with NS3: it will cause an error! That's why browser
	detection is used instead.

	(UPDATED - mk 1998-08-05. (comments: 2001-10-21)
*/
function openAWindow( pageToLoad, winName, width, height, scroll, center) {
	if (!width) {
		width = dwidth - 12;		// full width of screen if undefined (minus border)
	}
	if (!height) {
		height = dheight - 30;		// full height of screen if undefined (minus title bar & border)
	}

	xposition=0; yposition=0;
	if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
		xposition = (dwidth - width) / 2;
		yposition = (dheight - height) / 2;
	}

	args =
	  "width=" + width + "," 
	+ "height=" + height + "," 
	+ "location=0," 
	+ "menubar=0,"
	+ "resizable=1,"
	+ "scrollbars=" + scroll + ","
	+ "status=0,"                   // don't think this works...
	+ "titlebar=0,"
	+ "toolbar=0,"
	+ "hotkeys=0,"
	+ "screenx=" + xposition + ","  // NN Only
	+ "screeny=" + yposition + ","  // NN Only
	+ "left=" + xposition + ","     // IE Only
	+ "top=" + yposition;           // IE Only

	popup = window.open( pageToLoad,winName,args );
	if (popup.opener == null) popup.opener = self;
	
	popup.focus();
}