var celkem;
var aktualni;
var dalsi;
var pruhlednost;
var z;
var na;
var menic;
var pruhoz;
var beh;

function Stop()
{
  clearInterval(menic);
  Zvyrazni("_pause");
  Normalni("_play");
  beh = false;
}
function Play()
{
  menic = window.setInterval("Zmen()",1000*6);
  Zvyrazni("_play");
  Normalni("_pause");
  beh = true;
}
function Zobraz(cislo)
{

  var zobraz;
  zobraz = "top_foto" + cislo;
  clearInterval(menic);
  clearTimeout(pruhoz);
  Pruhlednost(z, 0 );
  Pruhlednost(na, 0 );
  Zindex(z, 4);
  Zindex(na, 4);
  Zindex(zobraz, 5);
  Pruhlednost(zobraz, 100 );
  Normalni(aktualni);
  Zvyrazni(cislo);
  aktualni = cislo;
  dalsi = Dalsi();
  z = "top_foto" + aktualni;
  na = "top_foto" + dalsi;
  if(beh)  menic = window.setInterval("Zmen()",1000*6);
}

function TopFoto(pocet)
{

  Zvyrazni(1);
  aktualni = 1;
  dalsi = Dalsi();
  z = "top_foto" + aktualni;
  na = "top_foto" + dalsi;
  celkem = pocet;
  beh = true;
  Zvyrazni("_play");
  menic = window.setInterval("Zmen()",1000*6);
  return 1;
}


function Zmen()
{
  z = "top_foto" + aktualni;
  na = "top_foto" + dalsi;

  pruhlednost = 100;
  Prohod();
  Zvyrazni(dalsi);
  Normalni(aktualni);
  aktualni = dalsi;
  dalsi = Dalsi();
}
function Prohod()
{
  if(pruhlednost >= 0)
  {
  	if(pruhlednost == 0){
  		Zindex(z, 4);
  		Zindex(na, 5);
  	}

    Pruhlednost(z, pruhlednost );
    Pruhlednost(na, 100 - pruhlednost );
    pruhlednost = pruhlednost - 5;
    pruhoz = window.setTimeout("Prohod()",50);
  }

}

function Dalsi()
{
  if(aktualni + 1 > celkem) return 1;
  else return aktualni + 1;
}


function Zindex(objekt, cislo){
	  document.getElementById(objekt).style.zIndex = cislo;
	  return 1;
}

function Pruhlednost(objekt, cislo)
{
  document.getElementById(objekt).style.opacity = cislo/100;
  document.getElementById(objekt).style.filter = 'alpha(opacity=' + cislo + ')';


  return 1;
}

function Zvyrazni(cislo)
{

  document.getElementById("tlacitko" + cislo).style.background = "#989796";
}
function Normalni(cislo)
{
  document.getElementById("tlacitko" + cislo).style.background = "none";
}
function On(e)
{
  e.style.color = "gray";
}
function Out(e)
{
  e.style.color = "black";
}
