jQuery.fn.extend({everyTime:function(a,c,e,d,b){return this.each(function(){jQuery.timer.add(this,a,c,e,d,b)})},oneTime:function(a,b,c){return this.each(function(){jQuery.timer.add(this,a,b,c,1)})},stopTime:function(a,b){return this.each(function(){jQuery.timer.remove(this,a,b)})}});jQuery.extend({timer:{guid:1,global:{},regex:/^([0-9]+)\s*(.*s)?$/,powers:{ms:1,cs:10,ds:100,s:1e3,das:1e4,hs:1e5,ks:1e6},timeParse:function(a){if(a==undefined||a==null)return null;var b=this.regex.exec(jQuery.trim(a.toString()));if(b[2]){var d=parseInt(b[1],10),c=this.powers[b[2]]||1;return d*c}else return a},add:function(c,e,a,d,b,f){var g=0;if(jQuery.isFunction(a)){if(!b)b=d;d=a;a=e}e=jQuery.timer.timeParse(e);if(typeof e!="number"||isNaN(e)||e<=0)return;if(b&&b.constructor!=Number){f=!!b;b=0}b=b||0;f=f||false;if(!c.$timers)c.$timers={};if(!c.$timers[a])c.$timers[a]={};d.$timerID=d.$timerID||this.guid++;var h=function(){if(f&&this.inProgress)return;this.inProgress=true;(++g>b&&b!==0||d.call(c,g)===false)&&jQuery.timer.remove(c,a,d);this.inProgress=false};h.$timerID=d.$timerID;if(!c.$timers[a][d.$timerID])c.$timers[a][d.$timerID]=window.setInterval(h,e);if(!this.global[a])this.global[a]=[];this.global[a].push(c)},remove:function(e,b,c){var a=e.$timers,d;if(a){if(!b)for(b in a)this.remove(e,b,c);else if(a[b]){if(c){if(c.$timerID){window.clearInterval(a[b][c.$timerID]);delete a[b][c.$timerID]}}else for(var c in a[b]){window.clearInterval(a[b][c]);delete a[b][c]}for(d in a[b])break;if(!d){d=null;delete a[b]}}for(d in a)break;if(!d)e.$timers=null}}}});if(jQuery.browser.msie)jQuery(window).one("unload",function(){var a=jQuery.timer.global;for(var b in a){var c=a[b],d=c.length;while(--d)jQuery.timer.remove(c[d],b)}});
