var paused=false;
var backing=false;
var tickerCount=0;
var topSlide;
var bottomSlide;
var slidePos = -100;
var currentTicker=1;
var t;

function backward(){
	var button=document.getElementById('pbbutton');
	if(backing){
		backing=false;
		button.src="img/forward.png";
		currentTicker++;
		if(currentTicker>tickerCount){
				currentTicker=1;
		}
	}else{
		button.src="img/backward.png";
		backing=true;
		currentTicker--;
		if(currentTicker<1){
				currentTicker=tickerCount;
		}
	}//*/
}
function playPause(){
	var button=document.getElementById('ppbutton');
	if(paused){
		paused=false;
		button.src="img/pause.png";
	}else{
		button.src="img/play.png";
		paused=true;
	}//*/
}
function startTicker(count){
	tickerCount=count;
	topSlide=document.getElementById('ticker1');
	bottomSlide=document.getElementById('ticker2');
	tick();
}
function tick(){
	if(paused){
		t=setTimeout("tick()",100);
	}
	else if(backing){
		if(slidePos == 0){//need to change slides
			bottomSlide="ticker"+currentTicker;
			currentTicker--;
			if(currentTicker<1){
				currentTicker=tickerCount;
			}
			topSlide="ticker"+currentTicker;
			topSlide=document.getElementById(topSlide);
			bottomSlide=document.getElementById(bottomSlide);
			slidePos=-100;
			t=setTimeout("tick()",3000);
		}else{//move slide one increment
			slidePos++;
			topSlide.style.top=slidePos+'px';
			bottomSlide.style.top=(slidePos+100)+'px';
			t=setTimeout("tick()",10);
		}
	}else{//play normally
		if(slidePos == -100){//need to change slides
			topSlide="ticker"+currentTicker;
			currentTicker++;
			if(currentTicker>tickerCount){
				currentTicker=1;
			}
			bottomSlide="ticker"+currentTicker;
			topSlide=document.getElementById(topSlide);
			bottomSlide=document.getElementById(bottomSlide);
			slidePos=0;
			t=setTimeout("tick()",3000);
		}else{//move slide one increment
			slidePos--;
			topSlide.style.top=slidePos+'px';
			bottomSlide.style.top=(slidePos+100)+'px';
			t=setTimeout("tick()",10);
		}
	}
}

