(function($) {
   $.fn.dumondeMultiGallery = function(options){
        var defaults = {
                imgSelector:           '.dumonde-gallery-big-img',
                imgLoadingSelector:    '.dumonde-gallery-loading'
        };
        var options = $.extend(defaults, options),
            $bigImg = $(options.imgSelector),
            $imgLoading = $(options.imgLoadingSelector);
        return this.each(function(index){
            var $listImagesWrapper = $(this),
                $currentBigImg = $($bigImg[index]),
                $currentImgLoading = $($imgLoading[index]),
                $currentBigImgWrapper = ($currentBigImg.parent(":not(a)").length ? $currentBigImg.parent() : $currentBigImg.parent().parent()),
                $currentBigImgWrapperWidth = $currentBigImgWrapper.width(),
                $currentBigImgWrapperHeight = $currentBigImgWrapper.height(),
                $items = $listImagesWrapper.find("a"),
                $firstItem = $items.filter(":first");
    		function show_image(img_url) { // show the loading
			    $currentBigImg.hide();
			    $currentImgLoading.show();
			    $currentBigImg.attr('src',img_url).load(function(){
			        $currentImgLoading.hide();
			        $currentBigImg.fadeIn();
			    });
		    };
		    function illuminateCurrent(current){
                $items.css('opacity','0.5');
                current.css('opacity',1);
		    };
            show_image($firstItem.attr('href'));
            illuminateCurrent($firstItem);
            $items.click(function(){
                show_image($(this).attr('href'));
                illuminateCurrent($(this));
                return false;
            });
        });
   };
})(jQuery);


