var Scroller = function(p){ this.currPos = p.currPos ? p.currPos : 0 ; this.increment = p.increment ? p.increment : 1 ; this.maxScroll = p.maxScroll ? p.maxScroll : 200 ; this.refresh = p.refresh ? p.refresh : 60 ; this.elem = p.elem ? p.elem : null ; this.elem = document.getElementById(this.elem); this.timer = null; this.status = "stop"; this.canPlay = true; var self = this ; this.play = function() { if( this.elem && this.canPlay ) { this.status = "run" ; this.currPos += this.increment ; // Reset curr position to loop scrolling if( this.currPos > this.maxScroll ) this.currPos = 0; // Scroll the element this.elem.scrollTop = this.currPos; this.timer = window.setTimeout( function(){ self.play() } , this.refresh ); } } this.stop = function() { //this.canPlay = false; clearTimeout( this.timer ); this.status = "stop" ; } } var s1 = null ; var s2 = null ; var s3 = null ; var s4 = null ; function init() { s1 = new Scroller({ maxScroll : 550 , elem : "banner_expocasa_text" }) ; s2 = new Scroller({ maxScroll : 200 , elem : "banner3_text" }) ; s3 = new Scroller({ maxScroll : 200 , elem : "banner5_text" }) ; s4 = new Scroller({ maxScroll : 200 , elem : "banner6_text" }) ; s1.play(); s2.play(); s3.play(); s4.play(); } function stopAnim(s) { if( s.status=="run" ) s.stop(); } function playAnim(s) { if( s.status=="stop" ) s.play(); } /*var currPos = 0 ; var increment = 1 ; var maxScroll = 550 ; var refresh = 60 ; var timer = null ; var status = "stop" ; var canPlay = false ; function init() { var s1 = new Scroller({ maxScroll : 550 , elem : "banner_expocasa_text" }) s1.play(); var s2 = new Scroller({ maxScroll : 200 , elem : "banner3_text" }) s2.play(); } function bannerScroller( elem ) { if( canPlay ) { status = "run" ; currPos += increment ; // Reset curr position to loop scrolling if( currPos > maxScroll ) currPos = 0; // Scroll the element elem.scrollTop = currPos; timer = window.setTimeout( function(){ bannerScroller( elem ) } , refresh ) } } function stopAnimation() { canPlay = false; clearTimeout( timer ); status = "stop" ; } function playAnimation() { if(canPlay==false) { canPlay = true; var elem = document.getElementById("banner_expocasa_text") ; bannerScroller( elem ) ; } } */