////////////////////////////////////////////////////
//name: _scripts/client/slideshow.js
//
//purpose: Client functions for displaying slideshow
//author: Tim Needham 26/07/2000
//
//modified: Jason Wheeler 08/06/2001 
//			Commented out opacity change
////////////////////////////////////////////////////

////////////////////////////////////////////////////
//Function to swap arrow buttons
////////////////////////////////////////////////////
function SwapImage(id, resource) {
	img = eval('document.'+id);
	img.src = resource;
}

//global variables

var count = 1;
var path = "";
var uniquefade = 0;	
var imagecount = 5;

////////////////////////////////////////////////////
//setPath()
//Takes a string as argument and sets the common
//path to the images in the slideshow.
////////////////////////////////////////////////////

function setPath(pt) {

	path = pt;
}

////////////////////////////////////////////////////
//setCount()
//Takes a string as argument and sets the number
//of images in the slideshow. the default is 5
////////////////////////////////////////////////////

function setCount(ct) {

	imagecount = ct;
}

////////////////////////////////////////////////////
//nextImg()
//Takes an image name and an HTMLelement target.
//This function will load the the next image in
//the chain with name starting with "name" into
//the HTMLelement target.
////////////////////////////////////////////////////

function nextImg(name, target) {
		
	if (count < imagecount) {
		count++;
	} else {
		count = 1;
	}

	slideImg(name, count, target);

	//Add this line to switch layer that holds caption
	flip_layer(br, 'text', count, numlay);
	
}

////////////////////////////////////////////////////
//lastImg()
//Takes an image name and an HTMLelement target.
//This function will load the the previous image in
//the chain with name starting with "name" into
//the HTMLelement target.
////////////////////////////////////////////////////

function lastImg(name, target) {

	if (count > 1) {
		count--;
	} else {
		count = imagecount;
	}

	slideImg(name, count, target);
	
	//Add this line to switch layer that holds caption
	flip_layer(br, 'text', count, numlay);
}


////////////////////////////////////////////////////
//nextImgAlt()
//Takes an image name and an HTMLelement target.
//This function will load the the next image in
//the chain with name starting with "name" into
//the HTMLelement target.
////////////////////////////////////////////////////

function nextImgAlt(name, target) {
		
	if (count < imagecount) {
		count++;
	} else {
		count = 1;
	}

	slideImg(name, count, target);
		
	document.getElementById('currentId').innerHTML = ''+count;
	
}

////////////////////////////////////////////////////
//lastImgAlt()
//Takes an image name and an HTMLelement target.
//This function will load the the previous image in
//the chain with name starting with "name" into
//the HTMLelement target.
////////////////////////////////////////////////////

function lastImgAlt(name, target) {

	if (count > 1) {
		count--;
	} else {
		count = imagecount;
	}

	slideImg(name, count, target);
	
	document.getElementById('currentId').innerHTML = ''+count;	

}



////////////////////////////////////////////////////
//slideImg()
//Takes an image name, an index into an image 
//sequence and an HTMLelement target.
//This function will load the the indexed image in
//the chain with name starting with "name" into
//the HTMLelement target.
////////////////////////////////////////////////////

function slideImg(name, number, target) {
	
	var img = eval("document."+target);
	var filter = "";
	
	count = number;
	
	img.src = path + name + number + ".jpg";

}

////////////////////////////////////////////////////
//nextImgN()
//This is for slideshows without captions
////////////////////////////////////////////////////
function nextImgN(name, target) {
		
	if (count < imagecount) {
		count++;
	} else {
		count = 1;
	}

	slideImg(name, count, target);
}

////////////////////////////////////////////////////
//lastImgN()
//This is for slideshows without captions
////////////////////////////////////////////////////
function lastImgN(name, target) {

	if (count > 1) {
		count--;
	} else {
		count = imagecount;
	}

	slideImg(name, count, target);
}

////////////////////////////////////////////////////
//moveCounter()
//Some slideshows have a set of counter layers
////////////////////////////////////////////////////
function moveCounter() {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		for (var i=0; i<imagecount; i++) {
			eval('document.all.counter'+(i+1)).style.visibility = 'hidden'
		}
		eval('document.all.counter'+count).style.visibility = 'visible'
	} else {
	}
	
}

////////////////////////////////////////////////////
//changeOpacity()
//Takes an image name, an opacity level, an opacity
//increment, an opacity limit and an image 
//identifier.
//This function will schedule itself to run 
//repreatedly until the opacity limit has been 
//reached OR the identifier has been superceded - ie
//another fade has started. This avoids multiple 
//fades and that horrible flickering effect.
////////////////////////////////////////////////////

//function changeOpacity(name, opac, incr, lim, uf_id) {

//	if (uf_id == uniquefade) {

//		var img = eval("document." + name);

//		if (navigator.appName.indexOf("Microsoft") != -1) {
//			img.style.filter = 'Alpha(opacity='+opac+', style=0)';
//		} else if (navigator.appName.indexOf("Netscape") != -1) {
//			img.filter = 'Alpha(opacity='+opac+', style=0)';
//		}

//		opac += incr;
//		if (((incr > 0) && (opac <= lim)) || ((incr < 0) && (opac >= lim))) {
//			setTimeout("changeOpacity('"+name+"',"+opac+", "+incr+", "+lim+", "+uf_id+")", 50);
//		} 
//	}
//}