jQuery.fn.extend({everyTime:function(c,b,a,d){return this.each(function(){jQuery.timer.add(this,c,b,a,d)})},oneTime:function(c,b,a){return this.each(function(){jQuery.timer.add(this,c,b,a,1)})},stopTime:function(b,a){return this.each(function(){jQuery.timer.remove(this,b,a)})}});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(a){if(a==undefined||a==null){return null}var b=this.regex.exec(jQuery.trim(a.toString()));if(b[2]){var d=parseFloat(b[1]);var c=this.powers[b[2]]||1;return d*c}else{return a}},add:function(b,h,f,d,a){var e=0;if(jQuery.isFunction(f)){if(!a){a=d}d=f;f=h}h=jQuery.timer.timeParse(h);if(typeof h!="number"||isNaN(h)||h<0){return}if(typeof a!="number"||isNaN(a)||a<0){a=0}a=a||0;var g=jQuery.data(b,this.dataKey)||jQuery.data(b,this.dataKey,{});if(!g[f]){g[f]={}}d.timerID=d.timerID||this.guid++;var c=function(){if((++e>a&&a!==0)||d.call(b,e)===false){jQuery.timer.remove(b,f,d)}};c.timerID=d.timerID;if(!g[f][d.timerID]){g[f][d.timerID]=window.setInterval(c,h)}this.global.push(b)},remove:function(d,b,a){var c=jQuery.data(d,this.dataKey),e;if(c){if(!b){for(b in c){this.remove(d,b,a)}}else{if(c[b]){if(a){if(a.timerID){window.clearInterval(c[b][a.timerID]);delete c[b][a.timerID]}}else{for(var a in c[b]){window.clearInterval(c[b][a]);delete c[b][a]}}for(e in c[b]){break}if(!e){e=null;delete c[b]}}}for(e in c){break}if(!e){jQuery.removeData(d,this.dataKey)}}}}});jQuery(window).bind("unload",function(){jQuery.each(jQuery.timer.global,function(b,a){jQuery.timer.remove(a)})});
