Auto Scrolling in a Div

<html>
<head>
<script language=”javascript”>
ScrollRate = 100;

function scrollDiv_init() {
DivElmnt = document.getElementById(‘MyDivName’);
ReachedMaxScroll = false;

DivElmnt.scrollTop = 0;
PreviousScrollTop = 0;

ScrollInterval = setInterval(‘scrollDiv()’, ScrollRate);
}

function scrollDiv() {

if (!ReachedMaxScroll) {
DivElmnt.scrollTop = PreviousScrollTop;
PreviousScrollTop++;

ReachedMaxScroll = DivElmnt.scrollTop >= (DivElmnt.scrollHeight – DivElmnt.offsetHeight);
}
else {
ReachedMaxScroll = (DivElmnt.scrollTop == 0)?false:true;

DivElmnt.scrollTop = PreviousScrollTop;
PreviousScrollTop–;
}
}

function pauseDiv() {
clearInterval(ScrollInterval);
}

function resumeDiv() {
PreviousScrollTop = DivElmnt.scrollTop;
ScrollInterval = setInterval(‘scrollDiv()’, ScrollRate);
}
</script>
</head>
<body onLoad=”scrollDiv_init()”>
<div id=”MyDivName” style=”overflow:auto;width:200px;height:100px” onMouseOver=”pauseDiv()” onMouseOut=”resumeDiv()”>
text text text text text text text text text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text text text text text text text text text
text text text text text text text text text text text text text text text text text text text text text text text text
</div>
</body>
</html>