(function(e){e.fn.countdown=function(n){var t={date:new Date,updateTime:1e3,htmlTemplate:"%{d} 天 %{h} 小时 %{m} 分 %{s} 秒",minus:false,onChange:null,onComplete:null,leadingZero:false},l={},a=/(%\{d\}|%\{h\}|%\{m\}|%\{s\})/g,i=/%\{d\}/,r=/%\{h\}/,f=/%\{m\}/,m=/%\{s\}/,o=false,c,p=Math.floor,g=null,u=null;e.extend(l,t,n);c=l.htmlTemplate;return this.each(function(){var n=e(this),t,g=new Date,u=new Date(l.date),d=864e5,h=u.getTime()-g.getTime(),s=h/d,w=p(s),T=(s-w)*24,C=p(T),v=p((T-C)*60),D=(T-C)*60,I=p((D-v)*60),Z="";if(l.onChange){n.bind("change",l.onChange)}if(l.onComplete){n.bind("complete",l.onComplete)}if(l.leadingZero){if(w<10){w="0"+w}if(C<10){C="0"+C}if(v<10){v="0"+v}if(I<10){I="0"+I}}if(g<=u||l.minus){Z=c.replace(i,w).replace(r,C).replace(f,v).replace(m,I)}else{Z=c.replace(a,"00");o=true}t=window.setInterval(function(){g=new Date,u=new Date(l.date),d=864e5,h=u.getTime()-g.getTime(),s=h/d,w=p(s),T=(s-w)*24,C=p(T),v=p((T-C)*60),D=(T-C)*60,I=p((D-v)*60),Z="";if(l.leadingZero){if(w<10){w="0"+w}if(C<10){C="0"+C}if(v<10){v="0"+v}if(I<10){I="0"+I}}if(g<=u||l.minus){Z=c.replace(i,w).replace(r,C).replace(f,v).replace(m,I)}else{Z=c.replace(a,"00");o=true}n.html(Z);n.trigger("change",[t]);if(o){n.trigger("complete");clearInterval(t)}},l.updateTime);n.html(Z);if(o){n.trigger("complete");clearInterval(t)}})}})(jQuery);