(function($) {
	$.fn.extend({
		imageZoomer: function() {
			return this.each(function() {
				var self = $(this);
				
				self.click(function (event) {
					event.preventDefault();

					var image = new Image();
					image.onload = function () {
						var container = $("<div />");
						container.css({
							"display": "none",
							"width": this.width + "px",
							"height": this.height + "px",
							"top": "50%",
							"left": "50%",
							"position": "fixed",
							"margin-left": "-" + (this.width / 2) + "px",
							"margin-top": "-" + (this.height / 2) + "px"
						});
						
						var btn = $("<div />").addClass("btn-close");
						var img = $(image).addClass("zoomed-image");
						container.append(img).append(btn).appendTo($("body")).fadeIn("slow");
						
						container.click(function() {
							$(this).remove();
						});
					}
					
					image.src = self.attr("href");
					
					return false;
				});
			});
		}
	});
})(jQuery);
