!function(d){"function"==typeof define&&define.amd?define(["jquery"],d):d(jQuery)}(function(d){function p(a){return function(b){var c=b.match(/%(-|!)?[A-Z]{1}(:[^;]+;)?/gi);if(c)for(var d=0,h=c.length;d<h;++d){var e=c[d].match(/%(-|!)?([a-zA-Z]{1})(:[^;]+;)?/),g;g=e[0].toString().replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1");g=new RegExp(g);var k=e[1]||"",l=e[3]||"",f=null,e=e[2];n.hasOwnProperty(e)&&(f=n[e],f=Number(a[f]));if(null!==f){if("!"===k)var e=l,l="s",m="",f=(e&&(e=e.replace(/(:|;|\s)/gi,"").split(/\,/),
1===e.length?l=e[0]:(m=e[0],l=e[1])),1<Math.abs(f)?l:m);""===k&&10>f&&(f="0"+f.toString());b=b.replace(g,f.toString())}}return b.replace(/%%/,"%")}}var g=[],h=[],m={precision:100,elapse:!1,defer:!1};h.push(/^[0-9]*$/.source);h.push(/([0-9]{1,2}\/){2}[0-9]{4}( [0-9]{1,2}(:[0-9]{2}){2})?/.source);h.push(/[0-9]{4}([\/\-][0-9]{1,2}){2}( [0-9]{1,2}(:[0-9]{2}){2})?/.source);var h=new RegExp(h.join("|")),n={Y:"years",m:"months",n:"daysToMonth",d:"daysToWeek",w:"weeks",W:"weeksToMonth",H:"hours",M:"minutes",
S:"seconds",D:"totalDays",I:"totalHours",N:"totalMinutes",T:"totalSeconds"},k=function(a,b,c){this.el=a;this.$el=d(a);this.interval=null;this.offset={};this.options=d.extend({},m);this.instanceNumber=g.length;g.push(this);this.$el.data("countdown-instance",this.instanceNumber);c&&("function"==typeof c?(this.$el.on("update.countdown",c),this.$el.on("stoped.countdown",c),this.$el.on("finish.countdown",c)):this.options=d.extend({},m,c));this.setFinalDate(b);!1===this.options.defer&&this.start()};d.extend(k.prototype,
{start:function(){null!==this.interval&&clearInterval(this.interval);var a=this;this.update();this.interval=setInterval(function(){a.update.call(a)},this.options.precision)},stop:function(){clearInterval(this.interval);this.interval=null;this.dispatchEvent("stoped")},toggle:function(){this.interval?this.stop():this.start()},pause:function(){this.stop()},resume:function(){this.start()},remove:function(){this.stop.call(this);g[this.instanceNumber]=null;delete this.$el.data().countdownInstance},setFinalDate:function(a){var b=
a;if(b instanceof Date)a=b;else if(String(b).match(h))a=(String(b).match(/^[0-9]*$/)&&(b=Number(b)),String(b).match(/\-/)&&(b=String(b).replace(/\-/g,"/")),new Date(b));else throw Error("Couldn't cast `"+b+"` to a date object.");this.finalDate=a},update:function(){if(0===this.$el.closest("html").length)return void this.remove();var a,b=void 0!==d._data(this.el,"events"),c=new Date;a=this.finalDate.getTime()-c.getTime();a=Math.ceil(a/1E3);a=!this.options.elapse&&0>a?0:Math.abs(a);this.totalSecsLeft!==
a&&b&&(this.totalSecsLeft=a,this.elapsed=c>=this.finalDate,this.offset={seconds:this.totalSecsLeft%60,minutes:Math.floor(this.totalSecsLeft/60)%60,hours:Math.floor(this.totalSecsLeft/60/60)%24,days:Math.floor(this.totalSecsLeft/60/60/24)%7,daysToWeek:Math.floor(this.totalSecsLeft/60/60/24)%7,daysToMonth:Math.floor(this.totalSecsLeft/60/60/24%30.4368),weeks:Math.floor(this.totalSecsLeft/60/60/24/7),weeksToMonth:Math.floor(this.totalSecsLeft/60/60/24/7)%4,months:Math.floor(this.totalSecsLeft/60/60/
24/30.4368),years:Math.abs(this.finalDate.getFullYear()-c.getFullYear()),totalDays:Math.floor(this.totalSecsLeft/60/60/24),totalHours:Math.floor(this.totalSecsLeft/60/60),totalMinutes:Math.floor(this.totalSecsLeft/60),totalSeconds:this.totalSecsLeft},this.options.elapse||0!==this.totalSecsLeft?this.dispatchEvent("update"):(this.stop(),this.dispatchEvent("finish")))},dispatchEvent:function(a){a=d.Event(a+".countdown");a.finalDate=this.finalDate;a.elapsed=this.elapsed;a.offset=d.extend({},this.offset);
a.strftime=p(this.offset);this.$el.trigger(a)}});d.fn.countdown=function(){var a=Array.prototype.slice.call(arguments,0);return this.each(function(){var b=d(this).data("countdown-instance");if(void 0!==b){var b=g[b],c=a[0];k.prototype.hasOwnProperty(c)?b[c].apply(b,a.slice(1)):null===String(c).match(/^[$A-Z_][0-9A-Z_$]*$/i)?(b.setFinalDate.call(b,c),b.start()):d.error("Method %s does not exist on jQuery.countdown".replace(/\%s/gi,c))}else new k(this,a[0],a[1])})}});