
var shown='';
var defWinCaption='Popup';
var windowwidth,windowheight,windowleft,windowtop;
var _toolbar,_location,_directories,_directories,_status,_scrollbars,_resizable,_copyhistory;

function setPopUpSize(w,h,l,t) {
	if (w) windowwidth=w;
	if (h) windowheight=h;
	if (l) {windowleft=l} else if (window.screen) windowleft=(screen.width-windowwidth)/2;
	if (t) {windowtop=t;} else if (window.screen) windowtop=(screen.height-windowheight)/2;
}

function setPopUpParamDef() {
	setPopUpSize(500,400);
	_toolbar='no';_location='no';_directories='no';_directories='no';
	_status='yes';_scrollbars='yes';_resizable='yes';_copyhistory='no';
}

function PopUpEx(url,wName) {
	if (!wName || wName.length==0) wName = defWinCaption;
	shown=window.open(url, wName, 'left='+windowleft+',top='+windowtop+
		',toolbar='+_toolbar+',location='+_location+',directories='+_directories+
		',status='+_status+',scrollbars='+_scrollbars+',resizable='+_resizable+
		',copyhistory='+_copyhistory+',width='+windowwidth+',height='+windowheight);
	shown.focus();
	return false;
}

function PopUp(url) { return PopUpEx(url, defWinCaption); }

function KillPopup() { if (!(shown=='' || shown.closed)) {shown.close();} }

function ClosePopup() {
	if (window.opener) {
		window.opener.focus();
		window.close();
	}
}

window.onunload=KillPopup;
setPopUpParamDef();
