var o_div, o_style, tmr, itr, lmtItr, cntr, offst, curItm = 0;
var item = getScroll();
var pause = 3000;

function stopStart(id) {
	if (id == 0) {
		clearInterval(tmr);
		clearTimeout(tmr);
	} else {
		if (itr <= cntr) tmr = setInterval("moveOut()", 100);
			else tmr = setInterval("moveIn()", 100);
	}
}
function getStopLoc() {
	var dvHght = o_div.offsetHeight;
	if (dvHght >= offst) return 10;
	dvHght = (offst - dvHght) / 2;
	dvHght = Math.round(dvHght);
	if (dvHght <= 10) return 10;
	return dvHght;
}
function doNext(intvl) {
	if (intvl != null) pause = intvl;
	o_div.innerHTML = item[curItm];
	lmtItr = offst + 50;
	itr = offst + 50;
	o_style.top = lmtItr + "px";
	cntr = getStopLoc();
	curItm += 1;
	if (curItm >= item.length) curItm = 0;
	tmr = setInterval("moveIn()", 100);
}
function moveOut() { 
	itr = itr - 10;
	if (-lmtItr >= itr) {
		clearInterval(tmr);
		doNext(null);
	}
	o_style.top = itr + "px";
}
function doPause() {
	tmr = setInterval("moveOut()", 100);
}
function moveIn() { 
	itr = itr - 10;
	if (itr <= cntr) {
		clearInterval(tmr);
		tmr = setTimeout("doPause()", pause);
	}
	o_style.top = itr + "px";
}
