(function(n){var o=function(n,t){typeof t=="undefined"&&(t={});this.init(n,t)},t=o.prototype,f,e=["canvas","vml"],i=["oval","spiral","square","rect","roundRect"],a=/^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/,c=navigator.appVersion.indexOf("MSIE")!==-1&&parseFloat(navigator.appVersion.split("MSIE")[1])===8?!0:!1,v=!!document.createElement("canvas").getContext,l=!0,u=function(n,t,i){var n=document.createElement(n);for(var r in i)n[r]=i[r];return typeof t!="undefined"&&t.appendChild(n),n},r=function(n,t){for(var i in t)n.style[i]=t[i];return n},s=function(n,t){for(var i in t)n.setAttribute(i,t[i]);return n},h=function(n,t,i,r){n.save();n.translate(t,i);n.rotate(r);n.translate(-t,-i);n.beginPath()};t.init=function(n,t){typeof t.safeVML=="boolean"&&(l=t.safeVML);try{this.mum=document.getElementById(n)!==void 0?document.getElementById(n):document.body}catch(h){this.mum=document.body}if(t.id=typeof t.id!="undefined"?t.id:"canvasLoader",this.cont=u("div",this.mum,{id:t.id}),v)f=e[0],this.can=u("canvas",this.cont),this.con=this.can.getContext("2d"),this.cCan=r(u("canvas",this.cont),{display:"none"}),this.cCon=this.cCan.getContext("2d");else{if(f=e[1],typeof o.vmlSheet=="undefined"){document.getElementsByTagName("head")[0].appendChild(u("style"));o.vmlSheet=document.styleSheets[document.styleSheets.length-1];var i=["group","oval","roundrect","fill"];for(var s in i)o.vmlSheet.addRule(i[s],"behavior:url(#default#VML); position:absolute;")}this.vml=u("group",this.cont)}this.setColor(this.color);this.draw();r(this.cont,{display:"none"})};t.cont={};t.can={};t.con={};t.cCan={};t.cCon={};t.timer={};t.activeId=0;t.diameter=40;t.setDiameter=function(n){this.diameter=Math.round(Math.abs(n));this.redraw()};t.getDiameter=function(){return this.diameter};t.cRGB={};t.color="#000000";t.setColor=function(n){this.color=a.test(n)?n:"#000000";this.cRGB=this.getRGB(this.color);this.redraw()};t.getColor=function(){return this.color};t.shape=i[0];t.setShape=function(n){for(var t in i)if(n===i[t]){this.shape=n;this.redraw();break}};t.getShape=function(){return this.shape};t.density=40;t.setDensity=function(n){this.density=l&&f===e[1]?Math.round(Math.abs(n))<=40?Math.round(Math.abs(n)):40:Math.round(Math.abs(n));this.density>360&&(this.density=360);this.activeId=0;this.redraw()};t.getDensity=function(){return this.density};t.range=1.3;t.setRange=function(n){this.range=Math.abs(n);this.redraw()};t.getRange=function(){return this.range};t.speed=2;t.setSpeed=function(n){this.speed=Math.round(Math.abs(n))};t.getSpeed=function(){return this.speed};t.fps=24;t.setFPS=function(n){this.fps=Math.round(Math.abs(n));this.reset()};t.getFPS=function(){return this.fps};t.getRGB=function(n){return n=n.charAt(0)==="#"?n.substring(1,7):n,{r:parseInt(n.substring(0,2),16),g:parseInt(n.substring(2,4),16),b:parseInt(n.substring(4,6),16)}};t.draw=function(){var w=0,t,y,n,l,a,d,p,k=this.density,g=Math.round(k*this.range),b,v,nt=0,o;if(v=this.cCon,o=this.diameter,f===e[0])for(v.clearRect(0,0,1e3,1e3),s(this.can,{width:o,height:o}),s(this.cCan,{width:o,height:o});w<k;){b=w<=g?1-1/g*w:b=0;d=270-360/k*w;p=d/180*Math.PI;v.fillStyle="rgba("+this.cRGB.r+","+this.cRGB.g+","+this.cRGB.b+","+b.toString()+")";switch(this.shape){case i[0]:case i[1]:t=o*.07;l=o*.47+Math.cos(p)*(o*.47-t)-o*.47;a=o*.47+Math.sin(p)*(o*.47-t)-o*.47;v.beginPath();this.shape===i[1]?v.arc(o*.5+l,o*.5+a,t*b,0,Math.PI*2,!1):v.arc(o*.5+l,o*.5+a,t,0,Math.PI*2,!1);break;case i[2]:t=o*.12;l=Math.cos(p)*(o*.47-t)+o*.5;a=Math.sin(p)*(o*.47-t)+o*.5;h(v,l,a,p);v.fillRect(l,a-t*.5,t,t);break;case i[3]:case i[4]:y=o*.3;n=y*.27;l=Math.cos(p)*(n+(o-n)*.13)+o*.5;a=Math.sin(p)*(n+(o-n)*.13)+o*.5;h(v,l,a,p);this.shape===i[3]?v.fillRect(l,a-n*.5,y,n):(t=n*.55,v.moveTo(l+t,a-n*.5),v.lineTo(l+y-t,a-n*.5),v.quadraticCurveTo(l+y,a-n*.5,l+y,a-n*.5+t),v.lineTo(l+y,a-n*.5+n-t),v.quadraticCurveTo(l+y,a-n*.5+n,l+y-t,a-n*.5+n),v.lineTo(l+t,a-n*.5+n),v.quadraticCurveTo(l,a-n*.5+n,l,a-n*.5+n-t),v.lineTo(l,a-n*.5+t),v.quadraticCurveTo(l,a-n*.5,l+t,a-n*.5))}v.closePath();v.fill();v.restore();++w}else{r(this.cont,{width:o,height:o});r(this.vml,{width:o,height:o});switch(this.shape){case i[0]:case i[1]:p="oval";t=140;break;case i[2]:p="roundrect";t=120;break;case i[3]:case i[4]:p="roundrect";t=300}for(y=n=t,l=500-n,a=-n*.5;w<k;){b=w<=g?1-1/g*w:b=0;d=270-360/k*w;switch(this.shape){case i[1]:y=n=t*b;l=500-t*.5-t*b*.5;a=(t-t*b)*.5;break;case i[0]:case i[2]:c&&(a=0,this.shape===i[2]&&(l=500-n*.5));break;case i[3]:case i[4]:y=t*.95;n=y*.28;c?(l=0,a=500-n*.5):(l=500-y,a=-n*.5);nt=this.shape===i[4]?.6:0}v=s(r(u("group",this.vml),{width:1e3,height:1e3,rotation:d}),{coordsize:"1000,1000",coordorigin:"-500,-500"});v=r(u(p,v,{stroked:!1,arcSize:nt}),{width:y,height:n,top:a,left:l});u("fill",v,{color:this.color,opacity:b});++w}}this.tick(!0)};t.clean=function(){if(f===e[0])this.con.clearRect(0,0,1e3,1e3);else{var n=this.vml;if(n.hasChildNodes())for(;n.childNodes.length>=1;)n.removeChild(n.firstChild)}};t.redraw=function(){this.clean();this.draw()};t.reset=function(){typeof this.timer=="number"&&(this.hide(),this.show())};t.tick=function(n){var i=this.con,t=this.diameter;n||(this.activeId+=360/this.density*this.speed);f===e[0]?(i.clearRect(0,0,t,t),h(i,t*.5,t*.5,this.activeId/180*Math.PI),i.drawImage(this.cCan,0,0,t,t),i.restore()):(this.activeId>=360&&(this.activeId-=360),r(this.vml,{rotation:this.activeId}))};t.show=function(){if(typeof this.timer!="number"){var n=this;this.timer=self.setInterval(function(){n.tick()},Math.round(1e3/this.fps));r(this.cont,{display:"block"})}};t.hide=function(){typeof this.timer=="number"&&(clearInterval(this.timer),delete this.timer,r(this.cont,{display:"none"}))};t.kill=function(){var n=this.cont,t;typeof this.timer=="number"&&this.hide();f===e[0]?(n.removeChild(this.can),n.removeChild(this.cCan)):n.removeChild(this.vml);for(t in this)delete this[t]};n.CanvasLoader=o})(window)