var loga = new Array();
var posun = 0;

function slideshow_start(id) {
  var snura = document.getElementById(id);
  var obrazky = snura.getElementsByTagName('img');
  for (i=0; i<obrazky.length; i++) {
    obrazky[i].style.margin = '0 10px';
    zdroj_obrazku = obrazky[i].getAttribute('src');
    loga[i] = new Image();
    loga[i].src = zdroj_obrazku;
  }
  slideshow_move(id);
}

function slideshow_move(id) {
  var smer = -1;
  var snura = document.getElementById(id);
  var obrazky = snura.getElementsByTagName('img');
  var odkazy = snura.getElementsByTagName('a');

  if (posun < (obrazky[0].clientWidth + (2 * 10))) {
    posun += 2;
    snura.style.marginLeft= (posun * -1)+'px';
    window.setTimeout("slideshow_move('"+id+"');",30);
  }
  else {
    novy_odkaz = document.createElement('a');
    novy_obrazek = document.createElement('img');
    snura.appendChild(novy_odkaz);
    odkazy[odkazy.length-1].appendChild(novy_obrazek);
    odkazy[odkazy.length-1].setAttribute('href',odkazy[0].getAttribute('href'));
    obrazky[obrazky.length-1].setAttribute('src',obrazky[0].getAttribute('src'));
    obrazky[obrazky.length-1].setAttribute('name',obrazky[0].getAttribute('name'));
    obrazky[obrazky.length-1].style.margin = '0 10px';
    odkazy[0].parentNode.removeChild(odkazy[0]);
    snura.style.marginLeft = 0;
    posun = 0;
    slideshow_move(id);
  }
}
