window.onload = initAll;

var currImg = 0;

var captionText = new Array(
	"Power Car Sc51043 at Bo'ness, in 2000, with a new coat of paint. Photo J.Horne",
	"Sc51043 leads the 3-car set out of Brechin before transfer to SRPS. Photo A.McConnell",
	"Sc51043 on jacks at Bo'ness during removal of residual asbestos. Photo SRPS",
	"Sc51043 delivered by road to Midland Railway Enterprises, Butterley, for thorough overhaul.",
	"Corroded panels removed, repairs to the cab structure in progress. MRE, Butterley",
	"Body side plating rectification at main window openings. MRE, Butterley",
	"Sc51043 lifted on jacks for mechanical and electrical repairs. MRE, Butterley",
	"Sc51043 underframe thoroughly descaled and primed. MRE, Butterley",
	"Sc51043 Control air and vacuum brake pipework before dismantling. MRE, Butterley",
	"Sc51043 New control air pipework completed. MRE, Butterley",
	"Sc51043 front saloon showing joiner work well advanced. MRE, Butterley",
	"Sc51043 Specialist contractor inspection of a final drive unit. MRE, Butterley",		
	"A wheelset being refitted to a bogie after tyre turning. MRE, Butterley",
	"Sc51043 back on its wheels, ready for painting. MRE, Butterley",
	"Sc51043 painting complete, ready to return to Bo'ness. MRE, Butterley",
	"Back at Bo'ness, awaiting internal fit out and commissioning. Photp SRPS.",
	"In Bo'ness North Yard, interior restoration still to do. Photo SRPS.",
	"SRPS volunteer staff, at Kinneil on the returning successful test run, 11th December 2007.<br/> Left to right, Ian Boettcher, C&W Dept.; Ian Forsyth, Driver; Iain&nbsp;Gent,&nbsp;Operating&nbsp;Dept.; Kenny&nbsp;Simpson,&nbsp;Diesel&nbsp;Dept.; Lindsay&nbsp;Paterson,&nbsp;Diesel&nbsp;Dept.; John&nbsp;Miller,&nbsp;DMU&nbsp;Project; Stuart&nbsp;Mackay,&nbsp;DMU&nbsp;Project&nbsp;Engineer",
	"Interior of front saloon, as fitted out, February 2008. Photo SRPS."
)

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

