var g_nWinUID = 0;

function popwin(p_sUrl, p_nWidth, p_nHeight, p_sWinName, p_sOptions)
{
	if (p_sWinName == "") {
		sTemp = Date() + "_" + g_nWinUID++;
		sTemp = "win_" +sTemp.replace(/ |:/g, ""); // strip all invalid chars coming from Date()
	} else {
		sTemp = p_sWinName;
	} // if

	sOptions = p_sOptions;
	if (sOptions != "") sOptions = "," + p_sOptions;

	if (document.all) {
		//alert("using document.body.clientHeight / .clientWidth");
		t = top.window.screenTop;
		l = top.window.screenLeft;
		w = top.document.body.clientWidth;
		h = top.document.body.clientHeight;
	} else if (document.layers) {
		//alert("using window.innerHeight / .innerWidth");
		t = window.top;
		l = window.left;
		w = window.innerWidth;
		h = window.innerHeight;
	} else {
		//alert("using screen.availHeight / .availWidth");
		t = 0;
		l = 0;
		w = screen.availWidth;
		h = screen.availHeight;
	} // if

	nTop = t + ((h - p_nHeight) / 2);
	nLeft = l + ((w - p_nWidth) / 2);

	//alert("nLeft = " + nLeft + "\nnTop = " + nTop + "\nw = " + w + "\nh = " + h + "\nt = " + t + "\nl = " + l);
	winTemp = window.open(p_sUrl, sTemp, "width=" + p_nWidth + ",height=" + p_nHeight + ",left=" + nLeft + ",top=" + nTop + sOptions);
	if (winTemp) winTemp.focus();
} // function popwin

