// JavaScript Document
var arrFeatures = new Array();
var iFeatureIndx = -1;
var iSlideshow;
var bPlaying = false;

function togglePausePlay() {
	if (bPlaying) { stopSlideshow(); }
	else { startSlideshow(); }
}

function addFeature(s) {
	arrFeatures.push(s);
}

function startSlideshow() {
	stopSlideshow();
	try {
		$("picPlayPause").src = "images/picSlideshow_Pause.gif";
	} catch(e) {
		// do nothing	
	}
	bPlaying = true;
	nextFeature();
	if (arrFeatures.length > 1) { iSlideshow = setInterval(nextFeature,7000); }
}

function stopSlideshow() {
	try {
		$("picPlayPause").src = "images/picSlideshow_Play.gif";
	} catch(e) {
		// do nothing	
	}
	bPlaying = false;
	clearInterval(iSlideshow);
}

function showFeature(iIndx) {
	hideCurrentFeature();
	if (iIndx >= 0 && iIndx < arrFeatures.length) {
		iFeatureIndx = iIndx;
	} else {
		iFeatureIndx = 0;
	}
	try { 
		switchImage('picSlideshow'+(iFeatureIndx+1), 'images/picSlideshow_'+(iFeatureIndx+1)+'_f2.gif');
		$('picSlideshow'+(iFeatureIndx+1)).className = "selected";
	} catch(e) {
		// do nothing	
	}
	Effect.Appear(arrFeatures[iFeatureIndx]);
}

function hideCurrentFeature() {
	if (iFeatureIndx >= 0 && iFeatureIndx < arrFeatures.length) {
		try { 
			switchImage('picSlideshow'+(iFeatureIndx+1), 'images/picSlideshow_'+(iFeatureIndx+1)+'.gif');
			$('picSlideshow'+(iFeatureIndx+1)).className = "unselected";
		} catch(e) {
			// do nothing	
		}
		Effect.Fade(arrFeatures[iFeatureIndx]);
	}
}

function highlightSlideshowButton(iIndx) {
	if (iIndx != iFeatureIndx) {
		switchImage('picSlideshow'+(iIndx+1), 'images/picSlideshow_'+(iIndx+1)+'_f2.gif');
	}
}

function unhighlightSlideshowButton(iIndx) {
	if (iIndx != iFeatureIndx) {
		switchImage('picSlideshow'+(iIndx+1), 'images/picSlideshow_'+(iIndx+1)+'.gif');
	}
}

function nextFeature() {
	var iVal = iFeatureIndx;
	iVal++;
	if (iVal > arrFeatures.length) { iVal = 0; }
	showFeature(iVal);
}

function prevFeature() {
	var iVal = iFeatureIndx;
	iVal--;
	if (iVal < 0) { iVal = arrFeatures.length; }
	showFeature(iVal);
}