                                                                                                                                                                                                                                                                                                                                                                                                       
var curImg = 0;
var timerId = -1;
var secTimerId = -1;




var interval = 2000;  			 // set speed to 2 per  second



var secInterval = interval / 1000;
var currSec = secInterval;
var copyType = "";
var isPlaying = 1;

function replaceNum()
{
  var input = SHOWINGSTRING;
  var output = input;
  var idx = output.indexOf("%slideNum");
  if (idx > -1) {
    output = input.substring(0, idx);
    output += eval(curImg+1);
    output += input.substr(idx+9);
  }
  return output;
}

function changeSpeed()
{
  var sidx = document.forms[0].speedMenu.selectedIndex;
  var speed = document.forms[0].speedMenu.options[sidx].value;
  //speed = 1;
  interval = speed;
  secInterval = interval / 1000;

  if (timerId != -1) {
    clearTimers();
  }

  play();
}

function imgLoadNotify()
{
  if (isPlaying == 1)
    setTimers();
}
//############################################################

//#################------------------#################################



function changeSlide()
{
  if (timerId != -1) {
    clearTimers();
    dispLoading();
  }

  var html = "<table cellpadding=0 cellspacing=0 border=0><tr><td align= left>"
//  html += "<font face=arial size=3 color="+textColor+"><b>" + a_src[curImg] + "</b>"
//  html += "</font></td></tr><tr><td>&nbsp;</td></tr><tr><td valign=top align=center>"
  html = "<img src=" + a_src[curImg] + " aligh = center  border=0 onload=\"imgLoadNotify();\">";
 // html += "</td></tr><tr><td>&nbsp;</td></tr><tr><td align=center>"
//  html += "<font face=arial size=-1 color="+textColor+">" + a_cap[curImg] + "</font>";
// html += "</td></tr></table>";
  
  var replaceNumvalue=replaceNum();
  document.test.text.value = replaceNumvalue;
  document.test.totalimage.value = a_src.length;
  // goes to slide show and gets number in array
 
 
      document.getElementById("imgDiv").innerHTML = html;  
  
  
}

function forward()
{
  curImg++;
  if (curImg == numImgs)
    curImg = 0;
  changeSlide();
}

function rewind()
{
  curImg--;
  if (curImg < 0)
      curImg = numImgs - 1;
  changeSlide();
}

function dispSec()
{
  var dispSec = ( currSec < 0 ) ? 0 : currSec;
  var secText = "<font face=arial color=green size=-2>Next slide in " + dispSec + " sec</font>";
  currSec--;
}


function dispLoading()
{
  var text = "<font face=arial color=green size=-2>Loading image...</font>";

}

function stop()
{
  clearTimers();
//  isPlaying = 0;

  var secText = "<font face=arial color=red size=-2>Slideshow Stopped</font>";

  
 // document.playbtn.src = buttonImgPfx + buttonOffArray[0];
 // document.stopbtn.src = buttonImgPfx + buttonOnArray[1];
}

function play()
{
//  setTimers();
  startShow();
}

function startShow()
{
  isPlaying = 1;

 // document.playbtn.src = buttonImgPfx + buttonOnArray[0];
 // document.stopbtn.src = buttonImgPfx + buttonOffArray[1];
}

function setTimers()
{
  currSec = secInterval;
  dispSec();

  if (secTimerId == -1)
    secTimerId = window.setInterval('dispSec();', 1000);
  if (timerId == -1)
    timerId = window.setInterval('forward();', interval);
}

function clearTimers()
{
  window.clearInterval(timerId);
  timerId = -1;
  window.clearInterval(secTimerId);
  secTimerId = -1;
}

function setButton(direction)
{
  if (direction == 0) {
   // document.prevbtn.src = buttonImgPfx + buttonOnArray[2];
   // window.setTimeout("document.prevbtn.src = buttonImgPfx + buttonOffArray[2];", 300);
  } else {
   // document.fowdbtn.src = buttonImgPfx + buttonOnArray[3];
   // window.setTimeout("document.fowdbtn.src = buttonImgPfx + buttonOffArray[3];", 300);
  }
}
