var timer = "";			// our timer
var timerSeconds = 10;	// interval between switches
var timerOn = 1;		// which element are we on currently
var lastSpotlight = 0;		// the last element
var playing = true;
function swap(el) {
	// they clicked, clear mouseover
	lastSpotlight = 0;
	if ( playing == false ) playing = true; // we want the playPause() to pause
	playPause();
	change(el);
}
function change(el) {
	timerOn = el;
	document.getElementById('spotlight1').style.display = "none";
	document.getElementById('spotlight2').style.display = "none";
	document.getElementById('spotlight3').style.display = "none";
	document.getElementById('spotlight4').style.display = "none";
	document.getElementById('spotlight5').style.display = "none";		

	if ( el == 1 ) {
		document.getElementById('spotlight1').style.display = "block";
	}
	else if ( el == 2 ) {
		document.getElementById('spotlight2').style.display = "block";
	}
	else if ( el == 3 ) {
		document.getElementById('spotlight3').style.display = "block";
	}
	 else if ( el == 4 ) {
		document.getElementById('spotlight4').style.display = "block"; 
	}
	 else if ( el == 5 ) {
		document.getElementById('spotlight5').style.display = "block"; 
	}
	
	
}
function startTimer() {
	if ( timer == "" ) timer = setTimeout("doTimer()", timerSeconds * 1000)
}
function doTimer() {
	timer = "";
	if ( playing == true && lastSpotlight == 0 ) {
		timerOn++;
		if ( timerOn == 5 ) {
			timerOn = 1;
		}
		change(timerOn);
		startTimer();
	}
}

function playPause() {
	if ( playing == true ) {
		var timer = "";
		playing = false;
		document.getElementById('imgPlayPause1').src = "http://concepts.rd.net/afsa/2009/build/images/BannerRotatorPlay.gif";
		document.getElementById('imgPlayPause2').src = "http://concepts.rd.net/afsa/2009/build/images/BannerRotatorPlay.gif";
		document.getElementById('imgPlayPause3').src = "http://concepts.rd.net/afsa/2009/build/images/BannerRotatorPlay.gif";
		document.getElementById('imgPlayPause4').src = "http://concepts.rd.net/afsa/2009/build/images/BannerRotatorPlay.gif";	
		document.getElementById('imgPlayPause5').src = "http://concepts.rd.net/afsa/2009/build/images/BannerRotatorPlay.gif";		
			
	} else {
		startTimer();
		playing = true;
		document.getElementById('imgPlayPause1').src = "http://concepts.rd.net/afsa/2009/build/images/BannerRotatorPause.gif";
		document.getElementById('imgPlayPause2').src = "http://concepts.rd.net/afsa/2009/build/images/BannerRotatorPause.gif";
		document.getElementById('imgPlayPause3').src = "http://concepts.rd.net/afsa/2009/build/images/BannerRotatorPause.gif";
		document.getElementById('imgPlayPause4').src = "http://concepts.rd.net/afsa/2009/build/images/BannerRotatorPause.gif";
		document.getElementById('imgPlayPause5').src = "http://concepts.rd.net/afsa/2009/build/images/BannerRotatorPause.gif";				
	}
}

function spotlightOver(el) {
	lastSpotlight = timerOn;
//	playPause();
	change(el);
}
function spotlightOut() {
	if ( lastSpotlight > 0 ) {
		change(lastSpotlight);
		lastSpotlight = 0;
		startTimer();
	}
}
startTimer();

