//
// Random Access
//  JavaScript code
//  animate.js
var gTimerID = 0;
var gSpeed = -1;
var gDirection = 1;

function getSlide (selectedIndex)
{
  var Slides = document.forms[0].slides;
  var imgSrc = Slides[selectedIndex].value;
  var viewerWin = window.open (imgSrc,"VIEWER");
}
function nextSlide (iDirection)
{
  var Slides = document.forms[0].slides;
  if (iDirection) { gDirection = iDirection }

  var selectedIndex = Slides.selectedIndex;

  selectedIndex += gDirection;
  if (selectedIndex < 0) {
    selectedIndex =  Slides.length - 1;
  }
  if (selectedIndex >= Slides.length) {
    selectedIndex =  0;
  }

  Slides.selectedIndex = selectedIndex;
  getSlide(selectedIndex);

  if (gSpeed) {
    stopTimer();
    gTimerID = setTimeout ("nextSlide()", gSpeed * 1000);
  }
}
function Play ()
{
  var Seconds = document.forms[0].secs;
  gSpeed = Seconds[Seconds.selectedIndex].value;
  nextSlide ();
}
function stopTimer()
{
  if (gTimerID) {
    clearTimeout(gTimerID);
    gTimerID = 0;
  }
}
function Stop ()
{
  stopTimer();
  gSpeed = -1;
}