(function($){
	$.fn.imgchanger = function(options){
		var element = $(this);
		var permission = true;
		var border = $('<div></div>');
		var options = $.extend({
			bigimg: $('img#img_big'),
			dir: '/downloads/gallery/pl/'
		},options);

		border.css({ width: element.width() + 'px', height: element.height() + 'px', left: element.offset().left + 'px', top: element.offset().top + 'px', position: 'absolute', border: '3px solid #f6e859' });
		border.appendTo($('body'));

		element.click(function(){
			if(permission){
				permission = false;
				border.animate({top: $(this).offset().top + 'px', width: $(this).width() + 'px', height: $(this).height() + 'px'}, 'slow');
				options.bigimg.css({ width: $('>img',options.bigimg).width()+'px', height: $('>img',options.bigimg).height()+'px' });
				var small = $(this).attr('src');
				var big = $('>img',options.bigimg).attr('src');
				big = big.split("/");
				small = small.split("/");
				options.bigimg.css({background: "url("+options.dir+"big/"+small[small.length-1]+") no-repeat"});
				$('>img',options.bigimg).fadeOut("slow", function(){
					$('>img',options.bigimg).attr('src', options.dir+'big/'+small[small.length-1]);
					$('>img',options.bigimg).fadeIn("", function(){
						permission = true;
					});
				});
			}
		});

	};
})(jQuery);