// JavaScript Document
<!--mini slide show -->


//I wanted to attach it to the playlist.js file, but I couldn't quite figure out how to connect the slideshow with the user-controlled playlist


var theimage = 'photos/2007_2007/fall_general/1_s.jpg'

var folderIndex = new Array
folderIndex[0] = 'photos/2006_2007/fall_general/'
folderIndex[1] = 'photos/2006_2007/spring_general/'
folderIndex[2] = 'photos/2006_2007/bbq 4.15.07/'
folderIndex[3] = 'photos/2007_2008/fall_general/'


var pFN = new Array //Photo Folder Names
pFN[0] = '2006-07: Fall - General'
pFN[1] = '2006-07: Spring - General'
pFN[2] = '2006-07: Spring - BBQ (4/15)'
pFN[3] = '2007-08: Fall - General'

/*
var pFN_src = new Array
pFN_src[0] = 'photos/2006_2007/fall_general/'
pFN_src[1] = 'photos/2006_2007/spring_general/'
pFN_src[2] = 'photos/2006_2007/bbq 4.15.07/'
pFN_src[3] = 'photos/2007_2008/fall_general/'

//the number of photos in each array
var pFN_totalImg = newArray
pFN_totalImg[0] = 8
pFN_totalImg[1] = 1
pFN_totalImg[2] = 8
pFN_totalImg[3] = 5

//this is a dynamic array; the amount of entries will vary per FN folder
var NewImg = new Array
NewImg[0] = '1_s.jpg'

function playSelection(selection)
{
thefolder = selection

for (i=0; i<pFN.length; i=i+1)
	{   if(pFN[i] == thfolder)
		{
		whichTitle = pFN[i]
		whichSrc = pFN_src[i]
		whichTotal = pFN_totalImg[i] 
		}
	}
for (x=0; x<whichtotal; x=x+1)
	{
		var NewImg[x] = whichSrc + x + '_s.jpg'
	}

}

*/


NewImg = new Array
NewImg[0] = 'photos/2006_2007/fall_general/1_s.jpg'
NewImg[1] = 'photos/2006_2007/fall_general/2_s.jpg'
NewImg[2] = 'photos/2006_2007/fall_general/3_s.jpg'
NewImg[3] = 'photos/2006_2007/fall_general/4_s.jpg'
NewImg[4] = 'photos/2006_2007/fall_general/5_s.jpg'
NewImg[5] = 'photos/2006_2007/fall_general/6_s.jpg'
NewImg[6] = 'photos/2006_2007/fall_general/7_s.jpg'
NewImg[7] = 'photos/2006_2007/fall_general/8_s.jpg'

NewTitle = new Array
NewTitle[0] = 'Team Photo'
NewTitle[1] = 'SC Logo'
NewTitle[2] = 'White Team'
NewTitle[3] = 'Goalie Henrique'
NewTitle[4] = 'Orange Team'
NewTitle[5] = 'Billy running fast'
NewTitle[6] = 'Black Team'
NewTitle[7] = 'Coach Lui'


var ImgNum = 0; //start with this image in the slideshow
var ImgLength = NewImg.length - 1; //how many images are there?
var ImgTitle = 'Team Photo'


var delay = 3000; //time delay between slides (in milliseconds)

var shouldplay = false; //determines what the initial setting will be
var intervalId;
var loop = false; //determines whether the show will loop or not.

//change the direction of the slideshow in a +1 or -1 direction;
function change(direction) 
{
	slideshow = document.getElementById('slideshowImage')
	src = slideshow.src
	title = ''
	rwd = document.getElementById('buttonRwd');
		rwd.src = 'images/icon-back.gif' //set the images to always be 'on' unless there is a loop
	fwd = document.getElementById('buttonFwd');
		fwd.src = 'images/icon-fwd.gif'
	playB = document.getElementById('buttonPlay');
	
//play the show as a loop?
	if (document.getElementById('loop').checked == true)
		{loop = true}
	else
		{loop = false}
	
	//alert('you are moving: ' + direction + '\n ImgNum was: ' + ImgNum)
	
//if you're going forward
	if(direction>0)
		{if (ImgNum>=ImgLength)
			{
				if (loop==true)
					{
					ImgNum = 0
					}
				else
					{
					ImgNum = ImgLength
					//stop the show
					fwd.src = 'images/icon-fwd2.gif'
					playB.src = 'images/icon-play.gif'
					clearInterval(intervalId);
					}
			}
		else 
			{
				ImgNum = ImgNum + direction;
			}
		}
		
//else you're going backward	
	else
		{
		if (ImgNum<=0)
			{
				if (loop==true)
					{
					ImgNum = ImgLength
					}
				else
					{
			 		ImgNum = 0
					//stop the show
					rwd.src = 'images/icon-back2.gif'
					playB.src = 'images/icon-play.gif'
					clearInterval(intervalId);
					}
			}
		else 
			{
				ImgNum = ImgNum + direction;
			} 
		}

//isolate the two cases that could appear without hitting the buttons
	if (loop==false && ImgNum == 0)
	{rwd.src = 'images/icon-back2.gif'}
	if (loop==false && ImgNum == ImgLength)
	{fwd.src = 'images/icon-fwd2.gif'}


//these are the new data
	src = NewImg[ImgNum];
	ImgTitle = NewTitle[ImgNum];
	
//this was how I was thinking I was going to incorporate the playlist
		whichFolder = 0 
		whichTitle = pFN[whichFolder]
		whichTitle = 'Photos 2006-07: Fall - General'
		

document.getElementById('slideshow_title').innerHTML = '<span class="playlistTitle-red">' + whichTitle + '</span><br /><span class="playlistSubTitle">' + ImgTitle +'</span>'

document.getElementById('slideshowImage').src = src


//and to summarize...
if (ImgNum ==0)
{outof = ''}
else if(ImgNum ==1)
{outof = 'st'}
else if (ImgNum ==2)
{outof = 'nd'}
else if(ImgNum ==3 || ImgNum==4)
{outof = 'rd'}
else
{outof = 'th'}
outof = ImgNum + outof

document.getElementById('slideshow_outof').innerHTML = '<span class="languages">(' + outof + ' out of ' + NewImg.length + ' photos)'
	
}


function play() 
{
	playB = document.getElementById('buttonPlay')
	if (shouldplay == true) 
	{
	//alert('T...shouldpay was = ' + shouldplay)
		clearInterval(intervalId); 
		playB.src = 'images/icon-play.gif'
		shouldplay = false;
	}
	else if (shouldplay == false)
	{
		intervalId = setInterval('change(1)', delay);
		playB.src = 'images/icon-pause.gif'
		shouldplay = true;
   	}
}

//didn't have time to write this one...
function fullScreen(layer)
{
	show = document.getElementById(layer)

}