var titleLoopRunning = 0; var JqueryUtil = { LoopText:function(){ var thisinstance = function(dText,step){ this.step = step; this.dText = dText; this.dPanel = dText.parentNode; this.dTextWidth = this.dText.offsetWidth; this.dPanelWidth = this.dPanel.offsetWidth; //alert(this.dPanelWidth + " " + this.dTextWidth); this.mustLoop = (this.dTextWidth > this.dPanelWidth); this.left = 0; if(!this.dText.style.left){this.dText.style.left = "0px";} }; thisinstance.prototype = { loopText:function(){ var left = this.left; if(left > -this.dTextWidth){ left -= this.step; }else{ left = this.dPanelWidth; } this.dText.style.left = left+"px"; this.left = left; othis = this; titleLoopRunning = setTimeout(function(){othis.loopText();},200); }, reset:function(){ if(titleLoopRunning != 0){ clearTimeout(titleLoopRunning); titleLoopRunning = 0; } this.dText.style.left = "0px"; this.left = 0; } }; return thisinstance; }() };