//<script type="text/javascript">

var hash = window.location.hash.split("#")[1];
if(hash){
	if(hash != ""){
        	window.location = window.location.protocol + '//' + window.location.host + window.location.pathname + '/'+ hash;
        }
}

$(document).ready(function(){
        $("a[rel^='gallery']").prettyPhoto({theme:'dark_square'});

        /*$(".events a").click(function(){
        	$(".events").hide();
                var id = $(this).attr('href').split('#')[1];

                $(".events").after('<p><a href="#" class="back">&lt; Späť</a></p><div id="current-event"><div class="loading">Načítavam...</div></div>');

                $(".back").click(function(){
		        $(this).parent().remove();
			$("#current-event").remove();
			$(".events").show();
		});

                $.ajax({
			method: "get",
			url: "/2009/osvetake/admin/front/ajax.php",
			data: "ajax=displayEvent&root=/2009/osvetake/&page=Archiv-podujati/Podujatia-2009&id="+id,
			dataType: "html",
                        success: function(html){
                                $("#current-event").html(html);
		                $("a[rel^='gallery']").prettyPhoto({theme:'dark_square'});
                        }
		});
        });*/

        $('div.sliderGallery').each(function () {
		var ul = $('ul', this);
		var productWidth = ul.innerWidth() - $(this).outerWidth();


                var sliderGallery = this;

		var slider = $('.slider', this).slider({
			handle: '.handle',
			min: 0,
			max: productWidth,
			slide: function (ev, ui) {
				ul.css('left', '-' + ui.value + 'px');
	      		},
	      		stop: function (ev, ui) {
	        		ul.animate({ 'left' : '-' + ui.value + 'px' }, 500, 'linear');
	      		}
		});

                $("div.slider-wrapper.left").click(function(){

		       var elValue = slider.slider('option', 'value');

		       if(elValue > 0) {

		          elValue = elValue - 450; // you can change the increment to whatever you like (250, 300, etc).

		          if(elValue < 0) {
		             elValue = 0;  // so it stops scrolling after reaching the end.
		          }

		          $(".slider", sliderGallery).slider('value', elValue); // so the handler jumps to the desired position
		          $("ul", sliderGallery).animate({'left' : elValue * -1}, 500); // scroll the page

		       }

		});

	        $("div.slider-wrapper.right").click(function(){

		       var elValue = slider.slider('option', 'value');

		       if(elValue < productWidth) {  // i have a variable called itemsWidth, with the max: size of my slider div.  You can change it to whatever is the size of your DIV.

		          elValue = elValue + 450;

		          if(elValue > productWidth) {
		             elValue = productWidth;
		          }

		          $(".slider",sliderGallery).slider('value', elValue);
		          $("ul",sliderGallery).animate({'left' : elValue * -1}, 500);

		       }

		});

	});

        $("#dialogy-artists").click(function () {
            $(".dialogy-artist").toggle();
        });

});


