window.onload = initAll;

var currImg = 0;
var captionText = new Array(
	"A vanishing breed? A recent survey suggests a looming shortage of Canadian geoscientists because of several factors. One appeal that the profession can claim is the opportunity to visit magnificent sites (above) like the late Carboniferous alluvial sequence at Joggins, Nova Scotia, Canada. Joggins is a UNESCO World Heritage site - and a great place for geologists to visit. <em>Photo by Rob Fensome, Geological Survey of Canada</em>",
	"Dalhousie University students analyzing tidal sediments in Minas Basin, Nova Scotia. <em>Photo courtesy of Elisabeth Kosters, CFES</em>",
	"Geologists examining Salten Formation near Canmore, AB.",
	"")

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 = "canada" + (currImg + 1) + ".jpg";
	document.getElementById("imgText").innerHTML = captionText[currImg];
}

