/*
 Use it if you like it
*/
if(!window.console){window.console={};window.console.log=function(){};window.console.dir=function(){}}if(!Array.indexOf)Array.prototype.indexOf=function(r){for(var b=0;b<this.length;b++)if(this[b]==r)return b;return-1};
(function(){function r(){var b={};b.FRAMERATE=30;b.init=function(e){b.Definitions={};b.Styles={};b.Animations=[];b.Images=[];b.ctx=e;b.ViewPort=new function(){this.viewPorts=[];this.SetCurrent=function(c,a){this.viewPorts.push({width:c,height:a})};this.RemoveCurrent=function(){this.viewPorts.pop()};this.Current=function(){return this.viewPorts[this.viewPorts.length-1]};this.width=function(){return this.Current().width};this.height=function(){return this.Current().height};this.ComputeSize=function(c){if(c!=
null&&typeof c=="number")return c;if(c=="x")return this.width();if(c=="y")return this.height();return Math.sqrt(Math.pow(this.width(),2)+Math.pow(this.height(),2))/Math.sqrt(2)}}};b.init();b.ImagesLoaded=function(){for(var e=0;e<b.Images.length;e++)if(!b.Images[e].loaded)return false;return true};b.trim=function(e){return e.replace(/^\s+|\s+$/g,"")};b.compressSpaces=function(e){return e.replace(/[\s\r\t\n]+/gm," ")};b.ajax=function(e){var c;if(c=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP")){c.open("GET",
e,false);c.send(null);return c.responseText}return null};b.parseXml=function(e){if(window.DOMParser)return(new DOMParser).parseFromString(e,"text/xml");else{e=e.replace(/<!DOCTYPE svg[^>]*>/,"");var c=new ActiveXObject("Microsoft.XMLDOM");c.async="false";c.loadXML(e);return c}};b.Property=function(e,c){this.name=e;this.value=c;this.hasValue=function(){return this.value!=null&&this.value!=""};this.numValue=function(){if(!this.hasValue())return 0;var f=parseFloat(this.value);if((this.value+"").match(/%$/))f/=
100;return f};this.valueOrDefault=function(f){if(this.hasValue())return this.value;return f};this.numValueOrDefault=function(f){if(this.hasValue())return this.numValue();return f};var a=this;this.Color={addOpacity:function(f){var d=a.value;if(f!=null&&f!=""){var g=new RGBColor(a.value);if(g.ok)d="rgba("+g.r+", "+g.g+", "+g.b+", "+f+")"}return new b.Property(a.name,d)}};this.Definition={getDefinition:function(){var f=a.value.replace(/^(url\()?#([^\)]+)\)?$/,"$2");return b.Definitions[f]},isUrl:function(){return a.value.indexOf("url(")==
0},getFillStyle:function(f){var d=this.getDefinition();if(d!=null&&d.createGradient)return d.createGradient(b.ctx,f);if(d!=null&&d.createPattern)return d.createPattern(b.ctx,f);return null}};this.Length={DPI:function(){return 96},EM:function(f){var d=12,g=new b.Property("fontSize",b.Font.Parse(b.ctx.font).fontSize);if(g.hasValue())d=g.Length.toPixels(f);return d},toPixels:function(f){if(!a.hasValue())return 0;var d=a.value+"";if(d.match(/em$/))return a.numValue()*this.EM(f);if(d.match(/ex$/))return a.numValue()*
this.EM(f)/2;if(d.match(/px$/))return a.numValue();if(d.match(/pt$/))return a.numValue()*1.25;if(d.match(/pc$/))return a.numValue()*15;if(d.match(/cm$/))return a.numValue()*this.DPI(f)/2.54;if(d.match(/mm$/))return a.numValue()*this.DPI(f)/25.4;if(d.match(/in$/))return a.numValue()*this.DPI(f);if(d.match(/%$/))return a.numValue()*b.ViewPort.ComputeSize(f);return a.numValue()}};this.Time={toMilliseconds:function(){if(!a.hasValue())return 0;var f=a.value+"";if(f.match(/s$/))return a.numValue()*1E3;
if(f.match(/ms$/))return a.numValue();return a.numValue()}};this.Angle={toRadians:function(){if(!a.hasValue())return 0;var f=a.value+"";if(f.match(/deg$/))return a.numValue()*(Math.PI/180);if(f.match(/grad$/))return a.numValue()*(Math.PI/200);if(f.match(/rad$/))return a.numValue();return a.numValue()*(Math.PI/180)}}};b.Font=new function(){this.Styles=["normal","italic","oblique","inherit"];this.Variants=["normal","small-caps","inherit"];this.Weights=["normal","bold","bolder","lighter","100","200",
"300","400","500","600","700","800","900","inherit"];this.CreateFont=function(c,a,f,d,g,h){h=h!=null?this.Parse(h):this.CreateFont("","","","","",b.ctx.font);return{fontFamily:g||h.fontFamily,fontSize:d||h.fontSize,fontStyle:c||h.fontStyle,fontWeight:f||h.fontWeight,fontVariant:a||h.fontVariant,toString:function(){return[this.fontStyle,this.fontVariant,this.fontWeight,this.fontSize,this.fontFamily].join(" ")}}};var e=this;this.Parse=function(c){var a={};c=b.trim(b.compressSpaces(c||"")).split(" ");
for(var f={fontSize:false,fontStyle:false,fontWeight:false,fontVariant:false},d="",g=0;g<c.length;g++)if(!f.fontStyle&&e.Styles.indexOf(c[g])!=-1){if(c[g]!="inherit")a.fontStyle=c[g];f.fontStyle=true}else if(!f.fontVariant&&e.Variants.indexOf(c[g])!=-1){if(c[g]!="inherit")a.fontVariant=c[g];f.fontStyle=f.fontVariant=true}else if(!f.fontWeight&&e.Weights.indexOf(c[g])!=-1){if(c[g]!="inherit")a.fontWeight=c[g];f.fontStyle=f.fontVariant=f.fontWeight=true}else if(f.fontSize){if(c[g]!="inherit")d+=c[g]}else{if(c[g]!=
"inherit")a.fontSize=c[g].split("/")[0];f.fontStyle=f.fontVariant=f.fontWeight=f.fontSize=true}if(d!="")a.fontFamily=d;return a}};b.ToNumberArray=function(e){e=b.trim(b.compressSpaces((e||"").replace(/,/g," "))).split(" ");for(var c=0;c<e.length;c++)e[c]=parseFloat(e[c]);return e};b.Point=function(e,c){this.x=e;this.y=c;this.angleTo=function(a){return Math.atan2(a.y-this.y,a.x-this.x)};this.applyTransform=function(a){var f=this.x*a[1]+this.y*a[3]+a[5];this.x=this.x*a[0]+this.y*a[2]+a[4];this.y=f}};
b.CreatePoint=function(e){e=b.ToNumberArray(e);return new b.Point(e[0],e[1])};b.CreatePath=function(e){e=b.ToNumberArray(e);for(var c=[],a=0;a<e.length;a+=2)c.push(new b.Point(e[a],e[a+1]));return c};b.BoundingBox=function(e,c,a,f){this.y2=this.x2=this.y1=this.x1=Number.NaN;this.x=function(){return this.x1};this.y=function(){return this.y1};this.width=function(){return this.x2-this.x1};this.height=function(){return this.y2-this.y1};this.addPoint=function(d,g){if(d!=null){if(isNaN(this.x1)||isNaN(this.x2))this.x2=
this.x1=d;if(d<this.x1)this.x1=d;if(d>this.x2)this.x2=d}if(g!=null){if(isNaN(this.y1)||isNaN(this.y2))this.y2=this.y1=g;if(g<this.y1)this.y1=g;if(g>this.y2)this.y2=g}};this.addX=function(d){this.addPoint(d,null)};this.addY=function(d){this.addPoint(null,d)};this.addBoundingBox=function(d){this.addPoint(d.x1,d.y1);this.addPoint(d.x2,d.y2)};this.addQuadraticCurve=function(d,g,h,j,k,l){h=d+2/3*(h-d);j=g+2/3*(j-g);this.addBezierCurve(d,g,h,h+1/3*(k-d),j,j+1/3*(l-g),k,l)};this.addBezierCurve=function(d,
g,h,j,k,l,p,m){var o=[d,g],n=[h,j],q=[k,l],u=[p,m];this.addPoint(o[0],o[1]);this.addPoint(u[0],u[1]);for(i=0;i<=1;i++){d=function(s){return Math.pow(1-s,3)*o[i]+3*Math.pow(1-s,2)*s*n[i]+3*(1-s)*Math.pow(s,2)*q[i]+Math.pow(s,3)*u[i]};g=6*o[i]-12*n[i]+6*q[i];h=-3*o[i]+9*n[i]-9*q[i]+3*u[i];j=3*n[i]-3*o[i];if(h==0){if(g!=0){g=-j/g;if(0<g&&g<1){i==0&&this.addX(d(g));i==1&&this.addY(d(g))}}}else{j=Math.pow(g,2)-4*j*h;if(!(j<0)){k=(-g+Math.sqrt(j))/(2*h);if(0<k&&k<1){i==0&&this.addX(d(k));i==1&&this.addY(d(k))}g=
(-g-Math.sqrt(j))/(2*h);if(0<g&&g<1){i==0&&this.addX(d(g));i==1&&this.addY(d(g))}}}}};this.isPointInBox=function(d,g){return this.x1<=d&&d<=this.x2&&this.y1<=g&&g<=this.y2};this.addPoint(e,c);this.addPoint(a,f)};b.Transform=function(e){var c=this;this.Type={};this.Type.translate=function(g){this.p=b.CreatePoint(g);this.apply=function(h){h.translate(this.p.x||0,this.p.y||0)};this.applyToPoint=function(h){h.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0])}};this.Type.rotate=function(g){g=b.ToNumberArray(g);
this.angle=new b.Property("angle",g[0]);this.cx=g[1]||0;this.cy=g[2]||0;this.apply=function(h){h.translate(this.cx,this.cy);h.rotate(this.angle.Angle.toRadians());h.translate(-this.cx,-this.cy)};this.applyToPoint=function(h){var j=this.angle.Angle.toRadians();h.applyTransform([1,0,0,1,this.p.x||0,this.p.y||0]);h.applyTransform([Math.cos(j),Math.sin(j),-Math.sin(j),Math.cos(j),0,0]);h.applyTransform([1,0,0,1,-this.p.x||0,-this.p.y||0])}};this.Type.scale=function(g){this.p=b.CreatePoint(g);this.apply=
function(h){h.scale(this.p.x||1,this.p.y||this.p.x||1)};this.applyToPoint=function(h){h.applyTransform([this.p.x||0,0,0,this.p.y||0,0,0])}};this.Type.matrix=function(g){this.m=b.ToNumberArray(g);this.apply=function(h){h.transform(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5])};this.applyToPoint=function(h){h.applyTransform(this.m)}};this.Type.SkewBase=function(g){this.base=c.Type.matrix;this.base(g);this.angle=new b.Property("angle",g)};this.Type.SkewBase.prototype=new this.Type.matrix;
this.Type.skewX=function(g){this.base=c.Type.SkewBase;this.base(g);this.m=[1,0,Math.tan(this.angle.Angle.toRadians()),1,0,0]};this.Type.skewX.prototype=new this.Type.SkewBase;this.Type.skewY=function(g){this.base=c.Type.SkewBase;this.base(g);this.m=[1,Math.tan(this.angle.Angle.toRadians()),0,1,0,0]};this.Type.skewY.prototype=new this.Type.SkewBase;this.transforms=[];this.apply=function(g){for(var h=0;h<this.transforms.length;h++)this.transforms[h].apply(g)};this.applyToPoint=function(g){for(var h=
0;h<this.transforms.length;h++)this.transforms[h].applyToPoint(g)};e=e.split(/\s(?=[a-z])/);for(var a=0;a<e.length;a++){var f=e[a].split("(")[0],d=e[a].split("(")[1].replace(")","");this.transforms.push(new this.Type[f](d))}};b.AspectRatio=function(e,c,a,f,d,g,h,j,k,l){c=b.compressSpaces(c);c=c.replace(/^defer\s/,"");var p=c.split(" ")[0]||"xMidYMid";c=c.split(" ")[1]||"meet";var m=a/f,o=d/g,n=Math.min(m,o),q=Math.max(m,o);if(c=="meet"){f*=n;g*=n}if(c=="slice"){f*=q;g*=q}k=new b.Property("refX",k);
l=new b.Property("refY",l);if(k.hasValue()&&l.hasValue())e.translate(-n*k.Length.toPixels("x"),-n*l.Length.toPixels("y"));else{if(p.match(/^xMid/)&&(c=="meet"&&n==o||c=="slice"&&q==o))e.translate(a/2-f/2,0);if(p.match(/YMid$/)&&(c=="meet"&&n==m||c=="slice"&&q==m))e.translate(0,d/2-g/2);if(p.match(/^xMax/)&&(c=="meet"&&n==o||c=="slice"&&q==o))e.translate(a-f,0);if(p.match(/YMax$/)&&(c=="meet"&&n==m||c=="slice"&&q==m))e.translate(0,d-g)}if(p=="none")e.scale(m,o);else if(c=="meet")e.scale(n,n);else c==
"slice"&&e.scale(q,q);e.translate(h==null?0:-h,j==null?0:-j)};b.Element={};b.Element.ElementBase=function(e){this.attributes={};this.styles={};this.children=[];this.attribute=function(d,g){var h=this.attributes[d];if(h!=null)return h;h=new b.Property(d,"");if(g==true)this.attributes[d]=h;return h};this.style=function(d,g){var h=this.styles[d];if(h!=null)return h;h=this.attribute(d);if(h!=null&&h.hasValue())return h;h=new b.Property(d,"");if(g==true)this.styles[d]=h;return h};this.render=function(d){if(this.attribute("display").value!=
"none"){d.save();this.setContext(d);this.renderChildren(d);this.clearContext(d);d.restore()}};this.setContext=function(){};this.clearContext=function(){};this.renderChildren=function(d){for(var g=0;g<this.children.length;g++)this.children[g].render(d)};this.addChild=function(d,g){var h=d;if(g)h=b.CreateElement(d);h.parent=this;this.children.push(h)};if(e!=null&&e.nodeType==1){for(var c=0;c<e.childNodes.length;c++){var a=e.childNodes[c];a.nodeType==1&&this.addChild(a,true)}for(c=0;c<e.attributes.length;c++){a=
e.attributes[c];this.attributes[a.nodeName]=new b.Property(a.nodeName,a.nodeValue)}e=b.Styles[this.type];if(e!=null)for(var f in e)this.styles[f]=e[f];if(this.attribute("class").hasValue()){c=b.compressSpaces(this.attribute("class").value).split(" ");for(a=0;a<c.length;a++){e=b.Styles["."+c[a]];if(e!=null)for(f in e)this.styles[f]=e[f]}}if(this.attribute("style").hasValue()){e=this.attribute("style").value.split(";");for(c=0;c<e.length;c++)if(b.trim(e[c])!=""){a=e[c].split(":");f=b.trim(a[0]);a=b.trim(a[1]);
this.styles[f]=new b.Property(f,a)}}if(this.attribute("id").hasValue())if(b.Definitions[this.attribute("id").value]==null)b.Definitions[this.attribute("id").value]=this}};b.Element.RenderedElementBase=function(e){this.base=b.Element.ElementBase;this.base(e);this.setContext=function(c){if(this.style("fill").Definition.isUrl()){var a=this.style("fill").Definition.getFillStyle(this);if(a!=null)c.fillStyle=a}else if(this.style("fill").hasValue()){a=this.style("fill");if(this.style("fill-opacity").hasValue())a=
a.Color.addOpacity(this.style("fill-opacity").value);c.fillStyle=a.value=="none"?"rgba(0,0,0,0)":a.value}if(this.style("stroke").Definition.isUrl()){a=this.style("stroke").Definition.getFillStyle(this);if(a!=null)c.strokeStyle=a}else if(this.style("stroke").hasValue()){a=this.style("stroke");if(this.style("stroke-opacity").hasValue())a=a.Color.addOpacity(this.style("stroke-opacity").value);c.strokeStyle=a.value=="none"?"rgba(0,0,0,0)":a.value}if(this.style("stroke-width").hasValue())c.lineWidth=this.style("stroke-width").Length.toPixels();
if(this.style("stroke-linecap").hasValue())c.lineCap=this.style("stroke-linecap").value;if(this.style("stroke-linejoin").hasValue())c.lineJoin=this.style("stroke-linejoin").value;if(this.style("stroke-miterlimit").hasValue())c.miterLimit=this.style("stroke-miterlimit").value;if(typeof c.font!="undefined")c.font=b.Font.CreateFont(this.style("font-style").value,this.style("font-variant").value,this.style("font-weight").value,this.style("font-size").hasValue()?this.style("font-size").Length.toPixels()+
"px":"",this.style("font-family").value).toString();this.attribute("transform").hasValue()&&(new b.Transform(this.attribute("transform").value)).apply(c);if(this.attribute("clip-path").hasValue()){a=this.attribute("clip-path").Definition.getDefinition();a!=null&&a.apply(c)}if(this.style("opacity").hasValue())c.globalAlpha=this.style("opacity").numValue()}};b.Element.RenderedElementBase.prototype=new b.Element.ElementBase;b.Element.PathElementBase=function(e){this.base=b.Element.RenderedElementBase;
this.base(e);this.path=function(c){c!=null&&c.beginPath();return new b.BoundingBox};this.renderChildren=function(c){this.path(c);b.Mouse.checkPath(this,c);c.fillStyle!=""&&c.fill();c.strokeStyle!=""&&c.stroke();var a=this.getMarkers();if(a!=null){if(this.attribute("marker-start").Definition.isUrl()){var f=this.attribute("marker-start").Definition.getDefinition();f.render(c,a[0][0],a[0][1])}if(this.attribute("marker-mid").Definition.isUrl()){f=this.attribute("marker-mid").Definition.getDefinition();
for(var d=1;d<a.length-1;d++)f.render(c,a[d][0],a[d][1])}if(this.attribute("marker-end").Definition.isUrl()){f=this.attribute("marker-end").Definition.getDefinition();f.render(c,a[a.length-1][0],a[a.length-1][1])}}};this.getBoundingBox=function(){return this.path()};this.getMarkers=function(){return null}};b.Element.PathElementBase.prototype=new b.Element.RenderedElementBase;b.Element.svg=function(e){this.base=b.Element.RenderedElementBase;this.base(e);this.baseClearContext=this.clearContext;this.clearContext=
function(c){this.baseClearContext(c);b.ViewPort.RemoveCurrent()};this.baseSetContext=this.setContext;this.setContext=function(c){c.strokeStyle="rgba(0,0,0,0)";c.lineCap="butt";c.lineJoin="miter";c.miterLimit=4;this.baseSetContext(c);this.attribute("x").hasValue()&&this.attribute("y").hasValue()&&c.translate(this.attribute("x").Length.toPixels("x"),this.attribute("y").Length.toPixels("y"));var a=b.ViewPort.width(),f=b.ViewPort.height();if(this.attribute("width").hasValue()&&this.attribute("height").hasValue()){a=
this.attribute("width").Length.toPixels("x");f=this.attribute("height").Length.toPixels("y");var d=0,g=0;if(this.attribute("refX").hasValue()&&this.attribute("refY").hasValue()){d=-this.attribute("refX").Length.toPixels("x");g=-this.attribute("refY").Length.toPixels("y")}c.beginPath();c.moveTo(d,g);c.lineTo(a,g);c.lineTo(a,f);c.lineTo(d,f);c.closePath();c.clip()}b.ViewPort.SetCurrent(a,f);if(this.attribute("viewBox").hasValue()){d=b.ToNumberArray(this.attribute("viewBox").value);g=d[0];var h=d[1];
a=d[2];f=d[3];b.AspectRatio(c,this.attribute("preserveAspectRatio").value,b.ViewPort.width(),a,b.ViewPort.height(),f,g,h,this.attribute("refX").value,this.attribute("refY").value);b.ViewPort.RemoveCurrent();b.ViewPort.SetCurrent(d[2],d[3])}}};b.Element.svg.prototype=new b.Element.RenderedElementBase;b.Element.rect=function(e){this.base=b.Element.PathElementBase;this.base(e);this.path=function(c){var a=this.attribute("x").Length.toPixels("x"),f=this.attribute("y").Length.toPixels("y"),d=this.attribute("width").Length.toPixels("x"),
g=this.attribute("height").Length.toPixels("y"),h=this.attribute("rx").Length.toPixels("x"),j=this.attribute("ry").Length.toPixels("y");if(this.attribute("rx").hasValue()&&!this.attribute("ry").hasValue())j=h;if(this.attribute("ry").hasValue()&&!this.attribute("rx").hasValue())h=j;if(c!=null){c.beginPath();c.moveTo(a+h,f);c.lineTo(a+d-h,f);c.quadraticCurveTo(a+d,f,a+d,f+j);c.lineTo(a+d,f+g-j);c.quadraticCurveTo(a+d,f+g,a+d-h,f+g);c.lineTo(a+h,f+g);c.quadraticCurveTo(a,f+g,a,f+g-j);c.lineTo(a,f+j);
c.quadraticCurveTo(a,f,a+h,f);c.closePath()}return new b.BoundingBox(a,f,a+d,f+g)}};b.Element.rect.prototype=new b.Element.PathElementBase;b.Element.circle=function(e){this.base=b.Element.PathElementBase;this.base(e);this.path=function(c){var a=this.attribute("cx").Length.toPixels("x"),f=this.attribute("cy").Length.toPixels("y"),d=this.attribute("r").Length.toPixels();if(c!=null){c.beginPath();c.arc(a,f,d,0,Math.PI*2,true);c.closePath()}return new b.BoundingBox(a-d,f-d,a+d,f+d)}};b.Element.circle.prototype=
new b.Element.PathElementBase;b.Element.ellipse=function(e){this.base=b.Element.PathElementBase;this.base(e);this.path=function(c){var a=4*((Math.sqrt(2)-1)/3),f=this.attribute("rx").Length.toPixels("x"),d=this.attribute("ry").Length.toPixels("y"),g=this.attribute("cx").Length.toPixels("x"),h=this.attribute("cy").Length.toPixels("y");if(c!=null){c.beginPath();c.moveTo(g,h-d);c.bezierCurveTo(g+a*f,h-d,g+f,h-a*d,g+f,h);c.bezierCurveTo(g+f,h+a*d,g+a*f,h+d,g,h+d);c.bezierCurveTo(g-a*f,h+d,g-f,h+a*d,g-
f,h);c.bezierCurveTo(g-f,h-a*d,g-a*f,h-d,g,h-d);c.closePath()}return new b.BoundingBox(g-f,h-d,g+f,h+d)}};b.Element.ellipse.prototype=new b.Element.PathElementBase;b.Element.line=function(e){this.base=b.Element.PathElementBase;this.base(e);this.getPoints=function(){return[new b.Point(this.attribute("x1").Length.toPixels("x"),this.attribute("y1").Length.toPixels("y")),new b.Point(this.attribute("x2").Length.toPixels("x"),this.attribute("y2").Length.toPixels("y"))]};this.path=function(c){var a=this.getPoints();
if(c!=null){c.beginPath();c.moveTo(a[0].x,a[0].y);c.lineTo(a[1].x,a[1].y)}return new b.BoundingBox(a[0].x,a[0].y,a[1].x,a[1].y)};this.getMarkers=function(){var c=this.getPoints(),a=c[0].angleTo(c[1]);return[[c[0],a],[c[1],a]]}};b.Element.line.prototype=new b.Element.PathElementBase;b.Element.polyline=function(e){this.base=b.Element.PathElementBase;this.base(e);this.points=b.CreatePath(this.attribute("points").value);this.path=function(c){var a=new b.BoundingBox(this.points[0].x,this.points[0].y);
if(c!=null){c.beginPath();c.moveTo(this.points[0].x,this.points[0].y)}for(var f=1;f<this.points.length;f++){a.addPoint(this.points[f].x,this.points[f].y);c!=null&&c.lineTo(this.points[f].x,this.points[f].y)}return a};this.getMarkers=function(){for(var c=[],a=0;a<this.points.length-1;a++)c.push([this.points[a],this.points[a].angleTo(this.points[a+1])]);c.push([this.points[this.points.length-1],c[c.length-1][1]]);return c}};b.Element.polyline.prototype=new b.Element.PathElementBase;b.Element.polygon=
function(e){this.base=b.Element.polyline;this.base(e);this.basePath=this.path;this.path=function(c){var a=this.basePath(c);if(c!=null){c.lineTo(this.points[0].x,this.points[0].y);c.closePath()}return a}};b.Element.polygon.prototype=new b.Element.polyline;b.Element.path=function(e){this.base=b.Element.PathElementBase;this.base(e);e=this.attribute("d").value;e=e.replace(/,/gm," ");e=e.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2");e=e.replace(/([MmZzLlHhVvCcSsQqTtAa])([MmZzLlHhVvCcSsQqTtAa])/gm,
"$1 $2");e=e.replace(/([MmZzLlHhVvCcSsQqTtAa])([^\s])/gm,"$1 $2");e=e.replace(/([^\s])([MmZzLlHhVvCcSsQqTtAa])/gm,"$1 $2");e=e.replace(/([0-9])([+\-])/gm,"$1 $2");e=e.replace(/(\.[0-9]*)(\.)/gm,"$1 $2");e=e.replace(/([Aa](\s+[0-9]+){3})\s+([01])\s*([01])/gm,"$1 $3 $4 ");e=b.compressSpaces(e);e=b.trim(e);this.PathParser=new function(c){this.tokens=c.split(" ");this.reset=function(){this.i=-1;this.previousCommand=this.command="";this.start=new b.Point(0,0);this.control=new b.Point(0,0);this.current=
new b.Point(0,0);this.points=[];this.angles=[]};this.isEnd=function(){return this.i>=this.tokens.length-1};this.isCommandOrEnd=function(){if(this.isEnd())return true;return this.tokens[this.i+1].match(/[A-Za-z]/)!=null};this.isRelativeCommand=function(){return this.command==this.command.toLowerCase()};this.getToken=function(){this.i+=1;return this.tokens[this.i]};this.getScalar=function(){return parseFloat(this.getToken())};this.nextCommand=function(){this.previousCommand=this.command;this.command=
this.getToken()};this.getPoint=function(){return this.makeAbsolute(new b.Point(this.getScalar(),this.getScalar()))};this.getAsControlPoint=function(){var a=this.getPoint();return this.control=a};this.getAsCurrentPoint=function(){var a=this.getPoint();return this.current=a};this.getReflectedControlPoint=function(){if(this.previousCommand.toLowerCase()!="c"&&this.previousCommand.toLowerCase()!="s")return this.current;return new b.Point(2*this.current.x-this.control.x,2*this.current.y-this.control.y)};
this.makeAbsolute=function(a){if(this.isRelativeCommand()){a.x=this.current.x+a.x;a.y=this.current.y+a.y}return a};this.addMarker=function(a,f){this.addMarkerAngle(a,f==null?null:f.angleTo(a))};this.addMarkerAngle=function(a,f){this.points.push(a);this.angles.push(f)};this.getMarkerPoints=function(){return this.points};this.getMarkerAngles=function(){for(var a=0;a<this.angles.length;a++)if(this.angles[a]==null)for(var f=a+1;f<this.angles.length;f++)if(this.angles[f]!=null){this.angles[a]=this.angles[f];
break}return this.angles}}(e);this.path=function(c){var a=this.PathParser;a.reset();var f=new b.BoundingBox;if(this.attribute("visibility").value!="hidden"){for(c!=null&&c.beginPath();!a.isEnd();){a.nextCommand();switch(a.command.toUpperCase()){case "M":var d=a.getAsCurrentPoint();a.addMarker(d);f.addPoint(d.x,d.y);c!=null&&c.moveTo(d.x,d.y);for(a.start=a.current;!a.isCommandOrEnd();){d=a.getAsCurrentPoint();a.addMarker(d);f.addPoint(d.x,d.y);c!=null&&c.lineTo(d.x,d.y)}break;case "L":for(;!a.isCommandOrEnd();){var g=
a.current;d=a.getAsCurrentPoint();a.addMarker(d,g);f.addPoint(d.x,d.y);c!=null&&c.lineTo(d.x,d.y)}break;case "H":for(;!a.isCommandOrEnd();){d=new b.Point((a.isRelativeCommand()?a.current.x:0)+a.getScalar(),a.current.y);a.addMarker(d,a.current);a.current=d;f.addPoint(a.current.x,a.current.y);c!=null&&c.lineTo(a.current.x,a.current.y)}break;case "V":for(;!a.isCommandOrEnd();){d=new b.Point(a.current.x,(a.isRelativeCommand()?a.current.y:0)+a.getScalar());a.addMarker(d,a.current);a.current=d;f.addPoint(a.current.x,
a.current.y);c!=null&&c.lineTo(a.current.x,a.current.y)}break;case "C":for(;!a.isCommandOrEnd();){var h=a.current;g=a.getPoint();var j=a.getAsControlPoint();d=a.getAsCurrentPoint();a.addMarker(d,j);f.addBezierCurve(h.x,h.y,g.x,g.y,j.x,j.y,d.x,d.y);c!=null&&c.bezierCurveTo(g.x,g.y,j.x,j.y,d.x,d.y)}break;case "S":for(;!a.isCommandOrEnd();){h=a.current;g=a.getReflectedControlPoint();j=a.getAsControlPoint();d=a.getAsCurrentPoint();a.addMarker(d,j);f.addBezierCurve(h.x,h.y,g.x,g.y,j.x,j.y,d.x,d.y);c!=
null&&c.bezierCurveTo(g.x,g.y,j.x,j.y,d.x,d.y)}break;case "Q":for(;!a.isCommandOrEnd();){h=a.current;j=a.getAsControlPoint();d=a.getAsCurrentPoint();a.addMarker(d,j);f.addQuadraticCurve(h.x,h.y,j.x,j.y,d.x,d.y);c!=null&&c.quadraticCurveTo(j.x,j.y,d.x,d.y)}break;case "T":for(;!a.isCommandOrEnd();){h=a.current;j=a.getReflectedControlPoint();a.control=j;d=a.getAsCurrentPoint();a.addMarker(d,j);f.addQuadraticCurve(h.x,h.y,j.x,j.y,d.x,d.y);c!=null&&c.quadraticCurveTo(j.x,j.y,d.x,d.y)}break;case "A":for(;!a.isCommandOrEnd();){h=
a.current;var k=a.getScalar(),l=a.getScalar();g=a.getScalar()*(Math.PI/180);var p=a.getScalar();j=a.getScalar();d=a.getAsCurrentPoint();var m=new b.Point(Math.cos(g)*(h.x-d.x)/2+Math.sin(g)*(h.y-d.y)/2,-Math.sin(g)*(h.x-d.x)/2+Math.cos(g)*(h.y-d.y)/2),o=Math.pow(m.x,2)/Math.pow(k,2)+Math.pow(m.y,2)/Math.pow(l,2);if(o>1){k*=Math.sqrt(o);l*=Math.sqrt(o)}p=(p==j?-1:1)*Math.sqrt((Math.pow(k,2)*Math.pow(l,2)-Math.pow(k,2)*Math.pow(m.y,2)-Math.pow(l,2)*Math.pow(m.x,2))/(Math.pow(k,2)*Math.pow(m.y,2)+Math.pow(l,
2)*Math.pow(m.x,2)));if(isNaN(p))p=0;var n=new b.Point(p*k*m.y/l,p*-l*m.x/k);h=new b.Point((h.x+d.x)/2+Math.cos(g)*n.x-Math.sin(g)*n.y,(h.y+d.y)/2+Math.sin(g)*n.x+Math.cos(g)*n.y);var q=function(s,t){return(s[0]*t[0]+s[1]*t[1])/(Math.sqrt(Math.pow(s[0],2)+Math.pow(s[1],2))*Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)))},u=function(s,t){return(s[0]*t[1]<s[1]*t[0]?-1:1)*Math.acos(q(s,t))};p=u([1,0],[(m.x-n.x)/k,(m.y-n.y)/l]);o=[(m.x-n.x)/k,(m.y-n.y)/l];n=[(-m.x-n.x)/k,(-m.y-n.y)/l];m=u(o,n);if(q(o,n)<=
-1)m=Math.PI;if(q(o,n)>=1)m=0;if(j==0&&m>0)m-=2*Math.PI;if(j==1&&m<0)m+=2*Math.PI;o=new b.Point(h.x-k*Math.cos((p+m)/2),h.y-l*Math.sin((p+m)/2));a.addMarkerAngle(o,(p+m)/2+(j==0?1:-1)*Math.PI/2);a.addMarkerAngle(d,m+(j==0?1:-1)*Math.PI/2);f.addPoint(d.x,d.y);if(c!=null){q=k>l?k:l;d=k>l?1:k/l;k=k>l?l/k:1;c.translate(h.x,h.y);c.rotate(g);c.scale(d,k);c.arc(0,0,q,p,p+m,1-j);c.scale(1/d,1/k);c.rotate(-g);c.translate(-h.x,-h.y)}}break;case "Z":c!=null&&c.closePath();a.current=a.start}}return f}};this.getMarkers=
function(){for(var c=this.PathParser.getMarkerPoints(),a=this.PathParser.getMarkerAngles(),f=[],d=0;d<c.length;d++)f.push([c[d],a[d]]);return f}};b.Element.path.prototype=new b.Element.PathElementBase;b.Element.pattern=function(e){this.base=b.Element.ElementBase;this.base(e);this.createPattern=function(c){var a=new b.Element.svg;a.attributes.viewBox=new b.Property("viewBox",this.attribute("viewBox").value);a.attributes.x=new b.Property("x",this.attribute("x").value);a.attributes.y=new b.Property("y",
this.attribute("y").value);a.attributes.width=new b.Property("width",this.attribute("width").value);a.attributes.height=new b.Property("height",this.attribute("height").value);a.children=this.children;var f=document.createElement("canvas");f.width=this.attribute("width").Length.toPixels();f.height=this.attribute("height").Length.toPixels();a.render(f.getContext("2d"));return c.createPattern(f,"repeat")}};b.Element.pattern.prototype=new b.Element.ElementBase;b.Element.marker=function(e){this.base=
b.Element.ElementBase;this.base(e);this.baseRender=this.render;this.render=function(c,a,f){c.translate(a.x,a.y);this.attribute("orient").valueOrDefault("auto")=="auto"&&c.rotate(f);this.attribute("markerUnits").valueOrDefault("strokeWidth")=="strokeWidth"&&c.scale(c.lineWidth,c.lineWidth);c.save();var d=new b.Element.svg;d.attributes.viewBox=new b.Property("viewBox",this.attribute("viewBox").value);d.attributes.refX=new b.Property("refX",this.attribute("refX").value);d.attributes.refY=new b.Property("refY",
this.attribute("refY").value);d.attributes.width=new b.Property("width",this.attribute("markerWidth").value);d.attributes.height=new b.Property("height",this.attribute("markerHeight").value);d.attributes.fill=new b.Property("fill",this.attribute("fill").valueOrDefault("black"));d.attributes.stroke=new b.Property("stroke",this.attribute("stroke").valueOrDefault("none"));d.children=this.children;d.render(c);c.restore();this.attribute("markerUnits").valueOrDefault("strokeWidth")=="strokeWidth"&&c.scale(1/
c.lineWidth,1/c.lineWidth);this.attribute("orient").valueOrDefault("auto")=="auto"&&c.rotate(-f);c.translate(-a.x,-a.y)}};b.Element.marker.prototype=new b.Element.ElementBase;b.Element.defs=function(e){this.base=b.Element.ElementBase;this.base(e);this.render=function(){}};b.Element.defs.prototype=new b.Element.ElementBase;b.Element.GradientBase=function(e){this.base=b.Element.ElementBase;this.base(e);this.gradientUnits=this.attribute("gradientUnits").valueOrDefault("objectBoundingBox");this.stops=
[];for(e=0;e<this.children.length;e++)this.stops.push(this.children[e]);this.getGradient=function(){};this.createGradient=function(c,a){var f=this;if(this.attribute("xlink:href").hasValue())f=this.attribute("xlink:href").Definition.getDefinition();for(var d=this.getGradient(c,a),g=0;g<f.stops.length;g++)d.addColorStop(f.stops[g].offset,f.stops[g].color);return d}};b.Element.GradientBase.prototype=new b.Element.ElementBase;b.Element.linearGradient=function(e){this.base=b.Element.GradientBase;this.base(e);
this.getGradient=function(c,a){var f=a.getBoundingBox(),d=this.gradientUnits=="objectBoundingBox"?f.x()+f.width()*this.attribute("x1").numValue():this.attribute("x1").Length.toPixels("x"),g=this.gradientUnits=="objectBoundingBox"?f.y()+f.height()*this.attribute("y1").numValue():this.attribute("y1").Length.toPixels("y"),h=this.gradientUnits=="objectBoundingBox"?f.x()+f.width()*this.attribute("x2").numValue():this.attribute("x2").Length.toPixels("x");f=this.gradientUnits=="objectBoundingBox"?f.y()+
f.height()*this.attribute("y2").numValue():this.attribute("y2").Length.toPixels("y");d=new b.Point(d,g);h=new b.Point(h,f);if(this.attribute("gradientTransform").hasValue()){g=new b.Transform(this.attribute("gradientTransform").value);g.applyToPoint(d);g.applyToPoint(h)}return c.createLinearGradient(d.x,d.y,h.x,h.y)}};b.Element.linearGradient.prototype=new b.Element.GradientBase;b.Element.radialGradient=function(e){this.base=b.Element.GradientBase;this.base(e);this.getGradient=function(c,a){var f=
a.getBoundingBox(),d=this.gradientUnits=="objectBoundingBox"?f.x()+f.width()*this.attribute("cx").numValue():this.attribute("cx").Length.toPixels("x"),g=this.gradientUnits=="objectBoundingBox"?f.y()+f.height()*this.attribute("cy").numValue():this.attribute("cy").Length.toPixels("y"),h=d,j=g;if(this.attribute("fx").hasValue())h=this.gradientUnits=="objectBoundingBox"?f.x()+f.width()*this.attribute("fx").numValue():this.attribute("fx").Length.toPixels("x");if(this.attribute("fy").hasValue())j=this.gradientUnits==
"objectBoundingBox"?f.y()+f.height()*this.attribute("fy").numValue():this.attribute("fy").Length.toPixels("y");f=this.gradientUnits=="objectBoundingBox"?(f.width()+f.height())/2*this.attribute("r").numValue():this.attribute("r").Length.toPixels();d=new b.Point(d,g);h=new b.Point(h,j);if(this.attribute("gradientTransform").hasValue()){j=new b.Transform(this.attribute("gradientTransform").value);j.applyToPoint(d);j.applyToPoint(h);for(g=0;g<j.transforms.length;g++)f*=(j.transforms[g].m[0]+j.transforms[g].m[3])/
2}return c.createRadialGradient(h.x,h.y,0,d.x,d.y,f)}};b.Element.radialGradient.prototype=new b.Element.GradientBase;b.Element.stop=function(e){this.base=b.Element.ElementBase;this.base(e);this.offset=this.attribute("offset").numValue();e=this.style("stop-color");if(this.style("stop-opacity").hasValue())e=e.Color.addOpacity(this.style("stop-opacity").value);this.color=e.value};b.Element.stop.prototype=new b.Element.ElementBase;b.Element.AnimateBase=function(e){this.base=b.Element.ElementBase;this.base(e);
b.Animations.push(this);this.duration=0;this.begin=this.attribute("begin").Time.toMilliseconds();this.maxDuration=this.begin+this.attribute("dur").Time.toMilliseconds();this.getProperty=function(){var c=this.attribute("attributeType").value,a=this.attribute("attributeName").value;if(c=="CSS")return this.parent.style(a,true);return this.parent.attribute(a,true)};this.initialValue=null;this.removed=false;this.calcValue=function(){return""};this.update=function(c){if(this.initialValue==null)this.initialValue=
this.getProperty().value;if(this.duration>this.maxDuration)if(this.attribute("repeatCount").value=="indefinite")this.duration=0;else if(this.attribute("fill").valueOrDefault("remove")=="remove"&&!this.removed){this.removed=true;this.getProperty().value=this.initialValue;return true}else return false;this.duration+=c;c=false;if(this.begin<this.duration){c=this.calcValue();if(this.attribute("type").hasValue())c=this.attribute("type").value+"("+c+")";this.getProperty().value=c;c=true}return c};this.progress=
function(){return(this.duration-this.begin)/(this.maxDuration-this.begin)}};b.Element.AnimateBase.prototype=new b.Element.ElementBase;b.Element.animate=function(e){this.base=b.Element.AnimateBase;this.base(e);this.calcValue=function(){var c=this.attribute("from").numValue(),a=this.attribute("to").numValue();return c+(a-c)*this.progress()}};b.Element.animate.prototype=new b.Element.AnimateBase;b.Element.animateColor=function(e){this.base=b.Element.AnimateBase;this.base(e);this.calcValue=function(){var c=
new RGBColor(this.attribute("from").value),a=new RGBColor(this.attribute("to").value);if(c.ok&&a.ok){var f=c.r+(a.r-c.r)*this.progress(),d=c.g+(a.g-c.g)*this.progress();c=c.b+(a.b-c.b)*this.progress();return"rgb("+parseInt(f,10)+","+parseInt(d,10)+","+parseInt(c,10)+")"}return this.attribute("from").value}};b.Element.animateColor.prototype=new b.Element.AnimateBase;b.Element.animateTransform=function(e){this.base=b.Element.animate;this.base(e)};b.Element.animateTransform.prototype=new b.Element.animate;
b.Element.text=function(e){this.base=b.Element.RenderedElementBase;this.base(e);if(e!=null){this.children=[];for(var c=0;c<e.childNodes.length;c++){var a=e.childNodes[c];if(a.nodeType==1)this.addChild(a,true);else a.nodeType==3&&this.addChild(new b.Element.tspan(a),false)}}this.baseSetContext=this.setContext;this.setContext=function(f){this.baseSetContext(f);if(this.attribute("text-anchor").hasValue()){var d=this.attribute("text-anchor").value;f.textAlign=d=="middle"?"center":d}if(this.attribute("alignment-baseline").hasValue())f.textBaseline=
this.attribute("alignment-baseline").value};this.renderChildren=function(f){if(this.attribute("visibility").value!="hidden")for(var d=this.attribute("x").Length.toPixels("x"),g=this.attribute("y").Length.toPixels("y"),h=0;h<this.children.length;h++){var j=this.children[h];if(j.attribute("x").hasValue())j.x=j.attribute("x").Length.toPixels("x");else{if(j.attribute("dx").hasValue())d+=j.attribute("dx").Length.toPixels("x");j.x=d;d+=j.measureText(f)}if(j.attribute("y").hasValue())j.y=j.attribute("y").Length.toPixels("y");
else{if(j.attribute("dy").hasValue())g+=j.attribute("dy").Length.toPixels("y");j.y=g}j.render(f)}}};b.Element.text.prototype=new b.Element.RenderedElementBase;b.Element.TextElementBase=function(e){this.base=b.Element.RenderedElementBase;this.base(e);this.renderChildren=function(c){c.fillText(b.compressSpaces(this.getText()),this.x,this.y)};this.getText=function(){};this.measureText=function(c){var a=b.compressSpaces(this.getText());if(!c.measureText)return a.length*10;return c.measureText(a).width}};
b.Element.TextElementBase.prototype=new b.Element.RenderedElementBase;b.Element.tspan=function(e){this.base=b.Element.TextElementBase;this.base(e);this.text=e.nodeType==3?e.nodeValue:e.childNodes[0].nodeValue;this.getText=function(){return this.text}};b.Element.tspan.prototype=new b.Element.TextElementBase;b.Element.tref=function(e){this.base=b.Element.TextElementBase;this.base(e);this.getText=function(){var c=this.attribute("xlink:href").Definition.getDefinition();if(c!=null)return c.children[0].getText()}};
b.Element.tref.prototype=new b.Element.TextElementBase;b.Element.a=function(e){this.base=b.Element.TextElementBase;this.base(e);this.hasText=true;for(var c=0;c<e.childNodes.length;c++)if(e.childNodes[c].nodeType!=3)this.hasText=false;this.text=this.hasText?e.childNodes[0].nodeValue:"";this.getText=function(){return this.text};this.baseRenderChildren=this.renderChildren;this.renderChildren=function(a){if(this.hasText){this.baseRenderChildren(a);var f=new b.Property("fontSize",b.Font.Parse(b.ctx.font).fontSize);
b.Mouse.checkBoundingBox(this,new b.BoundingBox(this.x,this.y-f.Length.toPixels("y"),this.x+this.measureText(a),this.y))}else{f=new b.Element.g;f.children=this.children;f.parent=this;f.render(a)}};this.onclick=function(){window.open(this.attribute("xlink:href").value)};this.onmousemove=function(){b.ctx.canvas.style.cursor="pointer"}};b.Element.a.prototype=new b.Element.TextElementBase;b.Element.image=function(e){this.base=b.Element.RenderedElementBase;this.base(e);b.Images.push(this);this.img=document.createElement("img");
this.loaded=false;var c=this;this.img.onload=function(){c.loaded=true};this.img.src=this.attribute("xlink:href").value;this.renderChildren=function(a){var f=this.attribute("x").Length.toPixels("x"),d=this.attribute("y").Length.toPixels("y"),g=this.attribute("width").Length.toPixels("x"),h=this.attribute("height").Length.toPixels("y");if(!(g==0||h==0)){a.save();a.translate(f,d);b.AspectRatio(a,this.attribute("preserveAspectRatio").value,g,this.img.width,h,this.img.height,0,0);a.drawImage(this.img,
0,0);a.restore()}}};b.Element.image.prototype=new b.Element.RenderedElementBase;b.Element.g=function(e){this.base=b.Element.RenderedElementBase;this.base(e);this.getBoundingBox=function(){for(var c=new b.BoundingBox,a=0;a<this.children.length;a++)c.addBoundingBox(this.children[a].getBoundingBox());return c}};b.Element.g.prototype=new b.Element.RenderedElementBase;b.Element.symbol=function(e){this.base=b.Element.RenderedElementBase;this.base(e);this.baseSetContext=this.setContext;this.setContext=function(c){this.baseSetContext(c);
if(this.attribute("viewBox").hasValue()){var a=b.ToNumberArray(this.attribute("viewBox").value),f=a[0],d=a[1];width=a[2];height=a[3];b.AspectRatio(c,this.attribute("preserveAspectRatio").value,this.attribute("width").Length.toPixels("x"),width,this.attribute("height").Length.toPixels("y"),height,f,d);b.ViewPort.SetCurrent(a[2],a[3])}}};b.Element.symbol.prototype=new b.Element.RenderedElementBase;b.Element.style=function(e){this.base=b.Element.ElementBase;this.base(e);e=e.childNodes[0].nodeValue;e=
e.replace(/(\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\/)|(\/\/.*)/gm,"");e=b.compressSpaces(e);e=e.split("}");for(var c=0;c<e.length;c++)if(b.trim(e[c])!=""){var a=e[c].split("{"),f=a[0].split(",");a=a[1].split(";");for(var d=0;d<f.length;d++){var g=b.trim(f[d]);if(g!=""){for(var h={},j=0;j<a.length;j++){var k=a[j].split(":"),l=k[1];if(k[0]!=null&&l!=null)h[b.trim(k[0])]=new b.Property(b.trim(k[0]),b.trim(k[1]))}b.Styles[g]=h}}}};b.Element.style.prototype=new b.Element.ElementBase;b.Element.use=
function(e){this.base=b.Element.RenderedElementBase;this.base(e);this.baseSetContext=this.setContext;this.setContext=function(c){this.baseSetContext(c);this.attribute("x").hasValue()&&c.translate(this.attribute("x").Length.toPixels("x"),0);this.attribute("y").hasValue()&&c.translate(0,this.attribute("y").Length.toPixels("y"))};this.getDefinition=function(){var c=this.attribute("xlink:href").Definition.getDefinition();if(this.attribute("width").hasValue())c.attribute("width",true).value=this.attribute("width").value;
if(this.attribute("height").hasValue())c.attribute("height",true).value=this.attribute("height").value;return c};this.path=function(c){var a=this.getDefinition();a!=null&&a.path(c)};this.renderChildren=function(c){var a=this.getDefinition();a!=null&&a.render(c)}};b.Element.use.prototype=new b.Element.RenderedElementBase;b.Element.clipPath=function(e){this.base=b.Element.ElementBase;this.base(e);this.apply=function(c){for(var a=0;a<this.children.length;a++)if(this.children[a].path){this.children[a].path(c);
c.clip()}}};b.Element.clipPath.prototype=new b.Element.ElementBase;b.Element.title=function(){};b.Element.title.prototype=new b.Element.ElementBase;b.Element.desc=function(){};b.Element.desc.prototype=new b.Element.ElementBase;b.Element.MISSING=function(e){console.log("ERROR: Element '"+e.nodeName+"' not yet implemented.")};b.Element.MISSING.prototype=new b.Element.ElementBase;b.CreateElement=function(e){var c=e.nodeName.replace(/^[^:]+:/,""),a=null;a=typeof b.Element[c]!="undefined"?new b.Element[c](e):
new b.Element.MISSING(e);a.type=e.nodeName;return a};b.load=function(e,c){b.loadXml(e,b.ajax(c))};b.loadXml=function(e,c){b.init(e);var a=function(k){for(var l=e.canvas;l;){k.x-=l.offsetLeft;k.y-=l.offsetTop;l=l.offsetParent}if(window.scrollX)k.x+=window.scrollX;if(window.scrollY)k.y+=window.scrollY;return k};if(b.opts==null||b.opts.ignoreMouse!=true){e.canvas.onclick=function(k){k=a(new b.Point(k!=null?k.clientX:event.clientX,k!=null?k.clientY:event.clientY));b.Mouse.onclick(k.x,k.y)};e.canvas.onmousemove=
function(k){k=a(new b.Point(k!=null?k.clientX:event.clientX,k!=null?k.clientY:event.clientY));b.Mouse.onmousemove(k.x,k.y)}}var f=b.parseXml(c),d=b.CreateElement(f.documentElement),g=true,h=function(){if(b.opts==null||b.opts.ignoreDimensions!=true){if(d.style("width").hasValue())e.canvas.width=d.style("width").Length.toPixels(e.canvas.parentNode.clientWidth);if(d.style("height").hasValue())e.canvas.height=d.style("height").Length.toPixels(e.canvas.parentNode.clientHeight)}b.ViewPort.SetCurrent(e.canvas.clientWidth,
e.canvas.clientHeight);if(b.opts!=null&&b.opts.offsetX!=null)d.attribute("x",true).value=b.opts.offsetX;if(b.opts!=null&&b.opts.offsetY!=null)d.attribute("y",true).value=b.opts.offsetY;if(b.opts!=null&&b.opts.scaleWidth!=null&&b.opts.scaleHeight!=null){d.attribute("width",true).value=b.opts.scaleWidth;d.attribute("height",true).value=b.opts.scaleHeight;d.attribute("viewBox",true).value="0 0 "+e.canvas.clientWidth+" "+e.canvas.clientHeight;d.attribute("preserveAspectRatio",true).value="none"}if(b.opts==
null||b.opts.ignoreClear!=true)e.clearRect(0,0,e.canvas.clientWidth,e.canvas.clientHeight);d.render(e);if(g){g=false;b.opts!=null&&typeof b.opts.renderCallback=="function"&&b.opts.renderCallback()}},j=true;if(b.ImagesLoaded()){j=false;h()}b.intervalID=setInterval(function(){var k=false;if(j&&b.ImagesLoaded()){j=false;k=true}if(b.opts==null||b.opts.ignoreMouse!=true)k|=b.Mouse.hasEvents();if(b.opts==null||b.opts.ignoreAnimation!=true)for(var l=0;l<b.Animations.length;l++)k|=b.Animations[l].update(1E3/
b.FRAMERATE);if(b.opts!=null&&typeof b.opts.forceRedraw=="function")if(b.opts.forceRedraw()==true)k=true;if(k){h();b.Mouse.runEvents()}},1E3/b.FRAMERATE)};b.stop=function(){b.intervalID&&clearInterval(b.intervalID)};b.Mouse=new function(){this.events=[];this.hasEvents=function(){return this.events.length!=0};this.onclick=function(e,c){this.events.push({type:"onclick",x:e,y:c,run:function(a){a.onclick&&a.onclick()}})};this.onmousemove=function(e,c){this.events.push({type:"onmousemove",x:e,y:c,run:function(a){a.onmousemove&&
a.onmousemove()}})};this.eventElements=[];this.checkPath=function(e,c){for(var a=0;a<this.events.length;a++){var f=this.events[a];if(c.isPointInPath&&c.isPointInPath(f.x,f.y))this.eventElements[a]=e}};this.checkBoundingBox=function(e,c){for(var a=0;a<this.events.length;a++){var f=this.events[a];if(c.isPointInBox(f.x,f.y))this.eventElements[a]=e}};this.runEvents=function(){b.ctx.canvas.style.cursor="";for(var e=0;e<this.events.length;e++)for(var c=this.events[e],a=this.eventElements[e];a;){c.run(a);
a=a.parent}this.events=[];this.eventElements=[]}};return b}this.canvg=function(b,e,c){if(b==null&&e==null&&c==null){e=document.getElementsByTagName("svg");for(var a=0;a<e.length;a++){b=e[a];c=document.createElement("canvas");c.width=b.clientWidth;c.height=b.clientHeight;b.parentNode.insertBefore(c,b);b.parentNode.removeChild(b);var f=document.createElement("div");f.appendChild(b);canvg(c,f.innerHTML)}}else{if(typeof b=="string")b=document.getElementById(b);if(b.svg==null){a=r();b.svg=a}else{a=b.svg;
a.stop()}a.opts=c;b=b.getContext("2d");e.substr(0,1)=="<"?a.loadXml(b,e):a.load(b,e)}}})();if(CanvasRenderingContext2D)CanvasRenderingContext2D.prototype.drawSvg=function(r,b,e,c,a){canvg(this.canvas,r,{ignoreMouse:true,ignoreAnimation:true,ignoreDimensions:true,ignoreClear:true,offsetX:b,offsetY:e,scaleWidth:c,scaleHeight:a})};
function RGBColor(r){this.ok=false;if(r.charAt(0)=="#")r=r.substr(1,6);r=r.replace(/ /g,"");r=r.toLowerCase();var b={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",
darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",
gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",
lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",
oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",
slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"},e;for(e in b)if(r==e)r=b[e];var c=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(d){return[parseInt(d[1]),parseInt(d[2]),parseInt(d[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,
example:["#00ff00","336699"],process:function(d){return[parseInt(d[1],16),parseInt(d[2],16),parseInt(d[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(d){return[parseInt(d[1]+d[1],16),parseInt(d[2]+d[2],16),parseInt(d[3]+d[3],16)]}}];for(e=0;e<c.length;e++){var a=c[e].process,f=c[e].re.exec(r);if(f){channels=a(f);this.r=channels[0];this.g=channels[1];this.b=channels[2];this.ok=true}}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r;this.g=this.g<0||isNaN(this.g)?
0:this.g>255?255:this.g;this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b;this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"};this.toHex=function(){var d=this.r.toString(16),g=this.g.toString(16),h=this.b.toString(16);if(d.length==1)d="0"+d;if(g.length==1)g="0"+g;if(h.length==1)h="0"+h;return"#"+d+g+h};this.getHelpXML=function(){for(var d=[],g=0;g<c.length;g++)for(var h=c[g].example,j=0;j<h.length;j++)d[d.length]=h[j];for(var k in b)d[d.length]=k;h=document.createElement("ul");
h.setAttribute("id","rgbcolor-examples");for(g=0;g<d.length;g++)try{var l=document.createElement("li"),p=new RGBColor(d[g]),m=document.createElement("div");m.style.cssText="margin: 3px; border: 1px solid black; background:"+p.toHex()+"; color:"+p.toHex();m.appendChild(document.createTextNode("test"));var o=document.createTextNode(" "+d[g]+" -> "+p.toRGB()+" -> "+p.toHex());l.appendChild(m);l.appendChild(o);h.appendChild(l)}catch(n){}return h}};
