var Popup = Class.create();
Popup.prototype = {

	win: null,
	options: null,
	current_options: null,
	tabWinOptions: null,

	initialize: function (options) {
		this.options = {
			'url': null,
			'title': null,
			'position': 'auto',
			'scrollbars': 'yes',
			'toolbar': 'no',
			'location': 'no',
			'status': 'no',
			'resizable': 'no',
			'width': 300,
			'height': 300,
			'top': 0,
			'left': 0
		}
		this.tabWinOptions = ['scrollbars', 'toolbar', 'location', 'status', 'resizable', 'width', 'height', 'top', 'left'];
		this.setOptions(options);
	},

	setOptions: function (options) {
		Object.extend(this.options, options || {});
	},

	autoPosition: function () {
		this.current_options.left = Math.round((screen.width-Number(this.current_options.width))/2);
		this.current_options.top = Math.round((screen.height-Number(this.current_options.height))/2);
	},

	openPopup: function (options) {
		this.current_options = Object.clone(this.options);
		Object.extend(this.current_options, options || {});
		if( this.current_options.position == 'auto' ) this.autoPosition();
		var window_options = [];
		for(var u=0; u<this.tabWinOptions.length; u++){ eval("window_options.push(this.tabWinOptions[u]+'='+this.current_options."+this.tabWinOptions[u]+");"); }
		this.win = window.open(this.current_options.url, this.current_options.title, window_options.join(','));
		this.win.focus();
	},

	closePopup: function () {
		this.win.close();
		this.win = null;
	},

	__void: function(){}

}