// JavaScript Document
//photo gallery for Theme Time with Bob Dylan


//set this varible to true if you wnat to shuffle the images. Set it false if you don't
var randominze_images = false;

	
	var photos = new Array();
	var styles = new Array();
	var captions = new Array();
	var current = 0;
	var defaultStyle = "defaultStyle";
	
	var count = 0;
	
	
	
	
	
	
photos[count] = "/images/onXM/series/dylan/photo_gallery/youngold.jpg";
styles[count] = "";
captions[count++] = '<span class="theme">THEME:</span> ' + "Youth &amp; Age";

photos[count] = "/images/onXM/series/dylan/photo_gallery/daysofweek.jpg";
styles[count] = "";
captions[count++] = '<span class="theme">THEME:</span> ' + "Days of the Week ";

photos[count] = "/images/onXM/series/dylan/photo_gallery/shoes.jpg";
styles[count] = "";
captions[count++] = '<span class="theme">THEME:</span> ' + "Shoes";

photos[count] = "/images/onXM/series/dylan/photo_gallery/weather.jpg";
styles[count] = "";
captions[count++] = '<span class="theme">THEME:</span> ' + "Weather";

photos[count] = "/images/onXM/series/dylan/photo_gallery/baseball.jpg";
styles[count] = "";
captions[count++] = '<span class="theme">THEME:</span> ' + "Baseball";

photos[count] = "/images/onXM/series/dylan/photo_gallery/coffee.jpg";
styles[count] = "";
captions[count++] = '<span class="theme">THEME:</span> ' + "Coffee";

photos[count] = "/images/onXM/series/dylan/photo_gallery/cars.jpg";
styles[count] = "";
captions[count++] = '<span class="theme">THEME:</span> ' + "Cars";


photos[count] = "/images/onXM/series/dylan/photo_gallery/radio.jpg";
styles[count] = "";
captions[count++] = '<span class="theme">THEME:</span> ' + "Radio";

photos[count] = "/images/onXM/series/dylan/photo_gallery/jail.jpg";
styles[count] = "";
captions[count++] = '<span class="theme">THEME:</span> ' + "Jail";

photos[count] = "/images/onXM/series/dylan/photo_gallery/newyork.jpg";
styles[count] = "";
captions[count++] = '<span class="theme">THEME:</span> ' + "New York";

photos[count] = "/images/onXM/series/dylan/photo_gallery/train.jpg";
styles[count] = "";
captions[count++] = '<span class="theme">THEME:</span> ' + "Trains ";

photos[count] = "/images/onXM/series/dylan/photo_gallery/hands.jpg";
styles[count] = "";
captions[count++] = '<span class="theme">THEME:</span> ' + "Hello";



var key_arr= new Array();


for (var i=0; i<photos.length ; i++){
	key_arr[i] = i;
}


	
//shuffle an array	
shuffle = function(o){ 
	for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
	return o;
}


//shuffle images?
if (randominze_images){
	//Shuffle up teh top array so that phtos are in random order
	shuffle(key_arr);
}



function next(){
	current++;
	current  = current % (photos.length); //if past end, set to zero
	
	var photo = document.getElementById("photo");
	var caption = document.getElementById("caption");
	
	photo.src =	photos[key_arr[current]];
	
	if (styles[current] != "" ){
		photo.className = styles[key_arr[current]];
	} else {
		photo.className	= defaultStyle;
	}
	
	caption.innerHTML = captions[key_arr[current]];
	
	
}






function prev(){
	current--;
	current  = current % (photos.length);
	if (current < 0) { current = photos.length - 1; } //if negative set to end
	
	
	var photo = document.getElementById("photo");
	var caption = document.getElementById("caption");
	
	
	photo.src =	photos[key_arr[current]];
	
	if (styles[current] != ""){
		photo.className = styles[key_arr[current]];
	} else {
		photo.className	= defaultStyle;
	}
	
	
	caption.innerHTML = captions[key_arr[current]];
	
}
