$(document).ready(function() {
	var start = $.cookie('jcarousel_akcninabidka');	
	if (start == null) {
		start = 1;
	}
	start = Number(start);
	$('#galleri').jcarousel({
		// Configuration goes here    prepis tady idecko muhehe
		start: start,
		vertical: false,
		scroll: 1,
		auto: 5,
		wrap: 'both',
		initCallback: jcarousel_initCallback,
		itemFirstOutCallback: jcarousel_itemFirstOutCallback,
		itemFirstInCallback: jcarousel_itemFirstInCallback
	});
	
	$('.hoverImage').hover(
    function()
    {
      $(this).css("opacity", 1);
    },
    function()
    {
      $(this).css("opacity", 0.85);
    }
  );
  
  $('.hoverImage').css("opacity", 0.85);
  
});

function jcarousel_initCallback(carousel) {
 	// Pause autoscrolling if the user moves with the cursor over the clip.
 	carousel.container.hover(function() {
 		carousel.stopAuto();
 	}, function() {
 		carousel.startAuto();
 	});
 };

function jcarousel_itemFirstOutCallback(carousel, panel, index, d) {
 	//if (d == 'next') {
 	//	$.cookie('jcarousel_akcninabidka', index + 1);
 	///}
}

function jcarousel_itemFirstInCallback(carousel, panel, index, d) {
	//if (d == "prev") {
	$.cookie('jcarousel_akcninabidka', index, { path: '/' });
	//}
}
