// Slideshow functions

function init() {
	window.document.stuff.min.value=thisPic;
	window.document.stuff.max.value=lastPic;
}

// change timelapse

function setTimelapse(val) {
	timelapse=val;
	// if (1500 == timelapse) {
		// alert('Speed set to fast')
	// } else if (3000 == timelapse) {
		// alert('Speed set to normal')
	// } else if (6000 == timelapse) {
		// alert('Speed set to slow')
	// } else {
		// alert('Unknown Speed set')
	// }
}

// change loop

function setLoop(val) {
	loop=val;
	// if (1 == loop) {
		// alert('Looping turned on')
	// } else {
		// alert('Looping turned off')
	// }
}


// Under construction

// function init_scroll(ctr) {

	// if (init_scroll.ctr>=listmax) {
		// init_scroll.ctr=0;
	// }
	// nextSeries(list[init_scroll.ctr])
	// timeoutID=setTimeout('init_scroll(init_scroll.ctr+1)',timelapse)
// }


// names = new Array("a","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");


function displayPic(thisPic) {
	var i = thisPic;
	if (usenames == 1) {
		name=names[i-1];
	} else {
		if (thisPic < 10) { i = "0"+i; }
		if ((lastPic > 99) && (thisPic < 100)) { i = "0"+i; }
		name=i;
	}
	document.myPicture.src=rootname+name+typename;
	window.document.stuff.imgname.value=rootname+name+typename;
	window.status=document.myPicture.src
}


function processPrevious() {

	if (document.images) {

		if (thisPic<=1) {
			thisPic=lastPic;
		} else {
			thisPic--;
		}
		displayPic(thisPic);
	}
}


function processNext(auto) {

	if (document.images) {

		if (thisPic>=lastPic) {
			 thisPic=1;
		} else {
			thisPic++;
		}

		if ((thisPic!=lastPic || loop==1) && auto==1) {
			timeoutID=setTimeout('processNext(1)',timelapse)	
		}

		displayPic(thisPic);
	}
}


function nextSeries(index) {
	rootname=serie[index];
	lastPic=max[index];
	document.stuff.max.value=max[index];
	thisPic=max[index];
	processNext(0);
}

// generate HTML to preload images

var preloaded_imgs = new Array();

function preload_pics() {
	var i;
	for (i=thisPic;i<=lastPic;i++) {
		if (usenames == 1) {
			name=names[i-1];
		} else {
			name = i;
			if (i < 10) { name = "0"+name; }
			if ((lastPic > 99) && (i < 100)) { name = "0"+name; }
		}
		preloaded_imgs[i]=new Image();
		preloaded_imgs[i].src=rootname+name+typename;
	}
}

// TIAF
