//  Image Slideshow Functions
//  Makes use of script.aculo.us for fading effects

			
/* Pause / Play Functionality */
function doPlay(){
	if(typeof(PicTimer)!='undefined'){
		clearTimeout(PicTimer);
		}
	PicTimer = setTimeout("showSlides('')", 500);
	pausedState = 0;
	$('playBtn').src='images/PlayonDK.png';
	$('pauseBtn').src='images/PauseoffDK.png';
	}
function doPause(){
	/* Unpause */
	if(pausedState == 1){
		PicTimer = setTimeout("showSlides('')", 500);
		pausedState = 0;
		$('playBtn').src='images/PlayonDK.png';
		$('pauseBtn').src='images/PauseoffDK.png';		
		}
	/* Pause */
	else{
		clearTimeout(PicTimer);
		pausedState = 1;
		$('playBtn').src='images/PlayoffDK.png';
		$('pauseBtn').src='images/PauseonDK.png';	
		}
	}
											


										
function showSlides(picNum){
	if(typeof(PicTimer)!='undefined'){
		clearTimeout(PicTimer);
		}
	/* They pressed a button to get here */
	if(picNum){
		if(typeof(picNum)=='number'){
			lastPic = currentPic;
			currentPic = imageSequence.indexOf(picNum);
			}
		else{
			if(picNum == 'N'){
				if (currentPic < totPic){
					lastPic = currentPic;
					currentPic++;			
					}
				else {
					lastPic = currentPic;
					currentPic = 0;
					}
				}
			else if(picNum == 'P'){
				if (currentPic > 0){
					lastPic = currentPic;
					currentPic--;			
					}
				else {
					lastPic = currentPic;
					currentPic = totPic;
					}
				}
			}
		}
	/* Not a button request, autoshow the next image */
	else{
		if (currentPic < totPic){
			lastPic = currentPic;
			currentPic++;			
			}
		else {
			lastPic = currentPic;
			currentPic = 0;
			}
		}
	icos = $('photo' + imageSequence[currentPic]);
	previcos = $('photo' + imageSequence[lastPic]);
	
	crnbtn = $('pbtn_' + imageSequence[currentPic]);
	prvbtn = $('pbtn_' + imageSequence[lastPic]);
	
	Effect.Appear(icos);
	Effect.Fade(previcos);
	
	crnbtn.className = 'current';
	prvbtn.className = '';
	if(pausedState != 1){
		PicTimer = setTimeout("showSlides('')", picShowTime);
		}
	}
