function scrolltext(content,btnprevious,btnnext,autostart,timeout,issmoothscroll) { this.speed = 5; this.timeout = timeout; this.stopscroll =false; this.issmoothscroll= issmoothscroll; this.lineheight = 26; this.nextbutton = this.$(btnnext); this.previousbutton = this.$(btnprevious); this.scrollcontent = this.$(content); this.scrollcontent.innerhtml += this.scrollcontent.innerhtml; if(this.previousbutton) { this.previousbutton.onclick = this.getfunction(this,"previous"); this.previousbutton.onmouseover = this.getfunction(this,"mouseover"); this.previousbutton.onmouseout = this.getfunction(this,"mouseout"); } if(this.nextbutton){ this.nextbutton.onclick = this.getfunction(this,"next"); this.nextbutton.onmouseover = this.getfunction(this,"mouseover"); this.nextbutton.onmouseout = this.getfunction(this,"mouseout"); } this.scrollcontent.onmouseover = this.getfunction(this,"mouseover"); this.scrollcontent.onmouseout = this.getfunction(this,"mouseout"); if(autostart) { this.start(); } } scrolltext.prototype = { $:function(element) { return document.getelementbyid(element); }, previous:function() { this.stopscroll = true; this.scroll("up"); }, next:function() { this.stopscroll = true; this.scroll("down"); }, start:function() { if(this.issmoothscroll) { this.autoscrolltimer = setinterval(this.getfunction(this,"smoothscroll"), this.timeout); } else { this.autoscrolltimer = setinterval(this.getfunction(this,"autoscroll"), this.timeout); } }, stop:function() { cleartimeout(this.autoscrolltimer); this.delaytimerstop = 0; }, mouseover:function() { this.stopscroll = true; }, mouseout:function() { this.stopscroll = false; }, autoscroll:function() { if(this.stopscroll) { return; } this.scrollcontent.scrolltop++; if(parseint(this.scrollcontent.scrolltop) % this.lineheight != 0) { this.scrolltimer = settimeout(this.getfunction(this,"autoscroll"), this.speed); } else { if(parseint(this.scrollcontent.scrolltop) >= parseint(this.scrollcontent.scrollheight) / 2) { this.scrollcontent.scrolltop = 0; } cleartimeout(this.scrolltimer); //this.autoscrolltimer = settimeout(this.getfunction(this,"autoscroll"), this.timeout); } }, smoothscroll:function() { if(this.stopscroll) { return; } this.scrollcontent.scrolltop++; if(parseint(this.scrollcontent.scrolltop) >= parseint(this.scrollcontent.scrollheight) / 2) { this.scrollcontent.scrolltop = 0; } }, scroll:function(direction) { if(direction=="up") { this.scrollcontent.scrolltop--; } else { this.scrollcontent.scrolltop++; } if(parseint(this.scrollcontent.scrolltop) >= parseint(this.scrollcontent.scrollheight) / 2) { this.scrollcontent.scrolltop = 0; } else if(parseint(this.scrollcontent.scrolltop)<=0) { this.scrollcontent.scrolltop = parseint(this.scrollcontent.scrollheight) / 2; } if(parseint(this.scrollcontent.scrolltop) % this.lineheight != 0) { this.scrolltimer = settimeout(this.getfunction(this,"scroll",direction), this.speed); } }, getfunction:function(variable,method,param) { return function() { variable[method](param); } } } function ignoreerror() { return true; } window.onerror = ignoreerror;