window.onload = initAll;

var currImg = 0;

var captionText = new Array(
	"Power Car Sc51017 in traffic at Carlisle. Photo A.McConnell",
	"The gutted interior of Sc51017 following the removal of asbestos insulation. All the SRPS Inter-City cars have passed through this stage of dismantling.",
	"Sc51017 (with Percy the very green engine) at Bo'ness awaiting its turn to go to Midland Railway Enterprises for repair.",
	"Sc51017 on arrival in 2006 at Midland Railway Enterprises, Butterley, for thorough overhaul. Photo S.Mackay",
	"Removing footstep attachment bolts from a bogie of Sc51017. Photo MRE, Butterley",
	"Steam cleaning a gearbox. Photo MRE, Butterley",
	"Painstaking reconstruction of the car interior. Photo MRE, Butterley",
	"Sc51017 lifted on jacks for access to the underframe and bogies. Photo MRE, Butterley",
	"Sc51017 saloon re-instated wall framing. Photo MRE, Butterley",
	"Loading for return to Bo'ness, August 2007. Photo MRE, Butterley",
	"In the Modern Motive Power depot, Bo'ness, for engine fitting, 30 October 2007",
	"At Bo'ness inner home signal, on test run 11th December 2007"
	)

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

