jQuery.fn.extend({everyTime:function(n,t,i,r,u){return this.each(function(){jQuery.timer.add(this,n,t,i,r,u)})},oneTime:function(n,t,i){return this.each(function(){jQuery.timer.add(this,n,t,i,1)})},stopTime:function(n,t){return this.each(function(){jQuery.timer.remove(this,n,t)})}}),jQuery.event.special,jQuery.extend({timer:{global:[],guid:1,dataKey:"jQuery.timer",regex:/^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/,powers:{ms:1,cs:10,ds:100,s:1e3,das:1e4,hs:1e5,ks:1e6},timeParse:function(n){var t,r,i;return n==undefined||n==null?null:(t=this.regex.exec(jQuery.trim(n.toString())),t[2]?(r=parseFloat(t[1]),i=this.powers[t[2]]||1,r*i):n)},add:function(n,t,i,r,u,f){var s=0,e,o;jQuery.isFunction(i)&&(u||(u=r),r=i,i=t),t=jQuery.timer.timeParse(t);if(typeof t!="number"||isNaN(t)||t<=0)return;u&&u.constructor!=Number&&(f=!!u,u=0),u=u||0,f=f||!1,e=jQuery.data(n,this.dataKey)||jQuery.data(n,this.dataKey,{}),e[i]||(e[i]={}),r.timerID=r.timerID||this.guid++,o=function(){if(f&&this.inProgress)return;this.inProgress=!0,(++s>u&&u!==0||r.call(n,s)===!1)&&jQuery.timer.remove(n,i,r),this.inProgress=!1},o.timerID=r.timerID,e[i][r.timerID]||(e[i][r.timerID]=window.setInterval(o,t)),this.global.push(n)},remove:function(n,t,i){var r=jQuery.data(n,this.dataKey),u,i;if(r){if(t){if(r[t]){if(i)i.timerID&&(window.clearInterval(r[t][i.timerID]),delete r[t][i.timerID]);else for(i in r[t])window.clearInterval(r[t][i]),delete r[t][i];for(u in r[t])break;u||(u=null,delete r[t])}}else for(t in r)this.remove(n,t,i);for(u in r)break;u||jQuery.removeData(n,this.dataKey)}}}}),jQuery(window).bind("unload",function(){jQuery.each(jQuery.timer.global,function(n,t){jQuery.timer.remove(t)})});
