﻿var textDiv = document.getElementById("rollText");
var textList = textDiv.getElementsByTagName("a");
var minTime,maxTime,divTop,divTopTo,newTop=0;
if(textList.length > 2){
	var textDat = textDiv.innerHTML;
	var br = textDat.toLowerCase().indexOf("<br",textDat.toLowerCase().indexOf("<br")+3);
	textDiv.innerHTML = textDat+textDat+textDat.substr(0,br);
	textDiv.style.cssText = "position:absolute; top:0";
	var textDatH = textDiv.offsetHeight;MaxRoll();
	//textDiv.onmouseover = function(){clearInterval(minTime);}
	//textDiv.onmouseout = function(){minTime = setInterval(MinRoll,1);}
}
function MinRoll(){
	newTop++;
	if(newTop<=divTopTo){
		textDiv.style.top = "-" + newTop + "px";
	}else{
		clearInterval(minTime);
		maxTime = setTimeout(MaxRoll,5000);
	}
}
function MaxRoll(){
	divTop = Math.abs(parseInt(textDiv.style.top));
	divTopTo = divTop + 40 ;
	if(divTop>=0 && divTop<textDatH-40){
		minTime = setInterval(MinRoll,50);
	}else{
		textDiv.style.top = 0;divTop = 0;newTop=0;MaxRoll();
	}
}

