var iss;
var jss = 0;
var kss = 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 = 0;

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

function stopTimer() {
  clearTimer();
  tStart = null;
}

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() {
  jssLast = jss;

//while (jss == jssLast)
//  jss = Math.round(Math.random() * pss);
  jss = jss + 1;

  if (jss >= pss) jss=0;

  kss = kss + 1;
  if (kss > pss) {
    stopTimer();
	document.location.href = "index.php";
  }
  else {
    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();
  }
}