// JavaScript for slideshow of Hope Mansell Churchyard Cleanup images
//

var pageHeading = "Hope Mansell Churchyard Cleanup";
var imageWidth = 700;
var imageHeight = 380;

var thumbnails_string = ""; // no thumbnails for this slide show

// load images for slideshows. Ensure all images are included here for pre-loading
(new Image()).src="images/HM_Churchyard_Cleanup_001.jpg";
(new Image()).src="images/HM_Churchyard_Cleanup_002.jpg";
(new Image()).src="images/HM_Churchyard_Cleanup_003.jpg";
(new Image()).src="images/HM_Churchyard_Cleanup_004.jpg";


var numberOfImages = 4;  //Ensure this is updated to include the number of elements in the array

// Note: IE and Firefox give different values for the length property of this array (IE is one higher)
// hence the need to use this variable

// The first element of this array (element 0) is loaded on initial entry to the page

var pageImages = [

    { "name":"Home Mansell Churchyard Cleanup",
      "path":"images/HM_Churchyard_Cleanup_001.jpg"},
		{ "name":"Home Mansell Churchyard Cleanup",
      "path":"images/HM_Churchyard_Cleanup_002.jpg"},
		{ "name":"Home Mansell Churchyard Cleanup",
      "path":"images/HM_Churchyard_Cleanup_003.jpg"},
		{ "name":"Home Mansell Churchyard Cleanup",
      "path":"images/HM_Churchyard_Cleanup_004.jpg"},

];

var currentPageImage = 0;

function slideShow(srcId, textId, imageList, slidePosition) {
  var imageId = document.getElementById(srcId);
  imageId.src = imageList[slidePosition]["path"];
  imageId.alt = imageList[slidePosition]["name"];
  imageId.title = imageList[slidePosition]["name"];
  var nameText = document.getElementById(textId);
  nameText.firstChild.nodeValue = imageList[slidePosition]["name"];
}

function nextPageImage() {
  currentPageImage++;
	if (currentPageImage >= numberOfImages) currentPageImage = 0;
  slideShow("pageSlides", "slideshowtext", pageImages, currentPageImage);
}
	
function previousPageImage() {
  currentPageImage--;
 	if (currentPageImage < 0) currentPageImage = numberOfImages - 1;
  slideShow("pageSlides", "slideshowtext", pageImages, currentPageImage);
}	

// This function loads the first image in the array (element 0) on initial entry to the page
function initialSlides() {
  slideShow("pageSlides", "slideshowtext", pageImages, currentPageImage);
}
