// JavaScript Document

var NewImg=[1,2,3,4,5,6];

var ImgNum = 0;
var ImgLength = NewImg.length - 1;

var delay = 2000;		//Time delay between Slides in milliseconds

var run;				

//Function to change image Previous or Next
function changeImage(direction) 		//Direction either -1 or 1 depending on left or right respectively
{
	ImgNum = ImgNum + direction;	//Change the ImgNum -1 or +1 respectively to which button was pressed
	
	//Check to see if ImgNum is more than the length of the array - 1 (hense it is at the last one)
	if (ImgNum > ImgLength) 		
	{
		ImgNum = 0;			//If its at the last image then go back to the beginning
	}
	
	//Check to see if ImgNum is less than 0, if so its past the 1st slide using the Previous button
	if (ImgNum < 0) 
	{
		ImgNum = ImgLength;		//If its past the 1st image using Previous button then ImgNum = last image in array
	}
	
	//Call function to change the image to first image
	change(ImgNum);
}

//Function to automatically run through the slideshow
function auto() 
{
	run = setInterval("changeImage(1)", delay);		//Start auto change (going forward) with delay 
}

function change(num)
{
	var img = document.images["slideshow"];			//works in firefox too

	var slideName="images/index" + NewImg[num] + ".jpg";	//get filename for each image
	
	ImgNum=num;
	img.src=slideName;					//change image src to be the new image filename
}