// The list of images to display in the slideshow
//creating a array of the image object
var image=new Array(
"images/OilAndGasBanner.jpg",
"images/PetroBanner.jpg",
"images/AirportsBanner.jpg",
"images/ConstructionBanner.jpg",
"images/MedicalBanner.jpg",
"images/PharmaBanner.jpg",
"images/ManufacturingBanner.jpg",
"images/HealthEstatesBanner.jpg",
"images/DefenceBanner.jpg"
)

var smallImage=new Array(
"images/OilAndGasSmallPic.jpg",
"images/PetroSmallPic.jpg",
"images/AirportSmallPic.jpg",
"images/ConstructSmallPic.jpg",
"images/MedicalSmallPic.jpg",
"images/PharmaSmallPic.jpg",
"images/ManuSmallPic.jpg",
"images/Health2SmallPic.jpg",
"images/DefenceSmallPic.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()*9);
	}
	num = newNum;
	return image[num];
}

// Find the next image by random - and ensure it is not the 
// same as the one previously selected.
function nextSmallImage()
{
	var newNum = num;
	while (newNum == num)
	{
		newNum = Math.floor(Math.random()*9);
	}
	num = newNum;
	return smallImage[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 + "')", 8000) 
       	document.images.slideShow.src= pathToRoot + nextImage();  
     }
}