// slideshow.js
// usage:
// In <head>
// 1) <script language="javascript" src="slideshow.js"></script>
// 2) <script language="javascript">
// Pic[0] = "uri-of-pic-1"
// Pic[1] = "uri-of-pic-2"
// .. Pic[n-1] = "uri-of-pic-n"
// 
// 3) Have <body onload="initSlideShow()">
// 4) In body have <img src="uri-of-pic-1" name="SlideShow">


// (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
// MODIFIED BY ADP TO INCLUDE FADES FOR non-blendTrans BROWSERS (FF, Opera, Safari, etc)

// =======================================
// set the following variables
// =======================================

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000

// Duration of crossfade (seconds)
var crossFadeDuration = 3

// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below


// =======================================
// do not edit anything below this line
// =======================================

var t
var j = 0
var p
var t1
var t2
var o = 1
var preLoad = new Array()

function fadeOut() {	// for browsers that don't have blendTrans, let's try altering opacity
	o -= 0.015
	if (o < 0) o = 0
	document.images.SlideShow.style.opacity = o
	if (o > 0) t1 = setTimeout('fadeOut()', 1)
	else
	{
	   document.images.SlideShow.src = preLoad[j].src
		fadeIn()
	}
}

function fadeIn() {
	o += 0.015
	if (o > 1) o = 1
	document.images.SlideShow.style.opacity = o
	if (o < 1) t2 = setTimeout('fadeIn()', 1)
}

function runSlideShow(){	// if blendTrans is about, use that, otherwise initiate fadeOut, load, fadeIn
   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
      document.images.SlideShow.filters.blendTrans.Play()
   }
	else // kludge a fadeout
	fadeOut()

   j = j + 1
   if (j > (p-1)) j=0
   t = setTimeout('runSlideShow()', slideShowSpeed)
}

function initSlideShow(){
	p = Pic.length
	for (i = 0; i < p; i++){
		preLoad[i] = new Image()
		preLoad[i].src = Pic[i]
	}
	t = setTimeout('runSlideShow()', slideShowSpeed)
}