/* openWindow.js
 * This file contains helper functions to open popup windows of different types.
 * openWindow() simply opens a window of the given sizes, etc.
 * open CenteredWindow opens a window centered on the screen.
 * openFullScreenWindow opens a full screen window.
 *
 * For further information, contact Isaac Connor, iconnor@penultima.org
 */

function openWindow( theURL, winName, otherfeatures, width, height, x, y ) {
	var features = '';

	// If it's IE on Mac, alter the width and height.  Mac gets it wrong for some reason
	if ( navigator.appName == 'Microsoft Internet Explorer' ) {
		if ( navigator.platform == 'MacPPC' ) {
			
			width -= 10;
			//height -= 10;
			
		} // end if
	} // end if

	features += "width=" + width + ",height=" + height;
	features += ",screenX=" + x + ",screenY=" + y;
	features += ",left=" + x + ",top=" + y;
	if ( otherfeatures != "" ) {
		features += "," + otherfeatures;
	} // end if
	var newWindow = window.open(theURL,winName,features);
	newWindow.focus();
	return newWindow;
}

function openCenteredWindow( theURL, winName, features, width, height ) { //v2.0
	return openWindow( theURL, winName, features, width, height, getCenteredX(width), getCenteredY(height) );
}

function openFullScreenWindow( theURL, winName, features ) { //v2.0
	var width = screen.width - 10;
	var height = screen.height - 30;
	return openWindow( theURL, winName, featuresi + ",fullscreen", width, height, 0,0 );
}

function maximizeWindow( windowObject ) {
	windowObject.moveTo( 0, 0 );
	var width = screen.availWidth;
	var height = screen.availHeight;
	if (document.all) { // IE
		windowObject.resizeTo( width, height );
	} else if (document.layers ) { // NS 4
		windowObject.outerHeight = height - 30;
		windowObject.outerWidth = width - 10;
	} else if ( document.getElementById ) { // NS 6,7
		windowObject.outerHeight = height;
		windowObject.outerWidth = width;
	} else {
		windowObject.resizeTo( width, height );
	} // end if

} // end function maximizeWindow

function getCenteredX (width) {
	return ((screen.availWidth)-width)/2;
}
function getCenteredY (height) {
	return ((screen.availHeight)-height)/2;
}

