var popup = {
	initialized: false,
	init: function(close)
	{
		if (close==null) close = true;
		if(this.initialized) return;
		if (close == true)
		{
			$('#popup-background').click(popup.close);
			$('#popup .close').click(function ()
			{
				popup.close();
				return false;
			});
			$('body').keydown(function (event)
			{
				if (event.keyCode == 27)
				{
					popup.close();
					return false;
				}
			});
		}
		else
		{
			$('#popup .close').hide();
		}
		this.initialized = true;
	},
	open: function(width, close)
	{
		if (close==null) close = true;
		if (width==null) width = '900px';
		$('#popup').css('width',width).css('left', (($(document).width()/2)-($('#popup').width()/2)) + 'px').css('top', ($(window).scrollTop() + 50) + 'px').show();
		$('#popup-background').css('height', $(document).height() + 40).show();
		popup.init(close);
	},
	close: function()
	{
		$('#popup').hide();
		$('#popup-background').hide();
		$(this).html('');
	}
}
