function swapImg( numNewImg ) {
	stopShow();
	eval("document.imgMain.src = imgPhoto" + numNewImg + ".src");

	if (document.getElementById('imgLabel'))
		document.getElementById('imgLabel').innerHTML = numNewImg;
	numCurrentImg = numNewImg;
}

function startShow() {
	if (timer == null)
	    swapTimeout();
}

function stopShow() {
	if (timer != null){
		window.clearTimeout(timer);
		timer = null;				
	}
}
function toggleShow() {
	if (timer == null) {
	    startShow();
	} else {
		stopShow();				
	}
}

function nextImg() {
	numNewImg = numCurrentImg+1;
	if (numNewImg > numPhotos)
		numNewImg = 1
		
	eval("document.imgMain.src = imgPhoto" + numNewImg + ".src");
	if (document.getElementById('imgLabel'))
		document.getElementById('imgLabel').innerHTML = numNewImg;
	numCurrentImg = numNewImg;
}

function prevImg() {
	numNewImg = numCurrentImg-1;
	if (numNewImg < 1)
		numNewImg = numPhotos
	
	eval("document.imgMain.src = imgPhoto" + numNewImg + ".src");
	if (document.getElementById('imgLabel'))
		document.getElementById('imgLabel').innerHTML = numNewImg;
	numCurrentImg = numNewImg;
}

function swapTimeout() {

	if ( numCurrentImg == numPhotos ) { // We've just displayed the last img.
		numCurrentImg = 1;
	} else {
		numCurrentImg++;
	}

	swapImg(numCurrentImg);
	timer = window.setTimeout(swapTimeout, numSeconds);
}


