// gives up and down scroll buttons to images, spans, ... named up_name, down_name, respectively.
// will keep the default scroll_box's style overflow if it encounters errors (so make overflow: auto;)

// usage: put this after the scrollbox div:  var div_scroll1 = new TextScroll('div_scroll1', 'scroll_box');
function TextScroll(scrollname, div_name, resetCount)
{
    this.div_name = div_name;
    this.name = scrollname;
    this.scrollCursor = 0;
    this.speed = 1;
    this.timeoutID = 0;
    this.div_obj = null;
 //   this.up_name = up_name;
  //  this.dn_name = down_name;
    var prevPoint = 0
    var pageCount = 0
    var resetC = resetCount
    

{
        if (document.getElementById) {
            div_obj = document.getElementById(this.div_name);
            if (div_obj) {
                this.div_obj = div_obj;
                this.div_obj.style.overflow = 'hidden';
                this.div_obj.onmouseover = function() { eval(scrollname + '.stopScroll();') };
                this.div_obj.onmouseout = function() { eval(scrollname + '.scrollDown();') };
            }
                setTimeout(this.name + ".scrollDown()", 5000);
           
        }
    }

this.stopScroll = function() {
        clearTimeout(this.timeoutID);
    }

this.scrollDown = function() {
        if (this.div_obj) {
            
            this.scrollCursor += this.speed;
            this.div_obj.scrollTop = this.scrollCursor;
            prevPoint = prevPoint + 1;
            
            if (prevPoint == 160) {
            
                prevPoint=0;
                pageCount = pageCount + 1;
                
                if (pageCount == resetC) {
              
                    setTimeout(this.name + ".resetScroll()", 0);
                }
                
                this.timeoutID = setTimeout(this.name + ".scrollDown()", 5000);
            
               return;
            }
            
            else {
            
                this.timeoutID = setTimeout(this.name + ".scrollDown()", 5);
            
            }
       }
    }

this.resetScroll = function() {
        if (this.div_obj) {
            pageCount = 0;
            this.div_obj.scrollTop = 0;
            this.scrollCursor = 0;
           
        }
    }
}
