//###########################################
function SetSlide(num) {
	//too big
	i=num%theimage.length;
	//too small
	if(i<0)i=theimage.length-1;

	//switch the image
	if(doTransition()) {
		eval('document.images.imgslide.filters.'+transtype+'.Apply()')
	}
	document.images.imgslide.src=theimage[i][0];
	if(doTransition()) {
		eval('document.images.imgslide.filters.'+transtype+'.Play()')
	}
	//if they want name of current slide
	tokens = theimage[i][0].split("/");
	title = decodeURI(tokens[tokens.length-1].split(".JPG")[0]) + "&nbsp;&nbsp;&nbsp;(" + (i+1) + "/" + theimage.length + ")";
	document.getElementById('slidebox').innerHTML="<center>"+title+"</center>";
	setIndexCookie(i);
}

function getIndexCookie() {
	if (document.cookie && document.cookie.indexOf("i=")>=0) {
		tokens = document.cookie.split(";");
		for (i=0; i<tokens.length; i++) {
			if (tokens[i].indexOf("i=")>=0) {
				tk = tokens[i].split("=");
				return tk[1];
			}
		}
	}
	return 0;
}

function setIndexCookie(index) {
	var expires = new Date();
	var infuenfTagen = expires.getTime() + (60 * 24 * 60 * 60 * 1000); // 60 days
	expires.setTime(infuenfTagen);
	document.cookie = "i="+index +"; expires=" + expires.toGMTString();
}

function doTransition() {
	return document.all&&!window.opera&&dotrans==1;
}


//###########################################
function PlaySlide() {
	if (!window.playing) {
		PlayingSlide(i+1);
		if(document.slideshow.play){
			document.slideshow.play.value="   Stop   ";
		}
	}
	else {
		playing=clearTimeout(playing);
		if(document.slideshow.play){
			document.slideshow.play.value="   Play   ";
		}
	}
	// if you have to change the image for the "playing" slide
	if(document.images.imgPlay){
		setTimeout('document.images.imgPlay.src="'+imgStop+'"',1);
		imgStop=document.images.imgPlay.src
	}
}


//###########################################
function PlayingSlide(num) {
	playing=setTimeout('PlayingSlide(i+1);SetSlide(i+1);', playspeed);
}


//###########################################
//desc: picks the transition to apply to the images
function GetTrans() {
	//si=document.slideshow.trans.selectedIndex;

		if((document.slideshow.trans && document.slideshow.trans.selectedIndex == 0) || (!document.slideshow.trans && dotrans==0)){
		dotrans=0;
	}
	else if ((document.slideshow.trans && document.slideshow.trans.selectedIndex == 1) || (!document.slideshow.trans && transtype == 'blendTrans')){
		dotrans=1;
		transtype='blendTrans';
		document.imgslide.style.filter = "blendTrans(duration=1,transition=1)";
	}else{
		dotrans=1;
		transtype='revealtrans';
		if(document.slideshow.trans) transattributes=document.slideshow.trans[document.slideshow.trans.selectedIndex].value;
		document.imgslide.style.filter = "revealTrans(duration=1,transition=" +transattributes+ ")";
	}

}
//###########################################
function preloadSlide() {
	for(k=0;k<theimage.length;k++) {
		theimage[k][0]=new Image().src=theimage[k][0];
	}
}

//###########################################
function showControls() {
	c=document.getElementById('controls');
	c.style.visibility = "visible";

}
//###########################################
function hideControls() {
	c=document.getElementById('controls')
	c.style.visibility = "hidden";
}
