Ext.namespace("THSite.misc");THSite.misc.Task=Ext.extend(Object,{options:undefined,constructor:function(a){this.options=Ext.apply({delayed:false,autoStart:true,repeatable:true},a);this.worker=function(){this.options.run.apply(this.options.scope||this.options,this.options.args||[])}.createDelegate(this);if(this.options.autoStart){this.start()}},start:function(b){this.stop();Ext.apply(this.options,b);if(!this.options.delayed){this.worker()}var a=this.options.repeatable?setInterval:setTimeout;this.timerId=a(this.worker,this.options.interval)},stop:function(){if(this.timerId){var a=this.options.repeatable?clearInterval:clearTimeout;a(this.timerId);this.timerId=null}if(this.delayTimerId){clearTimeout(this.delayTimerId);this.delayTimerId=null}},delay:function(a){this.stop();this.delayTimerId=setTimeout(function(){this.start()}.createDelegate(this),a)}});
