

var currentimg=0;  // currentimage - first image is loaded by html page

// on load, load the first image and set timer to change images
// slidenum specifies the index of the image to load
function slideshow_start(slidenum)
{
   // set current image to specified one
   selectImage(slidenum);

   // set the timer that will keep changing images
   setInterval("selectNextImage()", delay);

   // pre-load the other images
   // for (i=0; i < numImages; i++) {
   //    var pic= new Image(); 
   //    pic.src=imagefiles[i];
   // }

}

// make the specified image the selected one
function selectImage(imgnum)
{
   // if the image is already selected do nothing
   if (imgnum == currentimg)
      return;

   // change the selected image number
   currentimg = imgnum;

   // get element to load the image into
   var imgmain  = document.getElementById("slideshow");
  
   // if broswer is ie, add the cross-fade filter
   if (document.all)
   {
      imgmain.style.filter="blendTrans(duration=0.8)";
      imgmain.filters.blendTrans.Apply();
   }

   // set the new source image
   imgmain.src=imagefiles[imgnum];

   // if browser is IE, run the fade filter
   if (document.all)
   {
      imgmain.filters.blendTrans.Play();
   }

}

// brighten the indicated image id
function brightenImage(id)
{
   id.style.filter="alpha(Opacity=100)";

   id.style.borderBottom="2px";
}

// dim the indicated image id
function dimImage(id)
{
   id.style.filter="alpha(Opacity=40)";
}


// display the next image
// and pre-load the one after that one
function selectNextImage()
{
   // display the next image
   var next = nextImageNum();
   selectImage(next);

   // pre-load the following image
   var next = nextImageNum();
   var pic= new Image(); 
   pic.src=imagefiles[next];
    
}

// return the next image number from the current image 
function nextImageNum()
{
   var next = currentimg+1;
   if (next >= numImages)
     next=0;
   
   return next;
}

