window.onload = initAll;

var currImg = 0;
var captionText = new Array(
	"The year is 1985, seventeen year old Marty McFly helps out his scientist friend, Doc one night and accidently gets to go back in time to 1955. His appearence in 1955 affects the timeline but with help from the 1955 Doc they manage to put things right avoiding future chaos!",
	"Marty is back in 1985 and is promptly taken back to the future by Doc to sort out Marty's wayward children. After helping Marty's children they return to a different 1985 but somehow the past changed while they were still in the future. Doc and Marty have to go back to 1955 to put things right.",
	"The Delorean is struck by lightning with Doc inside and sent into the past to 1885. Marty is stranded in 1955 and enlists the help of the 1955 Doc again! Marty has to go back to 1885 to save 1985 Doc's life. On arrival in 1885 Marty finds Doc who has to figure out how to get the Delorean to 88 miles an hour!"
	
	)

function initAll() {
	document.getElementById("imgText").innerHTML = captionText[0];
	document.getElementById("prevLink").onclick = processPrevious;
	document.getElementById("nextLink").onclick = processNext;
}

function processPrevious() {
	newSlide(-1);
}

function processNext() {
	newSlide(1);
}

function newSlide(direction) {
	var imgCt = captionText.length;

	currImg = currImg + direction;
	if (currImg < 0) {
		currImg = imgCt-1;
	}
	if (currImg == imgCt) {
		currImg = 0;
	}
	
	document.getElementById("slideshow1").src = "bttf/slideImg" + currImg + ".gif";
	document.getElementById("imgText").innerHTML = captionText[currImg];
}

