if(!Array.prototype.indexOf)Array.prototype.indexOf=function(r,n,w){n=+n||0;for(var p=this.length;n
g)g=f;if(c<0){m+=c;
c=Math.abs(c);g+=c;t[0]+=c;l+=c;q+=c;b[0]+=c}c=Math.min(Math.min(s,d),Math.min(t[1],b[1]));f=Math.max(Math.max(s,d),Math.max(t[1],b[1]));if(f>i)i=f;if(c<0){j+=c;c=Math.abs(c);i+=c;t[1]+=c;s+=c;d+=c;b[1]+=c}return[m,j,g,i,l,s,q,d,t[0],t[1],b[0],b[1]]};this.paint=function(b,c){c.beginPath();c.moveTo(b[4],b[5]);c.bezierCurveTo(b[8],b[9],b[10],b[11],b[6],b[7]);c.stroke()}}},Endpoints:{Dot:function(a){a=a||{radius:10};var e=this;this.radius=a.radius;var b=0.5*this.radius,c=this.radius/3,f=function(d){try{return parseInt(d)}catch(g){if(d.substring(d.length-
1)=="%")return parseInt(d.substring(0,d-1))}},h=function(d){var g=b,i=c;if(d.offset)g=f(d.offset);if(d.innerRadius)i=f(d.innerRadius);return[g,i]};this.paint=function(d,g,i,m,j){var l=m.radius||e.radius;k.sizeCanvas(i,d[0]-l,d[1]-l,l*2,l*2);d=i.getContext("2d");i={};z(i,m);if(i.fillStyle==null)i.fillStyle=j.strokeStyle;z(d,i);j=/MSIE/.test(navigator.userAgent)&&!window.opera;if(m.gradient&&!j){j=h(m.gradient);g=d.createRadialGradient(l,l,l,l+(g[0]==1?j[0]*-1:j[0]),l+(g[1]==1?j[0]*-1:j[0]),j[1]);for(j=
0;j=4)b.orientation=[arguments[2],arguments[3]];if(arguments.length==6)b.offsets=[arguments[4],arguments[5]]}return new u(b)},repaint:function(a){var e=function(f,h){for(var d=o[h],g={absolutePosition:f.offset()},i=0;i0)B(a,"none"==e[0].canvas.style.display?"block":"none")},
unload:function(){delete o;delete x;delete y}},E=function(a){var e=this;this.source=typeof a.source=="string"?$("#"+a.source):a.source;this.target=typeof a.target=="string"?$("#"+a.target):a.target;this.sourceId=$(this.source).attr("id");this.targetId=$(this.target).attr("id");this.drawEndpoints=a.drawEndpoints!=null?a.drawEndpoints:true;this.endpointsOnTop=a.endpointsOnTop!=null?a.endpointsOnTop:true;this.anchors=a.anchors||k.DEFAULT_ANCHORS||[k.Anchors.BottomCenter,k.Anchors.TopCenter];this.connector=
a.connector||k.DEFAULT_CONNECTOR||new k.Connectors.Bezier;this.paintStyle=a.paintStyle||k.DEFAULT_PAINT_STYLE;this.endpoints=[];if(!a.endpoints)a.endpoints=[null,null];this.endpoints[0]=a.endpoints[0]||a.endpoint||k.DEFAULT_ENDPOINTS[0]||k.DEFAULT_ENDPOINT||new k.Endpoints.Dot;this.endpoints[1]=a.endpoints[1]||a.endpoint||k.DEFAULT_ENDPOINTS[1]||k.DEFAULT_ENDPOINT||new k.Endpoints.Dot;this.endpointStyles=[];if(!a.endpointStyles)a.endpointStyles=[null,null];this.endpointStyles[0]=a.endpointStyles[0]||
a.endpointStyle||k.DEFAULT_ENDPOINT_STYLES[0]||k.DEFAULT_ENDPOINT_STYLE;this.endpointStyles[1]=a.endpointStyles[1]||a.endpointStyle||k.DEFAULT_ENDPOINT_STYLES[1]||k.DEFAULT_ENDPOINT_STYLE;x[this.sourceId]=this.source.offset();y[this.sourceId]=[this.source.outerWidth(),this.source.outerHeight()];x[this.targetId]=this.target.offset();y[this.targetId]=[this.target.outerWidth(),this.target.outerHeight()];var b=C(k.connectorClass);this.canvas=b;if(this.drawEndpoints){this.sourceEndpointCanvas=C(k.endpointClass);
this.targetEndpointCanvas=C(k.endpointClass);if(this.endpointsOnTop){$(this.sourceEndpointCanvas).css("zIndex",this.source.css("zIndex")+1);$(this.targetEndpointCanvas).css("zIndex",this.target.css("zIndex")+1)}else{$(this.sourceEndpointCanvas).css("zIndex",this.source.css("zIndex")-1);$(this.targetEndpointCanvas).css("zIndex",this.target.css("zIndex")-1)}}this.paint=function(h,d,g){var i=h!=this.sourceId,m=i?this.sourceId:this.targetId,j=i?0:1,l=i?1:0;if(this.canvas.getContext){if(g){d=$("#"+h);
g=$("#"+m);y[h]=[d.outerWidth(),d.outerHeight()];y[m]=[g.outerWidth(),g.outerHeight()];x[h]=d.offset();x[m]=g.offset()}else{g=d.absolutePosition||d.offset;d=d!=null?g:$("#"+h).offset();x[h]=d}g=x[h];var s=x[m],q=y[h],t=y[m];d=b.getContext("2d");m=this.anchors[l].compute([g.left,g.top],q,[s.left,s.top],t);h=this.anchors[l].orientation;g=this.anchors[j].compute([s.left,s.top],t,[g.left,g.top],q);s=this.anchors[j].orientation;j=this.connector.compute(m,g,this.anchors[l],this.anchors[j],this.paintStyle.lineWidth);
k.sizeCanvas(b,j[0],j[1],j[2],j[3]);z(d,this.paintStyle);l=/MSIE/.test(navigator.userAgent)&&!window.opera;if(this.paintStyle.gradient&&!l){l=i?d.createLinearGradient(j[4],j[5],j[6],j[7]):d.createLinearGradient(j[6],j[7],j[4],j[5]);for(q=0;q