// (c) by Inovelop IT-Solutions
 

// 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=800,height=650,scrollbars=no");
  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(typ, 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";
  if (typ == 1)
    document.getElementById("imgpos").innerHTML = "Seite " + i + " / " + count;
  else
    document.getElementById("imgpos").innerHTML = "Bild " + i + " / " + count;
}


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