(function($j)
{
	$j.overlay = {
		selected: $j,
		
		show: function(selectors, status)
		{
			if (status != null && status == false)
			{
				this.selected = $j;
				
				$j(selectors).each(this.destroy);
			}
			else
			{
				this.selected = $j(selectors).each(this.create);
			}

			$j(window).bind('resize', this.resize);
		},

		create: function()
		{
			var oId = this.id + '_overlay';
			var existing = $j('#' + oId);
			var el = $j(this);

			if (existing.length > 0)
			{
				existing.css({
					top: el.offset().top + 1,
					left: el.offset().left + 1,
					width: el.width() / 2 + 16,
					height: el.height() / 2 + 16,
					'padding-left': el.width() / 2 - 16,
					'padding-top': el.height() / 2 - 16
				});
				
				return;
			}

			var overlay = $j('<div />').attr('id', oId)
				.addClass('loading_overlay')
				.css({
					top: el.offset().top + 1,
					left: el.offset().left + 1,
					width: el.width() / 2 + 16,
					height: el.height() / 2 + 16,
					'padding-left': el.width() / 2 - 16,
					'padding-top': el.height() / 2 - 16,
					opacity: 0.7
				})
				.append('<div />');

			$j('#' + this.id).after(overlay);
		},

		resize: function()
		{
			$j.overlay.selected.each($j.overlay.create);
		},

		destroy: function()
		{
			$j('#' + this.id + '_overlay').remove();
		}
	}
}(jQuery));

