﻿// JScript File

var __TIMER_DELAY = 25;
var __TIMER_PAUSE = 4000;
var __SCROLL_DELTA = -2;
var _timer;

var _messages = new Array();
var _msgIndex;

function scrollerStart() {
	_msgIndex = 0;
	var divCurrent = document.getElementById("divScroll0");
	if( divCurrent==null ) return;
	divCurrent.innerHTML = _messages[_msgIndex];
	divCurrent.style.top = "1px";	//jumps into timer loop just before pause on div0 w/ msg0

	scrollerMove(0);
}	//function startScroller() 

function scrollerMove(iCurrentNbr) {
	var divCurrent = document.getElementById("divScroll"+iCurrentNbr);
	var divOther = document.getElementById("divScroll"+(1-iCurrentNbr));

	var iTop = parseInt(divCurrent.style.top);
	if( (iTop>0) & (iTop+__SCROLL_DELTA<=0) ) {	//w/in 1 step of top--special handling
		divCurrent.style.top = 0;
		divOther.style.top = parseInt(divOther.style.height)+"px";
		_msgIndex = (_msgIndex+1) % (_messages.length);
		divOther.innerHTML = _messages[_msgIndex];
		
		_timer = window.setTimeout("scrollerMove("+(1-iCurrentNbr)+")", __TIMER_PAUSE);
	}else{
		divCurrent.style.top = (iTop+__SCROLL_DELTA)+"px";
		divOther.style.top = (parseInt(divOther.style.top)+__SCROLL_DELTA)+"px";
		
		_timer = window.setTimeout("scrollerMove("+iCurrentNbr+")", __TIMER_DELAY);
	}
}	//function scrollerMove(iCurrentNbr) 

function scrollerPause() {
	window.clearTimeout(_timer);
}

function scrollerResume() {
	var div0 = document.getElementById("divScroll0");
	var div1 = document.getElementById("divScroll1");
	var iCurrentNbr = ( parseInt(div0.style.top)>parseInt(div1.style.top) )?0:1;
	_timer = window.setTimeout("scrollerMove("+iCurrentNbr+")", __TIMER_DELAY);
}


