// JavaScript for slideshow of Hope Mansell Church images
//

var pageHeading = "Hope Mansell Church";
var imageWidth = 720;
var imageHeight = 480;

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-church-1.jpg";
(new Image()).src="images/hm-church-2.jpg";
(new Image()).src="images/hm-church-3.jpg";
(new Image()).src="images/hm-church-4.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":"Church in Winter",
      "path":"images/hm-church-1.jpg"},
				
    { "name":"Detail of Churchyard",
      "path":"images/hm-church-2.jpg"},
					
    { "name":"Church Interior",
      "path":"images/hm-church-3.jpg"},
				
    { "name":"Interior Detail",
      "path":"images/hm-church-4.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);
}
