/*
 * okOpenWindow.js
 *
 * Versione: 1.0
 *
 * Data: 29 Agosto 2003
 * 
 * Script per l'apertura di una finestra.
 *
 * OpenKey S.r.l. (http://www.openkey.it)
 *
 */

var openedWindow;

function openWindow(windowURL, windowName, windowWidth, windowHeight, isResizable, isMenuVisibled)
{
	var userAgent = navigator.userAgent;
	var ie = /MSIE/.test(userAgent);
	var windowAttributes;
	var resizableString;
	var menuBarString;

	var positionX = (screen.availWidth / 2) - (windowWidth / 2);
	var positionY = (screen.availHeight / 2) - (windowHeight / 2);

	if (isResizable) {
		resizableString = "resizable=yes, scrollbars=yes";
	}
	else {
		resizableString = "resizable=no, scrollbars=no";
	}
	
	if (isMenuVisibled) {
		menuBarString = ", menubar=yes";
	}
	else {
		menuBarString = ", menubar=no";
	}	

	if (ie) {
		windowAttributes = "width=" + windowWidth + ", height=" + windowHeight + ", left=" + positionX + ", top=" + positionY + ", directories=no, status=no, toolbar=no, " + resizableString + menuBarString;
	}
	else {
		windowAttributes = "width=" + windowWidth + ", height=" + windowHeight + ", screenX=" + positionX + ", screenY=" + positionY + ", dependent=yes, directories=no, titlebar=no, status=no, toolbar=no, " + resizableString + menuBarString;
	}

	openedWindow = window.open(windowURL, windowName, windowAttributes);

	if (ie) {
		if (window.focus) {
			openedWindow.focus();
		}
	}

	return false;
}

