//array of images that can be displayed
var homeImages = new Array ( );

homeImages[0] = "/images/home/WinterHomePageImage0825.jpg";
homeImages[1] = "/images/home/PhoenixHomePageImage0825.jpg";

//homeImages[0] = "/images/home/FallFreeForAll.jpg";
//homeImages[0] = "/images/home/WinterHomePageImage0729.jpg";
//homeImages[1] = "/images/home/PhoenixHomePageImage0728.jpg";

//homeImages[0] = "/images/home/FareSaleHomePageImage0810.jpg";
//homeImages[0] = "/images/home/AlaskaHomePageImage0106.jpg";
//homeImages[2] = "/images/home/WineHomePageImage0106.jpg";

//homeImages[0] = "/images/home/London622.jpg";
//homeImages[0] = "/images/home/FareSaleHomePageImage0519.jpg";
//homeImages[1] = "/images/home/QueensGuards.jpg";

//homeImages[0] = "/images/home/FareSaleHomePageImage0510.jpg";
//homeImages[1] = "/images/home/QueensGuards.jpg";

//homeImages[0] = "/images/home/FareSaleHomePageImage0503.jpg";
//homeImages[1] = "/images/home/QueensGuards.jpg";

//homeImages[0] = "/images/home/EastCoastHomePageImage0331.jpg";
//homeImages[1] = "/images/home/QueensGuards.jpg";
//homeImages[0] = "/images/home/EastCoastFareSaleImage0427.jpg";
//homeImages[1] = "/images/home/QueensGuards.jpg";

//homeImages[0] = "/images/home/EastCoastHomePageImage0331.jpg";
//homeImages[1] = "/images/home/QueensGuards.jpg";

//homeImages[0] = "/images/home/BOGOHomePageImage0416.jpg";
//homeImages[2] = "/images/home/AlaskaHomePageImage0329.jpg";
//homeImages[3] = "/images/home/EastCoastFareSaleImage0409.jpg";

//homeImages[2] = "/images/home/EastCoastHomePageImage0331.jpg";
//homeImages[0] = "/images/home/FareSaleHomePageImage0331.jpg";
//homeImages[0] = "/images/home/FareSaleHomePageImage0317.jpg";
//homeImages[1] = "/images/home/QueensGuards.jpg";
//homeImages[0] = "/images/home/WingItHomePageImage0316.jpg";
//homeImages[1] = "/images/home/QueensGuards.jpg";
//homeImages[0] = "/images/home/VacationHomePageImage0301.jpg";
//homeImages[1] = "/images/home/HomePageImage0303.jpg";
//homeImages[0] = "/images/home/WingItHomePageImage0223.jpg";
//homeImages[1] = "/images/home/CruiseHomePageImage0218.jpg";
//homeImages[0] = "/images/home/VacationSale21210.jpg";
//homeImages[0] = "/images/home/HomepageImageOmni.jpg";
//homeImages[1] = "/images/home/HomepageImagePuertoVallarta.jpg";
//homeImages[0] = "/images/home/VikingsHomePageImage0118.jpg";
//homeImages[1] = "/images/home/WingItHomePageImage0119.jpg";
//homeImages[0] = "/images/home/awardsHomepage.jpg";
//homeImages[1] = "/images/home/homepage_image0807.jpg";

//declare var to hold what image the user is seeing
var currentImage = 0;

//function to return a random number within the array constraints
function rand (n)
{
  return (Math.floor(Math.random() * n + 1 ));
}

// Pick a random image from the list,
// and set the image source the background td 
function pickImage()
{
	//set the image source to the random image
	document.getElementById("randomImage").style.background = "url(" + homeImages[rand(homeImages.length) - 1] + ")";
	//increment the current image so it is right if they click the next button
	currentImage = currentImage + 1;
	setTimeout("pickImage()",5000);
}

//function to display next image if they click on the next button
function nextImage()
{
	//check to see if we are at the upper bound of the images array
	if (currentImage < homeImages.length)
	{
		//change the image source to the current image
		document.getElementById("randomImage").style.background = "url(" + homeImages[currentImage] + ")";
	}
	else
	{
		//show the first element in the image array
		document.getElementById("randomImage").style.background = "url(" + homeImages[0] + ")";
		//set the current image back to the first
		currentImage = 0;
	}
		//increment to the next image in the array
		currentImage = currentImage + 1;
}

//call the pickImage function after the page loads to show a random image on the home page
pickImage();