var startinplaymode = 0;
var thisslide = 0;
var isplaying = 0;
var rotate = 0;
var slidespeed = 0;

function setslidespeed()
{
  slidespeed = document.slideshow.speedcombo.options[document.slideshow.speedcombo.selectedIndex].value;
}

function showthisslide()
{
  var thislabel;
  document.images.show.src = slide[thisslide];
  var slidenumb = thisslide + 1;
  thislabel = "Slide " + slidenumb + " of " + slide.length;
  if (thisslide == slide.length - 1)
  {
    thislabel = thislabel + " (end)";
  }
  document.slideshow.title.value = thislabel;
}

function showfirstslide()
{
  thisslide = 0;
  showthisslide();
}

function showprevslide()
{
  if (thisslide > 0)
  {
    thisslide--;
    showthisslide();
  }
}

function shownextslide()
{
  if (thisslide < slide.length - 1)
  {
    thisslide++;
    showthisslide();
  }
}

function showlastslide()
{
  thisslide = slide.length - 1;
  showthisslide();
}

function clickplaybutton()
{
  if (!isplaying)
  {
    isplaying = 1;
    document.slideshow.aplay.value = "STOP";
    window.setTimeout("advanceslide()", slidespeed);
  }
  else
  {
    isplaying = 0;
    document.slideshow.aplay.value = "START";
  }
}

function advanceslide()
{
  if (isplaying)
  {
    if (thisslide == slide.length - 1)
    {
      if (rotate)
      {
        thisslide = 0;
      }
    }
    else
    {
      thisslide++;
    }
    showthisslide();
    window.setTimeout("advanceslide()", slidespeed);
  }
}

function gotoslide()
{
  var framenum = Number(document.slideshow.framebox.value);
  document.slideshow.framebox.value = String(framenum);

  if ((framenum >= 1) && (framenum <= slide.length))
  {
    thisslide = framenum - 1;
    showthisslide();
  }
}

function initslideshow()
{
  setslidespeed();
  if (startinplaymode)
  {
    isplaying = 0;
  }
  else
  {
    isplaying = 1;
  }
  thisslide = 0;
  showthisslide();
  clickplaybutton();
}

