/* Copyright (c) Microsoft Corporation. All rights reserved.*/ function __initCanvas() { if(window.ActiveXObject&&document.namespaces) { document.namespaces.add("v","urn:schemas-microsoft-com:vml","#default#VML"); var cv=document.body.getElementsByTagName("canvas"); for(var i=0;i<cv.length;++i) { var c=cv[i]; c.parentNode.replaceChild(__makeCanvas(c),c); } } } function __gd() { var d=document.getElementById('__deb'); if(!d) { d=document.createElement("div");d.id="__deb";document.body.appendChild(d); } return d; } function __info() { return "Shapes:"+this.childNodes.length; } function deb(s){__gd().innerHTML+=s;} function debLn(s){deb(s+"<br>");} function __removeAllChildren(d) { while(d.hasChildNodes()){d.removeChild(d.childNodes[0]);} } function __makeCanvas(cvs) { /*copy style*/ var s=cvs.style.cssText+";width:"+cvs.width+"px;height:"+cvs.height+"px;overflow:hidden"; /*copy attributes (including events)*/ var t=""; for(var i=0;i<cvs.attributes.length;++i){ var a=cvs.attributes[i];
if(a.specified)t+=a.nodeName+"='"+a.nodeValue+"' "; } /*hack*/ var div=document.createElement("div"); div.innerHTML="<div id='"+cvs.id+"' style='"+s+"' "+t+"></div>"; div=div.removeChild(div.childNodes[0]); div.getContext=__getContext; div.width=parseInt(cvs.width); div.height=parseInt(cvs.height); div._info=__info; return div; } function __getContext(typ) { if(typ=="2d"){ /*firefox apparently shares context state across multiple contexts*/ if(this._context)return this._context; return (this._context=new __Context(this)); } return null; } /*State*/ function __State(c) { this._copy(this,c,false); } __State.prototype.restore=function(c) { this._copy(c,this,true); }; __State.prototype._copy=function(t,f,r) { t.strokeStyle=f.strokeStyle; t.fillStyle=f.fillStyle; t.globalAlpha=f.globalAlpha; t.lineWidth=f.lineWidth; t.lineCap=f.lineCap; t.lineJoin=f.lineJoin; t.miterLimit=f.miterLimit; t.globalCompositeOperation=f.globalCompositeOperation; t.shadowBlur=f.shadowBlur; t.shadowColor=f.shadowColor;
t.shadowOffsetX=f.shadowOffsetX; t.shadowOffsetY=f.shadowOffsetY; t._tm=(r?f._tm:f._tm.clone()); t._clip=f._clip; t._rot=f._rot; }; function __Context(cvs) { this.div=cvs; this.lineWidth=1; this.strokeStyle='#000'; this.fillStyle='#fff'; this.globalAlpha=1; this.globalCompositeOperation="source-over"; this.lineCap="butt"; this.lineJoin="miter"; this.miterLimit=1; this.shadowBlur=0; this.shadowColor="#000"; this.shadowOffsetX=0; this.shadowOffsetY=0; this._rot=0; this._clip=null; this._tm=new __TM(); this._grid=4; this._tm.scale(this._grid,this._grid); this._state=[]; } __Context._hex="0123456789abcdef"; __Context._hexNum=function(n){return __Context._hex.charAt((n>>4)&0xf)+__Context._hex.charAt(n&0xf);}; __Context._rgba=function(r,g,b,a) { return ["#"+__Context._hexNum(r)+__Context._hexNum(g)+__Context._hexNum(b),a]; }; __Context._rgb=function(r,g,b) { return ["#"+__Context._hexNum(r)+__Context._hexNum(g)+__Context._hexNum(b),1]; }; __Context.prototype._applyColor=function(p,col) {
if(typeof(col)=="object"){ /*gradient or pattern*/ col.apply(p); }else{ if(col.charAt(0)=="#"){ /*#RGB*/ p.color=col; p.opacity=this.globalAlpha; }else if(col.substr(0,3)=="rgb"){ /*rgb() or rgba()*/ var cx; eval("cx=__Context._"+col); p.color=cx[0]; p.opacity=cx[1]*this.globalAlpha; }else{ /*color name(?)*/ p.color=col; p.opacity=this.globalAlpha; } } }; __Context.prototype.clearRect=function(x,y,w,h) { if((x<=0)&&(y<=0)&&(x+w>=this.div.width)&&(y+h>=this.div.height)) { __removeAllChildren(this.div); } else { /*clear adds more stuff...*/ var f0=this.fillStyle; this.fillStyle='#fff'; this.fillRect(x,y,w,h); this.fillStyle=f0; } }; __Context.prototype.beginPath=function() { this.path=""; this.moved=false; }; __Context.prototype.moveTo=function(x,y) { this.path+="m"+this._tm.transS(x,y); this.moved=true; }; __Context.prototype.lineTo=function(x,y) { this.path+=(this.moved?"l":",")+this._tm.transS(x,y); this.moved=false; }; __Context.prototype.closePath=function() { this.path+="x"; };
__Context.prototype.stroke=function() { if(this.path.length==0)return; var s=document.createElement("v:shape"); this.div.appendChild(s); s.path=this.path+"e"; this.path=""; s.stroked=true; s.filled=false; this._applyColor(s.stroke,this.strokeStyle); s.stroke.endcap=(this.lineCap=='butt'?'flat':this.lineCap); s.stroke.joinstyle=this.lineJoin; s.strokeweight=0.8*this.lineWidth; s.coordsize=this._grid*1000+","+this._grid*1000; s.style.position="absolute"; s.style.width=1000; s.style.height=1000; }; __Context.prototype.fill=function() { if(this.path.length==0)return; var s=document.createElement("v:shape"); s.filled=true; s.stroked=false; this._applyColor(s.fill,this.fillStyle); s.coordsize=this._grid*1000+","+this._grid*1000; s.style.position="absolute"; s.style.width=1000; s.style.height=1000; s.path=this.path+"xe"; this.path=""; this.div.appendChild(s); }; __Context.prototype.fillRect=function(x,y,w,h) { this.rect(x,y,w,h); this.fill() }; __Context.prototype.strokeRect=function(x,y,w,h) { this.rect(x,y,w,h);
this.stroke(); }; __Context.prototype.rect=function(x,y,w,h) { var tm=this._tm; this.path+="m"+tm.transS(x,y)+"l"+tm.transS(x+w,y)+","+tm.transS(x+w,y+h)+","+tm.transS(x,y+h)+"x"; }; function __idiotArc(ctx,x,y,rad,a0,a1,cw) { var sx=(x+Math.cos(a0)*rad); var sy=(y+Math.sin(a0)*rad); var ex=(x+Math.cos(a1)*rad); var ey=(y+Math.sin(a1)*rad); var da=Math.PI/24; ctx.lineTo(sx,sy); if(cw){ if (a0<a1)a0+=2*Math.PI; while(a0-da>a1){ a0-=da; ctx.lineTo(x+Math.cos(a0)*rad,y+Math.sin(a0)*rad); } }else{ if (a1<a0)a1+=2*Math.PI; while(a0+da<a1){ a0+=da; ctx.lineTo(x+Math.cos(a0)*rad,y+Math.sin(a0)*rad); } } ctx.lineTo(ex,ey); } __Context.prototype.arc=function(x,y,rad,a0,a1,cw) { if(this._rot!=0){__idiotArc(this,x,y,rad,a0,a1,cw);return;} var l=(x-rad); var t=(y-rad); var r=(x+rad); var b=(y+rad); var sx=(x+Math.cos(a0)*rad); var sy=(y+Math.sin(a0)*rad); var ex=(x+Math.cos(a1)*rad); var ey=(y+Math.sin(a1)*rad); var tm=this._tm;
this.path+=(cw?"at":"wa")+tm.transS(l,t)+","+tm.transS(r,b)+","+tm.transS(sx,sy)+","+tm.transS(ex,ey); }; __Context.prototype.arcTo=function(x0,y0,x1,y1,rad) { }; __Context.prototype.bezierCurveTo=function(cp0x,cp0y,cp1x,cp1y,x,y) { var tm=this._tm; this.path+="c"+tm.transS(cp0x,cp0y)+","+tm.transS(cp1x,cp1y)+","+tm.transS(x,y); }; __Context.prototype.quadraticCurveTo=function(cpx,cpy,x,y) { var tm=this._tm; this.path+="qb"+tm.transS(cpx,cpy)+","+tm.transS(x,y); }; __Context.prototype.clip=function() { }; /*state*/ __Context.prototype.save=function() { this._state.push(new __State(this)) }; __Context.prototype.restore=function() { if(this._state.length>0)this._state.pop().restore(this) }; /*gradient*/ function __Gradient(x0,y0,x1,y1) { this.x0=x0; this.y0=y0; this.x1=x1; this.y1=y1; } __Gradient.prototype.addColorStop=function(off,col) { if(off==0){this.col0=col; }else if (off==1){this.col1=col; }else{ if(!this.stops)this.stops=[]; this.stops.push([off,col]); } }; function __angle(x0,y0,x1,y1) { var px=x1-x0;
var py=y1-y0; /*between(0,1) and (px,py)*/ return Math.acos(py/Math.sqrt(px*px+py*py)); } __Gradient.prototype.apply=function(f) { if(this.stops){ //    this.stops.sort(function(a,b){return a[0]-b[0]}); f.color=this.col0; f.color2=this.col1; if(f.colors==null)return; var c=""; for(var i=0;i<this.stops.length;++i){ var s=this.stops[i]; c+=" "+Math.round(100*s[0])+"% "+s[1]; } f.colors.value=c; f.method="sigma"; if(this.r0){ f.type="gradientradial"; f.focusposition="0.2,0.2"; f.focussize="0.2,0.2"; }else{ f.type="gradient"; f.focus=0; f.angle=180+(180*__angle(this.x0,this.y0,this.x1,this.y1)/Math.PI); } } }; __Context.prototype.createLinearGradient=function(x0,y0,x1,y1) { return new __Gradient(x0,y0,x1,y1); }; __Context.prototype.createRadialGradient=function(x0,y0,r0,x1,y1,r1) { var g=new __Gradient(x0,y0,x1,y1); g.r0=r0; g.r1=r1; return g; }; function __Pattern(img,rep) { this.img=img; this.rep=rep; } __Pattern.prototype.apply=function(f) { if(f.colors){ /*only for fills*/ f.type="tile"; f.src=this.img.src;
f.alignshape=false; } }; __Context.prototype.createPattern=function(img,rep) { /*rep="repeat","repeat-x","repeat-y","no-repeat"*/ return new __Pattern(img,rep); }; /*transform*/ __Context.prototype.translate=function(tx,ty) { this._tm.translate(tx,ty); }; __Context.prototype.scale=function(sx,sy) { this._tm.scale(sx,sy); }; __Context.prototype.rotate=function(ang) { this._rot+=ang; this._tm.rotate(ang); }; __Context.prototype._transform=function(x,y,p) { this._tm.transform(x,y,p); p.x=Math.round(p.x); p.y=Math.round(p.y); }; /*images*/ __Context.prototype.drawImage=function(img, sx, sy, swidth, sheight, dx, dy, dwidth, dheight) { var imn=img.nodeName.toLowerCase(); if(imn=="img"){ if(dx==null)this.__makeImage0(img, sx, sy, swidth, sheight); else this.__makeImage1(img, sx, sy, swidth, sheight, dx, dy, dwidth, dheight); }else if(imn=="div"){ } }; __Context.prototype.drawImageFromRect=function() { }; __Context.prototype.__makeImage0=function(img, x, y, width, height) { var im=document.createElement("v:image");
im.src=img.src; im.style.position="absolute"; im.style.left=x; im.style.top=y; im.style.width=(width!=null?width:img.offsetWidth); im.style.height=(height!=null?height:img.offsetHeight); this.div.appendChild(im); return im; }; __Context.prototype.__makeImage1=function(img, sx, sy, swidth, sheight, dx, dy, dwidth, dheight) { var im=this.__makeImage0(img, dx, dy, dwidth, dheight); im.cropleft=sx/img.offsetWidth; im.croptop=sy/img.offsetHeight; im.cropright=(img.offsetWidth-sx-swidth)/img.offsetWidth; im.cropbottom=(img.offsetHeight-sy-sheight)/img.offsetHeight; }; /*Transformation Matrix*/ function __TM() { this.M=[1,0,0,1,0,0]; } __TM.prototype.clone=function() { var t=new __TM(); var M=this.M; t.M=[M[0],M[1],M[2],M[3],M[4],M[5]]; return t; }; __TM.prototype._mult=function(a,b,c,d,e,f) { var M0 = this.M[0]; var M1 = this.M[1]; var M2 = this.M[2]; var M3 = this.M[3]; this.M[0] = a*M0 + b*M2; this.M[1] = a*M1 + b*M3; this.M[2] = c*M0 + d*M2; this.M[3] = c*M1 + d*M3; this.M[4] = e*M0 + f*M2 + this.M[4];
this.M[5] = e*M1 + f*M3 + this.M[5]; }; __TM.prototype.scale=function(sx,sy) { this._mult(sx,0,0,sy,0,0); }; __TM.prototype.translate=function(tx,ty) { this._mult(1,0,0,1,tx,ty); }; __TM.prototype.rotate=function(phi) { var c = Math.cos(phi); var s = Math.sin(phi); this._mult(c,s,-s,c,0,0); }; __TM.prototype.transform=function(x,y,p) { var M=this.M; p.x = x*M[0] + y*M[2] + M[4]; p.y = x*M[1] + y*M[3] + M[5]; }; __TM.prototype.transS=function(x,y) { var M=this.M; return Math.round(x*M[0]+y*M[2]+M[4])+","+Math.round(x*M[1]+y*M[3]+M[5]); }; __TM.prototype.transD=function(x,y) { var M=this.M; return Math.round(x*M[0]+y*M[2])+","+Math.round(x*M[1]+y*M[3]); }; __TM.prototype.transX=function(x,y) { var M=this.M; return x*M[0] + y*M[2] + M[4]; }; __TM.prototype.transY=function(x,y) { var M=this.M; return x*M[1] + y*M[3] + M[5]; };