var nCrtPhotoIndex;
var nSlideshowStarted;
var nSlideshowDelay, nStartSlideshowDelay;

nSlideshowDelay = 4000;
nStartSlideshowDelay = 1000;
nCrtPhotoIndex = 1;
nSlideshowStarted = false;

function swapPhoto(nIndex)
{
	var oTdPhotoCounter;
	var nNumImages;
	
	try
	{
		nNumImages = arrPhotoSrc.length;
		
		if(nIndex == -1 )
			nIndex = nCrtPhotoIndex ? (nCrtPhotoIndex + 1 <= nNumImages-1 ? nCrtPhotoIndex + 1: 1) : 2;
		else
			if(nIndex == -2 )
				nIndex = nCrtPhotoIndex ? ( nCrtPhotoIndex - 1 > 0 ? nCrtPhotoIndex - 1 : nNumImages-1 ) : 1;
		
		document.images["photo"].src = strPhotosURI+arrPhotoSrc[nIndex];
				
		nCrtPhotoIndex = nIndex;
		
		oTdPhotoCounter = document.getElementById("spnPhotoCounter");

		if(oTdPhotoCounter)
		{
			nNumImages --;
			oTdPhotoCounter.innerHTML = "Photo: "+nIndex+" sur "+nNumImages;
		}
		document.images["photo"].vspace = Math.ceil((276-arrPhotoHeight[nIndex])/2);
		//document.images["photo"].width = arrPhotoWidth[nIndex];
		//document.images["photo"].height = arrPhotoHeight[nIndex];
	}
	catch(excpt)
	{
	}

}
function startSlideShow()
{
	var oLnk;
	try
	{
		oLnk = document.getElementById("lnkStartSlideShow");
		
		if(nSlideshowStarted)
			nSlideshowStarted = false;
		else
		{
			nSlideshowStarted = true;
			//onTimer();
			setTimeout("onTimer()", nStartSlideshowDelay );
		}
		if(oLnk)
			oLnk.innerHTML = nSlideshowStarted ? "ARRÉTER LE DIAPORAMA" : "DÉMARRER LE DIAPORAMA";
	}
	catch(excpt)
	{
	}
}
function onTimer()
{
	var nNumImages, nIndex;
	if(!nSlideshowStarted)
		return;
	try
	{
		
		nIndex = isNaN(nCrtPhotoIndex) ? 2 : nCrtPhotoIndex + 1;
		nNumImages = arrPhotoSrc.length;
		if(nIndex>=nNumImages)
			nIndex = 1;
		
		swapPhoto(nIndex);
		nCrtPhotoIndex = nIndex;
		
		setTimeout("onTimer()", nSlideshowDelay );
	}
	catch(excpt)
	{
	}
}