
/**
 * Popup
 */
Popup = {}
Popup.instances = {};
Popup.defaultW = 420;
Popup.defaultH = 240;
Popup.open = function(url,name,w,h,x,y,scrollbars,status) {
	name = name ? name : 'default';
	w = w ? w : Popup.defaultW;
	h = h ? h : Popup.defaultH;
	x = x ? x : null;
	y = y ? y : null;
	status = status ? status : 'yes';
	scrollbars = scrollbars ? scrollbars : 'yes';
	info = PopupInfo.get(name);
	if (info != null) {
		w = info.w;
		h = info.h;
		x = info.x != null ? info.x : x;
		y = info.y != null ? info.y : y;
		status = info.status;
		scrollbars = info.scrollbars;
	}
	if (x == null) x = (screen.availWidth-w)/2;
	if (y == null) y = (screen.availHeight-h)/2;
	Popup.instances[name] = window.open(url,name,'toolbar=no,location=no,status=' + status + ',menubar=no,scrollbars=' + scrollbars + ',width=' + w + ',height=' + h + ',resizable=no,left=' + x + ',top=' + y + ',screenX=' + x + ',screenY=' + y );
	if (Popup.instances[name] && Popup.instances[name] != null) Popup.instances[name].focus();
	return Popup.instances[name];
}

/**
 * PopupInfo
 */
PopupInfo = function(name,w,h,x,y,scrollbars,status) {
	this.name = name;
	this.w = w;
	this.h = h;
	this.x = x ? x : null;
	this.y = y ? y : null;
	this.status = status ? status : 'yes';
	this.scrollbars = scrollbars ? scrollbars : 'yes';
}
PopupInfo.instances = {};
PopupInfo.create = function(name,w,h,x,y,scrollbars,status) { var p = PopupInfo.instances[name] = new PopupInfo(name,w,h,x,y,scrollbars,status); return p; }
PopupInfo.get = function(name) { return typeof PopupInfo.instances[name] != 'undefined' ? PopupInfo.instances[name] : null; }