// JScript source code
// The list of images to display in the slideshow
//creating a array of the image object
var image=new Array(
"images/slideshow/Leaves.jpg",
"images/slideshow/Shrubs.jpg",
"images/slideshow/Trees2.jpg",
"images/slideshow/AutumnLeaves.jpg",
"images/slideshow/BroomBraes.jpg",
"images/slideshow/FunPark.jpg",
"images/slideshow/Viaduct2.jpg",
"images/slideshow/Trees.jpg",
"images/slideshow/dog.jpg",
"images/slideshow/Viaduct.jpg"
)
          
//variable that will increment through the images
var initial = true;

// set the delay between images
var timeDelay;

// number of last image ... used to ensure we don't get
// the same image twice in a row
var num = -1;
 
//preload the images in the cache so that the images load faster
//create new instance of images in memory 
var imagePreload=new Array()
for (i=0;i<image.length;i++)
{
   	imagePreload[i]=new Image()
	// set the src attribute
	imagePreload[i].src=image[i]
}

// Find the next image by random - and ensure it is not the 
// same as the one previously selected.
function nextImage()
{
	var newNum = num;
	while (newNum == num)
	{
		newNum = Math.floor(Math.random()*10);
	}
	num = newNum;
	return image[num];
}



	
//for automatic Slideshow of the Images
function slideshow_automatic(pathToRoot)
{ 
	// Is this the first time? setthe first image some more time.
	if (initial)
	{	
		initial = false;	
		timeDelay=setTimeout("slideshow_automatic('" + pathToRoot + "')", 4000) 
	}
    else
    {
    	if (document.images.slideShow.filters)
    	{
    		document.images.slideShow.filters.item(0).Apply();
     		document.images.slideShow.filters.item(0).Play();
     	}
     	
       	//sets the timer value to 4 seconds,we can create a timing loop by using the setTimeout method
       	timeDelay=setTimeout("slideshow_automatic('" + pathToRoot + "')", 4000) 
       	document.images.slideShow.src= pathToRoot + nextImage();  
     }
}