				$(function() {
					$(".thumbnails_unstyled").addClass("thumbnails");			
					$("ul.thumbnails").galleria({
						history: false,
						clickNext: true,
						insert: "#glow_zdj",
						onImage: function(image, caption, thumb) {
							image.css("display", "none").fadeIn(500);
							caption.css("display", "none").fadeIn(500);
							var _li = thumb.parents("li");
							_li.siblings().children("img.selected").fadeTo(500, 0.5);
							thumb.fadeTo("fast", 1).addClass("selected");
							image.attr("title", "Next image");
						},
						onThumb: function(thumb) {
							var _li = thumb.parents("li");
							var _fadeTo = _li.is(".active") ? "1" : 0.5;
							thumb.css({display: "none", opacity: _fadeTo}).fadeIn(1500);
							thumb.hover(
								function() { 
									thumb.fadeTo("fast", 1);		
								},
								function() {
									_li.not(".active").children("img").fadeTo("fast", 0.5);
								}
							)
						},
						preloads: 3
					});
					
					$.galleria.loader = $(new Image()).attr("src","/images/stories/galeria_kamienia/skrypty/loader.gif").attr("title","Loading...").addClass("loader");
					
					prepareArrow = function(arrow) {
						arrow.css({display: "none", opacity: 0.5, "top": "0px"}).fadeIn( 1000);			
						arrow.hover(
							function() {
								arrow.fadeTo("fast", 1);
							},
							function() {
								arrow.fadeTo("fast", 0.5);			
							}
						);	
					}
					
					var leftArrow = $("#left_arrow");
					prepareArrow(leftArrow);
					leftArrow.css({"left": "-60px"});
					leftArrow.click(function() {
						$.galleria.prev();	
					});
					
					var rightArrow = $("#right_arrow");
					prepareArrow(rightArrow);
					rightArrow.css({"right": "-50px"});					
					rightArrow.click(function() {
						$.galleria.next();
					});
				});

				$(document).bind("keydown", "left", function() {
					if (!KeyboardNavigation.widgetHasFocus()) {
						$.galleria.prev();
					}
				});
				$(document).bind("keydown", "right", function() {
					if (!KeyboardNavigation.widgetHasFocus()) {
						$.galleria.next();
					}
				});

				var KeyboardNavigation = {
					widgetHasFocus: function() {
						if(typeof _jaWidgetFocus != 'undefined' && _jaWidgetFocus) {
							return true;
						}
						return false;
					}
				}

				var ImageScroller = {
					scrollRight: function() {
						$(this).scrollImages({ onScroll: function() { $.galleria.start() }, direction: "right", duration: 120, imageWidth: 106, size: 4 });
					},			
					scrollLeft: function() {
						$(this).scrollImages({ onScroll: function() { $.galleria.start() }, direction: "left", duration: 120, imageWidth: 106, size: 4 });
					}
				}
