/*

Assumed CSS / cutsomize sizing etc for your preference
Call initScroll() onload - or whenever you FIRST start the scroller.

#scrollBox {
	
    position: relative;
    top: 0px;
	font-size: 13px;
}

#scrollBoxWrapper {
	
	padding: 3px;
	color: #000000;
	position: relative; 
	top: 0px;
	left:38px;
	width:300px;
	height: 190px;
	overflow:hidden;
	z-index: 1;	
	
}



*/

var stopText = 0;
var originalTopPos;
var stopTopPos;
var TimerRef;
var direction = "down";
var bottomRestartTimer;

function initScroll() {
	
	originalTopPos = document.getElementById("scrollBox").offsetTop; //orginal inner diff top Position.
	var leftOverHeight = document.getElementById("scrollBox").offsetHeight - document.getElementById("scrollBoxWrapper").offsetHeight;
	stopTopPos = originalTopPos - (leftOverHeight);//original top minus (the hidden section height of the inner div)
	
	//shove the news down so it scrolls from the very bottom.
	//document.getElementById("scrollBox").style.top = "210px";
	
	move();
}

function move() {
	
	stopText = 0;
	if (!stopText) {
		TimerRef = setTimeout(moveText, 50);
	}
		
}
	
function moveText() {
	
	var obj = document.getElementById("scrollBox");
	var topPos = obj.offsetTop;
	//alert(topPos);
	var newPos;
	if (direction == "down") {
		newPos = (topPos - 1) + "px";
		//alert(newPos);
		
		if (topPos < stopTopPos) { 
			
			//stopText = 1; //stopping at bottom
			
			bottomRestartTimer = setTimeout(restartMove, 5000);
			
			return;
		}
		
	} else {
		newPos = (topPos + 1) + "px";
		if (topPos > originalTopPos) stopText = 1; //stopping at top
	}
	
	obj.style.top = newPos;
		
	if (!stopText) {
		TimerRef = setTimeout(moveText, 50);
	}
}
	
function stopMove() {
	clearTimeout(TimerRef);
	stopText = 1;
}

function restartMove() {
	document.getElementById("scrollBox").style.top = originalTopPos;
	initScroll();
	//alert(originalTopPos);
	//move();
}

function toggleMove() {
	if (stopText) { 
		move();
	} else {
		stopMove();
	}
}

function moveUp() {
	stopMove();
	direction = "down";
	move();
}

function moveDown() {
	stopMove();
	direction = "up";	
	move();
}












	
