/*! http://keith-wood.name/countdown.html countdown for jquery v2.1.0. written by keith wood (wood.keith{at}optusnet.com.au) january 2008. available under the mit (http://keith-wood.name/licence.html) license. please attribute the author if you use it. */ !function(a){"use strict";var b="countdown",c=0,d=1,e=2,f=3,g=4,h=5,i=6;a.jqplugin.createplugin({name:b,defaultoptions:{until:null,since:null,timezone:null,serversync:null,format:"dhms",layout:"",compact:!1,padzeroes:!1,significant:0,description:"",expiryurl:"",expirytext:"",alwaysexpire:!1,onexpiry:null,ontick:null,tickinterval:1},regionaloptions:{"":{labels:["years","months","weeks","days","hours","minutes","seconds"],labels1:["year","month","week","day","hour","minute","second"],compactlabels:["y","m","w","d"],whichlabels:null,digits:["0","1","2","3","4","5","6","7","8","9"],timeseparator:":",isrtl:!1}},_rtlclass:b+"-rtl",_sectionclass:b+"-section",_amountclass:b+"-amount",_periodclass:b+"-period",_rowclass:b+"-row",_holdingclass:b+"-holding",_showclass:b+"-show",_descrclass:b+"-descr",_timerelems:[],_init:function(){function b(a){var h=a<1e12?e?window.performance.now()+window.performance.timing.navigationstart:d():a||d();h-g>=1e3&&(c._updateelems(),g=h),f(b)}var c=this;this._super(),this._serversyncs=[];var d="function"==typeof date.now?date.now:function(){return(new date).gettime()},e=window.performance&&"function"==typeof window.performance.now,f=window.requestanimationframe||window.webkitrequestanimationframe||window.mozrequestanimationframe||window.orequestanimationframe||window.msrequestanimationframe||null,g=0;!f||a.norequestanimationframe?(a.norequestanimationframe=null,a.countdown._timer=setinterval(function(){c._updateelems()},1e3)):(g=window.animationstarttime||window.webkitanimationstarttime||window.mozanimationstarttime||window.oanimationstarttime||window.msanimationstarttime||d(),f(b))},utcdate:function(a,b,c,d,e,f,g,h){"object"==typeof b&&b instanceof date&&(h=b.getmilliseconds(),g=b.getseconds(),f=b.getminutes(),e=b.gethours(),d=b.getdate(),c=b.getmonth(),b=b.getfullyear());var i=new date;return i.setutcfullyear(b),i.setutcdate(1),i.setutcmonth(c||0),i.setutcdate(d||1),i.setutchours(e||0),i.setutcminutes((f||0)-(math.abs(a)<30?60*a:a)),i.setutcseconds(g||0),i.setutcmilliseconds(h||0),i},periodstoseconds:function(a){return 31557600*a[0]+2629800*a[1]+604800*a[2]+86400*a[3]+3600*a[4]+60*a[5]+a[6]},resync:function(){var b=this;a("."+this._getmarker()).each(function(){var c=a.data(this,b.name);if(c.options.serversync){for(var d=null,e=0;e-1},_removeelem:function(b){this._timerelems=a.map(this._timerelems,function(a){return a===b?null:a})},_updateelems:function(){for(var a=this._timerelems.length-1;a>=0;a--)this._updatecountdown(this._timerelems[a])},_optionschanged:function(b,c,d){d.layout&&(d.layout=d.layout.replace(/</g,"<").replace(/>/g,">")),this._resetextralabels(c.options,d);var e=c.options.timezone!==d.timezone;a.extend(c.options,d),this._adjustsettings(b,c,!this._eqnull(d.until)||!this._eqnull(d.since)||e);var f=new date;(c._since&&c._sincef)&&this._addelem(b[0]),this._updatecountdown(b,c)},_updatecountdown:function(b,c){if(b=b.jquery?b:a(b),c=c||this._getinst(b)){if(b.html(this._generatehtml(c)).toggleclass(this._rtlclass,c.options.isrtl),"pause"!==c._hold&&a.isfunction(c.options.ontick)){var d="lap"!==c._hold?c._periods:this._calculateperiods(c,c._show,c.options.significant,new date);1!==c.options.tickinterval&&this.periodstoseconds(d)%c.options.tickinterval!==0||c.options.ontick.apply(b[0],[d])}var e="pause"!==c._hold&&(c._since?c._now.gettime()=c._until.gettime());if(e&&!c._expiring){if(c._expiring=!0,this._haselem(b[0])||c.options.alwaysexpire){if(this._removeelem(b[0]),a.isfunction(c.options.onexpiry)&&c.options.onexpiry.apply(b[0],[]),c.options.expirytext){var f=c.options.layout;c.options.layout=c.options.expirytext,this._updatecountdown(b[0],c),c.options.layout=f}c.options.expiryurl&&(window.location=c.options.expiryurl)}c._expiring=!1}else"pause"===c._hold&&this._removeelem(b[0])}},_resetextralabels:function(a,b){var c=null;for(c in b)c.match(/[ll]abels[02-9]|compactlabels1/)&&(a[c]=b[c]);for(c in a)c.match(/[ll]abels[02-9]|compactlabels1/)&&"undefined"==typeof b[c]&&(a[c]=null)},_eqnull:function(a){return"undefined"==typeof a||null===a},_adjustsettings:function(b,c,d){for(var e=null,f=0;f0,n[o]="?"!==b._show[o]||k?b._show[o]:null,l+=n[o]?1:0,m-=b._periods[o]>0?1:0;var p=[!1,!1,!1,!1,!1,!1,!1];for(o=i;o>=c;o--)b._show[o]&&(b._periods[o]?p[o]=!0:(p[o]=m>0,m--));var q=b.options.compact?b.options.compactlabels:b.options.labels,r=b.options.whichlabels||this._normallabels,s=function(a){var c=b.options["compactlabels"+r(b._periods[a])];return n[a]?j._translatedigits(b,b._periods[a])+(c?c[a]:q[a])+" ":""},t=b.options.padzeroes?2:1,u=function(a){var c=b.options["labels"+r(b._periods[a])];return!b.options.significant&&n[a]||b.options.significant&&p[a]?''+j._mindigits(b,b._periods[a],t)+''+(c?c[a]:q[a])+"":""};return b.options.layout?this._buildlayout(b,n,b.options.layout,b.options.compact,b.options.significant,p):(b.options.compact?''+s(c)+s(d)+s(e)+s(f)+(n[g]?this._mindigits(b,b._periods[g],2):"")+(n[h]?(n[g]?b.options.timeseparator:"")+this._mindigits(b,b._periods[h],2):"")+(n[i]?(n[g]||n[h]?b.options.timeseparator:"")+this._mindigits(b,b._periods[i],2):""):''+u(c)+u(d)+u(e)+u(f)+u(g)+u(h)+u(i))+""+(b.options.description?''+b.options.description+"":"")},_buildlayout:function(b,j,k,l,m,n){for(var o=b.options[l?"compactlabels":"labels"],p=b.options.whichlabels||this._normallabels,q=function(a){return(b.options[(l?"compactlabels":"labels")+p(b._periods[a])]||o)[a]},r=function(a,c){return b.options.digits[math.floor(a/c)%10]},s={desc:b.options.description,sep:b.options.timeseparator,yl:q(c),yn:this._mindigits(b,b._periods[c],1),ynn:this._mindigits(b,b._periods[c],2),ynnn:this._mindigits(b,b._periods[c],3),y1:r(b._periods[c],1),y10:r(b._periods[c],10),y100:r(b._periods[c],100),y1000:r(b._periods[c],1e3),ol:q(d),on:this._mindigits(b,b._periods[d],1),onn:this._mindigits(b,b._periods[d],2),onnn:this._mindigits(b,b._periods[d],3),o1:r(b._periods[d],1),o10:r(b._periods[d],10),o100:r(b._periods[d],100),o1000:r(b._periods[d],1e3),wl:q(e),wn:this._mindigits(b,b._periods[e],1),wnn:this._mindigits(b,b._periods[e],2),wnnn:this._mindigits(b,b._periods[e],3),w1:r(b._periods[e],1),w10:r(b._periods[e],10),w100:r(b._periods[e],100),w1000:r(b._periods[e],1e3),dl:q(f),dn:this._mindigits(b,b._periods[f],1),dnn:this._mindigits(b,b._periods[f],2),dnnn:this._mindigits(b,b._periods[f],3),d1:r(b._periods[f],1),d10:r(b._periods[f],10),d100:r(b._periods[f],100),d1000:r(b._periods[f],1e3),hl:q(g),hn:this._mindigits(b,b._periods[g],1),hnn:this._mindigits(b,b._periods[g],2),hnnn:this._mindigits(b,b._periods[g],3),h1:r(b._periods[g],1),h10:r(b._periods[g],10),h100:r(b._periods[g],100),h1000:r(b._periods[g],1e3),ml:q(h),mn:this._mindigits(b,b._periods[h],1),mnn:this._mindigits(b,b._periods[h],2),mnnn:this._mindigits(b,b._periods[h],3),m1:r(b._periods[h],1),m10:r(b._periods[h],10),m100:r(b._periods[h],100),m1000:r(b._periods[h],1e3),sl:q(i),sn:this._mindigits(b,b._periods[i],1),snn:this._mindigits(b,b._periods[i],2),snnn:this._mindigits(b,b._periods[i],3),s1:r(b._periods[i],1),s10:r(b._periods[i],10),s100:r(b._periods[i],100),s1000:r(b._periods[i],1e3)},t=k,u=c;u<=i;u++){var v="yowdhms".charat(u),w=new regexp("\\{"+v+"<\\}([\\s\\s]*)\\{"+v+">\\}","g");t=t.replace(w,!m&&j[u]||m&&n[u]?"$1":"")}return a.each(s,function(a,b){var c=new regexp("\\{"+a+"\\}","g");t=t.replace(c,b)}),t},_mindigits:function(a,b,c){return b=""+b,b.length>=c?this._translatedigits(a,b):(b="0000000000"+b,this._translatedigits(a,b.substr(b.length-c)))},_translatedigits:function(a,b){return(""+b).replace(/[0-9]/g,function(b){return a.options.digits[b]})},_determineshow:function(a){var b=a.options.format,j=[];return j[c]=b.match("y")?"?":b.match("y")?"!":null,j[d]=b.match("o")?"?":b.match("o")?"!":null,j[e]=b.match("w")?"?":b.match("w")?"!":null,j[f]=b.match("d")?"?":b.match("d")?"!":null,j[g]=b.match("h")?"?":b.match("h")?"!":null,j[h]=b.match("m")?"?":b.match("m")?"!":null,j[i]=b.match("s")?"?":b.match("s")?"!":null,j},_calculateperiods:function(a,b,j,k){a._now=k,a._now.setmilliseconds(0);var l=new date(a._now.gettime());a._since?k.gettime()a._until.gettime()&&(a._now=k=l));var m=[0,0,0,0,0,0,0];if(b[c]||b[d]){var n=this._getdaysinmonth(k.getfullyear(),k.getmonth()),o=this._getdaysinmonth(l.getfullyear(),l.getmonth()),p=l.getdate()===k.getdate()||l.getdate()>=math.min(n,o)&&k.getdate()>=math.min(n,o),q=function(a){return 60*(60*a.gethours()+a.getminutes())+a.getseconds()},r=math.max(0,12*(l.getfullyear()-k.getfullyear())+l.getmonth()-k.getmonth()+(l.getdate()t&&k.setdate(t),k.setfullyear(k.getfullyear()+m[c]),k.setmonth(k.getmonth()+m[d]),s&&k.setdate(t)}var u=math.floor((l.gettime()-k.gettime())/1e3),v=null,w=function(a,c){m[a]=b[a]?math.floor(u/c):0,u-=m[a]*c};if(w(e,604800),w(f,86400),w(g,3600),w(h,60),w(i,1),u>0&&!a._since){var x=[1,12,4.3482,7,24,60,60],y=i,z=1;for(v=i;v>=c;v--)b[v]&&(m[y]>=z&&(m[y]=0,u=1),u>0&&(m[v]++,u=0,y=v,z=1)),z*=x[v]}if(j)for(v=c;v<=i;v++)j&&m[v]?j--:j||(m[v]=0);return m}})}(jquery);