/*
	This js opperates the news scroller that appears on the home page.
   	Originally written for UWPic by Clinton Howell
*/

var scrollStoryCount = 6;
var scrollRotatorTime = 3000;

function scrollerPause(){
	document.getElementById('scrollerPause').style.display = 'none';
	document.getElementById('scrollerPlay').style.display = 'block';
	// clear current timer
	window.clearTimeout(timeoutID);
}

function scrollerPlay(){
	document.getElementById('scrollerPause').style.display = 'block';
	document.getElementById('scrollerPlay').style.display = 'none';	
}

function scrollerPlayPause(){
	if(document.getElementById('scrollerPause').style.display == 'none')
		scrollerPlay();
	else
		scrollerPause();
		scrollerRotator();
}

function scrollerShowStory(storyNumber){
	var activeStory = 1;
	for(var i=1; i<=scrollStoryCount; i++){
		if(document.getElementById('niBtn' + i).className == 'nBtn on')
			activeStory = i;
			}
	document.getElementById('niBtn' + activeStory).className = "nBtn";
	Effect.Fade('ni' + activeStory, {duration: .5});
	document.getElementById('niBtn' + storyNumber).className = "nBtn on";	
	Effect.Appear('ni' + storyNumber, {duration: .5});
}

function scrollerRotateStory(){
	var activeStory = 6;
	for(var i=1; i<=scrollStoryCount; i++){
		if(document.getElementById('niBtn' + i).className == 'nBtn on')
			activeStory = i;
		}
	var nextStory = activeStory + 1;
	if(nextStory > scrollStoryCount)
		nextStory = 1;
		scrollerShowStory(nextStory);
}

function scrollerRotator(){
	if(document.getElementById('scrollerPause').style.display != 'none'){
		scrollerRotateStory();
		// set timer
		timeoutID = window.setTimeout("scrollerRotator()", scrollRotatorTime);
		}
}