//initial settings
var start_point=0;//global 
var playing=false;
var currentButton=-1;
var howManyImages=3;
var shortPause=600;
var longPause=6000;

function startRotator(){
	/*to start the rotator when the page loads, this function was being called with an onLoad in the body tag, 
	but that stepped on the onLoad function in osd/js/tabbed_pages.js and the tabs stopped working,
	so we put a call to this function in that onLoad function.  If anyone has a less kludgey idea, feel free to do it.
	*/
	if(howManyImages>1){
		playing=false;
		currentButton=-1;
		playPauseSwitch();
	}
}

function playPauseSwitch(){
	if(playing){
		//change the image to 
		document.getElementById('playPauseImage').src='osd/images/osd_play.gif';
		playing=false;
	} else {						
		document.getElementById('playPauseImage').src='osd/images/osd_pause.gif';
		playing=true;
		playPause();
	}
}

function playPause(){
	if(playing){
		currentButton++;
		if(currentButton == howManyImages){
			currentButton=0;
		}
		next_story_continue(currentButton);
		var index1=0;
		var buttonName='';
		for(index1=0;index1<howManyImages;index1++){
			buttonName='storyButton' + index1;
			document.getElementById(buttonName).style.color='#BBB';
		}
		buttonName='storyButton' + currentButton;
		//document.getElementById(buttonName).style.background='#888';
		//above seems to short-circuit the hover style.  Leave out until that is solved
		document.getElementById(buttonName).style.color='#ffffff';
		window.setTimeout("playPause()",longPause);
	} 
}

