popup = {
	add: function(settings) {
		var s = $.extend({
			link: null,
			popup: null,
			container: null,
			url: null
		}, settings);
		
		var $container = s.container || s.popup;
		if (!$container) {
			$container = $('<div class="popup" style="display:none"></div>');
			$("body").append($container);
		}
		
		$container.remove().appendTo("body");
		
		$container.jqm({
			ajax: s.url || "@href",
			target: s.popup,
			modal: true,
			onShow: function() {
				$container
					.css({
						"z-index": 5000,
						"visibility": "hidden"
					})
					.show();
			},
			onLoad: function() {
				$container
					.center()
					.css("visibility", "visible");
			}
		});
		
		$container.jqmAddTrigger(s.link);
		
		$(".jqmOverlay").live(
			"click",
			function() { $container.jqmHide(); }
		);
		
		$("#" + $container.attr("id") + " .jqmClose").live(
			"click",
			function() { $container.jqmHide(); }
		);
	},
	
	center: function($container) {
		$container
			.css("z-index", 5000)
			.center();
	}
}