// JavaScript Document
	$(document).ready(function(){
		flashHtml = new Array(
    '<embed src="swf/flvplayer.swf" width="450" height="360" allowfullscreen="true" flashvars="&file=1.flv&height=360&width=450&location=swf/flvplayer.swf&autostart=false" />',
    '<embed src="swf/flvplayer.swf" width="450" height="360" allowfullscreen="true" flashvars="&file=2.flv&height=360&width=450&location=swf/flvplayer.swf&autostart=false" />',
    '<embed src="swf/flvplayer.swf" width="450" height="360" allowfullscreen="true" flashvars="&file=3.flv&height=360&width=450&location=swf/flvplayer.swf&autostart=false" />',
    '<embed src="swf/flvplayer.swf" width="450" height="360" allowfullscreen="true" flashvars="&file=4.flv&height=360&width=450&location=swf/flvplayer.swf&autostart=false" />',
    '<embed src="swf/flvplayer.swf" width="450" height="360" allowfullscreen="true" flashvars="&file=5.flv&height=360&width=450&location=swf/flvplayer.swf&autostart=false" />',
    '<embed src="swf/flvplayer.swf" width="450" height="360" allowfullscreen="true" flashvars="&file=6.flv&height=360&width=450&location=swf/flvplayer.swf&autostart=false" />',
    '<embed src="swf/flvplayer.swf" width="470" height="396" allowfullscreen="true" flashvars="&file=jeep i przyczepa.flv&height=396&width=470&location=swf/flvplayer.swf&autostart=false" />',
    '<embed src="swf/flvplayer.swf" width="470" height="396" allowfullscreen="true" flashvars="&file=kólko w piachu.flv&height=396&width=470&location=swf/flvplayer.swf&autostart=false" />',
    '<embed src="swf/flvplayer.swf" width="470" height="396" allowfullscreen="true" flashvars="&file=kraweznik.flv&height=396&width=470&location=swf/flvplayer.swf&autostart=false" />',
    '<embed src="swf/flvplayer.swf" width="470" height="396" allowfullscreen="true" flashvars="&file=wzniesienie_10_procent_i_jeep.flv&height=396&width=470&location=swf/flvplayer.swf&autostart=false" />',
    '<embed src="swf/flvplayer.swf" width="470" height="396" allowfullscreen="true" flashvars="&file=wzniesienie 20 procent.flv&height=396&width=470&location=swf/flvplayer.swf&autostart=false" />',
    '<embed src="swf/flvplayer.swf" width="430" height="440" allowfullscreen="true" flashvars="&file=wzniesienie_10_procent+jeep.flv&height=440&width=430&location=swf/flvplayer.swf&autostart=false" />'
    );
		
		$('.gallery_demo_unstyled').addClass('gallery_demo'); // adds new class name to maintain degradability
		
		$('ul.gallery_demo').galleria({
			history   : true, // activates the history object for bookmarking, back-button etc.
			clickNext : true, // 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);
				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) { // thumbnail effects goes here
				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.6); } // don't fade out if the parent is active
				)
			}
		});
		$("#zdjecia").click(function(){
			$(".demo2").hide();
			$(".demo").show();
			return false;
		});
		$("#filmy").click(function(){
			$(".demo").hide();
			$(".demo2").show();
			return false;
		});	
		
		$(".movie_gal li span").css("opacity","0.5");
		$(".movie_gal li span").mouseover(function(){
		  $(this).fadeTo("fast", 1);
    }).mouseout(function(){
      $(this).fadeTo("fast", 0.5);
    });
    $(".movie_gal li span a img").click(function(){
      $(".movie_gal li span").css("opacity","0.5");
      var srcImg = $(this).attr("src");
      var titleImg = $(this).attr("title");
      var idImg = $(this).attr("id");
      $(".demo2 span.caption").html(titleImg);
      idImg -= 1;
      $(".flash").html(flashHtml[idImg]);   
      return false;
    });

		
	});
