/* Copyright 2007-2010 Richard Jones
This work (apart from the Yui library from Yahoo!) is licensed under the Creative Commons [insert description] License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/2.5/au/
*/
/*
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.com/yui/license.html
version: 2.8.1
*/
if(typeof YAHOO=="undefined"||!YAHOO){var YAHOO={};}YAHOO.namespace=function(){var A=arguments,E=null,C,B,D;for(C=0;C<A.length;C=C+1){D=(""+A[C]).split(".");E=YAHOO;for(B=(D[0]=="YAHOO")?1:0;B<D.length;B=B+1){E[D[B]]=E[D[B]]||{};E=E[D[B]];}}return E;};YAHOO.log=function(D,A,C){var B=YAHOO.widget.Logger;if(B&&B.log){return B.log(D,A,C);}else{return false;}};YAHOO.register=function(A,E,D){var I=YAHOO.env.modules,B,H,G,F,C;if(!I[A]){I[A]={versions:[],builds:[]};}B=I[A];H=D.version;G=D.build;F=YAHOO.env.listeners;B.name=A;B.version=H;B.build=G;B.versions.push(H);B.builds.push(G);B.mainClass=E;for(C=0;C<F.length;C=C+1){F[C](B);}if(E){E.VERSION=H;E.BUILD=G;}else{YAHOO.log("mainClass is undefined for module "+A,"warn");}};YAHOO.env=YAHOO.env||{modules:[],listeners:[]};YAHOO.env.getVersion=function(A){return YAHOO.env.modules[A]||null;};YAHOO.env.ua=function(){var D=function(H){var I=0;return parseFloat(H.replace(/\./g,function(){return(I++==1)?"":".";}));},G=navigator,F={ie:0,opera:0,gecko:0,webkit:0,mobile:null,air:0,caja:G.cajaVersion,secure:false,os:null},C=navigator&&navigator.userAgent,E=window&&window.location,B=E&&E.href,A;F.secure=B&&(B.toLowerCase().indexOf("https")===0);if(C){if((/windows|win32/i).test(C)){F.os="windows";}else{if((/macintosh/i).test(C)){F.os="macintosh";}}if((/KHTML/).test(C)){F.webkit=1;}A=C.match(/AppleWebKit\/([^\s]*)/);if(A&&A[1]){F.webkit=D(A[1]);if(/ Mobile\//.test(C)){F.mobile="Apple";}else{A=C.match(/NokiaN[^\/]*/);if(A){F.mobile=A[0];}}A=C.match(/AdobeAIR\/([^\s]*)/);if(A){F.air=A[0];}}if(!F.webkit){A=C.match(/Opera[\s\/]([^\s]*)/);if(A&&A[1]){F.opera=D(A[1]);A=C.match(/Opera Mini[^;]*/);if(A){F.mobile=A[0];}}else{A=C.match(/MSIE\s([^;]*)/);if(A&&A[1]){F.ie=D(A[1]);}else{A=C.match(/Gecko\/([^\s]*)/);if(A){F.gecko=1;A=C.match(/rv:([^\s\)]*)/);if(A&&A[1]){F.gecko=D(A[1]);}}}}}}return F;}();(function(){YAHOO.namespace("util","widget","example");if("undefined"!==typeof YAHOO_config){var B=YAHOO_config.listener,A=YAHOO.env.listeners,D=true,C;if(B){for(C=0;C<A.length;C++){if(A[C]==B){D=false;break;}}if(D){A.push(B);}}}})();YAHOO.lang=YAHOO.lang||{};(function(){var B=YAHOO.lang,A=Object.prototype,H="[object Array]",C="[object Function]",G="[object Object]",E=[],F=["toString","valueOf"],D={isArray:function(I){return A.toString.apply(I)===H;},isBoolean:function(I){return typeof I==="boolean";},isFunction:function(I){return(typeof I==="function")||A.toString.apply(I)===C;},isNull:function(I){return I===null;},isNumber:function(I){return typeof I==="number"&&isFinite(I);},isObject:function(I){return(I&&(typeof I==="object"||B.isFunction(I)))||false;},isString:function(I){return typeof I==="string";},isUndefined:function(I){return typeof I==="undefined";},_IEEnumFix:(YAHOO.env.ua.ie)?function(K,J){var I,M,L;for(I=0;I<F.length;I=I+1){M=F[I];L=J[M];if(B.isFunction(L)&&L!=A[M]){K[M]=L;}}}:function(){},extend:function(L,M,K){if(!M||!L){throw new Error("extend failed, please check that "+"all dependencies are included.");}var J=function(){},I;J.prototype=M.prototype;L.prototype=new J();L.prototype.constructor=L;L.superclass=M.prototype;if(M.prototype.constructor==A.constructor){M.prototype.constructor=M;}if(K){for(I in K){if(B.hasOwnProperty(K,I)){L.prototype[I]=K[I];}}B._IEEnumFix(L.prototype,K);}},augmentObject:function(M,L){if(!L||!M){throw new Error("Absorb failed, verify dependencies.");}var I=arguments,K,N,J=I[2];if(J&&J!==true){for(K=2;K<I.length;K=K+1){M[I[K]]=L[I[K]];}}else{for(N in L){if(J||!(N in M)){M[N]=L[N];}}B._IEEnumFix(M,L);}},augmentProto:function(L,K){if(!K||!L){throw new Error("Augment failed, verify dependencies.");}var I=[L.prototype,K.prototype],J;for(J=2;J<arguments.length;J=J+1){I.push(arguments[J]);}B.augmentObject.apply(this,I);},dump:function(I,N){var K,M,P=[],Q="{...}",J="f(){...}",O=", ",L=" => ";if(!B.isObject(I)){return I+"";}else{if(I instanceof Date||("nodeType" in I&&"tagName" in I)){return I;}else{if(B.isFunction(I)){return J;}}}N=(B.isNumber(N))?N:3;if(B.isArray(I)){P.push("[");for(K=0,M=I.length;K<M;K=K+1){if(B.isObject(I[K])){P.push((N>0)?B.dump(I[K],N-1):Q);}else{P.push(I[K]);}P.push(O);}if(P.length>1){P.pop();}P.push("]");}else{P.push("{");for(K in I){if(B.hasOwnProperty(I,K)){P.push(K+L);if(B.isObject(I[K])){P.push((N>0)?B.dump(I[K],N-1):Q);}else{P.push(I[K]);}P.push(O);}}if(P.length>1){P.pop();}P.push("}");}return P.join("");},substitute:function(Y,J,R){var N,M,L,U,V,X,T=[],K,O="dump",S=" ",I="{",W="}",Q,P;for(;;){N=Y.lastIndexOf(I);if(N<0){break;}M=Y.indexOf(W,N);if(N+1>=M){break;}K=Y.substring(N+1,M);U=K;X=null;L=U.indexOf(S);if(L>-1){X=U.substring(L+1);U=U.substring(0,L);}V=J[U];if(R){V=R(U,V,X);}if(B.isObject(V)){if(B.isArray(V)){V=B.dump(V,parseInt(X,10));}else{X=X||"";Q=X.indexOf(O);if(Q>-1){X=X.substring(4);}P=V.toString();if(P===G||Q>-1){V=B.dump(V,parseInt(X,10));}else{V=P;}}}else{if(!B.isString(V)&&!B.isNumber(V)){V="~-"+T.length+"-~";T[T.length]=K;}}Y=Y.substring(0,N)+V+Y.substring(M+1);}for(N=T.length-1;N>=0;N=N-1){Y=Y.replace(new RegExp("~-"+N+"-~"),"{"+T[N]+"}","g");}return Y;},trim:function(I){try{return I.replace(/^\s+|\s+$/g,"");}catch(J){return I;}},merge:function(){var L={},J=arguments,I=J.length,K;for(K=0;K<I;K=K+1){B.augmentObject(L,J[K],true);}return L;},later:function(P,J,Q,L,M){P=P||0;J=J||{};var K=Q,O=L,N,I;if(B.isString(Q)){K=J[Q];}if(!K){throw new TypeError("method undefined");}if(O&&!B.isArray(O)){O=[L];}N=function(){K.apply(J,O||E);};I=(M)?setInterval(N,P):setTimeout(N,P);return{interval:M,cancel:function(){if(this.interval){clearInterval(I);}else{clearTimeout(I);}}};},isValue:function(I){return(B.isObject(I)||B.isString(I)||B.isNumber(I)||B.isBoolean(I));}};B.hasOwnProperty=(A.hasOwnProperty)?function(I,J){return I&&I.hasOwnProperty(J);}:function(I,J){return !B.isUndefined(I[J])&&I.constructor.prototype[J]!==I[J];};D.augmentObject(B,D,true);YAHOO.util.Lang=B;B.augment=B.augmentProto;YAHOO.augment=B.augmentProto;YAHOO.extend=B.extend;})();YAHOO.register("yahoo",YAHOO,{version:"2.8.1",build:"19"});
(function(){YAHOO.env._id_counter=YAHOO.env._id_counter||0;var E=YAHOO.util,L=YAHOO.lang,m=YAHOO.env.ua,A=YAHOO.lang.trim,d={},h={},N=/^t(?:able|d|h)$/i,X=/color$/i,K=window.document,W=K.documentElement,e="ownerDocument",n="defaultView",v="documentElement",t="compatMode",b="offsetLeft",P="offsetTop",u="offsetParent",Z="parentNode",l="nodeType",C="tagName",O="scrollLeft",i="scrollTop",Q="getBoundingClientRect",w="getComputedStyle",a="currentStyle",M="CSS1Compat",c="BackCompat",g="class",F="className",J="",B=" ",s="(?:^|\\s)",k="(?= |$)",U="g",p="position",f="fixed",V="relative",j="left",o="top",r="medium",q="borderLeftWidth",R="borderTopWidth",D=m.opera,I=m.webkit,H=m.gecko,T=m.ie;E.Dom={CUSTOM_ATTRIBUTES:(!W.hasAttribute)?{"for":"htmlFor","class":F}:{"htmlFor":"for","className":g},DOT_ATTRIBUTES:{},get:function(z){var AB,x,AA,y,Y,G;if(z){if(z[l]||z.item){return z;}if(typeof z==="string"){AB=z;z=K.getElementById(z);G=(z)?z.attributes:null;if(z&&G&&G.id&&G.id.value===AB){return z;}else{if(z&&K.all){z=null;x=K.all[AB];for(y=0,Y=x.length;y<Y;++y){if(x[y].id===AB){return x[y];}}}}return z;}if(YAHOO.util.Element&&z instanceof YAHOO.util.Element){z=z.get("element");}if("length" in z){AA=[];for(y=0,Y=z.length;y<Y;++y){AA[AA.length]=E.Dom.get(z[y]);}return AA;}return z;}return null;},getComputedStyle:function(G,Y){if(window[w]){return G[e][n][w](G,null)[Y];}else{if(G[a]){return E.Dom.IE_ComputedStyle.get(G,Y);}}},getStyle:function(G,Y){return E.Dom.batch(G,E.Dom._getStyle,Y);},_getStyle:function(){if(window[w]){return function(G,y){y=(y==="float")?y="cssFloat":E.Dom._toCamel(y);var x=G.style[y],Y;if(!x){Y=G[e][n][w](G,null);if(Y){x=Y[y];}}return x;};}else{if(W[a]){return function(G,y){var x;switch(y){case"opacity":x=100;try{x=G.filters["DXImageTransform.Microsoft.Alpha"].opacity;}catch(z){try{x=G.filters("alpha").opacity;}catch(Y){}}return x/100;case"float":y="styleFloat";default:y=E.Dom._toCamel(y);x=G[a]?G[a][y]:null;return(G.style[y]||x);}};}}}(),setStyle:function(G,Y,x){E.Dom.batch(G,E.Dom._setStyle,{prop:Y,val:x});},_setStyle:function(){if(T){return function(Y,G){var x=E.Dom._toCamel(G.prop),y=G.val;if(Y){switch(x){case"opacity":if(L.isString(Y.style.filter)){Y.style.filter="alpha(opacity="+y*100+")";if(!Y[a]||!Y[a].hasLayout){Y.style.zoom=1;}}break;case"float":x="styleFloat";default:Y.style[x]=y;}}else{}};}else{return function(Y,G){var x=E.Dom._toCamel(G.prop),y=G.val;if(Y){if(x=="float"){x="cssFloat";}Y.style[x]=y;}else{}};}}(),getXY:function(G){return E.Dom.batch(G,E.Dom._getXY);},_canPosition:function(G){return(E.Dom._getStyle(G,"display")!=="none"&&E.Dom._inDoc(G));},_getXY:function(){if(K[v][Q]){return function(y){var z,Y,AA,AF,AE,AD,AC,G,x,AB=Math.floor,AG=false;if(E.Dom._canPosition(y)){AA=y[Q]();AF=y[e];z=E.Dom.getDocumentScrollLeft(AF);Y=E.Dom.getDocumentScrollTop(AF);AG=[AB(AA[j]),AB(AA[o])];if(T&&m.ie<8){AE=2;AD=2;AC=AF[t];if(m.ie===6){if(AC!==c){AE=0;AD=0;}}if((AC===c)){G=S(AF[v],q);x=S(AF[v],R);if(G!==r){AE=parseInt(G,10);}if(x!==r){AD=parseInt(x,10);}}AG[0]-=AE;AG[1]-=AD;}if((Y||z)){AG[0]+=z;AG[1]+=Y;}AG[0]=AB(AG[0]);AG[1]=AB(AG[1]);}else{}return AG;};}else{return function(y){var x,Y,AA,AB,AC,z=false,G=y;if(E.Dom._canPosition(y)){z=[y[b],y[P]];x=E.Dom.getDocumentScrollLeft(y[e]);Y=E.Dom.getDocumentScrollTop(y[e]);AC=((H||m.webkit>519)?true:false);while((G=G[u])){z[0]+=G[b];z[1]+=G[P];if(AC){z=E.Dom._calcBorders(G,z);}}if(E.Dom._getStyle(y,p)!==f){G=y;while((G=G[Z])&&G[C]){AA=G[i];AB=G[O];if(H&&(E.Dom._getStyle(G,"overflow")!=="visible")){z=E.Dom._calcBorders(G,z);}if(AA||AB){z[0]-=AB;z[1]-=AA;}}z[0]+=x;z[1]+=Y;}else{if(D){z[0]-=x;z[1]-=Y;}else{if(I||H){z[0]+=x;z[1]+=Y;}}}z[0]=Math.floor(z[0]);z[1]=Math.floor(z[1]);}else{}return z;};}}(),getX:function(G){var Y=function(x){return E.Dom.getXY(x)[0];};return E.Dom.batch(G,Y,E.Dom,true);},getY:function(G){var Y=function(x){return E.Dom.getXY(x)[1];};return E.Dom.batch(G,Y,E.Dom,true);},setXY:function(G,x,Y){E.Dom.batch(G,E.Dom._setXY,{pos:x,noRetry:Y});},_setXY:function(G,z){var AA=E.Dom._getStyle(G,p),y=E.Dom.setStyle,AD=z.pos,Y=z.noRetry,AB=[parseInt(E.Dom.getComputedStyle(G,j),10),parseInt(E.Dom.getComputedStyle(G,o),10)],AC,x;if(AA=="static"){AA=V;y(G,p,AA);}AC=E.Dom._getXY(G);if(!AD||AC===false){return false;}if(isNaN(AB[0])){AB[0]=(AA==V)?0:G[b];}if(isNaN(AB[1])){AB[1]=(AA==V)?0:G[P];}if(AD[0]!==null){y(G,j,AD[0]-AC[0]+AB[0]+"px");}if(AD[1]!==null){y(G,o,AD[1]-AC[1]+AB[1]+"px");}if(!Y){x=E.Dom._getXY(G);if((AD[0]!==null&&x[0]!=AD[0])||(AD[1]!==null&&x[1]!=AD[1])){E.Dom._setXY(G,{pos:AD,noRetry:true});}}},setX:function(Y,G){E.Dom.setXY(Y,[G,null]);},setY:function(G,Y){E.Dom.setXY(G,[null,Y]);},getRegion:function(G){var Y=function(x){var y=false;if(E.Dom._canPosition(x)){y=E.Region.getRegion(x);}else{}return y;};return E.Dom.batch(G,Y,E.Dom,true);},getClientWidth:function(){return E.Dom.getViewportWidth();},getClientHeight:function(){return E.Dom.getViewportHeight();},getElementsByClassName:function(AB,AF,AC,AE,x,AD){AF=AF||"*";AC=(AC)?E.Dom.get(AC):null||K;if(!AC){return[];}var Y=[],G=AC.getElementsByTagName(AF),z=E.Dom.hasClass;for(var y=0,AA=G.length;y<AA;++y){if(z(G[y],AB)){Y[Y.length]=G[y];}}if(AE){E.Dom.batch(Y,AE,x,AD);}return Y;},hasClass:function(Y,G){return E.Dom.batch(Y,E.Dom._hasClass,G);},_hasClass:function(x,Y){var G=false,y;if(x&&Y){y=E.Dom._getAttribute(x,F)||J;if(Y.exec){G=Y.test(y);}else{G=Y&&(B+y+B).indexOf(B+Y+B)>-1;}}else{}return G;},addClass:function(Y,G){return E.Dom.batch(Y,E.Dom._addClass,G);},_addClass:function(x,Y){var G=false,y;if(x&&Y){y=E.Dom._getAttribute(x,F)||J;if(!E.Dom._hasClass(x,Y)){E.Dom.setAttribute(x,F,A(y+B+Y));G=true;}}else{}return G;},removeClass:function(Y,G){return E.Dom.batch(Y,E.Dom._removeClass,G);},_removeClass:function(y,x){var Y=false,AA,z,G;if(y&&x){AA=E.Dom._getAttribute(y,F)||J;E.Dom.setAttribute(y,F,AA.replace(E.Dom._getClassRegex(x),J));z=E.Dom._getAttribute(y,F);if(AA!==z){E.Dom.setAttribute(y,F,A(z));Y=true;if(E.Dom._getAttribute(y,F)===""){G=(y.hasAttribute&&y.hasAttribute(g))?g:F;
y.removeAttribute(G);}}}else{}return Y;},replaceClass:function(x,Y,G){return E.Dom.batch(x,E.Dom._replaceClass,{from:Y,to:G});},_replaceClass:function(y,x){var Y,AB,AA,G=false,z;if(y&&x){AB=x.from;AA=x.to;if(!AA){G=false;}else{if(!AB){G=E.Dom._addClass(y,x.to);}else{if(AB!==AA){z=E.Dom._getAttribute(y,F)||J;Y=(B+z.replace(E.Dom._getClassRegex(AB),B+AA)).split(E.Dom._getClassRegex(AA));Y.splice(1,0,B+AA);E.Dom.setAttribute(y,F,A(Y.join(J)));G=true;}}}}else{}return G;},generateId:function(G,x){x=x||"yui-gen";var Y=function(y){if(y&&y.id){return y.id;}var z=x+YAHOO.env._id_counter++;if(y){if(y[e]&&y[e].getElementById(z)){return E.Dom.generateId(y,z+x);}y.id=z;}return z;};return E.Dom.batch(G,Y,E.Dom,true)||Y.apply(E.Dom,arguments);},isAncestor:function(Y,x){Y=E.Dom.get(Y);x=E.Dom.get(x);var G=false;if((Y&&x)&&(Y[l]&&x[l])){if(Y.contains&&Y!==x){G=Y.contains(x);}else{if(Y.compareDocumentPosition){G=!!(Y.compareDocumentPosition(x)&16);}}}else{}return G;},inDocument:function(G,Y){return E.Dom._inDoc(E.Dom.get(G),Y);},_inDoc:function(Y,x){var G=false;if(Y&&Y[C]){x=x||Y[e];G=E.Dom.isAncestor(x[v],Y);}else{}return G;},getElementsBy:function(Y,AF,AB,AD,y,AC,AE){AF=AF||"*";AB=(AB)?E.Dom.get(AB):null||K;if(!AB){return[];}var x=[],G=AB.getElementsByTagName(AF);for(var z=0,AA=G.length;z<AA;++z){if(Y(G[z])){if(AE){x=G[z];break;}else{x[x.length]=G[z];}}}if(AD){E.Dom.batch(x,AD,y,AC);}return x;},getElementBy:function(x,G,Y){return E.Dom.getElementsBy(x,G,Y,null,null,null,true);},batch:function(x,AB,AA,z){var y=[],Y=(z)?AA:window;x=(x&&(x[C]||x.item))?x:E.Dom.get(x);if(x&&AB){if(x[C]||x.length===undefined){return AB.call(Y,x,AA);}for(var G=0;G<x.length;++G){y[y.length]=AB.call(Y,x[G],AA);}}else{return false;}return y;},getDocumentHeight:function(){var Y=(K[t]!=M||I)?K.body.scrollHeight:W.scrollHeight,G=Math.max(Y,E.Dom.getViewportHeight());return G;},getDocumentWidth:function(){var Y=(K[t]!=M||I)?K.body.scrollWidth:W.scrollWidth,G=Math.max(Y,E.Dom.getViewportWidth());return G;},getViewportHeight:function(){var G=self.innerHeight,Y=K[t];if((Y||T)&&!D){G=(Y==M)?W.clientHeight:K.body.clientHeight;}return G;},getViewportWidth:function(){var G=self.innerWidth,Y=K[t];if(Y||T){G=(Y==M)?W.clientWidth:K.body.clientWidth;}return G;},getAncestorBy:function(G,Y){while((G=G[Z])){if(E.Dom._testElement(G,Y)){return G;}}return null;},getAncestorByClassName:function(Y,G){Y=E.Dom.get(Y);if(!Y){return null;}var x=function(y){return E.Dom.hasClass(y,G);};return E.Dom.getAncestorBy(Y,x);},getAncestorByTagName:function(Y,G){Y=E.Dom.get(Y);if(!Y){return null;}var x=function(y){return y[C]&&y[C].toUpperCase()==G.toUpperCase();};return E.Dom.getAncestorBy(Y,x);},getPreviousSiblingBy:function(G,Y){while(G){G=G.previousSibling;if(E.Dom._testElement(G,Y)){return G;}}return null;},getPreviousSibling:function(G){G=E.Dom.get(G);if(!G){return null;}return E.Dom.getPreviousSiblingBy(G);},getNextSiblingBy:function(G,Y){while(G){G=G.nextSibling;if(E.Dom._testElement(G,Y)){return G;}}return null;},getNextSibling:function(G){G=E.Dom.get(G);if(!G){return null;}return E.Dom.getNextSiblingBy(G);},getFirstChildBy:function(G,x){var Y=(E.Dom._testElement(G.firstChild,x))?G.firstChild:null;return Y||E.Dom.getNextSiblingBy(G.firstChild,x);},getFirstChild:function(G,Y){G=E.Dom.get(G);if(!G){return null;}return E.Dom.getFirstChildBy(G);},getLastChildBy:function(G,x){if(!G){return null;}var Y=(E.Dom._testElement(G.lastChild,x))?G.lastChild:null;return Y||E.Dom.getPreviousSiblingBy(G.lastChild,x);},getLastChild:function(G){G=E.Dom.get(G);return E.Dom.getLastChildBy(G);},getChildrenBy:function(Y,y){var x=E.Dom.getFirstChildBy(Y,y),G=x?[x]:[];E.Dom.getNextSiblingBy(x,function(z){if(!y||y(z)){G[G.length]=z;}return false;});return G;},getChildren:function(G){G=E.Dom.get(G);if(!G){}return E.Dom.getChildrenBy(G);},getDocumentScrollLeft:function(G){G=G||K;return Math.max(G[v].scrollLeft,G.body.scrollLeft);},getDocumentScrollTop:function(G){G=G||K;return Math.max(G[v].scrollTop,G.body.scrollTop);},insertBefore:function(Y,G){Y=E.Dom.get(Y);G=E.Dom.get(G);if(!Y||!G||!G[Z]){return null;}return G[Z].insertBefore(Y,G);},insertAfter:function(Y,G){Y=E.Dom.get(Y);G=E.Dom.get(G);if(!Y||!G||!G[Z]){return null;}if(G.nextSibling){return G[Z].insertBefore(Y,G.nextSibling);}else{return G[Z].appendChild(Y);}},getClientRegion:function(){var x=E.Dom.getDocumentScrollTop(),Y=E.Dom.getDocumentScrollLeft(),y=E.Dom.getViewportWidth()+Y,G=E.Dom.getViewportHeight()+x;return new E.Region(x,y,G,Y);},setAttribute:function(Y,G,x){E.Dom.batch(Y,E.Dom._setAttribute,{attr:G,val:x});},_setAttribute:function(x,Y){var G=E.Dom._toCamel(Y.attr),y=Y.val;if(x&&x.setAttribute){if(E.Dom.DOT_ATTRIBUTES[G]){x[G]=y;}else{G=E.Dom.CUSTOM_ATTRIBUTES[G]||G;x.setAttribute(G,y);}}else{}},getAttribute:function(Y,G){return E.Dom.batch(Y,E.Dom._getAttribute,G);},_getAttribute:function(Y,G){var x;G=E.Dom.CUSTOM_ATTRIBUTES[G]||G;if(Y&&Y.getAttribute){x=Y.getAttribute(G,2);}else{}return x;},_toCamel:function(Y){var x=d;function G(y,z){return z.toUpperCase();}return x[Y]||(x[Y]=Y.indexOf("-")===-1?Y:Y.replace(/-([a-z])/gi,G));},_getClassRegex:function(Y){var G;if(Y!==undefined){if(Y.exec){G=Y;}else{G=h[Y];if(!G){Y=Y.replace(E.Dom._patterns.CLASS_RE_TOKENS,"\\$1");G=h[Y]=new RegExp(s+Y+k,U);}}}return G;},_patterns:{ROOT_TAG:/^body|html$/i,CLASS_RE_TOKENS:/([\.\(\)\^\$\*\+\?\|\[\]\{\}\\])/g},_testElement:function(G,Y){return G&&G[l]==1&&(!Y||Y(G));},_calcBorders:function(x,y){var Y=parseInt(E.Dom[w](x,R),10)||0,G=parseInt(E.Dom[w](x,q),10)||0;if(H){if(N.test(x[C])){Y=0;G=0;}}y[0]+=G;y[1]+=Y;return y;}};var S=E.Dom[w];if(m.opera){E.Dom[w]=function(Y,G){var x=S(Y,G);if(X.test(G)){x=E.Dom.Color.toRGB(x);}return x;};}if(m.webkit){E.Dom[w]=function(Y,G){var x=S(Y,G);if(x==="rgba(0, 0, 0, 0)"){x="transparent";}return x;};}if(m.ie&&m.ie>=8&&K.documentElement.hasAttribute){E.Dom.DOT_ATTRIBUTES.type=true;}})();YAHOO.util.Region=function(C,D,A,B){this.top=C;this.y=C;this[1]=C;this.right=D;this.bottom=A;this.left=B;this.x=B;this[0]=B;
this.width=this.right-this.left;this.height=this.bottom-this.top;};YAHOO.util.Region.prototype.contains=function(A){return(A.left>=this.left&&A.right<=this.right&&A.top>=this.top&&A.bottom<=this.bottom);};YAHOO.util.Region.prototype.getArea=function(){return((this.bottom-this.top)*(this.right-this.left));};YAHOO.util.Region.prototype.intersect=function(E){var C=Math.max(this.top,E.top),D=Math.min(this.right,E.right),A=Math.min(this.bottom,E.bottom),B=Math.max(this.left,E.left);if(A>=C&&D>=B){return new YAHOO.util.Region(C,D,A,B);}else{return null;}};YAHOO.util.Region.prototype.union=function(E){var C=Math.min(this.top,E.top),D=Math.max(this.right,E.right),A=Math.max(this.bottom,E.bottom),B=Math.min(this.left,E.left);return new YAHOO.util.Region(C,D,A,B);};YAHOO.util.Region.prototype.toString=function(){return("Region {"+"top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+", left: "+this.left+", height: "+this.height+", width: "+this.width+"}");};YAHOO.util.Region.getRegion=function(D){var F=YAHOO.util.Dom.getXY(D),C=F[1],E=F[0]+D.offsetWidth,A=F[1]+D.offsetHeight,B=F[0];return new YAHOO.util.Region(C,E,A,B);};YAHOO.util.Point=function(A,B){if(YAHOO.lang.isArray(A)){B=A[1];A=A[0];}YAHOO.util.Point.superclass.constructor.call(this,B,A,B,A);};YAHOO.extend(YAHOO.util.Point,YAHOO.util.Region);(function(){var B=YAHOO.util,A="clientTop",F="clientLeft",J="parentNode",K="right",W="hasLayout",I="px",U="opacity",L="auto",D="borderLeftWidth",G="borderTopWidth",P="borderRightWidth",V="borderBottomWidth",S="visible",Q="transparent",N="height",E="width",H="style",T="currentStyle",R=/^width|height$/,O=/^(\d[.\d]*)+(em|ex|px|gd|rem|vw|vh|vm|ch|mm|cm|in|pt|pc|deg|rad|ms|s|hz|khz|%){1}?/i,M={get:function(X,Z){var Y="",a=X[T][Z];if(Z===U){Y=B.Dom.getStyle(X,U);}else{if(!a||(a.indexOf&&a.indexOf(I)>-1)){Y=a;}else{if(B.Dom.IE_COMPUTED[Z]){Y=B.Dom.IE_COMPUTED[Z](X,Z);}else{if(O.test(a)){Y=B.Dom.IE.ComputedStyle.getPixel(X,Z);}else{Y=a;}}}}return Y;},getOffset:function(Z,e){var b=Z[T][e],X=e.charAt(0).toUpperCase()+e.substr(1),c="offset"+X,Y="pixel"+X,a="",d;if(b==L){d=Z[c];if(d===undefined){a=0;}a=d;if(R.test(e)){Z[H][e]=d;if(Z[c]>d){a=d-(Z[c]-d);}Z[H][e]=L;}}else{if(!Z[H][Y]&&!Z[H][e]){Z[H][e]=b;}a=Z[H][Y];}return a+I;},getBorderWidth:function(X,Z){var Y=null;if(!X[T][W]){X[H].zoom=1;}switch(Z){case G:Y=X[A];break;case V:Y=X.offsetHeight-X.clientHeight-X[A];break;case D:Y=X[F];break;case P:Y=X.offsetWidth-X.clientWidth-X[F];break;}return Y+I;},getPixel:function(Y,X){var a=null,b=Y[T][K],Z=Y[T][X];Y[H][K]=Z;a=Y[H].pixelRight;Y[H][K]=b;return a+I;},getMargin:function(Y,X){var Z;if(Y[T][X]==L){Z=0+I;}else{Z=B.Dom.IE.ComputedStyle.getPixel(Y,X);}return Z;},getVisibility:function(Y,X){var Z;while((Z=Y[T])&&Z[X]=="inherit"){Y=Y[J];}return(Z)?Z[X]:S;},getColor:function(Y,X){return B.Dom.Color.toRGB(Y[T][X])||Q;},getBorderColor:function(Y,X){var Z=Y[T],a=Z[X]||Z.color;return B.Dom.Color.toRGB(B.Dom.Color.toHex(a));}},C={};C.top=C.right=C.bottom=C.left=C[E]=C[N]=M.getOffset;C.color=M.getColor;C[G]=C[P]=C[V]=C[D]=M.getBorderWidth;C.marginTop=C.marginRight=C.marginBottom=C.marginLeft=M.getMargin;C.visibility=M.getVisibility;C.borderColor=C.borderTopColor=C.borderRightColor=C.borderBottomColor=C.borderLeftColor=M.getBorderColor;B.Dom.IE_COMPUTED=C;B.Dom.IE_ComputedStyle=M;})();(function(){var C="toString",A=parseInt,B=RegExp,D=YAHOO.util;D.Dom.Color={KEYWORDS:{black:"000",silver:"c0c0c0",gray:"808080",white:"fff",maroon:"800000",red:"f00",purple:"800080",fuchsia:"f0f",green:"008000",lime:"0f0",olive:"808000",yellow:"ff0",navy:"000080",blue:"00f",teal:"008080",aqua:"0ff"},re_RGB:/^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i,re_hex:/^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i,re_hex3:/([0-9A-F])/gi,toRGB:function(E){if(!D.Dom.Color.re_RGB.test(E)){E=D.Dom.Color.toHex(E);}if(D.Dom.Color.re_hex.exec(E)){E="rgb("+[A(B.$1,16),A(B.$2,16),A(B.$3,16)].join(", ")+")";}return E;},toHex:function(H){H=D.Dom.Color.KEYWORDS[H]||H;if(D.Dom.Color.re_RGB.exec(H)){var G=(B.$1.length===1)?"0"+B.$1:Number(B.$1),F=(B.$2.length===1)?"0"+B.$2:Number(B.$2),E=(B.$3.length===1)?"0"+B.$3:Number(B.$3);H=[G[C](16),F[C](16),E[C](16)].join("");}if(H.length<6){H=H.replace(D.Dom.Color.re_hex3,"$1$1");}if(H!=="transparent"&&H.indexOf("#")<0){H="#"+H;}return H.toLowerCase();}};}());YAHOO.register("dom",YAHOO.util.Dom,{version:"2.8.1",build:"19"});YAHOO.util.CustomEvent=function(D,C,B,A,E){this.type=D;this.scope=C||window;this.silent=B;this.fireOnce=E;this.fired=false;this.firedWith=null;this.signature=A||YAHOO.util.CustomEvent.LIST;this.subscribers=[];if(!this.silent){}var F="_YUICEOnSubscribe";if(D!==F){this.subscribeEvent=new YAHOO.util.CustomEvent(F,this,true);}this.lastError=null;};YAHOO.util.CustomEvent.LIST=0;YAHOO.util.CustomEvent.FLAT=1;YAHOO.util.CustomEvent.prototype={subscribe:function(B,C,D){if(!B){throw new Error("Invalid callback for subscriber to '"+this.type+"'");}if(this.subscribeEvent){this.subscribeEvent.fire(B,C,D);}var A=new YAHOO.util.Subscriber(B,C,D);if(this.fireOnce&&this.fired){this.notify(A,this.firedWith);}else{this.subscribers.push(A);}},unsubscribe:function(D,F){if(!D){return this.unsubscribeAll();}var E=false;for(var B=0,A=this.subscribers.length;B<A;++B){var C=this.subscribers[B];if(C&&C.contains(D,F)){this._delete(B);E=true;}}return E;},fire:function(){this.lastError=null;var H=[],A=this.subscribers.length;var D=[].slice.call(arguments,0),C=true,F,B=false;if(this.fireOnce){if(this.fired){return true;}else{this.firedWith=D;}}this.fired=true;if(!A&&this.silent){return true;}if(!this.silent){}var E=this.subscribers.slice();for(F=0;F<A;++F){var G=E[F];if(!G){B=true;}else{C=this.notify(G,D);if(false===C){if(!this.silent){}break;}}}return(C!==false);},notify:function(F,C){var B,H=null,E=F.getScope(this.scope),A=YAHOO.util.Event.throwErrors;if(!this.silent){}if(this.signature==YAHOO.util.CustomEvent.FLAT){if(C.length>0){H=C[0];}try{B=F.fn.call(E,H,F.obj);}catch(G){this.lastError=G;if(A){throw G;}}}else{try{B=F.fn.call(E,this.type,C,F.obj);}catch(D){this.lastError=D;if(A){throw D;}}}return B;},unsubscribeAll:function(){var A=this.subscribers.length,B;for(B=A-1;B>-1;B--){this._delete(B);}this.subscribers=[];return A;},_delete:function(A){var B=this.subscribers[A];if(B){delete B.fn;delete B.obj;}this.subscribers.splice(A,1);},toString:function(){return"CustomEvent: "+"'"+this.type+"', "+"context: "+this.scope;}};YAHOO.util.Subscriber=function(A,B,C){this.fn=A;this.obj=YAHOO.lang.isUndefined(B)?null:B;this.overrideContext=C;};YAHOO.util.Subscriber.prototype.getScope=function(A){if(this.overrideContext){if(this.overrideContext===true){return this.obj;}else{return this.overrideContext;}}return A;};YAHOO.util.Subscriber.prototype.contains=function(A,B){if(B){return(this.fn==A&&this.obj==B);}else{return(this.fn==A);}};YAHOO.util.Subscriber.prototype.toString=function(){return"Subscriber { obj: "+this.obj+", overrideContext: "+(this.overrideContext||"no")+" }";};if(!YAHOO.util.Event){YAHOO.util.Event=function(){var G=false,H=[],J=[],A=0,E=[],B=0,C={63232:38,63233:40,63234:37,63235:39,63276:33,63277:34,25:9},D=YAHOO.env.ua.ie,F="focusin",I="focusout";return{POLL_RETRYS:500,POLL_INTERVAL:40,EL:0,TYPE:1,FN:2,WFN:3,UNLOAD_OBJ:3,ADJ_SCOPE:4,OBJ:5,OVERRIDE:6,CAPTURE:7,lastError:null,isSafari:YAHOO.env.ua.webkit,webkit:YAHOO.env.ua.webkit,isIE:D,_interval:null,_dri:null,_specialTypes:{focusin:(D?"focusin":"focus"),focusout:(D?"focusout":"blur")},DOMReady:false,throwErrors:false,startInterval:function(){if(!this._interval){this._interval=YAHOO.lang.later(this.POLL_INTERVAL,this,this._tryPreloadAttach,null,true);}},onAvailable:function(Q,M,O,P,N){var K=(YAHOO.lang.isString(Q))?[Q]:Q;for(var L=0;L<K.length;L=L+1){E.push({id:K[L],fn:M,obj:O,overrideContext:P,checkReady:N});}A=this.POLL_RETRYS;this.startInterval();},onContentReady:function(N,K,L,M){this.onAvailable(N,K,L,M,true);},onDOMReady:function(){this.DOMReadyEvent.subscribe.apply(this.DOMReadyEvent,arguments);},_addListener:function(M,K,V,P,T,Y){if(!V||!V.call){return false;}if(this._isValidCollection(M)){var W=true;for(var Q=0,S=M.length;Q<S;++Q){W=this.on(M[Q],K,V,P,T)&&W;}return W;}else{if(YAHOO.lang.isString(M)){var O=this.getEl(M);if(O){M=O;}else{this.onAvailable(M,function(){YAHOO.util.Event._addListener(M,K,V,P,T,Y);});return true;}}}if(!M){return false;}if("unload"==K&&P!==this){J[J.length]=[M,K,V,P,T];return true;}var L=M;if(T){if(T===true){L=P;}else{L=T;}}var N=function(Z){return V.call(L,YAHOO.util.Event.getEvent(Z,M),P);};var X=[M,K,V,N,L,P,T,Y];var R=H.length;H[R]=X;try{this._simpleAdd(M,K,N,Y);}catch(U){this.lastError=U;this.removeListener(M,K,V);return false;}return true;},_getType:function(K){return this._specialTypes[K]||K;},addListener:function(M,P,L,N,O){var K=((P==F||P==I)&&!YAHOO.env.ua.ie)?true:false;return this._addListener(M,this._getType(P),L,N,O,K);},addFocusListener:function(L,K,M,N){return this.on(L,F,K,M,N);},removeFocusListener:function(L,K){return this.removeListener(L,F,K);},addBlurListener:function(L,K,M,N){return this.on(L,I,K,M,N);},removeBlurListener:function(L,K){return this.removeListener(L,I,K);},removeListener:function(L,K,R){var M,P,U;K=this._getType(K);if(typeof L=="string"){L=this.getEl(L);}else{if(this._isValidCollection(L)){var S=true;for(M=L.length-1;M>-1;M--){S=(this.removeListener(L[M],K,R)&&S);}return S;}}if(!R||!R.call){return this.purgeElement(L,false,K);}if("unload"==K){for(M=J.length-1;M>-1;M--){U=J[M];if(U&&U[0]==L&&U[1]==K&&U[2]==R){J.splice(M,1);return true;}}return false;}var N=null;var O=arguments[3];if("undefined"===typeof O){O=this._getCacheIndex(H,L,K,R);}if(O>=0){N=H[O];}if(!L||!N){return false;}var T=N[this.CAPTURE]===true?true:false;try{this._simpleRemove(L,K,N[this.WFN],T);}catch(Q){this.lastError=Q;return false;}delete H[O][this.WFN];delete H[O][this.FN];H.splice(O,1);return true;},getTarget:function(M,L){var K=M.target||M.srcElement;return this.resolveTextNode(K);},resolveTextNode:function(L){try{if(L&&3==L.nodeType){return L.parentNode;}}catch(K){}return L;},getPageX:function(L){var K=L.pageX;if(!K&&0!==K){K=L.clientX||0;if(this.isIE){K+=this._getScrollLeft();}}return K;},getPageY:function(K){var L=K.pageY;if(!L&&0!==L){L=K.clientY||0;if(this.isIE){L+=this._getScrollTop();}}return L;},getXY:function(K){return[this.getPageX(K),this.getPageY(K)];},getRelatedTarget:function(L){var K=L.relatedTarget;if(!K){if(L.type=="mouseout"){K=L.toElement;
}else{if(L.type=="mouseover"){K=L.fromElement;}}}return this.resolveTextNode(K);},getTime:function(M){if(!M.time){var L=new Date().getTime();try{M.time=L;}catch(K){this.lastError=K;return L;}}return M.time;},stopEvent:function(K){this.stopPropagation(K);this.preventDefault(K);},stopPropagation:function(K){if(K.stopPropagation){K.stopPropagation();}else{K.cancelBubble=true;}},preventDefault:function(K){if(K.preventDefault){K.preventDefault();}else{K.returnValue=false;}},getEvent:function(M,K){var L=M||window.event;if(!L){var N=this.getEvent.caller;while(N){L=N.arguments[0];if(L&&Event==L.constructor){break;}N=N.caller;}}return L;},getCharCode:function(L){var K=L.keyCode||L.charCode||0;if(YAHOO.env.ua.webkit&&(K in C)){K=C[K];}return K;},_getCacheIndex:function(M,P,Q,O){for(var N=0,L=M.length;N<L;N=N+1){var K=M[N];if(K&&K[this.FN]==O&&K[this.EL]==P&&K[this.TYPE]==Q){return N;}}return -1;},generateId:function(K){var L=K.id;if(!L){L="yuievtautoid-"+B;++B;K.id=L;}return L;},_isValidCollection:function(L){try{return(L&&typeof L!=="string"&&L.length&&!L.tagName&&!L.alert&&typeof L[0]!=="undefined");}catch(K){return false;}},elCache:{},getEl:function(K){return(typeof K==="string")?document.getElementById(K):K;},clearCache:function(){},DOMReadyEvent:new YAHOO.util.CustomEvent("DOMReady",YAHOO,0,0,1),_load:function(L){if(!G){G=true;var K=YAHOO.util.Event;K._ready();K._tryPreloadAttach();}},_ready:function(L){var K=YAHOO.util.Event;if(!K.DOMReady){K.DOMReady=true;K.DOMReadyEvent.fire();K._simpleRemove(document,"DOMContentLoaded",K._ready);}},_tryPreloadAttach:function(){if(E.length===0){A=0;if(this._interval){this._interval.cancel();this._interval=null;}return;}if(this.locked){return;}if(this.isIE){if(!this.DOMReady){this.startInterval();return;}}this.locked=true;var Q=!G;if(!Q){Q=(A>0&&E.length>0);}var P=[];var R=function(T,U){var S=T;if(U.overrideContext){if(U.overrideContext===true){S=U.obj;}else{S=U.overrideContext;}}U.fn.call(S,U.obj);};var L,K,O,N,M=[];for(L=0,K=E.length;L<K;L=L+1){O=E[L];if(O){N=this.getEl(O.id);if(N){if(O.checkReady){if(G||N.nextSibling||!Q){M.push(O);E[L]=null;}}else{R(N,O);E[L]=null;}}else{P.push(O);}}}for(L=0,K=M.length;L<K;L=L+1){O=M[L];R(this.getEl(O.id),O);}A--;if(Q){for(L=E.length-1;L>-1;L--){O=E[L];if(!O||!O.id){E.splice(L,1);}}this.startInterval();}else{if(this._interval){this._interval.cancel();this._interval=null;}}this.locked=false;},purgeElement:function(O,P,R){var M=(YAHOO.lang.isString(O))?this.getEl(O):O;var Q=this.getListeners(M,R),N,K;if(Q){for(N=Q.length-1;N>-1;N--){var L=Q[N];this.removeListener(M,L.type,L.fn);}}if(P&&M&&M.childNodes){for(N=0,K=M.childNodes.length;N<K;++N){this.purgeElement(M.childNodes[N],P,R);}}},getListeners:function(M,K){var P=[],L;if(!K){L=[H,J];}else{if(K==="unload"){L=[J];}else{K=this._getType(K);L=[H];}}var R=(YAHOO.lang.isString(M))?this.getEl(M):M;for(var O=0;O<L.length;O=O+1){var T=L[O];if(T){for(var Q=0,S=T.length;Q<S;++Q){var N=T[Q];if(N&&N[this.EL]===R&&(!K||K===N[this.TYPE])){P.push({type:N[this.TYPE],fn:N[this.FN],obj:N[this.OBJ],adjust:N[this.OVERRIDE],scope:N[this.ADJ_SCOPE],index:Q});}}}}return(P.length)?P:null;},_unload:function(R){var L=YAHOO.util.Event,O,N,M,Q,P,S=J.slice(),K;for(O=0,Q=J.length;O<Q;++O){M=S[O];if(M){K=window;if(M[L.ADJ_SCOPE]){if(M[L.ADJ_SCOPE]===true){K=M[L.UNLOAD_OBJ];}else{K=M[L.ADJ_SCOPE];}}M[L.FN].call(K,L.getEvent(R,M[L.EL]),M[L.UNLOAD_OBJ]);S[O]=null;}}M=null;K=null;J=null;if(H){for(N=H.length-1;N>-1;N--){M=H[N];if(M){L.removeListener(M[L.EL],M[L.TYPE],M[L.FN],N);}}M=null;}L._simpleRemove(window,"unload",L._unload);},_getScrollLeft:function(){return this._getScroll()[1];},_getScrollTop:function(){return this._getScroll()[0];},_getScroll:function(){var K=document.documentElement,L=document.body;if(K&&(K.scrollTop||K.scrollLeft)){return[K.scrollTop,K.scrollLeft];}else{if(L){return[L.scrollTop,L.scrollLeft];}else{return[0,0];}}},regCE:function(){},_simpleAdd:function(){if(window.addEventListener){return function(M,N,L,K){M.addEventListener(N,L,(K));};}else{if(window.attachEvent){return function(M,N,L,K){M.attachEvent("on"+N,L);};}else{return function(){};}}}(),_simpleRemove:function(){if(window.removeEventListener){return function(M,N,L,K){M.removeEventListener(N,L,(K));};}else{if(window.detachEvent){return function(L,M,K){L.detachEvent("on"+M,K);};}else{return function(){};}}}()};}();(function(){var EU=YAHOO.util.Event;EU.on=EU.addListener;EU.onFocus=EU.addFocusListener;EU.onBlur=EU.addBlurListener;
/* DOMReady: based on work by: Dean Edwards/John Resig/Matthias Miller/Diego Perini */
if(EU.isIE){if(self!==self.top){document.onreadystatechange=function(){if(document.readyState=="complete"){document.onreadystatechange=null;EU._ready();}};}else{YAHOO.util.Event.onDOMReady(YAHOO.util.Event._tryPreloadAttach,YAHOO.util.Event,true);var n=document.createElement("p");EU._dri=setInterval(function(){try{n.doScroll("left");clearInterval(EU._dri);EU._dri=null;EU._ready();n=null;}catch(ex){}},EU.POLL_INTERVAL);}}else{if(EU.webkit&&EU.webkit<525){EU._dri=setInterval(function(){var rs=document.readyState;if("loaded"==rs||"complete"==rs){clearInterval(EU._dri);EU._dri=null;EU._ready();}},EU.POLL_INTERVAL);}else{EU._simpleAdd(document,"DOMContentLoaded",EU._ready);}}EU._simpleAdd(window,"load",EU._load);EU._simpleAdd(window,"unload",EU._unload);EU._tryPreloadAttach();})();}YAHOO.util.EventProvider=function(){};YAHOO.util.EventProvider.prototype={__yui_events:null,__yui_subscribers:null,subscribe:function(A,C,F,E){this.__yui_events=this.__yui_events||{};var D=this.__yui_events[A];if(D){D.subscribe(C,F,E);}else{this.__yui_subscribers=this.__yui_subscribers||{};var B=this.__yui_subscribers;if(!B[A]){B[A]=[];}B[A].push({fn:C,obj:F,overrideContext:E});}},unsubscribe:function(C,E,G){this.__yui_events=this.__yui_events||{};var A=this.__yui_events;if(C){var F=A[C];if(F){return F.unsubscribe(E,G);}}else{var B=true;for(var D in A){if(YAHOO.lang.hasOwnProperty(A,D)){B=B&&A[D].unsubscribe(E,G);}}return B;}return false;},unsubscribeAll:function(A){return this.unsubscribe(A);
},createEvent:function(B,G){this.__yui_events=this.__yui_events||{};var E=G||{},D=this.__yui_events,F;if(D[B]){}else{F=new YAHOO.util.CustomEvent(B,E.scope||this,E.silent,YAHOO.util.CustomEvent.FLAT,E.fireOnce);D[B]=F;if(E.onSubscribeCallback){F.subscribeEvent.subscribe(E.onSubscribeCallback);}this.__yui_subscribers=this.__yui_subscribers||{};var A=this.__yui_subscribers[B];if(A){for(var C=0;C<A.length;++C){F.subscribe(A[C].fn,A[C].obj,A[C].overrideContext);}}}return D[B];},fireEvent:function(B){this.__yui_events=this.__yui_events||{};var D=this.__yui_events[B];if(!D){return null;}var A=[];for(var C=1;C<arguments.length;++C){A.push(arguments[C]);}return D.fire.apply(D,A);},hasEvent:function(A){if(this.__yui_events){if(this.__yui_events[A]){return true;}}return false;}};(function(){var A=YAHOO.util.Event,C=YAHOO.lang;YAHOO.util.KeyListener=function(D,I,E,F){if(!D){}else{if(!I){}else{if(!E){}}}if(!F){F=YAHOO.util.KeyListener.KEYDOWN;}var G=new YAHOO.util.CustomEvent("keyPressed");this.enabledEvent=new YAHOO.util.CustomEvent("enabled");this.disabledEvent=new YAHOO.util.CustomEvent("disabled");if(C.isString(D)){D=document.getElementById(D);}if(C.isFunction(E)){G.subscribe(E);}else{G.subscribe(E.fn,E.scope,E.correctScope);}function H(O,N){if(!I.shift){I.shift=false;}if(!I.alt){I.alt=false;}if(!I.ctrl){I.ctrl=false;}if(O.shiftKey==I.shift&&O.altKey==I.alt&&O.ctrlKey==I.ctrl){var J,M=I.keys,L;if(YAHOO.lang.isArray(M)){for(var K=0;K<M.length;K++){J=M[K];L=A.getCharCode(O);if(J==L){G.fire(L,O);break;}}}else{L=A.getCharCode(O);if(M==L){G.fire(L,O);}}}}this.enable=function(){if(!this.enabled){A.on(D,F,H);this.enabledEvent.fire(I);}this.enabled=true;};this.disable=function(){if(this.enabled){A.removeListener(D,F,H);this.disabledEvent.fire(I);}this.enabled=false;};this.toString=function(){return"KeyListener ["+I.keys+"] "+D.tagName+(D.id?"["+D.id+"]":"");};};var B=YAHOO.util.KeyListener;B.KEYDOWN="keydown";B.KEYUP="keyup";B.KEY={ALT:18,BACK_SPACE:8,CAPS_LOCK:20,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,META:224,NUM_LOCK:144,PAGE_DOWN:34,PAGE_UP:33,PAUSE:19,PRINTSCREEN:44,RIGHT:39,SCROLL_LOCK:145,SHIFT:16,SPACE:32,TAB:9,UP:38};})();YAHOO.register("event",YAHOO.util.Event,{version:"2.8.1",build:"19"});YAHOO.register("yahoo-dom-event", YAHOO, {version: "2.8.1", build: "19"});/*
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.com/yui/license.html
version: 2.8.1
*/
(function(){var B=YAHOO.util;var A=function(D,C,E,F){if(!D){}this.init(D,C,E,F);};A.NAME="Anim";A.prototype={toString:function(){var C=this.getEl()||{};var D=C.id||C.tagName;return(this.constructor.NAME+": "+D);},patterns:{noNegatives:/width|height|opacity|padding/i,offsetAttribute:/^((width|height)|(top|left))$/,defaultUnit:/width|height|top$|bottom$|left$|right$/i,offsetUnit:/\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i},doMethod:function(C,E,D){return this.method(this.currentFrame,E,D-E,this.totalFrames);},setAttribute:function(C,F,E){var D=this.getEl();if(this.patterns.noNegatives.test(C)){F=(F>0)?F:0;}if(C in D&&!("style" in D&&C in D.style)){D[C]=F;}else{B.Dom.setStyle(D,C,F+E);}},getAttribute:function(C){var E=this.getEl();var G=B.Dom.getStyle(E,C);if(G!=="auto"&&!this.patterns.offsetUnit.test(G)){return parseFloat(G);}var D=this.patterns.offsetAttribute.exec(C)||[];var H=!!(D[3]);var F=!!(D[2]);if("style" in E){if(F||(B.Dom.getStyle(E,"position")=="absolute"&&H)){G=E["offset"+D[0].charAt(0).toUpperCase()+D[0].substr(1)];}else{G=0;}}else{if(C in E){G=E[C];}}return G;},getDefaultUnit:function(C){if(this.patterns.defaultUnit.test(C)){return"px";}return"";},setRuntimeAttribute:function(D){var I;var E;var F=this.attributes;this.runtimeAttributes[D]={};var H=function(J){return(typeof J!=="undefined");};if(!H(F[D]["to"])&&!H(F[D]["by"])){return false;}I=(H(F[D]["from"]))?F[D]["from"]:this.getAttribute(D);if(H(F[D]["to"])){E=F[D]["to"];}else{if(H(F[D]["by"])){if(I.constructor==Array){E=[];for(var G=0,C=I.length;G<C;++G){E[G]=I[G]+F[D]["by"][G]*1;}}else{E=I+F[D]["by"]*1;}}}this.runtimeAttributes[D].start=I;this.runtimeAttributes[D].end=E;this.runtimeAttributes[D].unit=(H(F[D].unit))?F[D]["unit"]:this.getDefaultUnit(D);return true;},init:function(E,J,I,C){var D=false;var F=null;var H=0;E=B.Dom.get(E);this.attributes=J||{};this.duration=!YAHOO.lang.isUndefined(I)?I:1;this.method=C||B.Easing.easeNone;this.useSeconds=true;this.currentFrame=0;this.totalFrames=B.AnimMgr.fps;this.setEl=function(M){E=B.Dom.get(M);};this.getEl=function(){return E;};this.isAnimated=function(){return D;};this.getStartTime=function(){return F;};this.runtimeAttributes={};this.animate=function(){if(this.isAnimated()){return false;}this.currentFrame=0;this.totalFrames=(this.useSeconds)?Math.ceil(B.AnimMgr.fps*this.duration):this.duration;if(this.duration===0&&this.useSeconds){this.totalFrames=1;}B.AnimMgr.registerElement(this);return true;};this.stop=function(M){if(!this.isAnimated()){return false;}if(M){this.currentFrame=this.totalFrames;this._onTween.fire();}B.AnimMgr.stop(this);};var L=function(){this.onStart.fire();this.runtimeAttributes={};for(var M in this.attributes){this.setRuntimeAttribute(M);}D=true;H=0;F=new Date();};var K=function(){var O={duration:new Date()-this.getStartTime(),currentFrame:this.currentFrame};O.toString=function(){return("duration: "+O.duration+", currentFrame: "+O.currentFrame);};this.onTween.fire(O);var N=this.runtimeAttributes;for(var M in N){this.setAttribute(M,this.doMethod(M,N[M].start,N[M].end),N[M].unit);}H+=1;};var G=function(){var M=(new Date()-F)/1000;var N={duration:M,frames:H,fps:H/M};N.toString=function(){return("duration: "+N.duration+", frames: "+N.frames+", fps: "+N.fps);};D=false;H=0;this.onComplete.fire(N);};this._onStart=new B.CustomEvent("_start",this,true);this.onStart=new B.CustomEvent("start",this);this.onTween=new B.CustomEvent("tween",this);this._onTween=new B.CustomEvent("_tween",this,true);this.onComplete=new B.CustomEvent("complete",this);this._onComplete=new B.CustomEvent("_complete",this,true);this._onStart.subscribe(L);this._onTween.subscribe(K);this._onComplete.subscribe(G);}};B.Anim=A;})();YAHOO.util.AnimMgr=new function(){var C=null;var B=[];var A=0;this.fps=1000;this.delay=1;this.registerElement=function(F){B[B.length]=F;A+=1;F._onStart.fire();this.start();};this.unRegister=function(G,F){F=F||E(G);if(!G.isAnimated()||F===-1){return false;}G._onComplete.fire();B.splice(F,1);A-=1;if(A<=0){this.stop();}return true;};this.start=function(){if(C===null){C=setInterval(this.run,this.delay);}};this.stop=function(H){if(!H){clearInterval(C);for(var G=0,F=B.length;G<F;++G){this.unRegister(B[0],0);}B=[];C=null;A=0;}else{this.unRegister(H);}};this.run=function(){for(var H=0,F=B.length;H<F;++H){var G=B[H];if(!G||!G.isAnimated()){continue;}if(G.currentFrame<G.totalFrames||G.totalFrames===null){G.currentFrame+=1;if(G.useSeconds){D(G);}G._onTween.fire();}else{YAHOO.util.AnimMgr.stop(G,H);}}};var E=function(H){for(var G=0,F=B.length;G<F;++G){if(B[G]===H){return G;}}return -1;};var D=function(G){var J=G.totalFrames;var I=G.currentFrame;var H=(G.currentFrame*G.duration*1000/G.totalFrames);var F=(new Date()-G.getStartTime());var K=0;if(F<G.duration*1000){K=Math.round((F/H-1)*G.currentFrame);}else{K=J-(I+1);}if(K>0&&isFinite(K)){if(G.currentFrame+K>=J){K=J-(I+1);}G.currentFrame+=K;}};this._queue=B;this._getIndex=E;};YAHOO.util.Bezier=new function(){this.getPosition=function(E,D){var F=E.length;var C=[];for(var B=0;B<F;++B){C[B]=[E[B][0],E[B][1]];}for(var A=1;A<F;++A){for(B=0;B<F-A;++B){C[B][0]=(1-D)*C[B][0]+D*C[parseInt(B+1,10)][0];C[B][1]=(1-D)*C[B][1]+D*C[parseInt(B+1,10)][1];}}return[C[0][0],C[0][1]];};};(function(){var A=function(F,E,G,H){A.superclass.constructor.call(this,F,E,G,H);};A.NAME="ColorAnim";A.DEFAULT_BGCOLOR="#fff";var C=YAHOO.util;YAHOO.extend(A,C.Anim);var D=A.superclass;var B=A.prototype;B.patterns.color=/color$/i;B.patterns.rgb=/^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i;B.patterns.hex=/^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i;B.patterns.hex3=/^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i;B.patterns.transparent=/^transparent|rgba\(0, 0, 0, 0\)$/;B.parseColor=function(E){if(E.length==3){return E;}var F=this.patterns.hex.exec(E);if(F&&F.length==4){return[parseInt(F[1],16),parseInt(F[2],16),parseInt(F[3],16)];}F=this.patterns.rgb.exec(E);if(F&&F.length==4){return[parseInt(F[1],10),parseInt(F[2],10),parseInt(F[3],10)];}F=this.patterns.hex3.exec(E);if(F&&F.length==4){return[parseInt(F[1]+F[1],16),parseInt(F[2]+F[2],16),parseInt(F[3]+F[3],16)];
}return null;};B.getAttribute=function(E){var G=this.getEl();if(this.patterns.color.test(E)){var I=YAHOO.util.Dom.getStyle(G,E);var H=this;if(this.patterns.transparent.test(I)){var F=YAHOO.util.Dom.getAncestorBy(G,function(J){return !H.patterns.transparent.test(I);});if(F){I=C.Dom.getStyle(F,E);}else{I=A.DEFAULT_BGCOLOR;}}}else{I=D.getAttribute.call(this,E);}return I;};B.doMethod=function(F,J,G){var I;if(this.patterns.color.test(F)){I=[];for(var H=0,E=J.length;H<E;++H){I[H]=D.doMethod.call(this,F,J[H],G[H]);}I="rgb("+Math.floor(I[0])+","+Math.floor(I[1])+","+Math.floor(I[2])+")";}else{I=D.doMethod.call(this,F,J,G);}return I;};B.setRuntimeAttribute=function(F){D.setRuntimeAttribute.call(this,F);if(this.patterns.color.test(F)){var H=this.attributes;var J=this.parseColor(this.runtimeAttributes[F].start);var G=this.parseColor(this.runtimeAttributes[F].end);if(typeof H[F]["to"]==="undefined"&&typeof H[F]["by"]!=="undefined"){G=this.parseColor(H[F].by);for(var I=0,E=J.length;I<E;++I){G[I]=J[I]+G[I];}}this.runtimeAttributes[F].start=J;this.runtimeAttributes[F].end=G;}};C.ColorAnim=A;})();
/*
TERMS OF USE - EASING EQUATIONS
Open source under the BSD License.
Copyright 2001 Robert Penner All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
 * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
YAHOO.util.Easing={easeNone:function(B,A,D,C){return D*B/C+A;},easeIn:function(B,A,D,C){return D*(B/=C)*B+A;},easeOut:function(B,A,D,C){return -D*(B/=C)*(B-2)+A;},easeBoth:function(B,A,D,C){if((B/=C/2)<1){return D/2*B*B+A;}return -D/2*((--B)*(B-2)-1)+A;},easeInStrong:function(B,A,D,C){return D*(B/=C)*B*B*B+A;},easeOutStrong:function(B,A,D,C){return -D*((B=B/C-1)*B*B*B-1)+A;},easeBothStrong:function(B,A,D,C){if((B/=C/2)<1){return D/2*B*B*B*B+A;}return -D/2*((B-=2)*B*B*B-2)+A;},elasticIn:function(C,A,G,F,B,E){if(C==0){return A;}if((C/=F)==1){return A+G;}if(!E){E=F*0.3;}if(!B||B<Math.abs(G)){B=G;var D=E/4;}else{var D=E/(2*Math.PI)*Math.asin(G/B);}return -(B*Math.pow(2,10*(C-=1))*Math.sin((C*F-D)*(2*Math.PI)/E))+A;},elasticOut:function(C,A,G,F,B,E){if(C==0){return A;}if((C/=F)==1){return A+G;}if(!E){E=F*0.3;}if(!B||B<Math.abs(G)){B=G;var D=E/4;}else{var D=E/(2*Math.PI)*Math.asin(G/B);}return B*Math.pow(2,-10*C)*Math.sin((C*F-D)*(2*Math.PI)/E)+G+A;},elasticBoth:function(C,A,G,F,B,E){if(C==0){return A;}if((C/=F/2)==2){return A+G;}if(!E){E=F*(0.3*1.5);}if(!B||B<Math.abs(G)){B=G;var D=E/4;}else{var D=E/(2*Math.PI)*Math.asin(G/B);}if(C<1){return -0.5*(B*Math.pow(2,10*(C-=1))*Math.sin((C*F-D)*(2*Math.PI)/E))+A;}return B*Math.pow(2,-10*(C-=1))*Math.sin((C*F-D)*(2*Math.PI)/E)*0.5+G+A;},backIn:function(B,A,E,D,C){if(typeof C=="undefined"){C=1.70158;}return E*(B/=D)*B*((C+1)*B-C)+A;},backOut:function(B,A,E,D,C){if(typeof C=="undefined"){C=1.70158;}return E*((B=B/D-1)*B*((C+1)*B+C)+1)+A;},backBoth:function(B,A,E,D,C){if(typeof C=="undefined"){C=1.70158;}if((B/=D/2)<1){return E/2*(B*B*(((C*=(1.525))+1)*B-C))+A;}return E/2*((B-=2)*B*(((C*=(1.525))+1)*B+C)+2)+A;},bounceIn:function(B,A,D,C){return D-YAHOO.util.Easing.bounceOut(C-B,0,D,C)+A;},bounceOut:function(B,A,D,C){if((B/=C)<(1/2.75)){return D*(7.5625*B*B)+A;}else{if(B<(2/2.75)){return D*(7.5625*(B-=(1.5/2.75))*B+0.75)+A;}else{if(B<(2.5/2.75)){return D*(7.5625*(B-=(2.25/2.75))*B+0.9375)+A;}}}return D*(7.5625*(B-=(2.625/2.75))*B+0.984375)+A;},bounceBoth:function(B,A,D,C){if(B<C/2){return YAHOO.util.Easing.bounceIn(B*2,0,D,C)*0.5+A;}return YAHOO.util.Easing.bounceOut(B*2-C,0,D,C)*0.5+D*0.5+A;}};(function(){var A=function(H,G,I,J){if(H){A.superclass.constructor.call(this,H,G,I,J);}};A.NAME="Motion";var E=YAHOO.util;YAHOO.extend(A,E.ColorAnim);var F=A.superclass;var C=A.prototype;C.patterns.points=/^points$/i;C.setAttribute=function(G,I,H){if(this.patterns.points.test(G)){H=H||"px";F.setAttribute.call(this,"left",I[0],H);F.setAttribute.call(this,"top",I[1],H);}else{F.setAttribute.call(this,G,I,H);}};C.getAttribute=function(G){if(this.patterns.points.test(G)){var H=[F.getAttribute.call(this,"left"),F.getAttribute.call(this,"top")];}else{H=F.getAttribute.call(this,G);}return H;};C.doMethod=function(G,K,H){var J=null;if(this.patterns.points.test(G)){var I=this.method(this.currentFrame,0,100,this.totalFrames)/100;J=E.Bezier.getPosition(this.runtimeAttributes[G],I);}else{J=F.doMethod.call(this,G,K,H);}return J;};C.setRuntimeAttribute=function(P){if(this.patterns.points.test(P)){var H=this.getEl();var J=this.attributes;var G;var L=J["points"]["control"]||[];var I;var M,O;if(L.length>0&&!(L[0] instanceof Array)){L=[L];}else{var K=[];for(M=0,O=L.length;M<O;++M){K[M]=L[M];}L=K;}if(E.Dom.getStyle(H,"position")=="static"){E.Dom.setStyle(H,"position","relative");}if(D(J["points"]["from"])){E.Dom.setXY(H,J["points"]["from"]);
}else{E.Dom.setXY(H,E.Dom.getXY(H));}G=this.getAttribute("points");if(D(J["points"]["to"])){I=B.call(this,J["points"]["to"],G);var N=E.Dom.getXY(this.getEl());for(M=0,O=L.length;M<O;++M){L[M]=B.call(this,L[M],G);}}else{if(D(J["points"]["by"])){I=[G[0]+J["points"]["by"][0],G[1]+J["points"]["by"][1]];for(M=0,O=L.length;M<O;++M){L[M]=[G[0]+L[M][0],G[1]+L[M][1]];}}}this.runtimeAttributes[P]=[G];if(L.length>0){this.runtimeAttributes[P]=this.runtimeAttributes[P].concat(L);}this.runtimeAttributes[P][this.runtimeAttributes[P].length]=I;}else{F.setRuntimeAttribute.call(this,P);}};var B=function(G,I){var H=E.Dom.getXY(this.getEl());G=[G[0]-H[0]+I[0],G[1]-H[1]+I[1]];return G;};var D=function(G){return(typeof G!=="undefined");};E.Motion=A;})();(function(){var D=function(F,E,G,H){if(F){D.superclass.constructor.call(this,F,E,G,H);}};D.NAME="Scroll";var B=YAHOO.util;YAHOO.extend(D,B.ColorAnim);var C=D.superclass;var A=D.prototype;A.doMethod=function(E,H,F){var G=null;if(E=="scroll"){G=[this.method(this.currentFrame,H[0],F[0]-H[0],this.totalFrames),this.method(this.currentFrame,H[1],F[1]-H[1],this.totalFrames)];}else{G=C.doMethod.call(this,E,H,F);}return G;};A.getAttribute=function(E){var G=null;var F=this.getEl();if(E=="scroll"){G=[F.scrollLeft,F.scrollTop];}else{G=C.getAttribute.call(this,E);}return G;};A.setAttribute=function(E,H,G){var F=this.getEl();if(E=="scroll"){F.scrollLeft=H[0];F.scrollTop=H[1];}else{C.setAttribute.call(this,E,H,G);}};B.Scroll=D;})();YAHOO.register("animation",YAHOO.util.Anim,{version:"2.8.1",build:"19"});/*
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.com/yui/license.html
version: 2.8.1
*/
if(!YAHOO.util.DragDropMgr){YAHOO.util.DragDropMgr=function(){var A=YAHOO.util.Event,B=YAHOO.util.Dom;return{useShim:false,_shimActive:false,_shimState:false,_debugShim:false,_createShim:function(){var C=document.createElement("div");C.id="yui-ddm-shim";if(document.body.firstChild){document.body.insertBefore(C,document.body.firstChild);}else{document.body.appendChild(C);}C.style.display="none";C.style.backgroundColor="red";C.style.position="absolute";C.style.zIndex="99999";B.setStyle(C,"opacity","0");this._shim=C;A.on(C,"mouseup",this.handleMouseUp,this,true);A.on(C,"mousemove",this.handleMouseMove,this,true);A.on(window,"scroll",this._sizeShim,this,true);},_sizeShim:function(){if(this._shimActive){var C=this._shim;C.style.height=B.getDocumentHeight()+"px";C.style.width=B.getDocumentWidth()+"px";C.style.top="0";C.style.left="0";}},_activateShim:function(){if(this.useShim){if(!this._shim){this._createShim();}this._shimActive=true;var C=this._shim,D="0";if(this._debugShim){D=".5";}B.setStyle(C,"opacity",D);this._sizeShim();C.style.display="block";}},_deactivateShim:function(){this._shim.style.display="none";this._shimActive=false;},_shim:null,ids:{},handleIds:{},dragCurrent:null,dragOvers:{},deltaX:0,deltaY:0,preventDefault:true,stopPropagation:true,initialized:false,locked:false,interactionInfo:null,init:function(){this.initialized=true;},POINT:0,INTERSECT:1,STRICT_INTERSECT:2,mode:0,_execOnAll:function(E,D){for(var F in this.ids){for(var C in this.ids[F]){var G=this.ids[F][C];if(!this.isTypeOfDD(G)){continue;}G[E].apply(G,D);}}},_onLoad:function(){this.init();A.on(document,"mouseup",this.handleMouseUp,this,true);A.on(document,"mousemove",this.handleMouseMove,this,true);A.on(window,"unload",this._onUnload,this,true);A.on(window,"resize",this._onResize,this,true);},_onResize:function(C){this._execOnAll("resetConstraints",[]);},lock:function(){this.locked=true;},unlock:function(){this.locked=false;},isLocked:function(){return this.locked;},locationCache:{},useCache:true,clickPixelThresh:3,clickTimeThresh:1000,dragThreshMet:false,clickTimeout:null,startX:0,startY:0,fromTimeout:false,regDragDrop:function(D,C){if(!this.initialized){this.init();}if(!this.ids[C]){this.ids[C]={};}this.ids[C][D.id]=D;},removeDDFromGroup:function(E,C){if(!this.ids[C]){this.ids[C]={};}var D=this.ids[C];if(D&&D[E.id]){delete D[E.id];}},_remove:function(E){for(var D in E.groups){if(D){var C=this.ids[D];if(C&&C[E.id]){delete C[E.id];}}}delete this.handleIds[E.id];},regHandle:function(D,C){if(!this.handleIds[D]){this.handleIds[D]={};}this.handleIds[D][C]=C;},isDragDrop:function(C){return(this.getDDById(C))?true:false;},getRelated:function(H,D){var G=[];for(var F in H.groups){for(var E in this.ids[F]){var C=this.ids[F][E];if(!this.isTypeOfDD(C)){continue;}if(!D||C.isTarget){G[G.length]=C;}}}return G;},isLegalTarget:function(G,F){var D=this.getRelated(G,true);for(var E=0,C=D.length;E<C;++E){if(D[E].id==F.id){return true;}}return false;},isTypeOfDD:function(C){return(C&&C.__ygDragDrop);},isHandle:function(D,C){return(this.handleIds[D]&&this.handleIds[D][C]);},getDDById:function(D){for(var C in this.ids){if(this.ids[C][D]){return this.ids[C][D];}}return null;},handleMouseDown:function(E,D){this.currentTarget=YAHOO.util.Event.getTarget(E);this.dragCurrent=D;var C=D.getEl();this.startX=YAHOO.util.Event.getPageX(E);this.startY=YAHOO.util.Event.getPageY(E);this.deltaX=this.startX-C.offsetLeft;this.deltaY=this.startY-C.offsetTop;this.dragThreshMet=false;this.clickTimeout=setTimeout(function(){var F=YAHOO.util.DDM;F.startDrag(F.startX,F.startY);F.fromTimeout=true;},this.clickTimeThresh);},startDrag:function(C,E){if(this.dragCurrent&&this.dragCurrent.useShim){this._shimState=this.useShim;this.useShim=true;}this._activateShim();clearTimeout(this.clickTimeout);var D=this.dragCurrent;if(D&&D.events.b4StartDrag){D.b4StartDrag(C,E);D.fireEvent("b4StartDragEvent",{x:C,y:E});}if(D&&D.events.startDrag){D.startDrag(C,E);D.fireEvent("startDragEvent",{x:C,y:E});}this.dragThreshMet=true;},handleMouseUp:function(C){if(this.dragCurrent){clearTimeout(this.clickTimeout);if(this.dragThreshMet){if(this.fromTimeout){this.fromTimeout=false;this.handleMouseMove(C);}this.fromTimeout=false;this.fireEvents(C,true);}else{}this.stopDrag(C);this.stopEvent(C);}},stopEvent:function(C){if(this.stopPropagation){YAHOO.util.Event.stopPropagation(C);}if(this.preventDefault){YAHOO.util.Event.preventDefault(C);}},stopDrag:function(E,D){var C=this.dragCurrent;if(C&&!D){if(this.dragThreshMet){if(C.events.b4EndDrag){C.b4EndDrag(E);C.fireEvent("b4EndDragEvent",{e:E});}if(C.events.endDrag){C.endDrag(E);C.fireEvent("endDragEvent",{e:E});}}if(C.events.mouseUp){C.onMouseUp(E);C.fireEvent("mouseUpEvent",{e:E});}}if(this._shimActive){this._deactivateShim();if(this.dragCurrent&&this.dragCurrent.useShim){this.useShim=this._shimState;this._shimState=false;}}this.dragCurrent=null;this.dragOvers={};},handleMouseMove:function(F){var C=this.dragCurrent;if(C){if(YAHOO.util.Event.isIE&&!F.button){this.stopEvent(F);return this.handleMouseUp(F);}else{if(F.clientX<0||F.clientY<0){}}if(!this.dragThreshMet){var E=Math.abs(this.startX-YAHOO.util.Event.getPageX(F));var D=Math.abs(this.startY-YAHOO.util.Event.getPageY(F));if(E>this.clickPixelThresh||D>this.clickPixelThresh){this.startDrag(this.startX,this.startY);}}if(this.dragThreshMet){if(C&&C.events.b4Drag){C.b4Drag(F);C.fireEvent("b4DragEvent",{e:F});}if(C&&C.events.drag){C.onDrag(F);C.fireEvent("dragEvent",{e:F});}if(C){this.fireEvents(F,false);}}this.stopEvent(F);}},fireEvents:function(V,L){var a=this.dragCurrent;if(!a||a.isLocked()||a.dragOnly){return;}var N=YAHOO.util.Event.getPageX(V),M=YAHOO.util.Event.getPageY(V),P=new YAHOO.util.Point(N,M),K=a.getTargetCoord(P.x,P.y),F=a.getDragEl(),E=["out","over","drop","enter"],U=new YAHOO.util.Region(K.y,K.x+F.offsetWidth,K.y+F.offsetHeight,K.x),I=[],D={},Q=[],c={outEvts:[],overEvts:[],dropEvts:[],enterEvts:[]};for(var S in this.dragOvers){var d=this.dragOvers[S];if(!this.isTypeOfDD(d)){continue;
}if(!this.isOverTarget(P,d,this.mode,U)){c.outEvts.push(d);}I[S]=true;delete this.dragOvers[S];}for(var R in a.groups){if("string"!=typeof R){continue;}for(S in this.ids[R]){var G=this.ids[R][S];if(!this.isTypeOfDD(G)){continue;}if(G.isTarget&&!G.isLocked()&&G!=a){if(this.isOverTarget(P,G,this.mode,U)){D[R]=true;if(L){c.dropEvts.push(G);}else{if(!I[G.id]){c.enterEvts.push(G);}else{c.overEvts.push(G);}this.dragOvers[G.id]=G;}}}}}this.interactionInfo={out:c.outEvts,enter:c.enterEvts,over:c.overEvts,drop:c.dropEvts,point:P,draggedRegion:U,sourceRegion:this.locationCache[a.id],validDrop:L};for(var C in D){Q.push(C);}if(L&&!c.dropEvts.length){this.interactionInfo.validDrop=false;if(a.events.invalidDrop){a.onInvalidDrop(V);a.fireEvent("invalidDropEvent",{e:V});}}for(S=0;S<E.length;S++){var Y=null;if(c[E[S]+"Evts"]){Y=c[E[S]+"Evts"];}if(Y&&Y.length){var H=E[S].charAt(0).toUpperCase()+E[S].substr(1),X="onDrag"+H,J="b4Drag"+H,O="drag"+H+"Event",W="drag"+H;if(this.mode){if(a.events[J]){a[J](V,Y,Q);a.fireEvent(J+"Event",{event:V,info:Y,group:Q});}if(a.events[W]){a[X](V,Y,Q);a.fireEvent(O,{event:V,info:Y,group:Q});}}else{for(var Z=0,T=Y.length;Z<T;++Z){if(a.events[J]){a[J](V,Y[Z].id,Q[0]);a.fireEvent(J+"Event",{event:V,info:Y[Z].id,group:Q[0]});}if(a.events[W]){a[X](V,Y[Z].id,Q[0]);a.fireEvent(O,{event:V,info:Y[Z].id,group:Q[0]});}}}}}},getBestMatch:function(E){var G=null;var D=E.length;if(D==1){G=E[0];}else{for(var F=0;F<D;++F){var C=E[F];if(this.mode==this.INTERSECT&&C.cursorIsOver){G=C;break;}else{if(!G||!G.overlap||(C.overlap&&G.overlap.getArea()<C.overlap.getArea())){G=C;}}}}return G;},refreshCache:function(D){var F=D||this.ids;for(var C in F){if("string"!=typeof C){continue;}for(var E in this.ids[C]){var G=this.ids[C][E];if(this.isTypeOfDD(G)){var H=this.getLocation(G);if(H){this.locationCache[G.id]=H;}else{delete this.locationCache[G.id];}}}}},verifyEl:function(D){try{if(D){var C=D.offsetParent;if(C){return true;}}}catch(E){}return false;},getLocation:function(H){if(!this.isTypeOfDD(H)){return null;}var F=H.getEl(),K,E,D,M,L,N,C,J,G;try{K=YAHOO.util.Dom.getXY(F);}catch(I){}if(!K){return null;}E=K[0];D=E+F.offsetWidth;M=K[1];L=M+F.offsetHeight;N=M-H.padding[0];C=D+H.padding[1];J=L+H.padding[2];G=E-H.padding[3];return new YAHOO.util.Region(N,C,J,G);},isOverTarget:function(K,C,E,F){var G=this.locationCache[C.id];if(!G||!this.useCache){G=this.getLocation(C);this.locationCache[C.id]=G;}if(!G){return false;}C.cursorIsOver=G.contains(K);var J=this.dragCurrent;if(!J||(!E&&!J.constrainX&&!J.constrainY)){return C.cursorIsOver;}C.overlap=null;if(!F){var H=J.getTargetCoord(K.x,K.y);var D=J.getDragEl();F=new YAHOO.util.Region(H.y,H.x+D.offsetWidth,H.y+D.offsetHeight,H.x);}var I=F.intersect(G);if(I){C.overlap=I;return(E)?true:C.cursorIsOver;}else{return false;}},_onUnload:function(D,C){this.unregAll();},unregAll:function(){if(this.dragCurrent){this.stopDrag();this.dragCurrent=null;}this._execOnAll("unreg",[]);this.ids={};},elementCache:{},getElWrapper:function(D){var C=this.elementCache[D];if(!C||!C.el){C=this.elementCache[D]=new this.ElementWrapper(YAHOO.util.Dom.get(D));}return C;},getElement:function(C){return YAHOO.util.Dom.get(C);},getCss:function(D){var C=YAHOO.util.Dom.get(D);return(C)?C.style:null;},ElementWrapper:function(C){this.el=C||null;this.id=this.el&&C.id;this.css=this.el&&C.style;},getPosX:function(C){return YAHOO.util.Dom.getX(C);},getPosY:function(C){return YAHOO.util.Dom.getY(C);},swapNode:function(E,C){if(E.swapNode){E.swapNode(C);}else{var F=C.parentNode;var D=C.nextSibling;if(D==E){F.insertBefore(E,C);}else{if(C==E.nextSibling){F.insertBefore(C,E);}else{E.parentNode.replaceChild(C,E);F.insertBefore(E,D);}}}},getScroll:function(){var E,C,F=document.documentElement,D=document.body;if(F&&(F.scrollTop||F.scrollLeft)){E=F.scrollTop;C=F.scrollLeft;}else{if(D){E=D.scrollTop;C=D.scrollLeft;}else{}}return{top:E,left:C};},getStyle:function(D,C){return YAHOO.util.Dom.getStyle(D,C);},getScrollTop:function(){return this.getScroll().top;},getScrollLeft:function(){return this.getScroll().left;},moveToEl:function(C,E){var D=YAHOO.util.Dom.getXY(E);YAHOO.util.Dom.setXY(C,D);},getClientHeight:function(){return YAHOO.util.Dom.getViewportHeight();},getClientWidth:function(){return YAHOO.util.Dom.getViewportWidth();},numericSort:function(D,C){return(D-C);},_timeoutCount:0,_addListeners:function(){var C=YAHOO.util.DDM;if(YAHOO.util.Event&&document){C._onLoad();}else{if(C._timeoutCount>2000){}else{setTimeout(C._addListeners,10);if(document&&document.body){C._timeoutCount+=1;}}}},handleWasClicked:function(C,E){if(this.isHandle(E,C.id)){return true;}else{var D=C.parentNode;while(D){if(this.isHandle(E,D.id)){return true;}else{D=D.parentNode;}}}return false;}};}();YAHOO.util.DDM=YAHOO.util.DragDropMgr;YAHOO.util.DDM._addListeners();}(function(){var A=YAHOO.util.Event;var B=YAHOO.util.Dom;YAHOO.util.DragDrop=function(E,C,D){if(E){this.init(E,C,D);}};YAHOO.util.DragDrop.prototype={events:null,on:function(){this.subscribe.apply(this,arguments);},id:null,config:null,dragElId:null,handleElId:null,invalidHandleTypes:null,invalidHandleIds:null,invalidHandleClasses:null,startPageX:0,startPageY:0,groups:null,locked:false,lock:function(){this.locked=true;},unlock:function(){this.locked=false;},isTarget:true,padding:null,dragOnly:false,useShim:false,_domRef:null,__ygDragDrop:true,constrainX:false,constrainY:false,minX:0,maxX:0,minY:0,maxY:0,deltaX:0,deltaY:0,maintainOffset:false,xTicks:null,yTicks:null,primaryButtonOnly:true,available:false,hasOuterHandles:false,cursorIsOver:false,overlap:null,b4StartDrag:function(C,D){},startDrag:function(C,D){},b4Drag:function(C){},onDrag:function(C){},onDragEnter:function(C,D){},b4DragOver:function(C){},onDragOver:function(C,D){},b4DragOut:function(C){},onDragOut:function(C,D){},b4DragDrop:function(C){},onDragDrop:function(C,D){},onInvalidDrop:function(C){},b4EndDrag:function(C){},endDrag:function(C){},b4MouseDown:function(C){},onMouseDown:function(C){},onMouseUp:function(C){},onAvailable:function(){},getEl:function(){if(!this._domRef){this._domRef=B.get(this.id);
}return this._domRef;},getDragEl:function(){return B.get(this.dragElId);},init:function(F,C,D){this.initTarget(F,C,D);A.on(this._domRef||this.id,"mousedown",this.handleMouseDown,this,true);for(var E in this.events){this.createEvent(E+"Event");}},initTarget:function(E,C,D){this.config=D||{};this.events={};this.DDM=YAHOO.util.DDM;this.groups={};if(typeof E!=="string"){this._domRef=E;E=B.generateId(E);}this.id=E;this.addToGroup((C)?C:"default");this.handleElId=E;A.onAvailable(E,this.handleOnAvailable,this,true);this.setDragElId(E);this.invalidHandleTypes={A:"A"};this.invalidHandleIds={};this.invalidHandleClasses=[];this.applyConfig();},applyConfig:function(){this.events={mouseDown:true,b4MouseDown:true,mouseUp:true,b4StartDrag:true,startDrag:true,b4EndDrag:true,endDrag:true,drag:true,b4Drag:true,invalidDrop:true,b4DragOut:true,dragOut:true,dragEnter:true,b4DragOver:true,dragOver:true,b4DragDrop:true,dragDrop:true};if(this.config.events){for(var C in this.config.events){if(this.config.events[C]===false){this.events[C]=false;}}}this.padding=this.config.padding||[0,0,0,0];this.isTarget=(this.config.isTarget!==false);this.maintainOffset=(this.config.maintainOffset);this.primaryButtonOnly=(this.config.primaryButtonOnly!==false);this.dragOnly=((this.config.dragOnly===true)?true:false);this.useShim=((this.config.useShim===true)?true:false);},handleOnAvailable:function(){this.available=true;this.resetConstraints();this.onAvailable();},setPadding:function(E,C,F,D){if(!C&&0!==C){this.padding=[E,E,E,E];}else{if(!F&&0!==F){this.padding=[E,C,E,C];}else{this.padding=[E,C,F,D];}}},setInitPosition:function(F,E){var G=this.getEl();if(!this.DDM.verifyEl(G)){if(G&&G.style&&(G.style.display=="none")){}else{}return;}var D=F||0;var C=E||0;var H=B.getXY(G);this.initPageX=H[0]-D;this.initPageY=H[1]-C;this.lastPageX=H[0];this.lastPageY=H[1];this.setStartPosition(H);},setStartPosition:function(D){var C=D||B.getXY(this.getEl());this.deltaSetXY=null;this.startPageX=C[0];this.startPageY=C[1];},addToGroup:function(C){this.groups[C]=true;this.DDM.regDragDrop(this,C);},removeFromGroup:function(C){if(this.groups[C]){delete this.groups[C];}this.DDM.removeDDFromGroup(this,C);},setDragElId:function(C){this.dragElId=C;},setHandleElId:function(C){if(typeof C!=="string"){C=B.generateId(C);}this.handleElId=C;this.DDM.regHandle(this.id,C);},setOuterHandleElId:function(C){if(typeof C!=="string"){C=B.generateId(C);}A.on(C,"mousedown",this.handleMouseDown,this,true);this.setHandleElId(C);this.hasOuterHandles=true;},unreg:function(){A.removeListener(this.id,"mousedown",this.handleMouseDown);this._domRef=null;this.DDM._remove(this);},isLocked:function(){return(this.DDM.isLocked()||this.locked);},handleMouseDown:function(J,I){var D=J.which||J.button;if(this.primaryButtonOnly&&D>1){return;}if(this.isLocked()){return;}var C=this.b4MouseDown(J),F=true;if(this.events.b4MouseDown){F=this.fireEvent("b4MouseDownEvent",J);}var E=this.onMouseDown(J),H=true;if(this.events.mouseDown){H=this.fireEvent("mouseDownEvent",J);}if((C===false)||(E===false)||(F===false)||(H===false)){return;}this.DDM.refreshCache(this.groups);var G=new YAHOO.util.Point(A.getPageX(J),A.getPageY(J));if(!this.hasOuterHandles&&!this.DDM.isOverTarget(G,this)){}else{if(this.clickValidator(J)){this.setStartPosition();this.DDM.handleMouseDown(J,this);this.DDM.stopEvent(J);}else{}}},clickValidator:function(D){var C=YAHOO.util.Event.getTarget(D);return(this.isValidHandleChild(C)&&(this.id==this.handleElId||this.DDM.handleWasClicked(C,this.id)));},getTargetCoord:function(E,D){var C=E-this.deltaX;var F=D-this.deltaY;if(this.constrainX){if(C<this.minX){C=this.minX;}if(C>this.maxX){C=this.maxX;}}if(this.constrainY){if(F<this.minY){F=this.minY;}if(F>this.maxY){F=this.maxY;}}C=this.getTick(C,this.xTicks);F=this.getTick(F,this.yTicks);return{x:C,y:F};},addInvalidHandleType:function(C){var D=C.toUpperCase();this.invalidHandleTypes[D]=D;},addInvalidHandleId:function(C){if(typeof C!=="string"){C=B.generateId(C);}this.invalidHandleIds[C]=C;},addInvalidHandleClass:function(C){this.invalidHandleClasses.push(C);},removeInvalidHandleType:function(C){var D=C.toUpperCase();delete this.invalidHandleTypes[D];},removeInvalidHandleId:function(C){if(typeof C!=="string"){C=B.generateId(C);}delete this.invalidHandleIds[C];},removeInvalidHandleClass:function(D){for(var E=0,C=this.invalidHandleClasses.length;E<C;++E){if(this.invalidHandleClasses[E]==D){delete this.invalidHandleClasses[E];}}},isValidHandleChild:function(F){var E=true;var H;try{H=F.nodeName.toUpperCase();}catch(G){H=F.nodeName;}E=E&&!this.invalidHandleTypes[H];E=E&&!this.invalidHandleIds[F.id];for(var D=0,C=this.invalidHandleClasses.length;E&&D<C;++D){E=!B.hasClass(F,this.invalidHandleClasses[D]);}return E;},setXTicks:function(F,C){this.xTicks=[];this.xTickSize=C;var E={};for(var D=this.initPageX;D>=this.minX;D=D-C){if(!E[D]){this.xTicks[this.xTicks.length]=D;E[D]=true;}}for(D=this.initPageX;D<=this.maxX;D=D+C){if(!E[D]){this.xTicks[this.xTicks.length]=D;E[D]=true;}}this.xTicks.sort(this.DDM.numericSort);},setYTicks:function(F,C){this.yTicks=[];this.yTickSize=C;var E={};for(var D=this.initPageY;D>=this.minY;D=D-C){if(!E[D]){this.yTicks[this.yTicks.length]=D;E[D]=true;}}for(D=this.initPageY;D<=this.maxY;D=D+C){if(!E[D]){this.yTicks[this.yTicks.length]=D;E[D]=true;}}this.yTicks.sort(this.DDM.numericSort);},setXConstraint:function(E,D,C){this.leftConstraint=parseInt(E,10);this.rightConstraint=parseInt(D,10);this.minX=this.initPageX-this.leftConstraint;this.maxX=this.initPageX+this.rightConstraint;if(C){this.setXTicks(this.initPageX,C);}this.constrainX=true;},clearConstraints:function(){this.constrainX=false;this.constrainY=false;this.clearTicks();},clearTicks:function(){this.xTicks=null;this.yTicks=null;this.xTickSize=0;this.yTickSize=0;},setYConstraint:function(C,E,D){this.topConstraint=parseInt(C,10);this.bottomConstraint=parseInt(E,10);this.minY=this.initPageY-this.topConstraint;this.maxY=this.initPageY+this.bottomConstraint;if(D){this.setYTicks(this.initPageY,D);
}this.constrainY=true;},resetConstraints:function(){if(this.initPageX||this.initPageX===0){var D=(this.maintainOffset)?this.lastPageX-this.initPageX:0;var C=(this.maintainOffset)?this.lastPageY-this.initPageY:0;this.setInitPosition(D,C);}else{this.setInitPosition();}if(this.constrainX){this.setXConstraint(this.leftConstraint,this.rightConstraint,this.xTickSize);}if(this.constrainY){this.setYConstraint(this.topConstraint,this.bottomConstraint,this.yTickSize);}},getTick:function(I,F){if(!F){return I;}else{if(F[0]>=I){return F[0];}else{for(var D=0,C=F.length;D<C;++D){var E=D+1;if(F[E]&&F[E]>=I){var H=I-F[D];var G=F[E]-I;return(G>H)?F[D]:F[E];}}return F[F.length-1];}}},toString:function(){return("DragDrop "+this.id);}};YAHOO.augment(YAHOO.util.DragDrop,YAHOO.util.EventProvider);})();YAHOO.util.DD=function(C,A,B){if(C){this.init(C,A,B);}};YAHOO.extend(YAHOO.util.DD,YAHOO.util.DragDrop,{scroll:true,autoOffset:function(C,B){var A=C-this.startPageX;var D=B-this.startPageY;this.setDelta(A,D);},setDelta:function(B,A){this.deltaX=B;this.deltaY=A;},setDragElPos:function(C,B){var A=this.getDragEl();this.alignElWithMouse(A,C,B);},alignElWithMouse:function(C,G,F){var E=this.getTargetCoord(G,F);if(!this.deltaSetXY){var H=[E.x,E.y];YAHOO.util.Dom.setXY(C,H);var D=parseInt(YAHOO.util.Dom.getStyle(C,"left"),10);var B=parseInt(YAHOO.util.Dom.getStyle(C,"top"),10);this.deltaSetXY=[D-E.x,B-E.y];}else{YAHOO.util.Dom.setStyle(C,"left",(E.x+this.deltaSetXY[0])+"px");YAHOO.util.Dom.setStyle(C,"top",(E.y+this.deltaSetXY[1])+"px");}this.cachePosition(E.x,E.y);var A=this;setTimeout(function(){A.autoScroll.call(A,E.x,E.y,C.offsetHeight,C.offsetWidth);},0);},cachePosition:function(B,A){if(B){this.lastPageX=B;this.lastPageY=A;}else{var C=YAHOO.util.Dom.getXY(this.getEl());this.lastPageX=C[0];this.lastPageY=C[1];}},autoScroll:function(J,I,E,K){if(this.scroll){var L=this.DDM.getClientHeight();var B=this.DDM.getClientWidth();var N=this.DDM.getScrollTop();var D=this.DDM.getScrollLeft();var H=E+I;var M=K+J;var G=(L+N-I-this.deltaY);var F=(B+D-J-this.deltaX);var C=40;var A=(document.all)?80:30;if(H>L&&G<C){window.scrollTo(D,N+A);}if(I<N&&N>0&&I-N<C){window.scrollTo(D,N-A);}if(M>B&&F<C){window.scrollTo(D+A,N);}if(J<D&&D>0&&J-D<C){window.scrollTo(D-A,N);}}},applyConfig:function(){YAHOO.util.DD.superclass.applyConfig.call(this);this.scroll=(this.config.scroll!==false);},b4MouseDown:function(A){this.setStartPosition();this.autoOffset(YAHOO.util.Event.getPageX(A),YAHOO.util.Event.getPageY(A));},b4Drag:function(A){this.setDragElPos(YAHOO.util.Event.getPageX(A),YAHOO.util.Event.getPageY(A));},toString:function(){return("DD "+this.id);}});YAHOO.util.DDProxy=function(C,A,B){if(C){this.init(C,A,B);this.initFrame();}};YAHOO.util.DDProxy.dragElId="ygddfdiv";YAHOO.extend(YAHOO.util.DDProxy,YAHOO.util.DD,{resizeFrame:true,centerFrame:false,createFrame:function(){var B=this,A=document.body;if(!A||!A.firstChild){setTimeout(function(){B.createFrame();},50);return;}var F=this.getDragEl(),E=YAHOO.util.Dom;if(!F){F=document.createElement("div");F.id=this.dragElId;var D=F.style;D.position="absolute";D.visibility="hidden";D.cursor="move";D.border="2px solid #aaa";D.zIndex=999;D.height="25px";D.width="25px";var C=document.createElement("div");E.setStyle(C,"height","100%");E.setStyle(C,"width","100%");E.setStyle(C,"background-color","#ccc");E.setStyle(C,"opacity","0");F.appendChild(C);A.insertBefore(F,A.firstChild);}},initFrame:function(){this.createFrame();},applyConfig:function(){YAHOO.util.DDProxy.superclass.applyConfig.call(this);this.resizeFrame=(this.config.resizeFrame!==false);this.centerFrame=(this.config.centerFrame);this.setDragElId(this.config.dragElId||YAHOO.util.DDProxy.dragElId);},showFrame:function(E,D){var C=this.getEl();var A=this.getDragEl();var B=A.style;this._resizeProxy();if(this.centerFrame){this.setDelta(Math.round(parseInt(B.width,10)/2),Math.round(parseInt(B.height,10)/2));}this.setDragElPos(E,D);YAHOO.util.Dom.setStyle(A,"visibility","visible");},_resizeProxy:function(){if(this.resizeFrame){var H=YAHOO.util.Dom;var B=this.getEl();var C=this.getDragEl();var G=parseInt(H.getStyle(C,"borderTopWidth"),10);var I=parseInt(H.getStyle(C,"borderRightWidth"),10);var F=parseInt(H.getStyle(C,"borderBottomWidth"),10);var D=parseInt(H.getStyle(C,"borderLeftWidth"),10);if(isNaN(G)){G=0;}if(isNaN(I)){I=0;}if(isNaN(F)){F=0;}if(isNaN(D)){D=0;}var E=Math.max(0,B.offsetWidth-I-D);var A=Math.max(0,B.offsetHeight-G-F);H.setStyle(C,"width",E+"px");H.setStyle(C,"height",A+"px");}},b4MouseDown:function(B){this.setStartPosition();var A=YAHOO.util.Event.getPageX(B);var C=YAHOO.util.Event.getPageY(B);this.autoOffset(A,C);},b4StartDrag:function(A,B){this.showFrame(A,B);},b4EndDrag:function(A){YAHOO.util.Dom.setStyle(this.getDragEl(),"visibility","hidden");},endDrag:function(D){var C=YAHOO.util.Dom;var B=this.getEl();var A=this.getDragEl();C.setStyle(A,"visibility","");C.setStyle(B,"visibility","hidden");YAHOO.util.DDM.moveToEl(B,A);C.setStyle(A,"visibility","hidden");C.setStyle(B,"visibility","");},toString:function(){return("DDProxy "+this.id);}});YAHOO.util.DDTarget=function(C,A,B){if(C){this.initTarget(C,A,B);}};YAHOO.extend(YAHOO.util.DDTarget,YAHOO.util.DragDrop,{toString:function(){return("DDTarget "+this.id);}});YAHOO.register("dragdrop",YAHOO.util.DragDropMgr,{version:"2.8.1",build:"19"});/*
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.com/yui/license.html
version: 2.8.1
*/
YAHOO.util.Connect={_msxml_progid:["Microsoft.XMLHTTP","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP"],_http_headers:{},_has_http_headers:false,_use_default_post_header:true,_default_post_header:"application/x-www-form-urlencoded; charset=UTF-8",_default_form_header:"application/x-www-form-urlencoded",_use_default_xhr_header:true,_default_xhr_header:"XMLHttpRequest",_has_default_headers:true,_default_headers:{},_poll:{},_timeOut:{},_polling_interval:50,_transaction_id:0,startEvent:new YAHOO.util.CustomEvent("start"),completeEvent:new YAHOO.util.CustomEvent("complete"),successEvent:new YAHOO.util.CustomEvent("success"),failureEvent:new YAHOO.util.CustomEvent("failure"),abortEvent:new YAHOO.util.CustomEvent("abort"),_customEvents:{onStart:["startEvent","start"],onComplete:["completeEvent","complete"],onSuccess:["successEvent","success"],onFailure:["failureEvent","failure"],onUpload:["uploadEvent","upload"],onAbort:["abortEvent","abort"]},setProgId:function(A){this._msxml_progid.unshift(A);},setDefaultPostHeader:function(A){if(typeof A=="string"){this._default_post_header=A;}else{if(typeof A=="boolean"){this._use_default_post_header=A;}}},setDefaultXhrHeader:function(A){if(typeof A=="string"){this._default_xhr_header=A;}else{this._use_default_xhr_header=A;}},setPollingInterval:function(A){if(typeof A=="number"&&isFinite(A)){this._polling_interval=A;}},createXhrObject:function(F){var D,A,B;try{A=new XMLHttpRequest();D={conn:A,tId:F,xhr:true};}catch(C){for(B=0;B<this._msxml_progid.length;++B){try{A=new ActiveXObject(this._msxml_progid[B]);D={conn:A,tId:F,xhr:true};break;}catch(E){}}}finally{return D;}},getConnectionObject:function(A){var C,D=this._transaction_id;try{if(!A){C=this.createXhrObject(D);}else{C={tId:D};if(A==="xdr"){C.conn=this._transport;C.xdr=true;}else{if(A==="upload"){C.upload=true;}}}if(C){this._transaction_id++;}}catch(B){}return C;},asyncRequest:function(G,D,F,A){var E,C,B=(F&&F.argument)?F.argument:null;if(this._isFileUpload){C="upload";}else{if(F.xdr){C="xdr";}}E=this.getConnectionObject(C);if(!E){return null;}else{if(F&&F.customevents){this.initCustomEvents(E,F);}if(this._isFormSubmit){if(this._isFileUpload){this.uploadFile(E,F,D,A);return E;}if(G.toUpperCase()=="GET"){if(this._sFormData.length!==0){D+=((D.indexOf("?")==-1)?"?":"&")+this._sFormData;}}else{if(G.toUpperCase()=="POST"){A=A?this._sFormData+"&"+A:this._sFormData;}}}if(G.toUpperCase()=="GET"&&(F&&F.cache===false)){D+=((D.indexOf("?")==-1)?"?":"&")+"rnd="+new Date().valueOf().toString();}if(this._use_default_xhr_header){if(!this._default_headers["X-Requested-With"]){this.initHeader("X-Requested-With",this._default_xhr_header,true);}}if((G.toUpperCase()==="POST"&&this._use_default_post_header)&&this._isFormSubmit===false){this.initHeader("Content-Type",this._default_post_header);}if(E.xdr){this.xdr(E,G,D,F,A);return E;}E.conn.open(G,D,true);if(this._has_default_headers||this._has_http_headers){this.setHeader(E);}this.handleReadyState(E,F);E.conn.send(A||"");if(this._isFormSubmit===true){this.resetFormState();}this.startEvent.fire(E,B);if(E.startEvent){E.startEvent.fire(E,B);}return E;}},initCustomEvents:function(A,C){var B;for(B in C.customevents){if(this._customEvents[B][0]){A[this._customEvents[B][0]]=new YAHOO.util.CustomEvent(this._customEvents[B][1],(C.scope)?C.scope:null);A[this._customEvents[B][0]].subscribe(C.customevents[B]);}}},handleReadyState:function(C,D){var B=this,A=(D&&D.argument)?D.argument:null;if(D&&D.timeout){this._timeOut[C.tId]=window.setTimeout(function(){B.abort(C,D,true);},D.timeout);}this._poll[C.tId]=window.setInterval(function(){if(C.conn&&C.conn.readyState===4){window.clearInterval(B._poll[C.tId]);delete B._poll[C.tId];if(D&&D.timeout){window.clearTimeout(B._timeOut[C.tId]);delete B._timeOut[C.tId];}B.completeEvent.fire(C,A);if(C.completeEvent){C.completeEvent.fire(C,A);}B.handleTransactionResponse(C,D);}},this._polling_interval);},handleTransactionResponse:function(B,I,D){var E,A,G=(I&&I.argument)?I.argument:null,C=(B.r&&B.r.statusText==="xdr:success")?true:false,H=(B.r&&B.r.statusText==="xdr:failure")?true:false,J=D;try{if((B.conn.status!==undefined&&B.conn.status!==0)||C){E=B.conn.status;}else{if(H&&!J){E=0;}else{E=13030;}}}catch(F){E=13030;}if((E>=200&&E<300)||E===1223||C){A=B.xdr?B.r:this.createResponseObject(B,G);if(I&&I.success){if(!I.scope){I.success(A);}else{I.success.apply(I.scope,[A]);}}this.successEvent.fire(A);if(B.successEvent){B.successEvent.fire(A);}}else{switch(E){case 12002:case 12029:case 12030:case 12031:case 12152:case 13030:A=this.createExceptionObject(B.tId,G,(D?D:false));if(I&&I.failure){if(!I.scope){I.failure(A);}else{I.failure.apply(I.scope,[A]);}}break;default:A=(B.xdr)?B.response:this.createResponseObject(B,G);if(I&&I.failure){if(!I.scope){I.failure(A);}else{I.failure.apply(I.scope,[A]);}}}this.failureEvent.fire(A);if(B.failureEvent){B.failureEvent.fire(A);}}this.releaseObject(B);A=null;},createResponseObject:function(A,G){var D={},I={},E,C,F,B;try{C=A.conn.getAllResponseHeaders();F=C.split("\n");for(E=0;E<F.length;E++){B=F[E].indexOf(":");if(B!=-1){I[F[E].substring(0,B)]=YAHOO.lang.trim(F[E].substring(B+2));}}}catch(H){}D.tId=A.tId;D.status=(A.conn.status==1223)?204:A.conn.status;D.statusText=(A.conn.status==1223)?"No Content":A.conn.statusText;D.getResponseHeader=I;D.getAllResponseHeaders=C;D.responseText=A.conn.responseText;D.responseXML=A.conn.responseXML;if(G){D.argument=G;}return D;},createExceptionObject:function(H,D,A){var F=0,G="communication failure",C=-1,B="transaction aborted",E={};E.tId=H;if(A){E.status=C;E.statusText=B;}else{E.status=F;E.statusText=G;}if(D){E.argument=D;}return E;},initHeader:function(A,D,C){var B=(C)?this._default_headers:this._http_headers;B[A]=D;if(C){this._has_default_headers=true;}else{this._has_http_headers=true;}},setHeader:function(A){var B;if(this._has_default_headers){for(B in this._default_headers){if(YAHOO.lang.hasOwnProperty(this._default_headers,B)){A.conn.setRequestHeader(B,this._default_headers[B]);}}}if(this._has_http_headers){for(B in this._http_headers){if(YAHOO.lang.hasOwnProperty(this._http_headers,B)){A.conn.setRequestHeader(B,this._http_headers[B]);
}}this._http_headers={};this._has_http_headers=false;}},resetDefaultHeaders:function(){this._default_headers={};this._has_default_headers=false;},abort:function(E,G,A){var D,B=(G&&G.argument)?G.argument:null;E=E||{};if(E.conn){if(E.xhr){if(this.isCallInProgress(E)){E.conn.abort();window.clearInterval(this._poll[E.tId]);delete this._poll[E.tId];if(A){window.clearTimeout(this._timeOut[E.tId]);delete this._timeOut[E.tId];}D=true;}}else{if(E.xdr){E.conn.abort(E.tId);D=true;}}}else{if(E.upload){var C="yuiIO"+E.tId;var F=document.getElementById(C);if(F){YAHOO.util.Event.removeListener(F,"load");document.body.removeChild(F);if(A){window.clearTimeout(this._timeOut[E.tId]);delete this._timeOut[E.tId];}D=true;}}else{D=false;}}if(D===true){this.abortEvent.fire(E,B);if(E.abortEvent){E.abortEvent.fire(E,B);}this.handleTransactionResponse(E,G,true);}return D;},isCallInProgress:function(A){A=A||{};if(A.xhr&&A.conn){return A.conn.readyState!==4&&A.conn.readyState!==0;}else{if(A.xdr&&A.conn){return A.conn.isCallInProgress(A.tId);}else{if(A.upload===true){return document.getElementById("yuiIO"+A.tId)?true:false;}else{return false;}}}},releaseObject:function(A){if(A&&A.conn){A.conn=null;A=null;}}};(function(){var G=YAHOO.util.Connect,H={};function D(I){var J='<object id="YUIConnectionSwf" type="application/x-shockwave-flash" data="'+I+'" width="0" height="0">'+'<param name="movie" value="'+I+'">'+'<param name="allowScriptAccess" value="always">'+"</object>",K=document.createElement("div");document.body.appendChild(K);K.innerHTML=J;}function B(L,I,J,M,K){H[parseInt(L.tId)]={"o":L,"c":M};if(K){M.method=I;M.data=K;}L.conn.send(J,M,L.tId);}function E(I){D(I);G._transport=document.getElementById("YUIConnectionSwf");}function C(){G.xdrReadyEvent.fire();}function A(J,I){if(J){G.startEvent.fire(J,I.argument);if(J.startEvent){J.startEvent.fire(J,I.argument);}}}function F(J){var K=H[J.tId].o,I=H[J.tId].c;if(J.statusText==="xdr:start"){A(K,I);return;}J.responseText=decodeURI(J.responseText);K.r=J;if(I.argument){K.r.argument=I.argument;}this.handleTransactionResponse(K,I,J.statusText==="xdr:abort"?true:false);delete H[J.tId];}G.xdr=B;G.swf=D;G.transport=E;G.xdrReadyEvent=new YAHOO.util.CustomEvent("xdrReady");G.xdrReady=C;G.handleXdrResponse=F;})();(function(){var D=YAHOO.util.Connect,F=YAHOO.util.Event;D._isFormSubmit=false;D._isFileUpload=false;D._formNode=null;D._sFormData=null;D._submitElementValue=null;D.uploadEvent=new YAHOO.util.CustomEvent("upload"),D._hasSubmitListener=function(){if(F){F.addListener(document,"click",function(J){var I=F.getTarget(J),H=I.nodeName.toLowerCase();if((H==="input"||H==="button")&&(I.type&&I.type.toLowerCase()=="submit")){D._submitElementValue=encodeURIComponent(I.name)+"="+encodeURIComponent(I.value);}});return true;}return false;}();function G(T,O,J){var S,I,R,P,W,Q=false,M=[],V=0,L,N,K,U,H;this.resetFormState();if(typeof T=="string"){S=(document.getElementById(T)||document.forms[T]);}else{if(typeof T=="object"){S=T;}else{return;}}if(O){this.createFrame(J?J:null);this._isFormSubmit=true;this._isFileUpload=true;this._formNode=S;return;}for(L=0,N=S.elements.length;L<N;++L){I=S.elements[L];W=I.disabled;R=I.name;if(!W&&R){R=encodeURIComponent(R)+"=";P=encodeURIComponent(I.value);switch(I.type){case"select-one":if(I.selectedIndex>-1){H=I.options[I.selectedIndex];M[V++]=R+encodeURIComponent((H.attributes.value&&H.attributes.value.specified)?H.value:H.text);}break;case"select-multiple":if(I.selectedIndex>-1){for(K=I.selectedIndex,U=I.options.length;K<U;++K){H=I.options[K];if(H.selected){M[V++]=R+encodeURIComponent((H.attributes.value&&H.attributes.value.specified)?H.value:H.text);}}}break;case"radio":case"checkbox":if(I.checked){M[V++]=R+P;}break;case"file":case undefined:case"reset":case"button":break;case"submit":if(Q===false){if(this._hasSubmitListener&&this._submitElementValue){M[V++]=this._submitElementValue;}Q=true;}break;default:M[V++]=R+P;}}}this._isFormSubmit=true;this._sFormData=M.join("&");this.initHeader("Content-Type",this._default_form_header);return this._sFormData;}function C(){this._isFormSubmit=false;this._isFileUpload=false;this._formNode=null;this._sFormData="";}function B(H){var I="yuiIO"+this._transaction_id,J;if(YAHOO.env.ua.ie){J=document.createElement('<iframe id="'+I+'" name="'+I+'" />');if(typeof H=="boolean"){J.src="javascript:false";}}else{J=document.createElement("iframe");J.id=I;J.name=I;}J.style.position="absolute";J.style.top="-1000px";J.style.left="-1000px";document.body.appendChild(J);}function E(H){var K=[],I=H.split("&"),J,L;for(J=0;J<I.length;J++){L=I[J].indexOf("=");if(L!=-1){K[J]=document.createElement("input");K[J].type="hidden";K[J].name=decodeURIComponent(I[J].substring(0,L));K[J].value=decodeURIComponent(I[J].substring(L+1));this._formNode.appendChild(K[J]);}}return K;}function A(K,V,L,J){var Q="yuiIO"+K.tId,R="multipart/form-data",T=document.getElementById(Q),M=(document.documentMode&&document.documentMode===8)?true:false,W=this,S=(V&&V.argument)?V.argument:null,U,P,I,O,H,N;H={action:this._formNode.getAttribute("action"),method:this._formNode.getAttribute("method"),target:this._formNode.getAttribute("target")};this._formNode.setAttribute("action",L);this._formNode.setAttribute("method","POST");this._formNode.setAttribute("target",Q);if(YAHOO.env.ua.ie&&!M){this._formNode.setAttribute("encoding",R);}else{this._formNode.setAttribute("enctype",R);}if(J){U=this.appendPostData(J);}this._formNode.submit();this.startEvent.fire(K,S);if(K.startEvent){K.startEvent.fire(K,S);}if(V&&V.timeout){this._timeOut[K.tId]=window.setTimeout(function(){W.abort(K,V,true);},V.timeout);}if(U&&U.length>0){for(P=0;P<U.length;P++){this._formNode.removeChild(U[P]);}}for(I in H){if(YAHOO.lang.hasOwnProperty(H,I)){if(H[I]){this._formNode.setAttribute(I,H[I]);}else{this._formNode.removeAttribute(I);}}}this.resetFormState();N=function(){if(V&&V.timeout){window.clearTimeout(W._timeOut[K.tId]);delete W._timeOut[K.tId];}W.completeEvent.fire(K,S);if(K.completeEvent){K.completeEvent.fire(K,S);
}O={tId:K.tId,argument:V.argument};try{O.responseText=T.contentWindow.document.body?T.contentWindow.document.body.innerHTML:T.contentWindow.document.documentElement.textContent;O.responseXML=T.contentWindow.document.XMLDocument?T.contentWindow.document.XMLDocument:T.contentWindow.document;}catch(X){}if(V&&V.upload){if(!V.scope){V.upload(O);}else{V.upload.apply(V.scope,[O]);}}W.uploadEvent.fire(O);if(K.uploadEvent){K.uploadEvent.fire(O);}F.removeListener(T,"load",N);setTimeout(function(){document.body.removeChild(T);W.releaseObject(K);},100);};F.addListener(T,"load",N);}D.setForm=G;D.resetFormState=C;D.createFrame=B;D.appendPostData=E;D.uploadFile=A;})();YAHOO.register("connection",YAHOO.util.Connect,{version:"2.8.1",build:"19"});PgnViewer=function(_1,_2){
var _3=new BoardConfig();
if(_1){
_3.applyConfig(_1);
}
if(!window._pvObject){
window._pvObject=new Array();
}
window._pvObject[_3.boardName]=this;
_1=_3;
_1.pgnMode=true;
_1.scrollVariations=true;
this.chessapp=new ChessApp(_1);
this.finishedCallback=_2;
if(_1.loadImmediately){
this.chessapp.init(null,null,null,this,true);
this.board=this.chessapp.board;
}else{
YAHOO.util.Event.onDOMReady(this.setup,this,true);
}
};
PgnViewer.prototype.setup=function(){
this.chessapp.init(null,null,null,this,true);
this.board=this.chessapp.board;
};
PgnViewer.prototype.updatePieceCallback=function(_4,_5,_6,_7,_8,_9,_a,_b,_c,_d,_e,_f){
var _10=new Object();
var _11=_e;
var _12=false;
var _13=Board.getVarMove(_11,_7,_6,_5,_4);
if(_11.fromColumn==_5.column&&_11.fromRow==_5.row&&_11.toRow==_7&&_11.toColumn==_6&&(_4==""||(_4==_11.promotion))){
_12=true;
}else{
if(_13){
_11=_13;
_12=true;
}
}
_10.move=_11;
_10.allowMove=_12;
_10.dontMakeOpponentMove=false;
return _10;
};
PgnViewer.prototype.setupFromPgn=function(pgn,_15){
this.chessapp.pgn.setupFromPGN(pgn,_15);
};
PgnViewer.prototype.setupFromFen=function(fen,_17,_18,_19){
this.chessapp.pgn.board.setupFromFen(fen,_17,_18,_19);
};
PGNGame=function(_1a,_1b,_1c,_1d,_1e,_1f,_20,_21,_22,_23,_24,_25){
this.movesseq=_1a;
this.startFen=_1b;
this.blackPlayer=_1c;
this.whitePlayer=_1d;
this.pgn_result=_1e;
this.event=_1f;
this.site=_20;
this.date=_21;
this.round=_22;
this.start_movenum=_23;
this.whitePlayerElo=_24;
this.blackPlayerElo=_25;
};
PGN=function(_26){
this.board=_26;
this.pgnGames=new Array();
this.lastShownGame=0;
};
PGN.prototype.pollPGNFromURL=function(url,_28,_29){
var _2a=this;
this.getPGNFromURL(url,_28);
if(this.foundResult){
_29=this.board.pollPGNMillisecondsPostResult;
this.foundResultPolls++;
}
if(this.foundResultPolls>=this.board.numberPollsAfterResult){
return;
}
setTimeout(function(){
_2a.pollPGNFromURL(url,_28,_29);
},_29);
};
PGN.prototype.getPGNFromURL=function(url,_2c){
var _2d=(new Date()).getTime()+"-"+parseInt(Math.random()*99999);
YAHOO.util.Connect.asyncRequest("GET",url+"?rs="+_2d,{success:function(o){
var _2f="";
var _30="";
var _31="";
var re=eval("/\\n[^[]/");
if(o.responseText.indexOf("\r")>=0){
eval("/\\r[^[]/");
}
var ind=o.responseText.search(re);
if(ind>=0){
_31=o.responseText.substring(ind);
}
re=eval("/\\[Result /");
ind=o.responseText.search(re);
if(ind>=0){
var _34=o.responseText.indexOf("\n",ind);
if(_34<0){
_34=o.responseText.indexOf("\r",ind);
}
if(_34>=0){
_2f=o.responseText.substring(ind,_34);
}
}
re=eval("/\\[Site /");
ind=o.responseText.search(re);
if(ind>=0){
var _34=o.responseText.indexOf("]",ind);
if(_34>=0){
_30=o.responseText.substring(ind+6,_34-1);
}
}
if(_30){
if(this.board.fideClock){
var _35=YAHOO.util.Dom.get(this.board.boardName+"-whitePlayerClock");
var _36=YAHOO.util.Dom.get(this.board.boardName+"-blackPlayerClock");
var ss=_30.split("-");
var _38=ss[0];
var _39="0";
if(_38.charAt(0)=="\""){
_38=_38.substr(1);
}
if(ss.length>1){
_39=ss[1];
}
if(_35){
_35.innerHTML=_38;
}
if(_36){
_36.innerHTML=_39;
}
}else{
var _3a=YAHOO.util.Dom.get(this.board.boardName+"-site");
if(_3a){
_3a.innerHTML=_30;
}
}
}
if(this.currentMoveText==_31&&this.currentResultTag==_2f){
return;
}
this.currentMoveText=_31;
this.currentResultTag=_2f;
this.setupFromPGN(o.responseText,_2c);
},failure:function(o){
if(!this.board.hidePGNErrors){
alert("pgn load failed:"+o.statusText+" for file:"+url);
}
},scope:this},"rs2="+_2d);
};
PGN.prototype.getMoveFromPGNMove=function(_3c,_3d,_3e){
var _3f=false;
var _40=false;
var _41=false;
var _42;
var _43=null;
var _44=false;
var _45=null;
if(_3c.charAt(_3c.length-1)=="#"){
_40=true;
_3f=true;
_3c=_3c.substr(0,_3c.length-1);
}else{
if(_3c.charAt(_3c.length-1)=="+"){
_40=true;
if(_3c.length>1&&_3c.charAt(_3c.length-2)=="+"){
_3f=true;
_3c=_3c.substr(0,_3c.length-2);
}else{
_3c=_3c.substr(0,_3c.length-1);
}
}
}
if(_3c=="O-O-O"){
if(_3d=="w"){
return this.board.createMoveFromString("e1c1");
}else{
return this.board.createMoveFromString("e8c8");
}
}else{
if(_3c=="O-O"){
if(_3d=="w"){
return this.board.createMoveFromString("e1g1");
}else{
return this.board.createMoveFromString("e8g8");
}
}
}
var _46=_3c.indexOf("=");
if(_46>=0){
var _47;
_43=_3c.substr(_46+1,1);
_47=_43.charAt(0);
_42=this.board.pieceCharToPieceNum(_47);
_41=true;
_3c=_3c.substr(0,_46);
}
var _48=_3c.charAt(_3c.length-1);
if(_48=="Q"||_48=="R"||_48=="N"||_48=="B"){
_43=_48+"";
_42=this.board.pieceCharToPieceNum(_43);
_41=true;
_3c=_3c.substr(0,_3c.length-1);
}
var _49=_3c.substr(_3c.length-2,2);
var _4a=_49.charCodeAt(0)-"a".charCodeAt(0);
var _4b=_49.charCodeAt(1)-"1".charCodeAt(0);
if(_4a>7||_4a<0||_4b>7||_4b<0){
this.lastMoveFromError=__js("Error processing to Square:{TO_SQUARE} on move:{MOVE}",[["TO_SQUARE",_49],["MOVE",_3c]]);
return null;
}
if(_3c.length>2){
if(_3c.charAt(_3c.length-3)=="x"){
_44=true;
_45=_3c.substr(0,_3c.length-3);
}else{
_45=_3c.substr(0,_3c.length-2);
}
}
var _4c=new Array();
var _4d=0;
var _4e=null;
var _4f=(_3d=="w")?ChessPiece.WHITE:ChessPiece.BLACK;
switch(_3c.charAt(0)){
case "K":
case "k":
_4e=ChessPiece.KING;
break;
case "Q":
case "q":
_4e=ChessPiece.QUEEN;
break;
case "R":
case "r":
_4e=ChessPiece.ROOK;
break;
case "B":
_4e=ChessPiece.BISHOP;
break;
case "N":
case "n":
_4e=ChessPiece.KNIGHT;
break;
case "P":
case "p":
_4e=ChessPiece.PAWN;
break;
default:
_4e=ChessPiece.PAWN;
}
var _50=null;
var _51=null;
if(_45){
var _52=_45.toLowerCase().charAt(0);
if(_52==_45.charAt(0)&&_52>="a"&&_52<="h"){
_51=_52;
if(_45.length==2){
_50=_45.charAt(1);
}
}else{
if(_45.length>1){
if(_45.length==2){
var c=_45.charAt(1);
if(c>="1"&&c<="8"){
_50=c;
}else{
_51=c;
}
}else{
if(_45.length==3){
_51=_45.charAt(1);
_50=_45.charAt(2);
if(_51>="1"&&_51<="9"){
var tmp=_51;
_51=_50;
_50=tmp;
}
}else{
this.lastMoveFromError=__js("Error: unhandled fromChars:{FROM_CHARS}",[["FROM_CHARS",_45]]);
return null;
}
}
}
}
}
for(var i=0;i<8;i++){
for(var j=0;j<8;j++){
var bp=this.board.boardPieces[i][j];
if(bp!=null&&bp.colour==_4f&&bp.piece==_4e){
if(this.board.canMove(bp,_4a,_4b,_3e,true)){
var _58=String.fromCharCode("a".charCodeAt(0)+i).charAt(0);
var _59=String.fromCharCode("1".charCodeAt(0)+j).charAt(0);
if((_51==null||_51==_58)&&(_50==null||_50==_59)){
_4c[_4d++]=bp;
}else{
}
}
}
}
}
if(_4d==0){
this.lastMoveFromError=__js("no candidate pieces for:{MOVE}",[["MOVE",_3c]]);
return null;
}
if(_4d>1){
this.lastMoveFromError=__js("Ambiguous:{MOVE} with fromChars:{FROM_CHARS} disambigRow:{DISAMBIG_ROW} disambigCol:{DISAMBIG_COL}",[["MOVE",_3c],["FROM_CHARS",_45],["DISAMBIG_ROW",_50],["DISAMBIG_COL",_51]]);
return null;
}
var _5a=_4c[0];
var _5b="";
_5b+=String.fromCharCode("a".charCodeAt(0)+_5a.column);
_5b+=String.fromCharCode("1".charCodeAt(0)+_5a.row);
if(_44){
_5b+="x";
}
_5b+=_49;
if(_43){
_5b+=_43;
}
var _5c=this.board.createMoveFromString(_5b);
return _5c;
};
PGN.prototype.parseTag=function(_5d,pgn,_5f){
if(pgn.substr(_5f,_5d.length+3)=="["+_5d+" \""){
var _60=pgn.indexOf("\"",_5f+_5d.length+3);
if(_60>=0){
return pgn.substring(_5f+_5d.length+3,_60);
}
}
return null;
};
PGN.prototype.parsePGN=function(pgn,_62,_63){
if(ctime){
console.time("parsePGN");
}
pgn=pgn.replace(/^\s+|\s+$/g,"");
var _64=0;
this.pgn=pgn;
var _65=new Array();
var _66=1;
var _67=0;
this.pgnGames=new Array();
this.finishedParseCallback=_62;
this.startParseTime=new Date().getTime();
var ret=this.parsePGN_cont(_65,_66,_67,_64,_63);
var _69=new Object();
if(!ret){
_69.parsedOk=true;
_69.pgnGames=this.pgnGames;
}else{
_69.parsedOk=false;
_69.errorString=ret;
_69.pgnGames=null;
}
if(ctime){
console.timeEnd("parsePGN");
}
return _69;
};
PGN.prototype.parsePGN_cont=function(_6a,_6b,_6c,_6d,_6e){
var pgn=this.pgn;
var _70=this.board.boardName+"-progress";
var _71=YAHOO.util.Dom.get(_70);
while(_6d<pgn.length){
var _72="";
var _73="";
var _74="";
var _75="";
var _76="";
var _77="";
var _78="";
var _79="?";
var _7a="?";
var _7b="w";
var _7c=0;
var _7d=0;
var _7e=new Array();
var _7f=0;
var _80="";
var _81=null;
var _82=null;
var _83=new Array();
var _84=new Array();
var _85=new Array();
var _86=new Array();
var _87=new Array();
this.board.pieceMoveDisabled=true;
if(this.board.initialFen){
this.board.startFen=this.board.initialFen;
}else{
this.board.startFen="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
}
var i=0;
for(i=_6d;i<pgn.length;i++){
var tag=this.parseTag("FEN",pgn,i);
if(tag&&tag!="?"){
this.board.startFen=tag;
}else{
tag=this.parseTag("White",pgn,i);
if(tag&&tag!="?"){
_78=tag;
}else{
tag=this.parseTag("Black",pgn,i);
if(tag&&tag!="?"){
_73=tag;
}else{
tag=this.parseTag("Result",pgn,i);
if(tag&&tag!="?"){
_72=tag;
}else{
tag=this.parseTag("Event",pgn,i);
if(tag&&tag!="?"){
_74=tag;
}else{
tag=this.parseTag("Site",pgn,i);
if(tag&&tag!="?"){
_75=tag;
}else{
tag=this.parseTag("Date",pgn,i);
if(tag&&tag!="?"){
_76=tag;
}else{
tag=this.parseTag("Round",pgn,i);
if(tag&&tag!="?"){
_77=tag;
}else{
tag=this.parseTag("WhiteElo",pgn,i);
if(tag&&tag!="?"){
_79=tag;
}else{
tag=this.parseTag("BlackElo",pgn,i);
if(tag&&tag!="?"){
_7a=tag;
}
}
}
}
}
}
}
}
}
}
if(pgn.charAt(i)=="["){
var j=pgn.indexOf;
for(j=i+1;j<pgn.length&&pgn.charAt(j)!="]";j++){
}
if(j==pgn.length){
var err=_js("PgnViewer: Error parsing PGN. Found unclosed [");
if(this.finishedParseCallback){
this.finishedParseCallback(_6e,err);
}
return err;
}
i=j-1;
continue;
}
if(pgn.charAt(i)=="{"){
var _8c=pgn.indexOf("}",i+1);
if(_8c>=0){
var _8d=pgn.substring(i+1,_8c);
i=_8c;
_80+="{ "+_8d+" } ";
}else{
var err=_js("PgnViewer: Error parsing PGN. Found unclosed {");
if(this.finishedParseCallback){
this.finishedParseCallback(_6e,err);
}
return err;
}
continue;
}
if(pgn.substr(i,1)=="."){
var j=i-1;
while(j>=0&&pgn.charAt(j)>="0"&&pgn.charAt(j)<="9"){
j--;
}
j++;
if(pgn.charAt(j)>="0"&&pgn.charAt(j)<="9"){
_6b=parseInt(pgn.substring(j,i));
}
break;
}
}
if(pgn.substr(i,1)!="."){
}
this.board.prev_move=null;
this.board.setupFromFen(this.board.startFen,false,false,true,true);
_81=this.board.prev_move;
var _8e=i;
var _8f=null;
for(i=i;i<pgn.length;i++){
var _90=-1;
if(pgn.substr(i,3)=="1-0"||pgn.substr(i,3)=="0-1"){
_90=3;
}else{
if(pgn.substr(i,7)=="1/2-1/2"){
_90=7;
}else{
if(pgn.substr(i,1)=="*"){
_90=1;
}
}
}
if(_90>0){
_8f=pgn.substr(i,_90);
_6d=i+_90;
break;
}
if(pgn.charAt(i)=="["){
_6d=i;
break;
}
if(pgn.charAt(i)==" "||pgn.charAt(i)=="\t"||pgn.charAt(i)=="\n"||pgn.charAt(i)=="\r"){
_8e=i+1;
continue;
}
if(pgn.charAt(i)>="0"&&pgn.charAt(i)<="9"){
continue;
}
if(pgn.charAt(i)=="."){
var _91=pgn.substring(_8e,i).replace(/^\s+|\s+$/g,"");
_8e=i;
while(i+1<pgn.length&&pgn.charAt(i+1)=="."){
i++;
}
if(_8e!=i){
_7b="b";
}else{
_7b="w";
}
_8e=i+1;
}else{
if(pgn.charAt(i)=="{"){
var _8c=pgn.indexOf("}",i+1);
if(_8c>=0){
var _8d=pgn.substring(i+1,_8c);
i=_8c;
_80+="{ "+_8d+" } ";
}
_8e=i+1;
}else{
if(pgn.charAt(i)=="("){
_83[_7c]=this.board.boardPieces;
_84[_7c]=_7b;
_86[_7c]=_81;
_87[_7c]=_82;
this.board.boardPieces=_85[_7c];
this.board.boardPieces=this.board.copyBoardPieces(false);
_81=_82;
_7c++;
_8e=i+1;
_80+="( ";
}else{
if(pgn.charAt(i)==")"){
boardPool.putObject(_83[_7c]);
_7c--;
this.board.boardPieces=_83[_7c];
_7b=_84[_7c];
_81=_86[_7c];
_82=_87[_7c];
_8e=i+1;
_80+=") ";
}else{
if(pgn.charAt(i)=="$"){
var j;
for(j=i+1;j<pgn.length&&pgn.charAt(j)>="0"&&pgn.charAt(j)<="9";j++){
}
j--;
if(j>i){
var _92=parseInt(pgn.substr(i+1,j+1));
if(_92<=9){
switch(_92){
case 1:
_80=_80.substr(0,_80.length-1)+"! ";
break;
case 2:
_80=_80.substr(0,_80.length-1)+"? ";
break;
case 3:
_80=_80.substr(0,_80.length-1)+"!! ";
break;
case 4:
_80=_80.substr(0,_80.length-1)+"?? ";
break;
case 5:
_80=_80.substr(0,_80.length-1)+"!? ";
break;
case 6:
_80=_80.substr(0,_80.length-1)+"?! ";
break;
case 7:
case 8:
case 9:
case 0:
default:
}
}else{
_80+=pgn.substring(i,j+1)+" ";
}
i=j;
}
continue;
}else{
var _93=-1;
for(var j=i+1;j<pgn.length;j++){
if(pgn.charAt(j)==")"||pgn.charAt(j)=="("||pgn.charAt(j)=="{"||pgn.charAt(j)=="}"||pgn.charAt(j)==" "||pgn.charAt(j)=="\t"||pgn.charAt(j)=="\n"||pgn.charAt(j)=="\r"){
_93=j;
break;
}
}
if(_93==-1){
_93=pgn.length;
}
var _94=_8e;
var _95=pgn.substring(_8e,_93).replace(/^\s+|\s+$/g,"");
_8e=_93;
i=_8e-1;
if(_95.length>=4&&_95.substring(0,4)=="e.p."){
continue;
}
if(_95.length==0){
var err=__js("PgnViewer: Error: got empty move endMoveInd:{ENDMOVE_INDEX} upto:{UPTO} from:{FROM}",[["ENDMOVE_INDEX",_93],["UPTO",_94],["FROM",pgn.substr(_94)]]);
if(this.finishedParseCallback){
this.finishedParseCallback(_6e,err);
}
return err;
}
var _96=_95.length-1;
while(_96>=0){
if(_95.charAt(_96)=="?"){
_96--;
}else{
if(_95.charAt(_96)=="!"){
_96--;
}else{
break;
}
}
}
var _97=_95.substring(0,_96+1);
var _98=this.getMoveFromPGNMove(_97,_7b,_81);
if(_98==null){
_80+="unknown ";
var err=__js("PgnViewer: Error parsing:{MOVE}, {ERROR_REASON}",[["MOVE",_95],["ERROR_REASON",this.lastMoveFromError]]);
if(this.finishedParseCallback){
this.finishedParseCallback(_6e,err);
}
return err;
}
_82=_81;
_81=_98;
var _99=this.board.boardPieces[_98.fromColumn][_98.fromRow];
boardPool.putObject(_85[_7c]);
_85[_7c]=this.board.copyBoardPieces(false);
if(_99){
this.board.makeMove(_98,_99,false,0.5,false,false);
}
_7d=_7c;
_7f++;
_7b=this.board.flipToMove(_7b);
_80+=_98.moveString+"|"+_95+" ";
}
}
}
}
}
}
if(_6d<i){
_6d=i;
}
var _9a=pgn.indexOf("{",_6d);
var _9b=pgn.indexOf("[",_6d);
if(_9a>=0){
if(_9b==-1||_9a<_9b){
var _9c=pgn.indexOf("}",_9a+1);
if(_9c>=0){
var _8d=pgn.substring(_9a+1,_9c);
_6d=_9c+1;
_80+="{ "+_8d+" } ";
}else{
var err=_js("PgnViewer: Error: Unclosed {");
if(this.finishedParseCallback){
this.finishedParseCallback(_6e,err);
}
return err;
}
}
}
_80=_80.replace(/^\s+|\s+$/g,"");
this.board.pieceMoveDisabled=false;
if(_8f!=null){
if(_72.length==0||_72=="?"){
_72=_8f;
}
}
if(this.board.ignoreMultipleGames){
if(_8f&&_72&&_72=="*"&&_8f!="*"&&_8f!="?"&&_8f!=""){
_72=_8f;
}
}
this.pgnGames[_6c++]=new PGNGame(_80,this.board.startFen,_73,_78,_72,_74,_75,_76,_77,_6b,_79,_7a);
if(_71){
_71.innerHTML="Loaded "+_6c+" games";
}
if(this.board.ignoreMultipleGames){
break;
}
if(this.finishedParseCallback&&new Date().getTime()-this.startParseTime>500){
this.startParseTime=new Date().getTime();
setTimeout("window._pvObject[\""+this.board.boardName+"\"].chessapp.pgn.parsePGN_cont(\""+_6a+"\",\""+_6b+"\",\""+_6c+"\",\""+_6d+"\","+_6e+");",0);
return;
}
}
if(this.finishedParseCallback){
this.finishedParseCallback(_6e);
}
return false;
};
PGN.prototype.setupFromPGN=function(pgn,_9e){
this.parsePGN(pgn,this.setupFromPGNCallback,_9e);
};
PGN.prototype.setupFromPGNCallback=function(_9f,err){
var _a1=this.board.boardName+"-progress";
var _a2=YAHOO.util.Dom.get(_a1);
if(err){
if(!this.board.hidePGNErrors){
alert(err);
}
return false;
}
if(this.pgnGames.length==0){
if(!this.board.hidePGNErrors){
alert("PgnViewer: Error: Unable to find any pgn games in:"+pgn);
}
return false;
}
if(this.pgnGames.length==1||this.board.ignoreMultipleGames){
var _a3=0;
if(_9f){
_a3=-1;
}
this.showGame(0,_a3);
}else{
var _a4=this.board.boardName+"-container";
var _a5=YAHOO.util.Dom.get(_a4);
var _a6=YAHOO.util.Dom.get(this.board.boardName+"-problemSelector");
var _a7=document.createElement("div");
var _a8="<form id=\""+this.board.boardName+"-problemSelectorForm\" action=\"\" method=\"\">";
var _a9="<select id=\""+this.board.boardName+"-problemSelector\" name=\""+this.board.boardName+"-problemSelector\" style=\"width: "+this.board.pieceSize*8+"px;\">";
var _aa="";
for(i=0;i<this.pgnGames.length;i++){
var _ab=this.pgnGames[i];
var _ac=this.board.boardName+"-game-"+i;
var _ad=(i+1)+". "+_ab.whitePlayer+" vs "+_ab.blackPlayer;
if(_ab.pgn_result.length>0&&_ab.pgn_result!="?"&&this.board.showResult==1){
_ad+=" "+_ab.pgn_result;
}
if(_ab.event.length>0&&_ab.event!="?"&&this.board.showEvent==1){
_ad+=" "+_ab.event;
}
if(_ab.round.length>0&&_ab.round!="?"&&this.board.showRound==1){
_ad+=" Rnd:"+_ab.round;
}
if(_ab.site.length>0&&_ab.site!="?"&&this.board.showSite==1){
_ad+=" "+_ab.site;
}
if(_ab.date.length>0&&_ab.date!="?"&&this.board.showDate==1){
_ad+=" "+_ab.date;
}
var sel="";
if(i==this.lastShownGame){
sel="selected=\"\"";
}
_aa+="<option "+sel+" id=\""+_ac+"\" value=\""+i+"\">"+_ad+"</option>";
}
if(_a6){
if(this.board.selectorBody!=_aa){
_a6.innerHTML=_aa;
this.board.selectorBody=_aa;
}
}else{
_a8+=_a9+_aa+"</select></form>";
_a7.innerHTML=_a8;
_a5.insertBefore(_a7,_a5.firstChild);
this.board.selectorBody=_aa;
}
var _a6=YAHOO.util.Dom.get(this.board.boardName+"-problemSelector");
YAHOO.util.Event.addListener(_a6,"change",this.selectGame,this,true);
var _a3=0;
var _af=0;
if(_9f){
_a3=-1;
_af=this.lastShownGame;
}
this.showGame(_af,_a3);
}
if(_a2){
YAHOO.util.Dom.setStyle(_a2,"visibility","hidden");
}
if(window._pvObject[this.board.boardName].finishedCallback){
window._pvObject[this.board.boardName].finishedCallback();
}
return;
};
PGN.prototype.selectGame=function(e){
var _b1=YAHOO.util.Event.getTarget(e).selectedIndex;
var _b2=0;
if(this.board.gotoEndOnRefresh){
_b2=-1;
}
this.showGame(_b1,_b2);
var _b3=this.board.boardName+"-piecestaken";
var _b4=YAHOO.util.Dom.get(_b3);
if(_b4){
_b4.innerHTML="";
}
this.board.resetMoveListScrollPosition();
};
PGN.prototype.showGame=function(_b5,_b6){
_b6=(typeof _b6=="undefined")?0:_b6;
var _b7=this.lastShownGame;
this.lastShownGame=_b5;
var _b8=this.board.moveArray;
var _b9=this.board.currentMove;
var _ba=false;
if(_b9&&_b9.atEnd){
_ba=true;
}
var _bb=this.pgnGames[_b5];
var _bc=_bb.pgn_result;
if(_bc&&(_bc=="1/2-1/2"||_bc=="0-1"||_bc=="1-0")){
this.foundResult=true;
}else{
this.foundResult=false;
this.foundResultPolls=0;
}
this.board.startFen=_bb.startFen;
this.board.setupFromFen(_bb.startFen,false,false,false);
this.board.setMoveSequence(_bb.movesseq,"NA",_bb.start_movenum,_bb.pgn_result);
var _bd=true;
var _be=-1;
if(_b5==_b7&&_ba){
_be=this.board.moveArray.length-1;
}
if(!Move.moveArraysEqual(_b8,this.board.moveArray)){
_bd=false;
}else{
var _bf=Move.findMoveInNewArray(_b8,this.board.moveArray,_b9);
if(_bf&&_bf.prev){
_be=_bf.prev.index;
}
}
this.board.displayPendingMoveList();
if(this.board.moveArray.length>0){
this.board.setCurrentMove(this.board.moveArray[0]);
}
if(_bd){
if(_be>0&&_be<this.board.moveArray.length){
if(clog){
console.log("going to currMoveIndex:"+_be);
}
this.board.gotoMoveIndex(_be,false,true);
}else{
}
}else{
if(_b6==-1){
var _c0=this.board.moveArray.length-1;
if(_c0>=0){
this.board.gotoMoveIndex(_c0,false,true);
}
}else{
if(_b6!=0){
this.board.gotoMoveIndex(_b6);
}
}
if(_b6!=-1&&this.board.autoplayFirst){
this.board.forwardMove();
}
}
this.board.displayMode=true;
var _c1=this.board.boardName;
var _c2=YAHOO.util.Dom.get(_c1+"-whitePlayer");
if(_c2){
_c2.innerHTML=_bb.whitePlayer;
}
var _c3=YAHOO.util.Dom.get(_c1+"-blackPlayer");
if(_c3){
_c3.innerHTML=_bb.blackPlayer;
}
var _c4=YAHOO.util.Dom.get(_c1+"-event");
if(_c4){
_c4.innerHTML=_bb.event;
}
var _c5=YAHOO.util.Dom.get(_c1+"-site");
if(_c5){
_c5.innerHTML=_bb.site;
}
var _c6=YAHOO.util.Dom.get(_c1+"-date");
if(_c6){
_c6.innerHTML=_bb.date;
}
var _c7=YAHOO.util.Dom.get(_c1+"-round");
if(_c7){
_c7.innerHTML=_bb.round;
}
var _c8=YAHOO.util.Dom.get(_c1+"-whiteElo");
if(_c8){
_c8.innerHTML=_bb.whitePlayerElo;
}
var _c9=YAHOO.util.Dom.get(_c1+"-blackElo");
if(_c9){
_c9.innerHTML=_bb.blackPlayerElo;
}
if(clog){
if(this.board.currentMove){
console.log("after show game currentMove:"+this.board.currentMove.output());
}else{
console.log("after show game currentMove is null");
}
}
};

var SITE_VERSION=1;
var clog=false;
var ctime=false;
var cprof=false;
var move_obj_id_counter=0;
var activeBoard=null;
var boardSounds=new CTSound({soundPath:"/sounds"});
YAHOO.util.Event.onDOMReady(function(){
boardSounds.createSound("takesounds/78263__SuGu14__Metall01","takePiece1");
boardSounds.createSound("movesounds/77971__SuGu14__Fusta_0_05","movePiece3");
boardSounds.createSound("movesounds/10537__batchku__Hit_knuckle_15_004","movePiece7");
});
function isMouseOver(_1,e){
var el=YAHOO.util.Dom.get(_1);
if(!el){
return false;
}
var _4=YAHOO.util.Dom.getRegion(el);
if(!_4){
return false;
}
var _5=_4.top;
var _6=_4.left;
var _7=_4.bottom;
var _8=_4.right;
var _9=YAHOO.util.Event.getXY(e);
var mX=_9[0];
var mY=_9[1];
var _c=(mX>_6&&mX<_8&&mY>_5&&mY<_7);
}
function trimStr(_d){
if(!_d){
return "";
}
var _d=_d.replace(/^\s\s*/,"");
var ws=/\s/;
var i=_d.length;
while(ws.test(_d.charAt(--i))){
}
return _d.slice(0,i+1);
}
BoardConfig=function(){
this.boardName="board";
this.puzzle=false;
this.showToMoveIndicators=false;
this.scrollVariations=false;
this.pgnString=null;
this.pgnDiv=null;
this.pgnFile=null;
this.scrollOffsetCorrection=0;
this.handleCommentClicks=false;
this.pollPGNMilliseconds=0;
this.pollPGNMillisecondsPostResult=30000;
this.numberPollsAfterResult=5;
this.gotoEndOnRefresh=false;
this.allowPreMoveSelection=false;
this.pieceSet="merida";
this.pieceSize=46;
this.isEndgame=false;
this.tr=false;
this.ie6FixCoordsOffsetSize=4;
this.allIeFixCoordsOffsetSize=0;
this.addVersion=false;
this.ignoreMultipleGames=true;
this.ml=9999;
this.r=false;
this.g=false;
this.g2=false;
this.canPasteFen=false;
this.makeActive=false;
this.avoidMouseoverActive=false;
this.autoScrollMoves=false;
this.moveAnimationLength=0.5;
this.showBracketsOnVariation=true;
this.hideBracketsOnTopLevelVariation=false;
this.variationStartString=" ( ";
this.variationEndString=" ) ";
this.ignoreCommentRegex=null;
this.newlineForEachMainMove=true;
this.useDivClearForNewline=false;
this.showNPS=false;
this.squareColorClass="";
this.analysisWindowName="analysis_window";
this.pieceTakenSize=this.pieceSize;
this.pauseBetweenMoves=800;
this.pgnMode=false;
this.hidePGNErrors=false;
this.previewMode=false;
this.movesFormat="default";
this.boardImagePath="http://ugra-chess.com";
this.showCoordinates=false;
this.highlightFromTo=false;
this.highlightValidSquares=false;
this.fideClock=false;
this.disableFlipper=false;
this.showResult=1;
this.showEvent=1;
this.showRound=1;
this.showSite=1;
this.showDate=1;
this.ignoreFlipping=false;
this.reverseFlip=false;
this.autoplayFirst=false;
this.dontOutputNavButtons=false;
this.dontCheckLeavingPage=false;
this.clickAndClick=false;
this.clickAndClickDisabled=false;
this.whiteMoveSoundName="movePiece3";
this.blackMoveSoundName="movePiece7";
this.whiteTakeSoundName="takePiece1";
this.blackTakeSoundName="takePiece1";
this.soundEnabled=false;
this.gamedb=false;
};
BoardConfig.prototype.applyConfig=function(_10){
for(var _11 in _10){
this[_11]=_10[_11];
}
};
ChessApp=function(_12){
this.displayMode=false;
this.config=_12;
this.board=null;
};
ChessApp.prototype.setDisplayMode=function(_13){
this.displayMode=_13;
};
ChessApp.prototype.setProblemNumber=function(_14,_15){
this.problemNumber=_14;
this.attId=_15;
};
ChessApp.prototype.init=function(e,_17,_18,us,_1a){
ChessPiece.init();
this.board=new Board(this.config.boardName);
if(_1a){
this.board.addUpdatePieceListener(us);
}
this.board.moveArray=new Array();
if(!this.hideOnInit){
YAHOO.util.Dom.setStyle(this.config.boardName+"-container","display","block");
YAHOO.util.Dom.setStyle("toPlaySpan","display","inline");
}
this.tactics=(this.displayMode||this.config.pgnMode||this.config.previewMode||this.config.fenBoard)?null:new TacticsUI(this.board);
this.problem=(this.config.pgnMode||this.config.previewMode||this.config.fenBoard)?null:new ProblemUI(this.board,this.tactics);
this.board.tactics=this.tactics;
this.board.problem=this.problem;
this.board.puzzle=this.config.puzzle;
if(this.problem){
this.problem.autoPlayOpponent=1;
}
this.pgn=(this.config.pgnMode)?new PGN(this.board):null;
var _1b=MovesDisplay.DEFAULT_DISPLAY_TYPE;
if(this.config.movesFormat=="main_on_own_line"){
_1b=MovesDisplay.MAIN_ON_OWN_LINE;
}
this.movesDisplay=new MovesDisplay(this.board,_1b);
this.movesDisplay.variationOnOwnLine=this.config.variationOnOwnLine;
this.board.movesDisplay=this.movesDisplay;
this.board.boardImagePath=this.config.boardImagePath;
this.board.showNPS=this.config.showNPS;
this.board.analysisWindowName=this.config.analysisWindowName;
this.board.squareColorClass=this.config.squareColorClass;
this.board.tr=this.config.tr;
this.board.scrollToBoardTop=this.config.scrollToBoardTop;
this.board.ml=this.config.ml;
this.board.r=this.config.r;
this.board.g=this.config.g;
this.board.g2=this.config.g2;
this.board.canPasteFen=this.config.canPasteFen;
this.board.addVersion=this.config.addVersion;
this.board.ignoreMultipleGames=this.config.ignoreMultipleGames;
this.board.ie6FixCoordsOffsetSize=this.config.ie6FixCoordsOffsetSize;
this.board.allIeFixCoordsOffsetSize=this.config.allIeFixCoordsOffsetSize;
this.board.allowingFreeMovement=this.config.allowingFreeMovement;
this.board.autoScrollMoves=this.config.autoScrollMoves;
this.board.moveAnimationLength=this.config.moveAnimationLength;
this.board.showBracketsOnVariation=this.config.showBracketsOnVariation;
this.board.hideBracketsOnTopLevelVariation=this.config.hideBracketsOnTopLevelVariation;
this.board.variationStartString=this.config.variationStartString;
this.board.variationEndString=this.config.variationEndString;
this.board.ignoreCommentRegex=this.config.ignoreCommentRegex;
this.board.newlineForEachMainMove=this.config.newlineForEachMainMove;
this.board.useDivClearForNewline=this.config.useDivClearForNewline;
this.board.pieceSize=this.config.pieceSize;
this.board.showToMoveIndicators=this.config.showToMoveIndicators;
this.board.handleCommentClicks=this.config.handleCommentClicks;
this.board.scrollOffsetCorrection=this.config.scrollOffsetCorrection;
this.board.pollPGNMilliseconds=this.config.pollPGNMilliseconds;
this.board.pollPGNMillisecondsPostResult=this.config.pollPGNMillisecondsPostResult;
this.board.numberPollsAfterResult=this.config.numberPollsAfterResult;
this.board.gotoEndOnRefresh=this.config.gotoEndOnRefresh;
this.board.allowPreMoveSelection=this.config.allowPreMoveSelection;
this.board.pieceTakenSize=this.config.pieceTakenSize;
this.board.pieceSet=this.config.pieceSet;
this.board.pauseBetweenMoves=this.config.pauseBetweenMoves;
this.board.showCoordinates=this.config.showCoordinates;
this.board.highlightFromTo=this.config.highlightFromTo;
this.board.highlightValidSquares=this.config.highlightValidSquares;
this.board.fideClock=this.config.fideClock;
this.board.disableFlipper=this.config.disableFlipper;
this.board.showDate=this.config.showDate;
this.board.showEvent=this.config.showEvent;
this.board.showGame=this.config.showGame;
this.board.showResult=this.config.showResult;
this.board.showRound=this.config.showRound;
this.board.showSite=this.config.showSite;
this.board.ignoreFlipping=this.config.ignoreFlipping;
this.board.reverseFlip=this.config.reverseFlip;
this.board.autoplayFirst=this.config.autoplayFirst;
this.board.scrollVariations=this.config.scrollVariations;
this.board.dontOutputNavButtons=this.config.dontOutputNavButtons;
this.board.clickAndClick=this.config.clickAndClick;
this.board.clickAndClickDisabled=this.config.clickAndClickDisabled;
this.board.avoidMouseoverActive=this.config.avoidMouseoverActive;
this.board.dontCheckLeavingPage=this.config.dontCheckLeavingPage;
this.board.whiteMoveSoundName=this.config.whiteMoveSoundName;
this.board.whiteTakeSoundName=this.config.whiteTakeSoundName;
this.board.blackMoveSoundName=this.config.blackMoveSoundName;
this.board.blackTakeSoundName=this.config.blackTakeSoundName;
this.board.soundEnabled=this.config.soundEnabled;
this.board.hidePGNErrors=this.config.hidePGNErrors;
this.board.gamedb=this.config.gamedb;
if(this.config.makeActive){
activeBoard=this.board;
}
if(this.problem){
this.problem.isEndgame=this.config.isEndgame;
}
if(!this.board.puzzle&&typeof loginManager!="undefined"){
if(this.tactics){
loginManager.setLoginCallback(this.tactics.loginCallback,this.tactics);
loginManager.setLogoutCallback(this.tactics.logoutCallback,this.tactics);
}
if(this.problem){
loginManager.setSessionCallback(this.problem.sessionCallback,this.problem);
}
}
YAHOO.util.DragDropMgr.clickTimeThresh=50;
YAHOO.util.DragDropMgr.clickPixelThresh=1;
this.board.createBoardUI();
if(!this.board.puzzle){
if(this.problem){
this.problem.createProblemUI();
}
if(this.tactics){
this.tactics.initProblemCompleteOverlay();
}
if(this.problem){
this.problem.initLoadingOverlay();
}
if(this.config.pgnMode){
if(this.config.pgnFile){
this.pgn.getPGNFromURL(this.config.pgnFile,this.config.gotoEndOnRefresh);
if(this.config.pollPGNMilliseconds){
this.pgn.foundResult=false;
this.pgn.foundResultPolls=0;
this.pgn.pollPGNFromURL(this.config.pgnFile,this.config.gotoEndOnRefresh,this.config.pollPGNMilliseconds);
}
}else{
if(this.config.pgnString){
this.pgn.setupFromPGN(this.config.pgnString);
}else{
if(this.config.pgnDiv){
var _1c=YAHOO.util.Dom.get(this.config.pgnDiv);
if(_1c){
this.pgn.setupFromPGN(_1c.innerHTML);
}
}
}
}
}else{
if(!this.board.dontCheckLeavingPage&&this.tactics){
YAHOO.util.Event.addListener(window,"beforeunload",this.tactics.checkLeavingPage,this.tactics,true);
YAHOO.util.Event.addListener(window,"unload",this.tactics.leavingPage,this.tactics,true);
this.tactics.updateSessionDisplay(0,0);
if(typeof showingStart!="undefined"&&showingStart){
var _1d=this;
var _1e="";
if(loggedIn){
if(this.config.isEndgame){
_1e=_js("Endgame Problem Set")+": <span id=\"startProblemSetStr\">"+_js(startEndgameSetName)+"</span>";
}else{
_1e=_js("Tactics Problem Set")+": <span id=\"startProblemSetStr\">"+_js(startTacticsSetName)+"</span>";
}
}
this.board.preloadPieces();
var _1f=new YAHOO.widget.SimpleDialog("starttacticdialog1",{width:"300px",fixedcenter:true,modal:false,visible:true,draggable:true,close:false,text:"<div style=\"color:black\">"+_1e+"</div><br/>"+"<div style=\"color:black\">"+_js("Click start to begin solving problems")+"</div>",icon:YAHOO.widget.SimpleDialog.ICON_INFO,constraintoviewport:true,buttons:[{text:_js("Start"),handler:function(){
if(_1d.board.imagesLoaded){
this.hide();
_1d.problem.getProblem();
}else{
alert(_js("Still trying to load piece images.\n If you keep receiving this message you may need to reload the page.\n If you continue to get this message, you can disable it by going into your preferences and turning 'show problem start dialog' (available under the other tab) off."));
}
},isDefault:true}]});
var _20=YAHOO.util.Dom.get("ctb-"+this.board.boardName);
_1f.render(document.body);
}else{
this.problem.getProblem();
}
}else{
if(this.problem){
if(this.problemNumber!=""){
YAHOO.util.Dom.setStyle("boardandmoves","display","block");
this.problem.getProblem(this.problemNumber,this.attId);
}
}
}
}
}
this.board.setupEventHandlers();
if(this.problem){
this.problem.setupEventHandlers();
}
if(this.tactics){
this.tactics.setupEventHandlers();
}
if(this.board.scrollToBoardTop){
var xy=YAHOO.util.Dom.getXY(this.board.boardName+"-boardBorder");
window.scrollTo(xy[0],xy[1]);
}
if(this.config.flipListener){
this.board.addFlipListener(this.config.flipListener);
}
};
function clearClone(o){
if(o==null){
return;
}
for(prop in o){
if(typeof (o[prop])=="object"&&o[prop]!=null&&o[prop].alreadyCloned){
o[prop].alreadyCloned=false;
clearClone(o[prop]);
}
}
}
function cloneWork(o){
if(o==null){
return null;
}
var _24=new Object();
for(prop in o){
if(typeof (o[prop])=="object"){
_24[prop]=o[prop];
}else{
_24[prop]=o[prop];
}
}
return _24;
}
function clone(o){
return cloneWork(o);
}
get_image_str=function(_26,_27,_28,_29,_2a){
var _2b=".vers"+SITE_VERSION;
if(!_2a){
_2b="";
}
if(check_bad_msie()){
return _27+"/images/"+_28+"/"+_26+_29+_2b+".png";
}else{
return _27+"/images/"+_28+"/"+_26+_29+_2b+".png";
}
};
check_bad_msie=function(){
var _2c=(window.ActiveXObject&&(typeof document.body.style.maxHeight=="undefined"));
return _2c;
};
fix_ie_png=function(img){
if(!check_bad_msie()){
return;
}
var _2e=(img.id)?"id='"+img.id+"' ":"";
var _2f=(img.className)?"class='"+img.className+"' ":"";
var _30=(img.title)?"title='"+img.title+"' ":"title='"+img.alt+"' ";
var _31="display:inline-block;"+img.style.cssText;
if(img.align=="left"){
_31="float:left;"+_31;
}
if(img.align=="right"){
_31="float:right;"+_31;
}
if(img.parentElement.href){
_31="cursor:hand;"+_31;
}
var _32="<span "+_2e+_2f+_30+" style=\""+"width:"+img.width+"px; height:"+img.height+"px;"+_31+";"+"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"+"(src='"+img.src+"', sizingMethod='image');\"></span>";
img.outerHTML=_32;
};
Move=function(_33,_34,_35,_36,_37,_38,_39){
this.fromColumn=_33;
this.fromRow=_34;
this.toColumn=_35;
this.toRow=_36;
this.take=_37;
this.promotion=_38;
this.moveString=_39;
this.prev=null;
this.next=null;
this.numVars=0;
this.prevMoveEnpassant=false;
this.ravLevel=0;
this.atEnd=false;
this.obj_id=move_obj_id_counter++;
this.beforeComment="";
this.afterComment="";
};
Move.prototype.freeMove=function(){
if(this.taken){
this.taken=null;
}
if(this.vars&&this.vars.length>0){
var i=0;
for(var i=0;i<this.vars.length;i++){
this.vars[i].freeMove();
}
}
};
Move.prototype.clone=function(_3b){
var _3c=this.take;
if(_3b&&_3c){
_3c=_3c.makeLightWeight();
}
var _3d=new Move(this.fromColumn,this.fromRow,this.toColumn,this.toRow,_3c,this.promotion,this.moveString);
_3d.moveNum=this.moveNum;
_3d.atEnd=this.atEnd;
_3d.beforeComment=this.beforeComment;
_3d.afterComment=this.afterComment;
_3d.prevMoveEnpassant=this.prevMoveEnpassant;
if(this.vars){
_3d.vars=[];
var cnt=0;
for(var i=0;i<this.vars.length;i++){
_3d.vars[i]=this.vars[i].clone(_3b);
cnt++;
}
_3d.numVars=cnt;
}
return _3d;
};
Move.columnToChar=function(col){
var a=String.fromCharCode("a".charCodeAt(0)+col);
return a;
};
Move.prototype.output=function(){
return Move.columnToChar(this.fromColumn)+""+(this.fromRow+1)+":"+Move.columnToChar(this.toColumn)+""+(this.toRow+1)+" prom:"+this.promotion+" objid:"+this.obj_id+" dummy:"+this.dummy+" endNode:"+this.endNode+" index:"+this.index+" moveNum:"+this.moveNum+" atEnd:"+this.atEnd+" beforeCom:"+this.beforeComment+" afterCom:"+this.afterComment;
};
Move.prototype.equals=function(m){
return (m&&(this.fromColumn==m.fromColumn&&this.fromRow==m.fromRow&&this.promotion==m.promotion&&this.toColumn==m.toColumn&&this.toRow==m.toRow));
};
Move.moveArraysEqual=function(a1,a2){
if(a1==a2){
return true;
}
if(a1==null||a2==null){
return false;
}
if(a1.length!=a2.length){
return false;
}
for(var i=0;i<a1.length;i++){
if(!a1[i].equals(a2[i])){
return false;
}
if(!Move.moveArraysEqual(a1[i].vars,a2[i].vars)){
return false;
}
}
return true;
};
Move.findMoveInNewArray=function(a1,a2,_48){
if(a1==a2){
return _48;
}
if(a1==null||a2==null){
return null;
}
if(a1.length!=a2.length){
return null;
}
for(var i=0;i<a1.length;i++){
if(!a1[i].equals(a2[i])){
return null;
}
if(!Move.moveArraysEqual(a1[i].vars,a2[i].vars)){
return null;
}
if(a1[i]==_48){
return a2[i];
}
}
return null;
};
Move.prototype.toMoveString=function(){
var _4a="";
if(this.promotion){
_4a=this.promotion;
}
return Move.columnToChar(this.fromColumn)+""+(this.fromRow+1)+Move.columnToChar(this.toColumn)+""+(this.toRow+1)+_4a;
};
function getTagValue(_4b,_4c){
var _4d=_4b.getElementsByTagName(_4c);
if(_4d==null){
YAHOO.log("got null node for tag:"+_4c);
return null;
}
if(_4d.length==0){
YAHOO.log("got empty array node for tag:"+_4c);
return null;
}
if(_4d[0].firstChild==null){
YAHOO.log("firstChild is null for tag:"+_4c);
return null;
}
if(_4d[0].firstChild.nodeValue==null){
YAHOO.log("firstChild.nodeValue is null for tag:"+_4c);
return null;
}
if(typeof (_4d[0].textContent)!="undefined"){
return _4d[0].textContent;
}
return _4d[0].firstChild.nodeValue;
}
var ua=navigator.userAgent.toLowerCase();
var isOpera=(ua.indexOf("opera")>-1);
var isIphone=(navigator.userAgent.match(/iPhone/i))||(navigator.userAgent.match(/iPod/i));
var isIpad=(navigator.userAgent.match(/iPad/i));
var isSafari=(ua.indexOf("safari")>-1);
var isGecko=(!isOpera&&!isSafari&&ua.indexOf("gecko")>-1);
var isIE=(!isOpera&&ua.indexOf("msie")>-1);
function unescapeHtml(s){
var n=document.createElement("div");
n.innerHTML=s;
if(n.innerText){
return n.innerText;
}else{
return n.textContent;
}
}
ChessPiece=function(div,_51,_52,_53){
var id=div.id;
this.board=_53;
this.icon=get_image_str(ChessPiece.pieceIconNames[_51][_52],this.board.boardImagePath,this.board.pieceSet,this.board.pieceSize,this.board.addVersion);
this.colour=_51;
this.piece=_52;
this.id=id;
this.div=div;
var _55=_53.getPieceDragDiv();
var _56=false;
var _57="";
if(_55==null){
_55=document.createElement("div");
_55.id="pieceDragDiv";
_56=true;
YAHOO.util.Dom.setStyle(_55,"visibility","hidden");
YAHOO.util.Dom.setStyle(_55,"border","0px");
YAHOO.util.Dom.setStyle(_55,"position","absolute");
}
this.pieceDragEl=_55;
this.pieceDragElId="pieceDragDiv";
if(_56){
var _58=this.board.getDocBody();
if(_58){
_58.appendChild(_55);
}
}
if(YAHOO.util.Event.isIE||isOpera){
var _59=this.div;
_59.innerHTML="<img src=\""+this.icon+"\"/>";
var img=_59.firstChild;
fix_ie_png(img);
}else{
YAHOO.util.Dom.setStyle([this.div],"backgroundImage","url("+this.icon+")");
}
YAHOO.util.Dom.setStyle([this.div],"height",this.board.pieceSize+"px");
YAHOO.util.Dom.setStyle([this.div],"width",this.board.pieceSize+"px");
if(isIphone||isIpad){
if(!this.board.clickAndClick){
initIphone(this.div);
}
}
YAHOO.util.Dom.setStyle([this.div],"position","relative");
if(!this.board.clickAndClick){
this.init(id,"ct-"+this.board.boardName+"-boardandpieces",{dragElId:this.pieceDragElId,resizeFrame:true,centerFrame:false,isTarget:false});
this.initFrame();
}
};
ChessPiece.prototype=new YAHOO.util.DDProxy();
ChessPiece.PAWN=0;
ChessPiece.BISHOP=1;
ChessPiece.KNIGHT=2;
ChessPiece.ROOK=3;
ChessPiece.KING=4;
ChessPiece.QUEEN=5;
ChessPiece.WHITE=0;
ChessPiece.BLACK=1;
ChessPiece.init=function(){
ChessPiece.pieceIconNames=new Array(2);
ChessPiece.pieceIconNames[0]=new Array(6);
ChessPiece.pieceIconNames[1]=new Array(6);
ChessPiece.pieceIconNames[ChessPiece.WHITE][ChessPiece.PAWN]="whitepawn";
ChessPiece.pieceIconNames[ChessPiece.WHITE][ChessPiece.BISHOP]="whitebishop";
ChessPiece.pieceIconNames[ChessPiece.WHITE][ChessPiece.KNIGHT]="whiteknight";
ChessPiece.pieceIconNames[ChessPiece.WHITE][ChessPiece.ROOK]="whiterook";
ChessPiece.pieceIconNames[ChessPiece.WHITE][ChessPiece.KING]="whiteking";
ChessPiece.pieceIconNames[ChessPiece.WHITE][ChessPiece.QUEEN]="whitequeen";
ChessPiece.pieceIconNames[ChessPiece.BLACK][ChessPiece.PAWN]="blackpawn";
ChessPiece.pieceIconNames[ChessPiece.BLACK][ChessPiece.BISHOP]="blackbishop";
ChessPiece.pieceIconNames[ChessPiece.BLACK][ChessPiece.KNIGHT]="blackknight";
ChessPiece.pieceIconNames[ChessPiece.BLACK][ChessPiece.ROOK]="blackrook";
ChessPiece.pieceIconNames[ChessPiece.BLACK][ChessPiece.KING]="blackking";
ChessPiece.pieceIconNames[ChessPiece.BLACK][ChessPiece.QUEEN]="blackqueen";
};
ChessPiece.materialValue=function(_5b){
switch(_5b){
case ChessPiece.PAWN:
return 1;
break;
case ChessPiece.BISHOP:
return 3;
break;
case ChessPiece.KNIGHT:
return 3;
break;
case ChessPiece.ROOK:
return 5;
break;
case ChessPiece.KING:
return 0;
break;
case ChessPiece.QUEEN:
return 9;
break;
}
return 0;
};
ChessPiece.prototype.free=function(){
if(!this.board.clickAndClick){
this.unreg();
}
};
ChessPiece.prototype.clickValidator=function(e){
if(this.board.dragDisabled){
return false;
}
if(!this.board.allowPreMoveSelection&&(this.board.toMove!=this.colour)){
return false;
}
if(this.board.restrictedColourMovement!=-1&&this.colour!=this.board.restrictedColourMovement){
return;
}
if(false&&this.board.clickAndClick){
return false;
}
var _5d=YAHOO.util.Event.getTarget(e);
var _5e=(this.isValidHandleChild(_5d)&&(this.id==this.handleElId||this.DDM.handleWasClicked(_5d,this.id)));
this.board.selectDestSquare(e);
if(true||!_5e){
YAHOO.util.Event.preventDefault(e);
}
return _5e;
};
ChessPiece.prototype.onDragOut=function(e,id){
this.insideBoard=false;
};
ChessPiece.prototype.onDragEnter=function(e,id){
this.insideBoard=true;
};
ChessPiece.prototype.endDrag=function(e){
if(this.board.lastOverSquare){
YAHOO.util.Dom.removeClass(this.board.lastOverSquare,"ct-over-valid-square");
YAHOO.util.Dom.removeClass(this.board.lastOverSquare,"ct-over-invalid-square");
}
this.board.lastOverSquare=null;
if(!this.insideBoard){
this.board.board_xy=null;
this.setPosition(this.column,this.row,false,null,this.board.moveAnimationLength);
}
if(!this.hideAfterDragEnd){
YAHOO.util.Dom.setStyle(this.getEl(),"visibility","visible");
}else{
this.hideAfterDragEnd=false;
}
};
ChessPiece.prototype.startDrag=function(x,y){
this.insideBoard=true;
var _66=null;
if(this.board.currentMove){
if(this.board.currentMove.prev){
_66=this.board.currentMove.prev;
}else{
_66=this.board.prev_move;
}
}else{
_66=this.board.prev_move;
}
if(this.board.highlightValidSquares){
this.candidates=null;
this.candidates=new Array(8);
for(var i=0;i<8;i++){
this.candidates[i]=new Array(8);
for(var j=0;j<8;j++){
this.candidates[i][j]=false;
}
}
}
this.pieceDragEl.innerHTML="<img src=\""+this.icon+"\"/>";
var img=this.pieceDragEl.firstChild;
fix_ie_png(img);
YAHOO.util.Dom.setStyle(this.pieceDragEl,"zIndex",1000);
YAHOO.util.Dom.setStyle(this.pieceDragEl,"height",this.board.pieceSize+"px");
YAHOO.util.Dom.setStyle(this.pieceDragEl,"width",this.board.pieceSize+"px");
YAHOO.util.Dom.setStyle(this.getEl(),"visibility","hidden");
if(this.board.highlightValidSquares){
for(var i=0;i<8;i++){
for(var j=0;j<8;j++){
var _6a=7-i;
var _6b=j;
if(this.board.isFlipped){
_6a=7-_6a;
_6b=7-_6b;
}
if((_6a==this.row&&_6b==this.column)||this.board.canMove(this.makeLightWeight(),_6b,_6a,_66,true)){
this.candidates[j][i]=true;
}
}
}
}
};
ChessPiece.prototype.onDragOver=function(e,id){
var x=YAHOO.util.Event.getPageX(e);
var y=YAHOO.util.Event.getPageY(e);
var _70=YAHOO.util.Dom.getX("ctb-"+this.board.boardName);
var _71=YAHOO.util.Dom.getY("ctb-"+this.board.boardName);
var c=parseInt((x-_70)/this.board.pieceSize);
var r=parseInt((y-_71)/this.board.pieceSize);
var _74=this.board.boardName+"-s"+c+""+(7-r);
var _75=YAHOO.util.Dom.get(_74);
if(this.board.highlightValidSquares){
if(this.board.lastOverSquare){
if(this.board.lastOverSquare!=_75){
YAHOO.util.Dom.removeClass(this.board.lastOverSquare,"ct-over-valid-square");
YAHOO.util.Dom.removeClass(this.board.lastOverSquare,"ct-over-invalid-square");
this.board.lastOverSquare=null;
if(this.candidates&&c<8&&c>=0&&r<8&&r>=0&&this.candidates[c][r]){
YAHOO.util.Dom.addClass(_75,"ct-over-valid-square");
}else{
YAHOO.util.Dom.addClass(_75,"ct-over-invalid-square");
}
}
}
this.board.lastOverSquare=_75;
}
};
ChessPiece.prototype.onDragDrop=function(e,id){
if(this.board.blockFowardBack||this.board.deferredBlockForwardBack){
return false;
}
if(this.board.allowPreMoveSelection&&this.board.toMove!=this.colour){
return false;
}
if(this.board.lastOverSquare){
YAHOO.util.Dom.removeClass(this.board.lastOverSquare,"ct-over-valid-square");
YAHOO.util.Dom.removeClass(this.board.lastOverSquare,"ct-over-invalid-square");
}
var x=YAHOO.util.Event.getPageX(e);
var y=YAHOO.util.Event.getPageY(e);
var _7a=YAHOO.util.Dom.getX("ctb-"+this.board.boardName);
var _7b=YAHOO.util.Dom.getY("ctb-"+this.board.boardName);
var c=parseInt((x-_7a)/this.board.pieceSize);
var r=parseInt((y-_7b)/this.board.pieceSize);
if(this.board.isFlipped){
r=7-r;
c=7-c;
}
if(this.board.allowPreMoveSelection&&(this.board.boardPieces[this.column][this.row]!=this)){
this.setVisible(false);
this.hideAfterDragEnd=true;
return false;
}
var _7e=false;
if(!this.board.currentMove||this.board.currentMove.atEnd){
_7e=true;
}
this.board.updatePiece(this,c,7-r,false,false,true);
if(!_7e&&this.board.currentMove&&!this.board.allowingFreeMovement&&this.board.currentMove.atEnd){
this.board.toggleToMove();
this.board.updateToPlay();
}
};
ChessPiece.prototype.makeLightWeight=function(){
var cp=this.board.createPiece(this.colour,this.piece,true);
cp.column=this.column;
cp.row=this.row;
cp.enPassant=this.enPassant;
cp.castled=this.castled;
return cp;
};
ChessPiece.prototype.removeFromParent=function(){
var _80=this.div;
if(_80.parentNode){
_80.parentNode.removeChild(_80);
}
};
ChessPiece.prototype.setVisible=function(_81){
var _82;
var _83;
if(_81){
_83="block";
_82="visible";
}else{
_83="none";
_82="hidden";
}
YAHOO.util.Dom.setStyle(this.id,"visibility",_82);
};
ChessPiece.prototype.moveResponse=function(o){
};
ChessPiece.prototype.getIcon=function(){
return this.icon;
};
ChessPiece.prototype.makeHeavyWeight=function(){
return this.copyPiece();
};
ChessPiece.prototype.copyPiece=function(){
var cp=new ChessPiece(this.div,this.colour,this.piece,this.board);
cp.column=this.column;
cp.row=this.row;
cp.enPassant=this.enPassant;
cp.castled=this.castled;
return cp;
};
ChessPiece.prototype.changePieceKeepImage=function(_86){
var _87=(_86+"").toLowerCase().charAt(0);
switch(_87){
case "k":
this.piece=ChessPiece.KING;
break;
case "q":
this.piece=ChessPiece.QUEEN;
break;
case "r":
this.piece=ChessPiece.ROOK;
break;
case "b":
this.piece=ChessPiece.BISHOP;
break;
case "n":
this.piece=ChessPiece.KNIGHT;
break;
case "p":
this.piece=ChessPiece.PAWN;
break;
default:
}
};
ChessPiece.prototype.changePiece=function(_88){
this.changePieceKeepImage(_88);
this.icon=get_image_str(ChessPiece.pieceIconNames[this.colour][this.piece],this.board.boardImagePath,this.board.pieceSet,this.board.pieceSize,this.board.addVersion);
if(YAHOO.util.Event.isIE||isOpera){
var _89=this.div;
_89.innerHTML="<img src=\""+this.icon+"\"/>";
var img=_89.firstChild;
if(!isOpera){
fix_ie_png(img);
}
}else{
YAHOO.util.Dom.setStyle(this.div,"backgroundImage","url("+this.icon+")");
YAHOO.util.Dom.setStyle(this.div,"background-repeat","no-repeat");
}
};
ChessPiece.prototype.getNewXYPosition=function(_8b,row){
var _8d=this.board.getBoardDiv();
var _8e=this.board.getXY();
var _8f=_8e[0];
var _90=_8e[1];
var _91=[0,0];
if(this.board.isFlipped){
_91[0]=_8f+((7-_8b)*this.board.pieceSize);
_91[1]=_90+((row)*this.board.pieceSize);
}else{
_91[0]=_8f+((_8b)*this.board.pieceSize);
_91[1]=_90+((7-row)*this.board.pieceSize);
}
return _91;
};
ChessPiece.prototype.setPosition=function(_92,row,_94,_95,_96,_97,_98){
this.column=_92;
this.row=row;
if(this.board.pieceMoveDisabled){
return;
}
var _99=this.div;
var _9a=null;
if(this.board.isFlipped){
_9a=this.board.boardName+"-s"+(7-this.column)+""+(7-this.row);
}else{
_9a=this.board.boardName+"-s"+(this.column)+""+(this.row);
}
var _9b=this.board.getBoardDivFromId(_9a);
var _9c=null;
if(!_97){
_9c=(this.colour==ChessPiece.WHITE)?this.board.whiteMoveSoundName:this.board.blackMoveSoundName;
}else{
_9c=(this.colour==ChessPiece.WHITE)?this.board.whiteTakeSoundName:this.board.blackTakeSoundName;
}
if(!_94){
if(!this.board.settingUpPosition){
var _9d=this.getNewXYPosition(_92,row);
YAHOO.util.Dom.setXY(_99,_9d,false);
}else{
if(_99.parentNode){
_99.parentNode.removeChild(_99);
}
_9b.appendChild(_99);
}
this.setVisible(true);
if(_98&&this.board.soundEnabled){
boardSounds.playSound(_9c);
}
if(_95){
_95();
}
}else{
var _9d=this.getNewXYPosition(_92,row);
if(this.board.oldAnim&&this.board.oldAnim.isAnimated()){
this.board.oldAnim.stop();
YAHOO.util.Dom.setXY(this.board.oldAnimPieceDiv,this.board.old_new_xy,false);
}
var _9e=new YAHOO.util.Motion(_99,{points:{to:_9d}});
this.board.oldAnim=_9e;
this.board.oldAnimPieceDiv=_99;
this.board.old_new_xy=_9d;
_9e.duration=_96;
var _9f=this;
_9e.onComplete.subscribe(function(){
if(_9f.board.soundEnabled){
boardSounds.playSound(_9c);
}
});
if(_95){
_9e.onComplete.subscribe(_95);
}
_9e.animate();
}
};
ChessPiece.prototype.getFenLetter=function(){
var _a0=ChessPiece.pieceTypeToChar(this.piece)+"";
if(this.colour!=ChessPiece.WHITE){
_a0=_a0.toLowerCase();
}
return _a0;
};
ChessPiece.pieceTypeToChar=function(_a1){
switch(_a1){
case ChessPiece.KING:
return "K";
case ChessPiece.QUEEN:
return "Q";
case ChessPiece.ROOK:
return "R";
case ChessPiece.BISHOP:
return "B";
case ChessPiece.KNIGHT:
return "N";
case ChessPiece.PAWN:
return "P";
}
return "?";
};
LightweightChessPiece=function(div,_a3,_a4,_a5){
this.board=_a5;
this.colour=_a3;
this.piece=_a4;
this.div=div;
};
LightweightChessPiece.prototype.getFenLetter=ChessPiece.prototype.getFenLetter;
LightweightChessPiece.prototype.makeLightWeight=function(){
return this.copyPiece();
};
LightweightChessPiece.prototype.makeHeavyWeight=function(){
var cp=this.board.createPiece(this.colour,this.piece,false);
cp.column=this.column;
cp.row=this.row;
cp.enPassant=this.enPassant;
cp.castled=this.castled;
return cp;
};
LightweightChessPiece.prototype.setVisible=function(_a7){
};
LightweightChessPiece.prototype.free=function(){
};
LightweightChessPiece.prototype.setPosition=function(_a8,row,_aa,_ab,_ac){
this.column=_a8;
this.row=row;
};
LightweightChessPiece.prototype.copyPiece=function(){
var cp=new LightweightChessPiece(this.id,this.colour,this.piece,this.board);
cp.column=this.column;
cp.row=this.row;
return cp;
};
LightweightChessPiece.prototype.changePiece=function(_ae){
this.changePieceKeepImage(_ae);
};
LightweightChessPiece.prototype.changePieceKeepImage=function(_af){
var _b0=(_af+"").toLowerCase().charAt(0);
switch(_b0){
case "k":
this.piece=ChessPiece.KING;
break;
case "q":
this.piece=ChessPiece.QUEEN;
break;
case "r":
this.piece=ChessPiece.ROOK;
break;
case "b":
this.piece=ChessPiece.BISHOP;
break;
case "n":
this.piece=ChessPiece.KNIGHT;
break;
case "p":
this.piece=ChessPiece.PAWN;
break;
default:
}
};
MovesDisplay=function(_b1,_b2){
this.board=_b1;
this.displayType=_b2;
};
MovesDisplay.DEFAULT_DISPLAY_TYPE=0;
MovesDisplay.MAIN_ON_OWN_LINE=1;
Board=function(_b3){
this.boardName=_b3;
if(_b3){
this.initTarget("ctb-"+_b3,"ct-"+this.boardName+"-boardandpieces");
this.boardPieces=Board.createBoardArray();
}
this.imagesLoaded=false;
this.disableNavigation=false;
this.currentMove=null;
this.moveIndex=-1;
this.restrictedColourMovement=-1;
this.settingUpPosition=false;
this.pendingLevelZeroCommentaryClose=false;
this.isUserFlipped=false;
this.registeredFlipListeners=[];
this.registeredForwardAtEndListeners=[];
this.registeredPasteFenClickedListeners=[];
this.registeredGotoMoveIndexListeners=[];
this.registeredBackMovePreCurrentListeners=[];
this.registeredForwardMovePostUpdateListeners=[];
this.registeredUpdateListeners=[];
this.registeredUpdatePieceFinishedListeners=[];
this.registeredUpdateEndOfMovesListeners=[];
this.registeredUpdateHaveAltListeners=[];
this.registeredUpdateWrongMoveListeners=[];
this.registeredUpdateAllowMoveListeners=[];
this.moveNumber=1;
this.halfMoveNumber=0;
};
Board.prototype=new YAHOO.util.DDTarget();
Board.invertToMove=function(_b4){
if(_b4==ChessPiece.WHITE){
return ChessPiece.BLACK;
}else{
return ChessPiece.WHITE;
}
};
Board.boardStyleToClassName=function(_b5){
var _b6="";
switch(_b5){
case 0:
_b6="-lightgrey";
break;
case 1:
_b6="-grey";
break;
case 2:
_b6="-brown";
break;
case 3:
_b6="-green";
break;
case 4:
_b6="-woodlight";
break;
case 5:
_b6="-wooddark";
break;
case 6:
_b6="-metal";
break;
case 7:
_b6="-marblebrown";
break;
case 8:
_b6="-stucco";
break;
case 9:
_b6="-goldsilver";
break;
case 10:
_b6="-sandsnow";
break;
case 11:
_b6="-crackedstone";
break;
case 12:
_b6="-granite";
break;
case 13:
_b6="-marblegreen";
break;
case 14:
_b6="-greenwhite";
break;
default:
}
return _b6;
};
Board.createBoardArray=function(){
var _b7=boardPool.getObject();
if(_b7==null){
_b7=new Array(8);
for(var i=0;i<8;i++){
_b7[i]=new Array(8);
}
}
return _b7;
};
Board.prototype.preloadPieces=function(){
var _b9=[];
for(var i=0;i<ChessPiece.QUEEN;i++){
for(var j=0;j<2;j++){
var _bc=get_image_str(ChessPiece.pieceIconNames[j][i],this.boardImagePath,this.pieceSet,this.pieceSize,true);
_b9.push(_bc);
}
}
var _bd=this;
function checkImages(){
var _be=true;
for(var i=0;i<_b9.length;i++){
var img=document.createElement("img");
img.src=_b9[i];
if(!img.complete||(typeof img.naturalWidth!="undefined"&&img.naturalWidth==0)){
_be=false;
}
}
if(!_be){
setTimeout(checkImages,1000);
}else{
_bd.imagesLoaded=true;
}
}
checkImages();
};
Board.prototype.selectDestSquare=function(e){
if(this.clickAndClickDisabled){
return true;
}
var _c2=(new Date()).getTime();
var _c3=false;
if(_c2-this.lastDestClick<100){
_c3=true;
}
this.lastDestClick=_c2;
var x=YAHOO.util.Event.getPageX(e);
var y=YAHOO.util.Event.getPageY(e);
var _c6=YAHOO.util.Dom.getX("ctb-"+this.boardName);
var _c7=YAHOO.util.Dom.getY("ctb-"+this.boardName);
var c=parseInt((x-_c6)/this.pieceSize);
var r=parseInt((y-_c7)/this.pieceSize);
var _ca=this.boardName+"-s"+c+""+(7-r);
var _cb=YAHOO.util.Dom.get(_ca);
if(_cb==this.oldSelectedSquare){
if(!_c3){
YAHOO.util.Dom.removeClass(_cb,"ct-source-square");
this.oldSelectedSquare=null;
this.oldSelectedPiece=null;
if(this.oldDestSquare){
YAHOO.util.Dom.removeClass(this.oldDestSquare,"ct-dest-square");
this.oldDestSquare=null;
}
}
return true;
}
if(this.isFlipped){
c=7-c;
r=7-r;
}
r=7-r;
var _cc=this.boardPieces[c][r];
if(_cc&&(_cc.colour==this.toMove||this.allowPreMoveSelection)&&(this.restrictedColourMovement==-1||(_cc.colour==this.restrictedColourMovement))){
if(this.oldSelectedSquare){
YAHOO.util.Dom.removeClass(this.oldSelectedSquare,"ct-source-square");
}
if(this.oldDestSquare){
YAHOO.util.Dom.removeClass(this.oldDestSquare,"ct-dest-square");
this.oldDestSquare=null;
}
YAHOO.util.Dom.addClass(_cb,"ct-source-square");
this.oldSelectedSquare=_cb;
this.oldSelectedPiece=_cc;
}else{
if(this.oldSelectedSquare){
if(this.oldSelectedPiece&&this.oldSelectedPiece.colour!=this.toMove){
return false;
}
var _cd=null;
if(this.currentMove){
if(this.currentMove.prev){
_cd=this.currentMove.prev;
}else{
_cd=this.prev_move;
}
}else{
_cd=this.prev_move;
}
if(this.canMove(this.oldSelectedPiece.makeLightWeight(),c,r,_cd,true)){
this.lastDestSquare=_cb;
this.lastDestRow=r;
this.lastDestColumn=c;
YAHOO.util.Dom.removeClass(this.oldSelectedSquare,"ct-source-square");
var _ce=false;
if(!this.currentMove||this.currentMove.atEnd){
_ce=true;
}
this.updatePiece(this.oldSelectedPiece,c,r,false,false,true);
this.oldSelectedPiece=null;
this.oldSelectedSquare=null;
if(!_ce&&this.currentMove&&!this.allowingFreeMovement&&this.currentMove.atEnd){
this.toggleToMove();
this.updateToPlay();
}
}else{
}
}else{
return true;
}
}
};
Board.prototype.selectSourcePiece=function(_cf){
if(this.lastSourceSquare){
YAHOO.util.Dom.removeClass(_d0,"ct-source-square");
}
var r=_cf.row;
var c=_cf.column;
if(this.isFlipped){
r=7-r;
c=7-c;
}
var _d3=this.boardName+"-s"+c+""+r;
var _d0=YAHOO.util.Dom.get(_d3);
YAHOO.util.Dom.addClass(_d0,"ct-source-square");
this.lastSourceSquare=_d0;
this.lastSourcePiece=_cf;
this.lastSourceRow=_cf.row;
this.lastSourceColumn=_cf.column;
};
Board.prototype.toggleToMove=function(){
if(this.toMove==ChessPiece.WHITE){
this.toMove=ChessPiece.BLACK;
}else{
this.toMove=ChessPiece.WHITE;
}
};
Board.prototype.setupPieceDivs=function(){
var _d4=this.getBoardDiv();
if(this.pieces){
for(var i=0;i<32;i++){
if(this.pieces[i]){
this.pieces[i].setVisible(false);
this.pieces[i].free();
this.pieces[i]=null;
}
}
}
if(this.availPieceDivs){
for(var i=0;i<32;i++){
if(this.availPieceDivs[i]){
if(this.availPieceDivs[i].parentNode){
this.availPieceDivs[i].parentNode.removeChild(this.availPieceDivs[i]);
}
}
}
}
this.availids=null;
this.availIds=new Array(32);
this.availPieceDivs=null;
this.availPieceDivs=new Array(32);
this.pieces=null;
this.pieces=new Array(32);
this.uptoId=0;
this.uptoPiece=0;
};
Board.prototype.getXY=function(){
if(true||!this.board_xy){
this.board_xy=YAHOO.util.Dom.getXY("ctb-"+this.boardName);
}
return this.board_xy;
};
Board.prototype.updateFromTo=function(_d6,_d7,_d8,_d9,_da,_db){
YAHOO.util.Dom.removeClass(this.lastFromSquare,"ct-from-square");
YAHOO.util.Dom.removeClass(this.lastToSquare,"ct-to-square");
if(_d8==null){
return;
}
this.lastFromSquare=_d6;
this.lastToSquare=_d7;
this.lastFromRow=_d8;
this.lastFromColumn=_d9;
this.lastToRow=_da;
this.lastToColumn=_db;
if(this.highlightFromTo){
YAHOO.util.Dom.addClass(_d6,"ct-from-square");
YAHOO.util.Dom.addClass(_d7,"ct-to-square");
}
};
Board.prototype.makeMove=function(_dc,_dd,_de,_df,_e0,_e1,_e2,_e3,_e4){
var _e5;
var _e6;
if(!this.isFlipped){
_e5=YAHOO.util.Dom.get(this.boardName+"-s"+_dc.fromColumn+""+_dc.fromRow);
_e6=YAHOO.util.Dom.get(this.boardName+"-s"+_dc.toColumn+""+_dc.toRow);
}else{
_e5=YAHOO.util.Dom.get(this.boardName+"-s"+(7-_dc.fromColumn)+""+(7-_dc.fromRow));
_e6=YAHOO.util.Dom.get(this.boardName+"-s"+(7-_dc.toColumn)+""+(7-_dc.toRow));
}
if(this.oldSelectedSquare){
if(!this.allowPreMoveSelection||(this.oldSelectedPiece&&_dd&&(this.oldSelectedPiece.colour==_dd.colour))){
YAHOO.util.Dom.removeClass(this.oldSelectedSquare,"ct-source-square");
this.oldSelectedSquare=null;
this.oldSelectedPiece=null;
}
}
if(_e1){
this.updateFromTo(_e5,_e6,_dc.fromRow,_dc.fromColumn,_dc.toRow,_dc.toColumn);
}
var _e7=this.boardPieces[_dc.toColumn][_dc.toRow];
if(_e7!=null){
_e7.enPassant=false;
_e7.castled=false;
}
if(_dd.piece==ChessPiece.PAWN&&_dc.toColumn!=_dc.fromColumn&&this.boardPieces[_dc.toColumn][_dc.toRow]==null){
_e7=this.boardPieces[_dc.toColumn][_dc.fromRow];
this.boardPieces[_dc.toColumn][_dc.fromRow]=null;
if(_e7!=null){
_e7.enPassant=true;
}
}
var _e8=null;
if(_dd.piece==ChessPiece.KING&&Math.abs(_dc.toColumn-_dc.fromColumn)>1){
var _e9;
var _ea;
if(_dc.toColumn>_dc.fromColumn){
_e8=this.boardPieces[7][_dc.fromRow];
_e9=_dc.fromRow;
_ea=5;
this.boardPieces[7][_dc.toRow]=null;
}else{
_e8=this.boardPieces[0][_dc.fromRow];
_e9=_dc.fromRow;
_ea=3;
this.boardPieces[0][_dc.toRow]=null;
}
if(!_e8){
alert("No castle piece");
}else{
_e8.setPosition(_ea,_e9,_de,null,_df,null,_e4);
this.boardPieces[_e8.column][_e8.row]=_e8;
_e8.castled=true;
}
}
_dc.taken=_e7;
if(_e7&&_e0){
this.processTaken(_e7,true);
}
this.moveNumber++;
_dc.preHalfMoveNumber=this.halfMoveNumber;
this.halfMoveNumber++;
if(_e7||_dd.piece==ChessPiece.PAWN){
this.halfMoveNumber=0;
}
this.board_xy=null;
if(_dc.promotion!=null){
_dd.changePieceKeepImage(_dc.promotion);
}
_dd.setPosition(_dc.toColumn,_dc.toRow,_de,function(){
var tp=_e7;
if(tp){
tp.setVisible(false);
}
if(_dc.promotion!=null){
_dd.changePiece(_dc.promotion);
}
if(_e2){
_e2.call(_e3);
}
},_df,_e7,_e4);
if(!_de){
if(_dc.promotion!=null){
_dd.changePiece(_dc.promotion);
}
}
this.boardPieces[_dc.fromColumn][_dc.fromRow]=null;
this.boardPieces[_dc.toColumn][_dc.toRow]=_dd;
if(_e8!=null){
_dc.taken=_e8;
}
_dc.preCastleQueenSide=new Array(2);
_dc.preCastleKingSide=new Array(2);
_dc.preCastleQueenSide[0]=this.canCastleQueenSide[0];
_dc.preCastleQueenSide[1]=this.canCastleQueenSide[1];
_dc.preCastleKingSide[0]=this.canCastleKingSide[0];
_dc.preCastleKingSide[1]=this.canCastleKingSide[1];
if(_dd.piece==ChessPiece.ROOK){
if(_dc.fromColumn==0){
this.canCastleQueenSide[_dd.colour]=false;
}else{
if(_dc.fromColumn==7){
this.canCastleKingSide[_dd.colour]=false;
}
}
}else{
if(_dd.piece==ChessPiece.KING){
this.canCastleQueenSide[_dd.colour]=false;
this.canCastleKingSide[_dd.colour]=false;
}else{
if(_e7&&(_e7.piece==ChessPiece.ROOK)){
if(_dc.toColumn==0){
if(((_e7.colour==ChessPiece.WHITE)&&_dc.toRow==0)||((_e7.colour==ChessPiece.BLACK)&&_dc.toRow==7)){
this.canCastleQueenSide[_e7.colour]=false;
}
}else{
if(_dc.toColumn==7){
if(((_e7.colour==ChessPiece.WHITE)&&_dc.toRow==0)||((_e7.colour==ChessPiece.BLACK)&&_dc.toRow==7)){
this.canCastleKingSide[_e7.colour]=false;
}
}
}
}
}
}
this.updatePositionReached(_dd.colour);
};
Board.prototype.isThreeFoldRep=function(_ec){
var _ed=this.toMove;
if(_ec){
if(_ed==ChessPiece.WHITE){
_ed=ChessPiece.BLACK;
}else{
_ed=ChessPiece.WHITE;
}
}
var _ee=this.boardToUniqueFen(_ed);
return (this.positionsSeen[_ee]>=3);
};
Board.prototype.updatePositionReached=function(_ef){
var _f0=this.boardToUniqueFen(_ef);
if(!this.positionsSeen){
this.positionsSeen=[];
}
if(this.positionsSeen[_f0]){
this.positionsSeen[_f0]++;
}else{
this.positionsSeen[_f0]=1;
}
};
Board.prototype.promptPromotion=function(_f1,col,row,_f4,_f5){
_f1.prePromotionColumn=_f1.column;
_f1.prePromotionRow=_f1.row;
_f1.setPosition(col,row,false,null,this.moveAnimationLength);
var _f6=this;
var _f7=new YAHOO.widget.Dialog("promotionDialogId",{width:"300px",fixedcenter:true,visible:true,modal:true,close:false,constraintoviewport:true,buttons:[{text:_js("Queen"),handler:function(){
_f7.hide();
_f6.updatePiece(_f1,col,row,_f4,_f5,false,"q");
},isDefault:true},{text:_js("Rook"),handler:function(){
_f7.hide();
_f6.updatePiece(_f1,col,row,_f4,_f5,false,"r");
},isDefault:false},{text:_js("Bishop"),handler:function(){
_f7.hide();
_f6.updatePiece(_f1,col,row,_f4,_f5,false,"b");
},isDefault:false},{text:_js("Knight"),handler:function(){
_f7.hide();
_f6.updatePiece(_f1,col,row,_f4,_f5,false,"n");
},isDefault:false}]});
_f7.setHeader(_js("Select Promotion Piece"));
_f7.setBody("<div></div>");
_f7.render(document.body);
};
Board.moveToLocale=function(_f8){
if(!_f8||_f8==""){
return _f8;
}
var _f9="";
for(var i=0;i<_f8.length;i++){
var _fb=_f8.charAt(i);
switch(_fb){
case "K":
_fb=_js("K");
break;
case "Q":
_fb=_js("Q");
break;
case "R":
_fb=_js("R");
break;
case "N":
_fb=_js("N");
break;
case "B":
_fb=_js("B");
break;
case "P":
_fb=_js("P");
break;
case "a":
_fb=_js("a");
break;
case "b":
_fb=_js("b");
break;
case "c":
_fb=_js("c");
break;
case "d":
_fb=_js("d");
break;
case "e":
_fb=_js("e");
break;
case "f":
_fb=_js("f");
break;
case "g":
_fb=_js("g");
break;
case "h":
_fb=_js("h");
break;
case "x":
_fb=_js("x");
break;
case "#":
_fb=_js("#");
break;
}
_f9+=_fb;
}
return _f9;
};
Board.prototype.updatePiece=function(_fc,col,row,_ff,_100,_101,_102,_103){
if(_102){
this.board_xy=null;
if(_fc.prePromotionRow){
_fc.row=_fc.prePromotionRow;
_fc.column=_fc.prePromotionColumn;
}
}
if(_102==null&&_fc.column==col&&_fc.row==row){
this.board_xy=null;
_fc.setPosition(_fc.column,_fc.row,false,null,this.moveAnimationLength);
if(clog){
console.log("moved piece back to its orig position");
}
return;
}
var _104=null;
if(this.currentMove){
if(this.currentMove.prev){
_104=this.currentMove.prev;
}else{
_104=this.prev_move;
}
}else{
_104=this.prev_move;
}
if(clog){
if(this.currentMove){
console.log("updatepiece currentMove:"+this.currentMove.output());
}else{
console.log("updatepiece currentmove null");
}
}
if(!_ff&&!this.canMove(_fc.makeLightWeight(),col,row,_104,true)){
this.board_xy=null;
_fc.setPosition(_fc.column,_fc.row,false,null,0.5);
if(clog){
console.log("move not legal , move back to orig:"+this.toMove);
if(_104){
console.log("prevMove was:"+_104.output());
}else{
console.log("prevMove was null");
}
}
return;
}
var _105="";
if(_101&&_fc.piece==ChessPiece.PAWN&&(row==7||row==0)){
this.promptPromotion(_fc,col,row,_ff,_100);
return;
}else{
if(_102!=null){
_105=_102;
}
}
var _106=true;
var _107="";
_107+=Move.columnToChar(_fc.column);
_107+=String.fromCharCode("1".charCodeAt(0)+_fc.row);
_107+=Move.columnToChar(col);
_107+=String.fromCharCode("1".charCodeAt(0)+(row));
if(_105){
_107+=_105;
}
var _108=this.createMoveFromString(_107);
var move=this.currentMove;
if(move){
_108.moveNum=move.moveNum;
}
var res=null;
for(var i=0;i<this.registeredUpdateListeners.length;i++){
_10c=this.registeredUpdateListeners[i].updatePieceCallback(_105,_fc,col,row,_ff,_100,_101,_102,_103,_104,this.currentMove,_108);
if(!_10c){
return false;
}
if(!_10c.ignoreRetVal){
res=_10c;
}
}
if(!res){
if(clog){
console.log("Got no update piece callbak");
}
return false;
}
if(res.allowMove){
if(this.oldSelectedSquare){
YAHOO.util.Dom.removeClass(this.oldSelectedSquare,"ct-source-square");
}
var move=res.move;
for(var i=0;i<this.registeredUpdateAllowMoveListeners.length;i++){
var res2=this.registeredUpdateAllowMoveListeners[i].updateAllowMoveCallback(_105,_fc,col,row,_ff,_100,_101,_102,_103,move);
}
this.makeMove(move,_fc,_100,this.moveAnimationLength,true,true,null,null,true);
var _10e=!res.dontMakeOpponentMove&&!_ff&&(this.currentMove&&this.currentMove.next&&!this.currentMove.next.atEnd);
if(clog){
if(move.next){
console.log("setting current move in updatepiece to:"+move.next.output());
}else{
console.log("in updatepiece, current move being set to null");
}
}
this.setCurrentMove(move.next,false,_10e);
if(this.currentMove.atEnd){
for(var i=0;i<this.registeredUpdateEndOfMovesListeners.length;i++){
var res=this.registeredUpdateEndOfMovesListeners[i].updateEndOfMovesCallback(_105,_fc,col,row,_ff,_100,_101,_102,_103);
}
}
if(_10e){
opponentMove=this.currentMove;
if(this.currentMove&&this.currentMove.next.atEnd){
this.toggleToMove();
}
this.updatePiece(this.boardPieces[opponentMove.fromColumn][opponentMove.fromRow],opponentMove.toColumn,opponentMove.toRow,true,true,false);
}
}else{
var move=res.move;
var _10f=_fc.column;
var _110=_fc.row;
this.board_xy=null;
_fc.setPosition(_fc.column,_fc.row,false,null,this.moveAnimationLength);
for(var i=0;i<this.registeredUpdateWrongMoveListeners.length;i++){
var res=this.registeredUpdateWrongMoveListeners[i].updateWrongMoveCallback(_105,_fc,col,row,_ff,_100,_101,_102,_103,move);
}
}
for(var i=0;i<this.registeredUpdatePieceFinishedListeners.length;i++){
var _10c=this.registeredUpdatePieceFinishedListeners[i].updatePieceFinishedCallback(_105,_fc,col,row,_ff,_100,_101,_102,_103,_104,this.currentMove,_108);
}
};
Board.prototype.addGotoMoveIndexListener=function(_111){
this.registeredGotoMoveIndexListeners.push(_111);
};
Board.prototype.addPasteFenClickedListener=function(_112){
this.registeredPasteFenClickedListeners.push(_112);
};
Board.prototype.addBackMovePreCurrentListener=function(_113){
this.registeredBackMovePreCurrentListeners.push(_113);
};
Board.prototype.addForwardMovePostUpdateListener=function(_114){
this.registeredForwardMovePostUpdateListeners.push(_114);
};
Board.prototype.addForwardAtEndListener=function(_115){
this.registeredForwardAtEndListeners.push(_115);
};
Board.prototype.addUpdatePieceListener=function(_116){
this.registeredUpdateListeners.push(_116);
};
Board.prototype.addUpdatePieceFinishedListener=function(_117){
this.registeredUpdatePieceFinishedListeners.push(_117);
};
Board.prototype.addUpdatePieceEndOfMovesListener=function(_118){
this.registeredUpdateEndOfMovesListeners.push(_118);
};
Board.prototype.addUpdatePieceHaveAltListener=function(_119){
this.registeredUpdateHaveAltListeners.push(_119);
};
Board.prototype.addUpdatePieceAllowMoveListener=function(_11a){
this.registeredUpdateAllowMoveListeners.push(_11a);
};
Board.prototype.addUpdatePieceWrongMoveListener=function(_11b){
this.registeredUpdateWrongMoveListeners.push(_11b);
};
Board.prototype.scoreToShortString=function(_11c){
if(_11c=="draw"){
return "D";
}
if(_11c>=0){
return "M"+_11c;
}else{
return "L"+(-1*_11c);
}
};
Board.prototype.scoreToLongString=function(_11d){
if(_11d=="draw"){
return _js("Draw");
}
if(_11d==0){
return _js("Mate");
}else{
if(_11d>0){
return __js("Mate in {NUMBER_MOVES}",[["NUMBER_MOVES",_11d]]);
}else{
return __js("Lose in {NUMBER_MOVES}",[["NUMBER_MOVES",(-1*_11d)]]);
}
}
};
Board.prototype.egMoveToScoreString=function(_11e){
var _11f=_11e.score;
var _120=_11e.optimal_score;
var s=this.scoreToShortString(_11f);
var opt=this.scoreToShortString(_120);
var _123=this.scoreToLongString(_11f);
var _124=this.scoreToLongString(_120);
if(_11f==_120){
return ["",_123];
}else{
var _125="ct-subopt-move-score";
if(_11f=="draw"||_11f<0){
_125="ct-bad-move-score";
}
return ["<span class=\""+_125+"\">"+s+"("+opt+")</span>",_123+"("+_124+")"];
}
};
Board.prototype.makeShortAlgabraic=function(_126,_127,_128,_129,_12a){
if(clog){
console.log("fromCol:"+_126+" fromRow:"+_127+" toCol:"+_128+" toRow:"+_129);
}
var _12b=this.boardPieces[_126][_127];
var _12c=_12b.piece;
var _12d=ChessPiece.pieceTypeToChar(_12c);
var move="";
if(_12c==ChessPiece.PAWN){
if(_126==_128){
move=Move.columnToChar(_126)+""+(_129+1);
}else{
move=Move.columnToChar(_126)+"x"+Move.columnToChar(_128)+""+(_129+1);
if(!this.boardPieces[_128][_129]){
move+=" e.p.";
}
}
}else{
if(_12c==ChessPiece.KING){
var _12f=Math.abs(_126-_128);
if(_12f==1||_12f==0){
move=_12d;
if(this.boardPieces[_128][_129]){
move+="x";
}
move+=Move.columnToChar(_128)+""+(_129+1);
}else{
if(_128==6){
move="O-O";
}else{
move="O-O-O";
}
}
}else{
var _130=[];
for(var row=0;row<8;row++){
for(var col=0;col<8;col++){
var cp=this.boardPieces[col][row];
if(cp&&cp.colour==_12b.colour&&cp.piece==_12c&&!(_12b.column==cp.column&&_12b.row==cp.row)){
var prev=null;
if(this.currentMove){
prev=this.currentMove.prev;
}
if(this.canMove(cp.makeLightWeight(),_128,_129,prev,true)){
_130.push(cp);
}
}
}
}
move=_12d;
if(_130.length>0){
var _135=false;
var _136=false;
for(var i=0;i<_130.length;i++){
if(_130[i].row==_127){
_136=true;
}
if(_130[i].column==_126){
_135=true;
}
}
if(_136||!(_136||_135)){
move+=Move.columnToChar(_126);
}
if(_135){
move+=""+(_127+1);
}
}
if(this.boardPieces[_128][_129]){
move+="x";
}
move+=Move.columnToChar(_128)+""+(_129+1);
}
}
var _138="";
var _139="";
if(_12a){
var _13a=this.cloneBoard();
var _13b=ChessPiece.WHITE;
if(_13a.boardPieces[_12a.fromColumn][_12a.fromRow].colour==ChessPiece.WHITE){
_13b=ChessPiece.BLACK;
}
_13a.makeMove(_12a,_13a.boardPieces[_12a.fromColumn][_12a.fromRow],false,_13a.moveAnimationLength,false,false);
if(!_13a.isKingSafe(_13b,_12a)){
_138="+";
if(_13a.isKingMated(_13b,_12a)){
_138="#";
}
}
if(_12a.promotion){
_139="="+((_12a.promotion+"").toUpperCase());
}
}
move+=_139+_138;
return move;
};
Board.getVarMove=function(move,row,col,_13f,_140){
if(move.vars&&move.vars.length>0){
var i=0;
for(var i=0;i<move.vars.length;i++){
var _142=move.vars[i];
if(_142.fromColumn==_13f.column&&_142.fromRow==_13f.row&&_142.toRow==row&&_142.toColumn==col&&(_140==""||(_140==_142.promotion))){
return _142;
}
}
}
};
Board.prototype.createMoveFromString=function(_143){
var _144=0;
var take=false;
var _146=null;
var _147=_143.charCodeAt(_144++);
var _148=_143.charCodeAt(_144++);
var _149=_143.split("|");
var pgn=null;
if(_149.length>1){
pgn=_149[1];
_143=_149[0];
}else{
_143=_149[0];
}
if(_143.charAt(_144)=="x"){
_144++;
take=true;
}
var _14b=_143.charCodeAt(_144++);
var _14c=_143.charCodeAt(_144++);
if(_144<_143.length){
_146=_143.charAt(_144);
}
var move=new Move(_147-("a".charCodeAt(0)),_148-("1".charCodeAt(0)),_14b-("a".charCodeAt(0)),_14c-("1".charCodeAt(0)),take,_146,_143);
move.pgn=pgn;
return move;
};
Board.prototype.getBackButton=function(){
if(!this.backButton){
this.backButton=YAHOO.util.Dom.get(this.boardName+"-back");
}
return this.backButton;
};
Board.prototype.getForwardButton=function(){
if(!this.forwardButton){
this.forwardButton=YAHOO.util.Dom.get(this.boardName+"-forward");
}
return this.forwardButton;
};
Board.prototype.getEndButton=function(){
if(!this.endButton){
this.endButton=YAHOO.util.Dom.get(this.boardName+"-end");
}
return this.endButton;
};
Board.prototype.getStartButton=function(){
if(!this.startButton){
this.startButton=YAHOO.util.Dom.get(this.boardName+"-start");
}
return this.startButton;
};
Board.prototype.setForwardBack=function(){
var back=this.getBackButton();
var _14f=this.getForwardButton();
var end=this.getEndButton();
var _151=this.getStartButton();
if(!this.currentMove){
if(back){
back.src=this.boardImagePath+"/images/resultset_previous_disabled"+this.getVersString()+".gif";
}
if(_151){
_151.src=this.boardImagePath+"/images/disabled_resultset_first"+this.getVersString()+".gif";
}
if(_14f){
_14f.src=this.boardImagePath+"/images/resultset_next_disabled"+this.getVersString()+".gif";
}
if(end){
end.src=this.boardImagePath+"/images/disabled_resultset_last"+this.getVersString()+".gif";
}
return;
}
if(this.currentMove.prev==null){
if(back){
back.src=this.boardImagePath+"/images/resultset_previous_disabled"+this.getVersString()+".gif";
}
if(_151){
_151.src=this.boardImagePath+"/images/disabled_resultset_first"+this.getVersString()+".gif";
}
}else{
if(back){
back.src=this.boardImagePath+"/images/resultset_previous"+this.getVersString()+".gif";
}
if(_151){
_151.src=this.boardImagePath+"/images/resultset_first"+this.getVersString()+".gif";
}
}
if(this.currentMove.atEnd){
if(_14f){
_14f.src=this.boardImagePath+"/images/resultset_next_disabled"+this.getVersString()+".gif";
}
if(end){
end.src=this.boardImagePath+"/images/disabled_resultset_last"+this.getVersString()+".gif";
}
}else{
if(_14f){
_14f.src=this.boardImagePath+"/images/resultset_next"+this.getVersString()+".gif";
}
if(end){
end.src=this.boardImagePath+"/images/resultset_last"+this.getVersString()+".gif";
}
}
};
Board.prototype.convertPiecesFromLightWeight=function(_152){
var _153=this.settingUpPosition;
this.settingUpPosition=true;
for(var i=0;i<8;i++){
for(var j=0;j<8;j++){
if(this.boardPieces[i][j]!=null){
var _156=this.boardPieces[i][j];
var p=_156.makeHeavyWeight();
this.boardPieces[i][j]=p;
p.setPosition(p.column,p.row,false,null,this.moveAnimationLength);
p.setVisible(true);
}
}
}
var move=this.moveArray[_152];
while(move!=null){
if(move.taken){
move.taken=move.taken.makeHeavyWeight();
}
move=move.prev;
}
this.settingUpPosition=_153;
};
MovesDisplay.prototype.setToMove=function(_159){
this.toMove=_159;
};
MovesDisplay.prototype.clickComment=function(e){
var t=e.currentTarget?e.currentTarget:e.targetElement?e.targetElement:false;
if(!t){
t=YAHOO.util.Event.getTarget(e);
}
if(!t.id){
t=t.parentNode;
}
var _15c=t.id.substr((this.board.boardName+"-mcX").length);
var _15d=true;
if(t.id.indexOf("-mca")>=0){
_15d=false;
}
var move=this.board.moveArray[_15c];
var _15f="";
if(_15d){
_15f=move.beforeComment;
}else{
_15f=move.afterComment;
}
mySimpleDialog=new YAHOO.widget.SimpleDialog(this.boardName+"-editCommentDialog",{width:"20em",fixedcenter:true,modal:true,visible:false,draggable:false});
mySimpleDialog.setHeader("Edit Comment");
mySimpleDialog.setBody("<textarea id=\""+this.board.boardName+"-editComment\">"+_15f+"</textarea>");
mySimpleDialog.cfg.setProperty("icon",YAHOO.widget.SimpleDialog.ICON_INFO);
var me=this;
var _161=function(){
if(_15d){
move.beforeComment=null;
}else{
move.afterComment=null;
}
t.innerHTML="";
this.hide();
};
var _162=function(){
var _163=YAHOO.util.Dom.get(me.board.boardName+"-editComment");
var txt=trimStr(_163.value);
if(_15d){
move.beforeComment=txt;
}else{
move.afterComment=txt;
}
if(_15d){
t.innerHTML=me.outputComment(txt,0)+" ";
}else{
t.innerHTML=" "+me.outputComment(txt,0);
}
this.hide();
};
var _165=function(){
this.hide();
};
var _166=[{text:"Delete",handler:_161},{text:"Save",handler:_162},{text:"Cancel",handler:_165,isDefault:true}];
mySimpleDialog.cfg.queueProperty("buttons",_166);
mySimpleDialog.render(document.body);
mySimpleDialog.show();
};
MovesDisplay.prototype.gotoMove=function(e){
if(this.board.disableNavigation){
return;
}
if(this.board.tactics&&this.board.tactics.problemActive){
return;
}
if(this.board.blockFowardBack||this.board.deferredBlockForwardBack){
return;
}
activeBoard=this.board;
var t=e.currentTarget?e.currentTarget:e.targetElement?e.targetElement:false;
if(!t){
t=YAHOO.util.Event.getTarget(e);
}
if(!t.id){
t=t.parentNode;
}
var _169=t.id.substr((this.board.boardName+"-m").length);
if(clog){
console.log("got goto move index:"+_169);
}
this.board.gotoMoveIndex(_169,false,false,false,false);
if(this.board.problem){
if(this.board.currentMove.bestMoves){
this.board.problem.showBestMoves(this.board.currentMove,this.board.currentMove.bestMoves,this.board.currentMove.correctMove,this.board.currentMove.wrongMove);
}else{
this.board.problem.clearBestMoves();
}
}
};
MovesDisplay.prototype.getMovesDisplay=function(){
if(!this.cachedMovesDisplay&&!this.allreadyCachedMovesDisplay){
var name=this.board.boardName+"-moves";
if(this.moveListName){
name=this.moveListName;
}
this.cachedMovesDisplay=YAHOO.util.Dom.get(name);
this.allreadyCachedMovesDisplay=true;
}
return this.cachedMovesDisplay;
};
MovesDisplay.prototype.outputVariationStart=function(_16b,_16c,_16d,_16e){
var _16f="";
if(_16c>this.board.ml){
return _16f;
}
if(this.board.ml==1&&_16e>1){
return _16f;
}
var _170=this.getMovesDisplay();
if(_170){
if(_16b==0&&this.displayType==MovesDisplay.MAIN_ON_OWN_LINE){
if(this.firstNonMove){
if(this.board.useDivClearForNewline){
_16f+="<div style=\"clear:both;\"></div>";
}
_16f+="<div class=\"ct-mainline-commentary\"/>";
this.pendingLevelZeroCommentaryClose=true;
}
}
if(this.variationOnOwnLine){
if(this.board.useDivClearForNewline){
_16f+="<div style=\"clear:both;\"></div>";
}else{
_16f+="<br/>";
}
}
if(this.board.showBracketsOnVariation&&(!this.board.hideBracketsOnTopLevelVariation||_16b>0)){
_16f+="<span>"+this.board.variationStartString+"</span>";
}
}
this.firstNonMove=false;
return _16f;
};
MovesDisplay.prototype.outputVariationEnd=function(_171,_172,_173,_174){
var _175=this.getMovesDisplay();
var _176="";
if(this.board.ml==1&&_172>0&&this.board.outputFirstVar){
return _176;
}
this.board.outputFirstVar=true;
if(_175){
if(this.board.showBracketsOnVariation&&(!this.board.hideBracketsOnTopLevelVariation||_171>1)){
_176+="<span>"+this.board.variationEndString+"</span>";
}
}
if(_171==1&&this.displayType==MovesDisplay.MAIN_ON_OWN_LINE){
}
this.firstNonMove=false;
return _176;
};
MovesDisplay.prototype.outputComment=function(_177,_178,_179){
if(this.board.ignoreCommentRegex){
var _17a=new RegExp(this.board.ignoreCommentRegex);
if(_17a.test(_177)){
return "";
}
}
var _17b="";
if(this.board.ml==1){
return _17b;
}
var _17c=this.getMovesDisplay();
if(_17c){
if(_178==0&&this.displayType==MovesDisplay.MAIN_ON_OWN_LINE){
if(this.firstNonMove){
_17b+="<br/>";
}
_17b+="<div class=\"ct-mainline-commentary\">";
this.pendingLevelZeroCommentaryClose=true;
}
var _17d="ct-board-move-comment";
if(_179){
_17d="ct-board-move-alt-comment";
}
if(this.board.handleCommentClicks){
_17d+=" ct-board-clickable-comment";
}
_17b+="<span class=\""+_17d+"\"> "+_177+" </span>";
if(_178==0&&this.displayType==MovesDisplay.MAIN_ON_OWN_LINE){
}
}
this.firstNonMove=false;
return _17b;
};
MovesDisplay.prototype.outputNag=function(_17e){
var _17f="";
var _180=this.getMovesDisplay();
if(_180){
var _181=null;
switch(_17e){
case 11:
_181="=";
break;
case 14:
_181="+=";
break;
case 15:
_181="=+";
break;
case 16:
_181="+/-";
break;
case 17:
_181="-/+";
break;
case 18:
_181="+-";
break;
case 19:
_181="-+";
break;
case 20:
_181="+--";
break;
case 21:
_181="--+";
break;
default:
}
if(_181){
_17f+="<span> "+_181+" </span>";
}
}
return _17f;
};
MovesDisplay.prototype.outputResult=function(_182){
return "<span class=\"ct-result\">"+_182+"</span>";
};
MovesDisplay.prototype.outputMove=function(_183,_184,_185,_186,_187,_188,_189,move,_18b,_18c){
if(clog){
console.log("outputMove:"+_186+" hideScore:"+_18b);
}
var _18d="";
var _18e=this.getMovesDisplay();
if(this.board.tr&&_184>0&&(_188>1||_189>3)&&!_187){
return _18d;
}
if(this.board.ml==1&&_188>0&&this.board.outputFirstVar){
return _18d;
}
if(_18e){
var _18f=""+Math.round(_185/2)+". ";
var _190=false;
if(_185%2!=1){
if(clog){
console.log("firstRav:"+_187+" firstNonMove:"+this.firstNonMove);
}
if(_187||!this.firstNonMove){
_18f=Math.round(_185/2)+"... ";
_190=true;
}else{
_18f="";
}
}
if(clog){
console.log("moveNum:"+_185+" moveNumOut:"+_18f);
}
if(this.displayType==MovesDisplay.MAIN_ON_OWN_LINE&&_184==0&&(!this.firstNonMove||_185%2==1)){
if(this.pendingLevelZeroCommentaryClose){
this.pendingLevelZeroCommentaryClose=false;
_18d+="</div>";
}
if(this.board.newlineForEachMainMove){
if(this.board.useDivClearForNewline){
_18d+="<div style=\"clear:both;\"></div>";
}else{
_18d+="<br/>";
}
}
}
var _191="";
var _192="";
if(move&&move.eg_move){
var res=this.board.egMoveToScoreString(move.eg_move);
_191=res[0];
_192=res[1];
}
var _194="";
if(_18b){
_194="initially_hidden";
}
if(_191!=""){
_191=" "+_191;
}
var _195="title";
if(_18b){
_195="alt";
}
var _196="";
if(_18c){
_196=" rel=\""+_186+"\" ";
_186="___";
}
var _197="";
if(_190&&_184==0){
_197="<span class=\"ct-board-move-dottedempty\">&nbsp;</span>";
}
var _198="";
if(_18f){
_198="<span class=\"ct-board-move-movenum\">"+_18f+"</span>";
}
_18d+="<span "+_196+_195+"=\""+_192+"\" id=\""+this.board.boardName+"-m"+_183+"\" class=\""+((_184==0)?"ct-board-move-mainline":"ct-board-move-variation")+"\">"+_198+_197+"<span class=\"ct-board-move-movetext\">"+_186+"</span><span id=\""+this.board.boardName+"-msc"+_183+"\" class=\""+_194+"\">"+_191+"</span></span>";
}
this.firstNonMove=true;
return _18d;
};
Board.prototype.setMoveSeqLalg=function(_199,_19a,_19b,_19c){
var _19d=new Array();
if(_199&&_199.length>0){
_19d=_199.replace(/\s+$/g,"").split(" ");
}
this.setupFromLalgArray(_19d,_19c,_19b,_19a);
};
Board.prototype.setupFromLalgArray=function(_19e,_19f,_1a0,_1a1){
this.outputFirstVar=false;
if(this.movesDisplay){
this.movesDisplay.pendingLevelZeroCommentaryClose=false;
var md=this.movesDisplay.getMovesDisplay();
if(md){
YAHOO.util.Event.purgeElement(md,true);
md.innerHTML="";
}
}
if(!_1a1){
_1a1=new Array();
}
var _1a3=this.cloneBoard();
this.movesDisplay.firstNonMove=false;
var _1a4=new Array();
var _1a5=new Array();
if(this.prev_move){
_1a3.makeMove(this.prev_move,_1a3.boardPieces[this.prev_move.fromColumn][this.prev_move.fromRow],false,_1a3.moveAnimationLength,false,false);
}
var _1a6=_1a3.cloneBoard();
var _1a7=null;
var _1a8=0;
var _1a9="";
var _1aa=false;
var _1ab=false;
var _1ac=0;
var _1ad=false;
var _1ae=new Array();
var _1af=new Array();
_1af[0]=0;
var _1b0=new Array();
var _1b1=new Array();
var _1b2=_1a0*2-1;
var _1b3=_1a0*2-1;
var _1b4=new Array();
var _1b5=ChessPiece.WHITE;
var _1b6=0;
var eval="";
var _1b8="";
var _1b9="";
var time="";
var _1bb=-1;
var _1bc=0;
for(var i=0;i<_19e.length;i++){
var _1be=0;
if(_19e[i]=="ALT"){
_1ab=true;
continue;
}
if(_19e[i].indexOf("EVAL")==0){
eval=_19e[i].split(":")[1];
if(parseInt(eval)>=175&&_1ac>0&&_1af[_1ac]>1){
_1ab=true;
}
continue;
}
if(_19e[i].indexOf("DEPTH")==0){
_1b8=_19e[i].split(":")[1];
continue;
}
if(_19e[i].indexOf("NODES")==0){
_1b9=_19e[i].split(":")[1];
continue;
}
if(_19e[i].indexOf("TIME")==0){
time=_19e[i].split(":")[1];
var e=eval;
if(eval.indexOf("mate")!=0){
e=(parseFloat(eval)/100).toFixed(2);
if(e>0){
e="+"+e;
}
}else{
e=e.replace(/_/," ");
var _1c0=e.split(" ");
_1be=parseInt(_1c0[1]);
e=_js("mate")+" "+_1c0[1];
if(_1af[_1ac]==1){
_1bb=_1be;
}
}
_1bc=_1be;
if(_1be<0){
_1ab=false;
}else{
if(_1be>0&&_1be<8&&_1ac>0&&_1af[_1ac]>1){
_1ab=true;
}
}
var _1c1="";
if(_1ab){
_1c1=_js("ALT")+" ";
}
var t=parseInt(time);
var nps=" "+__js("nps:{NODES_PER_SECOND}",[["NODES_PER_SECOND",Math.round(parseInt(_1b9)/(parseInt(time)/1000))]]);
if(!this.showNPS){
nps="";
}
if(!(_1ac>0&&_1af[_1ac]>this.ml)){
_19e[i]=_1c1+e+" ("+__js("depth:{DEPTH}",[["DEPTH",_1b8]])+nps+")";
}else{
_19e[i]="";
}
}
if(_19e[i]=="}"){
_1aa=false;
if(this.movesDisplay){
_1a9=_1a9.replace(/\s+$/g,"");
_1b4.push(this.movesDisplay.outputComment(_1a9,_1ac,_1ab));
}
continue;
}else{
if(_1aa){
_1a9+=_19e[i]+" ";
continue;
}else{
if(_19e[i]=="{"){
_1a9="";
_1aa=true;
continue;
}else{
if(_19e[i]=="("){
if(!_1af[_1ac+1]){
_1af[_1ac+1]=0;
}
_1af[_1ac+1]++;
if(this.movesDisplay){
_1b4.push(this.movesDisplay.outputVariationStart(_1ac,_1af[_1ac+1],_1b2,_1ae[0]));
}
_1ae[_1ac]=_1b2;
_1b0[_1ac]=_1a7;
_1b1[_1ac]=_1b5;
_1a4[_1ac]=_1a3;
_1a5[_1ac]=_1a6;
_1a3=_1a6.cloneBoard();
_1ac++;
_1b2--;
_1ad=true;
continue;
}else{
if(_19e[i]==")"){
if(this.movesDisplay){
_1b4.push(this.movesDisplay.outputVariationEnd(_1ac,_1af[_1ac],_1b2,_1ae[0]));
}
var _1c4=new Move();
_1c4.atEnd=true;
_1a7.next=_1c4;
_1c4.prev=_1a7;
_1ac--;
_1b2=_1ae[_1ac];
_1a7=_1b0[_1ac];
_1b5=_1b1[_1ac];
_1a3=_1a4[_1ac];
_1a6=_1a5[_1ac];
_1ab=false;
continue;
}else{
if(_19e[i].charAt(0)=="$"){
if(this.movesDisplay){
_1b4.push(this.movesDisplay.outputNag(parseInt(_19e[i].substring(1))));
}
continue;
}
}
}
}
}
}
var move=this.createMoveFromString(_19e[i]);
var _1c6=false;
if(_1b2==_1b3&&this.boardPieces[move.fromColumn][move.fromRow].colour==ChessPiece.BLACK){
_1b2++;
_1c6=true;
_1b5=ChessPiece.BLACK;
}
move.index=_1a8;
var _1c7=(move.pgn)?move.pgn:move.moveString;
if(move.pgn){
_1c7=move.pgn;
}else{
_1c7=_1a3.makeShortAlgabraic(move.fromColumn,move.fromRow,move.toColumn,move.toRow,move);
move.SAN=_1c7;
}
_1c7=Board.moveToLocale(_1c7);
if(this.movesDisplay){
this.movesDisplay.setToMove(_1b5);
_1b4.push(this.movesDisplay.outputMove(_1a8,_1ac,_1b2,_1c7+" ",_1ad,_1af[_1ac],_1ae[0]));
}
_1b5=(_1b5==ChessPiece.BLACK)?ChessPiece.WHITE:ChessPiece.BLACK;
move.moveNum=_1b2;
_1b2++;
if(_1ac>0){
if(_1ad){
var _1c8=_1a7;
if(_1c8==null){
alert("Got no previous move for variation:"+movesArra[i]);
}
if(_1c8.numVars==0){
_1c8.vars=new Array();
}
move.isAlt=_1ab;
move.mateInMoves=_1bc;
_1c8.vars[_1c8.numVars++]=move;
move.prev=_1c8.prev;
_1ad=false;
}else{
move.prev=_1a7;
if(_1a7!=null){
_1a7.next=move;
}
}
}else{
move.prev=_1a7;
if(_1a7!=null){
_1a7.next=move;
}
}
_1af[_1ac+1]=0;
if(_1ac==0){
_1b6=_1a8;
}
_1a1[_1a8++]=move;
_1a3.moveArray[_1a8-1]=move;
_1a7=move;
_1a6=_1a3.cloneBoard();
_1a3.makeMove(move,_1a3.boardPieces[move.fromColumn][move.fromRow],false,_1a3.moveAnimationLength,false,false);
}
if(this.movesDisplay&&!this.disableMoveOutput){
var _1c9=this.movesDisplay.getMovesDisplay();
_1b4.push(this.movesDisplay.outputResult(_19f));
this.pendingMovesOutput=_1b4.join("");
this.pendingMovesOutputCount=_1a8;
}
this.lastMoveIndex=_1b6;
if(_1a7!=null){
var _1c4=new Move();
_1c4.atEnd=true;
_1a7.next=_1c4;
_1c4.prev=_1a7;
}
this.lastCount=_1a8;
};
Board.prototype.getMaterialCount=function(){
var _1ca=0;
var _1cb=0;
for(var i=0;i<8;i++){
for(var j=0;j<8;j++){
var _1ce=this.boardPieces[i][j];
if(_1ce){
if(_1ce.colour==ChessPiece.WHITE){
_1ca+=ChessPiece.materialValue(_1ce.piece);
}else{
_1cb+=ChessPiece.materialValue(_1ce.piece);
}
}
}
}
return [_1ca,_1cb];
};
Board.prototype.getMaterialBalance=function(){
var cnt=this.getMaterialCount();
return cnt[0]-cnt[1];
};
Board.prototype.getMaterialBalances=function(){
var _1d0=this.cloneBoard();
var mv=this.moveArray[0];
_1d0.gotoMoveIndex(-1,true,true,true,true);
var _1d2=[];
while(mv&&!mv.atEnd){
_1d0.makeMove(mv,_1d0.boardPieces[mv.fromColumn][mv.fromRow],false,this.moveAnimationLength,false,false);
_1d2.push(_1d0.getMaterialBalance());
mv=mv.next;
_1d0.toggleToMove();
}
return _1d2;
};
Board.prototype.lalgToMoveList=function(_1d3,_1d4,_1d5,_1d6,_1d7){
if(ctime){
console.time("lalgToMoveList");
}
if(clog){
console.log("startMoveNum:"+_1d5);
}
if(!_1d6){
_1d6=new Array();
}
var _1d8=this.cloneBoard();
var _1d9=new Array();
var _1da=new Array();
if(!_1d7&&this.prev_move){
_1d8.makeMove(this.prev_move,_1d8.boardPieces[this.prev_move.fromColumn][this.prev_move.fromRow],false,_1d8.moveAnimationLength,false,false);
}
var _1db=_1d8.cloneBoard();
var nags=[];
var _1dd=null;
var _1de=0;
var _1df="";
var _1e0=false;
var _1e1=0;
var _1e2=false;
var _1e3=new Array();
var _1e4=new Array();
_1e4[0]=0;
var _1e5=new Array();
var _1e6=new Array();
var _1e7=_1d5*2-1;
var _1e8=new Array();
var _1e9=ChessPiece.WHITE;
var _1ea=0;
var _1eb=true;
for(var i=0;i<_1d3.length;i++){
if(_1d3[i]=="}"){
_1e0=false;
_1df=_1df.replace(/\s+$/g,"");
continue;
}else{
if(_1e0){
_1df+=_1d3[i]+" ";
continue;
}else{
if(_1d3[i]=="{"){
if(_1df){
if(_1dd){
_1dd.afterComment=trimStr(_1df);
}
}
_1df="";
_1e0=true;
continue;
}else{
if(_1d3[i]=="("){
if(clog){
console.log("var start comment:"+_1df);
}
if(_1dd){
_1dd.afterComment=trimStr(_1df);
_1df="";
}
if(clog){
if(_1dd){
console.log("old:"+_1dd.output());
}else{
console.log("no old move");
}
}
if(!_1e4[_1e1+1]){
_1e4[_1e1+1]=0;
}
_1e4[_1e1+1]++;
_1e3[_1e1]=_1e7;
_1e5[_1e1]=_1dd;
_1e6[_1e1]=_1e9;
_1d9[_1e1]=_1d8;
_1da[_1e1]=_1db;
_1d8=_1db.cloneBoard();
_1e1++;
_1e7--;
_1e2=true;
continue;
}else{
if(_1d3[i]==")"){
if(_1dd){
if(clog){
console.log("var end comment:"+_1df);
console.log("var end comment:"+_1dd.output());
}
_1dd.afterComment=trimStr(_1df);
_1df="";
}
var _1ed=new Move();
_1ed.atEnd=true;
_1dd.next=_1ed;
_1ed.prev=_1dd;
_1e1--;
_1e7=_1e3[_1e1];
_1dd=_1e5[_1e1];
_1e9=_1e6[_1e1];
_1d8=_1d9[_1e1];
_1db=_1da[_1e1];
continue;
}else{
if(_1d3[i].charAt(0)=="$"){
nags.push(parseInt(_1d3[i].substring(1)));
continue;
}
}
}
}
}
}
var move=this.createMoveFromString(_1d3[i]);
move.nags=nags;
move.beforeComment=trimStr(_1df);
_1df=null;
nags=[];
if(_1eb){
if(this.boardPieces[move.fromColumn][move.fromRow].colour==ChessPiece.BLACK){
_1e7++;
_1e9=ChessPiece.BLACK;
if(clog){
console.log("first move black new movenum:"+_1e7);
}
}
_1eb=false;
}
move.index=_1de;
var _1ef=(move.pgn)?move.pgn:move.moveString;
if(move.pgn){
_1ef=move.pgn;
move.SAN=move.pgn;
}else{
_1ef=_1d8.makeShortAlgabraic(move.fromColumn,move.fromRow,move.toColumn,move.toRow,move);
move.SAN=_1ef;
}
_1e9=(_1e9==ChessPiece.BLACK)?ChessPiece.WHITE:ChessPiece.BLACK;
move.moveNum=_1e7;
_1e7++;
if(_1e1>0){
if(_1e2){
var _1f0=_1dd;
if(_1f0==null){
alert("Got no previous move for variation:"+movesArra[i]);
}
if(_1f0.numVars==0){
_1f0.vars=new Array();
}
_1f0.vars[_1f0.numVars++]=move;
move.prev=_1f0.prev;
_1e2=false;
}else{
move.prev=_1dd;
if(_1dd!=null){
_1dd.next=move;
}
}
}else{
move.prev=_1dd;
if(_1dd!=null){
_1dd.next=move;
}
}
_1e4[_1e1+1]=0;
if(_1e1==0){
_1ea=_1de;
}
_1d6[_1de++]=move;
_1d8.moveArray[_1de-1]=move;
_1dd=move;
_1db=_1d8.cloneBoard();
_1d8.makeMove(move,_1d8.boardPieces[move.fromColumn][move.fromRow],false,_1d8.moveAnimationLength,false,false);
}
if(_1dd!=null){
var _1ed=new Move();
_1ed.atEnd=true;
_1dd.next=_1ed;
_1ed.prev=_1dd;
if(_1df){
_1dd.afterComment=trimStr(_1df);
}
}
if(ctime){
console.timeEnd("lalgToMoveList");
}
return _1d6;
};
Board.prototype.reset=function(fen,_1f2){
if(this.lastFromSquare){
YAHOO.util.Dom.removeClass(this.lastFromSquare,"ct-from-square");
}
if(this.lastToSquare){
YAHOO.util.Dom.removeClass(this.lastToSquare,"ct-to-square");
}
this.clearMoveList();
if(fen){
this.startFen=fen;
this.setupFromFen(fen,false,this.isFlipped,false,_1f2,true);
}else{
this.startFen=Board.INITIAL_FEN;
this.setupFromFen(Board.INITIAL_FEN,false,this.isFlipped,false,false,true);
}
this.setForwardBack();
};
Board.prototype.clearMoveList=function(_1f3){
this.movesDisplay.firstNonMove=false;
var _1f4=this.movesDisplay.getMovesDisplay();
if(_1f4){
YAHOO.util.Event.purgeElement(_1f4,true);
_1f4.innerHTML="";
}
this.currentMove=null;
this.moveIndex=-1;
this.moveArray=new Array();
if(_1f3){
_1f3.prev=null;
this.startMoveNum=_1f3.moveNum;
}else{
this.startMoveNum=1;
}
};
Board.prototype.insertMovesFromMoveList=function(_1f5,_1f6,_1f7){
var _1f8=!_1f6;
if(ctime&&_1f8){
console.time("insertMovesFromMoveList");
}
if(!this.movesDisplay){
return;
}
if(_1f8){
this.clearMoveList(_1f5);
}
var _1f9=0;
var _1fa=_1f5.moveNum;
var move=_1f5;
while(move!=null&&!move.atEnd){
if(clog){
console.log("move:"+move.output());
}
var _1fc=move.next;
if(clog){
if(this.currentMove){
console.log("current move:"+this.currentMove.output());
}else{
console.log("no current move");
}
if(_1fc){
console.log("next move:"+_1fc.output());
}else{
console.log("no next move");
}
}
if(_1f8||_1f5!=move||_1f7==null){
if(clog){
console.log("about to call insertmoveafter");
}
this.insertMoveAfter(this.currentMove,move);
if(clog){
console.log("finished call to insertmoveafter");
}
}else{
if(clog){
console.log("about to replace variationParent:"+_1f7.output()+" with move:"+move.output()+" and board:"+this.boardToFen());
}
this.replaceMove(_1f7,move,true,true);
}
if(move.beforeComment){
this.insertCommentIntoMoveDisplay(move,move.beforeComment,false);
}
if(move.afterComment){
this.insertCommentIntoMoveDisplay(move,move.afterComment,true);
}
if(clog){
console.log("about to make move:"+move.output()+" with board pos:"+this.boardToFen());
}
this.makeMove(move,this.boardPieces[move.fromColumn][move.fromRow],false,this.moveAnimationLength,false,false);
if(clog){
console.log("made move");
}
this.setCurrentMove(move,true,true);
if(move.numVars>0){
var _1fd=move.index;
var bm=move.prev;
var _1ff=-1;
if(bm){
_1ff=bm.index;
}
var _200=move.numVars;
var vars=move.vars;
move.numVars=0;
move.vars=[];
for(var i=0;i<_200;i++){
this.gotoMoveIndex(_1ff,true,true,true,true);
if(clog){
console.log("about to call insertMovesFromMoveList with head of variation");
}
this.insertMovesFromMoveList(vars[i],true,move);
if(clog){
console.log("about to reset currentMoveIndex  after variation insert:"+_1fd);
}
}
this.gotoMoveIndex(_1fd,true,true,true,true);
this.backMove();
var cm=this.currentMove;
this.makeMove(cm,this.boardPieces[cm.fromColumn][cm.fromRow],false,this.moveAnimationLength,false,false);
if(clog){
if(this.currentMove){
console.log("popped up from variation, current set back to:"+this.currentMove.output());
}else{
console.log("popped up from variation, current set to null");
}
}
}
move=_1fc;
}
if(_1f8){
this.gotoMoveIndex(-1,false,false,false,false);
}
if(clog){
var m=this.currentMove;
while(m){
console.log("m:"+m.output());
m=m.next;
}
}
if(ctime&&_1f8){
console.timeEnd("insertMovesFromMoveList");
}
};
Board.prototype.setupFromLalgArrayIncremental=function(_205,_206,_207,_208){
this.outputFirstVar=false;
if(this.movesDisplay&&this.lastCount){
this.movesDisplay.pendingLevelZeroCommentaryClose=false;
for(var i=0;i<this.lastCount;i++){
var mv=YAHOO.util.Dom.get(this.boardName+"-m"+i);
if(mv){
YAHOO.util.Event.purgeElement(mv);
}
}
}
var _20b=0;
var _20c=_207*2-1;
var _20d="";
var _20e=false;
var _20f=false;
var _210=ChessPiece.WHITE;
var _211=false;
var _212=true;
this.currentMove=null;
for(var i=0;i<_205.length;i++){
if(_205[i]=="}"){
_211=false;
if(this.movesDisplay){
_20d=_20d.replace(/\s+$/g,"");
}
continue;
}else{
if(_211){
_20d+=_205[i]+" ";
continue;
}else{
if(_205[i]=="{"){
_20d="";
_211=true;
continue;
}else{
if(_205[i]=="("){
_20e=true;
continue;
}else{
if(_205[i]==")"){
_20f=true;
continue;
}else{
if(_205[i].charAt(0)=="$"){
continue;
}
}
}
}
}
}
var move=this.createMoveFromString(_205[i]);
var _214=false;
if(_212&&this.boardPieces[move.fromColumn][move.fromRow].colour==ChessPiece.BLACK){
_20c++;
_214=true;
_210=ChessPiece.BLACK;
}
this.startMoveNum=_20c;
_212=false;
move.index=_20b++;
var _215=move.moveString;
_215=Board.moveToLocale(_215);
_210=(_210==ChessPiece.BLACK)?ChessPiece.WHITE:ChessPiece.BLACK;
this.insertMoveAfter(this.currentMove,move);
if(clog){
if(move.prev){
if(move.prev.next){
console.log("move.prev.next:"+move.prev.next.output());
}else{
console.log("move.prev:"+move.prev.output()+" next null");
}
}
}
this.makeMove(move,this.boardPieces[move.fromColumn][move.fromRow],false,this.moveAnimationLength,false,false);
this.setCurrentMove(move);
}
this.gotoMoveIndex(-1,false,false,false,false);
};
Board.prototype.displayPendingMoveList=function(){
if(this.pendingMovesOutput&&this.movesDisplay){
var _216=this.movesDisplay.getMovesDisplay();
if(_216){
_216.innerHTML=this.pendingMovesOutput;
var _217=new YAHOO.util.Scroll(_216,{scroll:{to:[0,0]}},0);
_217.animate();
}
if(this.movesDisplay){
for(var i=0;i<this.pendingMovesOutputCount;i++){
var mv1=YAHOO.util.Dom.get(this.boardName+"-m"+i);
if(mv1){
YAHOO.util.Event.addListener(mv1,"click",this.movesDisplay.gotoMove,this.movesDisplay,true);
if(this.handleCommentClicks){
var _21a=YAHOO.util.Dom.get(this.boardName+"-mcb"+i);
if(_21a){
YAHOO.util.Event.addListener(_21a,"click",this.movesDisplay.clickComment,this.movesDisplay,true);
}
_21a=YAHOO.util.Dom.get(this.boardName+"-mca"+i);
if(_21a){
YAHOO.util.Event.addListener(_21a,"click",this.movesDisplay.clickComment,this.movesDisplay,true);
}
}
}
}
}
}
};
Board.prototype.setMoveSequence=function(_21b,_21c,_21d,_21e){
this.tacticMoveArray=new Array();
this.moveArray=this.tacticMoveArray;
this.setMoveSeqLalg(_21b,this.tacticMoveArray,_21d,_21e);
this.tacticsmoveArrayLastMoveIndex=this.lastMoveIndex;
if(false&&_21c!="NA"){
this.fullmoveArray=new Array();
this.disableMoveOutput=true;
this.setMoveSeqLalg(_21c,this.fullmoveArray,_21d,_21e);
this.disableMoveOutput=false;
this.fullmoveArrayLastMoveIndex=this.lastMoveIndex;
}else{
this.fullmoveArray=null;
}
this.lastMoveIndex=this.tacticsmoveArrayLastMoveIndex;
};
Board.prototype.resetVariationsPreviousNodes=function(_21f,_220){
if(_21f.numVars>0){
for(var i=0;i<_21f.numVars;i++){
_21f.vars[i].prev=_220;
this.resetVariationsPreviousNodes(_21f.vars[i],_220);
}
}
};
Board.prototype.reconnectNextNodeVariations=function(_222,_223){
if(!_223){
return;
}
if(_223.numVars>0){
for(var i=0;i<_223.numVars;i++){
_223.vars[i].prev=_222;
this.reconnectNextNodeVariations(_222,_223.vars[i]);
}
}
};
Board.prototype.findFirstMoveFromList=function(move){
var m=move;
while(m&&m.prev!=null){
m=m.prev;
}
return m;
};
Board.prototype.findVariationHeadFromMove=function(move){
var m=move;
while(m&&m.prev&&m.prev.next==m){
m=m.prev;
}
if(m&&m.prev&&m.prev.next!=m){
return m;
}else{
if(m&&!m.prev){
var _229=this.moveArray[0];
if(m!=_229){
return m;
}
}
return null;
}
};
Board.prototype.liftVariation=function(_22a){
if(!_22a){
return;
}
var _22b=null;
var _22c=null;
if(_22a.prev){
_22b=_22a.prev.next;
}else{
_22b=this.moveArray[0];
_22c=_22a;
}
var _22d=null;
if(this.currentMove&&this.currentMove.prev){
_22d=this.currentMove.prev;
}
if(_22b){
var _22e=_22b.numVars;
var vars=_22b.vars;
_22b.numVars=0;
_22b.vars=[];
if(_22a.numVars==0){
_22a.vars=[];
}
for(var i=0;i<_22e;i++){
var _231=vars[i];
if(clog){
console.log("processing var:"+_231.output());
}
if(_231==_22a){
if(clog){
console.log("inserted parent var");
}
_22a.vars.push(_22b);
_22a.numVars++;
}else{
_22a.vars.push(_231);
_22a.numVars++;
}
}
if(_22a.prev){
_22a.prev.next=_22a;
}
if(clog){
console.log("finished moving variations");
}
if(!_22c){
_22c=this.findFirstMoveFromList(_22a);
}
this.moveArray[0]=_22c;
this.gotoMoveIndex(-1,true,true,true,true);
if(clog){
console.log("fm:"+_22c.output());
}
this.insertMovesFromMoveList(_22c);
}
if(_22d){
this.gotoMoveIndex(_22d.index);
}
};
Board.prototype.deleteMoveAndLine=function(move){
var m=move;
var oldM=m;
var _235=false;
var _236=null;
var _237=this.moveArray[0];
var _238=null;
if(clog){
console.log("delete line:"+move.output());
}
if(clog){
console.log("delete line prev:"+move.prev);
}
if(clog&&move.prev){
console.log("delete line prev.next:"+move.prev.next);
}
if(move&&move.prev&&move.prev.next!=move){
if(clog){
console.log("var is head and not front of move list");
}
_235=true;
_236=move.prev.next;
}else{
if(move&&!move.prev&&move!=this.moveArray[0]){
if(clog){
console.log("var is head and front of move list");
}
_235=true;
_236=this.moveArray[0];
}
}
if(clog){
console.log("isVariationHead:"+_235);
}
if(clog){
console.log("fm:"+_237.output());
}
var _239=m.prev;
if(_235){
_238=_236;
if(_236){
if(clog){
console.log("delete variation from parent:"+_236.output());
}
var _23a=[];
for(var i=0;i<_236.numVars;i++){
if(!(_236.vars[i]==oldM)){
if(clog){
console.log("saving var:"+_236.vars[i].output());
}
_23a.push(_236.vars[i]);
}else{
if(clog){
console.log("dropping var:"+_236.vars[i].output());
}
}
}
_236.vars=_23a;
_236.numVars=_23a.length;
}
}else{
if(_239){
_239.next=null;
_238=_239;
}else{
if(clog){
console.log("deleting entire list");
}
if(this.movesDisplay){
this.movesDisplay.firstNonMove=false;
YAHOO.util.Event.purgeElement(this.movesDisplay.getMovesDisplay(),true);
this.movesDisplay.pendingLevelZeroCommentaryClose=false;
}
var _23c=this.movesDisplay.getMovesDisplay();
if(_23c){
_23c.innerHTML="";
}
this.currentMove=null;
this.startMoveNum=_237.moveNum;
if(clog){
console.log("startFen:"+this.startFen);
}
this.moveIndex=-1;
this.moveArray=[];
this.setupFromFen(this.startFen);
if(this.lastFromSquare){
YAHOO.util.Dom.removeClass(this.lastFromSquare,"ct-from-square");
}
if(this.lastToSquare){
YAHOO.util.Dom.removeClass(this.lastToSquare,"ct-to-square");
}
this.setForwardBack();
return;
}
}
this.moveArray[0]=_237;
this.gotoMoveIndex(-1,true,true,true,true);
if(clog){
console.log("fm:"+_237.output());
}
this.insertMovesFromMoveList(_237);
if(_238){
this.gotoMoveIndex(_238.index);
}
};
Board.prototype.insertMoveAfter=function(_23d,_23e,_23f,_240,_241,_242){
addToMovelist=!_23f;
if(clog){
console.log("addToMovelist:"+addToMovelist);
}
var _243="null";
if(_23d){
_243=_23d.output();
}
if(clog){
console.log("insert newMove:"+_23e.output()+" after:"+_243);
}
if(_23d==null){
this.currentMove=_23e;
_23e.atEnd=0;
_23e.prev=null;
_23e.next=null;
this.firstMove=_23e;
if(this.startMoveNum>0){
this.currentMove.moveNum=this.startMoveNum;
}else{
if(this.toMove==ChessPiece.WHITE){
this.currentMove.moveNum=1;
}else{
this.currentMove.moveNum=2;
}
}
if(clog){
console.log("startMoveNum:"+this.startMoveNum+" currMoveNum:"+this.currentMove.moveNum);
}
}else{
_23e.atEnd=_23d.atEnd;
_23e.prev=_23d;
_23d.atEnd=0;
if(clog){
if(_23d.next){
console.log("prevMove.next:"+_23d.next.output());
}
}
if(_23e.equals(_23d.next)||_23e.equals(_23d)){
if(clog){
console.log("inserting move that already exists in variation:"+_23d.next.output());
}
var _244=_23d.next;
if(this.firstMove==_244){
this.firstMove=_23e;
}
if(_23e.equals(_23d)){
_244=_23d;
}
if(_244.prev&&(_244.prev.next==_244)){
_244.prev.next=_23e;
}
if(_244.next){
_244.next.prev=_23e;
}
addToMovelist=false;
_23e.moveNum=_244.moveNum;
_23e.ravLevel=_244.ravLevel;
_23e.index=_244.index;
_23e.fen=_244.fen;
_23e.nextFen=_244.nextFen;
_23e.bestMoves=_244.bestMoves;
_23e.correctMove=_244.correctMove;
_23e.wrongMove=_244.wrongMove;
_23e.next=_244.next;
_23e.vars=_244.vars;
_23e.numVars=_244.numVars;
this.reconnectNextNodeVariations(_23e,_244.next);
this.moveArray[_23e.index]=_23e;
if(this.currentMove==_244){
this.setCurrentMove(_23e);
}
}else{
_23e.moveNum=_23d.moveNum+1;
_23e.ravLevel=_23d.ravLevel;
_23e.next=_23d.next;
if(_23e.next){
_23e.next.prev=_23e;
}
}
_23d.next=_23e;
}
if(addToMovelist){
this.insertIntoMoveDisplay(_23d,_23e,_240,_241,_242);
}
if(_23e.next==null){
var _245=this.createMoveFromString("i1i2");
_23e.next=_245;
_245.prev=_23e;
_245.moveNum=_23e.moveNum+1;
_245.ravLevel=_23e.ravLevel;
_245.next=null;
_245.atEnd=1;
_245.endNode=true;
if(clog){
console.log("created endmove node in insertAfterMove:"+_245.output());
}
}else{
if(clog){
console.log("allready had a node at end:"+_23e.next.output());
}
_23e.next.moveNum=_23e.moveNum+1;
}
};
function insertBefore(node,_247){
if(_247){
_247.parentNode.insertBefore(node,_247);
}
}
function insertAfter(node,_249){
var _24a=_249.parentNode;
_24a.insertBefore(node,_249.nextSibling);
}
Board.prototype.replaceIntoMoveDisplay=function(_24b,_24c,_24d,_24e,_24f){
var _250="null";
if(_24b){
_250=_24b.output();
}
if(clog){
console.log("replace display newMove:"+_24c.output()+" after:"+_250+" hideScore:"+_24e);
}
if(!_24b){
if(clog){
console.log("null oldMove");
}
this.insertIntoMoveDisplay(null,_24c,false,_24e);
}else{
if(clog){
console.log("about to get movesdsiplay in replace into move display:"+this.movesDisplay);
}
var _251=this.movesDisplay.getMovesDisplay();
if(clog){
console.log("got moves display");
}
if(!_251){
if(clog){
console.log("no movesd disiplay in replace into move display");
}
return;
}
var san=_24c.SAN;
if(!san){
if(clog){
console.log("about to make san");
}
san=this.makeShortAlgabraic(_24c.fromColumn,_24c.fromRow,_24c.toColumn,_24c.toRow,_24c);
if(clog){
console.log("about to made san:"+san);
}
_24c.SAN=san;
}
if(clog){
console.log("oldMove.index:"+_24b.index);
}
var _253=this.boardName+"-ms"+_24b.index;
var _254=-1;
if(_24b.next){
_254=this.boardName+"-m"+_24b.next.index;
}
if(clog){
console.log("oldMoveId:"+_253);
}
var _255=YAHOO.util.Dom.get(_253);
var _256=YAHOO.util.Dom.get(_254);
if(_24d){
this.moveIndex++;
_24c.index=this.moveIndex;
this.moveArray[this.moveIndex]=_24c;
if(clog){
console.log("replace as variation old:"+_24b.output()+" new:"+_24c.output());
}
var _257=document.createElement("span");
var _258=this.movesDisplay.outputVariationStart(0,0,_24c.moveNum,0);
_24c.ravLevel=_24b.ravlevel+1;
var _250=Board.moveToLocale(san);
if(_24c.prev==null){
this.movesDisplay.firstNonMove=false;
}
var _259=this.movesDisplay.outputMove(this.moveIndex,_24c.ravLevel,_24c.moveNum,_250,_24d,0,_24c.moveNum,_24c,_24e,_24f);
var _25a=document.createElement("span");
_25a.id=(this.boardName+"-ms"+_24c.index);
_25a.innerHTML=_259+"&nbsp;";
var _25b=this.movesDisplay.outputVariationEnd(0,0,_24c.moveNum,0);
this.movesDisplay.firstNonMove=true;
var _25c=document.createElement("span");
_25c.innerHTML=_258;
var _25d=document.createElement("span");
_25d.innerHTML=_25b;
_257.appendChild(_25c);
var els=YAHOO.util.Dom.getElementsByClassName("ct-mainline-commentary","div",_257);
var _25f=_257;
if(els.length>0){
_25f=els[0];
}
_25f.appendChild(_25a);
_25f.appendChild(_25d);
_255.appendChild(_257);
if(_256){
var els=YAHOO.util.Dom.getElementsByClassName("ct-board-move-movenum","span",_256);
if(els.length==0){
var _260=_24b.next.moveNum;
var _261=""+Math.round(_260/2)+". ";
var _262=false;
if(_260%2!=1){
if(clog){
console.log("firstRav:"+firstRav+" firstNonMove:"+this.firstNonMove);
}
if(true||firstRav||!this.firstNonMove){
_261=Math.round(_260/2)+"... ";
_262=true;
}else{
_261="";
}
}
var _25a=document.createElement("span");
_25a.className="ct-board-move-movenum";
_25a.innerHTML=_261;
insertBefore(_25a,_256.firstChild);
_25a=document.createElement("span");
if(_262){
_25a.className="ct-board-move-dottedempty";
_25a.innerHTML="&nbsp;";
insertAfter(_25a,_256.firstChild);
}
}
}
}else{
_24c.index=_24b.index;
this.moveArray[_24c.index]=_24c;
var _250=Board.moveToLocale(san);
if(_24c.prev==null){
this.movesDisplay.firstNonMove=false;
}
var _259=this.movesDisplay.outputMove(_24c.index,_24c.ravLevel,_24c.moveNum,_250,_24d,0,_24c.moveNum,_24c,_24e,_24f);
var _25a=document.createElement("span");
_25a.innerHTML=_259+"&nbsp;";
_25a.id=(this.boardName+"-ms"+_24c.index);
var _263=[];
if(_255&&_255.childNodes){
for(var i=1;i<_255.childNodes.length;i++){
_263[i-1]=_255.childNodes[i];
}
}
if(clog){
console.log("replace as main line not variation old:"+_24b.output()+" new:"+_24c.output());
}
_255.parentNode.replaceChild(_25a,_255);
if(_263){
for(var i=0;i<_263.length;i++){
_25a.appendChild(_263[i]);
}
}
}
YAHOO.util.Event.removeListener(this.boardName+"-m"+_24c.index);
YAHOO.util.Event.addListener((this.boardName+"-m"+_24c.index),"click",this.movesDisplay.gotoMove,this.movesDisplay,true);
}
};
Board.prototype.insertCommentIntoMoveDisplay=function(move,_266,_267){
var _268=this.movesDisplay.getMovesDisplay();
if(!_268){
return;
}
var _269="b";
if(_267){
_269="a";
}
if(move){
var _26a=this.boardName+"-mc"+_269+move.index;
var _26b=YAHOO.util.Dom.get(_26a);
var _26c=false;
if(!_26b){
_26b=document.createElement("span");
_26b.id=_26a;
_26c=true;
}
_26b.innerHTML=this.movesDisplay.outputComment(_266,0);
var _26d=YAHOO.util.Dom.get((this.boardName+"-m"+move.index));
if(_26d){
if(_267){
move.afterComment=_266;
if(_26c){
insertAfter(_26b,_26d);
}
}else{
move.beforeComment=_266;
if(_26c){
insertBefore(_26b,_26d);
}
}
}
if(_26b&&_26c&&this.handleCommentClicks){
YAHOO.util.Event.addListener(_26b,"click",this.movesDisplay.clickComment,this.movesDisplay,true);
}
}else{
}
};
Board.prototype.insertIntoMoveDisplay=function(_26e,_26f,_270,_271,_272){
var _273=this.movesDisplay.getMovesDisplay();
if(!_273){
return;
}
if(clog){
var _274="null";
if(_26e){
_274=_26e.output();
}
console.log("insert display newMove:"+_26f.output()+" after:"+_274);
}
var san=_26f.SAN;
if(!san){
san=this.makeShortAlgabraic(_26f.fromColumn,_26f.fromRow,_26f.toColumn,_26f.toRow,_26f);
_26f.SAN=san;
}
this.moveIndex++;
_26f.index=this.moveIndex;
this.moveArray[this.moveIndex]=_26f;
var _274=Board.moveToLocale(san);
var _276=false;
var _277=null;
if(_26e){
_277=YAHOO.util.Dom.get((this.boardName+"-ms"+_26e.index));
}
if(_277){
var els=YAHOO.util.Dom.getElementsByClassName("ct-mainline-commentary","div",_277);
if(els.length>0){
_276=true;
}
}
var _279=this.movesDisplay.outputMove(this.moveIndex,_26f.ravLevel,_26f.moveNum,_274,_276,0,_26f.moveNum,_26f,_271,_272);
var _27a=document.createElement("span");
_27a.innerHTML=_279+"&nbsp;";
_27a.id=(this.boardName+"-ms"+this.moveIndex);
if(_270){
YAHOO.util.Dom.setStyle(_27a,"visibility","hidden");
}
if(_26e){
if(clog){
console.log("prevMove.index:"+_26e.index+"prevMove:"+_26e.output());
}
if(_277){
insertAfter(_27a,_277);
}else{
_273.appendChild(_27a);
}
}else{
if(_26f.next){
var _27b=YAHOO.util.Dom.get((this.boardName+"-ms"+_26f.next.index));
insertBefore(_27a,_27b);
}else{
_273.appendChild(_27a);
}
}
YAHOO.util.Event.removeListener(this.boardName+"-m"+this.moveIndex);
YAHOO.util.Event.addListener((this.boardName+"-m"+this.moveIndex),"click",this.movesDisplay.gotoMove,this.movesDisplay,true);
};
Board.prototype.replaceMove=function(_27c,_27d,_27e,_27f,_280,_281){
var _282="null";
if(_27c){
_282=_27c.output();
}
if(clog){
console.log("replace newMove:"+_27d.output()+" after:"+_282+" replace as var"+_27e+" rep move display:"+_27f+" hideScore:"+_280);
if(_27c&&_27c.prev){
console.log("replace oldMove.prev:"+_27c.prev.output());
}
if(_27c&&_27c.next){
console.log("replace oldMove.next:"+_27c.next.output());
}
}
var _283=false;
var _284=null;
var _285=0;
if(_27c.endNode){
if(clog){
console.log("asked to replace endNode,inserting before instead");
}
this.insertMoveAfter(_27c.prev,_27d,false,false,_280,_281);
_27d.fen=_27c.fen;
_27d.nextFen=_27c.nextFen;
return;
}
if(_27d.equals(_27c)){
if(clog){
console.log("new move is same as old move so not replacing as variation");
}
_27e=false;
}else{
if(_27c&&_27c.numVars>0){
for(var i=0;i<_27c.numVars;i++){
var _287=_27c.vars[i];
if(_27d.equals(_287)){
if(clog){
console.log("new move is same as an existing variation varNum:"+i);
console.log("variation:"+_287.output());
if(_287.next){
console.log("variation next:"+_287.next.output());
}
}
_283=true;
_284=_27c;
_27c=_287;
_285=i;
break;
}
}
}
}
if(_27c==null){
if(clog){
console.log("replaced new move with null oldmove");
}
this.currentMove=_27d;
_27d.atEnd=1;
_27d.next=null;
_27d.prev=null;
if(this.startPositionAfterOpponentMove){
_27d.fen=this.startPositionAfterOpponentMove;
_27d.nextFen=null;
}
if(this.toMove==ChessPiece.WHITE){
this.currentMove.moveNum=1;
}else{
this.currentMove.moveNum=2;
}
this.firstMove=_27d;
}else{
var _288=false;
if(_27c&&_27c.prev&&_27c.prev.next!=_27c){
_288=true;
}
if(this.currentMove==_27c&&!_27e){
this.currentMove=_27d;
}else{
if(clog){
console.log("not setting current move in replacemove");
}
}
_27d.atEnd=_27c.atEnd;
_27d.prev=_27c.prev;
_27d.next=_27c.next;
_27d.fen=_27c.fen;
_27d.nextFen=_27c.nextFen;
_27d.bestMoves=_27c.bestMoves;
_27d.correctMove=_27c.correctMove;
_27d.wrongMove=_27c.wrongMove;
_27d.moveNum=_27c.moveNum;
_27d.ravLevel=_27c.ravLevel;
_27d.index=_27c.index;
if(clog){
console.log("replacingVariation with var not null:"+_283);
}
if(_283){
_284.vars[_285]=_27d;
_27d.vars=_27c.vars;
_27d.numVars=_27c.numVars;
this.reconnectNextNodeVariations(_27d,_27c.next);
if(_27c.next){
_27c.next.prev=_27d;
}
this.moveArray[_27d.index]=_27d;
if(clog){
console.log("replacing existing sub variation of main line");
if(_27d.next){
console.log("next of replacement variation:"+_27d.next.output());
}
}
return;
}
if(!_27e){
if(clog){
console.log("not replacing as variation");
}
if(!_288&&_27c.prev){
_27c.prev.next=_27d;
}
if(_27c.next){
_27c.next.prev=_27d;
}
_27d.vars=_27c.vars;
_27d.numVars=_27c.numVars;
this.reconnectNextNodeVariations(_27d,_27c.next);
if(this.firstMove==_27c){
this.firstMove=_27d;
}
this.moveArray[_27d.index]=_27d;
}else{
if(clog){
console.log("replacing as variation");
}
if(_27c.numVars==0){
_27c.vars=new Array();
}
_27c.vars[_27c.numVars++]=_27d;
_27c.atEnd=0;
_27d.next=null;
var _289=this.createMoveFromString("i1i2");
_27d.next=_289;
_289.prev=_27d;
_289.next=null;
_289.atEnd=1;
_289.moveNum=_27d.moveNum+1;
_289.ravLevel=_27d.ravLevel;
_289.endNode=true;
}
}
if(_27f){
this.replaceIntoMoveDisplay(_27c,_27d,_27e,_280,_281);
}
};
Board.prototype.setCurrentMove=function(move,_28b,_28c){
if(!this.cloned&&this.currentMove!=null){
if(this.currentMove.prev!=null){
YAHOO.util.Dom.removeClass(this.boardName+"-m"+this.currentMove.prev.index,"ct-board-move-current");
}
}
this.currentMove=move;
if(!this.cloned&&this.currentMove!=null&&this.currentMove.prev!=null){
var _28d=this.boardName+"-m"+this.currentMove.prev.index;
if(clog){
console.log("setCurrentMove attempted highlight of id:"+_28d+" for move:"+move.output());
}
var span=YAHOO.util.Dom.get(_28d);
if(span){
var cls=span.className;
YAHOO.util.Dom.addClass(span,"ct-board-move-current");
if(this.autoScrollMoves){
if(!_28c&&(this.scrollVariations||cls.indexOf("ct-board-move-variation")==-1)){
var _290=this.movesDisplay.getMovesDisplay();
if(_290){
var y=YAHOO.util.Dom.getY(span)-YAHOO.util.Dom.getY(_290);
var _292=new YAHOO.util.Scroll(_290,{scroll:{by:[0,y-this.scrollOffsetCorrection]}},this.moveAnimationLength,YAHOO.util.Easing.easeOut);
_292.animate();
}
}
}
}
}else{
if(move==null){
if(clog){
console.log("attempted to set current move on null node");
}
}
}
if(!_28b){
this.setForwardBack();
}
};
Board.prototype.distanceFromInitial=function(){
var _293=this.cloneBoard();
_293.setupFromFen(Board.INITIAL_FEN,false,false,true,false,false);
var _294=0;
for(var i=0;i<8;i++){
for(var j=0;j<8;j++){
var p1=this.boardPieces[i][j];
var p2=_293.boardPieces[i][j];
if(p1==p2){
continue;
}
if(!p2){
continue;
}
if(!p1){
_294++;
continue;
}
if(p1.piece==p2.piece&&p1.colour==p2.colour){
continue;
}
_294++;
}
}
return _294;
};
Board.INITIAL_FEN="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
Board.isFenLegal=function(fen){
function isLegalCastling(c){
if(!c){
return false;
}
c=c.toLowerCase();
for(var i=0;i<c.length;i++){
if(!(c.charAt(i)=="q"||c.charAt(i)=="k"||c.charAt(i)=="-")){
return false;
}
}
return true;
}
function isLegalEnpassant(m){
if(!m){
return false;
}
if(m=="-"){
return true;
}
if(m.length!=2){
return false;
}
if(m.charAt(0)<"a"||m.charAt(0)>"h"){
return false;
}
var n=parseInt(m.charAt(1));
if(isNaN(n)||n<1||n>8){
return false;
}
return true;
}
function isRowLegal(r){
if(!r){
return false;
}
r=r.toLowerCase();
for(var i=0;i<r.length;i++){
if(!isSquareCharLegal(r.charAt(i))){
return false;
}
}
return true;
}
function isSquareCharLegal(c){
switch(c){
case "1":
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "p":
case "k":
case "b":
case "q":
case "r":
case "k":
return true;
default:
false;
}
}
if(!fen){
return false;
}
var ss=fen.split(" ");
if(ss.length!=6){
return false;
}
var pos=ss[0].split("/");
if(pos.length!=8){
return false;
}
if(ss[1]!="w"&&ss[1]!="b"){
return false;
}
if(isNaN(parseInt(ss[4]))){
return false;
}
if(isNaN(parseInt(ss[5]))){
return false;
}
if(!isLegalCastling(ss[2])){
return false;
}
if(!isLegalEnpassant(ss[3])){
return false;
}
return true;
};
Board.prototype.boardToUniqueFen=function(_2a3){
var fen=this.boardToFen();
var ss=fen.split(" ");
var _2a6="w";
if(_2a3==ChessPiece.BLACK){
_2a6="b";
}
var _2a7=ss[0]+" "+_2a6+" "+ss[2]+" "+ss[3];
return _2a7;
};
Board.prototype.boardToFen=function(_2a8){
var _2a9="";
for(var row=7;row>=0;row--){
var _2ab=0;
var line="";
if(row<7){
line="/";
}
for(var col=0;col<8;col++){
var _2ae=this.boardPieces[col][row];
if(_2ae){
var _2af="";
if(_2ab>0){
_2af=_2ab+"";
}
line+=_2af+_2ae.getFenLetter();
_2ab=0;
}else{
_2ab++;
}
}
if(_2ab>0){
line+=_2ab+"";
}
_2a9+=line;
}
var fen=_2a9;
var _2b1=" w ";
if(_2a8){
if(this.toMove==ChessPiece.WHITE){
_2b1=" b ";
}
}else{
if(this.toMove==ChessPiece.BLACK){
_2b1=" b ";
}
}
fen+=_2b1;
var _2b2="";
_2b2+=Board.getFenCastleChar(this.canCastleKingSide,"K",ChessPiece.WHITE);
_2b2+=Board.getFenCastleChar(this.canCastleQueenSide,"Q",ChessPiece.WHITE);
_2b2+=Board.getFenCastleChar(this.canCastleKingSide,"K",ChessPiece.BLACK);
_2b2+=Board.getFenCastleChar(this.canCastleQueenSide,"Q",ChessPiece.BLACK);
if(_2b2==""){
fen+="- ";
}else{
fen+=_2b2+" ";
}
var _2b3=null;
if(this.currentMove){
if(this.currentMove.prev){
_2b3=this.currentMove.prev;
}else{
_2b3=this.prev_move;
}
}else{
_2b3=this.prev_move;
}
var _2b4="- ";
if(_2b3){
if(_2b3){
var _2b5=this.boardPieces[_2b3.toColumn][_2b3.toRow];
if(_2b5){
if(_2b5.piece==ChessPiece.PAWN){
if(_2b5.colour==ChessPiece.WHITE){
if(_2b3.fromRow==1&&_2b3.toRow==3){
_2b4=Move.columnToChar(_2b3.fromColumn)+"3 ";
}
}else{
if(_2b3.fromRow==6&&_2b3.toRow==4){
_2b4=Move.columnToChar(_2b3.fromColumn)+"6 ";
}
}
}
}
}
}
fen+=_2b4;
fen+=this.halfMoveNumber+" "+parseInt((this.moveNumber+1)/2);
if(clog){
console.log("moveNumber:"+this.moveNumber+" fen:"+fen);
}
return fen;
};
Board.getFenCastleChar=function(_2b6,_2b7,_2b8){
if(_2b6[_2b8]){
if(_2b8==ChessPiece.WHITE){
return _2b7.toUpperCase();
}else{
return _2b7.toLowerCase();
}
}
return "";
};
Board.prototype.getCastlingString=function(_2b9){
var _2ba=_js("None");
if(this.canCastleKingSide[_2b9]){
_2ba="O-O";
}
if(this.canCastleQueenSide[_2b9]){
if(_2ba==_js("None")){
_2ba="O-O-O";
}else{
_2ba+=",O-O-O";
}
}
return _2ba;
};
Board.prototype.updateToPlay=function(){
if(this.disableUpdateToPlay){
return;
}
if(this.showToMoveIndicators){
if(this.isFlipped){
YAHOO.util.Dom.setStyle(this.boardName+"-top-to-move-inner","background-color","white");
YAHOO.util.Dom.setStyle(this.boardName+"-top-to-move-inner","border","1px solid black");
YAHOO.util.Dom.setStyle(this.boardName+"-bottom-to-move-inner","background-color","black");
YAHOO.util.Dom.setStyle(this.boardName+"-bottom-to-move-inner","border","1px solid white");
}else{
YAHOO.util.Dom.setStyle(this.boardName+"-bottom-to-move-inner","background-color","white");
YAHOO.util.Dom.setStyle(this.boardName+"-bottom-to-move-inner","border","1px solid black");
YAHOO.util.Dom.setStyle(this.boardName+"-top-to-move-inner","background-color","black");
YAHOO.util.Dom.setStyle(this.boardName+"-top-to-move-inner","border","1px solid white");
}
if(this.toMove==ChessPiece.WHITE){
if(this.isFlipped){
YAHOO.util.Dom.addClass(this.boardName+"-top-to-move-outer","ct-to-move-active");
YAHOO.util.Dom.removeClass(this.boardName+"-bottom-to-move-outer","ct-to-move-active");
}else{
YAHOO.util.Dom.addClass(this.boardName+"-bottom-to-move-outer","ct-to-move-active");
YAHOO.util.Dom.removeClass(this.boardName+"-top-to-move-outer","ct-to-move-active");
}
}else{
if(this.isFlipped){
YAHOO.util.Dom.addClass(this.boardName+"-bottom-to-move-outer","ct-to-move-active");
YAHOO.util.Dom.removeClass(this.boardName+"-top-to-move-outer","ct-to-move-active");
}else{
YAHOO.util.Dom.addClass(this.boardName+"-top-to-move-outer","ct-to-move-active");
YAHOO.util.Dom.removeClass(this.boardName+"-bottom-to-move-outer","ct-to-move-active");
}
}
}
var _2bb=YAHOO.util.Dom.get("toPlay");
if(_2bb==null){
return;
}
if(this.toMove==ChessPiece.WHITE){
_2bb.src="/images/whiteknight"+this.getVersString()+".gif";
_2bb.alt=_js("White to play");
}else{
_2bb.src="/images/blackknight"+this.getVersString()+".gif";
_2bb.alt=_js("Black to play");
}
var _2bc=YAHOO.util.Dom.get("fenStatus");
if(_2bc){
var _2bd=this.getCastlingString(ChessPiece.BLACK);
var _2be=this.getCastlingString(ChessPiece.WHITE);
var s="<div><span>"+_js("White Castling: ")+"</span><span>"+_2be+"</span></div>"+"<div><span>"+_js("Black Castling: ")+"</span><span>"+_2bd+"</span></div>";
_2bc.innerHTML=s;
}
};
Board.prototype.getBoardDivFromId=function(id){
if(!this[id]){
this[id]=YAHOO.util.Dom.get(id);
}
return this[id];
};
Board.prototype.getBoardDiv=function(){
if(!this.boardDiv){
this.boardDiv=YAHOO.util.Dom.get("ctb-"+this.boardName);
}
return this.boardDiv;
};
Board.prototype.getDocBody=function(){
if(!this.docBody){
var _2c1=document.getElementsByTagName("body");
if(_2c1==null||_2c1.length==0){
alert("Could not find body tag");
}else{
this.docBody=_2c1[0];
}
}
return this.docBody;
};
Board.prototype.getPieceDragDiv=function(){
if(!this.pieceDragDiv){
this.pieceDragDiv=YAHOO.util.Dom.get("pieceDragDiv");
}
return this.pieceDragDiv;
};
Board.prototype.createBoardCoords=function(){
this.coordinatesShown=false;
var _2c2=YAHOO.util.Dom.get(this.boardName+"-fileLabels");
var _2c3=YAHOO.util.Dom.get(this.boardName+"-rankLabels");
if(!_2c2||!_2c3){
return;
}
YAHOO.util.Event.purgeElement(_2c2,true);
_2c3.innerHTML="";
_2c2.innerHTML="";
var _2c4=YAHOO.util.Dom.get(this.boardName+"-boardBorder");
if(!this.showCoordinates){
YAHOO.util.Dom.setStyle(_2c2,"display","none");
YAHOO.util.Dom.setStyle(_2c3,"display","none");
var _2c5=0;
YAHOO.util.Dom.setStyle(_2c4,"width",(this.pieceSize*8+_2c5)+"px");
YAHOO.util.Dom.setStyle(_2c4,"height",(this.pieceSize*8+_2c5)+"px");
return;
}
YAHOO.util.Dom.setStyle(_2c2,"display","block");
YAHOO.util.Dom.setStyle(_2c3,"display","block");
var _2c5=15;
var _2c6=0;
if(check_bad_msie()){
_2c6=this.ie6FixCoordsOffsetSize;
}
if(YAHOO.util.Event.isIE){
_2c6+=this.allIeFixCoordsOffsetSize;
if(document.compatMode!="CSS1Compat"){
_2c6=8;
}
}
YAHOO.util.Dom.setStyle(_2c4,"width",(this.pieceSize*8+_2c5+_2c6)+"px");
YAHOO.util.Dom.setStyle(_2c4,"height",(this.pieceSize*8+_2c5)+"px");
this.coordinatesShown=true;
for(var i=0;i<8;i++){
var _2c8=document.createElement("div");
YAHOO.util.Dom.setStyle(_2c8,"height",this.pieceSize+"px");
YAHOO.util.Dom.setStyle(_2c8,"width","15px");
YAHOO.util.Dom.setStyle(_2c8,"text-align","center");
YAHOO.util.Dom.setStyle(_2c8,"line-height",this.pieceSize+"px");
if(this.isFlipped){
_2c8.innerHTML=""+(i+1);
}else{
_2c8.innerHTML=""+9-(i+1);
}
_2c3.appendChild(_2c8);
}
for(var i=0;i<9;i++){
var _2c9=document.createElement("span");
YAHOO.util.Dom.setStyle(_2c9,"float","left");
YAHOO.util.Dom.setStyle(_2c9,"height","15px");
if(i==0){
YAHOO.util.Dom.setStyle(_2c9,"width","15px");
YAHOO.util.Dom.setStyle(_2c9,"clear","both");
YAHOO.util.Dom.setStyle(_2c9,"margin-top","-5px");
if(_2c6){
YAHOO.util.Dom.setStyle(_2c9,"margin-left","-3px");
}else{
YAHOO.util.Dom.setStyle(_2c9,"margin-left","-2px");
}
var _2ca="";
if(this.isFlipped){
_2ca="whiteblack-flipper"+this.getVersString()+".png";
}else{
_2ca="blackwhite-flipper"+this.getVersString()+".png";
}
_2c9.innerHTML="<span><img id=\""+this.boardName+"-flipper\" title=\""+_js("Flip Board")+"\" src=\""+this.boardImagePath+"/images/"+_2ca+"\"/></span>";
if(!this.disableFlipper){
YAHOO.util.Event.addListener(this.boardName+"-flipper","click",this.flipBoard,this,true);
}
}else{
YAHOO.util.Dom.setStyle(_2c9,"width",this.pieceSize+"px");
YAHOO.util.Dom.setStyle(_2c9,"text-align","center");
if(this.isFlipped){
_2c9.innerHTML=_js(Move.columnToChar(8-(i)));
}else{
_2c9.innerHTML=_js(Move.columnToChar((i-1)));
}
}
_2c2.appendChild(_2c9);
}
var _2cb=YAHOO.util.Dom.get(this.boardName+"-flipper");
if(_2cb){
fix_ie_png(_2cb);
}
};
Board.prototype.showNavigation=function(){
this.disableNavigation=false;
YAHOO.util.Dom.setStyle(this.boardName+"-ct-nav-container","display","block");
};
Board.prototype.hideNavigation=function(){
this.disableNavigation=true;
YAHOO.util.Dom.setStyle(this.boardName+"-ct-nav-container","display","none");
};
Board.prototype.createBoardUI=function(){
var _2cc=this.boardName+"-container";
var _2cd=YAHOO.util.Dom.get(_2cc);
if(_2cd==null){
alert("Could not find board container:"+_2cc);
return;
}
YAHOO.util.Dom.addClass(_2cd,"ct-board-container");
this.boardDiv=null;
var _2ce=document.createElement("div");
_2ce.id=this.boardName+"-boardBorder";
YAHOO.util.Dom.addClass(_2ce,"ct-board-border"+this.squareColorClass);
var _2cf=0;
if(this.showCoordinates){
_2cf=15;
}
YAHOO.util.Dom.setStyle(_2ce,"width",(this.pieceSize*8+_2cf)+"px");
YAHOO.util.Dom.setStyle(_2ce,"height",(this.pieceSize*8+_2cf)+"px");
var _2d0=document.createElement("div");
YAHOO.util.Dom.setStyle(_2d0,"float","left");
_2d0.id=this.boardName+"-rankLabels";
_2ce.appendChild(_2d0);
var _2d1=document.createElement("div");
YAHOO.util.Dom.addClass(_2d1,"ct-board");
YAHOO.util.Dom.setStyle(_2d1,"width",(this.pieceSize*8)+"px");
YAHOO.util.Dom.setStyle(_2d1,"height",(this.pieceSize*8)+"px");
_2d1.id="ctb-"+this.boardName;
var _2d2="ct-white-square"+this.squareColorClass;
var _2d3="";
var _2d4=[];
for(var i=7;i>=0;i--){
var s="<div>";
for(var j=0;j<8;j++){
var _2d8=document.createElement("div");
var _2d9=this.boardName+"-s"+j+""+i;
var _2da=(((j+1)*(i+1))%19/19*100);
var _2db=((65-((j+1)*(i+1)))%19/19*100);
s+="<div id=\""+_2d9+"\" class=\""+_2d2+"\" style=\"width:"+this.pieceSize+"px;height:"+this.pieceSize+"px;background-position:"+_2da+"% "+_2db+"%\"></div>";
_2d4.push(_2d9);
_2d2=(_2d2=="ct-black-square"+this.squareColorClass)?"ct-white-square"+this.squareColorClass:"ct-black-square"+this.squareColorClass;
}
_2d2=(_2d2=="ct-black-square"+this.squareColorClass)?"ct-white-square"+this.squareColorClass:"ct-black-square"+this.squareColorClass;
s+="</div>";
_2d3+=s;
}
_2d1.innerHTML=_2d3;
var _2dc=document.createElement("div");
_2dc.id=this.boardName+"-fileLabels";
_2ce.appendChild(_2d1);
_2ce.appendChild(_2dc);
_2cd.appendChild(_2ce);
if(this.showToMoveIndicators){
var _2dd=document.createElement("div");
_2dd.id=this.boardName+"-moveIndicators";
YAHOO.util.Dom.addClass(_2dd,"ct-move-indicators");
_2dd.innerHTML="<div class=\"ct-top-to-move-outer\" id=\""+this.boardName+"-top-to-move-outer\"><div  class=\"ct-top-to-move-inner\" id=\""+this.boardName+"-top-to-move-inner\"></div></div><div class=\"ct-bottom-to-move-outer\"  id=\""+this.boardName+"-bottom-to-move-outer\"><div class=\"ct-bottom-to-move-inner\" id=\""+this.boardName+"-bottom-to-move-inner\" ></div>";
_2cd.appendChild(_2dd);
YAHOO.util.Dom.setStyle(_2ce,"float","left");
YAHOO.util.Dom.setStyle(_2dd,"float","left");
YAHOO.util.Dom.setStyle(_2dd,"margin-left","2px");
YAHOO.util.Dom.setStyle(_2dd,"height",((this.pieceSize*8)+2)+"px");
YAHOO.util.Dom.setStyle(_2dd,"position","relative");
var _2de=document.createElement("div");
YAHOO.util.Dom.setStyle(_2de,"clear","both");
_2cd.appendChild(_2de);
}
this.createBoardCoords();
var _2df=false;
var _2e0=YAHOO.util.Dom.get(this.boardName+"-ct-nav-container");
if(!_2e0){
_2e0=document.createElement("div");
}else{
_2df=true;
_2e0.innerHTML="";
}
_2e0.id=this.boardName+"-ct-nav-container";
if(!this.dontOutputNavButtons||this.r){
var _2e1="";
if(!this.dontOutputNavButtons){
if(!this.problem||!this.problem.isEndgame){
_2e1="<span id=\"playStopSpan\"><img class=\"ct-end\" id=\""+this.boardName+"-end\" src=\""+this.boardImagePath+"/images/resultset_last"+this.getVersString()+".gif\" alt=\""+_js("End position")+"\" title=\""+_js("Go to final position")+"\"/>"+"<img class=\"ct-play\" id=\""+this.boardName+"-play\" src=\""+this.boardImagePath+"/images/control_play_blue"+this.getVersString()+".gif\" alt=\""+_js("Play moves")+"\" title=\""+_js("Play sequence of moves")+"\"/>"+"<img class=\"ct-stop\" id=\""+this.boardName+"-stop\" src=\""+this.boardImagePath+"/images/control_stop_blue"+this.getVersString()+".gif\" alt=\""+_js("Stop playing")+"\" title=\""+_js("Stop playing move sequence")+"\"/></span>";
}
}
var _2e2="<div class=\"ct-nav-buttons\" id=\""+this.boardName+"-navButtons\"><span id=\""+this.boardName+"-nav-buttons-only\">";
if(!this.dontOutputNavButtons){
var size="";
if(isIphone){
size=" width=\"50px\" height=\"34px\" ";
_2e1="";
}
if(!isIphone){
_2e2+="<img class=\"ct-start\" id=\""+this.boardName+"-start\" src=\""+this.boardImagePath+"/images/resultset_first"+this.getVersString()+".gif\" alt=\""+_js("Start position")+"\" title=\""+_js("Go to starting position")+"\"/>";
}
_2e2+="<img class=\"ct-back\" id=\""+this.boardName+"-back\" "+size+" src=\""+this.boardImagePath+"/images/resultset_previous"+this.getVersString()+".gif\" alt=\""+_js("Previous Move")+"\" title=\""+_js("Go back a move")+"\"/>"+"<img class=\"ct-forward\" id=\""+this.boardName+"-forward\" "+size+" src=\""+this.boardImagePath+"/images/resultset_next"+this.getVersString()+".gif\" alt=\""+_js("Next Move")+"\" title=\""+_js("Go forward a move")+"\"/>"+_2e1;
}
if(this.r){
_2e2+="<img class=\"ct-forward\" id=\""+this.boardName+"-analyse\" src=\""+this.boardImagePath+"/images/anboard"+this.getVersString()+".gif\" alt=\""+_js("Analyse")+"\" title=\""+_js("Launch analysis board to explore different lines in this position")+"\"/>";
if(!this.g){
_2e2+="<img class=\"ct-forward\" id=\""+this.boardName+"-showfen\" src=\""+this.boardImagePath+"/images/copy_fen"+this.getVersString()+".gif\" alt=\""+_js("Copy FEN")+"\" title=\""+_js("Show FEN for current position")+"\"/>";
}
}
if(this.canPasteFen){
_2e2+="<img class=\"ct-forward\" id=\""+this.boardName+"-pastefen\" src=\""+this.boardImagePath+"/images/paste_fen"+this.getVersString()+".gif\" alt=\""+_js("Input FEN")+"\" title=\""+_js("Setup position from user supplied FEN or move list")+"\"/>";
}
if(this.g2){
_2e2+="<img class=\"ct-forward\" id=\""+this.boardName+"-playcomp\" src=\""+this.boardImagePath+"/images/computer"+this.getVersString()+".gif\" alt=\""+_js("Play Current Position vs Computer")+"\" title=\""+_js("Play current position against computer")+"\"/>";
}
_2e2+="</span>";
_2e2+="</div>";
if(this.puzzle){
var _2e4="";
var _2e5="";
var _2e6="";
var _2e7="";
if(this.pieceSize>=29){
_2e4=_js("Easy");
_2e5=_js("Medium");
_2e6=_js("Hard");
_2e7=_js("Help");
}else{
_2e4=_js("D1");
_2e5=_js("D2");
_2e6=_js("D3");
_2e7=_js("?");
}
_2e2+="<div><form action=\"\"><button type=\"button\" id=\""+this.boardName+"-puzzleSolution\" class=\"asolution-button\">"+_js("Show")+"</button><button id=\""+this.boardName+"-easyPuzzle\" type=\"button\" class=\"puzzle-difficulty\">"+_2e4+"</button>"+"<button id=\""+this.boardName+"-mediumPuzzle\" type=\"button\" class=\"puzzle-difficulty\">"+_2e5+"</button>"+"<button id=\""+this.boardName+"-hardPuzzle\" type=\"button\" class=\"puzzle-difficulty\">"+_2e6+"</button>"+"<button id=\""+this.boardName+"-puzzleHelp\" type=\"button\" class=\"puzzle-difficulty\">"+_2e7+"</button>"+"<img alt=\"\" class=\"ct-forward\" id=\""+this.boardName+"-problemState\"></img><span id=\""+this.boardName+"-puzzleResult\"></span></form></div>";
_2e2+="<div class=\"initially_hidden initially_invisible\" id=\""+this.boardName+"-moves\"></div>";
_2e2+="<div class=\"initially_hidden initially_invisible\" id=\""+this.boardName+"-moves\"></div>";
}
_2e0.innerHTML=_2e2;
}
if(!_2df){
_2cd.appendChild(_2e0);
}
if(this.problem){
var body=YAHOO.util.Dom.get("body");
if(body){
YAHOO.util.Dom.setStyle(body,"min-width",((this.pieceSize*8+_2cf)+300+200+120)+"px");
}
}
};
Board.prototype.getPieceDiv=function(){
var _2e9=this.getBoardDiv();
var _2ea=document.createElement("div");
this.availPieceDivs[this.uptoId]=_2ea;
this.availIds[this.uptoId]=YAHOO.util.Dom.generateId(_2ea);
YAHOO.util.Dom.setStyle(_2ea,"visibility","hidden");
YAHOO.util.Dom.addClass(_2ea,"board-piece-start-style");
_2e9.appendChild(_2ea);
this.uptoId++;
return _2ea;
};
Board.prototype.flipToMove=function(_2eb){
return (_2eb=="w")?"b":"w";
};
Board.prototype.pieceCharToPieceNum=function(_2ec){
var _2ed;
switch(_2ec){
case "K":
_2ed=ChessPiece.KING;
break;
case "Q":
_2ed=ChessPiece.QUEEN;
break;
case "R":
_2ed=ChessPiece.ROOK;
break;
case "B":
_2ed=ChessPiece.BISHOP;
break;
case "N":
_2ed=ChessPiece.KNIGHT;
break;
case "P":
_2ed=ChessPiece.PAWN;
break;
}
return _2ed;
};
Board.prototype.pieceTypeToChar=function(_2ee){
switch(_2ee){
case ChessPiece.KING:
return "K";
case ChessPiece.QUEEN:
return "Q";
case ChessPiece.ROOK:
return "R";
case ChessPiece.BISHOP:
return "B";
case ChessPiece.KNIGHT:
return "N";
case ChessPiece.PAWN:
return "P";
}
return "?";
};
Board.prototype.canMoveKnight=function(_2ef,_2f0,_2f1,_2f2){
if(_2ef+2==_2f1&&_2f0+1==_2f2){
return true;
}
if(_2ef+2==_2f1&&_2f0-1==_2f2){
return true;
}
if(_2ef-2==_2f1&&_2f0+1==_2f2){
return true;
}
if(_2ef-2==_2f1&&_2f0-1==_2f2){
return true;
}
if(_2ef+1==_2f1&&_2f0+2==_2f2){
return true;
}
if(_2ef-1==_2f1&&_2f0+2==_2f2){
return true;
}
if(_2ef+1==_2f1&&_2f0-2==_2f2){
return true;
}
if(_2ef-1==_2f1&&_2f0-2==_2f2){
return true;
}
return false;
};
Board.prototype.canMovePawn=function(_2f3,_2f4,_2f5,_2f6,_2f7){
var _2f8=this.boardPieces[_2f5][_2f6];
var _2f9=this.boardPieces[_2f3][_2f4];
if(_2f7){
var _2fa=this.boardPieces[_2f7.toColumn][_2f7.toRow];
if(_2fa&&_2fa.piece==ChessPiece.PAWN){
if(_2fa.colour==ChessPiece.WHITE){
if(_2f7.fromRow==1&&_2f7.toRow==3){
if(_2f5==_2f7.fromColumn&&_2f4==3&&_2f6==2&&(_2f3==_2f5+1||_2f3==_2f5-1)){
return true;
}
}
}else{
if(_2f7.fromRow==6&&_2f7.toRow==4){
if(_2f5==_2f7.fromColumn&&_2f4==4&&_2f6==5&&(_2f3==_2f5+1||_2f3==_2f5-1)){
return true;
}
}
}
}
}
if(_2f8){
if(_2f9.colour==ChessPiece.WHITE){
if((_2f3==_2f5+1||_2f3==_2f5-1)&&(_2f4==_2f6-1)){
return true;
}
}else{
if((_2f3==_2f5+1||_2f3==_2f5-1)&&(_2f4==_2f6+1)){
return true;
}
}
}else{
if(_2f3==_2f5){
if(_2f9.colour==ChessPiece.WHITE){
if(_2f4==1){
if(_2f6==2){
return true;
}else{
if(_2f6==3&&this.boardPieces[_2f5][2]==null){
return true;
}
}
}else{
if(_2f4+1==_2f6){
return true;
}
}
}else{
if(_2f4==6){
if(_2f6==5){
return true;
}else{
if(_2f6==4&&this.boardPieces[_2f5][5]==null){
return true;
}
}
}else{
if(_2f4-1==_2f6){
return true;
}
}
}
}
}
return false;
};
Board.prototype.canMoveStraight=function(_2fb,_2fc,_2fd,_2fe,_2ff,_300){
var _301=_2fb;
var _302=_2fc;
var _303=0;
var _304=0;
if(_2fd>_2fb){
_303=1;
}else{
if(_2fd<_2fb){
_303=-1;
}
}
if(_2fe>_2fc){
_304=1;
}else{
if(_2fe<_2fc){
_304=-1;
}
}
if(clog){
console.log("deltaRow:"+_304+" deltaCol:"+_303+" fromCol:"+_2fb+" fromRow:"+_2fc+" toCol:"+_2fd+" toRow:"+_2fe);
}
if(_2ff==ChessPiece.ROOK&&(_303!=0&&_304!=0)){
return false;
}
if(_2ff==ChessPiece.BISHOP&&(_303==0||_304==0)){
return false;
}
var _305=0;
while(true){
_305++;
_2fb+=_303;
_2fc+=_304;
if(_2ff==ChessPiece.KING&&_305>1){
if(clog){
console.log("king count:"+_305+" toCol:"+_2fd+" toRow:"+_2fe);
}
if(_305!=2){
return false;
}
if(_304!=0){
return false;
}
if(!(_2fd==6||_2fd==2)){
return false;
}
if(_2fd==2){
if(this.boardPieces[1][_2fc]||this.boardPieces[2][_2fc]||this.boardPieces[3][_2fc]){
return false;
}
if(!this.canCastleQueenSide[_300.colour]){
return false;
}
}else{
if(_2fd==6){
if(this.boardPieces[5][_2fc]||this.boardPieces[6][_2fc]){
if(clog){
console.log("king can't castle intervening piece");
}
return false;
}
if(!this.canCastleKingSide[_300.colour]){
if(clog){
console.log("king can't castle king side (made previously invalid) colour:"+_300.colour);
}
return false;
}
}else{
if(clog){
console.log("king not in col 2 or 6");
}
return false;
}
}
var _306="";
_306+=Move.columnToChar(_301);
_306+=String.fromCharCode("1".charCodeAt(0)+_302);
_306+=Move.columnToChar((_301+_303));
_306+=String.fromCharCode("1".charCodeAt(0)+(_302+_304));
var move=this.createMoveFromString(_306);
var _308=this.cloneBoard();
_308.makeMove(move,_308.boardPieces[_301][_302],false,this.moveAnimationLength,false,false);
kingSafe=_308.isKingSafe(_300.colour,move);
if(clog){
console.log("kingSafe1:"+kingSafe);
}
if(!kingSafe){
return false;
}
var _306="";
_306+=Move.columnToChar(_301);
_306+=String.fromCharCode("1".charCodeAt(0)+_302);
_306+=Move.columnToChar(_301);
_306+=String.fromCharCode("1".charCodeAt(0)+_302);
var move=this.createMoveFromString(_306);
var _308=this.cloneBoard();
_308.makeMove(move,_308.boardPieces[_301][_302],false,this.moveAnimationLength,false,false);
kingSafe=_308.isKingSafe(_300.colour,move);
var _308=this.cloneBoard();
_308.makeMove(move,_308.boardPieces[_301][_302],false,this.moveAnimationLength,false,false);
kingSafe=this.isKingSafe(_300.colour,move);
if(clog){
console.log("kingSafe2:"+kingSafe);
}
if(!kingSafe){
return false;
}
}
if(_2fb==_2fd&&_2fc==_2fe){
return true;
}
if(_2fb<0||_2fb>7||_2fc<0||_2fc>7){
return false;
}
if(this.boardPieces[_2fb][_2fc]!=null){
return false;
}
}
};
Board.prototype.canMove=function(_309,_30a,_30b,_30c,_30d){
var _30e=_309.column;
var _30f=_309.row;
if(_30a>7||_30a<0||_30b>7||_30b<0){
if(clog){
console.log("can't move coz out of bounds");
}
return false;
}
var _310=this.boardPieces[_30a][_30b];
var _311=this.boardPieces[_30e][_30f];
if(_311==null){
return false;
}
if(_310&&_310.colour==_311.colour){
return false;
}
var _312=false;
if(_309.piece==ChessPiece.PAWN){
_312=this.canMovePawn(_30e,_30f,_30a,_30b,_30c);
}else{
if(_309.piece==ChessPiece.KNIGHT){
_312=this.canMoveKnight(_30e,_30f,_30a,_30b);
}else{
_312=this.canMoveStraight(_30e,_30f,_30a,_30b,_309.piece,_309);
}
}
if(clog){
console.log("moveOk:"+_312);
}
var _313=true;
if(_312&&_30d){
var _314="";
_314+=Move.columnToChar(_30e);
_314+=String.fromCharCode("1".charCodeAt(0)+_30f);
_314+=Move.columnToChar(_30a);
_314+=String.fromCharCode("1".charCodeAt(0)+_30b);
var move=this.createMoveFromString(_314);
var _316=this.cloneBoard();
_316.makeMove(move,_316.boardPieces[_30e][_30f],false,this.moveAnimationLength,false,false);
_313=_316.isKingSafe(_309.colour,move);
}
return _312&&_313;
};
Board.prototype.is50MoveRule=function(){
return (this.halfMoveNumber>=100);
};
Board.prototype.isCheckmate=function(_317){
return (!this.isKingSafe(this.toMove,_317)&&this.isKingMated(this.toMove,_317));
};
Board.prototype.isStalemate=function(_318){
return (this.isKingSafe(this.toMove,_318)&&(this.getCandidateMoves(this.toMove,_318,true)).length==0);
};
Board.prototype.isKingMated=function(_319,_31a){
var _31b=null;
for(var i=0;i<8;i++){
for(var j=0;j<8;j++){
var bp=this.boardPieces[i][j];
if(bp!=null&&bp.piece==ChessPiece.KING&&bp.colour==_319){
_31b=bp;
break;
}
}
}
var _31f=[[1,0],[1,1],[1,-1],[-1,0],[-1,1],[-1,-1],[0,1],[0,-1],[2,0],[-2,0]];
var bp=_31b;
for(var k=0;k<_31f.length;k++){
if(this.canMove(bp,bp.column+_31f[k][0],bp.row+_31f[k][1],_31a,true)){
return false;
}
}
var _321=this.getCandidateMoves(_319,_31a,true,true);
if(_321.length>0){
return false;
}
return true;
};
Board.prototype.getCandidateMoves=function(_322,_323,_324,_325){
var _326=new Array();
for(var i=0;i<8;i++){
for(var j=0;j<8;j++){
var bp=this.boardPieces[i][j];
var _32a=[];
if(!bp||bp.colour!=_322){
continue;
}
switch(bp.piece){
case ChessPiece.KING:
if(_325){
continue;
}
_32a=[[1,0],[1,1],[1,-1],[-1,0],[-1,1],[-1,-1],[0,1],[0,-1],[2,0],[-2,0]];
break;
case ChessPiece.KNIGHT:
_32a=[[2,1],[2,-1],[-2,1],[-2,-1],[1,2],[1,-2],[-1,2],[-1,-2]];
break;
case ChessPiece.BISHOP:
for(var k=0;k<8;k++){
_32a.push([1+k,1+k]);
_32a.push([1+k,-1-k]);
_32a.push([-1-k,1+k]);
_32a.push([-1-k,-1-k]);
}
break;
case ChessPiece.QUEEN:
for(var k=0;k<8;k++){
_32a.push([1+k,0]);
_32a.push([1+k,1+k]);
_32a.push([1+k,-1-k]);
_32a.push([-1-k,0]);
_32a.push([-1-k,1+k]);
_32a.push([-1-k,-1-k]);
_32a.push([0,-1-k]);
_32a.push([0,1+k]);
}
break;
case ChessPiece.ROOK:
for(var k=0;k<8;k++){
_32a.push([1+k,0]);
_32a.push([-1-k,0]);
_32a.push([0,-1-k]);
_32a.push([0,1+k]);
}
break;
case ChessPiece.PAWN:
if(_322==ChessPiece.BLACK){
_32a=[[0,-1],[1,-1],[-1,-1]];
if(j==6){
_32a.push([0,-2]);
}
}else{
_32a=[[0,1],[1,1],[-1,1]];
if(j==1){
_32a.push([0,2]);
}
}
break;
}
for(var k=0;k<_32a.length;k++){
if(this.canMove(bp,bp.column+_32a[k][0],bp.row+_32a[k][1],_323,true)){
_326.push(new Move(bp.column,bp.row,bp.column+_32a[k][0],bp.row+_32a[k][1]));
if(_324){
return _326;
}
}
}
}
}
return _326;
};
Board.prototype.isKingSafe=function(_32c,_32d){
var _32e=null;
for(var i=0;i<8;i++){
for(var j=0;j<8;j++){
var bp=this.boardPieces[i][j];
if(bp!=null&&bp.piece==ChessPiece.KING&&bp.colour==_32c){
_32e=bp;
break;
}
}
}
for(var i=0;i<8;i++){
for(var j=0;j<8;j++){
var bp=this.boardPieces[i][j];
if(bp!=null&&bp.colour!=_32c){
if(this.canMove(bp,_32e.column,_32e.row,_32d,false)){
return false;
}
}
}
}
return true;
};
Board.prototype.freeBoardPieces=function(_332){
if(this.boardPieces){
for(var i=0;i<8;i++){
for(var j=0;j<8;j++){
if(this.boardPieces[i][j]!=null){
this.boardPieces[i][j].free();
this.boardPieces[i][j]=null;
}
}
if(_332){
this.boardPieces[i]=null;
}
}
}
if(_332){
this.boardPieces=null;
}
};
Board.prototype.freeBoard=function(){
this.freeBoardPieces(true);
this.freeMoveArray();
};
Board.prototype.freeMoveArray=function(){
if(this.moveArray){
for(var i=0;i<this.moveArray.length;i++){
var m=this.moveArray[i];
if(m){
m.freeMove();
this.moveArray[i]=null;
}
}
}
};
Board.prototype.cloneBoard=function(){
var _337=new Board();
_337.boardName=this.boardName;
_337.cloned=true;
_337.boardPieces=this.copyBoardPieces(true);
_337.moveArray=this.copyMoveArray(false);
_337.canCastleQueenSide=this.copyCastleQueenSide();
_337.canCastleKingSide=this.copyCastleKingSide();
_337.toMove=this.toMove;
_337.restrictedColourMovement=-1;
_337.opponentColour=this.opponentColour;
_337.isFlipped=this.isFlipped;
_337.isUserFlipped=this.isUserFlipped;
_337.ignoreFlipping=this.ignoreFlipping;
_337.reverseFlip=this.reverseFlip;
_337.moveAnimationLength=this.moveAnimationLength;
_337.moveNumber=this.moveNumber;
_337.halfMoveNumber=this.halfMoveNumber;
_337.startFen=this.startFen;
_337.boardImagePath=this.boardImagePath;
if(this.prev_move){
_337.prev_move=this.prev_move.clone();
}else{
_337.prev_move=null;
}
return _337;
};
Board.prototype.copyCastleQueenSide=function(){
return [this.canCastleQueenSide[0],this.canCastleQueenSide[1]];
};
Board.prototype.copyCastleKingSide=function(){
return [this.canCastleKingSide[0],this.canCastleKingSide[1]];
};
Board.prototype.copyMoveArray=function(_338){
var _339=new Array();
if(!_338){
if(this.moveArray.length>0){
_339=this.moveArray.slice(0);
}
return _339;
}else{
for(var i=0;i<this.moveArray.length;i++){
var m=_339[i];
if(m){
var newM=m.clone(true);
_339[i]=newM;
}
}
return _339;
}
};
Board.prototype.copyBoardPieces=function(_33d){
var _33e=Board.createBoardArray();
for(var i=0;i<8;i++){
for(var j=0;j<8;j++){
if(this.boardPieces[i][j]!=null){
if(_33d){
_33e[i][j]=this.boardPieces[i][j].makeLightWeight();
}else{
_33e[i][j]=this.boardPieces[i][j].copyPiece();
}
}else{
_33e[i][j]=null;
}
}
}
return _33e;
};
Board.prototype.createPiece=function(_341,_342,_343){
if(_343){
return new LightweightChessPiece(null,_341,_342,this);
}else{
return new ChessPiece(this.getPieceDiv(),_341,_342,this);
}
};
Board.prototype.restoreCastling=function(_344){
this.canCastleKingSide=_344.kingSide;
this.canCastleQueenSide=_344.queenSide;
};
Board.prototype.saveCastling=function(){
var _345=[this.canCastleQueenSide[0],this.canCastleQueenSide[1]];
var _346=[this.canCastleKingSide[0],this.canCastleKingSide[1]];
return {queenSide:_345,kingSide:_346};
};
var firstLightProf=true;
var firstHeavyProf=true;
Board.prototype.setupFromFenLightweight=function(fen,_348,flip,_34a,_34b){
var _34c=false&&firstLightProf;
if(_34c){
console.profile("setupFromFenLight");
}
this.setupFromFenGeneric(fen,_348,flip,true,_34a,_34b);
if(_34c){
console.profileEnd();
}
};
Board.prototype.setupFromFenHeavyWeight=function(fen,_34e,flip,_350,_351){
var _352=false&&firstHeavyProf;
if(_352){
console.profile("setupFromFenHeavy");
}
if(this.lastFromSquare){
YAHOO.util.Dom.removeClass(this.lastFromSquare,"ct-from-square");
}
if(this.lastToSquare){
YAHOO.util.Dom.removeClass(this.lastToSquare,"ct-to-square");
}
this.setupFromFenGeneric(fen,_34e,flip,false,_350,_351);
if(_352){
console.profileEnd();
}
};
Board.prototype.setupFromFen=function(fen,_354,flip,_356,_357,_358){
this.positionsSeen=[];
if(_356){
this.setupFromFenLightweight(fen,_354,flip,_357,_358);
}else{
this.setupFromFenHeavyWeight(fen,_354,flip,_357,_358);
}
};
Board.prototype.setupFromFenGeneric=function(fen,_35a,flip,_35c,_35d,_35e){
if(ctime){
console.time("setupFromFen"+_35c);
}
if(this.oldSelectedSquare){
YAHOO.util.Dom.removeClass(this.oldSelectedSquare,"ct-source-square");
}
this.oldSelectedSquare=null;
this.oldSelectedPiece=null;
this.settingUpPosition=true;
var _35f=fen.split(" ");
var _360=_35f[0].split("/");
this.halfMoveNumber=parseInt(_35f[4]);
this.moveNumber=parseInt(_35f[5])*2;
var _361=0;
var row=8;
this.uptoId=0;
this.board_xy=null;
var _363=_35f[2];
var _364=null;
this.canCastleQueenSide=[false,false];
this.canCastleKingSide=[false,false];
if(_363!="-"){
if(_363.indexOf("K")>=0){
this.canCastleKingSide[ChessPiece.WHITE]=true;
}
if(_363.indexOf("Q")>=0){
this.canCastleQueenSide[ChessPiece.WHITE]=true;
}
if(_363.indexOf("k")>=0){
this.canCastleKingSide[ChessPiece.BLACK]=true;
}
if(_363.indexOf("q")>=0){
this.canCastleQueenSide[ChessPiece.BLACK]=true;
}
}
if(_35e){
this.startMoveNum=this.moveNumber;
}
if(_35f[1]=="w"){
if(_35e){
this.startMoveNum--;
}
this.toMove=ChessPiece.WHITE;
this.opponentColour=ChessPiece.WHITE;
this.isFlipped=false;
this.moveNumber--;
}else{
this.toMove=ChessPiece.BLACK;
this.opponentColour=ChessPiece.BLACK;
this.isFlipped=true;
}
if(_35d){
var _365=_35f[3];
if(_365!="-"&&_365.length==2){
var _366=_365[0];
var _367=parseInt(_365[1]);
if(_367==3){
_364=this.createMoveFromString(_366+"2"+_366+"4");
}else{
_364=this.createMoveFromString(_366+"7"+_366+"5");
}
_364.prevMoveEnpassant=true;
this.prev_move=_364;
}
}
if(_35a){
this.toMove=(ChessPiece.BLACK==this.toMove)?ChessPiece.WHITE:ChessPiece.BLACK;
this.isFlipped=!this.isFlipped;
}
if(flip){
this.isFlipped=true;
}
if(this.reverseFlip){
this.isFlipped=!this.isFlipped;
}
if(this.ignoreFlipping){
this.isFlipped=false;
}
if(this.isUserFlipped){
this.isFlipped=!this.isFlipped;
}
this.updateToPlay();
this.setupPieceDivs();
for(var i=0;i<8;i++){
for(var j=0;j<8;j++){
this.boardPieces[i][j]=null;
}
}
for(var i=0;i<8;i++){
var line=_360[i];
row--;
_361=0;
for(var j=0;j<line.length;j++){
var c=line.charAt(j);
var code=line.charCodeAt(j);
var num=code-"0".charCodeAt(0);
if(num>0&&num<9){
while(num--){
var _36e=this.boardPieces[_361][row];
this.boardPieces[_361][row]=null;
_361++;
}
}else{
var _36f=(c+"").toLowerCase().charAt(0);
var _370=ChessPiece.WHITE;
if(_36f==c){
_370=ChessPiece.BLACK;
}
var cp;
switch(_36f){
case "k":
cp=this.createPiece(_370,ChessPiece.KING,_35c);
break;
case "q":
cp=this.createPiece(_370,ChessPiece.QUEEN,_35c);
break;
case "r":
cp=this.createPiece(_370,ChessPiece.ROOK,_35c);
break;
case "b":
cp=this.createPiece(_370,ChessPiece.BISHOP,_35c);
break;
case "n":
cp=this.createPiece(_370,ChessPiece.KNIGHT,_35c);
break;
case "p":
cp=this.createPiece(_370,ChessPiece.PAWN,_35c);
break;
default:
alert("unknown piece letter:"+_36f+" for fen:"+fen);
}
if(isGecko||isOpera){
cp.setPosition(_361,row,false,null,this.moveAnimationLength);
cp.setVisible(true);
}
this.boardPieces[_361][row]=cp;
this.pieces[this.uptoPiece]=cp;
this.pieces[this.uptoPiece].column=_361;
this.pieces[this.uptoPiece].row=row;
this.uptoPiece++;
_361++;
}
}
}
if(!isGecko){
for(var i=0;i<this.uptoPiece;i++){
this.pieces[i].setPosition(this.pieces[i].column,this.pieces[i].row,false,null,0);
}
}
if(!_35c){
for(var i=0;i<this.uptoPiece;i++){
this.pieces[i].setVisible(true);
}
}
if(!_35c){
this.createBoardCoords();
}
this.settingUpPosition=false;
if(ctime){
console.timeEnd("setupFromFen"+_35c);
}
};
Board.prototype.resetMoveListScrollPosition=function(){
var _372=this.movesDisplay.getMovesDisplay();
if(_372){
var _373=new YAHOO.util.Scroll(_372,{scroll:{to:[0,0]}},0);
_373.animate();
}
};
Board.prototype.changePieceSet=function(_374,_375){
if(!this.showedIE6Warning){
var str=_js("Depending on your browser you may need to reload the<br/> page for piece size changes to properly take effect.");
alert(str.replace("<br/>","\n"));
}
this.showedIE6Warning=true;
if(check_bad_msie()){
if(!this.showedIE6Warning){
var str=_js("Internet Explorer version 6 does not support dynamic piece size changes.<br/> Please reload page to view new settings.");
alert(str.replace("<br/>","\n"));
}
this.showedIE6Warning=true;
return;
}
var _377=this.pieceSize;
this.pieceSet=_374;
this.pieceSize=_375;
var _378=YAHOO.util.Dom.get(this.boardName+"-boardBorder");
var _379=0;
if(this.showCoordinates){
_379=15;
}
_378.className="";
YAHOO.util.Dom.addClass(_378,"ct-board-border"+this.squareColorClass);
YAHOO.util.Dom.setStyle(_378,"width",(this.pieceSize*8+_379)+"px");
YAHOO.util.Dom.setStyle(_378,"height",(this.pieceSize*8+_379)+"px");
var _37a=YAHOO.util.Dom.get("ctb-"+this.boardName);
YAHOO.util.Dom.setStyle(_37a,"width",(this.pieceSize*8)+"px");
YAHOO.util.Dom.setStyle(_37a,"height",(this.pieceSize*8)+"px");
var _37b="ct-white-square"+this.squareColorClass;
for(var i=7;i>=0;i--){
for(var j=0;j<8;j++){
var _37e=this.getBoardDivFromId(this.boardName+"-s"+j+""+i);
_37e.className="";
YAHOO.util.Dom.addClass(_37e,_37b);
YAHOO.util.Dom.setStyle(_37e,"width",this.pieceSize+"px");
YAHOO.util.Dom.setStyle(_37e,"height",this.pieceSize+"px");
var _37f=(((j+1)*(i+1))%19/19*100);
var _380=((65-((j+1)*(i+1)))%19/19*100);
YAHOO.util.Dom.setStyle(_37e,"background-position",_37f+"% "+_380+"%");
_37b=(_37b=="ct-black-square"+this.squareColorClass)?"ct-white-square"+this.squareColorClass:"ct-black-square"+this.squareColorClass;
}
_37b=(_37b=="ct-black-square"+this.squareColorClass)?"ct-white-square"+this.squareColorClass:"ct-black-square"+this.squareColorClass;
}
for(var i=0;i<8;i++){
for(var j=0;j<8;j++){
var cp=this.boardPieces[i][j];
if(cp){
cp.icon=get_image_str(ChessPiece.pieceIconNames[cp.colour][cp.piece],cp.board.boardImagePath,cp.board.pieceSet,cp.board.pieceSize,cp.board.addVersion);
if(YAHOO.util.Event.isIE||isOpera){
var _382=cp.div;
_382.innerHTML="<img src=\""+cp.icon+"\"/>";
var img=_382.firstChild;
if(!isOpera){
fix_ie_png(img);
}
}else{
YAHOO.util.Dom.setStyle([cp.div],"backgroundImage","url("+cp.icon+")");
YAHOO.util.Dom.setStyle([cp.div],"background-repeat","no-repeat");
}
YAHOO.util.Dom.setStyle([cp.div],"height",this.pieceSize+"px");
YAHOO.util.Dom.setStyle([cp.div],"width",this.pieceSize+"px");
YAHOO.util.Dom.setStyle([cp.div],"left","");
YAHOO.util.Dom.setStyle([cp.div],"top","");
var xy=cp.getNewXYPosition(cp.column,cp.row);
YAHOO.util.Dom.setXY(cp.div,xy,false);
}
}
}
if(this.moveArray){
var move=this.moveArray[0];
while(move!=null){
if(move.taken){
var cp=move.taken;
if(cp.getNewXYPosition){
cp.icon=get_image_str(ChessPiece.pieceIconNames[cp.colour][cp.piece],cp.board.boardImagePath,cp.board.pieceSet,cp.board.pieceSize,cp.board.addVersion);
if(YAHOO.util.Event.isIE||isOpera){
var _382=cp.div;
_382.innerHTML="<img src=\""+cp.icon+"\"/>";
YAHOO.util.Dom.setStyle([cp.div],"position","relative");
var img=_382.firstChild;
if(!isOpera){
fix_ie_png(img);
}
}else{
YAHOO.util.Dom.setStyle([cp.div],"backgroundImage","url("+cp.icon+")");
YAHOO.util.Dom.setStyle([cp.div],"background-repeat","no-repeat");
}
YAHOO.util.Dom.setStyle([cp.div],"height",this.pieceSize+"px");
YAHOO.util.Dom.setStyle([cp.div],"width",this.pieceSize+"px");
YAHOO.util.Dom.setStyle([cp.div],"left","");
YAHOO.util.Dom.setStyle([cp.div],"top","");
var xy=cp.getNewXYPosition(cp.column,cp.row);
YAHOO.util.Dom.setXY(cp.div,xy,false);
}
}
move=move.next;
}
}
if(this.problem){
var body=YAHOO.util.Dom.get("body");
if(body){
YAHOO.util.Dom.setStyle(body,"min-width",((this.pieceSize*8+_379)+300+200+120)+"px");
}
}
this.createBoardCoords();
};
Board.prototype.forwardMove=function(e){
if(this.disableNavigation){
return;
}
if(this.blockFowardBack||this.deferredBlockForwardBack){
if(clog){
console.log("returning early from forward due to block forward on");
}
return;
}
var _388=false;
if(this.tactics&&this.tactics.problemActive){
if(clog){
console.log("not forwarding, tactic is active");
}
return;
}
this.blockForwardBack=true;
if(this.currentMove&&!this.currentMove.atEnd){
move=this.currentMove;
if(move){
if(clog){
console.log("forward move:"+move.output());
}
}else{
if(clog){
console.log("forward move with currentmove null");
}
}
if(move.endNode){
if(clog){
console.log("calling processendgame from forward move");
}
if(!_388){
this.problem.processEndgame("",true);
}
this.toggleToMove();
this.updateToPlay();
}else{
if(clog){
console.log("forwarding move:"+move.output());
}
var _389=null;
piece=this.boardPieces[move.fromColumn][move.fromRow];
if(move.promotion){
_389=move.promotion;
piece.prePromotionColumn=null;
piece.prePromotionRow=null;
}
this.updatePiece(piece,move.toColumn,move.toRow,true,true,false,_389,true);
this.toggleToMove();
this.updateToPlay();
var _38a=this.currentMove;
if(clog){
if(_38a){
console.log("after forward curmove:"+_38a.output());
}else{
console.log("after forward cur move null");
}
}
for(var i=0;i<this.registeredForwardMovePostUpdateListeners.length;i++){
var _38c=this.registeredForwardMovePostUpdateListeners[i].forwardMovePostUpdateCallback(move);
}
}
}else{
if(clog){
console.log("already at end");
}
for(var i=0;i<this.registeredForwardAtEndListeners.length;i++){
var _38c=this.registeredForwardAtEndListeners[i].forwardAtEndCallback();
}
}
this.blockForwardBack=false;
};
Board.prototype.setupEventHandlers=function(){
this.timesLostFocus=0;
YAHOO.util.Event.addListener(document,"blur",this.lostFocus,this,true);
if(!this.avoidMouseoverActive){
YAHOO.util.Event.addListener(this.boardName+"-container","mouseover",function(e){
activeBoard=this;
},this,true);
}
if(true||this.clickAndClick){
YAHOO.util.Event.addListener(this.boardName+"-container","click",this.selectDestSquare,this,true);
}
var _38e="keydown";
if(isGecko){
_38e="keypress";
}
YAHOO.util.Event.addListener(document,_38e,function(e){
var _390=(e.target)?e.target:e.srcElement;
if(_390.form){
return true;
}
if(activeBoard!=this){
return true;
}
switch(YAHOO.util.Event.getCharCode(e)){
case 37:
this.backMove();
break;
case 39:
this.forwardMove();
break;
default:
}
return true;
},this,true);
YAHOO.util.Event.addListener(this.boardName+"-forward","click",this.forwardMove,this,true);
YAHOO.util.Event.addListener(this.boardName+"-back","click",this.backMove,this,true);
YAHOO.util.Event.addListener(this.boardName+"-start","click",this.gotoStart,this,true);
YAHOO.util.Event.addListener(this.boardName+"-end","click",this.gotoEnd,this,true);
YAHOO.util.Event.addListener(this.boardName+"-play","click",this.playMoves,this,true);
YAHOO.util.Event.addListener(this.boardName+"-stop","click",this.stopPlayingMoves,this,true);
if(this.r){
YAHOO.util.Event.addListener(this.boardName+"-analyse","click",this.analysePosition,this,true);
YAHOO.util.Event.addListener(this.boardName+"-showfen","click",this.showBoardFen,this,true);
}
if(this.canPasteFen){
YAHOO.util.Event.addListener(this.boardName+"-pastefen","click",this.pasteFen,this,true);
}
if(this.g2){
YAHOO.util.Event.addListener(this.boardName+"-playcomp","click",this.playComp,this,true);
}
};
Board.prototype.addFlipListener=function(_391){
this.registeredFlipListeners.push(_391);
};
Board.prototype.flipBoard=function(){
this.isUserFlipped=!this.isUserFlipped;
this.isFlipped=!this.isFlipped;
this.redrawBoard();
this.updateToPlay();
for(var i=0;i<this.registeredFlipListeners.length;i++){
this.registeredFlipListeners[i].boardFlipped(this);
}
};
Board.prototype.lostFocus=function(){
this.timesLostFocus++;
};
Board.prototype.redrawBoard=function(){
for(var i=0;i<8;i++){
for(var j=0;j<8;j++){
var cp=this.boardPieces[i][j];
if(cp){
var xy=cp.getNewXYPosition(cp.column,cp.row);
YAHOO.util.Dom.setXY(cp.div,xy,false);
}
}
}
if(this.moveArray){
var move=this.moveArray[0];
while(move!=null){
if(move.taken){
var cp=move.taken;
if(cp.getNewXYPosition){
var xy=cp.getNewXYPosition(cp.column,cp.row);
YAHOO.util.Dom.setXY(cp.div,xy,false);
}
}
move=move.next;
}
}
this.createBoardCoords();
if(this.oldSelectedSquare){
YAHOO.util.Dom.removeClass(this.oldSelectedSquare,"ct-source-square");
}
this.oldSelectedSquare=null;
this.oldSelectedPiece=null;
if(this.highlightFromTo){
if(!this.isFlipped){
var _398=YAHOO.util.Dom.get(this.boardName+"-s"+this.lastFromColumn+""+this.lastFromRow);
var _399=YAHOO.util.Dom.get(this.boardName+"-s"+this.lastToColumn+""+this.lastToRow);
}else{
var _398=YAHOO.util.Dom.get(this.boardName+"-s"+(7-this.lastFromColumn)+""+(7-this.lastFromRow));
var _399=YAHOO.util.Dom.get(this.boardName+"-s"+(7-this.lastToColumn)+""+(7-this.lastToRow));
}
this.updateFromTo(_398,_399,this.lastFromRow,this.lastFromColumn,this.lastToRow,this.lastToColumn);
}
};
Board.fenPositionOnly=function(fen){
var _39b=fen.split(" ");
return _39b[0]+" "+_39b[1];
};
Board.fenStripMoveClock=function(fen){
var _39d=fen.split(" ");
return _39d[0]+" "+_39d[1]+" "+_39d[2]+" "+_39d[3];
};
Board.fenSamePosition=function(fen1,fen2,_3a0){
if(!fen1||!fen2){
return false;
}
var f1=null;
var f2=null;
if(_3a0){
f1=Board.fenPositionOnly(fen1);
f2=Board.fenPositionOnly(fen2);
}else{
f1=Board.fenStripMoveClock(fen1);
f2=Board.fenStripMoveClock(fen2);
}
return (f1==f2);
};
Board.prototype.findFen=function(mv,brd,fen,_3a6){
var res=this.findFen2(mv,brd,fen,true);
if(res.move){
return res.move;
}else{
if(_3a6){
if(res.clockStrip){
return res.clockStrip;
}else{
if(res.fullStrip){
return res.fullStrip;
}
}
}
}
return null;
};
Board.prototype.findFen2=function(mv,brd,fen,_3ab){
var _3ac=brd.cloneBoard();
var res=Object();
var _3ae=null;
var _3af=null;
res.move=null;
if(_3ab){
_3ac.gotoMoveIndex(-1,true,true,true,true);
}
var _3b0=null;
while(mv){
var _3b1=_3ac.boardToFen();
if(_3b1==fen){
res.move=_3b0;
res.clockStrip=null;
res.fullStrip=null;
return res;
}else{
if(Board.fenSamePosition(fen,_3b1)){
_3ae=_3b0;
}else{
if(Board.fenSamePosition(fen,_3b1,true)){
_3af=_3b0;
}
}
}
if(mv.atEnd){
break;
}
if(mv.vars&&mv.vars.length>0){
for(var i=0;i<mv.vars.length;i++){
var _3b3=findFen(mv.vars[i],_3ac,fen,false);
if(_3b3.move){
return _3b3;
}else{
if(_3b3.clockStrip){
_3ae=_3b3.clockStrip;
}else{
if(_3b3.fullStrip){
_3af=_3b3.fullStrip;
}
}
}
}
}
if(clog){
console.log("about to make mv:"+mv.output());
}
_3ac.makeMove(mv,_3ac.boardPieces[mv.fromColumn][mv.fromRow],false,this.moveAnimationLength,false,false);
if(clog){
console.log("finished making mv");
}
_3b0=mv;
mv=mv.next;
if(clog){
console.log("toMove:"+_3ac.toMove);
}
_3ac.setCurrentMove(mv);
_3ac.toggleToMove();
}
if(_3ae){
res.clockStrip=_3ae;
}
if(_3af){
res.fullStrip=_3af;
}
return res;
};
Board.prototype.gotoFen=function(fen,_3b5){
if(clog){
console.log("about to find fen for:"+fen);
}
var _3b6=this.findFen(this.moveArray[0],this,fen,_3b5);
if(_3b6){
if(clog){
console.log("found move:"+_3b6.output()+" for fen:"+fen);
}
this.gotoMoveIndex(_3b6.index);
}else{
if(clog){
console.log("didn't find move for fen:"+fen);
}
}
};
Board.prototype.getMaxMoveIndex=function(){
return this.moveArray.length-1;
};
Board.prototype.gotoMoveIndex=function(_3b7,_3b8,_3b9,_3ba,_3bb){
if(clog){
console.log("going to move index:"+_3b7);
}
var _3bc=!_3b9;
if(!this.moveArray||this.moveArray.length<=_3b7||(_3b7==-1&&this.moveArray.length==0)){
return;
}
var _3bd=this.boardName+"-piecestaken";
var _3be=YAHOO.util.Dom.get(_3bd);
if(_3be){
_3be.innerHTML="";
}
if(_3b7==-1){
var flip=false;
if(this.prev_move&&!this.prev_move.prevMoveEnpassant){
flip=true;
}
this.setupFromFen(this.startFen,flip,false,_3bb);
if(this.prev_move&&!this.prev_move.prevMoveEnpassant){
this.makeMove(this.prev_move,this.boardPieces[this.prev_move.fromColumn][this.prev_move.fromRow],!_3b9,this.moveAnimationLength,true,true);
this.updateToPlay();
}
if(this.moveArray&&this.moveArray.length>0){
this.setCurrentMove(this.moveArray[0],_3b8);
}else{
this.setCurrentMove(this.firstMove,_3b8);
}
if(!_3b8){
this.setForwardBack();
}
if(!_3ba){
for(var i=0;i<this.registeredGotoMoveIndexListeners.length;i++){
var _3c1=this.registeredGotoMoveIndexListeners[i].gotoMoveIndexCallback(_3b7);
}
}
return;
}
var _3c2=new Array();
var move=this.moveArray[_3b7];
if(clog&&move){
console.log("gotomoveindex move:"+move.output());
if(move.next){
console.log("gotomoveindex move.next:"+move.next.output());
}
if(move.prev){
console.log("gotomoveindex move.prev:"+move.prev.output());
}
}
var _3c4=0;
if(move.next!=null){
this.setCurrentMove(move.next,_3b8);
}else{
if(clog){
console.log("move next null with move:"+move.output());
}
}
while(move!=null&&!move.dummy){
_3c2[_3c4++]=move;
move=move.prev;
}
var flip=false;
if(this.prev_move&&!this.prev_move.prevMoveEnpassant){
flip=true;
}
this.setupFromFen(this.startFen,flip,false,true);
if(this.prev_move&&!this.prev_move.prevMoveEnpassant){
if(clog){
console.log("gotomoveindex prev_move:"+this.prev_move.output());
}
this.makeMove(this.prev_move,this.boardPieces[this.prev_move.fromColumn][this.prev_move.fromRow],false,this.moveAnimationLength,true,true);
this.updateToPlay();
}
for(var i=_3c4-1;i>=1;i--){
var move=_3c2[i];
this.makeMove(move,this.boardPieces[move.fromColumn][move.fromRow],false,this.moveAnimationLength,true,false);
this.toggleToMove();
}
if(!_3b8){
this.convertPiecesFromLightWeight(_3b7);
}
var move=_3c2[0];
this.makeMove(move,this.boardPieces[move.fromColumn][move.fromRow],_3bc,this.moveAnimationLength,true,true);
this.toggleToMove();
this.updateToPlay();
if(!_3b8){
this.setForwardBack();
}
if(!_3ba){
for(var i=0;i<this.registeredGotoMoveIndexListeners.length;i++){
var _3c1=this.registeredGotoMoveIndexListeners[i].gotoMoveIndexCallback(_3b7);
}
}
};
Board.prototype.gotoStart=function(e){
if(this.disableNavigation){
return;
}
if(this.lastFromSquare){
YAHOO.util.Dom.removeClass(this.lastFromSquare,"ct-from-square");
}
if(this.lastToSquare){
YAHOO.util.Dom.removeClass(this.lastToSquare,"ct-to-square");
}
this.gotoMoveIndex(-1);
if(this.problem){
if(this.currentMove&&this.currentMove.bestMoves){
this.problem.showBestMoves(this.currentMove,this.currentMove.bestMoves,this.currentMove.correctMove,this.currentMove.wrongMove);
}else{
this.problem.clearBestMoves();
}
}
};
Board.prototype.gotoEnd=function(e){
if(this.disableNavigation){
return;
}
if(clog){
console.log("goto end called");
}
if(this.tactics&&this.tactics.problemActive){
this.tactics.autoForward=false;
this.tactics.markProblem(false,false,"NULL","NULL");
}
if(clog){
console.log("jumping to start");
}
this.gotoMoveIndex(-1,true,true,true);
var _3c7=0;
while(this.currentMove&&this.currentMove.next!=null){
var move=this.currentMove;
if(clog){
console.log("going to end move:"+move.output());
}
this.makeMove(move,this.boardPieces[move.fromColumn][move.fromRow],false,this.moveAnimationLength,true,true);
_3c7=move.index;
this.toggleToMove();
this.setCurrentMove(move.next);
}
for(var i=0;i<this.registeredGotoMoveIndexListeners.length;i++){
var _3ca=this.registeredGotoMoveIndexListeners[i].gotoMoveIndexCallback(_3c7);
}
};
Board.prototype.gotoPly=function(_3cb,_3cc){
if(clog){
console.log("goto ply called");
}
this.gotoMoveIndex(-1,true,true,true);
var cnt=1;
var _3ce=0;
while(cnt<=_3cb&&this.currentMove&&this.currentMove.next!=null){
var move=this.currentMove;
if(clog){
console.log("going to end move:"+move.output());
}
this.makeMove(move,this.boardPieces[move.fromColumn][move.fromRow],false,this.moveAnimationLength,true,true);
_3ce=move.index;
this.toggleToMove();
this.setCurrentMove(move.next);
cnt++;
}
if(_3cc){
for(var i=0;i<this.registeredGotoMoveIndexListeners.length;i++){
var _3d1=this.registeredGotoMoveIndexListeners[i].gotoMoveIndexCallback(_3ce);
}
}
};
Board.prototype.playMove=function(self){
if(!self.keepPlayingMoves||!self.currentMove||!self.currentMove.next){
var play=YAHOO.util.Dom.get(this.boardName+"-play");
play.src=this.boardImagePath+"/images/control_play_blue"+this.getVersString()+".gif";
self.keepPlayingMoves=false;
return;
}
self.forwardMove();
setTimeout(function(){
self.playMove(self);
},self.pauseBetweenMoves);
};
Board.prototype.getVersString=function(){
var _3d4=".vers"+SITE_VERSION;
if(!this.addVersion){
_3d4="";
}
return _3d4;
};
Board.prototype.playMoves=function(e){
if(this.disableNavigation){
return;
}
this.keepPlayingMoves=true;
var play=YAHOO.util.Dom.get(this.boardName+"-play");
play.src=this.boardImagePath+"/images/disabled_control_play_blue"+this.getVersString()+".gif";
this.playMove(this);
};
Board.prototype.stopPlayingMoves=function(e){
this.keepPlayingMoves=false;
};
Board.prototype.pasteFen=function(e){
for(var i=0;i<this.registeredPasteFenClickedListeners.length;i++){
var _3da=this.registeredPasteFenClickedListeners[i].pasteFenClickedCallback();
}
};
Board.prototype.playComp=function(e){
window.open("/play-computer/"+this.boardToFen());
};
Board.prototype.showBoardFen=function(e){
var fen=this.boardToFen();
var _3de=new YAHOO.widget.SimpleDialog("fenDialog",{fixedcenter:false,visible:true,draggable:true,constraintoviewport:false,buttons:[{id:"linkbutton4",text:"Test"},{text:_js("Ok"),handler:function(){
_3de.hide();
},isDefault:true}]});
_3de.setHeader(_js("Position FEN"));
_3de.setBody("<textarea class=\"showPgn\" id=\"fenText\" rows=\"1\" readonly=\"true\" cols=\""+(fen.length+9)+"\">"+fen+"</textarea>");
_3de.render(document.body);
_3de.setFooter("<span id=\"copyToComment\"></span><span id=\"fenok\"></span>");
_3de.center();
var _3df=this;
if(this.problem&&this.problem.comments){
var _3e0=new YAHOO.widget.Button({type:"button",label:_js("Copy To Comment"),container:"fenok",onclick:{fn:function(){
_3df.copyFenToComment(fen,Board.COPY_COMMENT_PROBLEM);
_3de.hide();
}}});
}
if(this.gameComments){
var _3e1=new YAHOO.widget.Button({type:"button",label:_js("Copy To Game Comment"),container:"fenok",onclick:{fn:function(){
_3df.copyFenToComment(fen,Board.COPY_COMMENT_GAME);
_3de.hide();
}}});
}
if(this.playerComments){
var _3e2=new YAHOO.widget.Button({type:"button",label:_js("Copy To Player Comment"),container:"fenok",onclick:{fn:function(){
_3df.copyFenToComment(fen,Board.COPY_COMMENT_PLAYER);
_3de.hide();
}}});
}
if(this.openingComments){
var _3e3=new YAHOO.widget.Button({type:"button",label:_js("Copy To Opening Comment"),container:"fenok",onclick:{fn:function(){
_3df.copyFenToComment(fen,Board.COPY_COMMENT_OPENING);
_3de.hide();
}}});
}
var _3e4=new YAHOO.widget.Button({type:"button",label:_js("Ok"),container:"fenok",onclick:{fn:function(){
_3de.hide();
}}});
};
Board.prototype.copyFenToComment=function(fen,_3e6){
switch(_3e6){
case (Board.COPY_COMMENT_PROBLEM):
if(this.problem){
var flip=false;
var col=fen.split(" ")[1];
var col2=this.startFen.split(" ")[1];
if(col==col2){
flip=true;
}
this.problem.comments.copyFenToComment(fen,flip);
}
break;
case (Board.COPY_COMMENT_GAME):
this.gameComments.copyFenToComment(fen);
break;
case (Board.COPY_COMMENT_PLAYER):
this.playerComments.copyFenToComment(fen);
break;
case (Board.COPY_COMMENT_OPENING):
this.openingComments.copyFenToComment(fen);
break;
}
};
Board.COPY_COMMENT_PROBLEM=0;
Board.COPY_COMMENT_PLAYER=1;
Board.COPY_COMMENT_GAME=2;
Board.COPY_COMMENT_OPENING=3;
Board.prototype.copyAnalysisToComment=function(_3ea,fen,flip,_3ed){
switch(_3ed){
case (Board.COPY_COMMENT_PROBLEM):
if(this.problem){
this.problem.comments.copyAnalysisToComment(_3ea,fen,flip);
}
break;
case (Board.COPY_COMMENT_GAME):
this.gameComments.copyAnalysisToComment(_3ea,fen,flip);
break;
case (Board.COPY_COMMENT_PLAYER):
this.playerComments.copyAnalysisToComment(_3ea,fen,flip);
break;
case (Board.COPY_COMMENT_OPENING):
this.openingComments.copyAnalysisToComment(_3ea,fen,flip);
break;
}
};
Board.squareColours=new Array(8);
var pCol=ChessPiece.BLACK;
for(var i=0;i<8;i++){
Board.squareColours[i]=new Array(8);
for(var j=0;j<8;j++){
Board.squareColours[i][j]=pCol;
pCol=Board.invertToMove(pCol);
}
pCol=Board.invertToMove(pCol);
}
Board.getSquareColour=function(i,j){
return Board.squareColours[i][j];
};
Board.prototype.isInsufficientMaterial=function(_3f0){
var _3f1=0;
var _3f2=0;
var _3f3=0;
var _3f4=0;
var _3f5=0;
var _3f6=0;
var _3f7=0;
var _3f8=0;
var _3f9=0;
var _3fa=0;
for(var i=0;i<8;i++){
for(var j=0;j<8;j++){
var p=this.boardPieces[i][j];
if(p){
if(p.piece==ChessPiece.PAWN){
if(p.colour==ChessPiece.WHITE){
_3f1++;
}else{
_3f2++;
}
}else{
if(p.piece!=ChessPiece.KING){
if(p.colour==ChessPiece.WHITE){
_3f3++;
if(p.piece==ChessPiece.KNIGHT){
_3f5++;
}else{
if(p.piece==ChessPiece.BISHOP){
if(Board.getSquareColour(i,j)==ChessPiece.WHITE){
_3f7++;
}else{
_3f8++;
}
}
}
}else{
_3f4++;
if(p.piece==ChessPiece.KNIGHT){
_3f6++;
}else{
if(p.piece==ChessPiece.BISHOP){
if(Board.getSquareColour(i,j)==ChessPiece.WHITE){
_3f9++;
}else{
_3fa++;
}
}
}
}
}
}
}
}
}
function checkBothPieces(){
if(_3f1>0||_3f2>0){
return false;
}
if(_3f3==_3f4==0){
return true;
}else{
if(_3f3==_3f5&&_3f4==0){
return true;
}else{
if(_3f4==_3f6&&_3f3==0){
return true;
}else{
if(_3f3==_3f7&&_3f4==_3f9){
return true;
}else{
if(_3f3==_3f8&&_3f4==_3fa){
return true;
}else{
if(_3f4==_3f9&&_3f3==_3f7){
return true;
}else{
if(_3f3==_3fa&&_3f3==_3f8){
return true;
}
}
}
}
}
}
}
return false;
}
if(_3f0==-1){
return checkBothPieces();
}else{
if(_3f0==ChessPiece.WHITE){
if(checkBothPieces()){
return true;
}
if(_3f1==0&&_3f3==0){
return true;
}else{
if(_3f3==_3f7&&_3f4==_3f9){
return true;
}else{
if(_3f3==_3f8&&_3f4==_3fa){
return true;
}else{
if(_3f3==_3f5&&(_3f4==0&&_3f2==0)){
return true;
}
}
}
}
return false;
}else{
if(checkBothPieces()){
return true;
}
if(_3f2==0&&_3f4==0){
return true;
}else{
if(_3f4==_3f9&&_3f3==_3f7){
return true;
}else{
if(_3f4==_3fa&&_3f3==_3f8){
return true;
}else{
if(_3f4==_3f6&&(_3f3==0&&_3f1==0)){
return true;
}
}
}
}
return false;
}
}
};
Board.prototype.analysePosition=function(e){
window.parentBoard=this;
var _3ff=(this.pieceSize*8)+450+50;
var _400=(this.pieceSize*8)+250;
var _401=window.open("/windows/analyse.html",this.analysisWindowName,"width="+_3ff+",height="+_400+",resizable=1,scrollbars=1,location=0,copyhistory=0,status=0,toolbar=0,menubar=0");
_401.focus();
};
Board.prototype.backMove=function(e){
if(this.disableNavigation){
return;
}
if(this.blockFowardBack||this.deferredBlockForwardBack){
return;
}
var _403=this.currentMove;
if(this.tactics){
if(this.tactics.problemActive){
return;
}
}
this.blockForwardBack=true;
if(this.currentMove&&this.currentMove.prev!=null){
YAHOO.util.Dom.removeClass(this.lastFromSquare,"ct-from-square");
YAHOO.util.Dom.removeClass(this.lastToSquare,"ct-to-square");
this.lastFromRow=null;
if(this.oldSelectedSquare){
YAHOO.util.Dom.removeClass(this.oldSelectedSquare,"ct-source-square");
}
this.oldSelectedSquare=null;
this.oldSelectedPiece=null;
var col=this.toMove;
if(col==ChessPiece.WHITE){
col=ChessPiece.BLACK;
}else{
col=ChessPiece.WHITE;
}
var _405=this.boardToUniqueFen(col);
if(this.positionsSeen[_405]){
this.positionsSeen[_405]--;
}
this.toggleToMove();
this.updateToPlay();
move=this.currentMove.prev;
if(move){
if(clog){
console.log("backwards moving to prev move:"+move.output()+" from current move:"+this.currentMove.output());
}
}
this.setCurrentMove(move);
piece=this.boardPieces[move.toColumn][move.toRow];
if(!piece){
if(clog){
console.log("got empty piece in backMove");
}
}
takenPiece=move.taken;
this.board_xy=null;
piece.setPosition(move.fromColumn,move.fromRow,true,null,this.moveAnimationLength);
this.boardPieces[move.fromColumn][move.fromRow]=piece;
if(move.promotion){
piece.changePiece("p");
}
piece.setVisible(true);
this.canCastleQueenSide[0]=move.preCastleQueenSide[0];
this.canCastleQueenSide[1]=move.preCastleQueenSide[1];
this.canCastleKingSide[0]=move.preCastleKingSide[0];
this.canCastleKingSide[1]=move.preCastleKingSide[1];
this.halfMoveNumber=move.preHalfMoveNumber;
var _406=false;
if(piece.piece==ChessPiece.KING&&Math.abs(move.fromColumn-move.toColumn)>1){
_406=true;
}
this.moveNumber--;
if(this.moveNumber<=0){
this.moveNumber=1;
}
if(takenPiece&&!_406){
this.board_xy=null;
var _407=move.toColumn;
var _408=move.toRow;
if(piece.piece==ChessPiece.PAWN&&move.fromColumn!=move.toColumn&&takenPiece.enPassant){
_408=move.fromRow;
this.boardPieces[move.toColumn][move.toRow]=null;
}
takenPiece.setPosition(_407,_408,false,null,this.moveAnimationLength);
this.boardPieces[_407][_408]=takenPiece;
move.taken=null;
this.processTaken(takenPiece,false);
}else{
this.boardPieces[move.toColumn][move.toRow]=null;
}
if(_406){
var _409=move.toRow;
var _40a;
var _40b;
if(move.fromColumn>move.toColumn){
_40a=0;
_40b=3;
}else{
_40a=7;
_40b=5;
}
var _40c=this.boardPieces[_40b][_409];
_40c.setPosition(_40a,_409,true,null,this.moveAnimationLength);
this.boardPieces[_40a][_409]=_40c;
this.boardPieces[_40b][_409]=null;
}
if(move!=null&&move.prev!=null&&move.prev.next!=move){
move=move.prev.next;
if(clog){
if(move){
console.log("moving backwards out of variation moving to:"+move.output());
}else{
console.log("jumping out of variation to null move");
}
}
}
for(var i=0;i<this.registeredBackMovePreCurrentListeners.length;i++){
var _40e=this.registeredBackMovePreCurrentListeners[i].backMovePreCurrentCallback(move,_403);
}
this.setCurrentMove(move);
this.setForwardBack();
}
this.blockForwardBack=false;
};
Board.prototype.getMovesToCurrent=function(){
var mvs=[];
var res=[];
var mv=this.currentMove;
if(!mv||!mv.prev){
return res;
}
mv=mv.prev;
while(mv){
mvs.push(mv);
mv=mv.prev;
}
for(var i=mvs.length-1;i>=0;i--){
res.push(mvs[i].toMoveString());
}
return res;
};
Board.prototype.getAllMoves=function(){
var mv=null;
if(this.moveArray&&this.moveArray.length>0){
mv=this.moveArray[0];
}else{
mv=this.firstMove;
}
if(!mv){
return [];
}
var mvs=[];
var res=[];
while(mv&&!mv.atEnd){
res.push(mv.toMoveString());
mv=mv.next;
}
return res;
};
Board.prototype.countPly=function(){
var mv=null;
if(this.moveArray&&this.moveArray.length>0){
mv=this.moveArray[0];
}else{
mv=this.firstMove;
}
var _417=0;
while(mv&&!mv.atEnd){
_417++;
mv=mv.next;
}
return _417;
};
Board.prototype.processTaken=function(_418,_419){
var _41a=this.boardName+"-piecestaken";
var _41b=YAHOO.util.Dom.get(_41a);
if(_41b){
if(_419){
var _41c=get_image_str(ChessPiece.pieceIconNames[_418.colour][_418.piece],this.boardImagePath,this.pieceSet,this.pieceTakenSize,this.addVersion);
_41b.innerHTML=_41b.innerHTML+"<img src=\""+_41c+"\"/>";
}else{
var _41d=_41b.innerHTML.split("<");
_41b.innerHTML="";
for(var i=1;i<_41d.length-1;i++){
_41b.innerHTML=_41b.innerHTML+"<"+_41d[i];
}
}
}
};
Pool=function(){
this.pool=new Array();
this.count=-1;
this.numGot=0;
this.numPut=0;
};
Pool.prototype.getObject=function(){
var o=null;
if(this.count>=0){
this.numGot++;
o=this.pool[this.count--];
}
return o;
};
Pool.prototype.putObject=function(o){
if(o!=null){
this.numPut++;
this.pool[++this.count]=o;
}
};
var boardPool=new Pool();
function touchHandler(_421){
var _422=_421.changedTouches,_423=_422[0],type="";
switch(_421.type){
case "touchstart":
type="mousedown";
break;
case "touchmove":
type="mousemove";
break;
case "touchend":
type="mouseup";
break;
default:
return;
}
var _425=document.createEvent("MouseEvent");
_425.initMouseEvent(type,true,true,window,1,_423.screenX,_423.screenY,_423.clientX,_423.clientY,false,false,false,false,0,null);
_423.target.dispatchEvent(_425);
_421.preventDefault();
}
function initIphone(_426){
_426.addEventListener("touchstart",touchHandler,true);
_426.addEventListener("touchmove",touchHandler,true);
_426.addEventListener("touchend",touchHandler,true);
_426.addEventListener("touchcancel",touchHandler,true);
}
FenBoard=function(fen,_428){
if(typeof _428.pieceSize=="undefined"){
_428.pieceSize=24;
}
_428.fenBoard=true;
_428.dontOutputNavButtons=true;
_428.avoidMouseoverActive=true;
this.chessapp=new ChessApp(_428);
this.chessapp.init();
this.chessapp.board.disableUpdateToPlay=true;
this.chessapp.board.setupFromFen(fen,false,false,false);
this.board=this.chessapp.board;
this.board.startFen=fen;
};


