$(document).ready(function() {

  // illustration
	$('#illustration ul').innerfade({
		speed: 1000,
		timeout: 2500,
		type: 'sequence'
	});

  // search form
  $('#searching-form').submit(function(){
    if ($('#search-text-inp').val() == '') {
      alert('Zadejte prosím hledaný výraz');
      return false;
    }
    if ($('#search-text-inp').val().length < 3) {
      alert('Hledaný výraz musí obsahovat alespoň tři znaky');
      return false
    }
  });

  // lightbox
  $(function() {
    $('a[rel*=lightbox]').lightBox({
     fixedNavigation:true,
	   containerResizeSpeed: 350,
	   txtImage: 'Obrázek',
	   txtOf: 'z'
   });
  });


  // slideshow
	$('#slider-stage').carousel('#slideshow-previous', '#slideshow-next');

  var intervalId;
  function automaticSlideshow() {
    intervalId = window.setInterval(simulatedClick, 2500);
  }
  function simulatedClick() {
    $('#slideshow-next').click();
  }
  automaticSlideshow();
  $('#slider-stage, #slideshow-previous, #slideshow-next').bind('mouseenter', function(){
    window.clearInterval(intervalId);
  }).bind('mouseleave', function(){
    automaticSlideshow();
  });

});

