!function(t){function e(t){var e=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;t=t.replace(e,function(t,e,a,i){return e+e+a+a+i+i});var a=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return a?{r:parseInt(a[1],16),g:parseInt(a[2],16),b:parseInt(a[3],16)}:null}function a(){var t=document.createElement("canvas");return!(!t.getContext||!t.getContext("2d"))}function i(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function n(){return i()+i()+"-"+i()+"-"+i()+"-"+i()+"-"+i()+i()+i()}function s(t){var e=t.match(/^[0-9]{4}-[0-9]{2}-[0-9]{2}\s[0-9]{1,2}:[0-9]{2}:[0-9]{2}$/);if(null!==e&&e.length>0){var a=t.split(" "),i=a[0].split("-"),n=a[1].split(":");return new Date(i[0],i[1]-1,i[2],n[0],n[1],n[2])}var s=Date.parse(t);return isNaN(s)?(s=Date.parse(t.replace(/-/g,"/").replace("T"," ")),isNaN(s)?new Date:s):s}function r(t,e,a,i,n){for(var s={},r={},o={},h={},d={},u={},l=null,f=0;f0?Math.floor(_):Math.ceil(_),b=b>0?Math.floor(b):Math.ceil(b)),"Days"!==p&&(_%=c,b%=c),s[p]=_,o[p]=Math.abs(_),r[p]=b,u[p]=Math.abs(b),h[p]=Math.abs(_)/c,d[p]=Math.abs(b)/c,l=p}return{raw_time:s,raw_old_time:r,time:o,old_time:u,pct:h,old_pct:d}}function o(){"undefined"!=typeof d.TC_Instance_List?p=d.TC_Instance_List:d.TC_Instance_List=p,h(d)}function h(t){for(var e=["webkit","moz"],a=0;ar;r++)t.call(n,a[r])&&o.push(a[r]);return o}}());var u=!1,l=200,f=("#debug"===location.hash,["Days","Hours","Minutes","Seconds"]),c={Seconds:"Minutes",Minutes:"Hours",Hours:"Days",Days:"Years"},m={Seconds:1,Minutes:60,Hours:3600,Days:86400,Months:2678400,Years:31536e3};Array.prototype.indexOf||(Array.prototype.indexOf=function(t){var e=this.length>>>0,a=Number(arguments[1])||0;for(a=0>a?Math.ceil(a):Math.floor(a),0>a&&(a+=e);e>a;a++)if(a in this&&this[a]===t)return a;return-1});var p={},_=function(t,e){this.element=t,this.container,this.listeners=null,this.data={paused:!1,last_frame:0,animation_frame:null,interval_fallback:null,timer:!1,total_duration:null,prev_time:null,drawn_units:[],text_elements:{Days:null,Hours:null,Minutes:null,Seconds:null},attributes:{canvas:null,context:null,item_size:null,line_width:null,radius:null,outer_radius:null},state:{fading:{Days:!1,Hours:!1,Minutes:!1,Seconds:!1}}},this.config=null,this.setOptions(e),this.initialize()};_.prototype.clearListeners=function(){this.listeners={all:[],visible:[]}},_.prototype.addTime=function(t){if(this.data.attributes.ref_date instanceof Date){var e=this.data.attributes.ref_date;e.setSeconds(e.getSeconds()+t)}else isNaN(this.data.attributes.ref_date)||(this.data.attributes.ref_date+=1e3*t)},_.prototype.initialize=function(e){this.data.drawn_units=[];for(var i=0;i"),this.container.addClass("time_circles"),this.container.appendTo(this.element);var s=this.element.offsetHeight,r=this.element.offsetWidth;0===s&&(s=t(this.element).height()),0===r&&(r=t(this.element).width()),0===s&&r>0?s=r/this.data.drawn_units.length:0===r&&s>0&&(r=s*this.data.drawn_units.length);var o=document.createElement("canvas");o.width=r,o.height=s,this.data.attributes.canvas=t(o),this.data.attributes.canvas.appendTo(this.container);var h=a();h||"undefined"==typeof G_vmlCanvasManager||(G_vmlCanvasManager.initElement(o),u=!0,h=!0),h&&(this.data.attributes.context=o.getContext("2d")),this.data.attributes.item_size=Math.min(r/this.data.drawn_units.length,s),this.data.attributes.line_width=this.data.attributes.item_size*this.config.fg_width,this.data.attributes.radius=(.8*this.data.attributes.item_size-this.data.attributes.line_width)/2,this.data.attributes.outer_radius=this.data.attributes.radius+.5*Math.max(this.data.attributes.line_width,this.data.attributes.line_width*this.config.bg_width);var i=0;for(var l in this.data.text_elements)if(this.config.time[l].show){var f=t("
");f.addClass("textDiv_"+l),f.css("top",Math.round(.35*this.data.attributes.item_size)),f.css("left",Math.round(i++*this.data.attributes.item_size)),f.css("width",this.data.attributes.item_size),f.appendTo(this.container);var c=t("");c.appendTo(f);var m=t("");m.text(this.config.time[l].text),m.appendTo(f),this.data.text_elements[l]=c}this.start(),this.config.start||(this.data.paused=!0);var p=this;this.data.interval_fallback=d.setInterval(function(){p.update.call(p,!0)},100)},_.prototype.update=function(t){if("undefined"==typeof t)t=!1;else if(t&&this.data.paused)return;u&&this.data.attributes.context.clearRect(0,0,this.data.attributes.canvas[0].width,this.data.attributes.canvas[0].hright);var e,a,i=this.data.prev_time,n=new Date;if(this.data.prev_time=n,null===i&&(i=n),!this.config.count_past_zero&&n>this.data.attributes.ref_date){for(var s=0;sMath.floor(b.old_time[y])?(this.radialFade(h,c,p,1,o),this.data.state.fading[o]=!0):Math.floor(b.time[y])A&&(A=1e3+A),A+=50,M.data.animation_frame=d.setTimeout(function(){M.data.animation_frame=d.requestAnimationFrame(x,M.element,M)},A)}}},_.prototype.animateArc=function(t,e,a,i,n,s){if(null!==this.data.attributes.context){var r=n-i;if(Math.abs(r)>.5)0===i?this.radialFade(t,e,a,1):this.radialFade(t,e,a,0);else{var o=(l-(s-(new Date).getTime()))/l;o>1&&(o=1);var h=n*(1-o)+i*o;if(this.drawArc(t,e,a,h),o>=1)return;var u=this;d.requestAnimationFrame(function(){u.animateArc(t,e,a,i,n,s)},this.element)}}},_.prototype.drawArc=function(t,e,a,i){if(null!==this.data.attributes.context){var n=Math.max(this.data.attributes.outer_radius,this.data.attributes.item_size/2);u||this.data.attributes.context.clearRect(t-n,e-n,2*n,2*n),this.config.use_background&&(this.data.attributes.context.beginPath(),this.data.attributes.context.arc(t,e,this.data.attributes.radius,0,2*Math.PI,!1),this.data.attributes.context.lineWidth=this.data.attributes.line_width*this.config.bg_width,this.data.attributes.context.strokeStyle=this.config.circle_bg_color,this.data.attributes.context.stroke());var s,r,o,h=-.5*Math.PI,d=2*Math.PI;s=h+this.config.start_angle/360*d;var l=2*i*Math.PI;"Both"===this.config.direction?(o=!1,s-=l/2,r=s+l):"Clockwise"===this.config.direction?(o=!1,r=s+l):(o=!0,r=s-l),this.data.attributes.context.beginPath(),this.data.attributes.context.arc(t,e,this.data.attributes.radius,s,r,o),this.data.attributes.context.lineWidth=this.data.attributes.line_width,this.data.attributes.context.strokeStyle=a,this.data.attributes.context.stroke()}},_.prototype.radialFade=function(t,a,i,n,s){var r,o=e(i),h=this,u=.2*(1===n?-1:1);for(r=0;1>=n&&n>=0;r++)!function(){var e=50*r,i="rgba("+o.r+", "+o.g+", "+o.b+", "+Math.round(10*n)/10+")";d.setTimeout(function(){h.drawArc(t,a,i,1)},e)}(),n+=u;void 0!==typeof s&&d.setTimeout(function(){h.data.state.fading[s]=!1},50*r)},_.prototype.timeLeft=function(){if(this.data.paused&&"number"==typeof this.data.timer)return this.data.timer;var t=new Date;return(this.data.attributes.ref_date-t)/1e3},_.prototype.start=function(){d.cancelAnimationFrame(this.data.animation_frame),d.clearTimeout(this.data.animation_frame);var e=t(this.element).data("date");if("undefined"==typeof e&&(e=t(this.element).attr("data-date")),"string"==typeof e)this.data.attributes.ref_date=s(e);else if("number"==typeof this.data.timer)this.data.paused&&(this.data.attributes.ref_date=(new Date).getTime()+1e3*this.data.timer);else{var a=t(this.element).data("timer");"undefined"==typeof a&&(a=t(this.element).attr("data-timer")),"string"==typeof a&&(a=parseFloat(a)),"number"==typeof a?(this.data.timer=a,this.data.attributes.ref_date=(new Date).getTime()+1e3*a):this.data.attributes.ref_date=this.config.ref_date}this.data.paused=!1,this.update.call(this)},_.prototype.restart=function(){this.data.timer=!1,this.start()},_.prototype.stop=function(){"number"==typeof this.data.timer&&(this.data.timer=this.timeLeft(this)),this.data.paused=!0,d.cancelAnimationFrame(this.data.animation_frame)},_.prototype.destroy=function(){this.clearListeners(),this.stop(),d.clearInterval(this.data.interval_fallback),this.data.interval_fallback=null,this.container.remove(),t(this.element).removeAttr("data-tc-id"),t(this.element).removeData("tc-id")},_.prototype.setOptions=function(e){if(null===this.config&&(this.default_options.ref_date=new Date,this.config=t.extend(!0,{},this.default_options)),t.extend(!0,this.config,e),d=this.config.use_top_frame?window.top:window,o(),this.data.total_duration=this.config.total_duration,"string"==typeof this.data.total_duration)if("undefined"!=typeof m[this.data.total_duration])this.data.total_duration=m[this.data.total_duration];else if("Auto"===this.data.total_duration)for(var a=0;a