window.onload = initAll;

var currImg = 0;

var captionText = new Array(
	"A 1958 leaflet promoting travel by the new diesel trains.",
	"Two 3-car sets at Garngaber Junction (Lenzie) bound for Edinburgh, April 1966. Photo J.Burnie",
	"A 1964 press advert for the regular interval service on the Edinburgh-Glasgow line.",
	"An Inter-City set at Corkerhill. Photo J.L.Stevenson",
	"An Inter-City set at Largs. Photo J.Horne",
	"In the early days of dieselisation, a set leaves Edinburgh Waverley, Glasgow bound. Photo M.Mensing",
	"Wish you were here! Valentine's postcard c.1960 &ldquo;Inter City Diesel Car train leaving Edinburgh Waverley Station for Glasgow&nbsp;Queen&nbsp;Street&rdquo;"
)

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("slideshow").src = "images/10085-88/10085-88_" + currImg + ".jpg";
	document.getElementById("imgtext").innerHTML = captionText[currImg];
}
