jQuery.fn.extend({everyTime:function(f,j,i,h,g){return this.each(function(){jQuery.timer.add(this,f,j,i,h,g)})},oneTime:function(e,d,f){return this.each(function(){jQuery.timer.add(this,e,d,f,1)})},stopTime:function(d,c){return this.each(function(){jQuery.timer.remove(this,d,c)})}});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:1000,das:10000,hs:100000,ks:1000000},timeParse:function(h){if(h==undefined||h==null){return null}var f=this.regex.exec(jQuery.trim(h.toString()));if(f[2]){var e=parseFloat(f[1]);var g=this.powers[f[2]]||1;return e*g}else{return h}},add:function(n,p,k,l,q,m){var r=0;if(jQuery.isFunction(k)){if(!q){q=l}l=k;k=p}p=jQuery.timer.timeParse(p);if(typeof p!="number"||isNaN(p)||p<=0){return}if(q&&q.constructor!=Number){m=!!q;q=0}q=q||0;m=m||false;var o=jQuery.data(n,this.dataKey)||jQuery.data(n,this.dataKey,{});if(!o[k]){o[k]={}}l.timerID=l.timerID||this.guid++;var j=function(){if(m&&this.inProgress){return}this.inProgress=true;if((++r>q&&q!==0)||l.call(n,r)===false){jQuery.timer.remove(n,k,l)}this.inProgress=false};j.timerID=l.timerID;if(!o[k][l.timerID]){o[k][l.timerID]=window.setInterval(j,p)}this.global.push(n)},remove:function(j,f,i){var h=jQuery.data(j,this.dataKey),g;if(h){if(!f){for(f in h){this.remove(j,f,i)}}else{if(h[f]){if(i){if(i.timerID){window.clearInterval(h[f][i.timerID]);delete h[f][i.timerID]}}else{for(var i in h[f]){window.clearInterval(h[f][i]);delete h[f][i]}}for(g in h[f]){break}if(!g){g=null;delete h[f]}}}for(g in h){break}if(!g){jQuery.removeData(j,this.dataKey)}}}}});jQuery(window).bind("unload",function(){jQuery.each(jQuery.timer.global,function(d,c){jQuery.timer.remove(c)})});
