﻿//How many seconds between transitions?
var timeBetweenTransitions = 5;

var arrImage = new Array();
arrImage[0] = '/slideshow/ppidisplay_0000.jpg';
arrImage[1] = '/slideshow/ppidisplay_0001.jpg';
arrImage[2] = '/slideshow/ppidisplay_0002.jpg';
arrImage[3] = '/slideshow/ppidisplay_0003.jpg';
arrImage[4] = '/slideshow/ppidisplay_0004.jpg';
arrImage[5] = '/slideshow/ppidisplay_0005.jpg';
arrImage[6] = '/slideshow/ppidisplay_0006.jpg';
arrImage[7] = '/slideshow/ppidisplay_0007.jpg';

var slideShowDuration = timeBetweenTransitions * 1000;
var l = arrImage.length;
var t;
var s = 0;

fisherYates(arrImage) //Randomize the array

// Preload Images so there is no delay
var preLoad = new Array()
for (i = 0; i < l; i++){
   preLoad[i] = new Image()
   preLoad[i].src = arrImage[i]
}

function runSlides(){
   if (document.all){
      document.images.SlideShow.style.filter="blendTrans(duration=2)"
      document.images.SlideShow.filters.blendTrans.Apply()      
   }
   document.images.SlideShow.src = preLoad[s].src
   if (document.all){
      document.images.SlideShow.filters.blendTrans.Play()
   }
   s = s + 1
   if (s > (l-1)) s=0
   t = setTimeout('runSlides()', slideShowDuration)
}

function fisherYates ( myArray ) {
  var i = myArray.length - 1;
  if ( i == 0 ) return false;
  while ( --i ) {
     var j = Math.floor( Math.random() * ( i + 1 ) ) + 1;
     var tempi = myArray[i];
     var tempj = myArray[j];
     myArray[i] = tempj;
     myArray[j] = tempi;
   }
}