var fP = "/images/hpss";

var captions = [];
captions[0] = "Campfire, Mashatu Game Reserve";
captions[1] = "Cheetah at Il moran Camp, Kenya";
captions[2] = "Dolphins at Plettenberg Bay, South Africa";
captions[3] = "Meno a Kwena Makgadikgadi Saltpans, Botswana";
captions[4] = "Jack's camp, Makgadikgadi Saltpans, Botswana";
captions[5] = "Kids at Hluhluwe River Lodge, KwaZulu Natal";
captions[6] = "Flying over Sossusvlei, Namibia (Michael Poliza)";
captions[7] = "Lion in South Luangwa, Zambia, (Robin Pope Safaris)";
captions[8] = "Spring Wild Flowers, Namaqualand, South Africa";
captions[9] = "Sunset drinks in Luangwa river";
captions[10] = "Meerkat family, Northern Cape, South Africa";
captions[11] = "Table Mountain, Cape Town";
captions[12] = "Victoria Falls";

var images = [];
images[0] = "/01.jpg";
images[1] = "/02.jpg";
images[2] = "/03.jpg";
images[3] = "/04.jpg";
images[4] = "/05.jpg";
images[5] = "/06.jpg";
images[6] = "/07.jpg";
images[7] = "/08.jpg";
images[8] = "/09.jpg";
images[9] = "/10.jpg";
images[10] = "/11.jpg";
images[11] = "/12.jpg";
images[12] = "/13.jpg";

//Above hardcoded for now, surely this can be AJAXed in at some point...

function doRotate()
{
	var interval = setInterval("chngImg()",'5000');
}

function chngImg()
{
	var currentImgAndServer = document.getElementById("destinationrotate").src;
	var currentImg = currentImgAndServer.substring(currentImgAndServer.lastIndexOf("/"));

	var currentIndex = -1;
	for(i = 0; i<images.length; i++)
	{
		if(images[i] == currentImg) currentIndex = i;
	}
	if(currentIndex != -1)
	{
		if(currentIndex == (images.length - 1)) currentIndex = 0;
		else currentIndex = currentIndex + 1;

		document.getElementById("destinationrotate").src = fP + images[currentIndex];
		document.getElementById("destinationrotate").alt = captions[currentIndex];
		document.getElementById("destinationrotate").title = captions[currentIndex];
		document.getElementById("destinationrotatecaption").innerHTML = captions[currentIndex];
	}
}