function CBoardRef(a0,b0){this.c0=a0||0;this.d0=b0||0;this.e0=e0;this.f0=f0;this.g0=g0;this.JSExp_GetYRank=function(){return this.f0();};}function e0(){return this.c0;}function f0(){return this.d0;}function g0(a0,b0){this.c0=a0;this.d0=b0;}function V6(h0,i0,j0,k0){this.l0=h0;this.m0=j0;this.n0=k0;this.o0=i0;this.p0=null;this.q0=false;this.r0=false;this.s0=s0;this.t0=t0;this.u0=u0;this.v0=v0;this.w0=w0;this.x0=x0;this.y0=y0;this.z0=z0;this.A0=A0;this.B0=B0;this.C0=C0;this.D0=D0;this.E0=E0;this.F0=F0;this.G0=G0;this.H0=H0;this.I0=I0;this.J0=J0;this.K0=K0;this.L0=L0;this.JSExp_IsWhite=function(){return this.z0();};this.JSExp_IsKing=function(){return this.L0();};this.JSExp_IsRook=function(){return this.H0();};this.JSExp_IsPawn=function(){return this.G0();};this.JSExp_GetBoardRef=function(){return this.t0();};}function s0(){return this.l0;}function t0(){return this.o0;}function u0(i0){this.o0=i0;}function v0(){return this.p0;}function w0(i0){this.p0=i0;}function x0(){return this.p0;}function y0(){this.p0=null;}function z0(){return this.n0;}function A0(k0){return this.n0=k0;}function B0(){return this.q0;}function C0(){return this.r0;}function D0(M0,N0){this.q0=M0;this.r0=N0;}function E0(){return this.m0;}function F0(j0){this.m0=j0;}function G0(){return(this.m0=='p');}function H0(){return(this.m0=='r');}function I0(){return(this.m0=='n');}function J0(){return(this.m0=='b');}function K0(){return(this.m0=='q');}function L0(){return(this.m0=='k');}function CBoardState(O0,P0){this.Q0=Math.floor(Math.random()*200000);this.R0=R0;this.S0=function(){return this.Q0;};this.T0=P0;this.U0=U0;this.V0=function(){return this.T0;};this.W0='ugc_boardstate_'+this.S0() +'_'+this.V0();this.X0=function(){return this.W0;};this.Y0=true;this.Z0=Z0;this.JSExp_SetIsPlayerWhite=JSExp_SetIsPlayerWhite;this._0=null;this.a1=a1;this.b1=b1;this.c1=c1;this.d1=d1;this.e1=e1;this.f1=f1;this.g1=new Array();this.h1=h1;this.i1=i1;this.j1=j1;this.k1=k1;this.l1=l1;this.m1=m1;this.n1=null;this.o1=o1;this.p1=p1;this.q1=q1;this.r1=r1;this.s1=null;this.t1=null;this.JSExp_SetLastMoveRefs=JSExp_SetLastMoveRefs;this.u1	=u1;this.v1	=v1;this.w1=null;this.x1=null;this.JSExp_SetInvalidMoveRefs=JSExp_SetInvalidMoveRefs;this.y1	=y1;this.z1	=z1;this.JSExp_ClearInvalidMoveRefs=JSExp_ClearInvalidMoveRefs;this.A1=null;this.B1=B1;this.C1=C1;this.D1	=D1;this.E1=E1;this.F1=1;this.G1=G1;this.H1=H1;this.I1=I1;this.J1=0;this.K1=K1;this.L1=L1;this.M1=M1;this.N1=N1;this.O1=true;this.P1=true;this.Q1=true;this.R1=true;this.JSExp_SetIsCastlingOn=JSExp_SetIsCastlingOn;this.JSExp_IsCastlingOn=JSExp_IsCastlingOn;this.S1=true;this.JSExp_SetIsWhiteToMove=JSExp_SetIsWhiteToMove;this.T1=T1;this.U1='';this.JSExp_SetStartingFen=JSExp_SetStartingFen;this.JSExp_GetStartingFen=JSExp_GetStartingFen;this.V1='';this.JSExp_SetActiveFen=JSExp_SetActiveFen;this.JSExp_GetActiveFen=JSExp_GetActiveFen;this.W1=W1;this.X1=X1;this.JSExp_ResetProposedMove=JSExp_ResetProposedMove;this.JSExp_GetNumPc=JSExp_GetNumPc;this.JSExp_GetPcFromIndex=JSExp_GetPcFromIndex;this.JSExp_GetPcFromBoardRef=JSExp_GetPcFromBoardRef;this.Y1=Y1;this.JSExp_GetActionHistory=JSExp_GetActionHistory;this.Z1=new CActionHistory(this);this.JSExp_GetFenFromBoardState=JSExp_GetFenFromBoardState;this.JSExp_SetBoardStateFromFen=JSExp_SetBoardStateFromFen;this._1=_1;}function JSExp_GetActionHistory(){return this.Z1;}function _1(i0){return(this.X1(i0)==null);}function R0(O0){this.Q0=O0;}function U0(P0){this.T0=P0;}function JSExp_SetIsCastlingOn(k0,a2,b2){if(k0){if(a2){this.P1=b2;}else{this.O1=b2;}}else{if(a2){this.R1=b2;}else{this.Q1=b2;}}}function JSExp_IsCastlingOn(k0,a2){if(k0){return(a2?this.P1:this.O1);}else{return(a2?this.R1:this.Q1);}}function JSExp_SetIsWhiteToMove(c2){this.S1=c2;}function T1(){return this.S1;}function JSExp_SetLastMoveRefs(d2,e2){this.s1=d2;this.t1=e2;}function u1(){return this.s1;}function v1(){return this.t1;}function JSExp_SetInvalidMoveRefs(f2,g2){this.w1=f2;this.x1=g2;}function y1(){return this.w1;}function z1(){return this.x1;}function JSExp_ClearInvalidMoveRefs(){this.JSExp_SetInvalidMoveRefs(null,null);}function Z0(){return this.Y0;}function JSExp_SetIsPlayerWhite(h2){this.Y0=h2;}function c1(i2){this._0=i2;}function d1(){return this._0;}function a1(){return this._0!=null;}function b1(j2){return(this.a1() &&this._0.s0() ===j2.s0());}function e1(){this._0=null;}function W6(){return this.k2;}function X6(){return this.k2.e0();}function Y6(){return this.k2.f0();}function f1(){var l2=this.l1();for(var m2=0;m2<l2;m2++){var n2=this.j1(m2);if(n2.x0()){return true;}}return false;}function h1(j2){this.g1[this.g1.length]=j2;}function i1(j2){var l2=this.l1();for(var m2=0;m2<l2;m2++){if(this.j1(m2).s0() ==j2.s0() ){this.g1.splice(m2,1); m2=l2; }}}function j1(o2){return this.g1[o2];}function k1(h0){var l2=this.l1();for(var m2=0;m2<l2;m2++){if(this.j1(m2).s0() ==h0){return this.j1(m2);}}return null;}function l1(){return this.g1.length;}function m1(){this.g1=new Array();}function o1(n2){this.n1=n2;}function q1(){return this.n1;}function p1(){return(this.n1!=null);}function r1(){this.n1=null;}function B1(p2){this.A1=p2;}function C1(){return this.A1;}function D1(){this.A1=null;}function E1(){return(this.A1!=null);}function G1(){return this.F1;}function H1(q2){this.F1=q2;}function I1(){this.F1++;}function K1(){return this.J1;}function L1(r2){this.J1=r2;}function M1(){this.J1++;}function N1(){this.J1=0;}function JSExp_SetStartingFen(s2){this.U1=s2;}function JSExp_GetStartingFen(){return this.U1;}function JSExp_SetActiveFen(s2){this.V1=s2;}function JSExp_GetActiveFen(){return this.V1;}function W1(t2,k0){var u2=0;var l2=this.l1();for(var m2=0;m2<l2;m2++){var n2=this.j1(m2);if(n2.E0() ==t2&&n2.z0() ==k0){u2++;}}return u2;}function X1(i0){var l2=this.l1();for(var m2=0;m2<l2;m2++){var n2=this.j1(m2);if(!n2.B0() ){var v2=n2.t0();if(v2.e0() ==i0.e0() &&v2.f0() ==i0.f0()){return n2;}}}return null;}function JSExp_ResetProposedMove(w2){var x2=false;if(w2){var l2=this.l1();for(var m2=0;m2<l2;m2++){var n2=this.j1(m2);if(n2.x0()){n2.y0();}if(n2.C0()){n2.D0(false,false);x2=true;}}}this.e1();return x2;}function JSExp_GetNumPc(){return this.l1();}function JSExp_GetPcFromIndex(o2){return this.j1(o2);}function JSExp_GetPcFromBoardRef(i0){return this.X1(i0);}function Y1(y2){var z2=this.d1();var A2=z2.t0();var B2=(z2.z0())?7:0;if(z2.L0() &&A2.e0()==4&&A2.f0() ==B2){var a2=(y2.e0() ==6);var C2=(y2.e0() ==2);if(a2||C2){var D2=(z2.z0())?7:0;var E2=a2?7:0;var F2=a2?5:3;var G2=new CBoardRef(E2,D2);var H2=this.X1(G2);if(H2){var I2=new CBoardRef(F2,D2);if(this._1(I2)){this.o1(H2,G2);H2.w0(I2);}}}}if(z2.G0() ){if(this.E1() ){var p2=this.C1();if(p2.e0() ==y2.e0() &&p2.f0() ==y2.f0()){var J2=(p2.f0()==2)?+1:-1;var K2=this.X1(new CBoardRef(p2.e0(),p2.f0()+J2));if(K2){K2.D0(true,true);}}}}}function JSExp_GetFenFromBoardState(){var l2=this.l1();var L2=new Array(64);for(var m2=0;m2<l2;m2++){var n2=this.j1(m2);if(!n2.B0() ){var M2=n2.t0().e0() +(8*n2.t0().f0());var t2=n2.E0();if(n2.z0() ){t2=t2.toUpperCase();}L2[M2]=t2;}}var N2='';var O2=0;for(var m2=0;m2<64;m2++){if(L2[m2]){if(O2>0){N2+=O2;O2=0;}N2+=L2[m2];}else{O2++;}if((m2>0&&m2<63)&&((m2+1)%8)==0){if(O2>0){N2+=O2;O2=0;}N2+='/';}}if(O2>0){N2+=O2;}N2+=' ';if(this.T1()){N2+='w';}else{N2+='b';}N2+=' ';if(this.JSExp_IsCastlingOn(true,true)||this.JSExp_IsCastlingOn(true,false)||this.JSExp_IsCastlingOn(false,true)||this.JSExp_IsCastlingOn(false,false)){N2+=this.JSExp_IsCastlingOn(true,true)?'K':'';N2+=this.JSExp_IsCastlingOn(true,false)?'Q':'';N2+=this.JSExp_IsCastlingOn(false,true)?'k':'';N2+=this.JSExp_IsCastlingOn(false,false)?'q':'';}else{N2+='-';}N2+=' ';if(this.E1() ){var p2=this.C1();N2+=E7(true,p2.e0())+E7(false,p2.f0());}else{N2+='-';}N2+=' '+this.K1();N2+=' '+this.G1();return N2;}function JSExp_SetBoardStateFromFen(N2){n7(this);this.m1();var P2;var Q2=0;var R2=0;var S2=0;while(R2<64){P2=N2.charAt(Q2);if(!isNaN(parseInt(P2))) {R2+=parseInt(P2);}else if(P2=='/'){}else if(P2==' '){R2=64; }else{var k0=(P2!=P2.toLowerCase());this.h1(new V6(this.X0() +'_pc_'+S2,new CBoardRef(Math.floor(R2%8),Math.floor(R2/8)),P2.toLowerCase(),k0));S2++;R2++;}Q2++;}Q2++;this.JSExp_SetIsWhiteToMove(Z6(N2,Q2)=='w');Q2+=2;var T2=Z6(N2,Q2);this.JSExp_SetIsCastlingOn(true,true,false);this.JSExp_SetIsCastlingOn(true,false,false);this.JSExp_SetIsCastlingOn(false,true,false);this.JSExp_SetIsCastlingOn(false,false,false);for(var m2=0;m2<T2.length;m2++){switch(T2.charAt(m2)){case 'K':	this.JSExp_SetIsCastlingOn(true,true,true);break;case 'Q':	this.JSExp_SetIsCastlingOn(true,false,true);break;case 'k':	this.JSExp_SetIsCastlingOn(false,true,true);break;case 'q':	this.JSExp_SetIsCastlingOn(false,false,true);break;}}Q2+=T2.length;Q2++;var U2=Z6(N2,Q2);if(U2!='-'&&U2.length>1){this.B1(new CBoardRef(F7(U2.charAt(0),true),F7(U2.charAt(1),false)) );}else{this.D1();}Q2+=U2.length;Q2++;var V2=Z6(N2,Q2);this.L1(parseInt(V2));Q2+=V2.length;Q2++;var W2=Z6(N2,Q2);this.H1(parseInt(W2));}function Z6(N2,X2){var o2=N2.indexOf(' ',X2);if(o2==-1){o2=N2.length;}return N2.substr(X2,o2-X2);}function CBoardRenderer(Y2,Z2,_2,a3,b3,c3){this.d3=Y2;g_boardRendererManager.JSExp_AddBoardRenderer(this.d3,this);this.e3=function(){return this.d3;};this.f3;this.g3=function(){return this.f3;};this.h3=h3;this.i3=Z2;this.JSExp_GetBoardState=JSExp_GetBoardState;this.j3=b3;this.k3=a3;this.l3='ugc_boardrenderer_'+Math.floor(Math.random()*99999);this.m3;this.n3;this.JSExp_GetBoardContainerEl=function(){return this.n3;};this.o3='crd_'+this.l3;this.p3=_2||0;this.JSExp_SetTileSizePx=JSExp_SetTileSizePx;this.q3=q3;this.r3=function(){return(this.p3*8);};this.s3=c3||false;this.t3=t3;this.JSExp_SetIsBoardInverted=JSExp_SetIsBoardInverted;this.u3=u3;this.v3=false;this.JSExp_IsFreeMoveInterface=JSExp_IsFreeMoveInterface;this.JSExp_SetIsFreeMoveInterface=JSExp_SetIsFreeMoveInterface;this.w3=false;this.JSExp_IsStaticBoard=JSExp_IsStaticBoard;this.JSExp_SetIsStaticBoard=JSExp_SetIsStaticBoard;this.JSExp_RenderBoard=JSExp_RenderBoard;this.x3=x3;this.y3=y3;this.z3=false;this.A3=A3;this.B3=B3;this.C3=false;this.JSExp_SetIsPrintableRender=JSExp_SetIsPrintableRender;this.D3=D3;this.E3='';this.JSExp_SetPrintablePcImgPath=JSExp_SetPrintablePcImgPath;this.JSExp_SetPrintableBoardImg=JSExp_SetPrintableBoardImg;this.F3=F3;this.G3=null;this.JSExp_SetCapturedBar=JSExp_SetCapturedBar;this.H3=false;this.I3=I3;this.J3=false;this.K3=K3;this.L3=null;this.M3=null;this.N3=null;this.JSExp_SetTilePreferences=JSExp_SetTilePreferences;this.O3=O3;this.P3=	function(){return this.m3;};this.O3();this.JSExp_ClearInvalidMoveTileHighLights=JSExp_ClearInvalidMoveTileHighLights;this.Q3=false;this.R3=function(){return this.Q3;};this.JSExp_SetIsFreeMoveOneSideOnly=JSExp_SetIsFreeMoveOneSideOnly;this.S3=true;this.T3=function(){return this.S3;};this.JSExp_SetIsFreeMoveOneSideColorWhite=JSExp_SetIsFreeMoveOneSideColorWhite;this.JSExp_ClearSelectedTileHighLights=JSExp_ClearSelectedTileHighLights;this.U3=U3;this.V3='';this.W3='';this.X3='';this.Y3='';this.JSExp_SetFormCoordElIds=JSExp_SetFormCoordElIds;this.Z3=Z3;this._3=_3;this.JSExp_TouchTipEnabled=JSExp_TouchTipEnabled;this.JSExp_SetClickSelectEnabled=JSExp_SetClickSelectEnabled;this.JSExp_SetClickContextEnabled=JSExp_SetClickContextEnabled;this.JSExp_SetSelectedPieceType	=JSExp_SetSelectedPieceType;this.JSExp_ToggleSelectedPieceColour=JSExp_ToggleSelectedPieceColour;this.JSExp_RemoveSelectedPiece=JSExp_RemoveSelectedPiece;this.a4=null;this.b4=b4;this.c4=c4;this.d4=d4;this.e4=null;this.f4=f4;this.JSExp_SetBoardActionCallBack=JSExp_SetBoardActionCallBack;this.g4=null;this.h4=h4;this.JSExp_SetContextActionCallBack=JSExp_SetContextActionCallBack;}function JSExp_SetFormCoordElIds(i4,j4,k4,l4){this.V3=i4;this.W3=j4;this.X3=k4;this.Y3=l4;}function Z3(m4,n4,o4,p4){if(!this.JSExp_IsFreeMoveInterface() ){if(document.getElementById(this.V3)){document.getElementById(this.V3).value=m4;document.getElementById(this.W3).value=n4;document.getElementById(this.X3).value=o4;document.getElementById(this.Y3).value=p4;return true;}}return false;}function JSExp_SetIsFreeMoveOneSideColorWhite(q4){this.S3=q4;}function JSExp_SetIsFreeMoveOneSideOnly(r4){this.Q3=r4;}function JSExp_ClearInvalidMoveTileHighLights(){this.F3('tile_invalidmovesrcid',false,'',null);this.F3('tile_invalidmovetgtid',false,'',null);}function JSExp_ClearSelectedTileHighLights(){this.F3('tile_selectedsrc',false,this.L3,null);this.F3('tile_selectedtgt',false,this.L3,null);}function h3(s4){this.f3=s4;}function O3(){var t4	=(this.p3*8);var u4=t4+28;var v4=document.createElement('div');v4.id='surroundouter';var w4=document.createElement('div');w4.id='surroundinner';var x4=document.createElement('div');x4.id='mainboardborder';var y4=document.createElement('div');y4.id=this.l3; x4.appendChild(y4);w4.appendChild(x4);v4.appendChild(w4);v4.style.width=ValInPx(u4);v4.style.height=ValInPx(u4);v4.style.borderColor='#CCCCCC';v4.style.borderStyle	='solid';v4.style.borderWidth='1px';v4.style.position='relative';w4.style.borderColor	='#666666';w4.style.borderStyle	='solid';w4.style.background	='#FFF';w4.style.borderWidth	='1px';w4.style.position	='absolute';w4.style.top	='12px';w4.style.left='12px';x4.style.width	=ValInPx(t4);x4.style.height=ValInPx(t4);x4.style.position='relative';y4.style.width	=ValInPx(t4);y4.style.height	=ValInPx(t4);y4.style.backgroundImage='url('+this.k3+')';y4.onclick=function(){return false;};y4.oncontextmenu=function(){return false;};this.m3=y4;this.m3.m_ownerBoardRendererId=this.e3();this.n3=v4;for(var m2=0;m2<16;m2++){var z4=document.createElement('div');z4.id=this.o3+m2;z4.innerHTML='X';z4.style.color='#666666';z4.style.position='absolute';z4.style.fontSize='8px';z4.style.fontWeight='bold';v4.appendChild(z4);}}function JSExp_TouchTipEnabled(){this.m3.addEventListener('touchstart',	A4,false);this.m3.addEventListener('touchmove',	B4,false);this.m3.addEventListener('touchend',	C4,false);}function JSExp_SetClickSelectEnabled(){this.m3.onmouseup=JSExp_SelectAction;}function JSExp_SetClickContextEnabled(){this.m3.oncontextmenu=JSExp_ContextAction;this.m3.ondblclick=JSExp_ContextAction; }function JSExp_SetTilePreferences(D4,E4,F4){this.L3=D4;this.M3=E4;this.N3=F4;}function JSExp_GetBoardState(){return this.i3;}function JSExp_SetIsBoardInverted(c3){this.s3=c3;}function t3(){return this.s3;}function JSExp_SetTileSizePx(G4){this.p3=G4;}function q3(){return this.p3;}function u3(){this.JSExp_SetIsBoardInverted(!this.t3() );this.I3();}function JSExp_SetIsFreeMoveInterface(H4){this.v3=H4;}function JSExp_IsFreeMoveInterface(){return this.v3;}function JSExp_SetIsStaticBoard(I4){this.w3=I4;}function JSExp_IsStaticBoard(){return this.w3;}function JSExp_RenderBoard(J4){this.K4=J4||false;var l2=this.i3.l1();for(var m2=0;m2<l2;m2++){var n2=this.i3.j1(m2);var L4=e7(n2.s0() );if(!L4){L4=document.createElement('div');L4.id=n2.s0();L4.m_ownerBoardRendererId=this.e3();this.m3.appendChild(L4);}L4.className='piece';L4.style.position='absolute';L4.style.width=ValInPx(this.q3() );L4.style.height=ValInPx(this.q3() );L4.style.backgroundRepeat='no-repeat';L4.style.cursor='pointer';L4.style.zIndex=100;if(!this.C3){L4.style.backgroundImage='url('+this.j3+')';}this.y3(n2,L4);}if(this.i3.u1() ){this.F3('tile_lastmovesrcid',true,this.M3,this.i3.u1() );}if(this.i3.v1() ){this.F3('tile_lastmovetgtid',true,this.M3,this.i3.v1() );}if(this.i3.y1() ){this.F3('tile_invalidmovesrcid',true,this.N3,this.i3.y1() );}if(this.i3.z1() ){this.F3('tile_invalidmovetgtid',true,this.N3,this.i3.z1() );}if(this.i3.a1() ){var i2=this.i3.d1();this.F3('tile_selectedsrc',true,this.L3,i2.t0() );if(i2.v0() ){this.F3('tile_selectedtgt',true,this.L3,i2.v0() );}else{this.F3('tile_selectedtgt',false,this.L3,null);}}else{this.JSExp_ClearSelectedTileHighLights();}if(this.K4||!this.H3){this.A3();this.H3=true;}if(this.G3&&(this.K4||!this.J3)){this.G3.X5();this.J3=true;}}function F3(M4,N4,O4,i0 ){var P4=this.e3() +'_'+M4;var Q4=e7(P4);if(!Q4){Q4=document.createElement('div');Q4.style.height=ValInPx(this.q3());Q4.style.width=ValInPx(this.q3() );Q4.style.background=O4;Q4.style.position='absolute';Q4.style.opacity=0.85;Q4.style.filter='alpha(opacity=85)';Q4.style.zIndex=30;Q4.id=P4;Q4.m_ownerBoardRendererId=this.e3();this.m3.appendChild(Q4);}Q4.style.visibility=(N4?'visible':'hidden');if(i0){r7(Q4,i0,this.q3(),this.t3() );}}function y3(n2,R4){if(n2.B0() ){p7(R4);}else{q7(R4);if(n2.x0()){var v2=n2.v0();}else{var v2=n2.t0();}r7(R4,v2,this.q3(),this.t3());if(this.C3){var S4=n2.s0() +'_img';var T4=e7(S4);if(!T4){T4=document.createElement('img');T4.id=S4;}T4.src=this.E3+(n2.z0()?'w':'b')+n2.E0() +'print.gif';T4.style.width=ValInPx(this.q3());T4.style.height=ValInPx(this.q3());T4.style.zIndex=50;R4.appendChild(T4);}else{R4.style.backgroundPosition=l7(n2,this.q3() )+'px '+m7(n2,this.q3() )+'px ';}}}function x3(n2){var R4=e7(n2.s0() );if(R4){y3(n2,R4);}}function D3(){this.u3();this.JSExp_RenderBoard();}function JSExp_SetIsPrintableRender(U4){this.C3=U4;}function JSExp_SetPrintablePcImgPath(V4){this.E3=V4;}function JSExp_SetPrintableBoardImg(W4,X4){var Y4=new Image();Y4.src=W4;Y4.style.height=ValInPx(X4);Y4.style.width=ValInPx(X4);this.m3.appendChild(Y4);}function JSExp_SetCapturedBar(Z4){this.G3=Z4;}function K3(){this.J3=false;}function I3(){this.H3=false;}function U3(_4){var Z2=this.JSExp_GetBoardState();var z2=Z2.d1();var a5=z2.t0();var y2=z2.v0();var b5=this.JSExp_IsFreeMoveInterface();if(!Z2._1(y2)){var c5=Z2.X1(y2);if(z2.s0() !=c5.s0() ) {var d5=Z2.X1(y2);d5.D0(true,!this.JSExp_IsFreeMoveInterface() );this.K3();}}if(!this.JSExp_IsFreeMoveInterface()){Z2.Y1(y2,Z2);this.Z3(a5.e0(),a5.f0(),y2.e0(),y2.f0() );}if(b5){z2.u0(y2);z2.y0();Z2.e1();}else{z2.w0(y2);}if(b5){_4.JSExp_AddFen(Z2.JSExp_GetFenFromBoardState() );}}function d4(){return this.a4!=null;}function c4(){return this.a4;}function b4(e5){this.a4=e5;}function _3(f5){return(f5==this.P3().id);}function A3(){var g5='12345678abcdefgh';for(var h5=0;h5<16;h5++){var m2;if(this.t3() ){m2=(h5<8)?15-h5:h5-8;}else{m2=(h5<8)?h5+8:15-h5;}var i5=e7(this.o3+h5);i5.innerHTML=g5.charAt(m2);}if(!this.z3){this.B3();}}function B3(){var borderWidth=14;var j5=2;var k5,l5;var m5=(borderWidth/2);var n5=(borderWidth/2)-m5;for(var h5=0;h5<16;h5++){var o5=(h5<8)?h5:h5-8;var p5=(o5*this.q3())+(this.q3()/2)+borderWidth-m5;if(h5<8){k5=p5+j5;l5=(this.q3()*8)+borderWidth+n5+j5;}else{k5=n5+j5;l5=p5+j5;}var i5=e7(this.o3+h5);s7(i5,k5,l5);}this.z3=true;}function JSExp_SetSelectedPieceType(j0){var q5=this.JSExp_GetBoardState(this);q5.e1();if(this.d4() ){var r5=this.c4();var n2=q5.X1(r5);if(n2){n2.F0(j0);}else{q5.h1(new V6('pc_'+(q5.l1()+1),r5,j0,q5.Z0() ));}this.JSExp_RenderBoard(true);q5.JSExp_GetActionHistory().JSExp_AddFen(q5.JSExp_GetFenFromBoardState() );}this.f4();}function JSExp_ToggleSelectedPieceColour(){var q5=this.JSExp_GetBoardState();q5.e1();if(this.d4() ){var n2=q5.X1(this.c4() );if(n2){n2.A0(!n2.z0());this.JSExp_RenderBoard(true);q5.JSExp_GetActionHistory().JSExp_AddFen(q5.JSExp_GetFenFromBoardState() );}}this.f4();}function JSExp_RemoveSelectedPiece(){var q5=this.JSExp_GetBoardState();q5.e1();if(this.d4() ){var n2=q5.X1(this.c4() );if(n2){o7(n2);			q5.i1(n2);this.JSExp_RenderBoard(true);q5.JSExp_GetActionHistory().JSExp_AddFen(q5.JSExp_GetFenFromBoardState() );}}this.f4();}function JSExp_SetBoardActionCallBack(s5){this.e4=s5;}function f4(){if(this.e4!=null){this.e4(this);}}function JSExp_SetContextActionCallBack(s5){this.g4=s5;}function h4(t5){if(this.g4!=null){this.g4(t5,this);}}function CBoardStats(Z2){this.i3=Z2;this.u5=0;this.v5=0;this.w5=0;this.x5=0;this.y5=0;this.z5=0;this.A5=0;this.B5=0;this.C5=0;this.D5=0;this.E5=0;this.F5=0;this.G5=0;this.H5=0;this.JSExp_CountPieces=JSExp_CountPieces;this.JSExp_GetTotalWhite=JSExp_GetTotalWhite;this.JSExp_GetTotalBlack=JSExp_GetTotalBlack;this.I5=I5;this.J5=J5;this.K5=K5;this.JSExp_GetTotalWhitePawn=function(){return this.w5;};this.JSExp_GetTotalWhiteBishop=function(){return this.A5;};this.JSExp_GetTotalWhiteKnight=function(){return this.y5;};this.JSExp_GetTotalWhiteRook=function(){return this.C5;};this.JSExp_GetTotalWhiteQueen=function(){return this.E5;};this.JSExp_GetTotalWhiteKing=function(){return this.G5;};this.JSExp_GetTotalBlackPawn=function(){return this.x5;};this.JSExp_GetTotalBlackBishop=function(){return this.B5;};this.JSExp_GetTotalBlackKnight=function(){return this.z5;};this.JSExp_GetTotalBlackRook=function(){return this.D5;};this.JSExp_GetTotalBlackQueen=function(){return this.F5;};this.JSExp_GetTotalBlackKing=function(){return this.H5;};this.L5=L5;this.M5=M5;this.N5=N5;this.O5=0;this.P5=0;}function JSExp_CountPieces(){this.u5=0;this.v5=0;this.w5=0;this.x5=0;this.y5=0;this.z5=0;this.A5=0;this.B5=0;this.C5=0;this.D5=0;this.E5=0;this.F5=0;this.G5=0;this.H5=0;var l2=this.i3.l1();for(var m2=0;m2<l2;m2++){var n2=this.i3.j1(m2);if(!n2.B0() ){if(n2.z0() ){if(n2.G0()){this.w5++;this.u5++;}if(n2.I0()){this.y5++;this.u5++;}if(n2.J0()){this.A5++;this.u5++;}if(n2.H0()){this.C5++;this.u5++;}if(n2.K0()){this.E5++;this.u5++;}if(n2.L0()){this.G5++;this.u5++;}}else{if(n2.G0()){this.x5++;this.v5++;}if(n2.I0()){this.z5++;this.v5++;}if(n2.J0()){this.B5++;this.v5++;}if(n2.H0()){this.D5++;this.v5++;}if(n2.K0()){this.F5++;this.v5++;}if(n2.L0()){this.H5++;this.v5++;}}}}this.O5=0;this.L5(true,2,this.y5);this.L5(true,2,this.A5);this.L5(true,2,this.C5);this.L5(true,1,this.E5);this.L5(true,1,this.G5);this.P5=0;this.L5(false,2,this.z5);this.L5(false,2,this.B5);this.L5(false,2,this.D5);this.L5(false,1,this.F5);this.L5(false,1,this.H5);return(this.v5+this.u5);}function L5(k0,Q5,R5){if(R5>Q5){var S5=R5-Q5;if(k0){this.O5+=S5;}else{this.P5+=S5;}}}function JSExp_GetTotalWhite(){return this.u5;}function JSExp_GetTotalBlack(){return this.v5;}function J5(){return(this.JSExp_GetTotalWhite() ==16);}function K5(){return(this.JSExp_GetTotalWhite() ==16);}function I5(){return(this.J5() ||this.K5());}function M5(){return this.O5;}function N5(){return this.P5;}function CCapturedBarRenderer(Z2,T5,U5,V5,W5){this.X5=X5;this.Y5=Y5;this.i3=Z2;this.Z5=T5;this._5=U5;this.a6=null;this.b6=null;this.c6=new CBoardStats(this.i3);this.d6=new Image();this.d6.src=W5;this.e6=V5;}function X5(){this.c6.JSExp_CountPieces();this.a6=e7(this.Z5);this.b6=e7(this._5);g7(this.a6);g7(this.b6);this.Y5('k',true,1,this.c6.JSExp_GetTotalWhiteKing());this.Y5('q',true,1,this.c6.JSExp_GetTotalWhiteQueen());this.Y5('r',true,2,this.c6.JSExp_GetTotalWhiteRook());this.Y5('b',true,2,this.c6.JSExp_GetTotalWhiteBishop());this.Y5('n',true,2,this.c6.JSExp_GetTotalWhiteKnight());this.Y5('p',true,8-this.c6.M5(),this.c6.JSExp_GetTotalWhitePawn());this.Y5('k',false,1,this.c6.JSExp_GetTotalBlackKing());this.Y5('q',false,1,this.c6.JSExp_GetTotalBlackQueen());this.Y5('r',false,2,this.c6.JSExp_GetTotalBlackRook());this.Y5('b',false,2,this.c6.JSExp_GetTotalBlackBishop());this.Y5('n',false,2,this.c6.JSExp_GetTotalBlackKnight());this.Y5('p',false,8-this.c6.N5(),this.c6.JSExp_GetTotalBlackPawn());}function Y5(t2,k0,f6,g6){var n2=new V6('cappcid',null,t2,k0);var h6=(k0)?this.a6:this.b6;if(h6){for(var h5=g6;h5<f6;h5++){var L4=document.createElement('img');L4.id=n2.s0() +'_'+h5;L4.className='piececap';L4.style.backgroundPosition=l7(n2,this.e6)+'px '+m7(n2,this.e6)+'px ';L4.style.height=ValInPx(this.e6);L4.style.width=ValInPx(this.e6);L4.style.position='relative';L4.src=this.d6.src;h6.appendChild(L4);}}}function _6(i6,j6){i6.style.left=ValInPx(j6);}function a7(i6,k6){i6.style.top=ValInPx(k6);}function b7(i6){return parseInt(i6.style.left);}function c7(i6){return parseInt(i6.style.top);}function d7(l6){var m6=GetElementFromId(l6);return m6.style;}function e7(l6){return document.getElementById(l6);}function f7(j2){return e7(j2.s0() );}function g7(i6){if(i6){i6.innerHTML=''};}function JSExp_GetElFromId(l6){return e7(l6);}/*function h7(t5){}*/function B4(t5){t5.preventDefault();return A4(t5);}function A4(t5){var n6=t5.changedTouches[0]; var o6=n6.target;var p6=g_boardRendererManager.JSExp_GetBoardRenderer(o6.m_ownerBoardRendererId);var q6=n6.pageX+t5.layerX;var r6=n6.pageY+t5.layerY;if(o6.id.indexOf('tile_')>=0||o6.id.indexOf('_pc_')>=0){q6=parseInt(o6.style.left)+q6;r6=parseInt(o6.style.top)+r6;o6=p6.P3();}var i0=new CBoardRef(v7(q6,p6.q3(),p6.t3() ),v7(r6,p6.q3(),p6.t3() ));j7(p6,i0);return false;}function i7(){if(document.getElementById('pcbubble_id')){var m6=document.getElementById('pcbubble_id');if(m6&&m6.parentNode){m6.style.background='#F00';m6.parentNode.removeChild(m6);}}}function C4(t5){i7();var n6=t5.changedTouches[0]; var o6=n6.target;var p6=g_boardRendererManager.JSExp_GetBoardRenderer(o6.m_ownerBoardRendererId);if(p6.JSExp_IsStaticBoard()){return false;}var q6=n6.pageX+t5.layerX;var r6=n6.pageY+t5.layerY;if(o6.id.indexOf('tile_')>=0||o6.id.indexOf('_pc_')>=0){q6=parseInt(o6.style.left)+q6;r6=parseInt(o6.style.top)+r6;o6=p6.P3();}var i0=new CBoardRef(v7(q6,p6.q3(),p6.t3() ),v7(r6,p6.q3(),p6.t3() ));JSExp_SelectActionFromBoardRef(p6,i0);}function j7(p6,i0){i7();if(i0.e0() <0||i0.e0() >7||i0.f0() <0||i0.f0() >7){return false;}var s6=p6.JSExp_GetBoardState().X1(i0);var t6=u7(i0.e0(),p6.q3(),p6.t3())- (p6.q3()/2)-4;var u6=u7(i0.f0(),p6.q3(),p6.t3())- (p6.q3()*2)-22;var v6=(s6!=0);var w6=document.createElement('div');w6.style.margin=ValInPx(2);w6.style.fontSize=ValInPx(10);w6.style.background='#FFF';w6.style.width=ValInPx(p6.q3() );w6.style.border='solid 1px #CCC';w6.style.textAlign='center';w6.innerHTML=E7(true,i0.e0())+E7(false,i0.f0());var L4=document.createElement('div');L4.style.height=ValInPx(p6.q3() );L4.style.width=ValInPx(p6.q3() );L4.style.background='#FFF';L4.style.border='solid 1px #CCC';if(s6){L4.style.backgroundPosition=l7(s6,p6.q3() )+'px '+m7(s6,p6.q3() )+'px ';L4.style.backgroundRepeat='no-repeat';L4.style.backgroundImage='url('+p6.j3+')';}x6=document.createElement('div');x6.id='pcbubble_id';x6.style.border='solid 1px #000';x6.style.background='#EEE';x6.style.cursor='pointer';x6.style.zIndex=200;x6.style.position='absolute';x6.style.padding=ValInPx((p6.q3()/2));x6.m_ownerBoardRendererId=p6.e3();x6.style.left	=ValInPx(t6);x6.style.top	=ValInPx(u6);x6.appendChild(L4);x6.appendChild(w6);p6.P3().appendChild(x6);}function JSExp_SelectAction(t5){var t5=GetCrossBrowserEvent(t5);var q6=y7(t5);var r6=z7(t5);var o6=x7(t5);var p6=g_boardRendererManager.JSExp_GetBoardRenderer(o6.m_ownerBoardRendererId);if(!p6){alert('No board renderer');}if(p6.JSExp_IsStaticBoard()){return false;}if(o6.id.indexOf('tile_')>=0||o6.id.indexOf('_pc_')>=0){q6=parseInt(o6.style.left)+q6;r6=parseInt(o6.style.top)+r6;if(o6.id.indexOf('tile_')>=0){o6=p6.P3();}}var i0=new CBoardRef(v7(q6,p6.q3(),p6.t3() ),v7(r6,p6.q3(),p6.t3() ));return JSExp_SelectActionFromBoardRef(p6,i0);}function JSExp_ContextAction(t5){var o6=x7(t5);var p6=g_boardRendererManager.JSExp_GetBoardRenderer(o6.m_ownerBoardRendererId);var q5=p6.JSExp_GetBoardState();if(!p6.JSExp_IsStaticBoard() &&p6.JSExp_IsFreeMoveInterface() ){q5.e1();var o6=x7(t5);if(p6._3(o6.id)){var y6=new CBoardRef(v7(y7(t5),p6.q3(),p6.t3() ),v7(z7(t5),p6.q3(),p6.t3() ));p6.b4(y6);}else{var s6=q5.k1(o6.id);p6.b4(s6.t0() );q5.c1(s6);p6.JSExp_RenderBoard();}p6.h4(t5);}return false;}function JSExp_SelectActionFromBoardRef(p6,i0){var q5=p6.JSExp_GetBoardState();var z6=q5.JSExp_GetPcFromBoardRef(i0);var A6=false;p6.Z3(-1,-1,-1,-1);var B6=(!z6);if(B6) {if(!q5.f1() ){if(q5.a1() ){var i2=q5.d1();i2.w0(i0);p6.U3(q5.JSExp_GetActionHistory());}}else{A6=q5.JSExp_ResetProposedMove(!p6.JSExp_IsFreeMoveInterface() ); }}else{if(k7(p6,z6)){if(q5.f1()){A6=q5.JSExp_ResetProposedMove(!p6.JSExp_IsFreeMoveInterface() ); q5.c1(z6);}else{if(q5.a1() &&(p6.JSExp_IsFreeMoveInterface() ||w7(z6,q5.Z0() ))){var i2=q5.d1();i2.w0(z6.t0() );p6.U3(q5.JSExp_GetActionHistory() );z6.D0(true,!p6.JSExp_IsFreeMoveInterface() );}else{q5.c1(z6);}}}else{A6=q5.JSExp_ResetProposedMove(!p6.JSExp_IsFreeMoveInterface() ); }}if(A6){p6.K3();}p6.JSExp_RenderBoard();p6.f4();return true;}function JSExp_SetBoardStateFromHistoryFen(p6,s2){var q5=p6.JSExp_GetBoardState();q5.e1();q5.JSExp_GetActionHistory().JSExp_AddFen(s2);q5.JSExp_SetBoardStateFromFen(s2);p6.JSExp_RenderBoard(true);p6.f4();}function JSExp_UndoLine(p6){var q5=p6.JSExp_GetBoardState();if(q5.JSExp_GetActionHistory().JSExp_IsPreviousFen() ){q5.e1();q5.JSExp_SetBoardStateFromFen(q5.JSExp_GetActionHistory().JSExp_GetPreviousFen() );p6.JSExp_RenderBoard(true);p6.f4();}}function JSExp_RedoLine(p6){var q5=p6.JSExp_GetBoardState();if(q5.JSExp_GetActionHistory().JSExp_IsAnotherFen() ){q5.e1();q5.JSExp_SetBoardStateFromFen(q5.JSExp_GetActionHistory().JSExp_GetNextFen() );p6.JSExp_RenderBoard(true);p6.f4();}}function JSExp_CurrentLine(p6){var q5=p6.JSExp_GetBoardState();q5.e1();q5.JSExp_SetBoardStateFromFen(q5.JSExp_GetActionHistory().JSExp_GetCurrentFen() );p6.JSExp_RenderBoard(true);p6.f4();}function JSExp_FlipBoardAction(p6){p6.D3();}function JSExp_ResetBoardToActiveFen(p6){var q5=p6.JSExp_GetBoardState();q5.e1();q5.JSExp_SetBoardStateFromFen(q5.JSExp_GetActiveFen() );p6.JSExp_RenderBoard(true);q5.JSExp_GetActionHistory().JSExp_ResetHistory();p6.f4();}function k7(p6,n2){var q5=p6.JSExp_GetBoardState();if(q5.a1() ){if(q5.d1() ===n2){return false;}}if(p6.JSExp_IsFreeMoveInterface() ){return true;}var C6=w7(n2,q5.Z0() );if(C6){return(q5.a1() &&!q5.f1() );}else{return true;}}function l7(n2,D6){var E6=0;var G4=-D6;if(n2.K0() ){E6=1;}else if(n2.J0() ){E6=2;}else if(n2.I0() ){E6=3;}else if(n2.H0() ){E6=4;}else if(n2.G0() ){E6=5;}return(E6*G4);}function m7(n2,D6){return(n2.z0())?0:-D6;}function n7(F6){var l2=F6.l1();for(var m2=0;m2<l2;m2++){o7(F6.j1(m2));}}function o7(n2){p7(f7(n2));}function p7(i6){i6.style.visibility='hidden';}function q7(i6){i6.style.visibility='visible';}function r7(m6,i0,D6,c3){s7(m6,u7(i0.e0(),D6,c3),u7(i0.f0(),D6,c3));}function s7(i6,k5,l5){_6(i6,k5);a7(i6,l5);}function t7(G6,c3){if(c3){G6=7-G6;}return G6;}function u7(G6,D6,t3){G6=t7(G6,t3);return(G6*D6);}function v7(H6,D6,c3){var G6=parseInt(Math.floor(parseInt(H6)/D6));return t7(G6,c3);}function w7(n2,h2){if(h2){return!n2.z0();}else{return n2.z0();}}function x7(t5){var t5=GetCrossBrowserEvent(t5);return(t5.target||t5.srcElement);}function y7(t5){var t5=GetCrossBrowserEvent(t5);return(t5.offsetX||t5.layerX);}function z7(t5){var t5=GetCrossBrowserEvent(t5);return(t5.offsetY||t5.layerY);}function A7(I6,J6){return(I6.indexOf(J6)!=-1);}function B7(i6){D7(i6.id+' : x : '+b7(i6)+' : y : '+c7(i6));}function C7(n2){if(n2){D7(n2.s0() +' : x : '+n2.t0().e0() +' : y : '+n2.t0().f0() );}}function D7(I6){window.status=I6;}function E7(K6,e5){var L6='87654321abcdefgh';var M6=(K6)? (e5+8):e5;return L6.charAt(M6);}function F7(N6,K6){var L6='abcdefgh';return(!K6)? (8-parseInt(N6)):L6.indexOf(N6);}function CActionHistory(O6){this.P6=O6;this.Q6=0;this.R6=new Array();this.S6=null;this.JSExp_AddFen=JSExp_AddFen;this.JSExp_GetFen=JSExp_GetFen;this.JSExp_GetNextFen=JSExp_GetNextFen;this.JSExp_GetPreviousFen=JSExp_GetPreviousFen;this.JSExp_ResetHistory=JSExp_ResetHistory;this.JSExp_GetHistoryIndex=JSExp_GetHistoryIndex;this.JSExp_CountFens=JSExp_CountFens;this.JSExp_IsPreviousFen=JSExp_IsPreviousFen;this.JSExp_IsAnotherFen=JSExp_IsAnotherFen;this.JSExp_SetBaseFen=JSExp_SetBaseFen;this.JSExp_GetCurrentFen=JSExp_GetCurrentFen;this.JSExp_ResetCursor=JSExp_ResetCursor;}function G7(){return this.P6;}function JSExp_ResetHistory(){this.R6.length=0;this.JSExp_AddFen(this.S6);this.Q6=0;}function JSExp_SetBaseFen(s2){this.S6=s2;this.JSExp_AddFen(this.S6);}function JSExp_AddFen(s2){if(this.Q6<(this.R6.length-1)){this.R6.length=this.Q6+1;}this.R6[this.R6.length]=s2;this.Q6=this.R6.length-1;}function JSExp_GetFen(o2){if(this.R6.length>0){if(o2<0||o2>=this.R6.length){o2=0;}return this.R6[o2];}return null;}function JSExp_GetCurrentFen(){return this.JSExp_GetFen(this.Q6);}function JSExp_GetNextFen(){this.Q6++;return this.JSExp_GetFen(this.Q6);}function JSExp_GetPreviousFen(){this.Q6--;return this.JSExp_GetFen(this.Q6);}function JSExp_GetHistoryIndex(){return this.Q6+1;}function JSExp_CountFens(){return this.R6.length;}function JSExp_IsPreviousFen(){return(this.Q6>0);}function JSExp_IsAnotherFen(){return(this.Q6<this.JSExp_CountFens()-1);}function JSExp_ResetCursor(){this.Q6=0;}function CBoardRendererManager(){this.T6=new Array();this.JSExp_AddBoardRenderer	=JSExp_AddBoardRenderer;this.JSExp_GetBoardRenderer	=JSExp_GetBoardRenderer;this.JSExp_RemoveBoardRenderer=JSExp_RemoveBoardRenderer;this.JSExp_IsBoardRenderer=JSExp_IsBoardRenderer;}function JSExp_AddBoardRenderer(Y2,U6){this.T6[Y2]=U6;}function JSExp_IsBoardRenderer(P0){if(this.T6[P0]){return true;}return false;}function JSExp_GetBoardRenderer(P0){if(this.JSExp_IsBoardRenderer(P0)){return this.T6[P0];}else{alert('Board renderer id not found : '+P0);return false;}}function JSExp_RemoveBoardRenderer(P0){if(this.JSExp_IsBoardRenderer(P0)){delete this.T6[P0];}}var g_boardRendererManager=new CBoardRendererManager();