// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 7000;

//the number of images to display
var numberOfPics = 8;

// Duration of crossfade (seconds)
var crossFadeDuration = 3;

// Specify the image files
var Pic = new Array();
// to add more images, just continue
// the pattern, adding to the array below

//fill the Pic array with image source locations (as strings)
for (var imageIndex=0; imageIndex < numberOfPics; imageIndex++){
    Pic[imageIndex] = "images/foto/foto_" + (imageIndex + 1).toString() + ".jpg";
}

//shuffle the array
Pic = shuffle(Pic);

var timeout;
var j = 0;
var preLoad = new Array();
for (var i = 0; i < Pic.length; i++){
    preLoad[i] = new Image();
    preLoad[i].src = Pic[i];

}

function runSlideShow(){
    if (document.all){
        document.images.SlideShow.style.filter="blendTrans(duration=2)";
        document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
        document.images.SlideShow.filters.blendTrans.Apply();
    }
    document.images.SlideShow.src = preLoad[j].src;
    if (document.all){
        document.images.SlideShow.filters.blendTrans.Play();
    }
    j = j + 1;
    if (j > (Pic.length-1)) j=0;
    timeout = setTimeout('runSlideShow()', slideShowSpeed);
}

 function shuffle(r_array){
   r_array.sort(function() {return 0.5 - Math.random();});
   return r_array;
 }
