                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
var curImg = 0;
var timerId = -1;
var secTimerId = -1;
var interval = 6000;
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;

  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 = "<center><table cellpadding=0 cellspacing=0 border=0><tr><td align=center><font face=arial size=3 color="+textColor+"><b>" + a_title[curImg] + "</b></font></td></tr><tr><td>&nbsp;</td></tr><tr><td valign=top align=center>" + "<img src=" + a_src[curImg] + " alt=\"photo\" border=0 onload=\"imgLoadNotify();\">";


  html += "</td></tr><tr><td>&nbsp;</td></tr><tr><td align=center><font face=arial size=-1 color="+textColor+">" + a_cap[curImg] + "</font>";
  html += "</td></tr></table></center>";
  
  var replaceNumvalue=replaceNum();
  document.test.text.value = replaceNumvalue;
  document.test.totalimage.value = a_src.length;
 
  switch(navigator.family) {
    case 'gecko':
      document.getElementById("imgDiv").innerHTML = html;
      break;
    case 'nn4':
      document.layers[0].document.imgDiv.document.open();
      document.layers[0].document.imgDiv.document.write(html);
      document.layers[0].document.imgDiv.document.close();

      //document.layers[0].document.pnumDiv.document.open();
	  //document.layers[0].document.pnumDiv.document.close();
      break;
    case 'ie4':
      document.all.imgp.innerHTML = html;
      break;
  }
}

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);
  }
}

