(function($){


	$.fn.gallery = function(thumbs){


		$(this).each(function(){


			var $el = $(this);


			$(thumbs).each(function(){


				var $thumb = $(this);


				var url = $thumb.attr('href');


				var newImg = new Image();

				newImg.src = url;


				$thumb.bind('click', function(){


					$el.attr('src', url);


					$el.trigger({

						type: 'picturechange',

						$thumb: $thumb

					});


				});


			});


		});


		return this;

	};


	$.event.special.picturechange;

	$.fn.picturechange = function(func){

		return $(this).bind('picturechange', func);

	};


})(jQuery);
