// zeigt eine Gallerie als eigenes Fenster an
function ShowImage(GalImage, GalCount)
{
  var ImageFile = "images/" + GalImage;
  
  GW = window.open("images.htm?ImageFile=" + ImageFile + "&ImageCount=" + GalCount,"Bildergallerie","width=820,height=660,scrollbars=yes");
  GW.focus();
}


// Fürhende Nullen einfügen
function InsertNull(i)
{
  var s = String(i);
  while (s.length < 4) s = "0" + s;
  return s;
}


// Bild anzeigen
function ShowImg(count, idx)
{
  var i;
  var s;
  
  s = document.images[0].src;
  i = Number(s.substr(s.length-8,4));
  
  switch (idx)
  {
    case 1: 
      i = 1;                // erstes Bild
      break; 
    case 2:
      if (i > 1) i--;      // vorheriges Bild
      break;
    case 3: 
      if (i < count) i++;  // nächstes Bild
      break;
    case 4:
      i = count;           // letztes Bild
      break;
  }
  document.images[0].src = s.slice(0,s.length-8) + InsertNull(i) + ".jpg";
  document.getElementById("imgpos").innerHTML = "Bild " + i + " / " + count;
}

// Slideshow starten/stoppen
function StartStopSL()
{ 
  if (SL == 0)
  {
    SL = 1;
	SLa = window.setInterval("ShowImg(ImageCount,3)", 3000);
	ShowImg(ImageCount,3);
  }
  else
  {
    SL = 0;
	window.clearInterval(SLa);
  }
}

