// Copyright 2000 SiteExperts.com, InsideDHTML.com, LLC. All rights reserved.
// You can reuse this script as long as the copyright notice is maintained.

// USER-DEFINED SETTINGS

// The list of images to display
var aImages = new Array("Image1.JPG","Image2.JPG","Image3.JPG","Image4.JPG","Image5.JPG")

// The width and height of the images. 
// All images should be the same size.
var aSize = new Array(425,275)

// The number of milliseconds to wait before switching images
var iDisplay = 5000


// SCRIPT
var oTimer = null 
var iCurrent = 0
var sSource = ""

function doDisplay() {
  // Try and display the image
  clearTimeout(oTimer)
  // The sSource is only set when the image is already available
  if (sSource!="") {
    // Use IE Transition
    if (document.images.slideShow.filters) { 
      document.images.slideShow.filters[0].Stop()
      document.images.slideShow.filters[0].Apply()
      // Use a random transition effect
      document.images.slideShow.filters.revealTrans.transition=23
    }
    document.images.slideShow.src = sSource
    // Run the transition in IE
    if (document.images.slideShow.filters)
      document.images.slideShow.filters[0].Play()
  }
}

function doReadyImage() {
  // Image is ready for display
  sSource = this.src
  // If time period expired just display
  if (oTimer==null) doDisplay()
}

function doErrorDisplay() {
  // If error, get next image
  // NOTE - Script not well written if all images fail
  clearTimeout(oTimer)
  doLoad()
}

function doLoad() {
  // Start getting the next image
  clearTimeout(oTimer)
  var img = new Image()
  img.onload = doReadyImage
  img.onerror = doErrorDisplay 
  sSource = ""
  iCurrent++
  if (iCurrent==aImages.length) iCurrent=0
  oTimer = setTimeout("oTimer=null;doDisplay()",iDisplay)
  img.src = aImages[iCurrent]
}

function quickNextLoad() {
  // Get next image ASAP
  clearTimeout(oTimer)
  oTimer=null
  var img = new Image()
  img.onload = doReadyImage
  img.onerror = doErrorDisplay 	
  img.src = aImages[iCurrent]
}

function quickPrevLoad() {
  // Get previous image ASAP
  clearTimeout(oTimer)
  oTimer=null
  var img = new Image()
  img.onload = doReadyImage
  img.onerror = doErrorDisplay 
  iCurrent-=1
  if (iCurrent<0) iCurrent=aImages.length-1
  iCurrent-=1
  if (iCurrent<0) iCurrent=aImages.length-1
  img.src = aImages[iCurrent]
}

// Output the Image tab and next and previous buttons
document.write("<IMG NAME=slideShow SRC=\"" + aImages[iCurrent] + "\" ONERROR=\"doLoad()\" ONLOAD=\"doLoad()\" WIDTH=\"" + aSize[0] + "\" HEIGHT=\"" + aSize[1] + "\" STYLE=\"filter: revealTrans(TRANSITION=23)\">")