(function($) {
	$.fn.glassbox = function(o) {
		var options = $.extend(true, {}, $.fn.glassbox.defaults, o);
		
		var html = options.templates.surround.gsub('%content', $(this).html());
		var glassbox = $(html).appendTo('body');
		glassbox.fadeOut(0);
		
		var width = glassbox.width(), height = glassbox.height();
		var bodyWidth = $(window).width(), bodyHeight = $(window).height();
		var x = (bodyWidth/2) - (width / 2), y = (bodyHeight/2) - (height / 2);
		glassbox.css('top', y+'px').css('left', x+'px');
		
		glassbox.fadeIn('normal');
		
		glassbox.find('.glassbox-closeButton').click(function() {
			glassbox.fadeOut('normal', function() {
				glassbox.remove();
			});
		});
		
		return glassbox;
	};
	
	$.fn.glassbox.defaults = {
		templates: {
			surround: "<div class='glassbox'><div class='glassbox-inner'><table class='glassbox-table'><tr><td class='glassbox-topleft'></td><td class='glassbox-top'></td><td class='glassbox-topright'></td></tr><tr><td class='glassbox-left'></td><td class='glassbox-content'>%content</td><td class='glassbox-right'></td></tr><tr><td class='glassbox-bottomleft'></td><td class='glassbox-bottom'></td><td class='glassbox-bottomright'></td></tr></table><div class='glassbox-closeButton'></div></div></div>"
		}
	};
	
})(jQuery);