var timer_length = 1000;  // nastavení kroku časovače (1s)
var timer_general;
var timer_foto1 = 8;
var foto1_n = 2;
var timer_foto2 = 8;
var foto2_n = 1;
var timer_foto3 = 8;
var foto3_n = 0;

function casovac() {
  if(timer_foto1>0) {
    foto1_n++;
    if(foto1_n==timer_foto1) {
      $("#showgal-foto1").fadeTo("slow", 0, function() {
        $("#showgal-foto1").load('ajax/foto.php', { sesid: sesid, n: '1' }, function() {
        $("#showgal-foto1").fadeTo("slow", 1);
        });
      });
      foto1_n=0;
    }
  }
  if(timer_foto2>0) {
    foto2_n++;
    if(foto2_n==timer_foto2) {
      $("#showgal-foto2").fadeTo("slow", 0, function() {
        $("#showgal-foto2").load('ajax/foto.php', { sesid: sesid, n: '2' }, function() {
          $("#showgal-foto2").fadeTo("slow", 1);
        });
      });
      foto2_n=0;
    }
  }
  if(timer_foto3>0) {
    foto3_n++;
    if(foto3_n==timer_foto1) {
      $("#showgal-foto3").fadeTo("slow", 0, function() {
        $("#showgal-foto3").load('ajax/foto.php', { sesid: sesid, n: '3' }, function() {
        $("#showgal-foto3").fadeTo("slow", 1);
        });
      });
      foto3_n=0;
    }
  }
  timer_general=setTimeout("casovac()", timer_length);
}

$(document).ready(function(){

	$("ul.topnav li .havesub").click(function() { //When trigger is clicked...

		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
		});

		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("subhover"); //On hover over, add class "subhover"
		}, function(){	//On Hover Out
			$(this).removeClass("subhover"); //On hover out, remove class "subhover"
	});

  timer_general=setTimeout("casovac()", timer_length);
});

