function PopupWindow() {}
PopupWindow.prototype = {
	
	window : null,
	temn : null,
	splashedy : false,
	splashedx : false,
	visible : false,
	initdim : [],
	interval : null,
	ms : 50,
	docdim : [-1, -1],
	iter : 0,
	
	_init : function() {
		this.temn = $('#temn');
		this.temn.css({backgroundColor:js_options.overlayBgColor, opacity: 0});
		if (is_ie6()) {
			this.window.css({position : 'absolute'});
			this.temn.css({position : 'absolute', width: '100%', height: '100%'});
		}
		this.window.find('a.close').click(this.hide.bind(this));
		this.initdim = [this.window.width(), this.window.height()];
	},
	
	show : function(event) {
		if (event)
			event.preventDefault();
		this.temn.show().fadeTo(200, js_options.overlayOpacity);
		this.centrize();
		this.interval = window.setInterval(this.centrize.bind(this), this.ms);
		this.window.show();
		this.visible = true;
	},
	
	find : function(selector) {
		return this.window.find(selector);
	},
	
	centrize : function() {
		force = arguments[1] || false;
		this.iter++;
		var docdim = [$(window).width(), $(window).height()];		
		if (!force && this.docdim[1] == docdim[1] && this.docdim[0] == docdim[0]) {
			return;
		}
		this.docdim = docdim;
		/*var dim = this.initdim;*/
		var dim = [$(this.window).width(), $(this.window).height()];
		var top = (docdim[1]-dim[1])/2;
		var left = (docdim[0] - dim[0])/2;
		if (docdim[1] < dim[1]) {
			$.browser.msie ? 
				this.css({'overflow-y': 'scroll'}):
				this.css({'overflow' : 'auto'});
			this.window.height(docdim[1]);
		}
		else {
			this.window.height(dim[1]);
			$.browser.msie ?
				this.css({'overflow-y': 'visible'}):
				this.css({overflow: 'visible'});
		}
		
		this.temn.css({top:0,bottom:0,left:0,right:0});
		if (top < 0) top = 0;
		if (left < 0) left = 0;
		this.css({top:top, left:left});
	},
	
	css : function(styles) {
		this.window.css(styles);
	},
	
	hide : function(event) {
		this.visible = false;
		event.preventDefault();
		this.window.hide();
		this.temn.css({opacity:0}).hide();
		window.clearInterval(this.interval);
	}
	
};
