//	Slide Show
//
//	© 2008 Gary Little
//
//	December 27, 2008
//

var kSlideInterval = 5000;
var kPhotoID = "photo";
var kCaptionID = "photocaption";
var kPhotoFolder = "sc-photos/";

var gPics = [];
var gCaptions = [];
		
function showNextPicture( i ) {

	var i;
	var p, c;
	
	p = document.getElementById(kPhotoID);
	p.src = kPhotoFolder + gPics[i];

	c = document.getElementById(kCaptionID);
	c.innerHTML = gCaptions[i];

	i = getNextIndex(i);
	
	setTimeout("showNextPicture(" + i + ")", kSlideInterval);
}

function getNextIndex( i ) {

	var iNew = i;
	
	while ( iNew == i ) {
	
		iNew = Math.floor(Math.random() * gPics.length);
	}
	
	return iNew;
}

function initSlideShow() {

	gPics[ 0] = "smuggler-cove.jpg";
	gPics[ 1] = "homesite-creek-falls.jpg";
	gPics[ 2] = "big-fir-park.jpg";
	gPics[ 3] = "sgtbay-aerial-2003.jpg";
	gPics[ 4] = "hmb-aerial-2003.jpg";
	gPics[ 5] = "chapman-creek-falls.jpg";
	gPics[ 6] = "porpoise-bay.jpg";
	gPics[ 7] = "sechelt-marsh.jpg";
	gPics[ 8] = "sechelt-sign.jpg";
	gPics[ 9] = "trail-islands.jpg";
	gPics[10] = "sechelt-totems.jpg";
	gPics[11] = "coopers-green.jpg";
	gPics[12] = "halfmoon-bay-sign.jpg";
	gPics[13] = "roberts-creek-sign.jpg";
	gPics[14] = "davis-bay.jpg";
	gPics[15] = "pender-harbour.jpg";
	gPics[16] = "secret-cove.jpg";
	gPics[17] = "merry-island.jpg";
	gPics[18] = "pender-from-daniel.jpg";
	gPics[19] = "merry-island-lighthouse.jpg";
	gPics[20] = "gibsons-sign.jpg";
	
	gCaptions[ 0] = "Smuggler Cove";
	gCaptions[ 1] = "Homesite Creek Falls";
	gCaptions[ 2] = "Big Fir Park";
	gCaptions[ 3] = "Sargeant Bay<br>(aerial view)";
	gCaptions[ 4] = "Halfmoon Bay<br>(aerial view)";
	gCaptions[ 5] = "Chapman Creek Falls";
	gCaptions[ 6] = "Porpoise Bay";
	gCaptions[ 7] = "Sechelt Marsh";
	gCaptions[ 8] = "Welcome to Sechelt";
	gCaptions[ 9] = "Trail Islands / Sechelt Beach";
	gCaptions[10] = "Sechelt Totem Poles";
	gCaptions[11] = "Halfmoon Bay<br>(south of Coopers Green)";
	gCaptions[12] = "Welcome to Halfmoon Bay";
	gCaptions[13] = "Welcome to Roberts Creek";
	gCaptions[14] = "Davis Bay";
	gCaptions[15] = "Pender Harbour";
	gCaptions[16] = "Secret Cove";
	gCaptions[17] = "Merry Island";
	gCaptions[18] = "Pender Harbour<br>(from Mt. Daniel)";
	gCaptions[19] = "Merry Island Lighthouse";
	gCaptions[20] = "Welcome to Gibsons";
	
	showNextPicture(getNextIndex(-1));
}
