$(document).ready(function(){
	var carouselWidth = $('.carousel').width();
	$('#header .carousel').show();
	$('#header .carousel .info').css({'left':(carouselWidth-880)/2});
	$('#header .carousel .items div').not('.info').css({'width': carouselWidth});
	$("#header .carousel").scrollable({circular: true, autopause: true, steps:1}).navigator().autoscroll({ autoplay: true, interval: 5000 });
	$("#content .carousel").scrollable({circular: true}).autoscroll({ autoplay: true, interval: 1000 });;    
  
  
    
	//	$("#content .carousel").scrollable({circular: true});

  // provide scrollable API for the action buttons ans top on navig button click
  window.sl_api = $("#header .carousel").data("scrollable");
  $(".carousel_prev, .carousel_next, .navi a").click(function(){
       sl_api.stop();
  });
	
	

  $("#showForm").click(
    function() {
      $("#requestForm").toggle();   

    });

   $(".bbg img[rel]").overlay();
	
	// Gallery
	$(".jsgallery").scrollable();

	
	$('.browse').hide();
	$('.carousel').hover(function(){
		$(this).find('.browse').not('.disabled').show();
	},
	function(){
		$(this).find('.browse').hide();
	});

	$('.carousel a').click(function(event){
		var c = $(this).closest('.carousel');
		c.trigger('mouseleave');
		c.trigger('mouseover');
	});
	

$("#imggallery .items img").click(function() {
	if ($(this).hasClass("active")) { return; }
	var url = $(this).attr("src").replace("_t", "");
	var wrap = $("#image_wrap").fadeTo("medium", 0.5);
	var img = new Image();
	img.onload = function() {
		wrap.fadeTo("fast", 1);
		wrap.find("img").attr("src", url);
		wrap.find("a").attr("href", url);
	};
	img.src = url;
	$("#imggallery .items img").removeClass("active");
	$(this).addClass("active");
}).filter(":first").click();

// Galerie
	$(".fancy").fancybox({
		'overlayShow'	: false,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});

	// rozklikavani dalsich sluzeb
	$('.toggle-box').hide();
	$('.toggle-link').click(function(){
		var a = $(this);
		$('.toggle-box').toggle('fast', function(){
		
			if(a.hasClass('arrow-down')){
				a.removeClass('arrow-down').addClass('arrow-up').html('Skrýt další služby');
			}else{
				a.removeClass('arrow-up').addClass('arrow-down').html('Zobrazit další služby');
			}
		});
		return false;
	});
});

