var Preview = {
	ajaxUrl: 'bricks/purchase.php?id=',

	showOptions: function(id)
	{
		var $ = jQuery;
		
		$('body').prepend(
			this.bg = $('<div></div>') 
				.width($(document).width())
				.height($(document).height())
				.css({
					position: 'absolute',
					left: '0px',
					top: '0px',
					backgroundColor: '#555',
					opacity: 0.5, 
					zIndex: 9999
				})
			);
				
		$('body').prepend(
			this.popup = $('<div></div>')
				.hide()
				.css({
					position: $.browser.msie ? 'absolute' : 'fixed',
					left: '30px',
					top: '30px',
					padding: '30px',
					border: '1px solid #03709f',
					backgroundColor: 'white',
					//overflow: 'auto',
					zIndex: 10000
				})
				.load(this.ajaxUrl + id, {}, function(){
					var client = {
						width:	$(window).width(),
						height:	$(window).height()
					};
					$(this)
						.css({
							width: Math.min($(this).width(), client.width - 100),
							height: Math.min($(this).height(), client.height - 70)
						})
						.css({
							left: (client.width - $(this).width()) / 2 + 'px',
							top: (client.height - $(this).height()) / 2 + 'px'
						})
						.prepend(
							$('<div></div>')
								.text('X')
								.css({
									float: 'right',
									color: '#eb4771',
									fontWeight: 'bold',
									padding: '10px',
									cursor: 'pointer'
								})
								.click(function(){
									Preview.popup.hide();
									Preview.bg.hide();
								})
						)
						.show()
					;
				})
		);
		return false;
	}
};
