/*
*  Automatically scrolls images specified in an initial array
*/
function scrollImage()
{
	// the array of images to scroll through
	var imageArray = new Array("../images/homepage/peopleWorshipping.jpg","../images/homepage/ashburnhamWaving.jpg","../images/homepage/stmarksoutside.jpg","../images/homepage/peoplePraying.jpg","../images/homepage/stmarkswide.jpg","../images/homepage/sittingOnGrass.jpg");

	// the image to replace has been given an id of 'imagetag' in the html
	var imageSource = document.getElementById('imagetag');
	var currentPosition = document.getElementById('currentPosition');
	var nextPosition = currentPosition.value
	
	// multiply the next position by 1 to ensure that it's in number format
	nextPosition = nextPosition * 1;
	nextPosition = nextPosition + 1;

	// if the next position is off the end of the array, start back at the beginning
	if(nextPosition>=imageArray.length)
	{
		nextPosition = 0;
	}

	if(nextPosition<0)
	{
		nextPosition = imageArray.length - 1;
	}
	imageSource.src = imageArray[nextPosition];
	currentPosition.value = nextPosition;

	// set the function to run again in 5 seconds
	var t=setTimeout("scrollImage()",5000);
}


