

/////////////// GALERIE PROSTORY ///////////////////////////////////////////////

var activeImg = 1;
var idcko;
var idcko2;
var next;
var t;


$("#Nahledy img").bind({
  click: function()
  {
    idcko  = parseInt($(this).attr("name"));
    if (idcko != activeImg)
    {
      displayNext(activeImg, idcko);
    }
    clearTimeout(t);
    t = setTimeout(skip, 8000);
  },
  mouseenter: function()
  {
    idcko2  = $(this).attr("name");
    if (idcko2 != activeImg)
    {
      $(this).fadeTo("fast", 1.0);
    }
  },
  mouseleave: function()
  {
    idcko2  = $(this).attr("name");
    if (idcko2 != activeImg)
    {
      $(this).fadeTo("fast", 0.2);
    }
  }
});



function getNext()
{
  if(activeImg < 5){
    next = activeImg + 1;
  }
  else {
    next = 1;
  }
  displayNext(activeImg, next);
}

function displayNext(old, nu)
{
  // thumb
  $("#thumb" + old).fadeTo("fast", 0.2);
  $("#thumb" + nu).fadeTo("fast", 1.0);
  
  // img
  $("#obr" + old).fadeOut('slow', function() {
    $("#obr" + nu).fadeIn("slow");
  });
  activeImg = nu;
}

function skip()
{
  getNext();
  t = setTimeout(skip, 4000);
};

skip();


if (/*@cc_on!@*/false) { // check for Internet Explorer
	document.onfocusin = onFcs;
	document.onfocusout = onBlr;
} else {
	window.onfocus = onFcs;
	window.onblur = onBlr;
}

function onFcs(){
  t = setTimeout(skip, 8000);
}

function onBlr(){
  clearTimeout(t);
}



