window.CoolClock=function(a){return this.init(a)};CoolClock.config={tickDelay:1000,longTickDelay:15000,defaultRadius:85,renderRadius:100,defaultSkin:"chunkySwiss",showSecs:true,showAmPm:true,skins:{swissRail:{outerBorder:{lineWidth:2,radius:95,color:"black",alpha:1},smallIndicator:{lineWidth:2,startAt:88,endAt:92,color:"black",alpha:1},largeIndicator:{lineWidth:4,startAt:79,endAt:92,color:"black",alpha:1},hourHand:{lineWidth:8,startAt:-15,endAt:50,color:"red",alpha:1},minuteHand:{lineWidth:7,startAt:-15,endAt:75,color:"red",alpha:1},secondHand:{lineWidth:1,startAt:-20,endAt:85,color:"red",alpha:1},secondDecoration:{lineWidth:1,startAt:70,radius:4,fillColor:"red",color:"red",alpha:1}},chunkySwiss:{outerBorder:{lineWidth:4,radius:97,color:"black",alpha:1},smallIndicator:{lineWidth:4,startAt:89,endAt:93,color:"black",alpha:1},largeIndicator:{lineWidth:8,startAt:80,endAt:93,color:"black",alpha:1},hourHand:{lineWidth:12,startAt:-15,endAt:60,color:"red",alpha:1},minuteHand:{lineWidth:10,startAt:-15,endAt:85,color:"red",alpha:1},secondHand:{lineWidth:4,startAt:-20,endAt:85,color:"red",alpha:1},secondDecoration:{lineWidth:2,startAt:70,radius:8,fillColor:"red",color:"red",alpha:1}},chunkySwissOnBlack:{outerBorder:{lineWidth:4,radius:97,color:"white",alpha:1},smallIndicator:{lineWidth:4,startAt:89,endAt:93,color:"white",alpha:1},largeIndicator:{lineWidth:8,startAt:80,endAt:93,color:"white",alpha:1},hourHand:{lineWidth:12,startAt:-15,endAt:60,color:"white",alpha:1},minuteHand:{lineWidth:10,startAt:-15,endAt:85,color:"white",alpha:1},secondHand:{lineWidth:4,startAt:-20,endAt:85,color:"red",alpha:1},secondDecoration:{lineWidth:2,startAt:70,radius:8,fillColor:"red",color:"red",alpha:1}}},isIE:!!document.all,clockTracker:{},noIdCount:0};CoolClock.prototype={init:function(a){this.canvasId=a.canvasId;this.skinId=a.skinId||CoolClock.config.defaultSkin;this.displayRadius=a.displayRadius||CoolClock.config.defaultRadius;this.showSecondHand=typeof a.showSecondHand=="boolean"?a.showSecondHand:true;this.gmtOffset=(a.gmtOffset!=null&&a.gmtOffset!="")?parseFloat(a.gmtOffset):null;this.showDigital=typeof a.showDigital=="boolean"?a.showDigital:false;this.logClock=typeof a.logClock=="boolean"?a.logClock:false;this.logClockRev=typeof a.logClock=="boolean"?a.logClockRev:false;this.tickDelay=CoolClock.config[this.showSecondHand?"tickDelay":"longTickDelay"];this.canvas=document.getElementById(this.canvasId);this.canvas.setAttribute("width",this.displayRadius*2);this.canvas.setAttribute("height",this.displayRadius*2);this.canvas.style.width=this.displayRadius*2+"px";this.canvas.style.height=this.displayRadius*2+"px";this.renderRadius=CoolClock.config.renderRadius;this.scale=this.displayRadius/this.renderRadius;this.ctx=this.canvas.getContext("2d");this.ctx.scale(this.scale,this.scale);CoolClock.config.clockTracker[this.canvasId]=this;this.tick();return this},fullCircleAt:function(a,c,b){this.ctx.save();this.ctx.globalAlpha=b.alpha;this.ctx.lineWidth=b.lineWidth;if(!CoolClock.config.isIE){this.ctx.beginPath()}if(CoolClock.config.isIE){this.ctx.lineWidth=this.ctx.lineWidth*this.scale}this.ctx.arc(a,c,b.radius,0,2*Math.PI,false);if(CoolClock.config.isIE){this.ctx.arc(a,c,b.radius,-0.1,0.1,false)}if(b.fillColor){this.ctx.fillStyle=b.fillColor;this.ctx.fill()}else{this.ctx.strokeStyle=b.color;this.ctx.stroke()}this.ctx.restore()},drawTextAt:function(b,a,d){this.ctx.save();this.ctx.font="15px sans-serif";var c=this.ctx.measureText(b);if(!c.height){c.height=15}this.ctx.fillText(b,a-c.width/2,d-c.height/2);this.ctx.restore()},lpad2:function(a){return(a<10?"0":"")+a},tickAngle:function(a){var b=3;if(this.logClock){return a==0?0:(Math.log(a*b)/Math.log(60*b))}else{if(this.logClockRev){a=(60-a)%60;return 1-(a==0?0:(Math.log(a*b)/Math.log(60*b)))}else{return a/60}}},timeText:function(a,b,d){var e=CoolClock.config;return""+(e.showAmPm?((a%12)==0?12:(a%12)):a)+":"+this.lpad2(b)+(e.showSecs?":"+this.lpad2(d):"")+(e.showAmPm?(a<12?" am":" pm"):"")},radialLineAtAngle:function(b,a){this.ctx.save();this.ctx.translate(this.renderRadius,this.renderRadius);this.ctx.rotate(Math.PI*(2*b-0.5));this.ctx.globalAlpha=a.alpha;this.ctx.strokeStyle=a.color;this.ctx.lineWidth=a.lineWidth;if(CoolClock.config.isIE){this.ctx.lineWidth=this.ctx.lineWidth*this.scale}if(a.radius){this.fullCircleAt(a.startAt,0,a)}else{this.ctx.beginPath();this.ctx.moveTo(a.startAt,0);this.ctx.lineTo(a.endAt,0);this.ctx.stroke()}this.ctx.restore()},render:function(a,c,d){var e=CoolClock.config.skins[this.skinId];if(!e){e=CoolClock.config.skins[CoolClock.config.defaultSkin]}this.ctx.clearRect(0,0,this.renderRadius*2,this.renderRadius*2);if(e.outerBorder){this.fullCircleAt(this.renderRadius,this.renderRadius,e.outerBorder)}for(var b=0;b<60;b++){(b%5)&&e.smallIndicator&&this.radialLineAtAngle(this.tickAngle(b),e.smallIndicator);!(b%5)&&e.largeIndicator&&this.radialLineAtAngle(this.tickAngle(b),e.largeIndicator)}if(this.showDigital){this.drawTextAt(this.timeText(a,c,d),this.renderRadius,this.renderRadius+this.renderRadius/2)}if(e.hourHand){this.radialLineAtAngle(this.tickAngle(((a%12)*5+c/60)),e.hourHand)}if(e.minuteHand){this.radialLineAtAngle(this.tickAngle((c+d/60)),e.minuteHand)}if(this.showSecondHand&&e.secondHand){this.radialLineAtAngle(this.tickAngle(d),e.secondHand)}if(!CoolClock.config.isIE&&this.showSecondHand&&e.secondDecoration){this.radialLineAtAngle(this.tickAngle(d),e.secondDecoration)}},refreshDisplay:function(){var b=new Date();if(this.gmtOffset!=null){var a=new Date(b.valueOf()+(this.gmtOffset*1000*60*60));this.render(a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds())}else{this.render(b.getHours(),b.getMinutes(),b.getSeconds())}},nextTick:function(){setTimeout("CoolClock.config.clockTracker['"+this.canvasId+"'].tick()",this.tickDelay)},stillHere:function(){return document.getElementById(this.canvasId)!=null},tick:function(){if(this.stillHere()){this.refreshDisplay();this.nextTick()}}};CoolClock.findAndCreateClocks=function(){var c=document.getElementsByTagName("canvas");for(var b=0;b<c.length;b++){var a=c[b].className.split(" ")[0].split(":");if(a[0]=="CoolClock"){if(!c[b].id){c[b].id="_coolclock_auto_id_"+CoolClock.config.noIdCount++}new CoolClock({canvasId:c[b].id,skinId:a[1],displayRadius:a[2],showSecondHand:a[3]!="noSeconds",gmtOffset:a[4],showDigital:a[5]=="showDigital",logClock:a[6]=="logClock",logClockRev:a[6]=="logClockRev"})}}};if(window.jQuery){jQuery(document).ready(CoolClock.findAndCreateClocks)};
