Raphael=(function(){
function R(){
if(R.is(arguments[0],_1)){
var a=arguments[0],_3=_4[_5](R,a.splice(0,3+R.is(a[0],nu))),_7=_3.set();
for(var i=0,ii=a[_a];i<ii;i++){
var j=a[i]||{};
_c.test(j.type)&&_7[_d](_3[j.type]().attr(j));
}
return _7;
}
return _4[_5](R,arguments);
}
R.version="1.4.3";
var _e=/[, ]+/,_c=/^(circle|rect|path|ellipse|text|image)$/,_f="prototype",has="hasOwnProperty",doc=document,win=window,_13={was:Object[_f][has].call(win,"Raphael"),is:win.Raphael},_14=function(){
},_15="appendChild",_5="apply",_16="concat",_17="createTouch" in doc,E="",S=" ",_1a="split",_1b="click dblclick mousedown mousemove mouseout mouseover mouseup touchstart touchmove touchend orientationchange touchcancel gesturestart gesturechange gestureend"[_1a](S),_1c={mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"},_1d="join",_a="length",_1e=String[_f].toLowerCase,_1f=Math,_20=_1f.max,_21=_1f.min,nu="number",_22="string",_1="array",_23="toString",_24="fill",_25=Object[_f][_23],_26={},pow=_1f.pow,_d="push",rg=/^(?=[\da-f]$)/,_29=/^url\(['"]?([^\)]+?)['"]?\)$/i,_2a=/^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+\s*,\s*[\d\.]+\s*,\s*[\d\.]+(?:\s*,\s*[\d\.]+)?)\s*\)|rgba?\(\s*([\d\.]+%\s*,\s*[\d\.]+%\s*,\s*[\d\.]+%(?:\s*,\s*[\d\.]+%))\s*\)|hs[bl]\(\s*([\d\.]+\s*,\s*[\d\.]+\s*,\s*[\d\.]+)\s*\)|hs[bl]\(\s*([\d\.]+%\s*,\s*[\d\.]+%\s*,\s*[\d\.]+%)\s*\))\s*$/i,_2b=_1f.round,_2c="setAttribute",_2d=parseFloat,_2e=parseInt,ms=" progid:DXImageTransform.Microsoft",_30=String[_f].toUpperCase,_31={blur:0,"clip-rect":"0 0 1e9 1e9",cursor:"default",cx:0,cy:0,fill:"#fff","fill-opacity":1,font:"10px \"Arial\"","font-family":"\"Arial\"","font-size":"10","font-style":"normal","font-weight":400,gradient:0,height:0,href:"http://raphaeljs.com/",opacity:1,path:"M0,0",r:0,rotation:0,rx:0,ry:0,scale:"1 1",src:"",stroke:"#000","stroke-dasharray":"","stroke-linecap":"butt","stroke-linejoin":"butt","stroke-miterlimit":0,"stroke-opacity":1,"stroke-width":1,target:"_blank","text-anchor":"middle",title:"Raphael",translation:"0 0",width:0,x:0,y:0},_32={along:"along",blur:nu,"clip-rect":"csv",cx:nu,cy:nu,fill:"colour","fill-opacity":nu,"font-size":nu,height:nu,opacity:nu,path:"path",r:nu,rotation:"csv",rx:nu,ry:nu,scale:"csv",stroke:"colour","stroke-opacity":nu,"stroke-width":nu,translation:"csv",width:nu,x:nu,y:nu},rp="replace";
R.type=(win.SVGAngle||doc.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure","1.1")?"SVG":"VML");
if(R.type=="VML"){
var d=doc.createElement("div");
d.innerHTML="<!--[if vml]><br><br><![endif]-->";
if(d.childNodes[_a]!=2){
return R.type=null;
}
d=null;
}
R.svg=!(R.vml=R.type=="VML");
_14[_f]=R[_f];
R._id=0;
R._oid=0;
R.fn={};
R.is=function(o,_36){
_36=_1e.call(_36);
return (_36=="object"&&o===Object(o))||(_36=="undefined"&&typeof o==_36)||(_36=="null"&&o==null)||_1e.call(_25.call(o).slice(8,-1))==_36;
};
R.setWindow=function(_37){
win=_37;
doc=win.document;
};
var _38=function(_39){
if(R.vml){
var _3a=/^\s+|\s+$/g;
_38=cacher(function(_3b){
var bod;
_3b=(_3b+E)[rp](_3a,E);
try{
var _3d=new win.ActiveXObject("htmlfile");
_3d.write("<body>");
_3d.close();
bod=_3d.body;
}
catch(e){
bod=win.createPopup().document.body;
}
var _3e=bod.createTextRange();
try{
bod.style.color=_3b;
var _3f=_3e.queryCommandValue("ForeColor");
_3f=((_3f&255)<<16)|(_3f&65280)|((_3f&16711680)>>>16);
return "#"+("000000"+_3f[_23](16)).slice(-6);
}
catch(e){
return "none";
}
});
}else{
var i=doc.createElement("i");
i.title="Rapha\xebl Colour Picker";
i.style.display="none";
doc.body[_15](i);
_38=cacher(function(_41){
i.style.color=_41;
return doc.defaultView.getComputedStyle(i,E).getPropertyValue("color");
});
}
return _38(_39);
};
var _42=function(){
return "hsb("+[this.h,this.s,this.b]+")";
},_43=function(){
return this.hex;
};
R.hsb2rgb=cacher(function(hue,_45,_46){
if(R.is(hue,"object")&&"h" in hue&&"s" in hue&&"b" in hue){
_46=hue.b;
_45=hue.s;
hue=hue.h;
}
var red,_48,_49;
if(_46==0){
return {r:0,g:0,b:0,hex:"#000"};
}
if(hue>1||_45>1||_46>1){
hue/=255;
_45/=255;
_46/=255;
}
var i=~~(hue*6),f=(hue*6)-i,p=_46*(1-_45),q=_46*(1-(_45*f)),t=_46*(1-(_45*(1-f)));
red=[_46,q,p,p,t,_46,_46][i];
_48=[t,_46,_46,q,p,p,t][i];
_49=[p,p,t,_46,_46,q,p][i];
red*=255;
_48*=255;
_49*=255;
var rgb={r:red,g:_48,b:_49,toString:_43},r=(~~red)[_23](16),g=(~~_48)[_23](16),b=(~~_49)[_23](16);
r=r[rp](rg,"0");
g=g[rp](rg,"0");
b=b[rp](rg,"0");
rgb.hex="#"+r+g+b;
return rgb;
},R);
R.rgb2hsb=cacher(function(red,_54,_55){
if(R.is(red,"object")&&"r" in red&&"g" in red&&"b" in red){
_55=red.b;
_54=red.g;
red=red.r;
}
if(R.is(red,_22)){
var clr=R.getRGB(red);
red=clr.r;
_54=clr.g;
_55=clr.b;
}
if(red>1||_54>1||_55>1){
red/=255;
_54/=255;
_55/=255;
}
var max=_20(red,_54,_55),min=_21(red,_54,_55),hue,_5a,_5b=max;
if(min==max){
return {h:0,s:0,b:max};
}else{
var _5c=(max-min);
_5a=_5c/max;
if(red==max){
hue=(_54-_55)/_5c;
}else{
if(_54==max){
hue=2+((_55-red)/_5c);
}else{
hue=4+((red-_54)/_5c);
}
}
hue/=6;
hue<0&&hue++;
hue>1&&hue--;
}
return {h:hue,s:_5a,b:_5b,toString:_42};
},R);
var p2s=/,?([achlmqrstvxz]),?/gi,_5e=/\s*,\s*/,_5f={hs:1,rg:1};
R._path2string=function(){
return this.join(",")[rp](p2s,"$1");
};
function cacher(f,_61,_62){
function newf(){
var arg=Array[_f].slice.call(arguments,0),_64=arg[_1d]("\u25ba"),_65=newf.cache=newf.cache||{},_66=newf.count=newf.count||[];
if(_65[has](_64)){
return _62?_62(_65[_64]):_65[_64];
}
_66[_a]>=1000&&delete _65[_66.shift()];
_66[_d](_64);
_65[_64]=f[_5](_61,arg);
return _62?_62(_65[_64]):_65[_64];
}
return newf;
}
R.getRGB=cacher(function(_67){
if(!_67||!!((_67=_67+E).indexOf("-")+1)){
return {r:-1,g:-1,b:-1,hex:"none",error:1};
}
if(_67=="none"){
return {r:-1,g:-1,b:-1,hex:"none"};
}
!(_5f[has](_67.substring(0,2))||_67.charAt()=="#")&&(_67=_38(_67));
var res,red,_6a,_6b,_6c,t,rgb=_67.match(_2a);
if(rgb){
if(rgb[2]){
_6b=_2e(rgb[2].substring(5),16);
_6a=_2e(rgb[2].substring(3,5),16);
red=_2e(rgb[2].substring(1,3),16);
}
if(rgb[3]){
_6b=_2e((t=rgb[3].charAt(3))+t,16);
_6a=_2e((t=rgb[3].charAt(2))+t,16);
red=_2e((t=rgb[3].charAt(1))+t,16);
}
if(rgb[4]){
rgb=rgb[4][_1a](_5e);
red=_2d(rgb[0]);
_6a=_2d(rgb[1]);
_6b=_2d(rgb[2]);
_6c=_2d(rgb[3]);
}
if(rgb[5]){
rgb=rgb[5][_1a](_5e);
red=_2d(rgb[0])*2.55;
_6a=_2d(rgb[1])*2.55;
_6b=_2d(rgb[2])*2.55;
_6c=_2d(rgb[3]);
}
if(rgb[6]){
rgb=rgb[6][_1a](_5e);
red=_2d(rgb[0]);
_6a=_2d(rgb[1]);
_6b=_2d(rgb[2]);
return R.hsb2rgb(red,_6a,_6b);
}
if(rgb[7]){
rgb=rgb[7][_1a](_5e);
red=_2d(rgb[0])*2.55;
_6a=_2d(rgb[1])*2.55;
_6b=_2d(rgb[2])*2.55;
return R.hsb2rgb(red,_6a,_6b);
}
rgb={r:red,g:_6a,b:_6b};
var r=(~~red)[_23](16),g=(~~_6a)[_23](16),b=(~~_6b)[_23](16);
r=r[rp](rg,"0");
g=g[rp](rg,"0");
b=b[rp](rg,"0");
rgb.hex="#"+r+g+b;
isFinite(_2d(_6c))&&(rgb.o=_6c);
return rgb;
}
return {r:-1,g:-1,b:-1,hex:"none",error:1};
},R);
R.getColor=function(_72){
var _73=this.getColor.start=this.getColor.start||{h:0,s:1,b:_72||0.75},rgb=this.hsb2rgb(_73.h,_73.s,_73.b);
_73.h+=0.075;
if(_73.h>1){
_73.h=0;
_73.s-=0.2;
_73.s<=0&&(this.getColor.start={h:0,s:1,b:_73.b});
}
return rgb.hex;
};
R.getColor.reset=function(){
delete this.start;
};
var _75=/([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/ig,_76=/(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/ig;
R.parsePathString=cacher(function(_77){
if(!_77){
return null;
}
var _78={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},_79=[];
if(R.is(_77,_1)&&R.is(_77[0],_1)){
_79=pathClone(_77);
}
if(!_79[_a]){
(_77+E)[rp](_75,function(a,b,c){
var _7d=[],_7e=_1e.call(b);
c[rp](_76,function(a,b){
b&&_7d[_d](+b);
});
if(_7e=="m"&&_7d[_a]>2){
_79[_d]([b][_16](_7d.splice(0,2)));
_7e="l";
b=b=="m"?"l":"L";
}
while(_7d[_a]>=_78[_7e]){
_79[_d]([b][_16](_7d.splice(0,_78[_7e])));
if(!_78[_7e]){
break;
}
}
});
}
_79[_23]=R._path2string;
return _79;
});
R.findDotsAtSegment=function(p1x,p1y,c1x,c1y,c2x,c2y,p2x,p2y,t){
var t1=1-t,x=pow(t1,3)*p1x+pow(t1,2)*3*t*c1x+t1*3*t*t*c2x+pow(t,3)*p2x,y=pow(t1,3)*p1y+pow(t1,2)*3*t*c1y+t1*3*t*t*c2y+pow(t,3)*p2y,mx=p1x+2*t*(c1x-p1x)+t*t*(c2x-2*c1x+p1x),my=p1y+2*t*(c1y-p1y)+t*t*(c2y-2*c1y+p1y),nx=c1x+2*t*(c2x-c1x)+t*t*(p2x-2*c2x+c1x),ny=c1y+2*t*(c2y-c1y)+t*t*(p2y-2*c2y+c1y),ax=(1-t)*p1x+t*c1x,ay=(1-t)*p1y+t*c1y,cx=(1-t)*c2x+t*p2x,cy=(1-t)*c2y+t*p2y,_95=(90-_1f.atan((mx-nx)/(my-ny))*180/_1f.PI);
(mx>nx||my<ny)&&(_95+=180);
return {x:x,y:y,m:{x:mx,y:my},n:{x:nx,y:ny},start:{x:ax,y:ay},end:{x:cx,y:cy},alpha:_95};
};
var _96=cacher(function(_97){
if(!_97){
return {x:0,y:0,width:0,height:0};
}
_97=_98(_97);
var x=0,y=0,X=[],Y=[],p;
for(var i=0,ii=_97[_a];i<ii;i++){
p=_97[i];
if(p[0]=="M"){
x=p[1];
y=p[2];
X[_d](x);
Y[_d](y);
}else{
var dim=_a1(x,y,p[1],p[2],p[3],p[4],p[5],p[6]);
X=X[_16](dim.min.x,dim.max.x);
Y=Y[_16](dim.min.y,dim.max.y);
x=p[5];
y=p[6];
}
}
var _a2=_21[_5](0,X),_a3=_21[_5](0,Y);
return {x:_a2,y:_a3,width:_20[_5](0,X)-_a2,height:_20[_5](0,Y)-_a3};
}),_a4=function(_a5){
var res=[];
if(!R.is(_a5,_1)||!R.is(_a5&&_a5[0],_1)){
_a5=R.parsePathString(_a5);
}
for(var i=0,ii=_a5[_a];i<ii;i++){
res[i]=[];
for(var j=0,jj=_a5[i][_a];j<jj;j++){
res[i][j]=_a5[i][j];
}
}
res[_23]=R._path2string;
return res;
},_ab=cacher(function(_ac){
if(!R.is(_ac,_1)||!R.is(_ac&&_ac[0],_1)){
_ac=R.parsePathString(_ac);
}
var res=[],x=0,y=0,mx=0,my=0,_b2=0;
if(_ac[0][0]=="M"){
x=_ac[0][1];
y=_ac[0][2];
mx=x;
my=y;
_b2++;
res[_d](["M",x,y]);
}
for(var i=_b2,ii=_ac[_a];i<ii;i++){
var r=res[i]=[],pa=_ac[i];
if(pa[0]!=_1e.call(pa[0])){
r[0]=_1e.call(pa[0]);
switch(r[0]){
case "a":
r[1]=pa[1];
r[2]=pa[2];
r[3]=pa[3];
r[4]=pa[4];
r[5]=pa[5];
r[6]=+(pa[6]-x).toFixed(3);
r[7]=+(pa[7]-y).toFixed(3);
break;
case "v":
r[1]=+(pa[1]-y).toFixed(3);
break;
case "m":
mx=pa[1];
my=pa[2];
default:
for(var j=1,jj=pa[_a];j<jj;j++){
r[j]=+(pa[j]-((j%2)?x:y)).toFixed(3);
}
}
}else{
r=res[i]=[];
if(pa[0]=="m"){
mx=pa[1]+x;
my=pa[2]+y;
}
for(var k=0,kk=pa[_a];k<kk;k++){
res[i][k]=pa[k];
}
}
var len=res[i][_a];
switch(res[i][0]){
case "z":
x=mx;
y=my;
break;
case "h":
x+=+res[i][len-1];
break;
case "v":
y+=+res[i][len-1];
break;
default:
x+=+res[i][len-2];
y+=+res[i][len-1];
}
}
res[_23]=R._path2string;
return res;
},0,_a4),_bc=cacher(function(_bd){
if(!R.is(_bd,_1)||!R.is(_bd&&_bd[0],_1)){
_bd=R.parsePathString(_bd);
}
var res=[],x=0,y=0,mx=0,my=0,_c3=0;
if(_bd[0][0]=="M"){
x=+_bd[0][1];
y=+_bd[0][2];
mx=x;
my=y;
_c3++;
res[0]=["M",x,y];
}
for(var i=_c3,ii=_bd[_a];i<ii;i++){
var r=res[i]=[],pa=_bd[i];
if(pa[0]!=_30.call(pa[0])){
r[0]=_30.call(pa[0]);
switch(r[0]){
case "A":
r[1]=pa[1];
r[2]=pa[2];
r[3]=pa[3];
r[4]=pa[4];
r[5]=pa[5];
r[6]=+(pa[6]+x);
r[7]=+(pa[7]+y);
break;
case "V":
r[1]=+pa[1]+y;
break;
case "H":
r[1]=+pa[1]+x;
break;
case "M":
mx=+pa[1]+x;
my=+pa[2]+y;
default:
for(var j=1,jj=pa[_a];j<jj;j++){
r[j]=+pa[j]+((j%2)?x:y);
}
}
}else{
for(var k=0,kk=pa[_a];k<kk;k++){
res[i][k]=pa[k];
}
}
switch(r[0]){
case "Z":
x=mx;
y=my;
break;
case "H":
x=r[1];
break;
case "V":
y=r[1];
break;
default:
x=res[i][res[i][_a]-2];
y=res[i][res[i][_a]-1];
}
}
res[_23]=R._path2string;
return res;
},null,_a4),l2c=function(x1,y1,x2,y2){
return [x1,y1,x2,y2,x2,y2];
},q2c=function(x1,y1,ax,ay,x2,y2){
var _13=1/3,_23=2/3;
return [_13*x1+_23*ax,_13*y1+_23*ay,_13*x2+_23*ax,_13*y2+_23*ay,x2,y2];
},a2c=function(x1,y1,rx,ry,_df,_e0,_e1,x2,y2,_e4){
var PI=_1f.PI,_e6=PI*120/180,rad=PI/180*(+_df||0),res=[],xy,_ea=cacher(function(x,y,rad){
var X=x*_1f.cos(rad)-y*_1f.sin(rad),Y=x*_1f.sin(rad)+y*_1f.cos(rad);
return {x:X,y:Y};
});
if(!_e4){
xy=_ea(x1,y1,-rad);
x1=xy.x;
y1=xy.y;
xy=_ea(x2,y2,-rad);
x2=xy.x;
y2=xy.y;
var cos=_1f.cos(PI/180*_df),sin=_1f.sin(PI/180*_df),x=(x1-x2)/2,y=(y1-y2)/2;
var h=(x*x)/(rx*rx)+(y*y)/(ry*ry);
if(h>1){
h=_1f.sqrt(h);
rx=h*rx;
ry=h*ry;
}
var rx2=rx*rx,ry2=ry*ry,k=(_e0==_e1?-1:1)*_1f.sqrt(_1f.abs((rx2*ry2-rx2*y*y-ry2*x*x)/(rx2*y*y+ry2*x*x))),cx=k*rx*y/ry+(x1+x2)/2,cy=k*-ry*x/rx+(y1+y2)/2,f1=_1f.asin(((y1-cy)/ry).toFixed(7)),f2=_1f.asin(((y2-cy)/ry).toFixed(7));
f1=x1<cx?PI-f1:f1;
f2=x2<cx?PI-f2:f2;
f1<0&&(f1=PI*2+f1);
f2<0&&(f2=PI*2+f2);
if(_e1&&f1>f2){
f1=f1-PI*2;
}
if(!_e1&&f2>f1){
f2=f2-PI*2;
}
}else{
f1=_e4[0];
f2=_e4[1];
cx=_e4[2];
cy=_e4[3];
}
var df=f2-f1;
if(_1f.abs(df)>_e6){
var _fd=f2,_fe=x2,_ff=y2;
f2=f1+_e6*(_e1&&f2>f1?1:-1);
x2=cx+rx*_1f.cos(f2);
y2=cy+ry*_1f.sin(f2);
res=a2c(x2,y2,rx,ry,_df,0,_e1,_fe,_ff,[f2,_fd,cx,cy]);
}
df=f2-f1;
var c1=_1f.cos(f1),s1=_1f.sin(f1),c2=_1f.cos(f2),s2=_1f.sin(f2),t=_1f.tan(df/4),hx=4/3*rx*t,hy=4/3*ry*t,m1=[x1,y1],m2=[x1+hx*s1,y1-hy*c1],m3=[x2+hx*s2,y2-hy*c2],m4=[x2,y2];
m2[0]=2*m1[0]-m2[0];
m2[1]=2*m1[1]-m2[1];
if(_e4){
return [m2,m3,m4][_16](res);
}else{
res=[m2,m3,m4][_16](res)[_1d]()[_1a](",");
var _10b=[];
for(var i=0,ii=res[_a];i<ii;i++){
_10b[i]=i%2?_ea(res[i-1],res[i],rad).y:_ea(res[i],res[i+1],rad).x;
}
return _10b;
}
},_10e=function(p1x,p1y,c1x,c1y,c2x,c2y,p2x,p2y,t){
var t1=1-t;
return {x:pow(t1,3)*p1x+pow(t1,2)*3*t*c1x+t1*3*t*t*c2x+pow(t,3)*p2x,y:pow(t1,3)*p1y+pow(t1,2)*3*t*c1y+t1*3*t*t*c2y+pow(t,3)*p2y};
},_a1=cacher(function(p1x,p1y,c1x,c1y,c2x,c2y,p2x,p2y){
var a=(c2x-2*c1x+p1x)-(p2x-2*c2x+c1x),b=2*(c1x-p1x)-2*(c2x-c1x),c=p1x-c1x,t1=(-b+_1f.sqrt(b*b-4*a*c))/2/a,t2=(-b-_1f.sqrt(b*b-4*a*c))/2/a,y=[p1y,p2y],x=[p1x,p2x],dot;
_1f.abs(t1)>1000000000000&&(t1=0.5);
_1f.abs(t2)>1000000000000&&(t2=0.5);
if(t1>0&&t1<1){
dot=_10e(p1x,p1y,c1x,c1y,c2x,c2y,p2x,p2y,t1);
x[_d](dot.x);
y[_d](dot.y);
}
if(t2>0&&t2<1){
dot=_10e(p1x,p1y,c1x,c1y,c2x,c2y,p2x,p2y,t2);
x[_d](dot.x);
y[_d](dot.y);
}
a=(c2y-2*c1y+p1y)-(p2y-2*c2y+c1y);
b=2*(c1y-p1y)-2*(c2y-c1y);
c=p1y-c1y;
t1=(-b+_1f.sqrt(b*b-4*a*c))/2/a;
t2=(-b-_1f.sqrt(b*b-4*a*c))/2/a;
_1f.abs(t1)>1000000000000&&(t1=0.5);
_1f.abs(t2)>1000000000000&&(t2=0.5);
if(t1>0&&t1<1){
dot=_10e(p1x,p1y,c1x,c1y,c2x,c2y,p2x,p2y,t1);
x[_d](dot.x);
y[_d](dot.y);
}
if(t2>0&&t2<1){
dot=_10e(p1x,p1y,c1x,c1y,c2x,c2y,p2x,p2y,t2);
x[_d](dot.x);
y[_d](dot.y);
}
return {min:{x:_21[_5](0,x),y:_21[_5](0,y)},max:{x:_20[_5](0,x),y:_20[_5](0,y)}};
}),_98=cacher(function(path,_12a){
var p=_bc(path),p2=_12a&&_bc(_12a),_12d={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},_12e={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},_12f=function(path,d){
var nx,ny;
if(!path){
return ["C",d.x,d.y,d.x,d.y,d.x,d.y];
}
!(path[0] in {T:1,Q:1})&&(d.qx=d.qy=null);
switch(path[0]){
case "M":
d.X=path[1];
d.Y=path[2];
break;
case "A":
path=["C"][_16](a2c[_5](0,[d.x,d.y][_16](path.slice(1))));
break;
case "S":
nx=d.x+(d.x-(d.bx||d.x));
ny=d.y+(d.y-(d.by||d.y));
path=["C",nx,ny][_16](path.slice(1));
break;
case "T":
d.qx=d.x+(d.x-(d.qx||d.x));
d.qy=d.y+(d.y-(d.qy||d.y));
path=["C"][_16](q2c(d.x,d.y,d.qx,d.qy,path[1],path[2]));
break;
case "Q":
d.qx=path[1];
d.qy=path[2];
path=["C"][_16](q2c(d.x,d.y,path[1],path[2],path[3],path[4]));
break;
case "L":
path=["C"][_16](l2c(d.x,d.y,path[1],path[2]));
break;
case "H":
path=["C"][_16](l2c(d.x,d.y,path[1],d.y));
break;
case "V":
path=["C"][_16](l2c(d.x,d.y,d.x,path[1]));
break;
case "Z":
path=["C"][_16](l2c(d.x,d.y,d.X,d.Y));
break;
}
return path;
},_134=function(pp,i){
if(pp[i][_a]>7){
pp[i].shift();
var pi=pp[i];
while(pi[_a]){
pp.splice(i++,0,["C"][_16](pi.splice(0,6)));
}
pp.splice(i,1);
ii=_20(p[_a],p2&&p2[_a]||0);
}
},fixM=function(_13a,_13b,a1,a2,i){
if(_13a&&_13b&&_13a[i][0]=="M"&&_13b[i][0]!="M"){
_13b.splice(i,0,["M",a2.x,a2.y]);
a1.bx=0;
a1.by=0;
a1.x=_13a[i][1];
a1.y=_13a[i][2];
ii=_20(p[_a],p2&&p2[_a]||0);
}
};
for(var i=0,ii=_20(p[_a],p2&&p2[_a]||0);i<ii;i++){
p[i]=_12f(p[i],_12d);
_134(p,i);
p2&&(p2[i]=_12f(p2[i],_12e));
p2&&_134(p2,i);
fixM(p,p2,_12d,_12e,i);
fixM(p2,p,_12e,_12d,i);
var seg=p[i],seg2=p2&&p2[i],_142=seg[_a],_143=p2&&seg2[_a];
_12d.x=seg[_142-2];
_12d.y=seg[_142-1];
_12d.bx=_2d(seg[_142-4])||_12d.x;
_12d.by=_2d(seg[_142-3])||_12d.y;
_12e.bx=p2&&(_2d(seg2[_143-4])||_12e.x);
_12e.by=p2&&(_2d(seg2[_143-3])||_12e.y);
_12e.x=p2&&seg2[_143-2];
_12e.y=p2&&seg2[_143-1];
}
return p2?[p,p2]:p;
},null,_a4),_144=cacher(function(_145){
var dots=[];
for(var i=0,ii=_145[_a];i<ii;i++){
var dot={},par=_145[i].match(/^([^:]*):?([\d\.]*)/);
dot.color=R.getRGB(par[1]);
if(dot.color.error){
return null;
}
dot.color=dot.color.hex;
par[2]&&(dot.offset=par[2]+"%");
dots[_d](dot);
}
for(i=1,ii=dots[_a]-1;i<ii;i++){
if(!dots[i].offset){
var _14b=_2d(dots[i-1].offset||0),end=0;
for(var j=i+1;j<ii;j++){
if(dots[j].offset){
end=dots[j].offset;
break;
}
}
if(!end){
end=100;
j=ii;
}
end=_2d(end);
var d=(end-_14b)/(j-i+1);
for(;i<j;i++){
_14b+=d;
dots[i].offset=_14b+"%";
}
}
}
return dots;
}),_14f=function(x,y,w,h){
var _154;
if(R.is(x,_22)||R.is(x,"object")){
_154=R.is(x,_22)?doc.getElementById(x):x;
if(_154.tagName){
if(y==null){
return {container:_154,width:_154.style.pixelWidth||_154.offsetWidth,height:_154.style.pixelHeight||_154.offsetHeight};
}else{
return {container:_154,width:y,height:w};
}
}
}else{
return {container:1,x:x,y:y,width:w,height:h};
}
},_155=function(con,add){
var that=this;
for(var prop in add){
if(add[has](prop)&&!(prop in con)){
switch(typeof add[prop]){
case "function":
(function(f){
con[prop]=con===that?f:function(){
return f[_5](that,arguments);
};
})(add[prop]);
break;
case "object":
con[prop]=con[prop]||{};
_155.call(this,con[prop],add[prop]);
break;
default:
con[prop]=add[prop];
break;
}
}
}
},tear=function(el,_15d){
el==_15d.top&&(_15d.top=el.prev);
el==_15d.bottom&&(_15d.bottom=el.next);
el.next&&(el.next.prev=el.prev);
el.prev&&(el.prev.next=el.next);
},_15e=function(el,_160){
if(_160.top===el){
return;
}
tear(el,_160);
el.next=null;
el.prev=_160.top;
_160.top.next=el;
_160.top=el;
},_161=function(el,_163){
if(_163.bottom===el){
return;
}
tear(el,_163);
el.next=_163.bottom;
el.prev=null;
_163.bottom.prev=el;
_163.bottom=el;
},_164=function(el,el2,_167){
tear(el,_167);
el2==_167.top&&(_167.top=el);
el2.next&&(el2.next.prev=el);
el.next=el2.next;
el.prev=el2;
el2.next=el;
},_168=function(el,el2,_16b){
tear(el,_16b);
el2==_16b.bottom&&(_16b.bottom=el);
el2.prev&&(el2.prev.next=el);
el.prev=el2.prev;
el2.prev=el;
el.next=el2;
},_16c=function(_16d){
return function(){
throw new Error("Rapha\xebl: you are calling to method \u201c"+_16d+"\u201d of removed object");
};
},_16e=/^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/;
if(R.svg){
_14[_f].svgns="http://www.w3.org/2000/svg";
_14[_f].xlink="http://www.w3.org/1999/xlink";
_2b=function(num){
return +num+(~~num===num)*0.5;
};
var $=function(el,attr){
if(attr){
for(var key in attr){
if(attr[has](key)){
el[_2c](key,attr[key]+E);
}
}
}else{
el=doc.createElementNS(_14[_f].svgns,el);
el.style.webkitTapHighlightColor="rgba(0,0,0,0)";
return el;
}
};
R[_23]=function(){
return "Your browser supports SVG.\nYou are running Rapha\xebl "+this.version;
};
var _174=function(_175,SVG){
var el=$("path");
SVG.canvas&&SVG.canvas[_15](el);
var p=new _179(el,SVG);
p.type="path";
_17a(p,{fill:"none",stroke:"#000",path:_175});
return p;
};
var _17b=function(o,_17d,SVG){
var type="linear",fx=0.5,fy=0.5,s=o.style;
_17d=(_17d+E)[rp](_16e,function(all,_fx,_fy){
type="radial";
if(_fx&&_fy){
fx=_2d(_fx);
fy=_2d(_fy);
var dir=((fy>0.5)*2-1);
pow(fx-0.5,2)+pow(fy-0.5,2)>0.25&&(fy=_1f.sqrt(0.25-pow(fx-0.5,2))*dir+0.5)&&fy!=0.5&&(fy=fy.toFixed(5)-0.00001*dir);
}
return E;
});
_17d=_17d[_1a](/\s*\-\s*/);
if(type=="linear"){
var _187=_17d.shift();
_187=-_2d(_187);
if(isNaN(_187)){
return null;
}
var _188=[0,0,_1f.cos(_187*_1f.PI/180),_1f.sin(_187*_1f.PI/180)],max=1/(_20(_1f.abs(_188[2]),_1f.abs(_188[3]))||1);
_188[2]*=max;
_188[3]*=max;
if(_188[2]<0){
_188[0]=-_188[2];
_188[2]=0;
}
if(_188[3]<0){
_188[1]=-_188[3];
_188[3]=0;
}
}
var dots=_144(_17d);
if(!dots){
return null;
}
var id=o.getAttribute(_24);
id=id.match(/^url\(#(.*)\)$/);
id&&SVG.defs.removeChild(doc.getElementById(id[1]));
var el=$(type+"Gradient");
el.id="r"+(R._id++)[_23](36);
$(el,type=="radial"?{fx:fx,fy:fy}:{x1:_188[0],y1:_188[1],x2:_188[2],y2:_188[3]});
SVG.defs[_15](el);
for(var i=0,ii=dots[_a];i<ii;i++){
var stop=$("stop");
$(stop,{offset:dots[i].offset?dots[i].offset:!i?"0%":"100%","stop-color":dots[i].color||"#fff"});
el[_15](stop);
}
$(o,{fill:"url(#"+el.id+")",opacity:1,"fill-opacity":1});
s.fill=E;
s.opacity=1;
s.fillOpacity=1;
return 1;
};
var _190=function(o){
var bbox=o.getBBox();
$(o.pattern,{patternTransform:R.format("translate({0},{1})",bbox.x,bbox.y)});
};
var _17a=function(o,_194){
var _195={"":[0],"none":[0],"-":[3,1],".":[1,1],"-.":[3,1,1,1],"-..":[3,1,1,1,1,1],". ":[1,3],"- ":[4,3],"--":[8,3],"- .":[4,3,1,3],"--.":[8,3,1,3],"--..":[8,3,1,3,1,3]},node=o.node,_197=o.attrs,rot=o.rotate(),_199=function(o,_19b){
_19b=_195[_1e.call(_19b)];
if(_19b){
var _19c=o.attrs["stroke-width"]||"1",butt={round:_19c,square:_19c,butt:0}[o.attrs["stroke-linecap"]||_194["stroke-linecap"]]||0,_19e=[];
var i=_19b[_a];
while(i--){
_19e[i]=_19b[i]*_19c+((i%2)?1:-1)*butt;
}
$(node,{"stroke-dasharray":_19e[_1d](",")});
}
};
_194[has]("rotation")&&(rot=_194.rotation);
var _1a0=(rot+E)[_1a](_e);
if(!(_1a0.length-1)){
_1a0=null;
}else{
_1a0[1]=+_1a0[1];
_1a0[2]=+_1a0[2];
}
_2d(rot)&&o.rotate(0,true);
for(var att in _194){
if(_194[has](att)){
if(!_31[has](att)){
continue;
}
var _1a2=_194[att];
_197[att]=_1a2;
switch(att){
case "blur":
o.blur(_1a2);
break;
case "rotation":
o.rotate(_1a2,true);
break;
case "href":
case "title":
case "target":
var pn=node.parentNode;
if(_1e.call(pn.tagName)!="a"){
var hl=$("a");
pn.insertBefore(hl,node);
hl[_15](node);
pn=hl;
}
pn.setAttributeNS(o.paper.xlink,att,_1a2);
break;
case "cursor":
node.style.cursor=_1a2;
break;
case "clip-rect":
var rect=(_1a2+E)[_1a](_e);
if(rect[_a]==4){
o.clip&&o.clip.parentNode.parentNode.removeChild(o.clip.parentNode);
var el=$("clipPath"),rc=$("rect");
el.id="r"+(R._id++)[_23](36);
$(rc,{x:rect[0],y:rect[1],width:rect[2],height:rect[3]});
el[_15](rc);
o.paper.defs[_15](el);
$(node,{"clip-path":"url(#"+el.id+")"});
o.clip=rc;
}
if(!_1a2){
var clip=doc.getElementById(node.getAttribute("clip-path")[rp](/(^url\(#|\)$)/g,E));
clip&&clip.parentNode.removeChild(clip);
$(node,{"clip-path":E});
delete o.clip;
}
break;
case "path":
if(o.type=="path"){
$(node,{d:_1a2?_197.path=_bc(_1a2):"M0,0"});
}
break;
case "width":
node[_2c](att,_1a2);
if(_197.fx){
att="x";
_1a2=_197.x;
}else{
break;
}
case "x":
if(_197.fx){
_1a2=-_197.x-(_197.width||0);
}
case "rx":
if(att=="rx"&&o.type=="rect"){
break;
}
case "cx":
_1a0&&(att=="x"||att=="cx")&&(_1a0[1]+=_1a2-_197[att]);
node[_2c](att,_2b(_1a2));
o.pattern&&_190(o);
break;
case "height":
node[_2c](att,_1a2);
if(_197.fy){
att="y";
_1a2=_197.y;
}else{
break;
}
case "y":
if(_197.fy){
_1a2=-_197.y-(_197.height||0);
}
case "ry":
if(att=="ry"&&o.type=="rect"){
break;
}
case "cy":
_1a0&&(att=="y"||att=="cy")&&(_1a0[2]+=_1a2-_197[att]);
node[_2c](att,_2b(_1a2));
o.pattern&&_190(o);
break;
case "r":
if(o.type=="rect"){
$(node,{rx:_1a2,ry:_1a2});
}else{
node[_2c](att,_1a2);
}
break;
case "src":
if(o.type=="image"){
node.setAttributeNS(o.paper.xlink,"href",_1a2);
}
break;
case "stroke-width":
node.style.strokeWidth=_1a2;
node[_2c](att,_1a2);
if(_197["stroke-dasharray"]){
_199(o,_197["stroke-dasharray"]);
}
break;
case "stroke-dasharray":
_199(o,_1a2);
break;
case "translation":
var xy=(_1a2+E)[_1a](_e);
xy[0]=+xy[0]||0;
xy[1]=+xy[1]||0;
if(_1a0){
_1a0[1]+=xy[0];
_1a0[2]+=xy[1];
}
translate.call(o,xy[0],xy[1]);
break;
case "scale":
xy=(_1a2+E)[_1a](_e);
o.scale(+xy[0]||1,+xy[1]||+xy[0]||1,isNaN(_2d(xy[2]))?null:+xy[2],isNaN(_2d(xy[3]))?null:+xy[3]);
break;
case _24:
var _1aa=(_1a2+E).match(_29);
if(_1aa){
el=$("pattern");
var ig=$("image");
el.id="r"+(R._id++)[_23](36);
$(el,{x:0,y:0,patternUnits:"userSpaceOnUse",height:1,width:1});
$(ig,{x:0,y:0});
ig.setAttributeNS(o.paper.xlink,"href",_1aa[1]);
el[_15](ig);
var img=doc.createElement("img");
img.style.cssText="position:absolute;left:-9999em;top-9999em";
img.onload=function(){
$(el,{width:this.offsetWidth,height:this.offsetHeight});
$(ig,{width:this.offsetWidth,height:this.offsetHeight});
doc.body.removeChild(this);
o.paper.safari();
};
doc.body[_15](img);
img.src=_1aa[1];
o.paper.defs[_15](el);
node.style.fill="url(#"+el.id+")";
$(node,{fill:"url(#"+el.id+")"});
o.pattern=el;
o.pattern&&_190(o);
break;
}
var clr=R.getRGB(_1a2);
if(!clr.error){
delete _194.gradient;
delete _197.gradient;
!R.is(_197.opacity,"undefined")&&R.is(_194.opacity,"undefined")&&$(node,{opacity:_197.opacity});
!R.is(_197["fill-opacity"],"undefined")&&R.is(_194["fill-opacity"],"undefined")&&$(node,{"fill-opacity":_197["fill-opacity"]});
}else{
if((({circle:1,ellipse:1})[has](o.type)||(_1a2+E).charAt()!="r")&&_17b(node,_1a2,o.paper)){
_197.gradient=_1a2;
_197.fill="none";
break;
}
}
clr[has]("o")&&$(node,{"fill-opacity":clr.o/100});
case "stroke":
clr=R.getRGB(_1a2);
node[_2c](att,clr.hex);
att=="stroke"&&clr[has]("o")&&$(node,{"stroke-opacity":clr.o/100});
break;
case "gradient":
(({circle:1,ellipse:1})[has](o.type)||(_1a2+E).charAt()!="r")&&_17b(node,_1a2,o.paper);
break;
case "opacity":
case "fill-opacity":
if(_197.gradient){
var _1ae=doc.getElementById(node.getAttribute(_24)[rp](/^url\(#|\)$/g,E));
if(_1ae){
var _1af=_1ae.getElementsByTagName("stop");
_1af[_1af[_a]-1][_2c]("stop-opacity",_1a2);
}
break;
}
default:
att=="font-size"&&(_1a2=_2e(_1a2,10)+"px");
var _1b0=att[rp](/(\-.)/g,function(w){
return _30.call(w.substring(1));
});
node.style[_1b0]=_1a2;
node[_2c](att,_1a2);
break;
}
}
}
_1b2(o,_194);
if(_1a0){
o.rotate(_1a0.join(S));
}else{
_2d(rot)&&o.rotate(rot,true);
}
};
var _1b3=1.2,_1b2=function(el,_1b5){
if(el.type!="text"||!(_1b5[has]("text")||_1b5[has]("font")||_1b5[has]("font-size")||_1b5[has]("x")||_1b5[has]("y"))){
return;
}
var a=el.attrs,node=el.node,_1b8=node.firstChild?_2e(doc.defaultView.getComputedStyle(node.firstChild,E).getPropertyValue("font-size"),10):10;
if(_1b5[has]("text")){
a.text=_1b5.text;
while(node.firstChild){
node.removeChild(node.firstChild);
}
var _1b9=(_1b5.text+E)[_1a]("\n");
for(var i=0,ii=_1b9[_a];i<ii;i++){
if(_1b9[i]){
var _1bc=$("tspan");
i&&$(_1bc,{dy:_1b8*_1b3,x:a.x});
_1bc[_15](doc.createTextNode(_1b9[i]));
node[_15](_1bc);
}
}
}else{
_1b9=node.getElementsByTagName("tspan");
for(i=0,ii=_1b9[_a];i<ii;i++){
i&&$(_1b9[i],{dy:_1b8*_1b3,x:a.x});
}
}
$(node,{y:a.y});
var bb=el.getBBox(),dif=a.y-(bb.y+bb.height/2);
dif&&isFinite(dif)&&$(node,{y:a.y+dif});
},_179=function(node,svg){
var X=0,Y=0;
this[0]=node;
this.id=R._oid++;
this.node=node;
node.raphael=this;
this.paper=svg;
this.attrs=this.attrs||{};
this.transformations=[];
this._={tx:0,ty:0,rt:{deg:0,cx:0,cy:0},sx:1,sy:1};
!svg.bottom&&(svg.bottom=this);
this.prev=svg.top;
svg.top&&(svg.top.next=this);
svg.top=this;
this.next=null;
};
_179[_f].rotate=function(deg,cx,cy){
if(this.removed){
return this;
}
if(deg==null){
if(this._.rt.cx){
return [this._.rt.deg,this._.rt.cx,this._.rt.cy][_1d](S);
}
return this._.rt.deg;
}
var bbox=this.getBBox();
deg=(deg+E)[_1a](_e);
if(deg[_a]-1){
cx=_2d(deg[1]);
cy=_2d(deg[2]);
}
deg=_2d(deg[0]);
if(cx!=null){
this._.rt.deg=deg;
}else{
this._.rt.deg+=deg;
}
(cy==null)&&(cx=null);
this._.rt.cx=cx;
this._.rt.cy=cy;
cx=cx==null?bbox.x+bbox.width/2:cx;
cy=cy==null?bbox.y+bbox.height/2:cy;
if(this._.rt.deg){
this.transformations[0]=R.format("rotate({0} {1} {2})",this._.rt.deg,cx,cy);
this.clip&&$(this.clip,{transform:R.format("rotate({0} {1} {2})",-this._.rt.deg,cx,cy)});
}else{
this.transformations[0]=E;
this.clip&&$(this.clip,{transform:E});
}
$(this.node,{transform:this.transformations[_1d](S)});
return this;
};
_179[_f].hide=function(){
!this.removed&&(this.node.style.display="none");
return this;
};
_179[_f].show=function(){
!this.removed&&(this.node.style.display="");
return this;
};
_179[_f].remove=function(){
if(this.removed){
return;
}
tear(this,this.paper);
this.node.parentNode.removeChild(this.node);
for(var i in this){
delete this[i];
}
this.removed=true;
};
_179[_f].getBBox=function(){
if(this.removed){
return this;
}
if(this.type=="path"){
return _96(this.attrs.path);
}
if(this.node.style.display=="none"){
this.show();
var hide=true;
}
var bbox={};
try{
bbox=this.node.getBBox();
}
catch(e){
}
finally{
bbox=bbox||{};
}
if(this.type=="text"){
bbox={x:bbox.x,y:Infinity,width:0,height:0};
for(var i=0,ii=this.node.getNumberOfChars();i<ii;i++){
var bb=this.node.getExtentOfChar(i);
(bb.y<bbox.y)&&(bbox.y=bb.y);
(bb.y+bb.height-bbox.y>bbox.height)&&(bbox.height=bb.y+bb.height-bbox.y);
(bb.x+bb.width-bbox.x>bbox.width)&&(bbox.width=bb.x+bb.width-bbox.x);
}
}
hide&&this.hide();
return bbox;
};
_179[_f].attr=function(name,_1ce){
if(this.removed){
return this;
}
if(name==null){
var res={};
for(var i in this.attrs){
if(this.attrs[has](i)){
res[i]=this.attrs[i];
}
}
this._.rt.deg&&(res.rotation=this.rotate());
(this._.sx!=1||this._.sy!=1)&&(res.scale=this.scale());
res.gradient&&res.fill=="none"&&(res.fill=res.gradient)&&delete res.gradient;
return res;
}
if(_1ce==null&&R.is(name,_22)){
if(name=="translation"){
return _1d1.call(this);
}
if(name=="rotation"){
return this.rotate();
}
if(name=="scale"){
return this.scale();
}
if(name==_24&&this.attrs.fill=="none"&&this.attrs.gradient){
return this.attrs.gradient;
}
return this.attrs[name];
}
if(_1ce==null&&R.is(name,_1)){
var _1d2={};
for(var j=0,jj=name.length;j<jj;j++){
_1d2[name[j]]=this.attr(name[j]);
}
return _1d2;
}
if(_1ce!=null){
var _1d5={};
_1d5[name]=_1ce;
_17a(this,_1d5);
}else{
if(name!=null&&R.is(name,"object")){
_17a(this,name);
}
}
return this;
};
_179[_f].toFront=function(){
if(this.removed){
return this;
}
this.node.parentNode[_15](this.node);
var svg=this.paper;
svg.top!=this&&_15e(this,svg);
return this;
};
_179[_f].toBack=function(){
if(this.removed){
return this;
}
if(this.node.parentNode.firstChild!=this.node){
this.node.parentNode.insertBefore(this.node,this.node.parentNode.firstChild);
_161(this,this.paper);
var svg=this.paper;
}
return this;
};
_179[_f].insertAfter=function(_1d8){
if(this.removed){
return this;
}
var node=_1d8.node;
if(node.nextSibling){
node.parentNode.insertBefore(this.node,node.nextSibling);
}else{
node.parentNode[_15](this.node);
}
_164(this,_1d8,this.paper);
return this;
};
_179[_f].insertBefore=function(_1da){
if(this.removed){
return this;
}
var node=_1da.node;
node.parentNode.insertBefore(this.node,node);
_168(this,_1da,this.paper);
return this;
};
_179[_f].blur=function(size){
var t=this;
if(+size!==0){
var fltr=$("filter"),blur=$("feGaussianBlur");
t.attrs.blur=size;
fltr.id="r"+(R._id++)[_23](36);
$(blur,{stdDeviation:+size||1.5});
fltr.appendChild(blur);
t.paper.defs.appendChild(fltr);
t._blur=fltr;
$(t.node,{filter:"url(#"+fltr.id+")"});
}else{
if(t._blur){
t._blur.parentNode.removeChild(t._blur);
delete t._blur;
delete t.attrs.blur;
}
t.node.removeAttribute("filter");
}
};
var _1e0=function(svg,x,y,r){
x=_2b(x);
y=_2b(y);
var el=$("circle");
svg.canvas&&svg.canvas[_15](el);
var res=new _179(el,svg);
res.attrs={cx:x,cy:y,r:r,fill:"none",stroke:"#000"};
res.type="circle";
$(el,res.attrs);
return res;
};
var _1e7=function(svg,x,y,w,h,r){
x=_2b(x);
y=_2b(y);
var el=$("rect");
svg.canvas&&svg.canvas[_15](el);
var res=new _179(el,svg);
res.attrs={x:x,y:y,width:w,height:h,r:r||0,rx:r||0,ry:r||0,fill:"none",stroke:"#000"};
res.type="rect";
$(el,res.attrs);
return res;
};
var _1f0=function(svg,x,y,rx,ry){
x=_2b(x);
y=_2b(y);
var el=$("ellipse");
svg.canvas&&svg.canvas[_15](el);
var res=new _179(el,svg);
res.attrs={cx:x,cy:y,rx:rx,ry:ry,fill:"none",stroke:"#000"};
res.type="ellipse";
$(el,res.attrs);
return res;
};
var _1f8=function(svg,src,x,y,w,h){
var el=$("image");
$(el,{x:x,y:y,width:w,height:h,preserveAspectRatio:"none"});
el.setAttributeNS(svg.xlink,"href",src);
svg.canvas&&svg.canvas[_15](el);
var res=new _179(el,svg);
res.attrs={x:x,y:y,width:w,height:h,src:src};
res.type="image";
return res;
};
var _201=function(svg,x,y,text){
var el=$("text");
$(el,{x:x,y:y,"text-anchor":"middle"});
svg.canvas&&svg.canvas[_15](el);
var res=new _179(el,svg);
res.attrs={x:x,y:y,"text-anchor":"middle",text:text,font:_31.font,stroke:"none",fill:"#000"};
res.type="text";
_17a(res,res.attrs);
return res;
};
var _208=function(_209,_20a){
this.width=_209||this.width;
this.height=_20a||this.height;
this.canvas[_2c]("width",this.width);
this.canvas[_2c]("height",this.height);
return this;
};
var _4=function(){
var con=_14f[_5](0,arguments),_20c=con&&con.container,x=con.x,y=con.y,_20f=con.width,_210=con.height;
if(!_20c){
throw new Error("SVG container not found.");
}
var cnvs=$("svg");
x=x||0;
y=y||0;
_20f=_20f||512;
_210=_210||342;
$(cnvs,{xmlns:"http://www.w3.org/2000/svg",version:1.1,width:_20f,height:_210});
if(_20c==1){
cnvs.style.cssText="position:absolute;left:"+x+"px;top:"+y+"px";
doc.body[_15](cnvs);
}else{
if(_20c.firstChild){
_20c.insertBefore(cnvs,_20c.firstChild);
}else{
_20c[_15](cnvs);
}
}
_20c=new _14;
_20c.width=_20f;
_20c.height=_210;
_20c.canvas=cnvs;
_155.call(_20c,_20c,R.fn);
_20c.clear();
return _20c;
};
_14[_f].clear=function(){
var c=this.canvas;
while(c.firstChild){
c.removeChild(c.firstChild);
}
this.bottom=this.top=null;
(this.desc=$("desc"))[_15](doc.createTextNode("Created with Rapha\xebl"));
c[_15](this.desc);
c[_15](this.defs=$("defs"));
};
_14[_f].remove=function(){
this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas);
for(var i in this){
this[i]=_16c(i);
}
};
}
if(R.vml){
var map={M:"m",L:"l",C:"c",Z:"x",m:"t",l:"r",c:"v",z:"x"},_215=/([clmz]),?([^clmz]*)/gi,val=/-?[^,\s-]+/g,_217=1000+S+1000,zoom=10,_219={path:1,rect:1},_21a=function(path){
var _21c=/[ahqstv]/ig,_21d=_bc;
(path+E).match(_21c)&&(_21d=_98);
_21c=/[clmz]/g;
if(_21d==_bc&&!(path+E).match(_21c)){
var res=(path+E)[rp](_215,function(all,_220,args){
var vals=[],_223=_1e.call(_220)=="m",res=map[_220];
args[rp](val,function(_224){
if(_223&&vals[_a]==2){
res+=vals+map[_220=="m"?"l":"L"];
vals=[];
}
vals[_d](_2b(_224*zoom));
});
return res+vals;
});
return res;
}
var pa=_21d(path),p,r;
res=[];
for(var i=0,ii=pa[_a];i<ii;i++){
p=pa[i];
r=_1e.call(pa[i][0]);
r=="z"&&(r="x");
for(var j=1,jj=p[_a];j<jj;j++){
r+=_2b(p[j]*zoom)+(j!=jj-1?",":E);
}
res[_d](r);
}
return res[_1d](S);
};
R[_23]=function(){
return "Your browser doesn\u2019t support SVG. Falling down to VML.\nYou are running Rapha\xebl "+this.version;
};
_174=function(_22c,vml){
var g=_22f("group");
g.style.cssText="position:absolute;left:0;top:0;width:"+vml.width+"px;height:"+vml.height+"px";
g.coordsize=vml.coordsize;
g.coordorigin=vml.coordorigin;
var el=_22f("shape"),ol=el.style;
ol.width=vml.width+"px";
ol.height=vml.height+"px";
el.coordsize=_217;
el.coordorigin=vml.coordorigin;
g[_15](el);
var p=new _179(el,g,vml),attr={fill:"none",stroke:"#000"};
_22c&&(attr.path=_22c);
p.isAbsolute=true;
p.type="path";
p.path=[];
p.Path=E;
_17a(p,attr);
vml.canvas[_15](g);
return p;
};
_17a=function(o,_235){
o.attrs=o.attrs||{};
var node=o.node,a=o.attrs,s=node.style,xy,_23a=(_235.x!=a.x||_235.y!=a.y||_235.width!=a.width||_235.height!=a.height||_235.r!=a.r)&&o.type=="rect",res=o;
for(var par in _235){
if(_235[has](par)){
a[par]=_235[par];
}
}
if(_23a){
a.path=rectPath(a.x,a.y,a.width,a.height,a.r);
o.X=a.x;
o.Y=a.y;
o.W=a.width;
o.H=a.height;
}
_235.href&&(node.href=_235.href);
_235.title&&(node.title=_235.title);
_235.target&&(node.target=_235.target);
_235.cursor&&(s.cursor=_235.cursor);
"blur" in _235&&o.blur(_235.blur);
if(_235.path&&o.type=="path"||_23a){
node.path=_21a(a.path);
}
if(_235.rotation!=null){
o.rotate(_235.rotation,true);
}
if(_235.translation){
xy=(_235.translation+E)[_1a](_e);
_1d1.call(o,xy[0],xy[1]);
if(o._.rt.cx!=null){
o._.rt.cx+=+xy[0];
o._.rt.cy+=+xy[1];
o.setBox(o.attrs,xy[0],xy[1]);
}
}
if(_235.scale){
xy=(_235.scale+E)[_1a](_e);
o.scale(+xy[0]||1,+xy[1]||+xy[0]||1,+xy[2]||null,+xy[3]||null);
}
if("clip-rect" in _235){
var rect=(_235["clip-rect"]+E)[_1a](_e);
if(rect[_a]==4){
rect[2]=+rect[2]+(+rect[0]);
rect[3]=+rect[3]+(+rect[1]);
var div=node.clipRect||doc.createElement("div"),_23f=div.style,_240=node.parentNode;
_23f.clip=R.format("rect({1}px {2}px {3}px {0}px)",rect);
if(!node.clipRect){
_23f.position="absolute";
_23f.top=0;
_23f.left=0;
_23f.width=o.paper.width+"px";
_23f.height=o.paper.height+"px";
_240.parentNode.insertBefore(div,_240);
div[_15](_240);
node.clipRect=div;
}
}
if(!_235["clip-rect"]){
node.clipRect&&(node.clipRect.style.clip=E);
}
}
if(o.type=="image"&&_235.src){
node.src=_235.src;
}
if(o.type=="image"&&_235.opacity){
node.filterOpacity=ms+".Alpha(opacity="+(_235.opacity*100)+")";
s.filter=(node.filterMatrix||E)+(node.filterOpacity||E);
}
_235.font&&(s.font=_235.font);
_235["font-family"]&&(s.fontFamily="\""+_235["font-family"][_1a](",")[0][rp](/^['"]+|['"]+$/g,E)+"\"");
_235["font-size"]&&(s.fontSize=_235["font-size"]);
_235["font-weight"]&&(s.fontWeight=_235["font-weight"]);
_235["font-style"]&&(s.fontStyle=_235["font-style"]);
if(_235.opacity!=null||_235["stroke-width"]!=null||_235.fill!=null||_235.stroke!=null||_235["stroke-width"]!=null||_235["stroke-opacity"]!=null||_235["fill-opacity"]!=null||_235["stroke-dasharray"]!=null||_235["stroke-miterlimit"]!=null||_235["stroke-linejoin"]!=null||_235["stroke-linecap"]!=null){
node=o.shape||node;
var fill=(node.getElementsByTagName(_24)&&node.getElementsByTagName(_24)[0]),_242=false;
!fill&&(_242=fill=_22f(_24));
if("fill-opacity" in _235||"opacity" in _235){
var _243=((+a["fill-opacity"]+1||2)-1)*((+a.opacity+1||2)-1)*((+R.getRGB(_235.fill).o+1||2)-1);
_243<0&&(_243=0);
_243>1&&(_243=1);
fill.opacity=_243;
}
_235.fill&&(fill.on=true);
if(fill.on==null||_235.fill=="none"){
fill.on=false;
}
if(fill.on&&_235.fill){
var _244=_235.fill.match(_29);
if(_244){
fill.src=_244[1];
fill.type="tile";
}else{
fill.color=R.getRGB(_235.fill).hex;
fill.src=E;
fill.type="solid";
if(R.getRGB(_235.fill).error&&(res.type in {circle:1,ellipse:1}||(_235.fill+E).charAt()!="r")&&_17b(res,_235.fill)){
a.fill="none";
a.gradient=_235.fill;
}
}
}
_242&&node[_15](fill);
var _245=(node.getElementsByTagName("stroke")&&node.getElementsByTagName("stroke")[0]),_246=false;
!_245&&(_246=_245=_22f("stroke"));
if((_235.stroke&&_235.stroke!="none")||_235["stroke-width"]||_235["stroke-opacity"]!=null||_235["stroke-dasharray"]||_235["stroke-miterlimit"]||_235["stroke-linejoin"]||_235["stroke-linecap"]){
_245.on=true;
}
(_235.stroke=="none"||_245.on==null||_235.stroke==0||_235["stroke-width"]==0)&&(_245.on=false);
var _247=R.getRGB(_235.stroke);
_245.on&&_235.stroke&&(_245.color=_247.hex);
_243=((+a["stroke-opacity"]+1||2)-1)*((+a.opacity+1||2)-1)*((+_247.o+1||2)-1);
var _248=(_2d(_235["stroke-width"])||1)*0.75;
_243<0&&(_243=0);
_243>1&&(_243=1);
_235["stroke-width"]==null&&(_248=a["stroke-width"]);
_235["stroke-width"]&&(_245.weight=_248);
_248&&_248<1&&(_243*=_248)&&(_245.weight=1);
_245.opacity=_243;
_235["stroke-linejoin"]&&(_245.joinstyle=_235["stroke-linejoin"]||"miter");
_245.miterlimit=_235["stroke-miterlimit"]||8;
_235["stroke-linecap"]&&(_245.endcap=_235["stroke-linecap"]=="butt"?"flat":_235["stroke-linecap"]=="square"?"square":"round");
if(_235["stroke-dasharray"]){
var _249={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};
_245.dashstyle=_249[has](_235["stroke-dasharray"])?_249[_235["stroke-dasharray"]]:E;
}
_246&&node[_15](_245);
}
if(res.type=="text"){
s=res.paper.span.style;
a.font&&(s.font=a.font);
a["font-family"]&&(s.fontFamily=a["font-family"]);
a["font-size"]&&(s.fontSize=a["font-size"]);
a["font-weight"]&&(s.fontWeight=a["font-weight"]);
a["font-style"]&&(s.fontStyle=a["font-style"]);
res.node.string&&(res.paper.span.innerHTML=(res.node.string+E)[rp](/</g,"&#60;")[rp](/&/g,"&#38;")[rp](/\n/g,"<br>"));
res.W=a.w=res.paper.span.offsetWidth;
res.H=a.h=res.paper.span.offsetHeight;
res.X=a.x;
res.Y=a.y+_2b(res.H/2);
switch(a["text-anchor"]){
case "start":
res.node.style["v-text-align"]="left";
res.bbx=_2b(res.W/2);
break;
case "end":
res.node.style["v-text-align"]="right";
res.bbx=-_2b(res.W/2);
break;
default:
res.node.style["v-text-align"]="center";
break;
}
}
};
_17b=function(o,_24b){
o.attrs=o.attrs||{};
var _24c=o.attrs,fill,type="linear",fxfy=".5 .5";
o.attrs.gradient=_24b;
_24b=(_24b+E)[rp](_16e,function(all,fx,fy){
type="radial";
if(fx&&fy){
fx=_2d(fx);
fy=_2d(fy);
pow(fx-0.5,2)+pow(fy-0.5,2)>0.25&&(fy=_1f.sqrt(0.25-pow(fx-0.5,2))*((fy>0.5)*2-1)+0.5);
fxfy=fx+S+fy;
}
return E;
});
_24b=_24b[_1a](/\s*\-\s*/);
if(type=="linear"){
var _253=_24b.shift();
_253=-_2d(_253);
if(isNaN(_253)){
return null;
}
}
var dots=_144(_24b);
if(!dots){
return null;
}
o=o.shape||o.node;
fill=o.getElementsByTagName(_24)[0]||_22f(_24);
!fill.parentNode&&o.appendChild(fill);
if(dots[_a]){
fill.on=true;
fill.method="none";
fill.color=dots[0].color;
fill.color2=dots[dots[_a]-1].color;
var clrs=[];
for(var i=0,ii=dots[_a];i<ii;i++){
dots[i].offset&&clrs[_d](dots[i].offset+S+dots[i].color);
}
fill.colors&&(fill.colors.value=clrs[_a]?clrs[_1d]():"0% "+fill.color);
if(type=="radial"){
fill.type="gradientradial";
fill.focus="100%";
fill.focussize=fxfy;
fill.focusposition=fxfy;
}else{
fill.type="gradient";
fill.angle=(270-_253)%360;
}
}
return 1;
};
_179=function(node,_259,vml){
var _25b=0,RotX=0,RotY=0,_25e=1;
this[0]=node;
this.id=R._oid++;
this.node=node;
node.raphael=this;
this.X=0;
this.Y=0;
this.attrs={};
this.Group=_259;
this.paper=vml;
this._={tx:0,ty:0,rt:{deg:0},sx:1,sy:1};
!vml.bottom&&(vml.bottom=this);
this.prev=vml.top;
vml.top&&(vml.top.next=this);
vml.top=this;
this.next=null;
};
_179[_f].rotate=function(deg,cx,cy){
if(this.removed){
return this;
}
if(deg==null){
if(this._.rt.cx){
return [this._.rt.deg,this._.rt.cx,this._.rt.cy][_1d](S);
}
return this._.rt.deg;
}
deg=(deg+E)[_1a](_e);
if(deg[_a]-1){
cx=_2d(deg[1]);
cy=_2d(deg[2]);
}
deg=_2d(deg[0]);
if(cx!=null){
this._.rt.deg=deg;
}else{
this._.rt.deg+=deg;
}
cy==null&&(cx=null);
this._.rt.cx=cx;
this._.rt.cy=cy;
this.setBox(this.attrs,cx,cy);
this.Group.style.rotation=this._.rt.deg;
return this;
};
_179[_f].setBox=function(_262,cx,cy){
if(this.removed){
return this;
}
var gs=this.Group.style,os=(this.shape&&this.shape.style)||this.node.style;
_262=_262||{};
for(var i in _262){
if(_262[has](i)){
this.attrs[i]=_262[i];
}
}
cx=cx||this._.rt.cx;
cy=cy||this._.rt.cy;
var attr=this.attrs,x,y,w,h;
switch(this.type){
case "circle":
x=attr.cx-attr.r;
y=attr.cy-attr.r;
w=h=attr.r*2;
break;
case "ellipse":
x=attr.cx-attr.rx;
y=attr.cy-attr.ry;
w=attr.rx*2;
h=attr.ry*2;
break;
case "image":
x=+attr.x;
y=+attr.y;
w=attr.width||0;
h=attr.height||0;
break;
case "text":
this.textpath.v=["m",_2b(attr.x),", ",_2b(attr.y-2),"l",_2b(attr.x)+1,", ",_2b(attr.y-2)][_1d](E);
x=attr.x-_2b(this.W/2);
y=attr.y-this.H/2;
w=this.W;
h=this.H;
break;
case "rect":
case "path":
if(!this.attrs.path){
x=0;
y=0;
w=this.paper.width;
h=this.paper.height;
}else{
var dim=_96(this.attrs.path);
x=dim.x;
y=dim.y;
w=dim.width;
h=dim.height;
}
break;
default:
x=0;
y=0;
w=this.paper.width;
h=this.paper.height;
break;
}
cx=(cx==null)?x+w/2:cx;
cy=(cy==null)?y+h/2:cy;
var left=cx-this.paper.width/2,top=cy-this.paper.height/2,t;
gs.left!=(t=left+"px")&&(gs.left=t);
gs.top!=(t=top+"px")&&(gs.top=t);
this.X=_219[has](this.type)?-left:x;
this.Y=_219[has](this.type)?-top:y;
this.W=w;
this.H=h;
if(_219[has](this.type)){
os.left!=(t=-left*zoom+"px")&&(os.left=t);
os.top!=(t=-top*zoom+"px")&&(os.top=t);
}else{
if(this.type=="text"){
os.left!=(t=-left+"px")&&(os.left=t);
os.top!=(t=-top+"px")&&(os.top=t);
}else{
gs.width!=(t=this.paper.width+"px")&&(gs.width=t);
gs.height!=(t=this.paper.height+"px")&&(gs.height=t);
os.left!=(t=x-left+"px")&&(os.left=t);
os.top!=(t=y-top+"px")&&(os.top=t);
os.width!=(t=w+"px")&&(os.width=t);
os.height!=(t=h+"px")&&(os.height=t);
}
}
};
_179[_f].hide=function(){
!this.removed&&(this.Group.style.display="none");
return this;
};
_179[_f].show=function(){
!this.removed&&(this.Group.style.display="block");
return this;
};
_179[_f].getBBox=function(){
if(this.removed){
return this;
}
if(_219[has](this.type)){
return _96(this.attrs.path);
}
return {x:this.X+(this.bbx||0),y:this.Y,width:this.W,height:this.H};
};
_179[_f].remove=function(){
if(this.removed){
return;
}
tear(this,this.paper);
this.node.parentNode.removeChild(this.node);
this.Group.parentNode.removeChild(this.Group);
this.shape&&this.shape.parentNode.removeChild(this.shape);
for(var i in this){
delete this[i];
}
this.removed=true;
};
_179[_f].attr=function(name,_273){
if(this.removed){
return this;
}
if(name==null){
var res={};
for(var i in this.attrs){
if(this.attrs[has](i)){
res[i]=this.attrs[i];
}
}
this._.rt.deg&&(res.rotation=this.rotate());
(this._.sx!=1||this._.sy!=1)&&(res.scale=this.scale());
res.gradient&&res.fill=="none"&&(res.fill=res.gradient)&&delete res.gradient;
return res;
}
if(_273==null&&R.is(name,_22)){
if(name=="translation"){
return _1d1.call(this);
}
if(name=="rotation"){
return this.rotate();
}
if(name=="scale"){
return this.scale();
}
if(name==_24&&this.attrs.fill=="none"&&this.attrs.gradient){
return this.attrs.gradient;
}
return this.attrs[name];
}
if(this.attrs&&_273==null&&R.is(name,_1)){
var ii,_277={};
for(i=0,ii=name[_a];i<ii;i++){
_277[name[i]]=this.attr(name[i]);
}
return _277;
}
var _278;
if(_273!=null){
_278={};
_278[name]=_273;
}
_273==null&&R.is(name,"object")&&(_278=name);
if(_278){
if(_278.text&&this.type=="text"){
this.node.string=_278.text;
}
_17a(this,_278);
if(_278.gradient&&(({circle:1,ellipse:1})[has](this.type)||(_278.gradient+E).charAt()!="r")){
_17b(this,_278.gradient);
}
(!_219[has](this.type)||this._.rt.deg)&&this.setBox(this.attrs);
}
return this;
};
_179[_f].toFront=function(){
!this.removed&&this.Group.parentNode[_15](this.Group);
this.paper.top!=this&&_15e(this,this.paper);
return this;
};
_179[_f].toBack=function(){
if(this.removed){
return this;
}
if(this.Group.parentNode.firstChild!=this.Group){
this.Group.parentNode.insertBefore(this.Group,this.Group.parentNode.firstChild);
_161(this,this.paper);
}
return this;
};
_179[_f].insertAfter=function(_279){
if(this.removed){
return this;
}
if(_279.Group.nextSibling){
_279.Group.parentNode.insertBefore(this.Group,_279.Group.nextSibling);
}else{
_279.Group.parentNode[_15](this.Group);
}
_164(this,_279,this.paper);
return this;
};
_179[_f].insertBefore=function(_27a){
if(this.removed){
return this;
}
_27a.Group.parentNode.insertBefore(this.Group,_27a.Group);
_168(this,_27a,this.paper);
return this;
};
var _27b=/ progid:\S+Blur\([^\)]+\)/g;
_179[_f].blur=function(size){
var s=this.node.style,f=s.filter;
f=f.replace(_27b,"");
if(+size!==0){
this.attrs.blur=size;
s.filter=f+ms+".Blur(pixelradius="+(+size||1.5)+")";
s.margin=Raphael.format("-{0}px 0 0 -{0}px",Math.round(+size||1.5));
}else{
s.filter=f;
s.margin=0;
delete this.attrs.blur;
}
};
_1e0=function(vml,x,y,r){
var g=_22f("group"),o=_22f("oval"),ol=o.style;
g.style.cssText="position:absolute;left:0;top:0;width:"+vml.width+"px;height:"+vml.height+"px";
g.coordsize=_217;
g.coordorigin=vml.coordorigin;
g[_15](o);
var res=new _179(o,g,vml);
res.type="circle";
_17a(res,{stroke:"#000",fill:"none"});
res.attrs.cx=x;
res.attrs.cy=y;
res.attrs.r=r;
res.setBox({x:x-r,y:y-r,width:r*2,height:r*2});
vml.canvas[_15](g);
return res;
};
function rectPath(x,y,w,h,r){
if(r){
return R.format("M{0},{1}l{2},0a{3},{3},0,0,1,{3},{3}l0,{5}a{3},{3},0,0,1,{4},{3}l{6},0a{3},{3},0,0,1,{4},{4}l0,{7}a{3},{3},0,0,1,{3},{4}z",x+r,y,w-r*2,r,-r,h-r*2,r*2-w,r*2-h);
}else{
return R.format("M{0},{1}l{2},0,0,{3},{4},0z",x,y,w,h,-w);
}
}
_1e7=function(vml,x,y,w,h,r){
var path=rectPath(x,y,w,h,r),res=vml.path(path),a=res.attrs;
res.X=a.x=x;
res.Y=a.y=y;
res.W=a.width=w;
res.H=a.height=h;
a.r=r;
a.path=path;
res.type="rect";
return res;
};
_1f0=function(vml,x,y,rx,ry){
var g=_22f("group"),o=_22f("oval"),ol=o.style;
g.style.cssText="position:absolute;left:0;top:0;width:"+vml.width+"px;height:"+vml.height+"px";
g.coordsize=_217;
g.coordorigin=vml.coordorigin;
g[_15](o);
var res=new _179(o,g,vml);
res.type="ellipse";
_17a(res,{stroke:"#000"});
res.attrs.cx=x;
res.attrs.cy=y;
res.attrs.rx=rx;
res.attrs.ry=ry;
res.setBox({x:x-rx,y:y-ry,width:rx*2,height:ry*2});
vml.canvas[_15](g);
return res;
};
_1f8=function(vml,src,x,y,w,h){
var g=_22f("group"),o=_22f("image"),ol=o.style;
g.style.cssText="position:absolute;left:0;top:0;width:"+vml.width+"px;height:"+vml.height+"px";
g.coordsize=_217;
g.coordorigin=vml.coordorigin;
o.src=src;
g[_15](o);
var res=new _179(o,g,vml);
res.type="image";
res.attrs.src=src;
res.attrs.x=x;
res.attrs.y=y;
res.attrs.w=w;
res.attrs.h=h;
res.setBox({x:x,y:y,width:w,height:h});
vml.canvas[_15](g);
return res;
};
_201=function(vml,x,y,text){
var g=_22f("group"),el=_22f("shape"),ol=el.style,path=_22f("path"),ps=path.style,o=_22f("textpath");
g.style.cssText="position:absolute;left:0;top:0;width:"+vml.width+"px;height:"+vml.height+"px";
g.coordsize=_217;
g.coordorigin=vml.coordorigin;
path.v=R.format("m{0},{1}l{2},{1}",_2b(x*10),_2b(y*10),_2b(x*10)+1);
path.textpathok=true;
ol.width=vml.width;
ol.height=vml.height;
o.string=text+E;
o.on=true;
el[_15](o);
el[_15](path);
g[_15](el);
var res=new _179(o,g,vml);
res.shape=el;
res.textpath=path;
res.type="text";
res.attrs.text=text;
res.attrs.x=x;
res.attrs.y=y;
res.attrs.w=1;
res.attrs.h=1;
_17a(res,{font:_31.font,stroke:"none",fill:"#000"});
res.setBox();
vml.canvas[_15](g);
return res;
};
_208=function(_2b3,_2b4){
var cs=this.canvas.style;
_2b3==+_2b3&&(_2b3+="px");
_2b4==+_2b4&&(_2b4+="px");
cs.width=_2b3;
cs.height=_2b4;
cs.clip="rect(0 "+_2b3+" "+_2b4+" 0)";
return this;
};
var _22f;
doc.createStyleSheet().addRule(".rvml","behavior:url(#default#VML)");
try{
!doc.namespaces.rvml&&doc.namespaces.add("rvml","urn:schemas-microsoft-com:vml");
_22f=function(_2b6){
return doc.createElement("<rvml:"+_2b6+" class=\"rvml\">");
};
}
catch(e){
_22f=function(_2b7){
return doc.createElement("<"+_2b7+" xmlns=\"urn:schemas-microsoft.com:vml\" class=\"rvml\">");
};
}
_4=function(){
var con=_14f[_5](0,arguments),_2b9=con.container,_2ba=con.height,s,_2bc=con.width,x=con.x,y=con.y;
if(!_2b9){
throw new Error("VML container not found.");
}
var res=new _14,c=res.canvas=doc.createElement("div"),cs=c.style;
x=x||0;
y=y||0;
_2bc=_2bc||512;
_2ba=_2ba||342;
_2bc==+_2bc&&(_2bc+="px");
_2ba==+_2ba&&(_2ba+="px");
res.width=1000;
res.height=1000;
res.coordsize=zoom*1000+S+zoom*1000;
res.coordorigin="0 0";
res.span=doc.createElement("span");
res.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";
c[_15](res.span);
cs.cssText=R.format("width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden",_2bc,_2ba);
if(_2b9==1){
doc.body[_15](c);
cs.left=x+"px";
cs.top=y+"px";
cs.position="absolute";
}else{
if(_2b9.firstChild){
_2b9.insertBefore(c,_2b9.firstChild);
}else{
_2b9[_15](c);
}
}
_155.call(res,res,R.fn);
return res;
};
_14[_f].clear=function(){
this.canvas.innerHTML=E;
this.span=doc.createElement("span");
this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";
this.canvas[_15](this.span);
this.bottom=this.top=null;
};
_14[_f].remove=function(){
this.canvas.parentNode.removeChild(this.canvas);
for(var i in this){
this[i]=_16c(i);
}
return true;
};
}
if((/^Apple|^Google/).test(win.navigator.vendor)&&(!(win.navigator.userAgent.indexOf("Version/4.0")+1)||win.navigator.platform.slice(0,2)=="iP")){
_14[_f].safari=function(){
var rect=this.rect(-99,-99,this.width+99,this.height+99);
win.setTimeout(function(){
rect.remove();
});
};
}else{
_14[_f].safari=function(){
};
}
var _2c4=function(){
this.returnValue=false;
},_2c5=function(){
return this.originalEvent.preventDefault();
},_2c6=function(){
this.cancelBubble=true;
},_2c7=function(){
return this.originalEvent.stopPropagation();
},_2c8=(function(){
if(doc.addEventListener){
return function(obj,type,fn,_2cc){
var _2cd=_17&&_1c[type]?_1c[type]:type;
var f=function(e){
if(_17&&_1c[has](type)){
for(var i=0,ii=e.targetTouches&&e.targetTouches.length;i<ii;i++){
if(e.targetTouches[i].target==obj){
var olde=e;
e=e.targetTouches[i];
e.originalEvent=olde;
e.preventDefault=_2c5;
e.stopPropagation=_2c7;
break;
}
}
}
return fn.call(_2cc,e);
};
obj.addEventListener(_2cd,f,false);
return function(){
obj.removeEventListener(_2cd,f,false);
return true;
};
};
}else{
if(doc.attachEvent){
return function(obj,type,fn,_2d6){
var f=function(e){
e=e||win.event;
e.preventDefault=e.preventDefault||_2c4;
e.stopPropagation=e.stopPropagation||_2c6;
return fn.call(_2d6,e);
};
obj.attachEvent("on"+type,f);
var _2d9=function(){
obj.detachEvent("on"+type,f);
return true;
};
return _2d9;
};
}
}
})();
for(var i=_1b[_a];i--;){
(function(_2db){
R[_2db]=_179[_f][_2db]=function(fn){
if(R.is(fn,"function")){
this.events=this.events||[];
this.events.push({name:_2db,f:fn,unbind:_2c8(this.shape||this.node||doc,_2db,fn,this)});
}
return this;
};
R["un"+_2db]=_179[_f]["un"+_2db]=function(fn){
var _2de=this.events,l=_2de[_a];
while(l--){
if(_2de[l].name==_2db&&_2de[l].f==fn){
_2de[l].unbind();
_2de.splice(l,1);
!_2de.length&&delete this.events;
return this;
}
}
return this;
};
})(_1b[i]);
}
_179[_f].hover=function(f_in,_2e1){
return this.mouseover(f_in).mouseout(_2e1);
};
_179[_f].unhover=function(f_in,_2e3){
return this.unmouseover(f_in).unmouseout(_2e3);
};
_179[_f].drag=function(_2e4,_2e5,_2e6){
this._drag={};
var el=this.mousedown(function(e){
(e.originalEvent?e.originalEvent:e).preventDefault();
this._drag.x=e.clientX;
this._drag.y=e.clientY;
this._drag.id=e.identifier;
_2e5&&_2e5.call(this,e.clientX,e.clientY);
Raphael.mousemove(move).mouseup(up);
}),move=function(e){
var x=e.clientX,y=e.clientY;
if(_17){
var i=e.touches.length,_2ef;
while(i--){
_2ef=e.touches[i];
if(_2ef.identifier==el._drag.id){
x=_2ef.clientX;
y=_2ef.clientY;
(e.originalEvent?e.originalEvent:e).preventDefault();
break;
}
}
}else{
e.preventDefault();
}
_2e4&&_2e4.call(el,x-el._drag.x,y-el._drag.y,x,y);
},up=function(){
el._drag={};
Raphael.unmousemove(move).unmouseup(up);
_2e6&&_2e6.call(el);
};
return this;
};
_14[_f].circle=function(x,y,r){
return _1e0(this,x||0,y||0,r||0);
};
_14[_f].rect=function(x,y,w,h,r){
return _1e7(this,x||0,y||0,w||0,h||0,r||0);
};
_14[_f].ellipse=function(x,y,rx,ry){
return _1f0(this,x||0,y||0,rx||0,ry||0);
};
_14[_f].path=function(_2fc){
_2fc&&!R.is(_2fc,_22)&&!R.is(_2fc[0],_1)&&(_2fc+=E);
return _174(R.format[_5](R,arguments),this);
};
_14[_f].image=function(src,x,y,w,h){
return _1f8(this,src||"about:blank",x||0,y||0,w||0,h||0);
};
_14[_f].text=function(x,y,text){
return _201(this,x||0,y||0,text||E);
};
_14[_f].set=function(_305){
arguments[_a]>1&&(_305=Array[_f].splice.call(arguments,0,arguments[_a]));
return new Set(_305);
};
_14[_f].setSize=_208;
_14[_f].top=_14[_f].bottom=null;
_14[_f].raphael=R;
function x_y(){
return this.x+S+this.y;
}
_179[_f].resetScale=function(){
if(this.removed){
return this;
}
this._.sx=1;
this._.sy=1;
this.attrs.scale="1 1";
};
_179[_f].scale=function(x,y,cx,cy){
if(this.removed){
return this;
}
if(x==null&&y==null){
return {x:this._.sx,y:this._.sy,toString:x_y};
}
y=y||x;
!+y&&(y=x);
var dx,dy,dcx,dcy,a=this.attrs;
if(x!=0){
var bb=this.getBBox(),rcx=bb.x+bb.width/2,rcy=bb.y+bb.height/2,kx=x/this._.sx,ky=y/this._.sy;
cx=(+cx||cx==0)?cx:rcx;
cy=(+cy||cy==0)?cy:rcy;
var dirx=~~(x/_1f.abs(x)),diry=~~(y/_1f.abs(y)),s=this.node.style,ncx=cx+(rcx-cx)*kx,ncy=cy+(rcy-cy)*ky;
switch(this.type){
case "rect":
case "image":
var neww=a.width*dirx*kx,newh=a.height*diry*ky;
this.attr({height:newh,r:a.r*_21(dirx*kx,diry*ky),width:neww,x:ncx-neww/2,y:ncy-newh/2});
break;
case "circle":
case "ellipse":
this.attr({rx:a.rx*dirx*kx,ry:a.ry*diry*ky,r:a.r*_21(dirx*kx,diry*ky),cx:ncx,cy:ncy});
break;
case "text":
this.attr({x:ncx,y:ncy});
break;
case "path":
var path=_ab(a.path),skip=true;
for(var i=0,ii=path[_a];i<ii;i++){
var p=path[i],P0=_30.call(p[0]);
if(P0=="M"&&skip){
continue;
}else{
skip=false;
}
if(P0=="A"){
p[path[i][_a]-2]*=kx;
p[path[i][_a]-1]*=ky;
p[1]*=dirx*kx;
p[2]*=diry*ky;
p[5]=+!(dirx+diry?!+p[5]:+p[5]);
}else{
if(P0=="H"){
for(var j=1,jj=p[_a];j<jj;j++){
p[j]*=kx;
}
}else{
if(P0=="V"){
for(j=1,jj=p[_a];j<jj;j++){
p[j]*=ky;
}
}else{
for(j=1,jj=p[_a];j<jj;j++){
p[j]*=(j%2)?kx:ky;
}
}
}
}
}
var dim2=_96(path);
dx=ncx-dim2.x-dim2.width/2;
dy=ncy-dim2.y-dim2.height/2;
path[0][1]+=dx;
path[0][2]+=dy;
this.attr({path:path});
break;
}
if(this.type in {text:1,image:1}&&(dirx!=1||diry!=1)){
if(this.transformations){
this.transformations[2]="scale("[_16](dirx,",",diry,")");
this.node[_2c]("transform",this.transformations[_1d](S));
dx=(dirx==-1)?-a.x-(neww||0):a.x;
dy=(diry==-1)?-a.y-(newh||0):a.y;
this.attr({x:dx,y:dy});
a.fx=dirx-1;
a.fy=diry-1;
}else{
this.node.filterMatrix=ms+".Matrix(M11="[_16](dirx,", M12=0, M21=0, M22=",diry,", Dx=0, Dy=0, sizingmethod='auto expand', filtertype='bilinear')");
s.filter=(this.node.filterMatrix||E)+(this.node.filterOpacity||E);
}
}else{
if(this.transformations){
this.transformations[2]=E;
this.node[_2c]("transform",this.transformations[_1d](S));
a.fx=0;
a.fy=0;
}else{
this.node.filterMatrix=E;
s.filter=(this.node.filterMatrix||E)+(this.node.filterOpacity||E);
}
}
a.scale=[x,y,cx,cy][_1d](S);
this._.sx=x;
this._.sy=y;
}
return this;
};
_179[_f].clone=function(){
if(this.removed){
return null;
}
var attr=this.attr();
delete attr.scale;
delete attr.translation;
return this.paper[this.type]().attr(attr);
};
var _326=cacher(function(p1x,p1y,c1x,c1y,c2x,c2y,p2x,p2y,_32f){
var len=0,old;
for(var i=0;i<1.001;i+=0.001){
var dot=R.findDotsAtSegment(p1x,p1y,c1x,c1y,c2x,c2y,p2x,p2y,i);
i&&(len+=pow(pow(old.x-dot.x,2)+pow(old.y-dot.y,2),0.5));
if(len>=_32f){
return dot;
}
old=dot;
}
}),_334=function(_335,_336){
return function(path,_338,_339){
path=_98(path);
var x,y,p,l,sp="",_33f={},_340,len=0;
for(var i=0,ii=path.length;i<ii;i++){
p=path[i];
if(p[0]=="M"){
x=+p[1];
y=+p[2];
}else{
l=_344(x,y,p[1],p[2],p[3],p[4],p[5],p[6]);
if(len+l>_338){
if(_336&&!_33f.start){
_340=_326(x,y,p[1],p[2],p[3],p[4],p[5],p[6],_338-len);
sp+=["C",_340.start.x,_340.start.y,_340.m.x,_340.m.y,_340.x,_340.y];
if(_339){
return sp;
}
_33f.start=sp;
sp=["M",_340.x,_340.y+"C",_340.n.x,_340.n.y,_340.end.x,_340.end.y,p[5],p[6]][_1d]();
len+=l;
x=+p[5];
y=+p[6];
continue;
}
if(!_335&&!_336){
_340=_326(x,y,p[1],p[2],p[3],p[4],p[5],p[6],_338-len);
return {x:_340.x,y:_340.y,alpha:_340.alpha};
}
}
len+=l;
x=+p[5];
y=+p[6];
}
sp+=p;
}
_33f.end=sp;
_340=_335?len:_336?_33f:R.findDotsAtSegment(x,y,p[1],p[2],p[3],p[4],p[5],p[6],1);
_340.alpha&&(_340={x:_340.x,y:_340.y,alpha:_340.alpha});
return _340;
};
},_344=cacher(function(p1x,p1y,c1x,c1y,c2x,c2y,p2x,p2y){
var old={x:0,y:0},len=0;
for(var i=0;i<1.01;i+=0.01){
var dot=_10e(p1x,p1y,c1x,c1y,c2x,c2y,p2x,p2y,i);
i&&(len+=pow(pow(old.x-dot.x,2)+pow(old.y-dot.y,2),0.5));
old=dot;
}
return len;
});
var _351=_334(1),_352=_334(),_353=_334(0,1);
_179[_f].getTotalLength=function(){
if(this.type!="path"){
return;
}
if(this.node.getTotalLength){
return this.node.getTotalLength();
}
return _351(this.attrs.path);
};
_179[_f].getPointAtLength=function(_354){
if(this.type!="path"){
return;
}
return _352(this.attrs.path,_354);
};
_179[_f].getSubpath=function(from,to){
if(this.type!="path"){
return;
}
if(_1f.abs(this.getTotalLength()-to)<0.000001){
return _353(this.attrs.path,from).end;
}
var a=_353(this.attrs.path,to,1);
return from?_353(a,from).end:a;
};
R.easing_formulas={linear:function(n){
return n;
},"<":function(n){
return pow(n,3);
},">":function(n){
return pow(n-1,3)+1;
},"<>":function(n){
n=n*2;
if(n<1){
return pow(n,3)/2;
}
n-=2;
return (pow(n,3)+2)/2;
},backIn:function(n){
var s=1.70158;
return n*n*((s+1)*n-s);
},backOut:function(n){
n=n-1;
var s=1.70158;
return n*n*((s+1)*n+s)+1;
},elastic:function(n){
if(n==0||n==1){
return n;
}
var p=0.3,s=p/4;
return pow(2,-10*n)*_1f.sin((n-s)*(2*_1f.PI)/p)+1;
},bounce:function(n){
var s=7.5625,p=2.75,l;
if(n<(1/p)){
l=s*n*n;
}else{
if(n<(2/p)){
n-=(1.5/p);
l=s*n*n+0.75;
}else{
if(n<(2.5/p)){
n-=(2.25/p);
l=s*n*n+0.9375;
}else{
n-=(2.625/p);
l=s*n*n+0.984375;
}
}
}
return l;
}};
var _367={length:0},_368=function(){
var Now=+new Date;
for(var l in _367){
if(l!="length"&&_367[has](l)){
var e=_367[l];
if(e.stop||e.el.removed){
delete _367[l];
_367[_a]--;
continue;
}
var time=Now-e.start,ms=e.ms,_36d=e.easing,from=e.from,diff=e.diff,to=e.to,t=e.t,prev=e.prev||0,that=e.el,_374=e.callback,set={},now;
if(time<ms){
var pos=R.easing_formulas[_36d]?R.easing_formulas[_36d](time/ms):time/ms;
for(var attr in from){
if(from[has](attr)){
switch(_32[attr]){
case "along":
now=pos*ms*diff[attr];
to.back&&(now=to.len-now);
var _379=_352(to[attr],now);
that.translate(diff.sx-diff.x||0,diff.sy-diff.y||0);
diff.x=_379.x;
diff.y=_379.y;
that.translate(_379.x-diff.sx,_379.y-diff.sy);
to.rot&&that.rotate(diff.r+_379.alpha,_379.x,_379.y);
break;
case nu:
now=+from[attr]+pos*ms*diff[attr];
break;
case "colour":
now="rgb("+[_37a(_2b(from[attr].r+pos*ms*diff[attr].r)),_37a(_2b(from[attr].g+pos*ms*diff[attr].g)),_37a(_2b(from[attr].b+pos*ms*diff[attr].b))][_1d](",")+")";
break;
case "path":
now=[];
for(var i=0,ii=from[attr][_a];i<ii;i++){
now[i]=[from[attr][i][0]];
for(var j=1,jj=from[attr][i][_a];j<jj;j++){
now[i][j]=+from[attr][i][j]+pos*ms*diff[attr][i][j];
}
now[i]=now[i][_1d](S);
}
now=now[_1d](S);
break;
case "csv":
switch(attr){
case "translation":
var x=diff[attr][0]*(time-prev),y=diff[attr][1]*(time-prev);
t.x+=x;
t.y+=y;
now=x+S+y;
break;
case "rotation":
now=+from[attr][0]+pos*ms*diff[attr][0];
from[attr][1]&&(now+=","+from[attr][1]+","+from[attr][2]);
break;
case "scale":
now=[+from[attr][0]+pos*ms*diff[attr][0],+from[attr][1]+pos*ms*diff[attr][1],(2 in to[attr]?to[attr][2]:E),(3 in to[attr]?to[attr][3]:E)][_1d](S);
break;
case "clip-rect":
now=[];
i=4;
while(i--){
now[i]=+from[attr][i]+pos*ms*diff[attr][i];
}
break;
}
break;
}
set[attr]=now;
}
}
that.attr(set);
that._run&&that._run.call(that);
}else{
if(to.along){
_379=_352(to.along,to.len*!to.back);
that.translate(diff.sx-(diff.x||0)+_379.x-diff.sx,diff.sy-(diff.y||0)+_379.y-diff.sy);
to.rot&&that.rotate(diff.r+_379.alpha,_379.x,_379.y);
}
(t.x||t.y)&&that.translate(-t.x,-t.y);
to.scale&&(to.scale+=E);
that.attr(to);
delete _367[l];
_367[_a]--;
that.in_animation=null;
R.is(_374,"function")&&_374.call(that);
}
e.prev=time;
}
}
R.svg&&that&&that.paper&&that.paper.safari();
_367[_a]&&win.setTimeout(_368);
},_37a=function(_381){
return _20(_21(_381,255),0);
},_1d1=function(x,y){
if(x==null){
return {x:this._.tx,y:this._.ty,toString:x_y};
}
this._.tx+=+x;
this._.ty+=+y;
switch(this.type){
case "circle":
case "ellipse":
this.attr({cx:+x+this.attrs.cx,cy:+y+this.attrs.cy});
break;
case "rect":
case "image":
case "text":
this.attr({x:+x+this.attrs.x,y:+y+this.attrs.y});
break;
case "path":
var path=_ab(this.attrs.path);
path[0][1]+=+x;
path[0][2]+=+y;
this.attr({path:path});
break;
}
return this;
};
_179[_f].animateWith=function(_385,_386,ms,_388,_389){
_367[_385.id]&&(_386.start=_367[_385.id].start);
return this.animate(_386,ms,_388,_389);
};
_179[_f].animateAlong=along();
_179[_f].animateAlongBack=along(1);
function along(_38a){
return function(path,ms,_38d,_38e){
var _38f={back:_38a};
R.is(_38d,"function")?(_38e=_38d):(_38f.rot=_38d);
path&&path.constructor==_179&&(path=path.attrs.path);
path&&(_38f.along=path);
return this.animate(_38f,ms,_38e);
};
}
_179[_f].onAnimation=function(f){
this._run=f||0;
return this;
};
_179[_f].animate=function(_391,ms,_393,_394){
if(R.is(_393,"function")||!_393){
_394=_393||null;
}
var from={},to={},diff={};
for(var attr in _391){
if(_391[has](attr)){
if(_32[has](attr)){
from[attr]=this.attr(attr);
(from[attr]==null)&&(from[attr]=_31[attr]);
to[attr]=_391[attr];
switch(_32[attr]){
case "along":
var len=_351(_391[attr]),_39a=_352(_391[attr],len*!!_391.back),bb=this.getBBox();
diff[attr]=len/ms;
diff.tx=bb.x;
diff.ty=bb.y;
diff.sx=_39a.x;
diff.sy=_39a.y;
to.rot=_391.rot;
to.back=_391.back;
to.len=len;
_391.rot&&(diff.r=_2d(this.rotate())||0);
break;
case nu:
diff[attr]=(to[attr]-from[attr])/ms;
break;
case "colour":
from[attr]=R.getRGB(from[attr]);
var _39c=R.getRGB(to[attr]);
diff[attr]={r:(_39c.r-from[attr].r)/ms,g:(_39c.g-from[attr].g)/ms,b:(_39c.b-from[attr].b)/ms};
break;
case "path":
var _39d=_98(from[attr],to[attr]);
from[attr]=_39d[0];
var _39e=_39d[1];
diff[attr]=[];
for(var i=0,ii=from[attr][_a];i<ii;i++){
diff[attr][i]=[0];
for(var j=1,jj=from[attr][i][_a];j<jj;j++){
diff[attr][i][j]=(_39e[i][j]-from[attr][i][j])/ms;
}
}
break;
case "csv":
var _3a3=(_391[attr]+E)[_1a](_e),_3a4=(from[attr]+E)[_1a](_e);
switch(attr){
case "translation":
from[attr]=[0,0];
diff[attr]=[_3a3[0]/ms,_3a3[1]/ms];
break;
case "rotation":
from[attr]=(_3a4[1]==_3a3[1]&&_3a4[2]==_3a3[2])?_3a4:[0,_3a3[1],_3a3[2]];
diff[attr]=[(_3a3[0]-from[attr][0])/ms,0,0];
break;
case "scale":
_391[attr]=_3a3;
from[attr]=(from[attr]+E)[_1a](_e);
diff[attr]=[(_3a3[0]-from[attr][0])/ms,(_3a3[1]-from[attr][1])/ms,0,0];
break;
case "clip-rect":
from[attr]=(from[attr]+E)[_1a](_e);
diff[attr]=[];
i=4;
while(i--){
diff[attr][i]=(_3a3[i]-from[attr][i])/ms;
}
break;
}
to[attr]=_3a3;
}
}
}
}
this.stop();
this.in_animation=1;
_367[this.id]={start:_391.start||+new Date,ms:ms,easing:_393,from:from,diff:diff,to:to,el:this,callback:_394,t:{x:0,y:0}};
++_367[_a]==1&&_368();
return this;
};
_179[_f].stop=function(){
_367[this.id]&&_367[_a]--;
delete _367[this.id];
return this;
};
_179[_f].translate=function(x,y){
return this.attr({translation:x+" "+y});
};
_179[_f][_23]=function(){
return "Rapha\xebl\u2019s object";
};
R.ae=_367;
var Set=function(_3a7){
this.items=[];
this[_a]=0;
this.type="set";
if(_3a7){
for(var i=0,ii=_3a7[_a];i<ii;i++){
if(_3a7[i]&&(_3a7[i].constructor==_179||_3a7[i].constructor==Set)){
this[this.items[_a]]=this.items[this.items[_a]]=_3a7[i];
this[_a]++;
}
}
}
};
Set[_f][_d]=function(){
var item,len;
for(var i=0,ii=arguments[_a];i<ii;i++){
item=arguments[i];
if(item&&(item.constructor==_179||item.constructor==Set)){
len=this.items[_a];
this[len]=this.items[len]=item;
this[_a]++;
}
}
return this;
};
Set[_f].pop=function(){
delete this[this[_a]--];
return this.items.pop();
};
for(var _3ae in _179[_f]){
if(_179[_f][has](_3ae)){
Set[_f][_3ae]=(function(_3af){
return function(){
for(var i=0,ii=this.items[_a];i<ii;i++){
this.items[i][_3af][_5](this.items[i],arguments);
}
return this;
};
})(_3ae);
}
}
Set[_f].attr=function(name,_3b3){
if(name&&R.is(name,_1)&&R.is(name[0],"object")){
for(var j=0,jj=name[_a];j<jj;j++){
this.items[j].attr(name[j]);
}
}else{
for(var i=0,ii=this.items[_a];i<ii;i++){
this.items[i].attr(name,_3b3);
}
}
return this;
};
Set[_f].animate=function(_3b8,ms,_3ba,_3bb){
(R.is(_3ba,"function")||!_3ba)&&(_3bb=_3ba||null);
var len=this.items[_a],i=len,item,set=this,_3bf;
_3bb&&(_3bf=function(){
!--len&&_3bb.call(set);
});
_3ba=R.is(_3ba,_22)?_3ba:_3bf;
item=this.items[--i].animate(_3b8,ms,_3ba,_3bf);
while(i--){
this.items[i].animateWith(item,_3b8,ms,_3ba,_3bf);
}
return this;
};
Set[_f].insertAfter=function(el){
var i=this.items[_a];
while(i--){
this.items[i].insertAfter(el);
}
return this;
};
Set[_f].getBBox=function(){
var x=[],y=[],w=[],h=[];
for(var i=this.items[_a];i--;){
var box=this.items[i].getBBox();
x[_d](box.x);
y[_d](box.y);
w[_d](box.x+box.width);
h[_d](box.y+box.height);
}
x=_21[_5](0,x);
y=_21[_5](0,y);
return {x:x,y:y,width:_20[_5](0,w)-x,height:_20[_5](0,h)-y};
};
Set[_f].clone=function(s){
s=new Set;
for(var i=0,ii=this.items[_a];i<ii;i++){
s[_d](this.items[i].clone());
}
return s;
};
R.registerFont=function(font){
if(!font.face){
return font;
}
this.fonts=this.fonts||{};
var _3cc={w:font.w,face:{},glyphs:{}},_3cd=font.face["font-family"];
for(var prop in font.face){
if(font.face[has](prop)){
_3cc.face[prop]=font.face[prop];
}
}
if(this.fonts[_3cd]){
this.fonts[_3cd][_d](_3cc);
}else{
this.fonts[_3cd]=[_3cc];
}
if(!font.svg){
_3cc.face["units-per-em"]=_2e(font.face["units-per-em"],10);
for(var _3cf in font.glyphs){
if(font.glyphs[has](_3cf)){
var path=font.glyphs[_3cf];
_3cc.glyphs[_3cf]={w:path.w,k:{},d:path.d&&"M"+path.d[rp](/[mlcxtrv]/g,function(_3d1){
return {l:"L",c:"C",x:"z",t:"m",r:"l",v:"c"}[_3d1]||"M";
})+"z"};
if(path.k){
for(var k in path.k){
if(path[has](k)){
_3cc.glyphs[_3cf].k[k]=path.k[k];
}
}
}
}
}
}
return font;
};
_14[_f].getFont=function(_3d3,_3d4,_3d5,_3d6){
_3d6=_3d6||"normal";
_3d5=_3d5||"normal";
_3d4=+_3d4||{normal:400,bold:700,lighter:300,bolder:800}[_3d4]||400;
if(!R.fonts){
return;
}
var font=R.fonts[_3d3];
if(!font){
var name=new RegExp("(^|\\s)"+_3d3[rp](/[^\w\d\s+!~.:_-]/g,E)+"(\\s|$)","i");
for(var _3d9 in R.fonts){
if(R.fonts[has](_3d9)){
if(name.test(_3d9)){
font=R.fonts[_3d9];
break;
}
}
}
}
var _3da;
if(font){
for(var i=0,ii=font[_a];i<ii;i++){
_3da=font[i];
if(_3da.face["font-weight"]==_3d4&&(_3da.face["font-style"]==_3d5||!_3da.face["font-style"])&&_3da.face["font-stretch"]==_3d6){
break;
}
}
}
return _3da;
};
_14[_f].print=function(x,y,_3df,font,size,_3e2){
_3e2=_3e2||"middle";
var out=this.set(),_3e4=(_3df+E)[_1a](E),_3e5=0,path=E,_3e7;
R.is(font,_3df)&&(font=this.getFont(font));
if(font){
_3e7=(size||16)/font.face["units-per-em"];
var bb=font.face.bbox.split(_e),top=+bb[0],_3ea=+bb[1]+(_3e2=="baseline"?bb[3]-bb[1]+(+font.face.descent):(bb[3]-bb[1])/2);
for(var i=0,ii=_3e4[_a];i<ii;i++){
var prev=i&&font.glyphs[_3e4[i-1]]||{},curr=font.glyphs[_3e4[i]];
_3e5+=i?(prev.w||font.w)+(prev.k&&prev.k[_3e4[i]]||0):0;
curr&&curr.d&&out[_d](this.path(curr.d).attr({fill:"#000",stroke:"none",translation:[_3e5,0]}));
}
out.scale(_3e7,_3e7,top,_3ea).translate(x-top,y-_3ea);
}
return out;
};
var _3ef=/\{(\d+)\}/g;
R.format=function(_3f0,_3f1){
var args=R.is(_3f1,_1)?[0][_16](_3f1):arguments;
_3f0&&R.is(_3f0,_22)&&args[_a]-1&&(_3f0=_3f0[rp](_3ef,function(str,i){
return args[++i]==null?E:args[i];
}));
return _3f0||E;
};
R.ninja=function(){
_13.was?(Raphael=_13.is):delete Raphael;
return R;
};
R.el=_179[_f];
return R;
})();

Array.prototype.contains=function(_1){
if(Array.prototype.indexOf){
return this.indexOf(_1)!=-1;
}
for(var i in this){
if(this[i]==_1){
return true;
}
}
return false;
};
Array.prototype.setLength=function(_3,_4){
_4=typeof _4!="undefined"?_4:null;
for(var i=0;i<_3;i++){
this[i]=_4;
}
return this;
};
Array.prototype.addDimension=function(_6,_7){
_7=typeof _7!="undefined"?_7:null;
var _8=this.length;
for(var i=0;i<_8;i++){
this[i]=[].setLength(_6,_7);
}
return this;
};
Array.prototype.first=function(){
return this[0];
};
Array.prototype.last=function(){
return this[this.length-1];
};
Array.prototype.copy=function(){
var _a=[];
var _b=this.length;
for(var i=0;i<_b;i++){
if(this[i] instanceof Array){
_a[i]=this[i].copy();
}else{
_a[i]=this[i];
}
}
return _a;
};
if(!Array.prototype.map){
Array.prototype.map=function(_d){
var _e=this.length;
if(typeof _d!="function"){
throw new TypeError();
}
var _f=new Array(_e);
var _10=arguments[1];
for(var i=0;i<_e;i++){
if(i in this){
_f[i]=_d.call(_10,this[i],i,this);
}
}
return _f;
};
}
if(!Array.prototype.filter){
Array.prototype.filter=function(fun){
var len=this.length;
if(typeof fun!="function"){
throw new TypeError();
}
var res=new Array();
var _15=arguments[1];
for(var i=0;i<len;i++){
if(i in this){
var val=this[i];
if(fun.call(_15,val,i,this)){
res.push(val);
}
}
}
return res;
};
}
if(!Array.prototype.forEach){
Array.prototype.forEach=function(fun){
var len=this.length;
if(typeof fun!="function"){
throw new TypeError();
}
var _1a=arguments[1];
for(var i=0;i<len;i++){
if(i in this){
fun.call(_1a,this[i],i,this);
}
}
};
}
if(!Array.prototype.every){
Array.prototype.every=function(fun){
var len=this.length;
if(typeof fun!="function"){
throw new TypeError();
}
var _1e=arguments[1];
for(var i=0;i<len;i++){
if(i in this&&!fun.call(_1e,this[i],i,this)){
return false;
}
}
return true;
};
}
if(!Array.prototype.some){
Array.prototype.some=function(fun){
var len=this.length;
if(typeof fun!="function"){
throw new TypeError();
}
var _22=arguments[1];
for(var i=0;i<len;i++){
if(i in this&&fun.call(_22,this[i],i,this)){
return true;
}
}
return false;
};
}
Array.from=function(it){
var arr=[];
for(var i=0;i<it.length;i++){
arr[i]=it[i];
}
return arr;
};
Function.prototype.bind=function(_27){
var _28=this;
var _29=Array.from(arguments).slice(1);
return function(){
return _28.apply(_27,_29.concat(Array.from(arguments)));
};
};

eidogo=window.eidogo||{};

(function(){
var ua=navigator.userAgent.toLowerCase();
var _2=(ua.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1];
eidogo.browser={ua:ua,ver:_2,ie:/msie/.test(ua)&&!/opera/.test(ua),moz:/mozilla/.test(ua)&&!/(compatible|webkit)/.test(ua),safari3:/webkit/.test(ua)&&parseInt(_2,10)>=420};
eidogo.util={byId:function(id){
return document.getElementById(id);
},makeQueryString:function(_4){
var qs="";
if(_4&&typeof _4=="object"){
var _6=[];
for(var _7 in _4){
if(_4[_7]&&_4[_7].constructor==Array){
for(var i=0;i<_4[_7].length;i++){
_6.push(encodeURIComponent(_7)+"="+encodeURIComponent(_4[_7]));
}
}else{
_6.push(encodeURIComponent(_7)+"="+encodeURIComponent(_4[_7]));
}
}
qs=_6.join("&").replace(/%20/g,"+");
}
return qs;
},ajax:function(_9,_a,_b,_c,_d,_e,_f){
_9=_9.toUpperCase();
var xhr=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();
var qs=(_b&&typeof _b=="object"?eidogo.util.makeQueryString(_b):null);
if(qs&&_9=="GET"){
_a+=(_a.match(/\?/)?"&":"?")+qs;
qs=null;
}
xhr.open(_9,_a,true);
if(qs){
xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
}
var _12=false;
var _13=/webkit/.test(navigator.userAgent.toLowerCase());
function httpSuccess(r){
try{
return !r.status&&location.protocol=="file:"||(r.status>=200&&r.status<300)||r.status==304||_13&&r.status==undefined;
}
catch(e){
}
return false;
}
function handleReadyState(_15){
if(!_12&&xhr&&(xhr.readyState==4||_15=="timeout")){
_12=true;
if(_16){
clearInterval(_16);
_16=null;
}
var _17=_15=="timeout"&&"timeout"||!httpSuccess(xhr)&&"error"||"success";
if(_17=="success"){
_c.call(_e,xhr);
}else{
_d.call(_e);
}
xhr=null;
}
}
var _16=setInterval(handleReadyState,13);
if(_f){
setTimeout(function(){
if(xhr){
xhr.abort();
if(!_12){
handleReadyState("timeout");
}
}
},_f);
}
xhr.send(qs);
return xhr;
},addEventHelper:function(_18,_19,_1a){
if(_18.addEventListener){
_18.addEventListener(_19,_1a,false);
}else{
if(!eidogo.util.addEventId){
eidogo.util.addEventId=1;
}
if(!_1a.$$guid){
_1a.$$guid=eidogo.util.addEventId++;
}
if(!_18.events){
_18.events={};
}
var _1b=_18.events[_19];
if(!_1b){
_1b=_18.events[_19]={};
if(_18["on"+_19]){
_1b[0]=_18["on"+_19];
}
}
_1b[_1a.$$guid]=_1a;
_18["on"+_19]=eidogo.util.handleEvent;
}
},handleEvent:function(_1c){
var _1d=true;
_1c=_1c||((this.ownerDocument||this.document||this).parentWindow||window).event;
var _1e=this.events[_1c.type];
for(var i in _1e){
this.$$handleEvent=_1e[i];
if(this.$$handleEvent(_1c)===false){
_1d=false;
}
}
return _1d;
},addEvent:function(el,_21,_22,arg,_24){
if(!el){
return;
}
if(_24){
_22=_22.bind(arg);
}else{
if(arg){
var _25=_22;
_22=function(e){
_25(e,arg);
};
}
}
eidogo.util.addEventHelper(el,_21,_22);
},onClick:function(el,_28,_29){
eidogo.util.addEvent(el,"click",_28,_29,true);
},getElClickXY:function(e,el,_2c){
var doc=el.ownerDocument;
if(!e.pageX){
e.pageX=e.clientX+(doc.documentElement.scrollLeft||doc.body.scrollLeft);
e.pageY=e.clientY+(doc.documentElement.scrollTop||doc.body.scrollTop);
}
var _2e=eidogo.util.getElXY(el,_2c);
return [e.pageX-_2e[0],e.pageY-_2e[1]];
},stopEvent:function(e){
if(!e){
return;
}
if(e.stopPropagation){
e.stopPropagation();
}else{
e.cancelBubble=true;
}
if(e.preventDefault){
e.preventDefault();
}else{
e.returnValue=false;
}
},getTarget:function(ev){
var t=ev.target||ev.srcElement;
return (t&&t.nodeName&&t.nodeName.toUpperCase()=="#TEXT")?t.parentNode:t;
},addClass:function(el,cls){
if(!cls){
return;
}
var ca=cls.split(/\s+/);
for(var i=0;i<ca.length;i++){
if(!eidogo.util.hasClass(el,ca[i])){
el.className+=(el.className?" ":"")+ca[i];
}
}
},removeClass:function(el,cls){
var ca=el.className.split(/\s+/);
var nc=[];
for(var i=0;i<ca.length;i++){
if(ca[i]!=cls){
nc.push(ca[i]);
}
}
el.className=nc.join(" ");
},hasClass:function(el,cls){
var ca=el.className.split(/\s+/);
for(var i=0;i<ca.length;i++){
if(ca[i]==cls){
return true;
}
}
return false;
},show:function(el,_40){
_40=_40||"block";
if(typeof el=="string"){
el=eidogo.util.byId(el);
}
if(!el){
return;
}
el.style.display=_40;
},hide:function(el){
if(typeof el=="string"){
el=eidogo.util.byId(el);
}
if(!el){
return;
}
el.style.display="none";
},getElXY:function(el,_43){
var _44=el,elX=0,elY=0,_47=el.parentNode,sx=0,sy=0,doc=el.ownerDocument;
if(el.getBoundingClientRect){
var _4b=el.getBoundingClientRect();
elX=_4b.left+Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft);
elY=_4b.top+Math.max(doc.documentElement.scrollTop,doc.body.scrollTop);
}else{
while(_44){
elX+=_44.offsetLeft;
elY+=_44.offsetTop;
_44=_44.offsetParent?_44.offsetParent:null;
}
while(!_43&&_47&&_47.tagName&&!/^body|html$/i.test(_47.tagName)){
sx+=_47.scrollLeft;
sy+=_47.scrollTop;
elX-=_47.scrollLeft;
elY-=_47.scrollTop;
_47=_47.parentNode;
}
}
return [elX,elY,sx,sy];
},getElX:function(el){
return this.getElXY(el)[0];
},getElY:function(el){
return this.getElXY(el)[1];
},addStyleSheet:function(_4e){
if(document.createStyleSheet){
document.createStyleSheet(_4e);
}else{
var _4f=document.createElement("link");
_4f.rel="stylesheet";
_4f.type="text/css";
_4f.href=_4e;
document.getElementsByTagName("head")[0].appendChild(_4f);
}
},getPlayerPath:function(){
var _50=document.getElementsByTagName("script");
var _51;
var _52;
for(var i=0;_52=_50[i];i++){
if(/(all\.compressed\.js|eidogo\.js)/.test(_52.src)){
_51=_52.src.replace(/\/js\/[^\/]+$/,"");
}
}
return _51;
},numProperties:function(obj){
var _55=0;
for(var i in obj){
_55++;
}
return _55;
},translate:function(_57){
return t[_57];
}};
})();

eidogo=window.eidogo||{};
eidogo.i18n=eidogo.i18n||{"move":"Move","loading":"Loading","passed":"passed","resigned":"resigned","variations":"Variations","no variations":"none","tool":"Tool","view":"Jump to Move","play":"Play","region":"Select Region","add_b":"Black Stone","add_w":"White Stone","edit comment":"Edit Comment","edit game info":"Edit Game Info","done":"Done","triangle":"Triangle","square":"Square","circle":"Circle","x":"X","letter":"Letter","number":"Number","label":"Custom Label","dim":"Dim","clear":"Clear Marker","score":"Score","score est":"Score Estimate","search":"Search","search corner":"Corner Search","search center":"Center Search","region info":"Click and drag to select a region.","two stones":"Please select at least two stones to search for.","two edges":"For corner searches, your selection must touch two adjacent edges of the board.","no search url":"No search URL provided.","close search":"close search","matches found":"matches found.","show games":"Show pro games with this position","save to server":"Save to Server","download sgf":"Download SGF","multi-game sgf":"Multi-game SGF: ","next game":"Next Game","previous game":"Previous Game","end of variation":"End of variation","right":"RIGHT","wrong":"WRONG","delete":"Delete move","white":"White","white rank":"White rank","white team":"White team","black":"Black","black rank":"Black rank","black team":"Black team","captures":"captures","time left":"time left","you":"You","game":"Game","handicap":"Handicap","komi":"Komi","result":"Result","date":"Date","info":"Info","place":"Place","event":"Event","round":"Round","overtime":"Overtime","opening":"Openning","ruleset":"Ruleset","annotator":"Annotator","copyright":"Copyright","source":"Source","time limit":"Time limit","transcriber":"Transcriber","created with":"Created with","january":"January","february":"February","march":"March","april":"April","may":"May","june":"June","july":"July","august":"August","september":"September","october":"October","november":"November","december":"December","gw":"Good for White","vgw":"Very good for White","gb":"Good for Black","vgb":"Very good for Black","dm":"Even position","dmj":"Even position (joseki)","uc":"Unclear position","te":"Tesuji","bm":"Bad move","vbm":"Very bad move","do":"Doubtful move","it":"Interesting move","black to play":"Black to play","white to play":"White to play","ho":"Hotspot","rules-punish":"Punish","rules-standard":"Standard","confirm delete":"You've removed all properties from this position.\n\nDelete this position and all sub-positions?","confirm delete subtree":"You're about to remove this move and its sub-moves.\n\nReally delete this position and all sub-positions?","position deleted":"Position deleted","show result":"Show result","now plays":"Now plays: ","last move makes":"Last move makes: ","szkrab result":"Standard szkrab result: ","pass result":"Pass-move-allowed result: ","B terr":"B territory: ","W terr":"W territory: ","B dots":"B dots: ","W dots":"W dots: ","dom error":"Error finding DOM container","error retrieving":"There was a problem retrieving the game data.","invalid data":"Received invalid game data","error board":"Error loading board container","unsaved changes":"There are unsaved changes in this game. You must save before you can permalink or download.","bad path":"Don't know how to get to path: ","gnugo thinking":"GNU Go is thinking...","blank board":"Blank Board","game saved to":"Game saved to"};

eidogo.gameNodeIdCounter=100000;
eidogo.GameNode=function(){
this.init.apply(this,arguments);
};
eidogo.GameNode.prototype={init:function(_1,_2,id){
this._id=(typeof id!="undefined"?id:eidogo.gameNodeIdCounter++);
this._parent=_1||null;
this._children=[];
this._preferredChild=0;
if(_2){
this.loadJson(_2);
}
},pushProperty:function(_4,_5){
if(this[_4]){
if(!(this[_4] instanceof Array)){
this[_4]=[this[_4]];
}
if(!this[_4].contains(_5)){
this[_4].push(_5);
}
}else{
this[_4]=_5;
}
},hasPropertyValue:function(_6,_7){
if(!this[_6]){
return false;
}
var _8=(this[_6] instanceof Array?this[_6]:[this[_6]]);
return _8.contains(_7);
},deletePropertyValue:function(_9,_a){
var _b=(_a instanceof RegExp)?function(v){
return _a.test(v);
}:function(v){
return _a==v;
};
var _e=(_9 instanceof Array?_9:[_9]);
for(var i=0;_9=_e[i];i++){
if(this[_9] instanceof Array){
this[_9]=this[_9].filter(function(v){
return !_b(v);
});
if(!this[_9].length){
delete this[_9];
}
}else{
if(_b(this.prop)){
delete this[_9];
}
}
}
},deleteAllProperties:function(){
for(propName in this){
isPrivate=(propName.charAt(0)=="_");
isString=(typeof this[propName]=="string");
isArray=(this[propName] instanceof Array);
if(!isPrivate&&(isString||isArray)){
delete this[propName];
}
}
},loadJson:function(_11){
var _12=[_11],_13=[this];
var _14,_15;
var i,len;
while(_12.length){
_14=_12.pop();
_15=_13.pop();
_15.loadJsonNode(_14);
len=(_14._children?_14._children.length:0);
for(i=0;i<len;i++){
_12.push(_14._children[i]);
if(!_15._children[i]){
_15._children[i]=new eidogo.GameNode(_15);
}
_13.push(_15._children[i]);
}
}
},loadJsonNode:function(_18){
for(var _19 in _18){
if(_19=="_id"){
this[_19]=_18[_19].toString();
eidogo.gameNodeIdCounter=Math.max(eidogo.gameNodeIdCounter,parseInt(_18[_19],10));
continue;
}
if(_19.charAt(0)!="_"){
this[_19]=_18[_19];
}
}
},appendChild:function(_1a){
_1a._parent=this;
this._children.push(_1a);
},getProperties:function(){
var _1b={},_1c,_1d,_1e,_1f;
for(_1c in this){
isPrivate=(_1c.charAt(0)=="_");
_1e=(typeof this[_1c]=="string");
_1f=(this[_1c] instanceof Array);
if(!isPrivate&&(_1e||_1f)){
_1b[_1c]=this[_1c];
}
}
return _1b;
},walk:function(fn,_21){
var _22=[this];
var _23;
var i,len;
while(_22.length){
_23=_22.pop();
fn.call(_21||this,_23);
len=(_23._children?_23._children.length:0);
for(i=0;i<len;i++){
_22.push(_23._children[i]);
}
}
},getMove:function(){
if(typeof this.W!="undefined"){
return this.W;
}else{
if(typeof this.B!="undefined"){
return this.B;
}
}
return null;
},emptyPoint:function(_26){
var _27=this.getProperties();
var _28=null;
for(var _29 in _27){
if(_29=="AW"||_29=="AB"||_29=="AE"){
if(!(this[_29] instanceof Array)){
this[_29]=[this[_29]];
}
this[_29]=this[_29].filter(function(val){
if(val==_26){
_28=val;
return false;
}
return true;
});
if(!this[_29].length){
delete this[_29];
}
}else{
if((_29=="B"||_29=="W")&&this[_29]==_26){
_28=this[_29];
delete this[_29];
}
}
}
return _28;
},getPosition:function(){
if(!this._parent){
return null;
}
var _2b=this._parent._children;
for(var i=0;i<_2b.length;i++){
if(_2b[i]._id==this._id){
return i;
}
}
return null;
},toSgf:function(){
var sgf=(this._parent?"(":"");
var _2e=this;
function propsToSgf(_2f){
if(!_2f){
return "";
}
var sgf=";",key,val;
for(key in _2f){
if(_2f[key] instanceof Array){
val=_2f[key].map(function(val){
return val.toString().replace(/\]/g,"\\]");
}).join("][");
}else{
val=_2f[key].toString().replace(/\]/g,"\\]");
}
sgf+=key+"["+val+"]";
}
return sgf;
}
sgf+=propsToSgf(_2e.getProperties());
while(_2e._children.length==1){
_2e=_2e._children[0];
sgf+=propsToSgf(_2e.getProperties());
}
for(var i=0;i<_2e._children.length;i++){
sgf+=_2e._children[i].toSgf();
}
sgf+=(this._parent?")":"");
return sgf;
}};
eidogo.GameCursor=function(){
this.init.apply(this,arguments);
};
eidogo.GameCursor.prototype={init:function(_35){
this.node=_35;
},next:function(_36){
if(!this.hasNext()){
return false;
}
_36=(typeof _36=="undefined"||_36==null?this.node._preferredChild:_36);
this.node._preferredChild=_36;
this.node=this.node._children[_36];
return true;
},previous:function(){
if(!this.hasPrevious()){
return false;
}
this.node=this.node._parent;
return true;
},hasNext:function(){
return this.node&&this.node._children.length;
},hasPrevious:function(){
return this.node&&this.node._parent&&this.node._parent._parent;
},getNextMoves:function(){
if(!this.hasNext()){
return null;
}
var _37={};
var i,_39;
for(i=0;_39=this.node._children[i];i++){
_37[_39.getMove()]=i;
}
return _37;
},getNextColor:function(){
if(!this.hasNext()){
return null;
}
var i,_3b;
for(var i=0;_3b=this.node._children[i];i++){
if(_3b.W||_3b.B){
return _3b.W?"W":"B";
}
}
return null;
},getNextNodeWithVariations:function(){
var _3c=this.node;
while(_3c._children.length==1){
_3c=_3c._children[0];
}
return _3c;
},getPath:function(){
var n=this.node,_3e=[],mn=0;
while(n&&n._parent&&n._parent._children.length==1&&n._parent._parent){
mn++;
n=n._parent;
}
_3e.push(mn);
while(n){
if(n._parent&&(n._parent._children.length>1||!n._parent._parent)){
_3e.push(n.getPosition()||0);
}
n=n._parent;
}
return _3e.reverse();
},getPathMoves:function(){
var _40=[];
var cur=new eidogo.GameCursor(this.node);
_40.push(cur.node.getMove());
while(cur.previous()){
var _42=cur.node.getMove();
if(_42){
_40.push(_42);
}
}
return _40.reverse();
},getMoveNumber:function(){
var num=0,_44=this.node;
while(_44){
if(_44.W||_44.B){
num++;
}
_44=_44._parent;
}
return num;
},getGameRoot:function(){
if(!this.node){
return null;
}
var cur=new eidogo.GameCursor(this.node);
if(!this.node._parent&&this.node._children.length){
return this.node._children[0];
}
while(cur.previous()){
}
return cur.node;
}};

eidogo.SgfParser=function(){
this.init.apply(this,arguments);
};
eidogo.SgfParser.prototype={init:function(_1,_2){
_2=(typeof _2=="function")?_2:null;
this.sgf=_1;
this.index=0;
this.root={_children:[]};
this.parseTree(this.root);
_2&&_2.call(this);
},parseTree:function(_3){
while(this.index<this.sgf.length){
var c=this.curChar();
this.index++;
switch(c){
case ";":
_3=this.parseNode(_3);
break;
case "(":
this.parseTree(_3);
break;
case ")":
return;
break;
}
}
},parseNode:function(_5){
var _6={_children:[]};
if(_5){
_5._children.push(_6);
}else{
this.root=_6;
}
_6=this.parseProperties(_6);
return _6;
},parseProperties:function(_7){
var _8="";
var _9=[];
var i=0;
while(this.index<this.sgf.length){
var c=this.curChar();
if(c==";"||c=="("||c==")"){
break;
}
if(this.curChar()=="["){
while(this.curChar()=="["){
this.index++;
_9[i]="";
while(this.curChar()!="]"&&this.index<this.sgf.length){
if(this.curChar()=="\\"){
this.index++;
while(this.curChar()=="\r"||this.curChar()=="\n"){
this.index++;
}
}
_9[i]+=this.curChar();
this.index++;
}
i++;
while(this.curChar()=="]"||this.curChar()=="\n"||this.curChar()=="\r"){
this.index++;
}
}
if(_7[_8]){
if(!(_7[_8] instanceof Array)){
_7[_8]=[_7[_8]];
}
_7[_8]=_7[_8].concat(_9);
}else{
_7[_8]=_9.length>1?_9:_9[0];
}
_8="";
_9=[];
i=0;
continue;
}
if(c!=" "&&c!="\n"&&c!="\r"&&c!="\t"){
_8+=c;
}
this.index++;
}
return _7;
},curChar:function(){
return this.sgf.charAt(this.index);
}};

eidogo.Board=function(){
this.init.apply(this,arguments);
};
eidogo.Board.prototype={WHITE:2,BLACK:1,EMPTY:0,INSTOP:4,COUNTED:8,COUNTEDPUNISH:16,init:function(_1,_2,_3){
this.boardSize=_2||19;
this.boardSizeY=_3||19;
this.stones=this.makeBoardArray(this.EMPTY);
this.markers=this.makeBoardArray(this.EMPTY);
this.stops="";
this.territory="";
this.currStops={};
this.currStops.st="";
this.currStops.col=this.EMPTY;
this.captures={};
this.captures.W=0;
this.captures.B=0;
this.captures.Wterr=0;
this.captures.Bterr=0;
this.cache=[];
this.renderer=_1||new eidogo.BoardRendererHtml();
this.lastRender={stones:this.makeBoardArray(null),stops:"",territory:"",markers:this.makeBoardArray(null)};
},reset:function(){
this.init(this.renderer,this.boardSize,this.boardSizeY);
},clear:function(){
this.clearStones();
this.clearMarkers();
this.clearCaptures();
this.clearStopsAndTerr();
this.clearCurrStops();
},clearStones:function(){
for(var i=0;i<this.stones.length;i++){
this.stones[i]=this.EMPTY;
}
},clearMarkers:function(){
for(var i=0;i<this.markers.length;i++){
this.markers[i]=this.EMPTY;
}
},clearCaptures:function(){
this.captures.W=0;
this.captures.B=0;
this.captures.Wterr=0;
this.captures.Bterr=0;
},clearStopsAndTerr:function(){
this.stops="";
this.territory="";
},clearCurrStops:function(){
this.currStops.st="";
this.currStops.col=this.EMPTY;
},makeBoardArray:function(_6){
return [].setLength(this.boardSize*this.boardSizeY,_6);
},commit:function(){
this.cache.push({stones:this.stones.concat(),stops:this.stops,territory:this.territory,currStops:{st:this.currStops.st,col:this.currStops.col},captures:{W:this.captures.W,B:this.captures.B,Wterr:this.captures.Wterr,Bterr:this.captures.Bterr}});
},rollback:function(){
if(this.cache.last()){
this.stones=this.cache.last().stones.concat();
this.stops=this.cache.last().stops,this.territory=this.cache.last().territory,this.currStops.st=this.cache.last().currStops.st;
this.currStops.col=this.cache.last().currStops.col;
this.captures.W=this.cache.last().captures.W;
this.captures.B=this.cache.last().captures.B;
this.captures.Wterr=this.cache.last().captures.Wterr;
this.captures.Bterr=this.cache.last().captures.Bterr;
}else{
this.clear();
}
},revert:function(_7){
_7=_7||1;
this.rollback();
for(var i=0;i<_7;i++){
this.cache.pop();
}
this.rollback();
},addStone:function(pt,_a){
this.stones[pt.y*this.boardSize+pt.x]=_a;
},wsp:function(i,j){
var _d=this.boardSizeY-1;
return (i+1)*(_d+3)+j+1;
},wsp_x:function(i){
var _f=this.boardSizeY-1;
return Math.floor(i/(_f+3))-1;
},wsp_y:function(i){
var _11=this.boardSizeY-1;
return (i%(_11+3))-1;
},sgfCoordToPoint:function(_12){
if(!_12){
return {x:null,y:null};
}
var _13={a:0,b:1,c:2,d:3,e:4,f:5,g:6,h:7,i:8,j:9,k:10,l:11,m:12,n:13,o:14,p:15,q:16,r:17,s:18,t:19,u:20,v:21,w:22,x:23,y:24,z:25,A:26,B:27,C:28,D:29,E:30,F:31,G:32,H:33,I:34,J:35,K:36,L:37,M:38,N:39};
return {x:_13[_12.charAt(0)],y:_13[_12.charAt(1)]};
},pointToSgfCoord:function(pt){
if(!pt||pt.x<0||pt.x>=this.boardSize||pt.y<0||pt.y>=this.boardSizeY){
return null;
}
var pts={0:"a",1:"b",2:"c",3:"d",4:"e",5:"f",6:"g",7:"h",8:"i",9:"j",10:"k",11:"l",12:"m",13:"n",14:"o",15:"p",16:"q",17:"r",18:"s",19:"t",20:"u",21:"v",22:"w",23:"x",24:"y",25:"z",26:"A",27:"B",28:"C",29:"D",30:"E",31:"F",32:"G",33:"H",34:"I",35:"J",36:"K",37:"L",38:"M",39:"N"};
return pts[pt.x]+pts[pt.y];
},floodFill:function(tab){
var _17=0;
var _18=new Array();
var _19=this.boardSize-1;
var _1a=this.boardSizeY-1;
for(var i=-1;i<=_19+1;i++){
tab[this.wsp(i,-1)]=4;
tab[this.wsp(i,_1a+1)]=4;
if(i>=0&&i<=_19){
var _1c=this.wsp(i,0);
if(tab[_1c]==0){
tab[_1c]=4;
_18[_17++]=_1c;
}
_1c=this.wsp(i,_1a);
if(tab[_1c]==0){
tab[_1c]=4;
_18[_17++]=_1c;
}
}else{
tab[this.wsp(i,0)]=4;
tab[this.wsp(i,_1a)]=4;
}
}
for(var j=1;j<_1a;j++){
tab[this.wsp(-1,j)]=4;
tab[this.wsp(_19+1,j)]=4;
var _1c=this.wsp(0,j);
if(tab[_1c]==0){
tab[_1c]=4;
_18[_17++]=_1c;
}
_1c=this.wsp(_19,j);
if(tab[_1c]==0){
tab[_1c]=4;
_18[_17++]=_1c;
}
}
var dp=[-1,1,_1a+3,-_1a-3];
while(_17){
var _1c=_18[--_17];
for(var k=0;k<4;k++){
if(tab[_1c+dp[k]]==0){
tab[_1c+dp[k]]=4;
_18[_17++]=_1c+dp[k];
}
}
}
},markInterior:function(tab,pt){
var _22=0;
var _23=new Array();
var _24=this.boardSize-1;
var _25=this.boardSizeY-1;
var _26=this.wsp(pt.x,pt.y);
_23[_22++]=this.wsp(pt.x,pt.y);
var dp=[-1,1,_25+3,-_25-3];
while(_22){
do{
var _28=_23[--_22];
for(var k=0;k<4;k++){
if(tab[_28+dp[k]]==0){
tab[_28+dp[k]]=1;
_23[_22++]=_28+dp[k];
}else{
if(tab[_28+dp[k]]==4){
if(_26>_28+dp[k]){
_26=_28+dp[k];
}
tab[_28+dp[k]]=5;
}
}
}
}while(_22);
return _26;
}
},findStopBorder:function(tab,pt){
var _2c=this.boardSize-1;
var _2d=this.boardSizeY-1;
dad=new Array((_2c+3)*(_2d+3));
for(var i=0;i<(_2c+3)*(_2d+3);i++){
dad[i]=0;
}
var _2f=[0,1,1,1,0,-1,-1,-1];
var _30=[-1,-1,0,1,1,1,0,-1];
var _31=new Array(8);
for(var i=0;i<8;i++){
_31[i]=_2f[i]*(_2d+3)+_30[i];
}
var _32=new Array();
var _33=new Array();
var _34=1;
var _35=this.wsp(pt.x,pt.y);
_32[0]=116;
dad[_33[0]=this.wsp(pt.x+1,pt.y-1)]=_35;
var _36=false;
do{
var pn=_33[_34-1];
var _38=(_32[_34-1]&15);
var _39=(_32[_34-1]>>4);
if(--_38==-1){
_38=7;
}
while(_38!=_39){
var pn2=pn+_31[_38];
if(tab[pn2]==5&&dad[pn2]==0){
dad[pn2]=pn;
if(pn2==_35){
return dad;
}
_32[_34-1]&=240;
_32[_34-1]|=_38;
_33[_34]=pn2;
var kk=(_38^4);
_32[_34++]=(kk<<4)+kk;
_36=true;
break;
}
if(--_38==-1){
_38=7;
}
}
if(!_36){
_34--;
}else{
_36=false;
}
}while(_34);
return null;
},makeStop:function(_3c,_3d,_3e){
var _3f=this.boardSize-1;
var _40=this.boardSizeY-1;
var tab=new Array((_3f+3)*(_40+3));
for(var i=0;i<(_3f+3)*(_40+3);i++){
tab[i]=0;
}
var i=0;
var _43=-1;
var _44=this.EMPTY;
for(var n=0;n<_3c.length;n+=2){
var pt=this.sgfCoordToPoint(_3c.substr(n,2));
var _47=this.wsp(pt.x,pt.y);
if(_44==this.EMPTY){
_44=this.getStone(pt)&~(this.INSTOP|this.COUNTED|this.COUNTEDPUNISH);
}
tab[_47]=4;
if(_43==-1){
_43=_47;
}else{
if(_43==_47){
break;
}
}
i++;
}
this.floodFill(tab);
var _48=(_3d==0)?this.INSTOP:0;
for(var i=1;i<_3f;i++){
for(var j=1;j<_40;j++){
var pt={x:i,y:j};
if(tab[this.wsp(i,j)]==0){
var _4a=this.getStone(pt);
var _4b=this.getStone(pt)&~(this.INSTOP|this.COUNTED|this.COUNTEDPUNISH);
if(_4b==this.EMPTY){
_4a|=_48;
if(_3d){
if(_44==this.BLACK){
this.captures.Bterr++;
}else{
this.captures.Wterr++;
}
}
}else{
if(_4a&this.INSTOP){
if(_4b==_44&&(_4a&this.COUNTED)){
_4a&=~(this.COUNTED);
if(_4b==this.BLACK){
this.captures.W--;
}else{
this.captures.B--;
}
}else{
if(_4b!=_44&&!(_4a&this.COUNTED)){
_4a|=this.COUNTED;
if(_44==this.BLACK){
this.captures.B++;
}else{
this.captures.W++;
}
}
}
}else{
if(_4b==_44){
_4a|=_48;
if(_3e){
if(_44==this.BLACK){
this.captures.B--;
}else{
this.captures.W--;
}
_4a|=this.COUNTEDPUNISH;
}
}else{
if(_44==this.BLACK){
this.captures.B++;
}else{
this.captures.W++;
}
_4a|=(_48|this.COUNTED);
}
}
}
this.addStone(pt,_4a);
}
}
}
},addStop:function(_4c,_4d){
var _4e=_4c.split(".");
for(var n=_4e.length-1;n>=0;n--){
this.makeStop(_4e[n],0,_4d);
}
this.stops+=_4c;
},addTerritory:function(_50,_51){
var _52=_50.split(".");
for(var n=_52.length-1;n>=0;n--){
this.makeStop(_52[n],1,_51);
}
this.territory+=_50;
},addCurrStop:function(x,y,_56){
this.currStops.col=(_56=="B")?this.BLACK:this.WHITE;
var _57=this.pointToSgfCoord({x:x,y:y});
if(this.currStops.st==""){
if(this.getStone({x:x,y:y})!=this.EMPTY){
return this.currStops.st;
}else{
return this.currStops.st+=_57+".";
}
}
if(_57!=this.currStops.st.substr(0,2)&&this.getStone({x:x,y:y})!=this.currStops.col){
return this.currStops.st;
}
if(this.currStops.st.lastIndexOf(".")<this.currStops.st.length-1){
var _58=this.sgfCoordToPoint(this.currStops.st.substr(this.currStops.st.length-2,2));
if(x<_58.x-1||x>_58.x+1||y<_58.y-1||y>_58.y+1){
return this.currStops.st;
}
if(x==_58.x&&y==_58.y){
return (this.currStops.st=this.currStops.st.substr(0,this.currStops.st.length-2));
}
if(this.currStops.st.substr(this.currStops.st.lastIndexOf(".")+1,2)==_57){
return this.currStops.st+=_57+".";
}else{
return this.currStops.st+=_57;
}
}else{
return this.currStops.st+=_57;
}
},finishCurrStop:function(){
if(this.currStops.st==""){
return;
}
this.currStops.st=this.currStops.st.substr(0,this.currStops.st.lastIndexOf("."));
if(this.currStops.st.length<=2){
return;
}
var _59=this.currStops.st.substr(3,this.currStops.st.length-3).split(".");
for(var i=0;i<_59.length;i++){
var _5b=new Array(_59[i].length/2-1);
var min=0;
for(var p=0;p<_59[i].length-2;p+=2){
_5b[p/2]=_59[i].substr(p,2);
if(_5b[p/2]<_5b[min]){
min=p/2;
}
}
var _5e=((min>0)?_5b[min-1]:_5b[_5b.length-1]);
var _5f=((min<_5b.length-1)?_5b[min+1]:_5b[0]);
var _60;
if(_5e.charAt(0)==_5b[min].charAt(0)){
_60=-1;
}else{
if(_5f.charAt(0)==_5b[min].charAt(0)){
_60=+1;
}else{
_60=(_5f>_5e)?+1:-1;
}
}
_59[i]=_5b[min];
for(var p=min+_60;;p+=_60){
if(p==_5b.length){
p=0;
}else{
if(p==-1){
p=_5b.length-1;
}
}
_59[i]+=_5b[p];
if(p==min){
break;
}
}
}
_59.sort();
this.currStops.st=this.currStops.st.substr(0,2);
for(var i=0;i<_59.length;i++){
this.currStops.st+="."+_59[i];
}
},doAutoStops:function(_61){
var _62=this.boardSize-1;
var _63=this.boardSizeY-1;
var tab=new Array((_62+3)*(_63+3));
for(var i=0;i<(_62+3)*(_63+3);i++){
tab[i]=0;
}
for(var i=0;i<=_62;i++){
for(var j=0;j<=_63;j++){
var pt={x:i,y:j};
var _68=this.getStone(pt);
var _69=_68&~(this.INSTOP|this.COUNTED|this.COUNTEDPUNISH);
if(_69==_61&&!(_68&this.INSTOP)){
tab[this.wsp(i,j)]=4;
}
}
}
this.floodFill(tab);
var _6a=(_61==this.WHITE?this.BLACK:this.WHITE);
for(var i=1;i<_62;i++){
for(var j=1;j<_63;j++){
var pt={x:i,y:j};
if(tab[this.wsp(i,j)]==0){
var _68=this.getStone(pt);
var _69=this.getStone(pt)&~(this.INSTOP|this.COUNTED|this.COUNTEDPUNISH);
if(_69==_6a&&!(_68&this.INSTOP)){
var _6b=this.markInterior(tab,pt);
var dad=this.findStopBorder(tab,{x:this.wsp_x(_6b),y:this.wsp_y(_6b)});
var _6d=".";
var p=_6b;
do{
_6d+=this.pointToSgfCoord({x:this.wsp_x(p),y:this.wsp_y(p)});
p=dad[p];
}while(p!=_6b);
_6d+=this.pointToSgfCoord({x:this.wsp_x(p),y:this.wsp_y(p)});
this.addStop(_6d,false);
for(var ii=0;ii<=_62;ii++){
for(var jj=0;jj<=_63;jj++){
var pt={x:ii,y:jj};
var _68=this.getStone(pt);
var _69=_68&~(this.INSTOP|this.COUNTED|this.COUNTEDPUNISH);
if(_69==_61&&!(_68&this.INSTOP)){
tab[this.wsp(ii,jj)]=4;
}else{
if(tab[this.wsp(ii,jj)]==1||tab[this.wsp(ii,jj)]==5){
tab[this.wsp(ii,jj)]=0;
}
}
}
}
}
}
}
}
},whoMakesLastMove:function(_71){
var _72=0;
for(var i=0;i<this.boardSize;i++){
for(var j=0;j<this.boardSizeY;j++){
var pt={x:i,y:j};
var _76=this.getStone(pt);
if(_76==this.EMPTY){
_72++;
}
}
}
if((_72%2)==1){
return _71;
}else{
return (_71==this.BLACK?this.WHITE:this.BLACK);
}
},getGameResult:function(_77,_78){
var _79=this.captures.Wterr-this.captures.Bterr;
var _7a=this.WHITE;
if(_79<0){
_79=-_79;
_7a=this.BLACK;
}
if(_77==0){
if(_78!=_7a&&_79>0){
_79--;
}
if((_79%2)==1){
_79--;
}
var _7b=this.captures.B;
var _7c=this.captures.W;
if(_7a==this.BLACK){
_7b+=_79/2;
}else{
_7c+=_79/2;
}
return {W:_7c,B:_7b};
}else{
return {W:(this.captures.W+((_7a==this.BLACK)?0:(_79/2))),B:(this.captures.B+((_7a==this.BLACK)?(_79/2):0))};
}
},getCurrStop:function(){
return this.currStops.st;
},isOnBoard:function(pt){
return (pt.x>=0&&pt.x<this.boardSize&&pt.y>=0&&pt.y<this.boardSizeY);
},getStone:function(pt){
return this.stones[pt.y*this.boardSize+pt.x];
},isInStop:function(pt){
return (this.stones[pt.y*this.boardSize+pt.x]&this.INSTOP)!=0;
},getRegion:function(t,l,w,h){
var _84=[].setLength(w*h,this.EMPTY);
var _85;
for(var y=t;y<t+h;y++){
for(var x=l;x<l+w;x++){
_85=(y-t)*w+(x-l);
_84[_85]=this.getStone({x:x,y:y});
}
}
return _84;
},addMarker:function(pt,_89){
this.markers[pt.y*this.boardSize+pt.x]=_89;
},getMarker:function(pt){
return this.markers[pt.y*this.boardSize+pt.x];
},render:function(_8b){
var _8c=this.makeBoardArray(null);
var _8d=this.makeBoardArray(null);
var _8e;
var _8f,_90;
var len;
if(!_8b&&this.cache.last()){
var _92=this.cache.last();
len=this.stones.length;
for(var i=0;i<len;i++){
if(_92.stones[i]!=this.lastRender.stones[i]){
_8c[i]=_92.stones[i];
}
}
_8d=this.markers;
if(_92.stops.indexOf(this.lastRender.stops)==0){
_8e=this.stops;
this.lastRender.stops="";
this.renderer.renderStop0();
}else{
_8e=this.stops;
this.lastRender.stops="";
this.renderer.renderStop0();
}
}else{
_8c=this.stones;
_8d=this.markers;
_8e=this.stops;
this.lastRender.stops="";
this.renderer.renderStop0();
}
var _94;
this.renderer.adjustSizes();
for(var x=0;x<this.boardSize;x++){
for(var y=0;y<this.boardSizeY;y++){
_94=y*this.boardSize+x;
if(_8d[_94]!=null){
this.renderer.renderMarker({x:x,y:y},_8d[_94]);
this.lastRender.markers[_94]=_8d[_94];
}
if(_8c[_94]==null){
continue;
}else{
var _97=_8c[_94]&~(this.INSTOP|this.COUNTED|this.COUNTEDPUNISH);
if(_97==this.EMPTY){
_8f="empty";
}else{
_8f=(_97==this.WHITE?"white":"black");
}
}
this.renderer.renderStone({x:x,y:y},_8f);
this.lastRender.stones[_94]=_8c[_94];
}
}
this.renderer.renderCurrStop0();
this.renderer.renderBackground();
var _98=new Array(_8e,this.currStops.st,this.territory);
if(this.currStops.st!=""){
_98[1]=this.currStops.st.substr(2,this.currStops.st.length-2);
}
for(var cs=0;cs<3;cs++){
if(_98[cs]!=""){
if(cs==0){
this.lastRender.stops+=_8e;
}
var _9a=_98[cs].split(".");
if(_9a.length){
for(var s=_9a.length-1;s>=0;s--){
var ptx=new Array();
var pty=new Array();
var i=0;
var _8f=this.EMPTY;
for(var n=0;n<_9a[s].length;n+=2){
var pt=this.sgfCoordToPoint(_9a[s].substr(n,2));
if(_8f==this.EMPTY){
_8f=this.getStone(pt)&~(this.INSTOP|this.COUNTED|this.COUNTEDPUNISH);
}
ptx[i]=pt.x;
pty[i]=pt.y;
i++;
}
if(_8f==this.WHITE){
_8f="white";
}else{
if(_8f==this.BLACK){
_8f="black";
}else{
_8f="empty";
}
}
this.renderer.renderStop(ptx,pty,_8f,cs);
}
}
}
}
if(this.currStops.st!=""){
var pt=this.sgfCoordToPoint(this.currStops.st.substr(0,2));
if((this.currStops.col&~(this.INSTOP|this.COUNTED|this.COUNTEDPUNISH))==this.EMPTY){
_8f="empty";
}else{
_8f=(this.currStops.col==this.WHITE)?"white":"black";
}
this.renderer.renderStone(pt,_8f);
}
this.renderer.renderStop1();
this.renderer.renderCurrStop1();
}};
eidogo.BoardRendererHtml=function(){
this.init.apply(this,arguments);
};
eidogo.BoardRendererHtml.prototype={init:function(_a0,_a1,_a2,_a3,_a4){
if(!_a0){
throw "No DOM container";
return;
}
this.boardSize=_a1||19;
this.boardSizeY=_a2||19;
var _a5=document.createElement("div");
_a5.className="board-gutter";
if(this.boardSize==20&&this.boardSize==this.boardSizeY){
_a5.className+=" with-coords20";
}else{
if(this.boardSize==30&&this.boardSize==this.boardSizeY){
_a5.className+=" with-coords30";
}
}
_a0.appendChild(_a5);
var _a6=document.createElement("div");
if((this.boardSize==20||this.boardSize==30)&&(this.boardSize==this.boardSizeY)){
_a6.className="board size"+this.boardSize;
}else{
_a6.className="board sizeany";
}
_a6.style.position=(_a4&&eidogo.browser.ie?"static":"relative");
_a5.appendChild(_a6);
this.domNode=_a6;
this.domGutter=_a5;
this.domContainer=_a0;
this.player=_a3;
this.uniq=_a0.id+"-";
var _a7=(this.boardSize>=this.boardSizeY)?this.boardSize:this.boardSizeY;
this.renderCache={stones:[].setLength(_a7,0).addDimension(_a7,0),markers:[].setLength(_a7,0).addDimension(_a7,0)};
this.pointWidth=0;
this.pointHeight=0;
this.margin=0;
var _a8=this.renderStonePng({x:0,y:0},"black");
this.pointWidthSave=this.pointWidth=this.pointHeight=_a8.offsetWidth;
this.renderStonePng({x:0,y:0},"white");
this.renderMarker({x:0,y:0},"current");
this.clear();
this.domNodeOffsetWidthSave=this.domNode.offsetWidth;
this.margin=(this.domNode.offsetWidth-(this.boardSize*this.pointWidth))/2;
this.scrollX=0;
this.scrollY=0;
if(_a4){
this.crop(_a4);
if(eidogo.browser.ie){
var _a9=this.domNode.parentNode;
while(_a9&&_a9.tagName&&!/^body|html$/i.test(_a9.tagName)){
this.scrollX+=_a9.scrollLeft;
this.scrollY+=_a9.scrollTop;
_a9=_a9.parentNode;
}
}
}
this.scrollXsave=this.scrollX;
this.scrollYsave=this.scrollY;
this.dom={};
this.dom.searchRegion=document.createElement("div");
this.dom.searchRegion.id=this.uniq+"search-region";
this.dom.searchRegion.className="search-region";
this.domNode.appendChild(this.dom.searchRegion);
eidogo.util.addEvent(this.domNode,"mousemove",this.handleHover,this,true);
eidogo.util.addEvent(this.domNode,"mousedown",this.handleMouseDown,this,true);
eidogo.util.addEvent(this.domNode,"mouseup",this.handleMouseUp,this,true);
this.dom.stops=document.createElement("div");
this.dom.stops.id=this.uniq+"stops";
this.dom.stops.className="stops";
this.domNode.appendChild(this.dom.stops);
this.jra=Raphael(_a6,430,430);
this.jra_arr=[];
this.jra_arr_cs=[];
this.stones_el=[].setLength(_a7,0).addDimension(_a7,0);
for(var i=0;i<=this.boardSize-1;i++){
for(var j=0;j<=this.boardSizeY-1;j++){
this.stones_el[i][j]=null;
}
}
this.dom.currStops=document.createElement("div");
this.dom.currStops.id=this.uniq+"currStops";
this.dom.currStops.className="currStops";
this.domNode.appendChild(this.dom.currStops);
},adjustSizes:function(){
var _ac=(this.boardSize>=this.boardSizeY)?this.boardSize:this.boardSizeY;
if(_ac<=20){
this.pointWidth=this.pointHeight=this.pointWidthSave;
this.scrollX=this.scrollXsave;
this.scrollY=this.scrollYsave;
}else{
if(_ac==30){
this.pointWidth=this.pointHeight=13;
this.scrollX=this.scrollXsave;
this.scrollY=this.scrollYsave;
}else{
if(_ac>=36&&_ac<=40){
this.pointWidth=this.pointHeight=10;
this.scrollX=this.scrollXsave;
this.scrollY=this.scrollYsave;
}else{
this.pointWidth=this.pointHeight=Math.floor((this.pointWidthSave*(20-1))/(_ac-1));
this.scrollX=this.scrollXsave;
this.scrollY=this.scrollYsave;
}
}
}
this.margin=((this.domNodeOffsetWidthSave-(_ac*this.pointWidth))/2);
},showRegion:function(_ad){
this.dom.searchRegion.style.top=(this.margin+this.pointHeight*_ad[0])+"px";
this.dom.searchRegion.style.left=(this.margin+this.pointWidth*_ad[1])+"px";
this.dom.searchRegion.style.width=this.pointWidth*_ad[2]+"px";
this.dom.searchRegion.style.height=this.pointHeight*_ad[3]+"px";
eidogo.util.show(this.dom.searchRegion);
},hideRegion:function(){
eidogo.util.hide(this.dom.searchRegion);
},clear:function(){
this.domNode.innerHTML="";
},renderStone:function(pt,_af){
var _b0=0.25*this.pointWidth;
if(this.pointWidth<=10){
_b0=0.35*this.pointWidth;
}
if(_af!="empty"){
if(!this.stones_el[pt.x][pt.y]){
this.stones_el[pt.x][pt.y]=this.jra.circle(pt.x*this.pointWidth+this.pointWidth/2+this.margin-this.scrollX,pt.y*this.pointWidth+this.pointWidth/2+this.margin-this.scrollY,_b0);
}else{
this.stones_el[pt.x][pt.y].attr({cx:pt.x*this.pointWidth+this.pointWidth/2+this.margin-this.scrollX,cy:pt.y*this.pointWidth+this.pointWidth/2+this.margin-this.scrollY,r:_b0});
}
if(_af=="black"){
this.stones_el[pt.x][pt.y].attr({fill:"#1f33c5",stroke:"#1f33c5"}).show();
}else{
this.stones_el[pt.x][pt.y].attr({fill:"#e3241a",stroke:"#e3241a"}).show();
}
this.stones_el[pt.x][pt.y].toFront();
}else{
if(this.stones_el[pt.x][pt.y]){
this.stones_el[pt.x][pt.y].remove();
this.stones_el[pt.x][pt.y]=null;
}
}
},renderStonePng:function(pt,_b2){
var _b3=document.getElementById(this.uniq+"stone-"+pt.x+"-"+pt.y);
if(_b3){
_b3.parentNode.removeChild(_b3);
}
if(_b2!="empty"){
var div=document.createElement("div");
div.id=this.uniq+"stone-"+pt.x+"-"+pt.y;
var _b5=(this.boardSize>=this.boardSizeY)?this.boardSize:this.boardSizeY;
if(_b5<=20){
div.className="point stone "+_b2;
}else{
if(_b5<35){
div.className="point stone small "+_b2;
}else{
div.className="point stone tiny "+_b2;
}
}
try{
div.style.left=(pt.x*this.pointWidth+this.margin-this.scrollX)+"px";
div.style.top=(pt.y*this.pointHeight+this.margin-this.scrollY)+"px";
}
catch(e){
}
this.domNode.appendChild(div);
return div;
}
return null;
},renderMarker:function(pt,_b7){
if(this.renderCache.markers[pt.x][pt.y]){
var _b8=document.getElementById(this.uniq+"marker-"+pt.x+"-"+pt.y);
if(_b8){
_b8.parentNode.removeChild(_b8);
}
}
if(_b7=="empty"||!_b7){
this.renderCache.markers[pt.x][pt.y]=0;
return null;
}
this.renderCache.markers[pt.x][pt.y]=1;
if(_b7){
var _b9="";
switch(_b7){
case "triangle":
case "square":
case "circle":
case "ex":
case "territory-white":
case "territory-black":
case "dim":
case "current":
break;
default:
if(_b7.indexOf("varB:")==0){
_b9=_b7.substring(5);
if(this.pointWidth>=13){
_b7="variationB";
}else{
_b7="variationBsmall";
}
}else{
if(_b7.indexOf("varW:")==0){
_b9=_b7.substring(5);
if(this.pointWidth>=13){
_b7="variationW";
}else{
_b7="variationWsmall";
}
}else{
_b9=_b7;
_b7="label";
}
}
break;
}
var div=document.createElement("div");
div.id=this.uniq+"marker-"+pt.x+"-"+pt.y;
div.className="point marker "+_b7;
var _bb=0;
var _bc=(this.boardSize>=this.boardSizeY)?this.boardSize:this.boardSizeY;
if(_bc>=35){
_bb=4;
}else{
if(_bc>27){
_bb=3;
}else{
if(_bc>20){
_bb=2;
}
}
}
try{
div.style.left=(pt.x*this.pointWidth+this.margin-_bb-this.scrollX)+"px";
div.style.top=(pt.y*this.pointHeight+this.margin-_bb-this.scrollY)+"px";
}
catch(e){
}
div.appendChild(document.createTextNode(_b9));
this.domNode.appendChild(div);
return div;
}
return null;
},renderStop:function(ptx,pty,_bf,_c0){
if(ptx.length<2){
return;
}
for(var i=0;i<ptx.length;i++){
ptx[i]=ptx[i]*this.pointWidth+this.pointWidth/2+this.margin-this.scrollX;
pty[i]=pty[i]*this.pointWidth+this.pointWidth/2+this.margin-this.scrollY;
}
var _c2="M "+ptx[0]+" "+pty[0]+" ";
for(var i=1;i<ptx.length;i++){
_c2+="L "+ptx[i]+" "+pty[i];
}
var _c3;
switch(_c0){
case 0:
if(_bf=="white"){
_c3=this.jra.path(_c2).attr({fill:"#eaa297",stroke:"black"});
}else{
if(_bf=="black"){
_c3=this.jra.path(_c2).attr({fill:"#b0b7f4",stroke:"black"});
}else{
_c3=this.jra.path(_c2).attr({fill:"red",stroke:"black"});
}
}
this.jra_arr.push(_c3);
break;
case 2:
if(_bf=="white"){
_c3=this.jra.path(_c2).attr({fill:"#ffb2a6",stroke:"#ffb2a6"});
}else{
if(_bf=="black"){
_c3=this.jra.path(_c2).attr({fill:"#c2c9ff",stroke:"#c2c9ff"});
}else{
_c3=this.jra.path(_c2).attr({fill:"red",stroke:"red"});
}
}
this.jra_arr.push(_c3);
break;
case 1:
_c3=this.jra.path(_c2).attr({stroke:"black"});
this.jra_arr_cs.push(_c3);
break;
}
_c3.toBack();
},renderStop0:function(){
while(this.jra_arr.length>0){
var el=this.jra_arr.pop();
el.remove();
}
},renderStop1:function(){
},renderBackground:function(){
var _c5=(this.boardSize>=this.boardSizeY)?this.boardSize:this.boardSizeY;
var _c6=(_c5==20||_c5==30);
if(!_c6||this.boardSize!=this.boardSizeY){
var min=(this.pointWidth/2+this.margin);
var max=((this.boardSize-1)*this.pointWidth+this.pointWidth/2+this.margin);
var _c9=((this.boardSizeY-1)*this.pointWidth+this.pointWidth/2+this.margin);
var _ca="";
for(var i=0;i<_c5;i++){
if(i%5==0){
continue;
}
if(i<this.boardSize){
var x=Math.floor(i*this.pointWidth+this.pointWidth/2+this.margin-this.scrollX)+0.5;
_ca+="M "+x+" "+(min-this.scrollY)+"L "+x+" "+(_c9-this.scrollY)+" ";
}
if(i<this.boardSizeY){
var y=Math.floor(i*this.pointWidth+this.pointWidth/2+this.margin-this.scrollY)+0.5;
_ca+="M "+(min-this.scrollX)+" "+y+"L "+(max-this.scrollX)+" "+y+" ";
}
}
var el1=this.jra.path(_ca).attr({stroke:"#cecfce","stroke-width":1});
el1.toBack();
this.jra_arr.push(el1);
_ca="";
for(var i=0;i<_c5;i+=5){
if(i<this.boardSize){
var x=Math.floor(i*this.pointWidth+this.pointWidth/2+this.margin-this.scrollX)+0.5;
_ca+="M "+x+" "+(min-this.scrollY)+"L "+x+" "+(_c9-this.scrollY)+" ";
}
if(i<this.boardSizeY){
var y=Math.floor(i*this.pointWidth+this.pointWidth/2+this.margin-this.scrollY)+0.5;
_ca+="M "+(min-this.scrollX)+" "+y+"L "+(max-this.scrollX)+" "+y+" ";
}
}
var el2=this.jra.path(_ca).attr({stroke:"#bbbcbb","stroke-width":1});
el2.toBack();
this.jra_arr.push(el2);
}
},renderCurrStop0:function(){
while(this.jra_arr_cs.length>0){
var el=this.jra_arr_cs.pop();
el.remove();
}
},renderCurrStop1:function(){
},setCursor:function(_d1){
this.domNode.style.cursor=_d1;
},handleHover:function(e){
var xy=this.getXY(e);
this.player.handleBoardHover(xy[0],xy[1],xy[2],xy[3],e);
},handleMouseDown:function(e){
var xy=this.getXY(e);
this.player.handleBoardMouseDown(xy[0],xy[1],xy[2],xy[3],e);
},handleMouseUp:function(e){
var xy=this.getXY(e);
this.player.handleBoardMouseUp(xy[0],xy[1]);
},getXY:function(e){
var _d9=eidogo.util.getElClickXY(e,this.domNode);
var m=this.margin;
var pw=this.pointWidth;
var ph=this.pointHeight;
var x=Math.round((_d9[0]-m-(pw/2))/pw);
var y=Math.round((_d9[1]-m-(ph/2))/ph);
return [x,y,_d9[0],_d9[1]];
},crop:function(_df){
eidogo.util.addClass(this.domContainer,"shrunk");
this.domGutter.style.overflow="hidden";
var _e0=_df.width*this.pointWidth+(this.margin*2);
var _e1=_df.height*this.pointHeight+(this.margin*2);
this.domGutter.style.width=_e0+"px";
this.domGutter.style.height=_e1+"px";
this.player.dom.player.style.width=_e0+"px";
this.domGutter.scrollLeft=_df.left*this.pointWidth;
this.domGutter.scrollTop=_df.top*this.pointHeight;
}};
eidogo.BoardRendererFlash=function(){
this.init.apply(this,arguments);
};
eidogo.BoardRendererFlash.prototype={init:function(_e2,_e3,_e4,_e5){
if(!_e2){
throw "No DOM container";
return;
}
this.ready=false;
this.swf=null;
this.unrendered=[];
var _e6=_e2.id+"-board";
var so=new SWFObject(eidogo.playerPath+"/swf/board.swf",_e6,"421","421","8","#665544");
so.addParam("allowScriptAccess","sameDomain");
so.write(_e2);
var _e8=0;
var _e9=function(){
swf=eidogo.util.byId(_e6);
if(!swf||!swf.init){
if(_e8>2000){
throw "Error initializing board";
return;
}
setTimeout(arguments.callee.bind(this),10);
_e8+=10;
return;
}
this.swf=swf;
this.swf.init(_e4.uniq,_e3);
this.ready=true;
}.bind(this);
_e9();
},showRegion:function(_ea){
},hideRegion:function(){
},clear:function(){
if(!this.swf){
return;
}
this.swf.clear();
},renderStone:function(pt,_ec){
if(!this.swf){
this.unrendered.push(["stone",pt,_ec]);
return;
}
for(var i=0;i<this.unrendered.length;i++){
if(this.unrendered[i][0]=="stone"){
this.swf.renderStone(this.unrendered[i][1],this.unrendered[i][2]);
}
}
this.unrendered=[];
this.swf.renderStone(pt,_ec);
},renderMarker:function(pt,_ef){
if(!_ef){
return;
}
if(!this.swf){
this.unrendered.push(["marker",pt,_ef]);
return;
}
for(var i=0;i<this.unrendered.length;i++){
if(this.unrendered[i][0]=="marker"){
this.swf.renderMarker(this.unrendered[i][1],this.unrendered[i][2]);
}
}
this.unrendered=[];
this.swf.renderMarker(pt,_ef);
},setCursor:function(_f1){
},crop:function(){
}};
eidogo.BoardRendererAscii=function(_f2,_f3){
this.init(_f2,_f3);
};
eidogo.BoardRendererAscii.prototype={pointWidth:2,pointHeight:1,margin:1,blankBoard:"+-------------------------------------+\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"|. . . . . . . . . . . . . . . . . . .|\n"+"+-------------------------------------+",init:function(_f4,_f5){
this.domNode=_f4||null;
this.boardSize=_f5||19;
this.content=this.blankBoard;
},clear:function(){
this.content=this.blankBoard;
this.domNode.innerHTML="<pre>"+this.content+"</pre>";
},renderStone:function(pt,_f7){
var _f8=(this.pointWidth*this.boardSize+this.margin*2)*(pt.y*this.pointHeight+1)+(pt.x*this.pointWidth)+2;
this.content=this.content.substring(0,_f8-1)+"."+this.content.substring(_f8);
if(_f7!="empty"){
this.content=this.content.substring(0,_f8-1)+(_f7=="white"?"O":"#")+this.content.substring(_f8);
}
this.domNode.innerHTML="<pre>"+this.content+"</pre>";
},renderMarker:function(pt,_fa){
}};

eidogo.Rules=function(_1){
this.init(_1);
};
eidogo.Rules.prototype={init:function(_2){
this.board=_2;
this.pendingCaptures=[];
this.punish=false;
this.russian=false;
},setPunish:function(_3){
this.punish=_3;
},getPunish:function(){
return this.punish;
},setRussian:function(_4){
this.russian=_4;
},getRussian:function(){
return this.russian;
},check:function(pt,_6){
if(!this.board.isOnBoard(pt)){
return false;
}
if(this.board.getStone(pt)!=this.board.EMPTY){
return false;
}
return true;
},apply:function(pt,_8){
if(this.russian){
this.board.doAutoStops(_8);
}
}};

(function(){
var t=eidogo.i18n,_2=eidogo.util.byId,_3=eidogo.util.ajax,_4=eidogo.util.addEvent,_5=eidogo.util.onClick,_6=eidogo.util.getElClickXY,_7=eidogo.util.stopEvent,_8=eidogo.util.addClass,_9=eidogo.util.removeClass,_a=eidogo.util.show,_b=eidogo.util.hide,_c=eidogo.browser.moz,_d=eidogo.util.getPlayerPath();
eidogo.players=eidogo.players||{};
eidogo.delegate=function(_e,fn){
var _10=eidogo.players[_e];
_10[fn].apply(_10,Array.from(arguments).slice(2));
};
eidogo.Player=function(){
this.init.apply(this,arguments);
};
eidogo.Player.prototype={init:function(cfg){
cfg=cfg||{};
this.mode=cfg.mode?cfg.mode:"play";
this.dom={};
this.dom.container=(typeof cfg.container=="string"?_2(cfg.container):cfg.container);
if(!this.dom.container){
alert(t["dom error"]);
return;
}
this.uniq=(new Date()).getTime();
eidogo.players[this.uniq]=this;
this.sgfPath=cfg.sgfPath;
this.searchUrl=cfg.searchUrl;
this.showingSearch=false;
this.saveUrl=cfg.saveUrl;
this.downloadUrl=cfg.downloadUrl;
this.scoreEstUrl=cfg.scoreEstUrl;
this.hooks=cfg.hooks||{};
this.permalinkable=!!this.hooks.setPermalink;
this.propertyHandlers={W:this.playMove,B:this.playMove,KO:this.playMove,MN:this.setMoveNumber,AW:this.addStone,AB:this.addStone,AE:this.addStone,CR:this.addMarker,LB:this.addMarker,TR:this.addMarker,MA:this.addMarker,SQ:this.addMarker,TW:this.addTerritory,TB:this.addTerritory,DD:this.addMarker,PL:this.setColor,C:this.showComments,N:this.showAnnotation,GB:this.showAnnotation,GW:this.showAnnotation,DM:this.showAnnotation,HO:this.showAnnotation,UC:this.showAnnotation,V:this.showAnnotation,BM:this.showAnnotation,DO:this.showAnnotation,IT:this.showAnnotation,TE:this.showAnnotation,BL:this.showTime,OB:this.showTime,WL:this.showTime,OW:this.showTime};
this.infoLabels={GN:t["game"],PW:t["white"],WR:t["white rank"],WT:t["white team"],PB:t["black"],BR:t["black rank"],BT:t["black team"],HA:t["handicap"],KM:t["komi"],RE:t["result"],DT:t["date"],GC:t["info"],PC:t["place"],EV:t["event"],RO:t["round"],OT:t["overtime"],ON:t["opening"],RU:t["ruleset"],AN:t["annotator"],CP:t["copyright"],SO:t["source"],TM:t["time limit"],US:t["transcriber"],AP:t["created with"]};
this.months=[t["january"],t["february"],t["march"],t["april"],t["may"],t["june"],t["july"],t["august"],t["september"],t["october"],t["november"],t["december"]];
this.theme=cfg.theme;
this.reset(cfg);
this.renderer=cfg.renderer||"html";
this.cropParams=null;
this.shrinkToFit=cfg.shrinkToFit;
if(this.shrinkToFit||cfg.cropWidth||cfg.cropHeight){
this.cropParams={};
this.cropParams.width=cfg.cropWidth;
this.cropParams.height=cfg.cropHeight;
this.cropParams.left=cfg.cropLeft;
this.cropParams.top=cfg.cropTop;
this.cropParams.padding=cfg.cropPadding||1;
}
this.constructDom();
if(cfg.enableShortcuts){
_4(document,_c?"keypress":"keydown",this.handleKeypress,this,true);
}
_4(document,"mouseup",this.handleDocMouseUp,this,true);
if(cfg.sgf||cfg.sgfUrl||(cfg.sgfPath&&cfg.gameName)){
this.loadSgf(cfg);
}
this.hook("initDone");
},hook:function(_12,_13){
if(_12 in this.hooks){
return this.hooks[_12].bind(this)(_13);
}
},reset:function(cfg){
this.gameName="";
this.collectionRoot=new eidogo.GameNode();
this.cursor=new eidogo.GameCursor();
this.progressiveLoad=cfg.progressiveLoad?true:false;
this.progressiveLoads=null;
this.progressiveUrl=null;
this.progressiveMode=cfg.progressiveLoad&&cfg.progressiveMode||"id";
this.opponentUrl=null;
this.opponentColor=null;
this.opponentLevel=null;
this.board=null;
this.rules=null;
this.currentColor=null;
this.moveNumber=null;
this.totalMoves=null;
this.variations=null;
this.timeB="";
this.timeW="";
this.regionTop=null;
this.regionLeft=null;
this.regionWidth=null;
this.regionHeight=null;
this.regionBegun=null;
this.regionClickSelect=null;
this.mouseDown=null;
this.mouseDownX=null;
this.mouseDownY=null;
this.mouseDownClickX=null;
this.mouseDownClickY=null;
this.labelLastLetter=null;
this.labelLastNumber=null;
this.resetLastLabels();
this.unsavedChanges=false;
this.updatedNavTree=false;
this.navTreeTimeout=null;
this.searching=false;
this.editingText=false;
this.goingBack=false;
this.problemMode=cfg.problemMode;
this.problemColor=cfg.problemColor;
this.problemSolution=0;
this.prefs={};
this.prefs.markCurrent=typeof cfg.markCurrent!="undefined"?!!cfg.markCurrent:true;
this.prefs.markNext=typeof cfg.markNext!="undefined"?cfg.markNext:false;
this.prefs.markVariations=typeof cfg.markVariations!="undefined"?!!cfg.markVariations:true;
this.prefs.showGameInfo=!!cfg.showGameInfo;
this.prefs.showPlayerInfo=!!cfg.showPlayerInfo;
this.prefs.showTools=!!cfg.showTools;
this.prefs.showComments=typeof cfg.showComments!="undefined"?!!cfg.showComments:true;
this.prefs.showOptions=!!cfg.showOptions;
this.prefs.showNavTree=!this.progressiveLoad&&typeof cfg.showNavTree!="undefined"?!!cfg.showNavTree:false;
},loadSgf:function(cfg,_16){
cfg=cfg||{};
this.nowLoading();
this.reset(cfg);
this.sgfPath=cfg.sgfPath||this.sgfPath;
this.loadPath=cfg.loadPath&&cfg.loadPath.length>1?cfg.loadPath:[0,0];
this.gameName=cfg.gameName||"";
var _17=false;
if(typeof cfg.sgf=="string"){
var sgf=new eidogo.SgfParser(cfg.sgf);
this.load(sgf.root);
}else{
if(typeof cfg.sgf=="object"){
this.load(cfg.sgf);
}else{
if(cfg.progressiveLoad&&cfg.progressiveUrl){
this.progressiveLoads=0;
this.progressiveUrl=cfg.progressiveUrl;
this.fetchProgressiveData(_16);
_17=true;
}else{
if(typeof cfg.sgfUrl=="string"||this.gameName){
if(!cfg.sgfUrl){
cfg.sgfUrl=this.sgfPath+this.gameName+".sgf";
}
this.remoteLoad(cfg.sgfUrl,null,false,null,_16);
_17=true;
if(cfg.progressiveLoad){
this.progressiveLoads=0;
this.progressiveUrl=cfg.progressiveUrl||cfg.sgfUrl.replace(/\?.+$/,"");
}
}else{
var _19=cfg.boardSize||"20";
var _1a={20:0,19:0,13:0,9:0,7:0};
var _1b={_children:[{SZ:_19,KM:cfg.komi||_1a[_19]||0,_children:[]}]};
if(cfg.opponentUrl){
this.gameName="gnugo";
this.opponentUrl=cfg.opponentUrl;
this.opponentColor=cfg.opponentColor=="B"?cfg.opponentColor:"W";
this.opponentLevel=cfg.opponentLevel||7;
var _1c=_1b._children[0];
_1c.PW=this.opponentColor=="B"?t["you"]:"GNU Go";
_1c.PB=this.opponentColor=="B"?"GNU Go":t["you"];
_1c.HA=parseInt(cfg.handicap,10)||0;
if(_1c.HA){
var _1d={19:[["pd","dp"],["pd","dp","pp"],["pd","dp","pp","dd"],["pd","dp","pp","dd","jj"],["pd","dp","pp","dd","dj","pj"],["pd","dp","pp","dd","dj","pj","jj"],["pd","dp","pp","dd","dj","pj","jd","jp"],["pd","dp","pp","dd","dj","pj","jd","jp","jj"]],13:[["jd","dj"],["jd","dj","jj"],["jd","dj","jj","dd"],["jd","dj","jj","dd","gg"],["jd","dj","jj","dd","dg","jg"],["jd","dj","jj","dd","dg","jg","gg"],["jd","dj","jj","dd","dg","jg","gd","gj"],["jd","dj","jj","dd","dg","jg","gd","gj","gg"]],9:[["cg","gc"],["cg","gc","gg"],["cg","gc","gg","cc"],["cg","gc","gg","cc","ee"],["cg","gc","gg","cc","ce","ge"],["cg","gc","gg","cc","ce","ge","ee"],["cg","gc","gg","cc","ce","ge","ec","eg"],["cg","gc","gg","cc","ce","ge","ec","eg","ee"]]};
_1c.KM=0.5;
if(_1c.HA>1){
_1c.AB=_1d[_19][_1c.HA-2];
}
}
}
this.load(_1b);
}
}
}
}
if(!_17&&typeof _16=="function"){
_16();
}
},load:function(_1e,_1f){
var _20=false;
if(!_1f){
_1f=new eidogo.GameNode();
this.collectionRoot=_1f;
}
_1f.loadJson(_1e);
_1f._cached=true;
this.doneLoading();
this.progressiveLoads--;
if(!_1f._parent){
var _21=this.loadPath.length?parseInt(this.loadPath[0],10):0;
this.initGame(_1f._children[_21||0]);
_20=true;
}
if(this.loadPath.length){
this.goTo(this.loadPath,_20);
if(!this.progressiveLoad){
this.loadPath=[0,0];
}
}else{
this.refresh();
}
if(_20&&this.problemMode){
if(!this.problemColor){
this.currentColor=this.problemColor=(this.cursor.getNextColor()||"B");
}else{
this.currentColor=this.problemColor;
}
}
},remoteLoad:function(url,_23,_24,_25,_26){
_24=_24=="undefined"?true:_24;
_26=(typeof _26=="function")?_26:null;
if(_24){
if(!_23){
this.gameName=url;
}
url=this.sgfPath+url+".sgf";
}
if(_25){
this.loadPath=_25;
}
var _27=function(req){
var _29=req.responseText.replace(/^( |\t|\r|\n)*/,"");
if(_29.charAt(0)!="("&&_29.charAt(0)!="{"){
var cor=_29.indexOf("(;FF[");
if(cor>0){
_29=_29.substr(cor);
}
}
if(_29.charAt(0)=="("){
var me=this;
var sgf=new eidogo.SgfParser(_29,function(){
me.load(this.root,_23);
_26&&_26();
});
}else{
if(_29.charAt(0)=="{"){
_29=eval("("+_29+")");
this.load(_29,_23);
_26&&_26();
}else{
this.croak(t["invalid data"]);
}
}
};
var _2d=function(req){
this.croak(t["error retrieving"]);
};
_3("get",url,null,_27,_2d,this,30000);
},initGame:function(_2f){
_2f=_2f||{};
this.handleDisplayPrefs();
var _30=_2f.SZ;
if(!_30){
_30=20;
}
var _31=_30;
if(_30.indexOf(":")>=0){
var tab=_30.split(":",2);
_30=tab[0];
var _31=tab[1];
}
if(_30<9||_30>40){
_30=20;
}
if(this.shrinkToFit){
this.calcShrinkToFit(_2f,_30);
}else{
if(this.problemMode&&!this.cropParams){
this.cropParams={width:_30,height:_30,top:0,left:0,padding:1};
}
}
if(!this.board){
this.createBoard(_30,_31);
this.rules=new eidogo.Rules(this.board);
}
this.unsavedChanges=false;
this.resetCursor(true);
this.totalMoves=0;
var _33=new eidogo.GameCursor(this.cursor.node);
while(_33.next()){
this.totalMoves++;
}
this.totalMoves--;
this.showGameInfo(_2f);
this.enableNavSlider();
this.selectTool(this.mode=="view"?"view":"play");
this.hook("initGame");
},handleDisplayPrefs:function(){
(this.prefs.showGameInfo||this.prefs.showPlayerInfo?_a:_b)(this.dom.info);
(this.prefs.showGameInfo?_a:_b)(this.dom.infoGame);
(this.prefs.showPlayerInfo?_a:_b)(this.dom.infoPlayers);
(this.prefs.showTools?_a:_b)(this.dom.toolsContainer);
if(!this.showingSearch){
(this.prefs.showComments?_a:_b)(this.dom.comments);
}
(this.prefs.showOptions?_a:_b)(this.dom.options);
(this.prefs.showNavTree?_a:_b)(this.dom.navTreeContainer);
},createBoard:function(_34,_35){
_34=_34||20;
_35=_35||20;
if(this.board&&this.board.renderer&&this.board.boardSize==_34&&this.board.boardSizeY==_35){
return;
}
try{
this.dom.boardContainer.innerHTML="";
var _36=(this.renderer=="flash"?eidogo.BoardRendererFlash:eidogo.BoardRendererHtml);
var _37=new _36(this.dom.boardContainer,_34,_35,this,this.cropParams);
this.board=new eidogo.Board(_37,_34,_35);
}
catch(e){
if(e=="No DOM container"){
this.croak(t["error board"]);
return;
}
}
},calcShrinkToFit:function(_38,_39){
var l=null,t=null,r=null,b=null;
var _3d={};
var me=this;
_38.walk(function(_3f){
var _40,i,_42;
for(_40 in _3f){
if(/^(W|B|AW|AB|LB)$/.test(_40)){
_42=_3f[_40];
if(!(_42 instanceof Array)){
_42=[_42];
}
if(_40!="LB"){
_42=me.expandCompressedPoints(_42);
}else{
_42=[_42[0].split(/:/)[0]];
}
for(i=0;i<_42.length;i++){
_3d[_42[i]]="";
}
}
}
});
for(var key in _3d){
var pt=this.sgfCoordToPoint(key);
if(l==null||pt.x<l){
l=pt.x;
}
if(r==null||pt.x>r){
r=pt.x;
}
if(t==null||pt.y<t){
t=pt.y;
}
if(b==null||pt.y>b){
b=pt.y;
}
}
this.cropParams.width=r-l+1;
this.cropParams.height=b-t+1;
this.cropParams.left=l;
this.cropParams.top=t;
var pad=this.cropParams.padding;
for(var _46=pad;l-_46<0;_46--){
}
if(_46){
this.cropParams.width+=_46;
this.cropParams.left-=_46;
}
for(var _47=pad;t-_47<0;_47--){
}
if(_47){
this.cropParams.height+=_47;
this.cropParams.top-=_47;
}
for(var _48=pad;r+_48>_39;_48--){
}
if(_48){
this.cropParams.width+=_48;
}
for(var _49=pad;b+_49>_39;_49--){
}
if(_49){
this.cropParams.height+=_49;
}
},fetchOpponentMove:function(){
this.nowLoading(t["gnugo thinking"]);
var _4a=function(req){
this.doneLoading();
this.createMove(req.responseText);
};
var _4c=function(req){
this.croak(t["error retrieving"]);
};
var _4e=this.cursor.getGameRoot();
var _4f={sgf:_4e.toSgf(),move:this.currentColor,size:_4e.SZ,level:this.opponentLevel};
_3("post",this.opponentUrl,_4f,_4a,_4c,this,45000);
},fetchScoreEstimate:function(){
this.nowLoading(t["gnugo thinking"]);
var _50=function(req){
this.doneLoading();
var _52=req.responseText.split("\n");
var _53,_54=_52[1].split(" ");
for(var i=0;i<_54.length;i++){
_53=_54[i].split(":");
if(_53[1]){
this.addMarker(_53[1],_53[0]);
}
}
this.board.render();
this.prependComment(_52[0]);
};
var _56=function(req){
this.croak(t["error retrieving"]);
};
var _58=this.cursor.getGameRoot();
var _59={sgf:_58.toSgf(),move:"est",size:_58.SZ||19,komi:_58.KM||0,mn:this.moveNumber+1};
_3("post",this.scoreEstUrl,_59,_50,_56,this,45000);
},playProblemResponse:function(_5a){
setTimeout(function(){
this.variation(null,_5a);
if(this.hooks.playProblemResponse){
this.hook("playProblemResponse");
}else{
if(!this.cursor.hasNext()){
this.prependComment(t["end of variation"]);
if(this.problemSolution<=0){
this.problemSolution=-1;
this.prependComment(t["wrong"]);
}else{
this.prependComment(t["right"]);
}
}
}
}.bind(this),200);
},goTo:function(_5b,_5c){
_5c=typeof _5c!="undefined"?_5c:true;
if(_5c&&_5b.length>1&&_5b[0]!=this.cursor.getGameRoot().getPosition()){
this.updatedNavTree=false;
}
if(_5c){
this.resetCursor(true);
}
var _5d=parseInt(_5b,10);
if(!(_5b instanceof Array)&&!isNaN(_5d)){
if(_5c){
_5d++;
}
for(var i=0;i<_5d;i++){
this.variation(null,true);
}
this.refresh();
return;
}
if(!(_5b instanceof Array)||!_5b.length){
alert(t["bad path"]+" "+_5b);
return;
}
var _5f;
var _60;
if(isNaN(parseInt(_5b[0],10))){
if(!this.cursor.node._parent){
this.variation(0,true);
}
while(_5b.length){
if(this.progressiveLoads>0){
this.loadPath.push(_5f);
return;
}
_5f=_5b.shift();
_60=this.getVariations();
for(var i=0;i<_60.length;i++){
if(_60[i].move==_5f){
this.variation(_60[i].varNum,true);
break;
}
}
}
this.refresh();
return;
}
var _61=true;
while(_5b.length){
_5f=parseInt(_5b.shift(),10);
if(!_5b.length){
for(var i=0;i<_5f;i++){
this.variation(0,true);
}
}else{
if(_5b.length){
if(!_61&&(this.cursor.node._parent._parent||_5c)){
while(this.cursor.node._children.length==1){
this.variation(0,true);
}
}
this.variation(_5f,true);
}
}
_61=false;
}
this.refresh();
},resetCursor:function(_62,_63){
this.board.reset();
this.resetCurrentColor();
if(_63){
this.cursor.node=this.cursor.getGameRoot();
}else{
this.cursor.node=this.collectionRoot;
}
this.refresh(_62);
},resetCurrentColor:function(){
this.currentColor=(this.problemMode?this.problemColor:"B");
var _64=this.cursor.getGameRoot();
if(_64&&_64.HA>1){
this.currentColor="W";
}
},refresh:function(_65){
if(this.progressiveLoads>0){
var me=this;
setTimeout(function(){
me.refresh.call(me);
},10);
return;
}
this.board.revert(1);
this.execNode(_65);
},variation:function(_67,_68){
if(this.cursor.next(_67)){
this.execNode(_68);
this.resetLastLabels();
if(this.progressiveLoads>0){
return false;
}
return true;
}
return false;
},execNode:function(_69,_6a){
if(!_6a&&this.progressiveLoads>0){
var me=this;
setTimeout(function(){
me.execNode.call(me,_69);
},10);
return;
}
if(!this.cursor.node){
return;
}
if(!_69){
this.dom.comments.innerHTML="";
this.board.clearMarkers();
this.moveNumber=this.cursor.getMoveNumber();
}
if(this.moveNumber<1){
this.resetCurrentColor();
}
if(this.mode=="playstop"){
this.board.clearCurrStops();
this.mode="play";
}
var _6c=this.cursor.node.getProperties();
for(var _6d in _6c){
if(this.propertyHandlers[_6d]){
(this.propertyHandlers[_6d]).apply(this,[this.cursor.node[_6d],_6d,_69]);
}
}
if(_69){
this.board.commit();
}else{
if(this.opponentUrl&&this.opponentColor==this.currentColor&&this.moveNumber==this.totalMoves){
this.fetchOpponentMove();
}
this.findVariations();
this.updateControls();
this.board.commit();
this.board.render();
}
if(!_6a&&this.progressiveUrl){
this.fetchProgressiveData();
}
if(this.problemMode&&this.currentColor&&this.currentColor!=this.problemColor&&!this.goingBack){
this.playProblemResponse(_69);
}
this.goingBack=false;
},fetchProgressiveData:function(_6e){
var _6f=this.cursor.node||null;
if(_6f&&_6f._cached){
return;
}
if(this.progressiveMode=="pattern"){
if(_6f&&!_6f._parent._parent){
return;
}
this.fetchProgressiveContinuations(_6e);
}else{
var _70=(_6f&&_6f._id)||0;
this.nowLoading();
this.progressiveLoads++;
var _71=function(){
var _72=this.cursor.getMoveNumber();
if(_72>1){
this.cursor.node.C="<a id='cont-search' href='#'>"+t["show games"]+"</a>"+(this.cursor.node.C||"");
}
this.refresh();
if(_6e&&typeof _6e=="function"){
_6e();
}
_4(_2("cont-search"),"click",function(e){
var _74=8;
var _75=this.board.getRegion(0,20-_74,_74,_74);
var _76=this.convertRegionPattern(_75);
this.loadSearch("ne",_74+"x"+_74,this.compressPattern(_76));
_7(e);
}.bind(this));
}.bind(this);
var url=this.progressiveUrl+"?"+eidogo.util.makeQueryString({id:_70,pid:this.uniq});
this.remoteLoad(url,_6f,false,null,_71);
}
},fetchProgressiveContinuations:function(_78){
this.nowLoading();
this.progressiveLoads++;
var _79=this.cursor.getMoveNumber();
var _7a=(_79>1?11:7);
var _7b=20-_7a-1;
var _7c=this.board?this.convertRegionPattern(this.board.getRegion(0,_7b+1,_7a,_7a)):".................................................";
var _7d={q:"ne",w:_7a,h:_7a,p:_7c,a:"continuations",t:(new Date()).getTime()};
var _7e=function(req){
this.croak(t["error retrieving"]);
};
var _80=function(req){
if(!req.responseText||req.responseText=="NONE"){
this.progressiveLoads--;
this.doneLoading();
this.cursor.node._cached=true;
this.refresh();
return;
}
var _82={LB:[],_children:[]},_83;
_82.C=_79>1?"<a id='cont-search' href='#'>"+t["show games"]+"</a>":"";
var _84,_85=eval("("+req.responseText+")");
if(_85.length){
_85.sort(function(a,b){
return parseInt(b.count,10)-parseInt(a.count,10);
});
var _88=parseInt(_85[0].count,10);
var x,y,_8b,_8c;
_82.C+="<div class='continuations'>";
for(var i=0;_84=_85[i];i++){
_8c=parseInt(_84.count/_88*150);
if(_88>20&&parseInt(_84.count,10)<10){
continue;
}
_83={};
x=_7b+parseInt(_84.x,10)+1;
y=parseInt(_84.y,10);
_8b=this.pointToSgfCoord({x:x,y:y});
_83[this.currentColor||"B"]=_8b;
_82.LB.push(_8b+":"+_84.label);
if(_8c){
_82.C+="<div class='continuation'>"+"<div class='cont-label'>"+_84.label+"</div>"+"<div class='cont-bar' style='width: "+_8c+"px'></div>"+"<div class='cont-count'>"+_84.count+"</div>"+"</div>";
}
_82._children.push(_83);
}
_82.C+="</div>";
if(!this.cursor.node){
_82={_children:[_82]};
}
}
this.load(_82,this.cursor.node);
_4(_2("cont-search"),"click",function(e){
this.loadSearch("ne",_7a+"x"+_7a,this.compressPattern(_7c));
_7(e);
}.bind(this));
if(_78&&typeof _78=="function"){
_78();
}
}.bind(this);
_3("get",this.progressiveUrl,_7d,_80,_7e,this,45000);
},findVariations:function(){
this.variations=this.getVariations();
},getVariations:function(){
var _8f=[],_90=this.cursor.node._children;
for(var i=0;i<_90.length;i++){
_8f.push({move:_90[i].getMove(),varNum:i});
}
return _8f;
},back:function(e,obj,_94){
if(this.cursor.previous()){
this.board.revert(1);
this.problemSolution=0;
this.goingBack=true;
this.refresh(_94);
this.resetLastLabels();
}
},forward:function(e,obj,_97){
this.variation(null,_97);
},first:function(){
if(!this.cursor.hasPrevious()){
return;
}
this.problemSolution=0;
this.resetCursor(false,true);
},last:function(){
if(!this.cursor.hasNext()){
return;
}
while(this.variation(null,true)){
}
this.refresh();
},stopp:function(){
var _98=0;
if(this.mode=="play"){
this.selectTool("playstop");
this.board.clearCurrStops();
_98=1;
}else{
if(this.mode.substr(0,8)=="playstop"){
this.selectTool("play");
this.board.finishCurrStop();
var _99=this.board.getCurrStop();
if(_99!=""){
var _9a=this.cursor.getNextMoves();
if(_9a&&_99 in _9a){
this.variation(_9a[_99]);
}else{
this.createMove(_99);
}
}
this.board.clearCurrStops();
_98=1;
}
}
if(_98){
this.updateControls();
}
},handleBoardMouseDown:function(x,y,cx,cy,e){
if(this.domLoading){
return;
}
if(!this.boundsCheck(x,y,[0,this.board.boardSize-1])){
return;
}
this.mouseDown=true;
this.mouseDownX=x;
this.mouseDownY=y;
this.mouseDownClickX=cx;
this.mouseDownClickY=cy;
if(this.mode=="region"&&x>=0&&y>=0&&!this.regionBegun){
this.regionTop=y;
this.regionLeft=x;
this.regionBegun=true;
}
},handleBoardHover:function(x,y,cx,cy,e){
if(this.domLoading){
return;
}
if(this.mouseDown||this.regionBegun){
if(!this.boundsCheck(x,y,[0,this.board.boardSize-1])){
return;
}
var _a5=(x!=this.mouseDownX||y!=this.mouseDownY);
var _a6=Math.abs(this.mouseDownClickX-cx)>=19||Math.abs(this.mouseDownClickY-cy)>=19;
if(this.searchUrl&&!this.regionBegun&&_a5&&_a6){
this.selectTool("region");
this.regionBegun=true;
this.regionTop=this.mouseDownY;
this.regionLeft=this.mouseDownX;
}
if(this.regionBegun){
this.regionRight=x+(x>=this.regionLeft?1:0);
this.regionBottom=y+(y>=this.regionTop?1:0);
this.showRegion();
}
_7(e);
}
},handleBoardMouseUp:function(x,y,e){
if(this.domLoading){
return;
}
this.mouseDown=false;
var _aa=this.pointToSgfCoord({x:x,y:y});
if(this.mode=="view"||this.mode=="play"){
for(var i=0;i<this.variations.length;i++){
if(this.variations[i].move.length>2){
if(this.mode=="play"&&!this.problemMode){
continue;
}
}
var _ac=this.sgfCoordToPoint(this.variations[i].move);
if(_ac.x==x&&_ac.y==y){
this.variation(this.variations[i].varNum);
_7(e);
return;
}
}
}
if(this.mode=="view"){
var _ad=this.cursor.getGameRoot(),_ae=[0,_ad.getPosition()],mn=0,_b0=_ad._children[0];
while(_b0){
if(_b0.getMove().substr(0,2)==_aa){
_ae.push(mn);
this.goTo(_ae);
break;
}
mn++;
_b0=_b0._children[0];
}
return;
}
if(this.mode.substr(0,4)=="play"){
if((this.mode=="play"||(this.mode=="playstop"&&this.board.getCurrStop()==""))&&!this.rules.check({x:x,y:y},this.currentColor)){
return;
}
if(this.mode=="play"){
if(_aa){
var _b1=this.cursor.getNextMoves();
if(_b1&&_aa in _b1){
this.variation(_b1[_aa]);
}else{
this.createMove(_aa);
}
}
}else{
this.board.addCurrStop(x,y,this.currentColor);
this.board.render();
}
}else{
if(this.mode=="region"&&x>=-1&&y>=-1&&this.regionBegun){
if(this.regionTop==y&&this.regionLeft==x&&!this.regionClickSelect){
this.regionClickSelect=true;
this.regionRight=x+1;
this.regionBottom=y+1;
this.showRegion();
}else{
this.regionBegun=false;
this.regionClickSelect=false;
this.regionBottom=(y<0?0:(y>=this.board.boardSize)?y:y+(y>this.regionTop?1:0));
this.regionRight=(x<0?0:(x>=this.board.boardSize)?x:x+(x>this.regionLeft?1:0));
this.showRegion();
_a(this.dom.searchButton,"inline");
_7(e);
}
}else{
var _b2;
var _b3=this.board.getStone({x:x,y:y});
if(this.mode=="add_b"||this.mode=="add_w"){
var _b4=this.cursor.node.emptyPoint(this.pointToSgfCoord({x:x,y:y}));
if(_b3!=this.board.BLACK&&this.mode=="add_b"){
_b2="AB";
}else{
if(_b3!=this.board.WHITE&&this.mode=="add_w"){
_b2="AW";
}else{
if(this.board.getStone({x:x,y:y})!=this.board.EMPTY&&!_b4){
_b2="AE";
}
}
}
}else{
switch(this.mode){
case "tr":
_b2="TR";
break;
case "sq":
_b2="SQ";
break;
case "cr":
_b2="CR";
break;
case "x":
_b2="MA";
break;
case "dim":
_b2="DD";
break;
case "number":
_b2="LB";
_aa=_aa+":"+this.labelLastNumber;
this.labelLastNumber++;
break;
case "letter":
_b2="LB";
_aa=_aa+":"+this.labelLastLetter;
this.labelLastLetter=String.fromCharCode(this.labelLastLetter.charCodeAt(0)+1);
break;
case "label":
_b2="LB";
_aa=_aa+":"+this.dom.labelInput.value;
break;
case "clear":
this.cursor.node.deletePropertyValue(["TR","SQ","CR","MA","DD","LB"],new RegExp("^"+_aa));
break;
}
if(this.cursor.node.hasPropertyValue(_b2,_aa)){
this.cursor.node.deletePropertyValue(_b2,_aa);
_b2=null;
}
}
if(_b2){
this.cursor.node.pushProperty(_b2,_aa);
}
this.unsavedChanges=true;
var _b4=this.checkForEmptyNode(true);
this.refresh();
if(_b4){
this.prependComment(t["position deleted"]);
}
}
}
},checkForEmptyNode:function(_b5){
if(!eidogo.util.numProperties(this.cursor.node.getProperties())){
var _b6=_b5?window.confirm(t["confirm delete"]):true;
if(_b6){
var id=this.cursor.node._id;
var _b8=0;
this.back();
this.cursor.node._children=this.cursor.node._children.filter(function(_b9,i){
if(_b9._id==id){
_b8=i;
return false;
}else{
return true;
}
});
if(_b8&&this.cursor.node._preferredChild==_b8){
this.cursor.node._preferredChild--;
}
return true;
}
}
return false;
},handleDocMouseUp:function(evt){
if(this.domLoading){
return true;
}
if(this.mode=="region"&&this.regionBegun&&!this.regionClickSelect){
this.mouseDown=false;
this.regionBegun=false;
_a(this.dom.searchButton,"inline");
}
return true;
},boundsCheck:function(x,y,_be){
if(_be.length==2){
_be[3]=_be[2]=_be[1];
_be[1]=_be[0];
}
return (x>=_be[0]&&y>=_be[1]&&x<=_be[2]&&y<=_be[3]);
},getRegionBounds:function(){
var l=this.regionLeft;
var w=this.regionRight-this.regionLeft;
if(w<0){
l=this.regionRight;
w=-w+1;
}
var t=this.regionTop;
var h=this.regionBottom-this.regionTop;
if(h<0){
t=this.regionBottom;
h=-h+1;
}
return [t,l,w,h];
},showRegion:function(){
var _c3=this.getRegionBounds();
this.board.renderer.showRegion(_c3);
},hideRegion:function(){
this.board.renderer.hideRegion();
},convertRegionPattern:function(_c4){
return _c4.join("").replace(new RegExp(this.board.EMPTY,"g"),".").replace(new RegExp(this.board.BLACK,"g"),"x").replace(new RegExp(this.board.WHITE,"g"),"o");
},loadSearch:function(q,dim,p,a,o){
var _ca={_children:[{SZ:this.board.boardSize,_children:[]}]};
this.load(_ca);
a=a||"corner";
this.dom.searchAlgo.value=a;
p=this.uncompressPattern(p);
dim=dim.split("x");
var w=dim[0];
var h=dim[1];
var bs=this.board.boardSize;
var l;
var t;
switch(q){
case "nw":
l=0;
t=0;
break;
case "ne":
l=bs-w;
t=0;
break;
case "se":
l=bs-w;
t=bs-h;
break;
case "sw":
l=0;
t=bs-h;
break;
}
var c;
var x;
var y;
for(y=0;y<h;y++){
for(x=0;x<w;x++){
c=p.charAt(y*w+x);
if(c=="o"){
c="AW";
}else{
if(c=="x"){
c="AB";
}else{
c="";
}
}
this.cursor.node.pushProperty(c,this.pointToSgfCoord({x:l+x,y:t+y}));
}
}
this.refresh();
this.regionLeft=l;
this.regionTop=t;
this.regionRight=l+x;
this.regionBottom=t+y;
var b=this.getRegionBounds();
var r=[b[1],b[0],b[1]+b[2],b[0]+b[3]-1];
for(y=0;y<this.board.boardSize;y++){
for(x=0;x<this.board.boardSize;x++){
if(!this.boundsCheck(x,y,r)){
this.board.renderer.renderMarker({x:x,y:y},"dim");
}
}
}
this.searchRegion(o);
},searchRegion:function(_d5){
if(this.searching){
return;
}
this.searching=true;
if(!this.searchUrl){
_a(this.dom.comments);
_b(this.dom.searchContainer);
this.prependComment(t["no search url"]);
return;
}
var _d5=parseInt(_d5,10)||0;
var _d6=this.dom.searchAlgo.value;
var _d7=this.getRegionBounds();
var _d8=this.board.getRegion(_d7[0],_d7[1],_d7[2],_d7[3]);
var _d9=this.convertRegionPattern(_d8);
var _da=/^\.*$/.test(_d9);
var _db=/^\.*o\.*$/.test(_d9);
var _dc=/^\.*x\.*$/.test(_d9);
if(_da||_db||_dc){
this.searching=false;
_a(this.dom.comments);
_b(this.dom.searchContainer);
this.prependComment(t["two stones"]);
return;
}
var _dd=[];
if(_d7[0]==0){
_dd.push("n");
}
if(_d7[1]==0){
_dd.push("w");
}
if(_d7[0]+_d7[3]==this.board.boardSize){
_dd.push("s");
}
if(_d7[1]+_d7[2]==this.board.boardSize){
_dd.push("e");
}
if(_d6=="corner"&&!(_dd.length==2&&((_dd.contains("n")&&_dd.contains("e"))||(_dd.contains("n")&&_dd.contains("w"))||(_dd.contains("s")&&_dd.contains("e"))||(_dd.contains("s")&&_dd.contains("w"))))){
this.searching=false;
_a(this.dom.comments);
_b(this.dom.searchContainer);
this.prependComment(t["two edges"]);
return;
}
var _de=(_dd.contains("n")?"n":"s");
_de+=(_dd.contains("w")?"w":"e");
this.showComments("");
this.gameName="search";
var _df=function(req){
this.searching=false;
this.doneLoading();
_b(this.dom.comments);
_a(this.dom.searchContainer);
this.showingSearch=true;
if(req.responseText=="ERROR"){
this.croak(t["error retrieving"]);
return;
}else{
if(req.responseText=="NONE"){
_b(this.dom.searchResultsContainer);
this.dom.searchCount.innerHTML="No";
return;
}
}
var ret=eval("("+req.responseText+")");
var _e2=ret.results,_e3,_e4="",odd,_e6=parseInt(ret.total,10),_e7=parseInt(ret.offset,10)+1,_e8=parseInt(ret.offset,10)+50;
for(var i=0;_e3=_e2[i];i++){
odd=odd?false:true;
_e4+="<a class='search-result"+(odd?" odd":"")+"' href='#'>                    <span class='id'>"+_e3.id+"</span>                    <span class='mv'>"+_e3.mv+"</span>                    <span class='pw'>"+_e3.pw+" "+_e3.wr+"</span>                    <span class='pb'>"+_e3.pb+" "+_e3.br+"</span>                    <span class='re'>"+_e3.re+"</span>                    <span class='dt'>"+_e3.dt+"</span>                    <div class='clear'>&nbsp;</div>                    </a>";
}
if(_e6>_e8){
_e4+="<div class='search-more'><a href='#' id='search-more'>Show more...</a></div>";
}
_a(this.dom.searchResultsContainer);
this.dom.searchResults.innerHTML=_e4+"<br>";
this.dom.searchCount.innerHTML=_e6;
this.dom.searchOffsetStart.innerHTML=_e7;
this.dom.searchOffsetEnd.innerHTML=(_e6<_e8?_e6:_e8);
this.dom.searchContainer.scrollTop=0;
if(_e6>_e8){
setTimeout(function(){
_4(_2("search-more"),"click",function(e){
this.loadSearch(_de,_d7[2]+"x"+_d7[3],_d9,"corner",ret.offset+51);
_7(e);
}.bind(this));
}.bind(this),0);
}
};
var _eb=function(req){
this.croak(t["error retrieving"]);
};
var _ed={q:_de,w:_d7[2],h:_d7[3],p:_d9,a:_d6,o:_d5,t:(new Date()).getTime()};
this.progressiveLoad=false;
this.progressiveUrl=null;
this.prefs.markNext=false;
this.prefs.showPlayerInfo=true;
this.hook("searchRegion",_ed);
this.nowLoading();
_3("get",this.searchUrl,_ed,_df,_eb,this,45000);
},loadSearchResult:function(e){
this.nowLoading();
var _ef=e.target||e.srcElement;
if(_ef.nodeName=="SPAN"){
_ef=_ef.parentNode;
}
if(_ef.nodeName=="A"){
var _f0;
var id;
var mv;
for(var i=0;_f0=_ef.childNodes[i];i++){
if(_f0.className=="id"){
id=_f0.innerHTML;
}
if(_f0.className=="mv"){
mv=parseInt(_f0.innerHTML,10);
}
}
}
this.remoteLoad(id,null,true,[0,mv],function(){
this.doneLoading();
this.setPermalink();
this.prefs.showOptions=true;
this.handleDisplayPrefs();
}.bind(this));
_7(e);
},closeSearch:function(){
this.showingSearch=false;
_b(this.dom.searchContainer);
_a(this.dom.comments);
},compressPattern:function(_f4){
var c=null;
var pc="";
var n=1;
var ret="";
for(var i=0;i<_f4.length;i++){
c=_f4.charAt(i);
if(c==pc){
n++;
}else{
ret=ret+pc+(n>1?n:"");
n=1;
pc=c;
}
}
ret=ret+pc+(n>1?n:"");
return ret;
},uncompressPattern:function(_fa){
var c=null;
var s=null;
var n="";
var ret="";
for(var i=0;i<_fa.length;i++){
c=_fa.charAt(i);
if(c=="."||c=="x"||c=="o"){
if(s!=null){
n=parseInt(n,10);
n=isNaN(n)?1:n;
for(var j=0;j<n;j++){
ret+=s;
}
n="";
}
s=c;
}else{
n+=c;
}
}
n=parseInt(n,10);
n=isNaN(n)?1:n;
for(var j=0;j<n;j++){
ret+=s;
}
return ret;
},createMove:function(_101){
var _102={};
_102[this.currentColor]=_101;
var _103=new eidogo.GameNode(null,_102);
_103._cached=true;
this.totalMoves++;
this.cursor.node.appendChild(_103);
this.unsavedChanges=[this.cursor.node._children.last(),this.cursor.node];
this.updatedNavTree=false;
this.variation(this.cursor.node._children.length-1);
},handleKeypress:function(e){
if(this.editingText){
return true;
}
var _105=e.keyCode||e.charCode;
if(!_105||e.ctrlKey||e.altKey||e.metaKey){
return true;
}
var _106=String.fromCharCode(_105).toLowerCase();
var _107=[];
for(var i=0;i<this.variations.length;i++){
var _109=this.variations[i].move;
var _10a=this.sgfCoordToPoint(_109);
var _10b=""+(i+1);
var _10c=this.board.getMarker(_10a);
if(_10a.x!=null&&_10c!=this.board.EMPTY&&typeof _10c=="string"&&!_107.contains(_109)){
_10b=_10c.toLowerCase();
}
_10b=_10b.replace(/^var.:/,"");
if(_106==_10b.charAt(0)){
this.variation(this.variations[i].varNum);
_7(e);
return;
}
_107.push(_109);
}
if(_105==112||_105==27){
this.selectTool("play");
}
var stop=true;
switch(_105){
case 39:
if(e.shiftKey){
var _10e=this.totalMoves-this.moveNumber;
var _10f=(_10e>9?9:_10e-1);
for(var i=0;i<_10f;i++){
this.forward(null,null,true);
}
}
this.forward();
break;
case 37:
if(e.shiftKey){
var _10f=(this.moveNumber>9?9:this.moveNumber-1);
for(var i=0;i<_10f;i++){
this.back(null,null,true);
}
}
this.back();
break;
case 40:
this.last();
break;
case 38:
this.first();
break;
default:
stop=false;
break;
}
if(stop){
_7(e);
}
},showGameInfo:function(_110){
this.hook("showGameInfo",_110);
if(!_110){
return;
}
this.dom.infoGame.innerHTML="";
this.dom.whiteName.innerHTML="";
this.dom.blackName.innerHTML="";
var dl=document.createElement("dl"),val;
for(var _113 in this.infoLabels){
if(_110[_113] instanceof Array){
_110[_113]=_110[_113][0];
}
if(_110[_113]){
if(_113=="PW"){
this.dom.whiteName.innerHTML=_110[_113]+(_110["WR"]?", "+_110["WR"]:"");
continue;
}else{
if(_113=="PB"){
this.dom.blackName.innerHTML=_110[_113]+(_110["BR"]?", "+_110["BR"]:"");
continue;
}
}
if(_113=="WR"||_113=="BR"){
continue;
}
val=_110[_113];
if(_113=="DT"){
var _114=_110[_113].split(/[\.-]/);
if(_114.length==3){
var _115=_114[2].split(" ");
val=_115[0].replace(/^0+/,"")+" "+this.months[_114[1]-1]+" "+_114[0];
if(_115.length>1){
val+=", ";
for(var i=1;i<_115.length;i++){
val+=" "+_115[i];
}
}
}
}
var dt=document.createElement("dt");
dt.innerHTML=this.infoLabels[_113]+":";
var dd=document.createElement("dd");
dd.innerHTML=val;
dl.appendChild(dt);
dl.appendChild(dd);
}
}
this.dom.whiteName.innerHTML+=" (W)";
this.dom.blackName.innerHTML+=" (B)";
this.dom.infoGame.appendChild(dl);
},selectTool:function(tool){
var _11a;
_b(this.dom.scoreEst);
_b(this.dom.labelInput);
if(tool=="region"){
_11a="crosshair";
}else{
if(tool=="comment"){
this.startEditComment();
}else{
if(tool=="gameinfo"){
this.startEditGameInfo();
}else{
if(tool=="label"){
_a(this.dom.labelInput,"inline");
this.dom.labelInput.focus();
}else{
if(tool=="delete"){
this.deleteSubtree();
}else{
if(tool=="result"){
this.showResult();
}else{
_11a="default";
this.regionBegun=false;
this.hideRegion();
_b(this.dom.searchButton);
_b(this.dom.searchAlgo);
if(this.searchUrl){
_a(this.dom.scoreEst,"inline");
}
}
}
}
}
}
}
this.board.renderer.setCursor(_11a);
this.mode=tool;
this.dom.toolsSelect.value=tool;
},deleteSubtree:function(){
var _11b=window.confirm(t["confirm delete subtree"]);
if(_11b){
this.cursor.node.deleteAllProperties();
this.unsavedChanges=true;
this.selectTool("play");
var _11c=this.checkForEmptyNode(false);
this.refresh();
if(_11c){
this.prependComment(t["position deleted"]);
this.updatedNavTree=false;
this.updateControls();
}
}else{
this.selectTool("play");
this.refresh();
}
},getStandResult:function(){
this.setRules();
var _11d;
var _11e=this.cursor.node;
while(_11e!=null&&_11e.getMove()==null){
_11e=_11e._parent;
}
if(_11e==null){
var root=this.cursor.getGameRoot();
if(root&&root.HA>1){
_11d=this.board.WHITE;
}else{
_11d=this.board.BLACK;
}
}else{
var _120=_11e.getProperties();
if("B" in _120){
_11d=this.board.WHITE;
}else{
_11d=this.board.BLACK;
}
}
var _121=this.board.whoMakesLastMove(_11d);
return this.board.getGameResult(0,_121);
},showResult:function(){
this.setRules();
var _122;
var _123=this.cursor.node;
while(_123!=null&&_123.getMove()==null){
_123=_123._parent;
}
if(_123==null){
var root=this.cursor.getGameRoot();
if(root&&root.HA>1){
_122=this.board.WHITE;
}else{
_122=this.board.BLACK;
}
}else{
var _125=_123.getProperties();
if("B" in _125){
_122=this.board.WHITE;
}else{
_122=this.board.BLACK;
}
}
var _126=this.board.whoMakesLastMove(_122);
var _127=this.board.getGameResult(0,_126);
var _128=this.board.getGameResult(1,_126);
window.alert(t["ruleset"]+": "+(this.rules.getPunish()?t["rules-punish"]:t["rules-standard"])+"\n"+t["now plays"]+(_122==this.board.BLACK?"B":"W")+"\n"+t["last move makes"]+(_126==this.board.BLACK?"B":"W")+"\n"+"\n"+t["B dots"]+this.board.captures.B+"\n"+t["B terr"]+this.board.captures.Bterr+"\n"+t["W dots"]+this.board.captures.W+"\n"+t["W terr"]+this.board.captures.Wterr+"\n"+"\n"+t["szkrab result"]+"W:"+_127.W+", B:"+_127.B+"\n"+t["pass result"]+"W:"+_128.W+", B:"+_128.B+"\n");
this.selectTool("play");
this.refresh();
},startEditComment:function(){
this.closeSearch();
var div=this.dom.commentsEdit;
div.style.position="absolute";
div.style.top=this.dom.comments.offsetTop+"px";
div.style.left=this.dom.comments.offsetLeft+"px";
_a(this.dom.shade);
this.dom.comments.innerHTML="";
_a(div);
_a(this.dom.commentsEditDone);
this.dom.commentsEditTa.value=this.cursor.node.C||"";
this.dom.commentsEditTa.focus();
this.editingText=true;
},finishEditComment:function(){
this.editingText=false;
var oldC=this.cursor.node.C;
var newC=this.dom.commentsEditTa.value;
if(oldC!=newC){
this.unsavedChanges=true;
this.cursor.node.C=newC;
}
if(!this.cursor.node.C){
delete this.cursor.node.C;
}
_b(this.dom.shade);
_b(this.dom.commentsEdit);
_a(this.dom.comments);
this.selectTool("play");
var _12c=this.checkForEmptyNode(true);
this.refresh();
if(_12c){
this.prependComment(t["position deleted"]);
}
},startEditGameInfo:function(){
this.closeSearch();
var div=this.dom.gameInfoEdit;
div.style.position="absolute";
div.style.top=this.dom.comments.offsetTop+"px";
div.style.left=this.dom.comments.offsetLeft+"px";
_a(this.dom.shade);
this.dom.comments.innerHTML="";
_a(div);
_a(this.dom.gameInfoEditDone);
var root=this.cursor.getGameRoot();
var html=["<table>"];
for(var prop in this.infoLabels){
html.push("<tr><td>"+this.infoLabels[prop]+":"+"</td><td>"+"<input type=\"text\" id=\"game-info-edit-field-"+prop+"\""+" value=\""+(root[prop]||"")+"\">"+"</td></tr>");
}
html.push("</table>");
this.dom.gameInfoEditForm.innerHTML=html.join("");
setTimeout(function(){
_2("game-info-edit-field-GN").focus();
},0);
this.editingText=true;
},finishEditGameInfo:function(){
this.editingText=false;
_b(this.dom.shade);
_b(this.dom.gameInfoEdit);
_a(this.dom.comments);
var root=this.cursor.getGameRoot();
var _132=null;
for(var prop in this.infoLabels){
_132=_2("game-info-edit-field-"+prop).value;
if((root[prop]||"")!=_132){
root[prop]=_132;
this.unsavedChanges=true;
}
}
this.showGameInfo(root);
this.dom.gameInfoEditForm.innerHTML="";
this.selectTool("play");
this.refresh();
},updateControls:function(){
this.dom.moveNumber.innerHTML=(this.moveNumber?(t["move"]+" "+this.moveNumber):(this.permalinkable?"permalink":""));
if(this.board.captures.Wterr==0&&this.board.captures.Bterr==0){
this.dom.whiteCaptures.innerHTML=t["captures"]+": <span>"+this.board.captures.W+"</span>";
this.dom.blackCaptures.innerHTML=t["captures"]+": <span>"+this.board.captures.B+"</span>";
}else{
var _134=this.getStandResult();
this.dom.whiteCaptures.innerHTML=t["captures"]+": <span>"+_134.W+"</span>";
this.dom.blackCaptures.innerHTML=t["captures"]+": <span>"+_134.B+"</span>";
}
this.dom.whiteTime.innerHTML=t["time left"]+": <span>"+(this.timeW?this.timeW:"--")+"</span>";
this.dom.blackTime.innerHTML=t["time left"]+": <span>"+(this.timeB?this.timeB:"--")+"</span>";
_9(this.dom.controlStopp,"stopp-on");
if(this.mode.substr(0,8)=="playstop"){
_8(this.dom.controlStopp,"stopp-on");
}
this.dom.variations.innerHTML="";
for(var i=0;i<this.variations.length;i++){
var _136=i+1;
var _137=false;
if(this.prefs.markNext||this.variations.length>1){
var _138=this.sgfCoordToPoint(this.variations[i].move);
if(this.board.getMarker(_138)!=this.board.EMPTY){
var _139=this.board.getMarker(_138);
if(_139.indexOf("varB:")!==0&&_139.indexOf("varW:")!==0){
_136=_139;
}else{
_137=true;
}
}
if(this.prefs.markVariations&&!_137){
this.board.addMarker(_138,"var"+this.currentColor+":"+_136);
}
}
var _13a=document.createElement("div");
_13a.className="variation-nav";
_13a.innerHTML=_136;
_4(_13a,"click",function(e,arg){
arg.me.variation(arg.varNum);
},{me:this,varNum:this.variations[i].varNum});
this.dom.variations.appendChild(_13a);
}
if(this.variations.length<2){
this.dom.variations.innerHTML="<div class='variation-nav none'>"+t["no variations"]+"</div>";
}
if(this.cursor.hasNext()){
_8(this.dom.controlForward,"forward-on");
_8(this.dom.controlLast,"last-on");
}else{
_9(this.dom.controlForward,"forward-on");
_9(this.dom.controlLast,"last-on");
}
if(this.cursor.hasPrevious()){
_8(this.dom.controlBack,"back-on");
_8(this.dom.controlFirst,"first-on");
}else{
_9(this.dom.controlBack,"back-on");
_9(this.dom.controlFirst,"first-on");
var info="";
if(!this.prefs.showPlayerInfo){
info+=this.getGameDescription(true);
}
if(!this.prefs.showGameInfo){
info+=this.dom.infoGame.innerHTML;
}
if(info.length&&this.theme!="problem"){
this.prependComment(info,"comment-info");
}
}
if(!this.progressiveLoad){
this.updateNavSlider();
}
if(this.prefs.showNavTree){
this.updateNavTree();
}
var node=this.cursor.node,pos,html,js;
if(node._parent&&!node._parent._parent&&node._parent._children.length>1){
pos=node.getPosition();
html=t["multi-game sgf"];
js="javascript:eidogo.delegate("+this.uniq+", \"goTo\", [";
if(pos){
html+="<a href='"+js+(pos-1)+",0])'>"+t["previous game"]+"</a>";
}
if(node._parent._children[pos+1]){
html+=(pos?" | ":"")+"<a href='"+js+(pos+1)+",0])'>"+t["next game"]+"</a>";
}
this.prependComment(html,"comment-info");
}
},setColor:function(_142){
this.prependComment(_142=="B"?t["black to play"]:t["white to play"]);
this.currentColor=this.problemColor=_142;
},setMoveNumber:function(num){
this.moveNumber=num;
},setRules:function(){
var _144=this.cursor.getGameRoot();
this.rules.setPunish(_144.hasPropertyValue("RU","PUNISH"));
this.rules.setRussian(_144.hasPropertyValue("RU","russian"));
},playMove:function(_145,_146,_147){
this.setRules();
_146=_146||this.currentColor;
this.currentColor=(_146=="B"?"W":"B");
_146=_146=="W"?this.board.WHITE:this.board.BLACK;
var pt=this.sgfCoordToPoint(_145);
if((!_145||_145=="")&&!_147){
this.prependComment((_146==this.board.WHITE?t["white"]:t["black"])+" "+t["passed"],"comment-pass");
}else{
if(_145=="resign"){
this.prependComment((_146==this.board.WHITE?t["white"]:t["black"])+" "+t["resigned"],"comment-resign");
}else{
if(_145){
if(_145.charAt(0)!="."){
this.board.addStone(pt,_146);
}
var st=_145.indexOf(".");
if(st>=0){
this.board.addStop(_145.substring(st),this.rules.getPunish());
}
this.rules.apply(pt,_146);
if(this.prefs.markCurrent&&!_147){
this.addMarker(_145,"current");
}
}
}
}
},addTerritory:function(_14a,_14b){
if(!_14a||_14a==""){
return;
}
this.setRules();
var st=_14a.indexOf(".");
if(st>=0){
this.board.addTerritory(_14a.substring(st),this.rules.getPunish());
}
},addStone:function(_14d,_14e){
if(!(_14d instanceof Array)){
_14d=[_14d];
}
_14d=this.expandCompressedPoints(_14d);
for(var i=0;i<_14d.length;i++){
this.board.addStone(this.sgfCoordToPoint(_14d[i]),_14e=="AW"?this.board.WHITE:_14e=="AB"?this.board.BLACK:this.board.EMPTY);
}
},addMarker:function(_150,type){
if(!(_150 instanceof Array)){
_150=[_150];
}
_150=this.expandCompressedPoints(_150);
var _152;
for(var i=0;i<_150.length;i++){
switch(type){
case "TR":
_152="triangle";
break;
case "SQ":
_152="square";
break;
case "CR":
_152="circle";
break;
case "MA":
_152="ex";
break;
case "TW":
_152="territory-white";
break;
case "TB":
_152="territory-black";
break;
case "DD":
_152="dim";
break;
case "LB":
_152=(_150[i].split(":"))[1];
break;
default:
_152=type;
break;
}
this.board.addMarker(this.sgfCoordToPoint((_150[i].split(":"))[0]),_152);
}
},showTime:function(_154,type){
var tp=(type=="BL"||type=="OB"?"timeB":"timeW");
if(type=="BL"||type=="WL"){
var mins=Math.floor(_154/60);
var secs=(_154%60).toFixed(0);
secs=(secs<10?"0":"")+secs;
this[tp]=mins+":"+secs;
}else{
this[tp]+=" ("+_154+")";
}
},showAnnotation:function(_159,type){
var msg;
switch(type){
case "N":
msg=_159;
break;
case "GB":
msg=(_159>1?t["vgb"]:t["gb"]);
break;
case "GW":
msg=(_159>1?t["vgw"]:t["gw"]);
break;
case "DM":
msg=(_159>1?t["dmj"]:t["dm"]);
break;
case "UC":
msg=t["uc"];
break;
case "TE":
msg=t["te"];
break;
case "BM":
msg=(_159>1?t["vbm"]:t["bm"]);
break;
case "DO":
msg=t["do"];
break;
case "IT":
msg=t["it"];
break;
case "HO":
msg=t["ho"];
break;
}
this.prependComment(msg);
},showComments:function(_15c,junk,_15e){
if(!_15c||_15e){
return;
}
var com=_15c.replace(/^(\n|\r|\t|\s)+/,"").replace(/\n/g,"<br />");
if(com.length>=5&&com.substr(com.length-5)=="RIGHT"){
this.dom.comments.innerHTML+=com.substr(0,com.length-5);
this.problemSolution=1;
}else{
this.dom.comments.innerHTML+=com;
this.problemSolution=0;
}
},isSolution:function(){
return this.problemSolution;
},prependComment:function(_160,cls){
cls=cls||"comment-status";
this.dom.comments.innerHTML="<div class='"+cls+"'>"+_160+"</div>"+this.dom.comments.innerHTML;
},downloadSgf:function(evt){
_7(evt);
if(this.downloadUrl){
if(this.unsavedChanges){
alert(t["unsaved changes"]);
return;
}
location.href=this.downloadUrl+this.gameName;
}else{
if(_c){
location.href="data:text/plain,"+encodeURIComponent(this.cursor.getGameRoot().toSgf());
}
}
},save:function(evt){
_7(evt);
var _164=function(req){
this.hook("saved",[req.responseText]);
};
var _166=function(req){
this.croak(t["error retrieving"]);
};
var sgf=this.cursor.getGameRoot().toSgf();
_3("POST",this.saveUrl,{sgf:sgf},_164,_166,this,30000);
},constructDom:function(){
this.dom.player=document.createElement("div");
this.dom.player.className="eidogo-player"+(this.theme?" theme-"+this.theme:"");
this.dom.player.id="player-"+this.uniq;
this.dom.container.innerHTML="";
eidogo.util.show(this.dom.container);
this.dom.container.appendChild(this.dom.player);
var _169="            <div id='board-container' class='board-container'></div>            <div id='controls-container' class='controls-container'>                <ul id='controls' class='controls'>                    <li id='control-first' class='control first'>First</li>                    <li id='control-back' class='control back'>Back</li>                    <li id='control-forward' class='control forward'>Forward</li>                    <li id='control-last' class='control last'>Last</li>                    <li id='control-stopp' class='control stopp'>Stop</li>                </ul>                <div id='move-number' class='move-number"+(this.permalinkable?" permalink":"")+"'></div>                <div id='nav-slider' class='nav-slider'>                    <div id='nav-slider-thumb' class='nav-slider-thumb'></div>                </div>                <div id='variations-container' class='variations-container'>                    <div id='variations-label' class='variations-label'>"+t["variations"]+":</div>                    <div id='variations' class='variations'></div>                </div>                <div class='controls-stop'></div>            </div>            <div id='tools-container' class='tools-container'"+(this.prefs.showTools?"":" style='display: none'")+">                <div id='tools-label' class='tools-label'>"+t["tool"]+":</div>                <select id='tools-select' class='tools-select'>                    <option value='play'>&#9658; "+t["play"]+"</option>                    <option value='view'>&#8594; "+t["view"]+"</option>                    <option value='add_b'>&#9679; "+t["add_b"]+"</option>                    <option value='add_w'>&#9675; "+t["add_w"]+"</option>                    "+(this.searchUrl?("<option value='region'>&#9618; "+t["region"]+"</option>"):"")+"                    "+(this.saveUrl&&!this.progressiveLoad?("<option value='comment'>&para; "+t["edit comment"]+"</option>"):"")+"                    "+(this.saveUrl?("<option value='gameinfo'>&#8962; "+t["edit game info"]+"</option>"):"")+"                    <option value='tr'>&#9650; "+t["triangle"]+"</option>                    <option value='sq'>&#9632; "+t["square"]+"</option>                    <option value='cr'>&#9679; "+t["circle"]+"</option>                    <option value='x'>&times; "+t["x"]+"</option>                    <option value='letter'>A "+t["letter"]+"</option>                    <option value='number'>5 "+t["number"]+"</option>                    <option value='label'>&Ccedil; "+t["label"]+"</option>                    <option value='dim'>&#9619; "+t["dim"]+"</option>                    <option value='clear'>&#9617; "+t["clear"]+"</option>                    <option value='delete'>X "+t["delete"]+"</option>                    <option value='result'>? "+t["show result"]+"</option>                </select>                <input type='button' id='score-est' class='score-est-button' value='"+t["score est"]+"' />                <select id='search-algo' class='search-algo'>                    <option value='corner'>"+t["search corner"]+"</option>                    <option value='center'>"+t["search center"]+"</option>                </select>                <input type='button' id='search-button' class='search-button' value='"+t["search"]+"' />                <input type='text' id='label-input' class='label-input' />            </div>            <div id='comments' class='comments'></div>            <div id='comments-edit' class='comments-edit'>                <textarea id='comments-edit-ta' class='comments-edit-ta'></textarea>                <div id='comments-edit-done' class='comments-edit-done'>"+t["done"]+"</div>            </div>            <div id='game-info-edit' class='game-info-edit'>                <div id='game-info-edit-form' class='game-info-edit-form'></div>                <div id='game-info-edit-done' class='game-info-edit-done'>"+t["done"]+"</div>            </div>            <div id='search-container' class='search-container'>                <div id='search-close' class='search-close'>"+t["close search"]+"</div>                <p class='search-count'><span id='search-count'></span>&nbsp;"+t["matches found"]+"                    Showing <span id='search-offset-start'></span>-<span id='search-offset-end'></span></p>                <div id='search-results-container' class='search-results-container'>                    <div class='search-result'>                        <span class='pw'><b>"+t["white"]+"</b></span>                        <span class='pb'><b>"+t["black"]+"</b></span>                        <span class='re'><b>"+t["result"]+"</b></span>                        <span class='dt'><b>"+t["date"]+"</b></span>                        <div class='clear'></div>                    </div>                    <div id='search-results' class='search-results'></div>                </div>            </div>            <div id='info' class='info'>                <div id='info-players' class='players'>                    <div id='black' class='player black'>                        <div id='black-name' class='name' style=\"color:#aaaaff\"></div>                        <div id='black-captures' class='captures'></div>                        <div id='black-time' class='time'></div>                    </div>                    <div id='white' class='player white'>                        <div id='white-name' class='name' style=\"color:#ffaaaa\"></div>                        <div id='white-captures' class='captures'></div>                        <div id='white-time' class='time'></div>                    </div>                </div>                <div id='info-game' class='game'></div>            </div>            <div id='nav-tree-container' class='nav-tree-container'>                <div id='nav-tree' class='nav-tree'></div>            </div>            <div id='options' class='options'>                "+(this.saveUrl?"<a id='option-save' class='option-save' href='#'>"+t["save to server"]+"</a>":"")+"                "+(this.downloadUrl||_c?"<a id='option-download' class='option-download' href='#'>"+t["download sgf"]+"</a>":"")+"                <div class='options-stop'></div>            </div>            <div id='preferences' class='preferences'>                <div><input type='checkbox'> Show variations on board</div>                <div><input type='checkbox'> Mark current move</div>            </div>            <div id='footer' class='footer'></div>            <div id='shade' class='shade'></div>        ";
_169=_169.replace(/ id='([^']+)'/g," id='$1-"+this.uniq+"'");
this.dom.player.innerHTML=_169;
var re=/ id='([^']+)-\d+'/g;
var _16b;
var id;
var _16d;
while(_16b=re.exec(_169)){
id=_16b[0].replace(/'/g,"").replace(/ id=/,"");
_16d="";
_16b[1].split("-").forEach(function(word,i){
word=i?word.charAt(0).toUpperCase()+word.substring(1):word;
_16d+=word;
});
this.dom[_16d]=_2(id);
}
[["moveNumber","setPermalink"],["controlFirst","first"],["controlBack","back"],["controlForward","forward"],["controlLast","last"],["controlStopp","stopp"],["scoreEst","fetchScoreEstimate"],["searchButton","searchRegion"],["searchResults","loadSearchResult"],["searchClose","closeSearch"],["optionDownload","downloadSgf"],["optionSave","save"],["commentsEditDone","finishEditComment"],["gameInfoEditDone","finishEditGameInfo"],["navTree","navTreeClick"]].forEach(function(eh){
if(this.dom[eh[0]]){
_5(this.dom[eh[0]],this[eh[1]],this);
}
}.bind(this));
_4(this.dom.toolsSelect,"change",function(e){
this.selectTool.apply(this,[(e.target||e.srcElement).value]);
},this,true);
},enableNavSlider:function(){
if(this.progressiveLoad){
_b(this.dom.navSliderThumb);
return;
}
this.dom.navSlider.style.cursor="pointer";
var _172=false;
var _173=null;
_4(this.dom.navSlider,"mousedown",function(e){
_172=true;
_7(e);
},this,true);
_4(document,"mousemove",function(e){
if(!_172){
return;
}
var xy=_6(e,this.dom.navSlider);
clearTimeout(_173);
_173=setTimeout(function(){
this.updateNavSlider(xy[0]);
}.bind(this),10);
_7(e);
},this,true);
_4(document,"mouseup",function(e){
if(!_172){
return true;
}
_172=false;
var xy=_6(e,this.dom.navSlider);
this.updateNavSlider(xy[0]);
return true;
},this,true);
},updateNavSlider:function(_179){
var _17a=this.dom.navSlider.offsetWidth-this.dom.navSliderThumb.offsetHeight;
var _17b=this.totalMoves;
var _17c=!!_179;
_179=_179||(this.moveNumber/_17b*_17a);
_179=_179>_17a?_17a:_179;
_179=_179<0?0:_179;
var _17d=parseInt(_179/_17a*_17b,10);
if(_17c){
this.nowLoading();
var _17e=_17d-this.cursor.getMoveNumber();
for(var i=0;i<Math.abs(_17e);i++){
if(_17e>0){
this.variation(null,true);
}else{
if(_17e<0){
this.cursor.previous();
}
}
}
if(_17e<0){
this.board.revert(Math.abs(_17e));
}
this.doneLoading();
this.refresh();
}
_179=parseInt(_17d/_17b*_17a,10)||0;
this.dom.navSliderThumb.style.left=_179+"px";
},updateNavTree:function(_180){
if(!this.prefs.showNavTree){
return;
}
if(this.updatedNavTree){
this.showNavTreeCurrent();
return;
}
if(!_180){
if(this.navTreeTimeout){
clearTimeout(this.navTreeTimeout);
}
this.navTreeTimeout=setTimeout(function(){
this.updateNavTree(true);
}.bind(this),eidogo.browser.ie?1000:500);
return;
}
this.updatedNavTree=true;
var _181=[],_182=this.cursor.getGameRoot();
path=[_182.getPosition()],cur=new eidogo.GameCursor(),maxx=0;
var _184=function(node,_186,_187){
var y=_187,x=_186;
var n=node,_18b=1;
while(n&&n._children.length==1){
_18b++;
n=n._children[0];
}
while(_181[y]&&_181[y].slice(x,x+_18b+1).some(function(el){
return (typeof el!="undefined");
})){
y++;
}
do{
if(!_181[y]){
_181[y]=[];
}
cur.node=node;
node._pathStr=path.join("-")+"-"+(x-_186);
_181[y][x]=node;
if(x>maxx){
maxx=x;
}
x++;
if(node._children.length!=1){
break;
}
node=node._children[0];
}while(node);
for(var i=0;i<node._children.length;i++){
path.push(i);
_184(node._children[i],x,y);
path.pop();
}
};
_184(_182,0,0);
var html=["<table class='nav-tree'>"],node,td,cur=new eidogo.GameCursor(),x,y,_193,_194=1,LINE=2;
for(x=0;x<maxx;x++){
_193=false;
for(y=_181.length-1;y>0;y--){
if(!_181[y][x]){
if(typeof _181[y][x+1]=="object"){
_181[y][x]=_194;
_193=true;
}else{
if(_193){
_181[y][x]=LINE;
}
}
}else{
_193=false;
}
}
}
for(y=0;y<_181.length;y++){
html.push("<tr>");
for(x=0;x<_181[y].length;x++){
node=_181[y][x];
if(node==_194){
td="<div class='elbow'></div>";
}else{
if(node==LINE){
td="<div class='line'></div>";
}else{
if(node){
td=["<a href='#' id='navtree-node-",node._pathStr,"' class='",(typeof node.W!="undefined"?"w":(typeof node.B!="undefined"?"b":"x")),"'>",x,"</a>"].join("");
}else{
td="<div class='empty'></div>";
}
}
}
html.push("<td>");
html.push(td);
html.push("</td>");
}
html.push("</tr>");
}
html.push("</table>");
this.dom.navTree.innerHTML=html.join("");
setTimeout(function(){
this.showNavTreeCurrent();
}.bind(this),0);
},showNavTreeCurrent:function(){
var id="navtree-node-"+this.cursor.getPath().join("-"),_197=_2(id);
if(!_197){
return;
}
if(this.prevNavTreeCurrent){
this.prevNavTreeCurrent.className=this.prevNavTreeCurrentClass;
}
this.prevNavTreeCurrent=_197;
this.prevNavTreeCurrentClass=_197.className;
_197.className="current";
var w=_197.offsetWidth,h=_197.offsetHeight,xy=eidogo.util.getElXY(_197),_19b=eidogo.util.getElXY(this.dom.navTree),l=xy[0]-_19b[0],t=xy[1]-_19b[1],ntc=this.dom.navTreeContainer,maxl=ntc.scrollLeft,maxr=maxl+ntc.offsetWidth-100;
maxt=ntc.scrollTop,maxb=maxt+ntc.offsetHeight-30;
if(l<maxl){
ntc.scrollLeft-=(maxl-l);
}
if(l+w>maxr){
ntc.scrollLeft+=((l+w)-maxr);
}
if(t<maxt){
ntc.scrollTop-=(maxt-t);
}
if(t+h>maxb){
ntc.scrollTop+=((t+h)-maxb);
}
},navTreeClick:function(e){
var _1a1=e.target||e.srcElement;
if(!_1a1||!_1a1.id){
return;
}
var path=_1a1.id.replace(/^navtree-node-/,"").split("-");
this.goTo(path,true);
_7(e);
},resetLastLabels:function(){
this.labelLastNumber=1;
this.labelLastLetter="A";
},getGameDescription:function(_1a3){
var root=this.cursor.getGameRoot();
if(!root){
return;
}
var desc=(_1a3?"":root.GN||this.gameName);
if(root.PW&&root.PB){
var wr=root.WR?" "+root.WR:"";
var br=root.BR?" "+root.BR:"";
desc+=(desc.length?" - ":"")+root.PW+wr+" vs "+root.PB+br;
}
return desc;
},sgfCoordToPoint:function(_1a8){
if(!_1a8){
return {x:null,y:null};
}
var _1a9={a:0,b:1,c:2,d:3,e:4,f:5,g:6,h:7,i:8,j:9,k:10,l:11,m:12,n:13,o:14,p:15,q:16,r:17,s:18,t:19,u:20,v:21,w:22,x:23,y:24,z:25,A:26,B:27,C:28,D:29,E:30,F:31,G:32,H:33,I:34,J:35,K:36,L:37,M:38,N:39};
return {x:_1a9[_1a8.charAt(0)],y:_1a9[_1a8.charAt(1)]};
},pointToSgfCoord:function(pt){
if(!pt||pt.x<0||pt.y<0||(this.board&&(pt.x>=this.boardSize||pt.y>=this.boardSizeY))){
return null;
}
var pts={0:"a",1:"b",2:"c",3:"d",4:"e",5:"f",6:"g",7:"h",8:"i",9:"j",10:"k",11:"l",12:"m",13:"n",14:"o",15:"p",16:"q",17:"r",18:"s",19:"t",20:"u",21:"v",22:"w",23:"x",24:"y",25:"z",26:"A",27:"B",28:"C",29:"D",30:"E",31:"F",32:"G",33:"H",34:"I",35:"J",36:"K",37:"L",38:"M",39:"N"};
return pts[pt.x]+pts[pt.y];
},expandCompressedPoints:function(_1ac){
var _1ad;
var ul,lr;
var x,y;
var _1b2=[];
var hits=[];
for(var i=0;i<_1ac.length;i++){
_1ad=_1ac[i].split(/:/);
if(_1ad.length>1){
ul=this.sgfCoordToPoint(_1ad[0]);
lr=this.sgfCoordToPoint(_1ad[1]);
for(x=ul.x;x<=lr.x;x++){
for(y=ul.y;y<=lr.y;y++){
_1b2.push(this.pointToSgfCoord({x:x,y:y}));
}
}
hits.push(i);
}
}
_1ac=_1ac.concat(_1b2);
return _1ac;
},setPermalink:function(){
if(!this.permalinkable){
return true;
}
if(this.unsavedChanges){
alert(t["unsaved changes"]);
return;
}
this.hook("setPermalink");
},nowLoading:function(msg){
if(this.croaked||this.problemMode){
return;
}
msg=msg||t["loading"]+"...";
if(_2("eidogo-loading-"+this.uniq)){
return;
}
this.domLoading=document.createElement("div");
this.domLoading.id="eidogo-loading-"+this.uniq;
this.domLoading.className="eidogo-loading"+(this.theme?" theme-"+this.theme:"");
this.domLoading.innerHTML=msg;
this.dom.player.appendChild(this.domLoading);
},doneLoading:function(){
if(this.domLoading&&this.domLoading!=null&&this.domLoading.parentNode){
this.domLoading.parentNode.removeChild(this.domLoading);
this.domLoading=null;
}
},croak:function(msg){
this.doneLoading();
if(this.board){
alert(msg);
}else{
if(this.problemMode){
this.prependComment(msg);
}else{
this.dom.player.innerHTML+="<div class='eidogo-error "+(this.theme?" theme-"+this.theme:"")+"'>"+msg.replace(/\n/g,"<br />")+"</div>";
this.croaked=true;
}
}
}};
})();

(function(){
if(typeof eidogoPlayerCss=="undefined"){
eidogoPlayerCss="player.css";
}
var _1=window.eidogoConfig||{};
var _2={theme:"problem",problemMode:true,markVariations:false,markNext:false,shrinkToFit:true};
var _3=eidogo.util.getPlayerPath();
var _4=eidogo.playerPath=(_1.playerPath||_3||"player").replace(/\/$/,"");
if(!_1.skipCss){
eidogo.util.addStyleSheet(_4+"/css/"+eidogoPlayerCss);
if(eidogo.browser.ie&&parseInt(eidogo.browser.ver,10)<=6){
eidogo.util.addStyleSheet(_4+"/css/player-ie6.css");
}
}
eidogo.util.addEvent(window,"load",function(){
eidogo.autoPlayers=[];
var _5=[];
var _6=document.getElementsByTagName("div");
var _7=_6.length;
for(var i=0;i<_7;i++){
if(eidogo.util.hasClass(_6[i],"eidogo-player-auto")||eidogo.util.hasClass(_6[i],"eidogo-player-problem")){
_5.push(_6[i]);
}
}
var el;
for(var i=0;el=_5[i];i++){
var _a={container:el,enableShortcuts:false,theme:"compact"};
if(eidogo.util.hasClass(el,"eidogo-player-problem")){
for(var _b in _2){
_a[_b]=_2[_b];
}
}
for(var _b in _1){
_a[_b]=_1[_b];
}
var _c=el.getAttribute("sgf");
if(_c){
_a.sgfUrl=_c;
}else{
if(el.innerHTML){
_a.sgf=el.innerHTML;
}
}
var _d=el.getAttribute("shrink");
if(_d){
_a.shrinkToFit=(_d=="no"?false:true);
}
el.innerHTML="";
eidogo.util.show(el);
var _e=new eidogo.Player(_a);
eidogo.autoPlayers.push(_e);
}
});
})();

