
var Popup = function(id) {

	var win_id = id, that = this;

	this.open = function(html) {

		var size = {
			width: $(window).width(),
			height: $(document).height()
		};

		var overlay = $('<div>').css({
			'background': '#000',
			'position': 'absolute',
			'top': 0,
			'left': 0,
			'width': size.width,
			'height': size.height,
			'opacity': 0.6,
			'z-index': 1000
		}).attr({
			'id': win_id + '_overlay',
			'class': 'popup_overlay'
		}).bind('click', that.close);

		var win_size = arguments[1] || {width: 600, height: 'auto'};
		var left = (size.width / 2) - (win_size.width / 2);
		var top = 50 + $(window).scrollTop();

		var win = $('<div>').css({
			'background': '#fff',
			'position': 'absolute',
			'top': top,
			'left': left,
			'width': win_size.width,
			'height': win_size.height,
			'z-index': 1001
		}).attr({
			'id': win_id + '_win',
			'class': 'popup_win'
		}).html(html);

		var btn = $('<a>').attr({
			'id': win_id + '_btn',
			'class': 'popup_close_btn',
			'href': '#close'
		}).bind('click', function() {
			that.close();
			return false;
		}).html('Close');

		win.append(btn);

		$('body').append(overlay).append(win);
	};

	this.close = function() {
		$('#' + win_id + '_overlay').remove();
		$('#' + win_id + '_win').remove();
	};
};


