var popup = new function()
{
	var o = this;
	
	o.init = function()
	{
		if(!$('#popup').size())
		{
			var popup_html = ''+
					'<div id="popup">'+
						'<div class="top"></div>'+
						'<div class="container">'+
							'<div id="popup_content"></div>'+
							'<div class="close"><a onclick="popup.close();" id="btn_popup_close">Close</a></div>'+
						'</div>'+
					'</div>'+
			'';
			this.el_pop = $(popup_html).appendTo('body');
			this.el_title = $('#popup_title'); // Get the content container
			this.el_content = $('#popup_content'); // Get the content container
			this.el_footer = $('#popup_footer'); // Get the content container
		}
	}
	o.position = function()
	{
		var window_center = $(window).scrollTop() + ($(window).height() / 2);
		var max_width = $('body').width();
		var top;
		var left;

		// Center the popup
		top = window_center - (this.el_pop.height() / 2);
		left = (max_width - this.el_pop.width()) / 2;
		this.el_pop.css('top', top +'px');
		this.el_pop.css('left', left +'px');
	}

	// Show the stuff inline
	o.inline = function(s_html)
	{
		o.init();
		this.el_content.html(s_html);

		$(window).scroll( function() { o.position(); });
		this.position();
		this.el_pop.show();
	}
	
	// Get HTML from ajax and show it inline
	o.inline_ajax = function(s_url)
	{
		$.get(s_url, function(data) { o.inline(data, s_title); });
	} 

	// Display an iframe
	o.iframe = function(url, noscroll)
	{
		o.inline('<iframe src="'+url+'" frameborder="0" allowtransparency="true" height="300" width="380" '+(noscroll?'scrolling="no"':'')+'></iframe>');
	}

	/*
	iframe: function(url, settings, noscroll)
	{
		this.create(settings);
		this.popup_content.css('padding', '0');
		this.popup_content.append('<iframe src="'+url+'" frameborder="0" allowtransparency="true" '+(noscroll?'scrolling="no"':'')+'></iframe>');
		$(window).scroll( function() { $.popup.position(); });
		this.position();
		this.open();
	},
	 */


	
	o.close = function()
	{
		if(!$('#popup').size())
			return;
		this.el_pop.hide();
		$(window).unbind("scroll");
	}
}
/*
<div id="AddComment" class="DisplayNone" style="left: 325px; top: 6701px; display: block;">
<a class="FR close" onmousedown="ShowAddComment(event);" href="javascript:void(0);">
</a>
<div class="header">Write your comment below:</div>
<textarea class="txtbox" name="comment_text"/>
<a class="btn" href="javascript:document.comments.submit();">Submit Comment</a>
</div>
*/