		function gallery_init() {
		
		    $('.photo_list img').each(
		        function() {
		            $(this).wrap('<ul class="gallery"><li><a href="' + $(this).attr('src').replace(/_s./, '_l.') + '"></a></li><ul>');
					$(this).attr('border', '0');
		        }
		    );
		    
		    var active_thumb = $('.photo_list img').eq(0);
		    active_thumb.parents('li').addClass('active');
		
			$('#cache_img').hide();
			$('.gallery').addClass('gallery_list'); // adds new class name to maintain degradability
			
			$('.photo_list').css('display', 'none');
			
			$('ul.gallery_list').galleria({
				history   : false, // activates the history object for bookmarking, back-button etc.
				clickNext : false, // helper for making the image clickable
				insert    : '#main_image', // the containing selector for our main image
				onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
				    
					image.css('display','none').fadeIn(1000);
					caption.css('display','none').fadeIn(1000);
					
					// fetch the thumbnail container
					var _table = thumb.parents('table');
					
					// fade out inactive thumbnail
					var selectedImg = _table.find('img.selected');
					selectedImg.fadeTo(500, 0.6)
					selectedImg.removeClass('selected');
					selectedImg.parents('li').removeClass('active');
					
					// fade in active thumbnail
					thumb.fadeTo('fast',1).addClass('selected');
					thumb.parents('li').addClass('active');
					
					// add a title for the clickable image
					//image.attr('title','Next image >>');
				},
				onThumb : function(thumb) { // thumbnail effects goes here

					// fetch the thumbnail container
					var _li = thumb.parents('li');
					
					// if thumbnail is active, fade all the way.
					var _fadeTo = _li.is('.active') ? '1' : '0.6';
					
					// fade in the thumbnail when finnished loading
					thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
					
					// hover effects
					thumb.hover(
						function() { thumb.fadeTo('fast',1); },
						function() { _li.not('.active').children('img').fadeTo('fast',0.6); } // don't fade out if the parent is active
					);
				}
			});
			$('.photo_list').fadeIn(1000);
			
		}
