<!-- Based on code taken from http://www.codelifter.com I think-->

<!-- Begin
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000;
// Duration of crossfade (seconds)
var crossFadeDuration = 3;
// Set the pause flag to false
var sspause = false;
// Set the running flag to false
var ssrunning = false;
// 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 = Pic.length;
var preLoad = new Array();

if (slideshow_compatible) {
	for (i = 0; i < p; i++) {
		preLoad[i] = new Image();
		preLoad[i].src = Pic[i];
	}
}

function initSlideShow() {
	if (slideshow_filtercompatible) {
		document.images.SlideShow.style.filter="blendTrans(duration=2)";
		document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
		document.images.SlideShow.filters.blendTrans.Apply();
	}
}

function runSlideShow() {
	if (!sspause) {
		ssrunning = true;
		initSlideShow();
		document.getElementById('waitanim').innerHTML = '<img src="../images/wait.gif">';
		document.getElementById('animbutton').innerHTML = '<a href="javascript:pauseSlideShow()" title="Pause Slide Show"><img src="../images/pause.gif"></a>';
		document.images.SlideShow.src = preLoad[j].src;
		//Set the caption text
		document.getElementById('slideshowcaption').innerHTML = Cap[j];
		if (slideshow_filtercompatible) {
			document.images.SlideShow.filters.blendTrans.Play();
		}
		j = j + 1;
		if (j > (p - 1)) j = 0;
		t = setTimeout('runSlideShow()', slideShowSpeed);
	}
	else {
		sspause = false;
	}
}

function nextSlide() {
	initSlideShow();
	if (ssrunning){
		document.getElementById('waitanim').innerHTML = '<img src="../images/wait.gif">';
		t = clearInterval(t);
		t = setTimeout('runSlideShow()', slideShowSpeed);		
	}
	else if (sspause){
		document.getElementById('waitanim').innerHTML = '<img src="../images/pauseanim.gif">';
	}
	document.images.SlideShow.src = preLoad[j].src;
	//Set the caption text
	document.getElementById('slideshowcaption').innerHTML = Cap[j];
	if (slideshow_filtercompatible) {
		document.images.SlideShow.filters.blendTrans.Play();
	}
	j = j + 1;
	if (j > (p - 1)) j = 0;
}

function prevSlide() {
	//Still a bit wonky
	j = j - 1;
	if (j < 0) j = p-1;
	
	initSlideShow();
	document.images.SlideShow.src = preLoad[j].src;
	if (ssrunning){
		document.getElementById('waitanim').innerHTML = '<img src="../images/wait.gif">';
		t = clearInterval(t);
		t = setTimeout('runSlideShow()', slideShowSpeed);	
	}
	else if (sspause){
		document.getElementById('waitanim').innerHTML = '<img src="../images/pauseanim.gif">';
	}
	
	//Set the caption text
	document.getElementById('slideshowcaption').innerHTML = Cap[j];
	if (slideshow_filtercompatible) {
		document.images.SlideShow.filters.blendTrans.Play();
	}
}


function pauseSlideShow() {
	sspause = true;
	ssrunning = false;
	document.getElementById('waitanim').innerHTML = '<img src="../images/pauseanim.gif">';
	document.getElementById('animbutton').innerHTML = '<a href="javascript:runSlideShow()" title="Resume Slide Show"><img src="../images/play.gif"></a>';
}
//  End -->

