//<script>
function Co_Interval_Manager(){this.Interval=null; this.Milliseconds=0; this.EventHandlers = {}; this.win=window; this.Loops=0; this.LoopIndex=0;};
Co_Interval_Manager.prototype.AddListener=Co_Interval_Manager.prototype.AddHandler=Co_Interval_Manager.prototype.AddEventListener=Co_Interval_Manager.prototype.AddEventHandler=function(evName, func, target_obj, paramsArray){var obj=this.EventHandlers[evName.toLowerCase()];if (typeof(obj)!="object")obj=[]; if (typeof(obj.length)=="undefined") obj=[];obj.push({func:func,obj:target_obj,params:paramsArray});this.EventHandlers[evName.toLowerCase()]=obj;}
Co_Interval_Manager.prototype.RemoveListeners=function(evName) {this.EventHandlers[evName.toLowerCase()]=[];}
Co_Interval_Manager.prototype.ClearInterval=function(){if (this.Interval==null)return;this.win.clearInterval(this.Interval);this.LoopIndex=0;this.onEnd();}
Co_Interval_Manager.prototype.Start=function(ms, win){this.ClearInterval();this.win=win||window;this.Milliseconds=ms;this.Interval=Co_Tools.SetInterval(this.onInterval, ms, this, null, win);this.LoopIndex=0;this.onStart();}
Co_Interval_Manager.prototype.Stop=Co_Interval_Manager.prototype.End=function(){this.ClearInterval();}
Co_Interval_Manager.prototype.Reset=function(){this.LoopIndex=0;this.ClearInterval();this.Start(this.Milliseconds,this.win);}
Co_Interval_Manager.prototype.Pause=function(){if (this.Interval==null)return;this.win.clearInterval(this.Interval);}
Co_Interval_Manager.prototype.Resume=function(){if (this.Interval!=null)this.Pause();this.Interval=Co_Tools.SetInterval(this.onInterval, this.Milliseconds, this, null, this.win);}
Co_Interval_Manager.prototype.onStart=function(){this.FireEvent("start");}
Co_Interval_Manager.prototype.onEnd=function(){this.FireEvent("end");}
Co_Interval_Manager.prototype.onInterval=function(){this.LoopIndex++;this.FireEvent("interval");if (this.Loops > 0 && this.LoopIndex >= this.Loops) this.End(); }
Co_Interval_Manager.prototype.FireEvent=function(evName){var obj=this.EventHandlers[evName.toLowerCase()];if (typeof(obj)!="object") return;if (typeof(obj.length)=="undefined") return;for (var i=0;i<obj.length;i++){this.RunEventHandler(obj[i].func, obj[i].obj, obj[i].params);}}
Co_Interval_Manager.prototype.RunEventHandler=function(f,o,p){try {if(p)f.apply(o,[].concat(p));else f.apply(o);} catch (e){}}
var Co_Interval = new Co_Interval_Manager();
//</script>
