
var pWinHandle = "";
var WINDOW_BASE_NAME = "POPUP_";

function pWin(url, width, height, attributes, windowName)
{
	var	args = "width=" + width + ",height=" + height + ",menubar=no";
	var	foo;

	if (attributes && ((typeof attributes) == "string")) {
		args += (attributes.indexOf("noscroll") != -1 ) ? ",scrollbars=no" : ",scrollbars=yes";
		args += (attributes.indexOf("resize") != -1) ? ",resizable=yes" : ",resizeable=no";
		args += (attributes.indexOf("tool") != -1) ? ",toolbar=yes" : ",toolbar=no";
		args += (attributes.indexOf("loc") != -1) ? ",location=yes" : ",location=no";
		args += (attributes.indexOf("status") != -1) ? ",status=yes" : ",status=no";
	} else if (attributes) {	// this is for backwards compatibility...
		args += ",scrollbars=yes,resizeable=no,toolbar=yes,location=no,status=no";
	} else {
		args += ",scrollbars=yes,resizeable=no,toolbar=no,location=no,status=no";
	}	

	if (!windowName) {
		pWinHandle = WINDOW_BASE_NAME + (Math.round(89999*Math.random() + 10000)).toString();
	} else {
		pWinHandle = windowName;
	}
		
	foo = window.open(url, pWinHandle, args);

	if (windowName)
		foo.focus();
}

function pWinReturn(url, width, height, attributes)
{
	pWin(url, width, height, attributes);
	return pWinHandle;
}


