
//===========================================================
//Script:   JavaScript Cross-Browser SlideShow Script
//          With Cross-Fade Effect between Images
//          Adjustable Timing and Unlimited Images
//Function: Displays images continuously in a slideshow
//          presentation format, with a fade effect on
//          image transitions.
//Browsers: All common browsers: NS3-6, IE 4-6
//          Fade effect only in IE; others degrade gracefully
//Author:   etLux
//===========================================================

// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this  header
// NS4-6,IE4-6
// Fade effect only in IE; degrades gracefully

// =======================================
// set the following variables
// =======================================

// Debug
var DEBUG = 0;

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000

// Duration of crossfade (seconds)
var crossFadeDuration = 3;


// create different sets of images per picture group
function select_pic(index)
{
   select = index;
   if (DEBUG) alert("in select_pic, select ="+select);

   //general pictures 1  
   if (select == 1)
   {
      if (DEBUG) alert("general pictures 1");
       
      Pic[0] = 'slides/flip0.jpg'
      Pic[1] = 'slides/flip1.jpg'
      Pic[2] = 'slides/flip2.jpg'
      Pic[3] = 'slides/flip3.jpg'
   }

}

// =======================================
// do not edit anything below this line
// =======================================


// global variables
var Pic = new Array(); // picture definition
var preLoad = new Array() ; //preload array
var j = 0; 
var t;
var p;
var PRELOAD = 0;
var select;


// to preload images
function load_pic()
{
   if (DEBUG) alert("in load_pic");

   // set loaded to true
   PRELOAD = 1;

   // number of pictures in slide show
   p = Pic.length

   for (i = 0; i < p; i++)
   {
      preLoad[i] = new Image()
      preLoad[i].src = Pic[i]
   }
}

// run slideshow
function runSlideShow(select)
{
   if (DEBUG) alert("in runslideshow, select ="+select);
   
   //check to see if image object exists
   if (!document.images.SlideShow)
   {
       return;
   }

   //check if pictures have been loaded already
   if (PRELOAD == 0)
   {
      if (DEBUG) alert("preloading pictures");

      //picture selection
      select_pic(select);   
   
      //preload
      load_pic();
   }

   if (DEBUG) alert("Pic[1] = "+Pic[1]);
   if (DEBUG) alert("preLoad[1] = "+preLoad[1]);

   //normal stuff
   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 > (p-1)) j=0
   t = setTimeout('runSlideShow(select)', slideShowSpeed)
}
