//-----------------------------------------------
//  Slideshow player
//-----------------------------------------------

var iss;
var jss = 0;
var pss = Picture.length;

var preLoad = new Array();
for (iss = 0; iss < pss; iss++) {
  preLoad[iss] = new Image();
  preLoad[iss].src = Picture[iss];
}

var timerID = 0;
var tStart = null;
var playSpeed = 6;
var fadeDuration = 2;

function startTimer() {
  tStart = new Date();
  timerID = setTimeout("updateTimer()", 1000);
}

function clearTimer() {
  if (timerID) {
    clearTimeout(timerID);
    timerID = 0;
  }
}

function updateTimer() {
  clearTimer();
  var tDate = new Date();
  var tDiff = tDate.getTime() - tStart.getTime();
  tDate.setTime(tDiff);
  if (tDate.getSeconds() >= playSpeed) {
    tStart = new Date();
    playNext();
  }
  timerID = setTimeout("updateTimer()", 1000);
}

function playNext() {
  jss = jss + 1;
//jss = Math.round(Math.random() * pss);
  if (jss >= pss) jss=0;
  if (document.all) {
    document.images.slideshow.style.filter="blendTrans(duration="+fadeDuration+")";
    document.images.slideshow.filters[0].Apply();
  }
  document.images.slideshow.src = preLoad[jss].src;
  if (document.all) document.images.slideshow.filters[0].Play();
}