/* Copyright 2007-2009 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) 2008, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 2.5.2
*/
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;if(!I[A]){I[A]={versions:[],builds:[]};}var 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(var 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 C={ie:0,opera:0,gecko:0,webkit:0,mobile:null,air:0};var B=navigator.userAgent,A;if((/KHTML/).test(B)){C.webkit=1;}A=B.match(/AppleWebKit\/([^\s]*)/);if(A&&A[1]){C.webkit=parseFloat(A[1]);if(/ Mobile\//.test(B)){C.mobile="Apple";}else{A=B.match(/NokiaN[^\/]*/);if(A){C.mobile=A[0];}}A=B.match(/AdobeAIR\/([^\s]*)/);if(A){C.air=A[0];}}if(!C.webkit){A=B.match(/Opera[\s\/]([^\s]*)/);if(A&&A[1]){C.opera=parseFloat(A[1]);A=B.match(/Opera Mini[^;]*/);if(A){C.mobile=A[0];}}else{A=B.match(/MSIE\s([^;]*)/);if(A&&A[1]){C.ie=parseFloat(A[1]);}else{A=B.match(/Gecko\/([^\s]*)/);if(A){C.gecko=1;A=B.match(/rv:([^\s\)]*)/);if(A&&A[1]){C.gecko=parseFloat(A[1]);}}}}}return C;}();(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=C+1){if(A[C]==B){D=false;break;}}if(D){A.push(B);}}}})();YAHOO.lang=YAHOO.lang||{};(function(){var A=YAHOO.lang,C=["toString","valueOf"],B={isArray:function(D){if(D){return A.isNumber(D.length)&&A.isFunction(D.splice);}return false;},isBoolean:function(D){return typeof D==="boolean";},isFunction:function(D){return typeof D==="function";},isNull:function(D){return D===null;},isNumber:function(D){return typeof D==="number"&&isFinite(D);},isObject:function(D){return(D&&(typeof D==="object"||A.isFunction(D)))||false;},isString:function(D){return typeof D==="string";},isUndefined:function(D){return typeof D==="undefined";},_IEEnumFix:(YAHOO.env.ua.ie)?function(F,E){for(var D=0;D<C.length;D=D+1){var H=C[D],G=E[H];if(A.isFunction(G)&&G!=Object.prototype[H]){F[H]=G;}}}:function(){},extend:function(H,I,G){if(!I||!H){throw new Error("extend failed, please check that "+"all dependencies are included.");}var E=function(){};E.prototype=I.prototype;H.prototype=new E();H.prototype.constructor=H;H.superclass=I.prototype;if(I.prototype.constructor==Object.prototype.constructor){I.prototype.constructor=I;}if(G){for(var D in G){if(A.hasOwnProperty(G,D)){H.prototype[D]=G[D];}}A._IEEnumFix(H.prototype,G);}},augmentObject:function(H,G){if(!G||!H){throw new Error("Absorb failed, verify dependencies.");}var D=arguments,F,I,E=D[2];if(E&&E!==true){for(F=2;F<D.length;F=F+1){H[D[F]]=G[D[F]];}}else{for(I in G){if(E||!(I in H)){H[I]=G[I];}}A._IEEnumFix(H,G);}},augmentProto:function(G,F){if(!F||!G){throw new Error("Augment failed, verify dependencies.");}var D=[G.prototype,F.prototype];for(var E=2;E<arguments.length;E=E+1){D.push(arguments[E]);}A.augmentObject.apply(this,D);},dump:function(D,I){var F,H,K=[],L="{...}",E="f(){...}",J=", ",G=" => ";if(!A.isObject(D)){return D+"";}else{if(D instanceof Date||("nodeType" in D&&"tagName" in D)){return D;}else{if(A.isFunction(D)){return E;}}}I=(A.isNumber(I))?I:3;if(A.isArray(D)){K.push("[");for(F=0,H=D.length;F<H;F=F+1){if(A.isObject(D[F])){K.push((I>0)?A.dump(D[F],I-1):L);}else{K.push(D[F]);}K.push(J);}if(K.length>1){K.pop();}K.push("]");}else{K.push("{");for(F in D){if(A.hasOwnProperty(D,F)){K.push(F+G);if(A.isObject(D[F])){K.push((I>0)?A.dump(D[F],I-1):L);}else{K.push(D[F]);}K.push(J);}}if(K.length>1){K.pop();}K.push("}");}return K.join("");},substitute:function(S,E,L){var I,H,G,O,P,R,N=[],F,J="dump",M=" ",D="{",Q="}";for(;;){I=S.lastIndexOf(D);if(I<0){break;}H=S.indexOf(Q,I);if(I+1>=H){break;}F=S.substring(I+1,H);O=F;R=null;G=O.indexOf(M);if(G>-1){R=O.substring(G+1);O=O.substring(0,G);}P=E[O];if(L){P=L(O,P,R);}if(A.isObject(P)){if(A.isArray(P)){P=A.dump(P,parseInt(R,10));}else{R=R||"";var K=R.indexOf(J);if(K>-1){R=R.substring(4);}if(P.toString===Object.prototype.toString||K>-1){P=A.dump(P,parseInt(R,10));}else{P=P.toString();}}}else{if(!A.isString(P)&&!A.isNumber(P)){P="~-"+N.length+"-~";N[N.length]=F;}}S=S.substring(0,I)+P+S.substring(H+1);}for(I=N.length-1;I>=0;I=I-1){S=S.replace(new RegExp("~-"+I+"-~"),"{"+N[I]+"}","g");}return S;},trim:function(D){try{return D.replace(/^\s+|\s+$/g,"");}catch(E){return D;}},merge:function(){var G={},E=arguments;for(var F=0,D=E.length;F<D;F=F+1){A.augmentObject(G,E[F],true);}return G;},later:function(K,E,L,G,H){K=K||0;E=E||{};var F=L,J=G,I,D;if(A.isString(L)){F=E[L];}if(!F){throw new TypeError("method undefined");}if(!A.isArray(J)){J=[G];}I=function(){F.apply(E,J);};D=(H)?setInterval(I,K):setTimeout(I,K);return{interval:H,cancel:function(){if(this.interval){clearInterval(D);}else{clearTimeout(D);}}};},isValue:function(D){return(A.isObject(D)||A.isString(D)||A.isNumber(D)||A.isBoolean(D));}};A.hasOwnProperty=(Object.prototype.hasOwnProperty)?function(D,E){return D&&D.hasOwnProperty(E);}:function(D,E){return !A.isUndefined(D[E])&&D.constructor.prototype[E]!==D[E];};B.augmentObject(A,B,true);YAHOO.util.Lang=A;A.augment=A.augmentProto;YAHOO.augment=A.augmentProto;YAHOO.extend=A.extend;})();YAHOO.register("yahoo",YAHOO,{version:"2.5.2",build:"1076"});(function(){var B=YAHOO.util,K,I,J={},F={},M=window.document;YAHOO.env._id_counter=YAHOO.env._id_counter||0;var C=YAHOO.env.ua.opera,L=YAHOO.env.ua.webkit,A=YAHOO.env.ua.gecko,G=YAHOO.env.ua.ie;var E={HYPHEN:/(-[a-z])/i,ROOT_TAG:/^body|html$/i,OP_SCROLL:/^(?:inline|table-row)$/i};var N=function(P){if(!E.HYPHEN.test(P)){return P;}if(J[P]){return J[P];}var Q=P;while(E.HYPHEN.exec(Q)){Q=Q.replace(RegExp.$1,RegExp.$1.substr(1).toUpperCase());}J[P]=Q;return Q;};var O=function(Q){var P=F[Q];if(!P){P=new RegExp("(?:^|\\s+)"+Q+"(?:\\s+|$)");F[Q]=P;}return P;};if(M.defaultView&&M.defaultView.getComputedStyle){K=function(P,S){var R=null;if(S=="float"){S="cssFloat";}var Q=P.ownerDocument.defaultView.getComputedStyle(P,"");if(Q){R=Q[N(S)];}return P.style[S]||R;};}else{if(M.documentElement.currentStyle&&G){K=function(P,R){switch(N(R)){case"opacity":var T=100;try{T=P.filters["DXImageTransform.Microsoft.Alpha"].opacity;}catch(S){try{T=P.filters("alpha").opacity;}catch(S){}}return T/100;case"float":R="styleFloat";default:var Q=P.currentStyle?P.currentStyle[R]:null;return(P.style[R]||Q);}};}else{K=function(P,Q){return P.style[Q];};}}if(G){I=function(P,Q,R){switch(Q){case"opacity":if(YAHOO.lang.isString(P.style.filter)){P.style.filter="alpha(opacity="+R*100+")";if(!P.currentStyle||!P.currentStyle.hasLayout){P.style.zoom=1;}}break;case"float":Q="styleFloat";default:P.style[Q]=R;}};}else{I=function(P,Q,R){if(Q=="float"){Q="cssFloat";}P.style[Q]=R;};}var D=function(P,Q){return P&&P.nodeType==1&&(!Q||Q(P));};YAHOO.util.Dom={get:function(R){if(R&&(R.nodeType||R.item)){return R;}if(YAHOO.lang.isString(R)||!R){return M.getElementById(R);}if(R.length!==undefined){var S=[];for(var Q=0,P=R.length;Q<P;++Q){S[S.length]=B.Dom.get(R[Q]);}return S;}return R;},getStyle:function(P,R){R=N(R);var Q=function(S){return K(S,R);};return B.Dom.batch(P,Q,B.Dom,true);},setStyle:function(P,R,S){R=N(R);var Q=function(T){I(T,R,S);};B.Dom.batch(P,Q,B.Dom,true);},getXY:function(P){var Q=function(R){if((R.parentNode===null||R.offsetParent===null||this.getStyle(R,"display")=="none")&&R!=R.ownerDocument.body){return false;}return H(R);};return B.Dom.batch(P,Q,B.Dom,true);},getX:function(P){var Q=function(R){return B.Dom.getXY(R)[0];};return B.Dom.batch(P,Q,B.Dom,true);},getY:function(P){var Q=function(R){return B.Dom.getXY(R)[1];};return B.Dom.batch(P,Q,B.Dom,true);},setXY:function(P,S,R){var Q=function(V){var U=this.getStyle(V,"position");if(U=="static"){this.setStyle(V,"position","relative");U="relative";}var X=this.getXY(V);if(X===false){return false;}var W=[parseInt(this.getStyle(V,"left"),10),parseInt(this.getStyle(V,"top"),10)];if(isNaN(W[0])){W[0]=(U=="relative")?0:V.offsetLeft;}if(isNaN(W[1])){W[1]=(U=="relative")?0:V.offsetTop;}if(S[0]!==null){V.style.left=S[0]-X[0]+W[0]+"px";}if(S[1]!==null){V.style.top=S[1]-X[1]+W[1]+"px";}if(!R){var T=this.getXY(V);if((S[0]!==null&&T[0]!=S[0])||(S[1]!==null&&T[1]!=S[1])){this.setXY(V,S,true);}}};B.Dom.batch(P,Q,B.Dom,true);},setX:function(Q,P){B.Dom.setXY(Q,[P,null]);},setY:function(P,Q){B.Dom.setXY(P,[null,Q]);},getRegion:function(P){var Q=function(R){if((R.parentNode===null||R.offsetParent===null||this.getStyle(R,"display")=="none")&&R!=R.ownerDocument.body){return false;}var S=B.Region.getRegion(R);return S;};return B.Dom.batch(P,Q,B.Dom,true);},getClientWidth:function(){return B.Dom.getViewportWidth();},getClientHeight:function(){return B.Dom.getViewportHeight();},getElementsByClassName:function(T,X,U,V){X=X||"*";U=(U)?B.Dom.get(U):null||M;if(!U){return[];}var Q=[],P=U.getElementsByTagName(X),W=O(T);for(var R=0,S=P.length;R<S;++R){if(W.test(P[R].className)){Q[Q.length]=P[R];if(V){V.call(P[R],P[R]);}}}return Q;},hasClass:function(R,Q){var P=O(Q);var S=function(T){return P.test(T.className);};return B.Dom.batch(R,S,B.Dom,true);},addClass:function(Q,P){var R=function(S){if(this.hasClass(S,P)){return false;}S.className=YAHOO.lang.trim([S.className,P].join(" "));return true;};return B.Dom.batch(Q,R,B.Dom,true);},removeClass:function(R,Q){var P=O(Q);var S=function(T){if(!Q||!this.hasClass(T,Q)){return false;}var U=T.className;T.className=U.replace(P," ");if(this.hasClass(T,Q)){this.removeClass(T,Q);}T.className=YAHOO.lang.trim(T.className);return true;};return B.Dom.batch(R,S,B.Dom,true);},replaceClass:function(S,Q,P){if(!P||Q===P){return false;}var R=O(Q);var T=function(U){if(!this.hasClass(U,Q)){this.addClass(U,P);return true;}U.className=U.className.replace(R," "+P+" ");if(this.hasClass(U,Q)){this.replaceClass(U,Q,P);}U.className=YAHOO.lang.trim(U.className);return true;};return B.Dom.batch(S,T,B.Dom,true);},generateId:function(P,R){R=R||"yui-gen";var Q=function(S){if(S&&S.id){return S.id;}var T=R+YAHOO.env._id_counter++;if(S){S.id=T;}return T;};return B.Dom.batch(P,Q,B.Dom,true)||Q.apply(B.Dom,arguments);},isAncestor:function(P,Q){P=B.Dom.get(P);Q=B.Dom.get(Q);if(!P||!Q){return false;}if(P.contains&&Q.nodeType&&!L){return P.contains(Q);}else{if(P.compareDocumentPosition&&Q.nodeType){return !!(P.compareDocumentPosition(Q)&16);}else{if(Q.nodeType){return !!this.getAncestorBy(Q,function(R){return R==P;});}}}return false;},inDocument:function(P){return this.isAncestor(M.documentElement,P);},getElementsBy:function(W,Q,R,T){Q=Q||"*";R=(R)?B.Dom.get(R):null||M;if(!R){return[];}var S=[],V=R.getElementsByTagName(Q);for(var U=0,P=V.length;U<P;++U){if(W(V[U])){S[S.length]=V[U];if(T){T(V[U]);}}}return S;},batch:function(T,W,V,R){T=(T&&(T.tagName||T.item))?T:B.Dom.get(T);if(!T||!W){return false;}var S=(R)?V:window;if(T.tagName||T.length===undefined){return W.call(S,T,V);}var U=[];for(var Q=0,P=T.length;Q<P;++Q){U[U.length]=W.call(S,T[Q],V);}return U;},getDocumentHeight:function(){var Q=(M.compatMode!="CSS1Compat")?M.body.scrollHeight:M.documentElement.scrollHeight;var P=Math.max(Q,B.Dom.getViewportHeight());return P;},getDocumentWidth:function(){var Q=(M.compatMode!="CSS1Compat")?M.body.scrollWidth:M.documentElement.scrollWidth;var P=Math.max(Q,B.Dom.getViewportWidth());return P;},getViewportHeight:function(){var P=self.innerHeight;
var Q=M.compatMode;if((Q||G)&&!C){P=(Q=="CSS1Compat")?M.documentElement.clientHeight:M.body.clientHeight;}return P;},getViewportWidth:function(){var P=self.innerWidth;var Q=M.compatMode;if(Q||G){P=(Q=="CSS1Compat")?M.documentElement.clientWidth:M.body.clientWidth;}return P;},getAncestorBy:function(P,Q){while(P=P.parentNode){if(D(P,Q)){return P;}}return null;},getAncestorByClassName:function(Q,P){Q=B.Dom.get(Q);if(!Q){return null;}var R=function(S){return B.Dom.hasClass(S,P);};return B.Dom.getAncestorBy(Q,R);},getAncestorByTagName:function(Q,P){Q=B.Dom.get(Q);if(!Q){return null;}var R=function(S){return S.tagName&&S.tagName.toUpperCase()==P.toUpperCase();};return B.Dom.getAncestorBy(Q,R);},getPreviousSiblingBy:function(P,Q){while(P){P=P.previousSibling;if(D(P,Q)){return P;}}return null;},getPreviousSibling:function(P){P=B.Dom.get(P);if(!P){return null;}return B.Dom.getPreviousSiblingBy(P);},getNextSiblingBy:function(P,Q){while(P){P=P.nextSibling;if(D(P,Q)){return P;}}return null;},getNextSibling:function(P){P=B.Dom.get(P);if(!P){return null;}return B.Dom.getNextSiblingBy(P);},getFirstChildBy:function(P,R){var Q=(D(P.firstChild,R))?P.firstChild:null;return Q||B.Dom.getNextSiblingBy(P.firstChild,R);},getFirstChild:function(P,Q){P=B.Dom.get(P);if(!P){return null;}return B.Dom.getFirstChildBy(P);},getLastChildBy:function(P,R){if(!P){return null;}var Q=(D(P.lastChild,R))?P.lastChild:null;return Q||B.Dom.getPreviousSiblingBy(P.lastChild,R);},getLastChild:function(P){P=B.Dom.get(P);return B.Dom.getLastChildBy(P);},getChildrenBy:function(Q,S){var R=B.Dom.getFirstChildBy(Q,S);var P=R?[R]:[];B.Dom.getNextSiblingBy(R,function(T){if(!S||S(T)){P[P.length]=T;}return false;});return P;},getChildren:function(P){P=B.Dom.get(P);if(!P){}return B.Dom.getChildrenBy(P);},getDocumentScrollLeft:function(P){P=P||M;return Math.max(P.documentElement.scrollLeft,P.body.scrollLeft);},getDocumentScrollTop:function(P){P=P||M;return Math.max(P.documentElement.scrollTop,P.body.scrollTop);},insertBefore:function(Q,P){Q=B.Dom.get(Q);P=B.Dom.get(P);if(!Q||!P||!P.parentNode){return null;}return P.parentNode.insertBefore(Q,P);},insertAfter:function(Q,P){Q=B.Dom.get(Q);P=B.Dom.get(P);if(!Q||!P||!P.parentNode){return null;}if(P.nextSibling){return P.parentNode.insertBefore(Q,P.nextSibling);}else{return P.parentNode.appendChild(Q);}},getClientRegion:function(){var R=B.Dom.getDocumentScrollTop(),Q=B.Dom.getDocumentScrollLeft(),S=B.Dom.getViewportWidth()+Q,P=B.Dom.getViewportHeight()+R;return new B.Region(R,S,P,Q);}};var H=function(){if(M.documentElement.getBoundingClientRect){return function(Q){var R=Q.getBoundingClientRect();var P=Q.ownerDocument;return[R.left+B.Dom.getDocumentScrollLeft(P),R.top+B.Dom.getDocumentScrollTop(P)];};}else{return function(R){var S=[R.offsetLeft,R.offsetTop];var Q=R.offsetParent;var P=(L&&B.Dom.getStyle(R,"position")=="absolute"&&R.offsetParent==R.ownerDocument.body);if(Q!=R){while(Q){S[0]+=Q.offsetLeft;S[1]+=Q.offsetTop;if(!P&&L&&B.Dom.getStyle(Q,"position")=="absolute"){P=true;}Q=Q.offsetParent;}}if(P){S[0]-=R.ownerDocument.body.offsetLeft;S[1]-=R.ownerDocument.body.offsetTop;}Q=R.parentNode;while(Q.tagName&&!E.ROOT_TAG.test(Q.tagName)){if(Q.scrollTop||Q.scrollLeft){if(!E.OP_SCROLL.test(B.Dom.getStyle(Q,"display"))){if(!C||B.Dom.getStyle(Q,"overflow")!=="visible"){S[0]-=Q.scrollLeft;S[1]-=Q.scrollTop;}}}Q=Q.parentNode;}return S;};}}();})();YAHOO.util.Region=function(C,D,A,B){this.top=C;this[1]=C;this.right=D;this.bottom=A;this.left=B;this[0]=B;};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);var D=Math.min(this.right,E.right);var A=Math.min(this.bottom,E.bottom);var 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);var D=Math.max(this.right,E.right);var A=Math.max(this.bottom,E.bottom);var 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+"}");};YAHOO.util.Region.getRegion=function(D){var F=YAHOO.util.Dom.getXY(D);var C=F[1];var E=F[0]+D.offsetWidth;var A=F[1]+D.offsetHeight;var 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];}this.x=this.right=this.left=this[0]=A;this.y=this.top=this.bottom=this[1]=B;};YAHOO.util.Point.prototype=new YAHOO.util.Region();YAHOO.register("dom",YAHOO.util.Dom,{version:"2.5.2",build:"1076"});YAHOO.util.CustomEvent=function(D,B,C,A){this.type=D;this.scope=B||window;this.silent=C;this.signature=A||YAHOO.util.CustomEvent.LIST;this.subscribers=[];if(!this.silent){}var E="_YUICEOnSubscribe";if(D!==E){this.subscribeEvent=new YAHOO.util.CustomEvent(E,this,true);}this.lastError=null;};YAHOO.util.CustomEvent.LIST=0;YAHOO.util.CustomEvent.FLAT=1;YAHOO.util.CustomEvent.prototype={subscribe:function(B,C,A){if(!B){throw new Error("Invalid callback for subscriber to '"+this.type+"'");}if(this.subscribeEvent){this.subscribeEvent.fire(B,C,A);}this.subscribers.push(new YAHOO.util.Subscriber(B,C,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 K=[],E=this.subscribers.length;if(!E&&this.silent){return true;}var I=[].slice.call(arguments,0),G=true,D,J=false;if(!this.silent){}var C=this.subscribers.slice(),A=YAHOO.util.Event.throwErrors;for(D=0;D<E;++D){var M=C[D];if(!M){J=true;}else{if(!this.silent){}var L=M.getScope(this.scope);if(this.signature==YAHOO.util.CustomEvent.FLAT){var B=null;if(I.length>0){B=I[0];}try{G=M.fn.call(L,B,M.obj);}catch(F){this.lastError=F;if(A){throw F;}}}else{try{G=M.fn.call(L,this.type,I,M.obj);}catch(H){this.lastError=H;if(A){throw H;}}}if(false===G){if(!this.silent){}break;}}}return(G!==false);},unsubscribeAll:function(){for(var A=this.subscribers.length-1;A>-1;A--){this._delete(A);}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+"', "+"scope: "+this.scope;}};YAHOO.util.Subscriber=function(B,C,A){this.fn=B;this.obj=YAHOO.lang.isUndefined(C)?null:C;this.override=A;};YAHOO.util.Subscriber.prototype.getScope=function(A){if(this.override){if(this.override===true){return this.obj;}else{return this.override;}}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+", override: "+(this.override||"no")+" }";};if(!YAHOO.util.Event){YAHOO.util.Event=function(){var H=false;var I=[];var J=[];var G=[];var E=[];var C=0;var F=[];var B=[];var A=0;var D={63232:38,63233:40,63234:37,63235:39,63276:33,63277:34,25:9};return{POLL_RETRYS:2000,POLL_INTERVAL:20,EL:0,TYPE:1,FN:2,WFN:3,UNLOAD_OBJ:3,ADJ_SCOPE:4,OBJ:5,OVERRIDE:6,lastError:null,isSafari:YAHOO.env.ua.webkit,webkit:YAHOO.env.ua.webkit,isIE:YAHOO.env.ua.ie,_interval:null,_dri:null,DOMReady:false,throwErrors:false,startInterval:function(){if(!this._interval){var K=this;var L=function(){K._tryPreloadAttach();};this._interval=setInterval(L,this.POLL_INTERVAL);}},onAvailable:function(P,M,Q,O,N){var K=(YAHOO.lang.isString(P))?[P]:P;for(var L=0;L<K.length;L=L+1){F.push({id:K[L],fn:M,obj:Q,override:O,checkReady:N});}C=this.POLL_RETRYS;this.startInterval();},onContentReady:function(M,K,N,L){this.onAvailable(M,K,N,L,true);},onDOMReady:function(K,M,L){if(this.DOMReady){setTimeout(function(){var N=window;if(L){if(L===true){N=M;}else{N=L;}}K.call(N,"DOMReady",[],M);},0);}else{this.DOMReadyEvent.subscribe(K,M,L);}},addListener:function(M,K,V,Q,L){if(!V||!V.call){return false;}if(this._isValidCollection(M)){var W=true;for(var R=0,T=M.length;R<T;++R){W=this.on(M[R],K,V,Q,L)&&W;}return W;}else{if(YAHOO.lang.isString(M)){var P=this.getEl(M);if(P){M=P;}else{this.onAvailable(M,function(){YAHOO.util.Event.on(M,K,V,Q,L);});return true;}}}if(!M){return false;}if("unload"==K&&Q!==this){J[J.length]=[M,K,V,Q,L];return true;}var Y=M;if(L){if(L===true){Y=Q;}else{Y=L;}}var N=function(Z){return V.call(Y,YAHOO.util.Event.getEvent(Z,M),Q);};var X=[M,K,V,N,Y,Q,L];var S=I.length;I[S]=X;if(this.useLegacyEvent(M,K)){var O=this.getLegacyIndex(M,K);if(O==-1||M!=G[O][0]){O=G.length;B[M.id+K]=O;G[O]=[M,K,M["on"+K]];E[O]=[];M["on"+K]=function(Z){YAHOO.util.Event.fireLegacyEvent(YAHOO.util.Event.getEvent(Z),O);};}E[O].push(X);}else{try{this._simpleAdd(M,K,N,false);}catch(U){this.lastError=U;this.removeListener(M,K,V);return false;}}return true;},fireLegacyEvent:function(O,M){var Q=true,K,S,R,T,P;S=E[M].slice();for(var L=0,N=S.length;L<N;++L){R=S[L];if(R&&R[this.WFN]){T=R[this.ADJ_SCOPE];P=R[this.WFN].call(T,O);Q=(Q&&P);}}K=G[M];if(K&&K[2]){K[2](O);}return Q;},getLegacyIndex:function(L,M){var K=this.generateId(L)+M;if(typeof B[K]=="undefined"){return -1;}else{return B[K];}},useLegacyEvent:function(L,M){if(this.webkit&&("click"==M||"dblclick"==M)){var K=parseInt(this.webkit,10);if(!isNaN(K)&&K<418){return true;}}return false;},removeListener:function(L,K,T){var O,R,V;if(typeof L=="string"){L=this.getEl(L);}else{if(this._isValidCollection(L)){var U=true;for(O=L.length-1;O>-1;O--){U=(this.removeListener(L[O],K,T)&&U);}return U;}}if(!T||!T.call){return this.purgeElement(L,false,K);}if("unload"==K){for(O=J.length-1;O>-1;O--){V=J[O];if(V&&V[0]==L&&V[1]==K&&V[2]==T){J.splice(O,1);return true;}}return false;}var P=null;var Q=arguments[3];if("undefined"===typeof Q){Q=this._getCacheIndex(L,K,T);}if(Q>=0){P=I[Q];}if(!L||!P){return false;}if(this.useLegacyEvent(L,K)){var N=this.getLegacyIndex(L,K);var M=E[N];if(M){for(O=0,R=M.length;O<R;++O){V=M[O];if(V&&V[this.EL]==L&&V[this.TYPE]==K&&V[this.FN]==T){M.splice(O,1);break;}}}}else{try{this._simpleRemove(L,K,P[this.WFN],false);}catch(S){this.lastError=S;return false;}}delete I[Q][this.WFN];delete I[Q][this.FN];I.splice(Q,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 D)){K=D[K];}return K;},_getCacheIndex:function(O,P,N){for(var M=0,L=I.length;M<L;M=M+1){var K=I[M];if(K&&K[this.FN]==N&&K[this.EL]==O&&K[this.TYPE]==P){return M;}}return -1;},generateId:function(K){var L=K.id;if(!L){L="yuievtautoid-"+A;++A;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",this),_load:function(L){if(!H){H=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(F.length===0){C=0;clearInterval(this._interval);this._interval=null;return ;}if(this.locked){return ;}if(this.isIE){if(!this.DOMReady){this.startInterval();return ;}}this.locked=true;var Q=!H;if(!Q){Q=(C>0&&F.length>0);}var P=[];var R=function(T,U){var S=T;if(U.override){if(U.override===true){S=U.obj;}else{S=U.override;}}U.fn.call(S,U.obj);};var L,K,O,N,M=[];for(L=0,K=F.length;L<K;L=L+1){O=F[L];if(O){N=this.getEl(O.id);if(N){if(O.checkReady){if(H||N.nextSibling||!Q){M.push(O);F[L]=null;}}else{R(N,O);F[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);}C--;if(Q){for(L=F.length-1;L>-1;L--){O=F[L];if(!O||!O.id){F.splice(L,1);}}this.startInterval();}else{clearInterval(this._interval);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=[I,J];}else{if(K==="unload"){L=[J];}else{L=[I];}}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(Q){var K=YAHOO.util.Event,N,M,L,P,O,R=J.slice();for(N=0,P=J.length;N<P;++N){L=R[N];if(L){var S=window;if(L[K.ADJ_SCOPE]){if(L[K.ADJ_SCOPE]===true){S=L[K.UNLOAD_OBJ];}else{S=L[K.ADJ_SCOPE];}}L[K.FN].call(S,K.getEvent(Q,L[K.EL]),L[K.UNLOAD_OBJ]);R[N]=null;L=null;S=null;}}J=null;if(I){for(M=I.length-1;M>-1;M--){L=I[M];if(L){K.removeListener(L[K.EL],L[K.TYPE],L[K.FN],M);}}L=null;}G=null;K._simpleRemove(window,"unload",K._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;
/* DOMReady: based on work by: Dean Edwards/John Resig/Matthias Miller */
if(EU.isIE){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,override: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(G,D){this.__yui_events=this.__yui_events||{};var A=D||{};var I=this.__yui_events;
if(I[G]){}else{var H=A.scope||this;var E=(A.silent);var B=new YAHOO.util.CustomEvent(G,H,E,YAHOO.util.CustomEvent.FLAT);I[G]=B;if(A.onSubscribeCallback){B.subscribeEvent.subscribe(A.onSubscribeCallback);}this.__yui_subscribers=this.__yui_subscribers||{};var F=this.__yui_subscribers[G];if(F){for(var C=0;C<F.length;++C){B.subscribe(F[C].fn,F[C].obj,F[C].override);}}}return I[G];},fireEvent:function(E,D,A,C){this.__yui_events=this.__yui_events||{};var G=this.__yui_events[E];if(!G){return null;}var B=[];for(var F=1;F<arguments.length;++F){B.push(arguments[F]);}return G.fire.apply(G,B);},hasEvent:function(A){if(this.__yui_events){if(this.__yui_events[A]){return true;}}return false;}};YAHOO.util.KeyListener=function(A,F,B,C){if(!A){}else{if(!F){}else{if(!B){}}}if(!C){C=YAHOO.util.KeyListener.KEYDOWN;}var D=new YAHOO.util.CustomEvent("keyPressed");this.enabledEvent=new YAHOO.util.CustomEvent("enabled");this.disabledEvent=new YAHOO.util.CustomEvent("disabled");if(typeof A=="string"){A=document.getElementById(A);}if(typeof B=="function"){D.subscribe(B);}else{D.subscribe(B.fn,B.scope,B.correctScope);}function E(J,I){if(!F.shift){F.shift=false;}if(!F.alt){F.alt=false;}if(!F.ctrl){F.ctrl=false;}if(J.shiftKey==F.shift&&J.altKey==F.alt&&J.ctrlKey==F.ctrl){var G;if(F.keys instanceof Array){for(var H=0;H<F.keys.length;H++){G=F.keys[H];if(G==J.charCode){D.fire(J.charCode,J);break;}else{if(G==J.keyCode){D.fire(J.keyCode,J);break;}}}}else{G=F.keys;if(G==J.charCode){D.fire(J.charCode,J);}else{if(G==J.keyCode){D.fire(J.keyCode,J);}}}}}this.enable=function(){if(!this.enabled){YAHOO.util.Event.addListener(A,C,E);this.enabledEvent.fire(F);}this.enabled=true;};this.disable=function(){if(this.enabled){YAHOO.util.Event.removeListener(A,C,E);this.disabledEvent.fire(F);}this.enabled=false;};this.toString=function(){return"KeyListener ["+F.keys+"] "+A.tagName+(A.id?"["+A.id+"]":"");};};YAHOO.util.KeyListener.KEYDOWN="keydown";YAHOO.util.KeyListener.KEYUP="keyup";YAHOO.util.KeyListener.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.5.2",build:"1076"});YAHOO.register("yahoo-dom-event", YAHOO, {version: "2.5.2", build: "1076"});
/*
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 2.5.2
*/
(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,E,D){if(this.patterns.noNegatives.test(C)){E=(E>0)?E:0;}B.Dom.setStyle(this.getEl(),C,E+D);},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(F||(B.Dom.getStyle(E,"position")=="absolute"&&H)){G=E["offset"+D[0].charAt(0).toUpperCase()+D[0].substr(1)];}else{G=0;}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;}};};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";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 H=YAHOO.util.Dom.getStyle(G,E);
if(this.patterns.transparent.test(H)){var F=G.parentNode;H=C.Dom.getStyle(F,E);while(F&&this.patterns.transparent.test(H)){F=F.parentNode;H=C.Dom.getStyle(F,E);if(F.tagName.toUpperCase()=="HTML"){H="#fff";}}}}else{H=D.getAttribute.call(this,E);}return H;};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.5.2",build:"1076"});/*
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 2.5.2
*/
if(!YAHOO.util.DragDropMgr){YAHOO.util.DragDropMgr=function(){var A=YAHOO.util.Event;return{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(D,C){for(var E in this.ids){for(var B in this.ids[E]){var F=this.ids[E][B];if(!this.isTypeOfDD(F)){continue;}F[D].apply(F,C);}}},_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(B){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(C,B){if(!this.initialized){this.init();}if(!this.ids[B]){this.ids[B]={};}this.ids[B][C.id]=C;},removeDDFromGroup:function(D,B){if(!this.ids[B]){this.ids[B]={};}var C=this.ids[B];if(C&&C[D.id]){delete C[D.id];}},_remove:function(C){for(var B in C.groups){if(B&&this.ids[B][C.id]){delete this.ids[B][C.id];}}delete this.handleIds[C.id];},regHandle:function(C,B){if(!this.handleIds[C]){this.handleIds[C]={};}this.handleIds[C][B]=B;},isDragDrop:function(B){return(this.getDDById(B))?true:false;},getRelated:function(G,C){var F=[];for(var E in G.groups){for(var D in this.ids[E]){var B=this.ids[E][D];if(!this.isTypeOfDD(B)){continue;}if(!C||B.isTarget){F[F.length]=B;}}}return F;},isLegalTarget:function(F,E){var C=this.getRelated(F,true);for(var D=0,B=C.length;D<B;++D){if(C[D].id==E.id){return true;}}return false;},isTypeOfDD:function(B){return(B&&B.__ygDragDrop);},isHandle:function(C,B){return(this.handleIds[C]&&this.handleIds[C][B]);},getDDById:function(C){for(var B in this.ids){if(this.ids[B][C]){return this.ids[B][C];}}return null;},handleMouseDown:function(D,C){this.currentTarget=YAHOO.util.Event.getTarget(D);this.dragCurrent=C;var B=C.getEl();this.startX=YAHOO.util.Event.getPageX(D);this.startY=YAHOO.util.Event.getPageY(D);this.deltaX=this.startX-B.offsetLeft;this.deltaY=this.startY-B.offsetTop;this.dragThreshMet=false;this.clickTimeout=setTimeout(function(){var E=YAHOO.util.DDM;E.startDrag(E.startX,E.startY);E.fromTimeout=true;},this.clickTimeThresh);},startDrag:function(B,D){clearTimeout(this.clickTimeout);var C=this.dragCurrent;if(C&&C.events.b4StartDrag){C.b4StartDrag(B,D);C.fireEvent("b4StartDragEvent",{x:B,y:D});}if(C&&C.events.startDrag){C.startDrag(B,D);C.fireEvent("startDragEvent",{x:B,y:D});}this.dragThreshMet=true;},handleMouseUp:function(B){if(this.dragCurrent){clearTimeout(this.clickTimeout);if(this.dragThreshMet){if(this.fromTimeout){this.fromTimeout=false;this.handleMouseMove(B);}this.fromTimeout=false;this.fireEvents(B,true);}else{}this.stopDrag(B);this.stopEvent(B);}},stopEvent:function(B){if(this.stopPropagation){YAHOO.util.Event.stopPropagation(B);}if(this.preventDefault){YAHOO.util.Event.preventDefault(B);}},stopDrag:function(D,C){var B=this.dragCurrent;if(B&&!C){if(this.dragThreshMet){if(B.events.b4EndDrag){B.b4EndDrag(D);B.fireEvent("b4EndDragEvent",{e:D});}if(B.events.endDrag){B.endDrag(D);B.fireEvent("endDragEvent",{e:D});}}if(B.events.mouseUp){B.onMouseUp(D);B.fireEvent("mouseUpEvent",{e:D});}}this.dragCurrent=null;this.dragOvers={};},handleMouseMove:function(E){var B=this.dragCurrent;if(B){if(YAHOO.util.Event.isIE&&!E.button){this.stopEvent(E);return this.handleMouseUp(E);}else{if(E.clientX<0||E.clientY<0){}}if(!this.dragThreshMet){var D=Math.abs(this.startX-YAHOO.util.Event.getPageX(E));var C=Math.abs(this.startY-YAHOO.util.Event.getPageY(E));if(D>this.clickPixelThresh||C>this.clickPixelThresh){this.startDrag(this.startX,this.startY);}}if(this.dragThreshMet){if(B&&B.events.b4Drag){B.b4Drag(E);B.fireEvent("b4DragEvent",{e:E});}if(B&&B.events.drag){B.onDrag(E);B.fireEvent("dragEvent",{e:E});}if(B){this.fireEvents(E,false);}}this.stopEvent(E);}},fireEvents:function(U,K){var Z=this.dragCurrent;if(!Z||Z.isLocked()||Z.dragOnly){return ;}var M=YAHOO.util.Event.getPageX(U),L=YAHOO.util.Event.getPageY(U),O=new YAHOO.util.Point(M,L),J=Z.getTargetCoord(O.x,O.y),E=Z.getDragEl(),D=["out","over","drop","enter"],T=new YAHOO.util.Region(J.y,J.x+E.offsetWidth,J.y+E.offsetHeight,J.x),H=[],C={},P=[],a={outEvts:[],overEvts:[],dropEvts:[],enterEvts:[]};for(var R in this.dragOvers){var c=this.dragOvers[R];if(!this.isTypeOfDD(c)){continue;}if(!this.isOverTarget(O,c,this.mode,T)){a.outEvts.push(c);}H[R]=true;delete this.dragOvers[R];}for(var Q in Z.groups){if("string"!=typeof Q){continue;}for(R in this.ids[Q]){var F=this.ids[Q][R];if(!this.isTypeOfDD(F)){continue;}if(F.isTarget&&!F.isLocked()&&F!=Z){if(this.isOverTarget(O,F,this.mode,T)){C[Q]=true;if(K){a.dropEvts.push(F);}else{if(!H[F.id]){a.enterEvts.push(F);}else{a.overEvts.push(F);}this.dragOvers[F.id]=F;}}}}}this.interactionInfo={out:a.outEvts,enter:a.enterEvts,over:a.overEvts,drop:a.dropEvts,point:O,draggedRegion:T,sourceRegion:this.locationCache[Z.id],validDrop:K};for(var B in C){P.push(B);}if(K&&!a.dropEvts.length){this.interactionInfo.validDrop=false;if(Z.events.invalidDrop){Z.onInvalidDrop(U);Z.fireEvent("invalidDropEvent",{e:U});}}for(R=0;R<D.length;R++){var X=null;if(a[D[R]+"Evts"]){X=a[D[R]+"Evts"];}if(X&&X.length){var G=D[R].charAt(0).toUpperCase()+D[R].substr(1),W="onDrag"+G,I="b4Drag"+G,N="drag"+G+"Event",V="drag"+G;if(this.mode){if(Z.events[I]){Z[I](U,X,P);Z.fireEvent(I+"Event",{event:U,info:X,group:P});}if(Z.events[V]){Z[W](U,X,P);Z.fireEvent(N,{event:U,info:X,group:P});}}else{for(var Y=0,S=X.length;Y<S;++Y){if(Z.events[I]){Z[I](U,X[Y].id,P[0]);Z.fireEvent(I+"Event",{event:U,info:X[Y].id,group:P[0]});}if(Z.events[V]){Z[W](U,X[Y].id,P[0]);Z.fireEvent(N,{event:U,info:X[Y].id,group:P[0]});
}}}}}},getBestMatch:function(D){var F=null;var C=D.length;if(C==1){F=D[0];}else{for(var E=0;E<C;++E){var B=D[E];if(this.mode==this.INTERSECT&&B.cursorIsOver){F=B;break;}else{if(!F||!F.overlap||(B.overlap&&F.overlap.getArea()<B.overlap.getArea())){F=B;}}}}return F;},refreshCache:function(C){var E=C||this.ids;for(var B in E){if("string"!=typeof B){continue;}for(var D in this.ids[B]){var F=this.ids[B][D];if(this.isTypeOfDD(F)){var G=this.getLocation(F);if(G){this.locationCache[F.id]=G;}else{delete this.locationCache[F.id];}}}}},verifyEl:function(C){try{if(C){var B=C.offsetParent;if(B){return true;}}}catch(D){}return false;},getLocation:function(G){if(!this.isTypeOfDD(G)){return null;}var E=G.getEl(),J,D,C,L,K,M,B,I,F;try{J=YAHOO.util.Dom.getXY(E);}catch(H){}if(!J){return null;}D=J[0];C=D+E.offsetWidth;L=J[1];K=L+E.offsetHeight;M=L-G.padding[0];B=C+G.padding[1];I=K+G.padding[2];F=D-G.padding[3];return new YAHOO.util.Region(M,B,I,F);},isOverTarget:function(J,B,D,E){var F=this.locationCache[B.id];if(!F||!this.useCache){F=this.getLocation(B);this.locationCache[B.id]=F;}if(!F){return false;}B.cursorIsOver=F.contains(J);var I=this.dragCurrent;if(!I||(!D&&!I.constrainX&&!I.constrainY)){return B.cursorIsOver;}B.overlap=null;if(!E){var G=I.getTargetCoord(J.x,J.y);var C=I.getDragEl();E=new YAHOO.util.Region(G.y,G.x+C.offsetWidth,G.y+C.offsetHeight,G.x);}var H=E.intersect(F);if(H){B.overlap=H;return(D)?true:B.cursorIsOver;}else{return false;}},_onUnload:function(C,B){this.unregAll();},unregAll:function(){if(this.dragCurrent){this.stopDrag();this.dragCurrent=null;}this._execOnAll("unreg",[]);this.ids={};},elementCache:{},getElWrapper:function(C){var B=this.elementCache[C];if(!B||!B.el){B=this.elementCache[C]=new this.ElementWrapper(YAHOO.util.Dom.get(C));}return B;},getElement:function(B){return YAHOO.util.Dom.get(B);},getCss:function(C){var B=YAHOO.util.Dom.get(C);return(B)?B.style:null;},ElementWrapper:function(B){this.el=B||null;this.id=this.el&&B.id;this.css=this.el&&B.style;},getPosX:function(B){return YAHOO.util.Dom.getX(B);},getPosY:function(B){return YAHOO.util.Dom.getY(B);},swapNode:function(D,B){if(D.swapNode){D.swapNode(B);}else{var E=B.parentNode;var C=B.nextSibling;if(C==D){E.insertBefore(D,B);}else{if(B==D.nextSibling){E.insertBefore(B,D);}else{D.parentNode.replaceChild(B,D);E.insertBefore(D,C);}}}},getScroll:function(){var D,B,E=document.documentElement,C=document.body;if(E&&(E.scrollTop||E.scrollLeft)){D=E.scrollTop;B=E.scrollLeft;}else{if(C){D=C.scrollTop;B=C.scrollLeft;}else{}}return{top:D,left:B};},getStyle:function(C,B){return YAHOO.util.Dom.getStyle(C,B);},getScrollTop:function(){return this.getScroll().top;},getScrollLeft:function(){return this.getScroll().left;},moveToEl:function(B,D){var C=YAHOO.util.Dom.getXY(D);YAHOO.util.Dom.setXY(B,C);},getClientHeight:function(){return YAHOO.util.Dom.getViewportHeight();},getClientWidth:function(){return YAHOO.util.Dom.getViewportWidth();},numericSort:function(C,B){return(C-B);},_timeoutCount:0,_addListeners:function(){var B=YAHOO.util.DDM;if(YAHOO.util.Event&&document){B._onLoad();}else{if(B._timeoutCount>2000){}else{setTimeout(B._addListeners,10);if(document&&document.body){B._timeoutCount+=1;}}}},handleWasClicked:function(B,D){if(this.isHandle(D,B.id)){return true;}else{var C=B.parentNode;while(C){if(this.isHandle(D,C.id)){return true;}else{C=C.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,_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);
},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(H,G){var D=H.which||H.button;if(this.primaryButtonOnly&&D>1){return ;}if(this.isLocked()){return ;}var C=this.b4MouseDown(H);if(this.events.b4MouseDown){C=this.fireEvent("b4MouseDownEvent",H);}var E=this.onMouseDown(H);if(this.events.mouseDown){E=this.fireEvent("mouseDownEvent",H);}if((C===false)||(E===false)){return ;}this.DDM.refreshCache(this.groups);var F=new YAHOO.util.Point(A.getPageX(H),A.getPageY(H));if(!this.hasOuterHandles&&!this.DDM.isOverTarget(F,this)){}else{if(this.clickValidator(H)){this.setStartPosition();this.DDM.handleMouseDown(H,this);this.DDM.stopEvent(H);}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 G=this.getDragEl(),E=YAHOO.util.Dom;if(!G){G=document.createElement("div");G.id=this.dragElId;var D=G.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");G.appendChild(C);if(YAHOO.env.ua.ie){var F=document.createElement("iframe");F.setAttribute("src","javascript:");F.setAttribute("scrolling","no");F.setAttribute("frameborder","0");G.insertBefore(F,G.firstChild);E.setStyle(F,"height","100%");E.setStyle(F,"width","100%");E.setStyle(F,"position","absolute");E.setStyle(F,"top","0");E.setStyle(F,"left","0");E.setStyle(F,"opacity","0");E.setStyle(F,"zIndex","-1");E.setStyle(F.nextSibling,"zIndex","2");}A.insertBefore(G,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.5.2",build:"1076"});/*
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 2.5.2
*/
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:{},_isFormSubmit:false,_isFileUpload:false,_formNode:null,_sFormData:null,_poll:{},_timeOut:{},_polling_interval:50,_transaction_id:0,_submitElementValue:null,_hasSubmitListener:(function(){if(YAHOO.util.Event){YAHOO.util.Event.addListener(document,"click",function(B){var A=YAHOO.util.Event.getTarget(B);if(A.nodeName.toLowerCase()=="input"&&(A.type&&A.type.toLowerCase()=="submit")){YAHOO.util.Connect._submitElementValue=encodeURIComponent(A.name)+"="+encodeURIComponent(A.value);}});return true;}return false;})(),startEvent:new YAHOO.util.CustomEvent("start"),completeEvent:new YAHOO.util.CustomEvent("complete"),successEvent:new YAHOO.util.CustomEvent("success"),failureEvent:new YAHOO.util.CustomEvent("failure"),uploadEvent:new YAHOO.util.CustomEvent("upload"),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);YAHOO.log("ActiveX Program Id  "+A+" added to _msxml_progid.","info","Connection");},setDefaultPostHeader:function(A){if(typeof A=="string"){this._default_post_header=A;YAHOO.log("Default POST header set to  "+A,"info","Connection");}else{if(typeof A=="boolean"){this._use_default_post_header=A;}}},setDefaultXhrHeader:function(A){if(typeof A=="string"){this._default_xhr_header=A;YAHOO.log("Default XHR header set to  "+A,"info","Connection");}else{this._use_default_xhr_header=A;}},setPollingInterval:function(A){if(typeof A=="number"&&isFinite(A)){this._polling_interval=A;YAHOO.log("Default polling interval set to "+A+"ms","info","Connection");}},createXhrObject:function(E){var D,A;try{A=new XMLHttpRequest();D={conn:A,tId:E};YAHOO.log("XHR object created for transaction "+E,"info","Connection");}catch(C){for(var B=0;B<this._msxml_progid.length;++B){try{A=new ActiveXObject(this._msxml_progid[B]);D={conn:A,tId:E};YAHOO.log("ActiveX XHR object created for transaction "+E,"info","Connection");break;}catch(C){}}}finally{return D;}},getConnectionObject:function(A){var C;var D=this._transaction_id;try{if(!A){C=this.createXhrObject(D);}else{C={};C.tId=D;C.isUpload=true;}if(C){this._transaction_id++;}}catch(B){}finally{return C;}},asyncRequest:function(F,C,E,A){var D=(this._isFileUpload)?this.getConnectionObject(true):this.getConnectionObject();var B=(E&&E.argument)?E.argument:null;if(!D){YAHOO.log("Unable to create connection object.","error","Connection");return null;}else{if(E&&E.customevents){this.initCustomEvents(D,E);}if(this._isFormSubmit){if(this._isFileUpload){this.uploadFile(D,E,C,A);return D;}if(F.toUpperCase()=="GET"){if(this._sFormData.length!==0){C+=((C.indexOf("?")==-1)?"?":"&")+this._sFormData;}}else{if(F.toUpperCase()=="POST"){A=A?this._sFormData+"&"+A:this._sFormData;}}}if(F.toUpperCase()=="GET"&&(E&&E.cache===false)){C+=((C.indexOf("?")==-1)?"?":"&")+"rnd="+new Date().valueOf().toString();}D.conn.open(F,C,true);if(this._use_default_xhr_header){if(!this._default_headers["X-Requested-With"]){this.initHeader("X-Requested-With",this._default_xhr_header,true);YAHOO.log("Initialize transaction header X-Request-Header to XMLHttpRequest.","info","Connection");}}if((F.toUpperCase()=="POST"&&this._use_default_post_header)&&this._isFormSubmit===false){this.initHeader("Content-Type",this._default_post_header);YAHOO.log("Initialize header Content-Type to application/x-www-form-urlencoded; UTF-8 for POST transaction.","info","Connection");}if(this._has_default_headers||this._has_http_headers){this.setHeader(D);}this.handleReadyState(D,E);D.conn.send(A||"");YAHOO.log("Transaction "+D.tId+" sent.","info","Connection");if(this._isFormSubmit===true){this.resetFormState();}this.startEvent.fire(D,B);if(D.startEvent){D.startEvent.fire(D,B);}return D;}},initCustomEvents:function(A,C){for(var 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);YAHOO.log("Transaction-specific Custom Event "+A[this._customEvents[B][1]]+" created.","info","Connection");A[this._customEvents[B][0]].subscribe(C.customevents[B]);YAHOO.log("Transaction-specific Custom Event "+A[this._customEvents[B][1]]+" subscribed.","info","Connection");}}},handleReadyState:function(C,D){var B=this;var 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(F,G,A){var D,C;var B=(G&&G.argument)?G.argument:null;try{if(F.conn.status!==undefined&&F.conn.status!==0){D=F.conn.status;}else{D=13030;}}catch(E){D=13030;}if(D>=200&&D<300||D===1223){C=this.createResponseObject(F,B);if(G&&G.success){if(!G.scope){G.success(C);YAHOO.log("Success callback. HTTP code is "+D,"info","Connection");}else{G.success.apply(G.scope,[C]);YAHOO.log("Success callback with scope. HTTP code is "+D,"info","Connection");}}this.successEvent.fire(C);if(F.successEvent){F.successEvent.fire(C);}}else{switch(D){case 12002:case 12029:case 12030:case 12031:case 12152:case 13030:C=this.createExceptionObject(F.tId,B,(A?A:false));if(G&&G.failure){if(!G.scope){G.failure(C);
YAHOO.log("Failure callback. Exception detected. Status code is "+D,"warn","Connection");}else{G.failure.apply(G.scope,[C]);YAHOO.log("Failure callback with scope. Exception detected. Status code is "+D,"warn","Connection");}}break;default:C=this.createResponseObject(F,B);if(G&&G.failure){if(!G.scope){G.failure(C);YAHOO.log("Failure callback. HTTP status code is "+D,"warn","Connection");}else{G.failure.apply(G.scope,[C]);YAHOO.log("Failure callback with scope. HTTP status code is "+D,"warn","Connection");}}}this.failureEvent.fire(C);if(F.failureEvent){F.failureEvent.fire(C);}}this.releaseObject(F);C=null;},createResponseObject:function(A,G){var D={};var I={};try{var C=A.conn.getAllResponseHeaders();var F=C.split("\n");for(var E=0;E<F.length;E++){var B=F[E].indexOf(":");if(B!=-1){I[F[E].substring(0,B)]=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;var G="communication failure";var C=-1;var B="transaction aborted";var 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){if(this._has_default_headers){for(var B in this._default_headers){if(YAHOO.lang.hasOwnProperty(this._default_headers,B)){A.conn.setRequestHeader(B,this._default_headers[B]);YAHOO.log("Default HTTP header "+B+" set with value of "+this._default_headers[B],"info","Connection");}}}if(this._has_http_headers){for(var B in this._http_headers){if(YAHOO.lang.hasOwnProperty(this._http_headers,B)){A.conn.setRequestHeader(B,this._http_headers[B]);YAHOO.log("HTTP header "+B+" set with value of "+this._http_headers[B],"info","Connection");}}delete this._http_headers;this._http_headers={};this._has_http_headers=false;}},resetDefaultHeaders:function(){delete this._default_headers;this._default_headers={};this._has_default_headers=false;},setForm:function(K,E,B){this.resetFormState();var J;if(typeof K=="string"){J=(document.getElementById(K)||document.forms[K]);}else{if(typeof K=="object"){J=K;}else{YAHOO.log("Unable to create form object "+K,"warn","Connection");return ;}}if(E){var F=this.createFrame((window.location.href.toLowerCase().indexOf("https")===0||B)?true:false);this._isFormSubmit=true;this._isFileUpload=true;this._formNode=J;return ;}var A,I,G,L;var H=false;for(var D=0;D<J.elements.length;D++){A=J.elements[D];L=A.disabled;I=A.name;G=A.value;if(!L&&I){switch(A.type){case"select-one":case"select-multiple":for(var C=0;C<A.options.length;C++){if(A.options[C].selected){if(window.ActiveXObject){this._sFormData+=encodeURIComponent(I)+"="+encodeURIComponent(A.options[C].attributes["value"].specified?A.options[C].value:A.options[C].text)+"&";}else{this._sFormData+=encodeURIComponent(I)+"="+encodeURIComponent(A.options[C].hasAttribute("value")?A.options[C].value:A.options[C].text)+"&";}}}break;case"radio":case"checkbox":if(A.checked){this._sFormData+=encodeURIComponent(I)+"="+encodeURIComponent(G)+"&";}break;case"file":case undefined:case"reset":case"button":break;case"submit":if(H===false){if(this._hasSubmitListener&&this._submitElementValue){this._sFormData+=this._submitElementValue+"&";}else{this._sFormData+=encodeURIComponent(I)+"="+encodeURIComponent(G)+"&";}H=true;}break;default:this._sFormData+=encodeURIComponent(I)+"="+encodeURIComponent(G)+"&";}}}this._isFormSubmit=true;this._sFormData=this._sFormData.substr(0,this._sFormData.length-1);YAHOO.log("Form initialized for transaction. HTML form POST message is: "+this._sFormData,"info","Connection");this.initHeader("Content-Type",this._default_form_header);YAHOO.log("Initialize header Content-Type to application/x-www-form-urlencoded for setForm() transaction.","info","Connection");return this._sFormData;},resetFormState:function(){this._isFormSubmit=false;this._isFileUpload=false;this._formNode=null;this._sFormData="";},createFrame:function(A){var B="yuiIO"+this._transaction_id;var C;if(window.ActiveXObject){C=document.createElement('<iframe id="'+B+'" name="'+B+'" />');if(typeof A=="boolean"){C.src="javascript:false";}}else{C=document.createElement("iframe");C.id=B;C.name=B;}C.style.position="absolute";C.style.top="-1000px";C.style.left="-1000px";document.body.appendChild(C);YAHOO.log("File upload iframe created. Id is:"+B,"info","Connection");},appendPostData:function(A){var D=[];var B=A.split("&");for(var C=0;C<B.length;C++){var E=B[C].indexOf("=");if(E!=-1){D[C]=document.createElement("input");D[C].type="hidden";D[C].name=B[C].substring(0,E);D[C].value=B[C].substring(E+1);this._formNode.appendChild(D[C]);}}return D;},uploadFile:function(D,M,E,C){var N=this;var H="yuiIO"+D.tId;var I="multipart/form-data";var K=document.getElementById(H);var J=(M&&M.argument)?M.argument:null;var B={action:this._formNode.getAttribute("action"),method:this._formNode.getAttribute("method"),target:this._formNode.getAttribute("target")};this._formNode.setAttribute("action",E);this._formNode.setAttribute("method","POST");this._formNode.setAttribute("target",H);if(YAHOO.env.ua.ie){this._formNode.setAttribute("encoding",I);}else{this._formNode.setAttribute("enctype",I);}if(C){var L=this.appendPostData(C);}this._formNode.submit();this.startEvent.fire(D,J);if(D.startEvent){D.startEvent.fire(D,J);}if(M&&M.timeout){this._timeOut[D.tId]=window.setTimeout(function(){N.abort(D,M,true);},M.timeout);}if(L&&L.length>0){for(var G=0;G<L.length;G++){this._formNode.removeChild(L[G]);}}for(var A in B){if(YAHOO.lang.hasOwnProperty(B,A)){if(B[A]){this._formNode.setAttribute(A,B[A]);}else{this._formNode.removeAttribute(A);}}}this.resetFormState();var F=function(){if(M&&M.timeout){window.clearTimeout(N._timeOut[D.tId]);
delete N._timeOut[D.tId];}N.completeEvent.fire(D,J);if(D.completeEvent){D.completeEvent.fire(D,J);}var P={};P.tId=D.tId;P.argument=M.argument;try{P.responseText=K.contentWindow.document.body?K.contentWindow.document.body.innerHTML:K.contentWindow.document.documentElement.textContent;P.responseXML=K.contentWindow.document.XMLDocument?K.contentWindow.document.XMLDocument:K.contentWindow.document;}catch(O){}if(M&&M.upload){if(!M.scope){M.upload(P);YAHOO.log("Upload callback.","info","Connection");}else{M.upload.apply(M.scope,[P]);YAHOO.log("Upload callback with scope.","info","Connection");}}N.uploadEvent.fire(P);if(D.uploadEvent){D.uploadEvent.fire(P);}YAHOO.util.Event.removeListener(K,"load",F);setTimeout(function(){document.body.removeChild(K);N.releaseObject(D);YAHOO.log("File upload iframe destroyed. Id is:"+H,"info","Connection");},100);};YAHOO.util.Event.addListener(K,"load",F);},abort:function(E,G,A){var D;var B=(G&&G.argument)?G.argument:null;if(E&&E.conn){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&&E.isUpload===true){var C="yuiIO"+E.tId;var F=document.getElementById(C);if(F){YAHOO.util.Event.removeListener(F,"load");document.body.removeChild(F);YAHOO.log("File upload iframe destroyed. Id is:"+C,"info","Connection");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);YAHOO.log("Transaction "+E.tId+" aborted.","info","Connection");}return D;},isCallInProgress:function(B){if(B&&B.conn){return B.conn.readyState!==4&&B.conn.readyState!==0;}else{if(B&&B.isUpload===true){var A="yuiIO"+B.tId;return document.getElementById(A)?true:false;}else{return false;}}},releaseObject:function(A){if(A&&A.conn){A.conn=null;YAHOO.log("Connection object for transaction "+A.tId+" destroyed.","info","Connection");A=null;}}};YAHOO.register("connection",YAHOO.util.Connect,{version:"2.5.2",build:"1076"});PgnViewer=function(_1,_2){
var _3=new BoardConfig();
_3.applyConfig(_1);
if(!window._pvObject){
window._pvObject=new Array();
}
window._pvObject[_3.boardName]=this;
_1=_3;
_1.pgnMode=true;
this.chessapp=new ChessApp(_1);
this.finishedCallback=_2;
if(_1.loadImmediately){
this.chessapp.init();
}else{
YAHOO.util.Event.addListener(window,"load",this.chessapp.init,this.chessapp,true);
}
};
PgnViewer.prototype.setupFromPgn=function(_4){
this.chessapp.pgn.setupFromPGN(_4);
};
PGNGame=function(_5,_6,_7,_8,_9,_a,_b,_c,_d,_e){
this.movesseq=_5;
this.startFen=_6;
this.blackPlayer=_7;
this.whitePlayer=_8;
this.pgn_result=_9;
this.event=_a;
this.site=_b;
this.date=_c;
this.round=_d;
this.start_movenum=_e;
};
PGN=function(_f){
this.board=_f;
this.pgnGames=new Array();
};
PGN.prototype.getPGNFromURL=function(url){
YAHOO.util.Connect.asyncRequest("POST",url,{success:function(o){
this.setupFromPGN(o.responseText);
},failure:function(o){
YAHOO.log("pgn load failed:"+o.statusText+" for file:"+url);
alert("pgn load failed:"+o.statusText+" for file:"+url);
},scope:this},"emptyText");
};
PGN.prototype.getMoveFromPGNMove=function(_13,_14,_15){
var _16=false;
var _17=false;
var _18=false;
var _19;
var _1a=null;
var _1b=false;
var _1c=null;
if(_13.charAt(_13.length-1)=="#"){
_17=true;
_16=true;
_13=_13.substr(0,_13.length-1);
}else{
if(_13.charAt(_13.length-1)=="+"){
_17=true;
if(_13.length>1&&_13.charAt(_13.length-2)=="+"){
_16=true;
_13=_13.substr(0,_13.length-2);
}else{
_13=_13.substr(0,_13.length-1);
}
}
}
if(_13=="O-O-O"){
if(_14=="w"){
return this.board.createMoveFromString("e1c1");
}else{
return this.board.createMoveFromString("e8c8");
}
}else{
if(_13=="O-O"){
if(_14=="w"){
return this.board.createMoveFromString("e1g1");
}else{
return this.board.createMoveFromString("e8g8");
}
}
}
var _1d=_13.indexOf("=");
if(_1d>=0){
var _1e;
_1a=_13.substr(_1d+1,1);
_1e=_1a.charAt(0);
_19=this.board.pieceCharToPieceNum(_1e);
_18=true;
_13=_13.substr(0,_1d);
}
var _1f=_13.substr(_13.length-2,2);
var _20=_1f.charCodeAt(0)-"a".charCodeAt(0);
var _21=_1f.charCodeAt(1)-"1".charCodeAt(0);
if(_20>7||_20<0||_21>7||_21<0){
alert("PgnViewer: Error processing to Square:"+_1f+" on move:"+_13);
return null;
}
if(_13.length>2){
if(_13.charAt(_13.length-3)=="x"){
_1b=true;
_1c=_13.substr(0,_13.length-3);
}else{
_1c=_13.substr(0,_13.length-2);
}
}
var _22=new Array();
var _23=0;
var _24=null;
var _25=(_14=="w")?ChessPiece.WHITE:ChessPiece.BLACK;
switch(_13.charAt(0)){
case "K":
case "k":
_24=ChessPiece.KING;
break;
case "Q":
case "q":
_24=ChessPiece.QUEEN;
break;
case "R":
case "r":
_24=ChessPiece.ROOK;
break;
case "B":
_24=ChessPiece.BISHOP;
break;
case "N":
case "n":
_24=ChessPiece.KNIGHT;
break;
case "P":
case "p":
_24=ChessPiece.PAWN;
break;
default:
_24=ChessPiece.PAWN;
}
var _26=null;
var _27=null;
if(_1c){
var _28=_1c.toLowerCase().charAt(0);
if(_28==_1c.charAt(0)&&_28>="a"&&_28<="h"){
_27=_28;
if(_1c.length==2){
_26=_1c.charAt(1);
}
}else{
if(_1c.length>1){
if(_1c.length==2){
var c=_1c.charAt(1);
if(c>="1"&&c<="8"){
_26=c;
}else{
_27=c;
}
}else{
if(_1c.length==3){
_27=_1c.charAt(1);
_26=_1c.charAt(2);
if(_27>="1"&&_27<="9"){
var tmp=_27;
_27=_26;
_26=tmp;
}
}else{
alert("PgnViewer: Error: unhandled fromChars:"+_1c);
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==_25&&bp.piece==_24){
if(this.board.canMove(bp,_20,_21,_15,true)){
var _2e=String.fromCharCode("a".charCodeAt(0)+i).charAt(0);
var _2f=String.fromCharCode("1".charCodeAt(0)+j).charAt(0);
if((_27==null||_27==_2e)&&(_26==null||_26==_2f)){
_22[_23++]=bp;
}else{
}
}
}
}
}
if(_23==0){
alert("PgnViewer: no candidate pieces for:"+_13);
return null;
}
if(_23>1){
alert("PgnViewer: Ambiguous:"+_13+" with fromChars:"+_1c+" disRow:"+_26+" disCol:"+_27);
return null;
}
var _30=_22[0];
var _31="";
_31+=String.fromCharCode("a".charCodeAt(0)+_30.column);
_31+=String.fromCharCode("1".charCodeAt(0)+_30.row);
if(_1b){
_31+="x";
}
_31+=_1f;
if(_1a){
_31+=_1a;
}
var _32=this.board.createMoveFromString(_31);
return _32;
};
PGN.prototype.parseTag=function(_33,pgn,_35){
if(pgn.substr(_35,_33.length+3)=="["+_33+" \""){
var _36=pgn.indexOf("\"",_35+_33.length+3);
if(_36>=0){
return pgn.substring(_35+_33.length+3,_36);
}
}
return null;
};
PGN.prototype.setupFromPGN=function(pgn){
var _38=new Array();
var _39=new Array();
var _3a=0;
this.pgnGames=new Array();
pgn=pgn.replace(/^\s+|\s+$/g,"");
var _3b=0;
this.pgn=pgn;
this.setupFromPGN_cont(_38,_39,_3a,_3b);
};
PGN.prototype.setupFromPGN_cont=function(_3c,_3d,_3e,_3f){
var _40=new Date().getTime();
var pgn=this.pgn;
var _42=this.board.boardName+"-progress";
var _43=YAHOO.util.Dom.get(_42);
while(_3f<pgn.length){
var _44="";
var _45="";
var _46="";
var _47="";
var _48="";
var _49="";
var _4a="";
var _4b="w";
var _4c=0;
var _4d=0;
var _4e=new Array();
var _4f=0;
var _50="";
var _51=null;
var _52=null;
var _53=new Array();
var _54=new Array();
var _55=new Array();
var _56=new Array();
var _57=new Array();
this.board.pieceMoveDisabled=true;
this.board.startFen="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1";
var i=0;
for(i=_3f;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!="?"){
_4a=tag;
}else{
tag=this.parseTag("Black",pgn,i);
if(tag&&tag!="?"){
_45=tag;
}else{
tag=this.parseTag("Result",pgn,i);
if(tag&&tag!="?"){
_44=tag;
}else{
tag=this.parseTag("Event",pgn,i);
if(tag&&tag!="?"){
_46=tag;
}else{
tag=this.parseTag("Site",pgn,i);
if(tag&&tag!="?"){
_47=tag;
}else{
tag=this.parseTag("Date",pgn,i);
if(tag&&tag!="?"){
_48=tag;
}else{
tag=this.parseTag("Round",pgn,i);
if(tag&&tag!="?"){
_49=tag;
}
}
}
}
}
}
}
}
if(pgn.charAt(i)=="["){
var j=pgn.indexOf;
for(j=i+1;j<pgn.length&&pgn.charAt(j)!="]";j++){
}
if(j==pgn.length){
alert("PgnViewer: Error parsing PGN. Found unclosed [");
return false;
}
i=j-1;
continue;
}
if(pgn.charAt(i)=="{"){
var _5b=pgn.indexOf("}",i+1);
if(_5b>=0){
var _5c=pgn.substring(i+1,_5b);
i=_5b;
_50+="{ "+_5c+" } ";
}else{
alert("PgnViewer: Error parsing PGN. Found unclosed {");
return false;
}
continue;
}
var _5d=1;
if(pgn.substr(i,1)=="."){
var j=i-1;
while(j>0&&pgn.charAt(j)>="0"&&pgn.charAt(j)<="9"){
j--;
}
if(j>0){
_5d=parseInt(pgn.substring(j+1,i));
}
break;
}
}
if(pgn.substr(i,1)!="."){
alert("PgnViewer: Error: Could not find movelist:"+pgn.substr(i));
return false;
}
this.board.setupFromFen(this.board.startFen,false,false,true);
var _5e=i;
var _5f=null;
for(i=i;i<pgn.length;i++){
var _60=-1;
if(pgn.substr(i,3)=="1-0"||pgn.substr(i,3)=="0-1"){
_60=3;
}else{
if(pgn.substr(i,7)=="1/2-1/2"){
_60=7;
}else{
if(pgn.substr(i,1)=="*"){
_60=1;
}
}
}
if(_60>0){
_5f=pgn.substr(i,_60);
_3f=i+_60;
break;
}
if(pgn.charAt(i)=="["){
_3f=i;
break;
}
if(pgn.charAt(i)==" "||pgn.charAt(i)=="\t"||pgn.charAt(i)=="\n"||pgn.charAt(i)=="\r"){
_5e=i+1;
continue;
}
if(pgn.charAt(i)>="0"&&pgn.charAt(i)<="9"){
continue;
}
if(pgn.charAt(i)=="."){
var _61=pgn.substring(_5e,i).replace(/^\s+|\s+$/g,"");
_5e=i;
while(i+1<pgn.length&&pgn.charAt(i+1)=="."){
i++;
}
if(_5e!=i){
_4b="b";
}else{
_4b="w";
}
_5e=i+1;
}else{
if(pgn.charAt(i)=="{"){
var _5b=pgn.indexOf("}",i+1);
if(_5b>=0){
var _5c=pgn.substring(i+1,_5b);
i=_5b;
_50+="{ "+_5c+" } ";
}
_5e=i+1;
}else{
if(pgn.charAt(i)=="("){
_53[_4c]=this.board.boardPieces;
_54[_4c]=_4b;
_56[_4c]=_51;
_57[_4c]=_52;
this.board.boardPieces=_55[_4c];
this.board.boardPieces=this.board.copyBoardPieces(false);
_51=_52;
_4c++;
_5e=i+1;
_50+="( ";
}else{
if(pgn.charAt(i)==")"){
boardPool.putObject(_53[_4c]);
_4c--;
this.board.boardPieces=_53[_4c];
_4b=_54[_4c];
_51=_56[_4c];
_52=_57[_4c];
_5e=i+1;
_50+=") ";
}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 _62=parseInt(pgn.substr(i+1,j+1));
if(_62<=9){
switch(_62){
case 1:
_50=_50.substr(0,_50.length-1)+"! ";
break;
case 2:
_50=_50.substr(0,_50.length-1)+"? ";
break;
case 3:
_50=_50.substr(0,_50.length-1)+"!! ";
break;
case 4:
_50=_50.substr(0,_50.length-1)+"?? ";
break;
case 5:
_50=_50.substr(0,_50.length-1)+"!? ";
break;
case 6:
_50=_50.substr(0,_50.length-1)+"?! ";
break;
case 7:
case 8:
case 9:
case 0:
default:
}
}else{
_50+=pgn.substring(i,j+1)+" ";
}
i=j;
}
continue;
}else{
var _63=-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"){
_63=j;
break;
}
}
if(_63==-1){
_63=pgn.length;
}
var _64=_5e;
var _65=pgn.substring(_5e,_63).replace(/^\s+|\s+$/g,"");
_5e=_63;
i=_5e-1;
if(_65.length==0){
alert("PgnViewer: Error: got empty move endMoveInd:"+_63+" upto:"+_64+" from:"+pgn.substr(_64)+"#");
return false;
}
var _66=_65.length-1;
while(_66>=0){
if(_65.charAt(_66)=="?"){
_66--;
}else{
if(_65.charAt(_66)=="!"){
_66--;
}else{
break;
}
}
}
var _67=_65.substring(0,_66+1);
var _68=this.getMoveFromPGNMove(_67,_4b,_51);
if(_68==null){
_50+="unknown ";
alert("PgnViewer: Error parsing:"+_65);
return false;
}
_52=_51;
_51=_68;
var _69=this.board.boardPieces[_68.fromColumn][_68.fromRow];
boardPool.putObject(_55[_4c]);
_55[_4c]=this.board.copyBoardPieces(false);
if(_69){
this.board.makeMove(_68,_69,false,0.5,false,false);
}
_4d=_4c;
_4f++;
_4b=this.board.flipToMove(_4b);
_50+=_68.moveString+"|"+_65+" ";
}
}
}
}
}
}
if(_3f<i){
_3f=i;
}
var _6a=pgn.indexOf("{",_3f);
var _6b=pgn.indexOf("[",_3f);
if(_6a>=0){
if(_6b==-1||_6a<_6b){
var _6c=pgn.indexOf("}",_6a+1);
if(_6c>=0){
var _5c=pgn.substring(_6a+1,_6c);
_3f=_6c+1;
_50+="{ "+_5c+" } ";
}else{
alert("PgnViewer: Error: Unclosed {");
return false;
}
}
}
_50=_50.replace(/^\s+|\s+$/g,"");
this.board.pieceMoveDisabled=false;
if(_5f!=null){
if(_44.length==0||_44=="?"){
_44=_5f;
}
}
this.pgnGames[_3e++]=new PGNGame(_50,this.board.startFen,_45,_4a,_44,_46,_47,_48,_49,_5d);
if(_43){
_43.innerHTML="Loaded "+_3e+" games";
}
if(new Date().getTime()-_40>500){
setTimeout("window._pvObject[\""+this.board.boardName+"\"].chessapp.pgn.setupFromPGN_cont(\""+_3c+"\",\""+_3d+"\",\""+_3e+"\",\""+_3f+"\");",0);
return;
}
}
var _6d=YAHOO.util.Dom.get(this.board.boardName+"-problemSelectorForm");
if(_6d){
_6d.parentNode.removeChild(_6d);
}
if(this.pgnGames.length==0){
alert("PgnViewer: Error: Unable to find any pgn games in:"+pgn);
return false;
}
if(this.pgnGames.length==1){
this.showGame(0);
}else{
var _6e=this.board.boardName+"-container";
var _6f=YAHOO.util.Dom.get(_6e);
var _70=document.createElement("div");
var _71="<form id=\""+this.board.boardName+"-problemSelectorForm\" action=\"\" method=\"\"><select id=\""+this.board.boardName+"-problemSelector\" name=\""+this.board.boardName+"-problemSelector\" style=\"width: "+this.board.pieceSize*8+"px;\">";
for(i=0;i<this.pgnGames.length;i++){
var _72=this.pgnGames[i];
var _73=this.board.boardName+"-game-"+i;
var _74=(i+1)+". "+_72.whitePlayer+" vs "+_72.blackPlayer;
if(_72.pgn_result.length>0&&_72.pgn_result!="?"&&this.board.showResult==1){
_74+=" "+_72.pgn_result;
}
if(_72.event.length>0&&_72.event!="?"&&this.board.showEvent==1){
_74+=" "+_72.event;
}
if(_72.round.length>0&&_72.round!="?"&&this.board.showRound==1){
_74+=" Rnd:"+_72.round;
}
if(_72.site.length>0&&_72.site!="?"&&this.board.showSite==1){
_74+=" "+_72.site;
}
if(_72.date.length>0&&_72.date!="?"&&this.board.showDate==1){
_74+=" "+_72.date;
}
_71+="<option id=\""+_73+"\" value=\""+i+"\">"+_74+"</option>";
}
_71+="</select></form>";
_70.innerHTML=_71;
_6f.insertBefore(_70,_6f.firstChild);
YAHOO.util.Event.addListener(this.board.boardName+"-problemSelector","change",this.selectGame,this,true);
this.showGame(0);
}
if(_43){
YAHOO.util.Dom.setStyle(_43,"visibility","hidden");
_43.appendChild(_43);
}
if(window._pvObject[this.board.boardName].finishedCallback){
window._pvObject[this.board.boardName].finishedCallback();
}
return;
};
PGN.prototype.selectGame=function(e){
var _76=YAHOO.util.Event.getTarget(e).selectedIndex;
this.showGame(_76);
var _77=this.board.boardName+"-piecestaken";
var _78=YAHOO.util.Dom.get(_77);
if(_78){
_78.innerHTML="";
}
this.board.resetMoveListScrollPosition();
};
PGN.prototype.showGame=function(_79){
this.board.startFen=this.pgnGames[_79].startFen;
this.board.setupFromFen(this.pgnGames[_79].startFen,false,false,false);
this.board.setMoveSequence(this.pgnGames[_79].movesseq,"NA",this.pgnGames[_79].start_movenum,this.pgnGames[_79].pgn_result);
this.board.displayPendingMoveList();
this.board.setCurrentMove(this.board.moveArray[0]);
if(this.board.autoplayFirst){
this.board.forwardMove();
}
this.board.displayMode=true;
};

var SITE_VERSION=1;
var clog=false;
var move_obj_id_counter=0;
BoardConfig=function(){
this.boardName="board";
this.pgnString=null;
this.pgnFile=null;
this.pieceSet="merida";
this.pieceSize=46;
this.isEndgame=false;
this.tr=false;
this.addVersion=true;
this.ml=9999;
this.autoScrollMoves=false;
this.moveAnimationLength=0.5;
this.showBracketsOnVariation=true;
this.newlineForEachMainMove=true;
this.showNPS=false;
this.squareColorClass="";
this.pieceTakenSize=this.pieceSize;
this.pauseBetweenMoves=800;
this.pgnMode=false;
this.previewMode=false;
this.movesFormat="default";
this.boardImagePath="http://chesstempo.com";
this.showCoordinates=false;
this.highlightFromTo=false;
this.highlightValidSquares=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;
};
BoardConfig.prototype.applyConfig=function(_1){
for(var _2 in _1){
this[_2]=_1[_2];
}
};
ChessApp=function(_3){
this.displayMode=false;
this.config=_3;
this.board=null;
};
ChessApp.prototype.setDisplayMode=function(_4){
this.displayMode=_4;
};
ChessApp.prototype.setProblemNumber=function(_5,_6){
this.problemNumber=_5;
this.attId=_6;
};
ChessApp.prototype.init=function(us){
ChessPiece.init();
this.board=new Board(this.config.boardName);
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)?null:new TacticsUI(this.board);
this.problem=(this.config.pgnMode||this.config.previewMode)?null:new ProblemUI(this.board,this.tactics);
this.board.tactics=this.tactics;
this.board.problem=this.problem;
if(this.problem){
this.problem.autoPlayOpponent=1;
}
this.pgn=(this.config.pgnMode)?new PGN(this.board):null;
var _8=MovesDisplay.DEFAULT_DISPLAY_TYPE;
if(this.config.movesFormat=="main_on_own_line"){
_8=MovesDisplay.MAIN_ON_OWN_LINE;
}
this.movesDisplay=new MovesDisplay(this.board,_8);
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.squareColorClass=this.config.squareColorClass;
this.board.tr=this.config.tr;
this.board.ml=this.config.ml;
this.board.addVersion=this.config.addVersion;
this.board.autoScrollMoves=this.config.autoScrollMoves;
this.board.moveAnimationLength=this.config.moveAnimationLength;
this.board.showBracketsOnVariation=this.config.showBracketsOnVariation;
this.board.newlineForEachMainMove=this.config.newlineForEachMainMove;
this.board.pieceSize=this.config.pieceSize;
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.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.dontOutputNavButtons=this.config.dontOutputNavButtons;
if(this.problem){
this.problem.isEndgame=this.config.isEndgame;
}
if(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.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);
}else{
if(this.config.pgnString){
this.pgn.setupFromPGN(this.config.pgnString);
}
}
}else{
if(this.tactics){
YAHOO.util.Event.addListener(window,"unload",this.tactics.leavingPage,this.tactics,true);
this.tactics.updateSessionDisplay(0,0);
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();
}
};
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 _b=new Object();
for(prop in o){
if(typeof (o[prop])=="object"){
_b[prop]=o[prop];
}else{
_b[prop]=o[prop];
}
}
return _b;
}
function clone(o){
return cloneWork(o);
}
get_image_str=function(_d,_e,_f,_10,_11){
var _12=".vers"+SITE_VERSION;
if(!_11){
_12="";
}
if(check_bad_msie()){
return _e+"/images/"+_f+"/"+_d+_10+_12+".png";
}else{
return _e+"/images/"+_f+"/"+_d+_10+_12+".png";
}
};
check_bad_msie=function(){
return (window.ActiveXObject&&(typeof document.body.style.maxHeight=="undefined"));
};
fix_ie_png=function(img){
if(!check_bad_msie()){
return;
}
var _14=(img.id)?"id='"+img.id+"' ":"";
var _15=(img.className)?"class='"+img.className+"' ":"";
var _16=(img.title)?"title='"+img.title+"' ":"title='"+img.alt+"' ";
var _17="display:inline-block;"+img.style.cssText;
if(img.align=="left"){
_17="float:left;"+_17;
}
if(img.align=="right"){
_17="float:right;"+_17;
}
if(img.parentElement.href){
_17="cursor:hand;"+_17;
}
var _18="<span "+_14+_15+_16+" style=\""+"width:"+img.width+"px; height:"+img.height+"px;"+_17+";"+"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"+"(src='"+img.src+"', sizingMethod='image');\"></span>";
img.outerHTML=_18;
};
Move=function(_19,_1a,_1b,_1c,_1d,_1e,_1f){
this.fromColumn=_19;
this.fromRow=_1a;
this.toColumn=_1b;
this.toRow=_1c;
this.take=_1d;
this.promotion=_1e;
this.moveString=_1f;
this.prev=null;
this.next=null;
this.numVars=0;
this.ravLevel=0;
this.atEnd=false;
this.obj_id=move_obj_id_counter++;
};
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;
};
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.prototype.toMoveString=function(){
var _23="";
if(this.promotion){
_23=this.promotion;
}
return Move.columnToChar(this.fromColumn)+""+(this.fromRow+1)+Move.columnToChar(this.toColumn)+""+(this.toRow+1)+_23;
};
function getTagValue(_24,_25){
var _26=_24.getElementsByTagName(_25);
if(_26==null){
YAHOO.log("got null node for tag:"+_25);
return null;
}
if(_26.length==0){
YAHOO.log("got empty array node for tag:"+_25);
return null;
}
if(_26[0].firstChild==null){
YAHOO.log("firstChild is null for tag:"+_25);
return null;
}
if(_26[0].firstChild.nodeValue==null){
YAHOO.log("firstChild.nodeValue is null for tag:"+_25);
return null;
}
if(typeof (_26[0].textContent)!="undefined"){
return _26[0].textContent;
}
return _26[0].firstChild.nodeValue;
}
ChessPiece=function(div,_28,_29,_2a){
var ua=navigator.userAgent.toLowerCase();
var _2c=(ua.indexOf("opera")>-1);
var id=div.id;
this.board=_2a;
this.icon=get_image_str(ChessPiece.pieceIconNames[_28][_29],this.board.boardImagePath,this.board.pieceSet,this.board.pieceSize,this.board.addVersion);
this.colour=_28;
this.piece=_29;
this.id=id;
this.div=div;
var _2e=_2a.getPieceDragDiv();
var _2f=false;
if(_2e==null){
_2e=document.createElement("div");
_2e.id="pieceDragDiv";
_2f=true;
YAHOO.util.Dom.setStyle(_2e,"visibility","hidden");
YAHOO.util.Dom.setStyle(_2e,"border","0px");
YAHOO.util.Dom.setStyle(_2e,"position","absolute");
}
this.pieceDragEl=_2e;
this.pieceDragElId="pieceDragDiv";
if(_2f){
var _30=document.getElementsByTagName("body");
if(_30==null||_30.length==0){
alert("Could not find body tag");
}else{
_30[0].appendChild(_2e);
}
}
if(YAHOO.util.Event.isIE){
var _31=this.div;
_31.innerHTML="<img src=\""+this.icon+"\"/>";
var img=_31.firstChild;
if(!_2c){
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");
}
YAHOO.util.Dom.setStyle([this.div],"height",this.board.pieceSize+"px");
YAHOO.util.Dom.setStyle([this.div],"width",this.board.pieceSize+"px");
YAHOO.util.Dom.setStyle([this.div],"border","0px");
YAHOO.util.Dom.setStyle([this.div],"padding","0px");
var ua=navigator.userAgent.toLowerCase();
var _2c=(ua.indexOf("opera")>-1);
if(false&&_2c){
YAHOO.util.Dom.setStyle([this.div],"position","absolute");
}else{
YAHOO.util.Dom.setStyle([this.div],"position","relative");
}
this.init(id,"ct-"+this.board.boardName+"-boardandpieces",{dragElId:this.pieceDragElId,resizeFrame:false,centreFrame:true,isTarget:false});
this.initFrame();
};
ChessPiece.prototype=new YAHOO.util.DDProxy();
ChessPiece.init=function(){
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.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.prototype.oldIsValidHandleChild=ChessPiece.prototype.isValidHandleChild;
ChessPiece.prototype.oldStartDrag=ChessPiece.prototype.startDrag;
ChessPiece.prototype.isValidHandleChild=function(_33){
if(this.board.dragDisabled){
return false;
}
if(this.board.toMove!=this.colour){
return false;
}
return this.oldIsValidHandleChild(_33);
};
ChessPiece.prototype.onDragOut=function(e,id){
this.insideBoard=false;
};
ChessPiece.prototype.onDragEnter=function(e,id){
this.insideBoard=true;
};
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.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);
}
YAHOO.util.Dom.setStyle(this.getEl(),"visibility","visible");
};
ChessPiece.prototype.startDrag=function(x,y){
this.insideBoard=true;
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 _3f=7-i;
var _40=j;
if(this.board.isFlipped){
_3f=7-_3f;
_40=7-_40;
}
if((_3f==this.row&&_40==this.column)||this.board.canMove(this.makeLightWeight(),_40,_3f,this.board.currentMove.prev,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 _45=YAHOO.util.Dom.getX("ctb-"+this.board.boardName);
var _46=YAHOO.util.Dom.getY("ctb-"+this.board.boardName);
var c=parseInt((x-_45)/this.board.pieceSize);
var r=parseInt((y-_46)/this.board.pieceSize);
var _49=this.board.boardName+"-s"+c+""+(7-r);
var _4a=YAHOO.util.Dom.get(_49);
if(this.board.highlightValidSquares){
if(this.board.lastOverSquare){
if(this.board.lastOverSquare!=_4a){
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&&this.candidates[c][r]){
YAHOO.util.Dom.addClass(_4a,"ct-over-valid-square");
}else{
YAHOO.util.Dom.addClass(_4a,"ct-over-invalid-square");
}
}
}
this.board.lastOverSquare=_4a;
}
};
ChessPiece.prototype.onDragDrop=function(e,id){
if(this.board.blockFowardBack||this.board.deferredBlockForwardBack){
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 _4f=YAHOO.util.Dom.getX("ctb-"+this.board.boardName);
var _50=YAHOO.util.Dom.getY("ctb-"+this.board.boardName);
var c=parseInt((x-_4f)/this.board.pieceSize);
var r=parseInt((y-_50)/this.board.pieceSize);
if(this.board.isFlipped){
r=7-r;
c=7-c;
}
var _53=false;
if(!this.board.currentMove||this.board.currentMove.atEnd){
_53=true;
}
this.board.updatePiece(this,c,7-r,false,false,true);
if(!_53&&this.board.currentMove&&this.board.currentMove.atEnd){
this.board.toggleToMove();
this.board.updateToPlay();
}
};
ChessPiece.prototype.removeFromParent=function(){
var _54=this.div;
if(_54.parentNode){
_54.parentNode.removeChild(_54);
}
};
ChessPiece.prototype.setVisible=function(_55){
var _56;
var _57;
if(_55){
_57="block";
_56="visible";
}else{
_57="none";
_56="hidden";
}
YAHOO.util.Dom.setStyle(this.id,"visibility",_56);
};
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.changePiece=function(_5a){
var ua=navigator.userAgent.toLowerCase();
var _5c=(ua.indexOf("opera")>-1);
var _5d=(_5a+"").toLowerCase().charAt(0);
switch(_5d){
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:
}
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){
var _5e=this.div;
_5e.innerHTML="<img src=\""+this.icon+"\"/>";
var img=_5e.firstChild;
if(!_5c){
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(_60,row){
var _62=this.board.getBoardDiv();
var _63=this.board.getXY();
var _64=_63[0];
var _65=_63[1];
var _66=[0,0];
if(this.board.isFlipped){
_66[0]=_64+((7-_60)*this.board.pieceSize);
_66[1]=_65+((row)*this.board.pieceSize);
}else{
_66[0]=_64+((_60)*this.board.pieceSize);
_66[1]=_65+((7-row)*this.board.pieceSize);
}
return _66;
};
ChessPiece.prototype.setPosition=function(_67,row,_69,_6a,_6b){
this.column=_67;
this.row=row;
if(this.board.pieceMoveDisabled){
return;
}
var _6c=this.div;
if(!_69){
if(!this.board.settingUpPosition){
var _6d=this.getNewXYPosition(_67,row);
YAHOO.util.Dom.setXY(_6c,_6d,false);
}else{
var _6e=null;
if(this.board.isFlipped){
_6e=this.board.boardName+"-s"+(7-this.column)+""+(7-this.row);
}else{
_6e=this.board.boardName+"-s"+(this.column)+""+(this.row);
}
var _6f=this.board[_6e];
if(_6c.parentNode){
_6c.parentNode.removeChild(_6c);
}
_6f.appendChild(_6c);
}
this.setVisible(true);
if(_6a){
_6a();
}
}else{
var _6d=this.getNewXYPosition(_67,row);
var _70=new YAHOO.util.Motion(_6c,{points:{to:_6d}});
_70.duration=_6b;
var _71=this;
_70.onComplete.subscribe(function(){
});
if(_6a){
_70.onComplete.subscribe(_6a);
}
_70.animate();
}
};
LightweightChessPiece=function(div,_73,_74,_75){
this.board=_75;
this.colour=_73;
this.piece=_74;
this.div=div;
};
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(_77){
};
LightweightChessPiece.prototype.unreg=function(){
};
LightweightChessPiece.prototype.setPosition=function(_78,row,_7a,_7b,_7c){
this.column=_78;
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(_7e){
var _7f=(_7e+"").toLowerCase().charAt(0);
switch(_7f){
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(_80,_81){
this.board=_80;
this.displayType=_81;
};
MovesDisplay.DEFAULT_DISPLAY_TYPE=0;
MovesDisplay.MAIN_ON_OWN_LINE=1;
Board=function(_82){
this.boardName=_82;
if(_82){
this.initTarget("ctb-"+_82,"ct-"+this.boardName+"-boardandpieces");
this.boardPieces=Board.createBoardArray();
}
this.settingUpPosition=false;
this.pendingLevelZeroCommentaryClose=false;
this.isUserFlipped=false;
};
Board.prototype=new YAHOO.util.DDTarget();
Board.createBoardArray=function(){
var _83=boardPool.getObject();
if(_83==null){
_83=new Array(8);
for(var i=0;i<8;i++){
_83[i]=new Array(8);
}
}
return _83;
};
Board.prototype.toggleToMove=function(){
if(this.toMove==ChessPiece.WHITE){
this.toMove=ChessPiece.BLACK;
}else{
this.toMove=ChessPiece.WHITE;
}
};
Board.prototype.setupPieceDivs=function(){
var _85=this.getBoardDiv();
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]);
}
}
}
}
if(this.pieces){
for(var i=0;i<32;i++){
if(this.pieces[i]){
this.pieces[i].setVisible(false);
this.pieces[i].unreg();
}
}
}
this.availIds=new Array(32);
this.availPieceDivs=new Array(32);
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(_87,_88,_89,_8a,_8b,_8c){
YAHOO.util.Dom.removeClass(this.lastFromSquare,"ct-from-square");
YAHOO.util.Dom.removeClass(this.lastToSquare,"ct-to-square");
if(_89==null){
return;
}
this.lastFromSquare=_87;
this.lastToSquare=_88;
this.lastFromRow=_89;
this.lastFromColumn=_8a;
this.lastToRow=_8b;
this.lastToColumn=_8c;
if(this.highlightFromTo){
YAHOO.util.Dom.addClass(_87,"ct-from-square");
YAHOO.util.Dom.addClass(_88,"ct-to-square");
}
};
Board.prototype.makeMove=function(_8d,_8e,_8f,_90,_91,_92,_93,_94){
var _95;
var _96;
if(!this.isFlipped){
_95=YAHOO.util.Dom.get(this.boardName+"-s"+_8d.fromColumn+""+_8d.fromRow);
_96=YAHOO.util.Dom.get(this.boardName+"-s"+_8d.toColumn+""+_8d.toRow);
}else{
_95=YAHOO.util.Dom.get(this.boardName+"-s"+(7-_8d.fromColumn)+""+(7-_8d.fromRow));
_96=YAHOO.util.Dom.get(this.boardName+"-s"+(7-_8d.toColumn)+""+(7-_8d.toRow));
}
if(_92){
this.updateFromTo(_95,_96,_8d.fromRow,_8d.fromColumn,_8d.toRow,_8d.toColumn);
}
var _97=this.boardPieces[_8d.toColumn][_8d.toRow];
if(_97!=null){
_97.enPassant=false;
_97.castled=false;
}
if(_8e.piece==ChessPiece.PAWN&&_8d.toColumn!=_8d.fromColumn&&this.boardPieces[_8d.toColumn][_8d.toRow]==null){
_97=this.boardPieces[_8d.toColumn][_8d.fromRow];
this.boardPieces[_8d.toColumn][_8d.fromRow]=null;
if(_97!=null){
_97.enPassant=true;
}
}
var _98=null;
if(_8e.piece==ChessPiece.KING&&Math.abs(_8d.toColumn-_8d.fromColumn)>1){
var _99;
var _9a;
if(_8d.toColumn>_8d.fromColumn){
_98=this.boardPieces[7][_8d.fromRow];
_99=_8d.fromRow;
_9a=5;
this.boardPieces[7][_8d.toRow]=null;
}else{
_98=this.boardPieces[0][_8d.fromRow];
_99=_8d.fromRow;
_9a=3;
this.boardPieces[0][_8d.toRow]=null;
}
if(!_98){
alert("No castle piece");
}else{
_98.setPosition(_9a,_99,_8f,null,_90);
this.boardPieces[_98.column][_98.row]=_98;
_98.castled=true;
}
}
_8d.taken=_97;
if(_97&&_91){
this.processTaken(_97,true);
}
this.board_xy=null;
_8e.setPosition(_8d.toColumn,_8d.toRow,_8f,function(){
var tp=_97;
if(tp){
tp.setVisible(false);
}
if(_8d.promotion!=null){
_8e.changePiece(_8d.promotion);
}
if(_93){
_93.call(_94);
}
},_90);
if(!_8f){
if(_8d.promotion!=null){
_8e.changePiece(_8d.promotion);
}
}
this.boardPieces[_8d.fromColumn][_8d.fromRow]=null;
this.boardPieces[_8d.toColumn][_8d.toRow]=_8e;
if(_98!=null){
_8d.taken=_98;
}
if(_8e.piece==ChessPiece.ROOK){
if(_8d.fromColumn==0){
this.canCastleQueenSide[_8e.colour]=false;
}else{
if(_8d.fromColumn==7){
this.canCastleKingSide[_8e.colour]=false;
}
}
}else{
if(_8e.piece==ChessPiece.KING){
this.canCastleQueenSide[_8e.colour]=false;
this.canCastleKingSide[_8e.colour]=false;
}
}
};
Board.prototype.promptPromotion=function(_9c,col,row,_9f,_a0){
_9c.prePromotionColumn=_9c.column;
_9c.prePromotionRow=_9c.row;
_9c.setPosition(col,row,false,null,this.moveAnimationLength);
var _a1=this;
var _a2=new YAHOO.widget.Dialog("promotionDialogId",{width:"300px",fixedcenter:true,visible:true,modal:true,close:false,constraintoviewport:true,buttons:[{text:_js("Dama"),handler:function(){
_a2.hide();
_a1.updatePiece(_9c,col,row,_9f,_a0,false,"q");
},isDefault:true},{text:_js("Torre"),handler:function(){
_a2.hide();
_a1.updatePiece(_9c,col,row,_9f,_a0,false,"r");
},isDefault:false},{text:_js("Alfil"),handler:function(){
_a2.hide();
_a1.updatePiece(_9c,col,row,_9f,_a0,false,"b");
},isDefault:false},{text:_js("Caballo"),handler:function(){
_a2.hide();
_a1.updatePiece(_9c,col,row,_9f,_a0,false,"n");
},isDefault:false}]});
_a2.setHeader(_js("Selecciona en qué pieza va a promocionar el peón:"));
_a2.setBody("");
_a2.render(document.body);
};
Board.prototype.moveToLocale=function(_a3){
if(!_a3||_a3==""){
return _a3;
}
var _a4="";
for(var i=0;i<_a3.length;i++){
var _a6=_a3.charAt(i);
switch(_a6){
case "K":
_a6=_js("K");
break;
case "Q":
_a6=_js("Q");
break;
case "R":
_a6=_js("R");
break;
case "N":
_a6=_js("N");
break;
case "B":
_a6=_js("B");
break;
case "a":
_a6=_js("a");
break;
case "b":
_a6=_js("b");
break;
case "c":
_a6=_js("c");
break;
case "d":
_a6=_js("d");
break;
case "e":
_a6=_js("e");
break;
case "f":
_a6=_js("f");
break;
case "g":
_a6=_js("g");
break;
case "h":
_a6=_js("h");
break;
case "x":
_a6=_js("x");
break;
case "#":
_a6=_js("#");
break;
}
_a4+=_a6;
}
return _a4;
};
Board.prototype.updatePiece=function(_a7,col,row,_aa,_ab,_ac,_ad,_ae){
if(_ad){
this.board_xy=null;
if(_a7.prePromotionRow){
_a7.row=_a7.prePromotionRow;
_a7.column=_a7.prePromotionColumn;
}
}
if(_ad==null&&_a7.column==col&&_a7.row==row){
this.board_xy=null;
_a7.setPosition(_a7.column,_a7.row,false,null,this.moveAnimationLength);
if(clog){
console.log("moved piece back to its orig position");
}
return;
}
var _af=null;
if(this.currentMove){
_af=this.currentMove.prev;
}
var _b0="";
if(_ac&&_a7.piece==ChessPiece.PAWN&&(row==7||row==0)){
this.promptPromotion(_a7,col,row,_aa,_ab);
return;
}else{
if(_ad!=null){
_b0=_ad;
}
}
if(this.problem&&this.problem.isEndgame){
if(!this.canMove(_a7.makeLightWeight(),col,row,_af,true)){
this.board_xy=null;
_a7.setPosition(_a7.column,_a7.row,false,null,this.moveAnimationLength);
if(clog){
console.log("move not legal , move back to orig");
}
return;
}else{
if(clog){
console.log("move is legal");
}
}
var _b1=Move.columnToChar(_a7.column)+""+(_a7.row+1)+""+Move.columnToChar(col)+""+(row+1)+_b0;
var _b2=this.createMoveFromString(_b1);
if(clog){
console.log("creating pending move:"+_b2.output());
}
this.problem.endgamePendingPiece=_a7;
this.problem.endgameOldPosition=[_a7.column,_a7.row];
this.problem.endgamePendingMove=_b2;
if(!this.currentMove||this.currentMove.next==null||!this.currentMove.bestMoves||!_ae){
var _b3="currmovenull";
if(this.currentMove){
if(clog){
console.log("in endgame updatepiece calling processEndgame currentMove:"+this.currentMove.output()+" fens:"+this.currentMove.fen);
}
}
if(!_ae){
if(clog){
console.log("col:"+col+" row:"+row);
}
_a7.setPosition(col,row,false,null,this.moveAnimationLength);
}
if(this.tactics&&this.tactics.problemFirstMoveDate==0){
this.tactics.problemFirstMoveDate=new Date().getTime();
}
this.problem.processEndgame(_b1,_ae);
}else{
_b1=this.currentMove;
this.makeMove(_b1,_a7,_ab,this.moveAnimationLength,true,true);
this.setCurrentMove(this.currentMove.next);
var cm=this.currentMove;
}
}else{
if(this.tactics&&this.tactics.problemActive){
this.tactics.hideProblemStatus();
}
if(!this.currentMove||this.currentMove.atEnd){
this.board_xy=null;
_a7.setPosition(_a7.column,_a7.row,false,null,this.moveAnimationLength);
YAHOO.log("already at end of move list");
alert("already at end");
return;
}
_b1=this.currentMove;
if(_b1.fromColumn==_a7.column&&_b1.fromRow==_a7.row&&_b1.toRow==row&&_b1.toColumn==col&&(_b0==""||(_b0==_b1.promotion))){
if(this.tactics&&this.tactics.problemFirstMoveDate==0){
this.tactics.problemFirstMoveDate=new Date().getTime();
}
YAHOO.log("Made correct move");
this.makeMove(_b1,_a7,_ab,this.moveAnimationLength,true,true);
this.setCurrentMove(this.currentMove.next);
if(this.currentMove.atEnd){
if(this.tactics&&this.tactics.problemActive){
var _b5=0;
if(this.tactics.session&&this.tactics.session.continueCorrect==1){
_b5=1;
}
this.tactics.markProblem(true,_b5,"NULL","NULL");
}
}
if(!_aa&&!this.currentMove.atEnd){
opponentMove=this.currentMove;
YAHOO.log("Updating opponent move fromcol:"+opponentMove.fromColumn+" frowRow:"+opponentMove.fromRow);
this.updatePiece(this.boardPieces[opponentMove.fromColumn][opponentMove.fromRow],opponentMove.toColumn,opponentMove.toRow,true,true,false);
}
}else{
var _b6=_a7.column;
var _b7=_a7.row;
var _b8=false;
var _b9=null;
if(_b1.vars&&_b1.vars.length>0){
var i=0;
for(var i=0;i<_b1.vars.length;i++){
_b9=_b1.vars[i];
if(_b9.isAlt&&_b9.fromColumn==_b6&&_b9.fromRow==_b7&&_b9.toRow==row&&_b9.toColumn==col){
_b8=true;
break;
}
}
}
if(_b8){
if(this.tactics){
var _bb=_js("That");
if(_b9&&_b9.SAN){
_bb=this.moveToLocale(_b9.SAN);
}
this.tactics.showProblemStatus(_js("Keep Looking"),__js("{ALTERNATIVE_MOVE} was a good move, but not the computer's first choice.<br/> Please keep looking for another move.",[["ALTERNATIVE_MOVE",_bb]]));
this.tactics.aCount++;
}
}
this.board_xy=null;
_a7.setPosition(_a7.column,_a7.row,false,null,this.moveAnimationLength);
if(!_b8&&this.canMove(_a7.makeLightWeight(),col,row,this.currentMove.prev,true)){
if(this.tactics){
this.tactics.autoForward=false;
}
if(this.tactics&&this.tactics.problemActive){
var _bc=false;
if(this.tactics.session){
_bc=(this.tactics.session.continueFailed==1);
}
var _bd=Math.round(_b1.moveNum/2);
var _be=Move.columnToChar(_a7.column)+""+(_a7.row+1)+""+Move.columnToChar(col)+""+(row+1);
_be+="|"+this.makeShortAlgabraic(_a7.column,_a7.row,col,row);
this.tactics.markProblem(false,_bc,_bd,_be);
}
}
}
}
};
Board.prototype.scoreToShortString=function(_bf){
if(_bf=="draw"){
return "D";
}
if(_bf>=0){
return "M"+_bf;
}else{
return "L"+(-1*_bf);
}
};
Board.prototype.scoreToLongString=function(_c0){
if(_c0=="draw"){
return _js("Draw");
}
if(_c0==0){
return _js("Mate");
}else{
if(_c0>0){
return __js("Mate in {NUMBER_MOVES}",[["NUMBER_MOVES",_c0]]);
}else{
return __js("Lose in {NUMBER_MOVES}",[["NUMBER_MOVES",(-1*_c0)]]);
}
}
};
Board.prototype.egMoveToScoreString=function(_c1){
var _c2=_c1.score;
var _c3=_c1.optimal_score;
var s=this.scoreToShortString(_c2);
var opt=this.scoreToShortString(_c3);
var _c6=this.scoreToLongString(_c2);
var _c7=this.scoreToLongString(_c3);
if(_c2==_c3){
return ["",_c6];
}else{
var _c8="ct-subopt-move-score";
if(_c2=="draw"||_c2<0){
_c8="ct-bad-move-score";
}
return ["<span class=\""+_c8+"\">"+s+"("+opt+")</span>",_c6+"("+_c7+")"];
}
};
Board.prototype.makeShortAlgabraic=function(_c9,_ca,_cb,_cc,_cd){
if(clog){
console.log("fromCol:"+_c9+" fromRow:"+_ca+" toCol:"+_cb+" toRow:"+_cc);
}
var _ce=this.boardPieces[_c9][_ca];
var _cf=_ce.piece;
var _d0=this.pieceTypeToChar(_cf);
var _d1="";
if(_cf==ChessPiece.PAWN){
if(_c9==_cb){
_d1=Move.columnToChar(_c9)+""+(_cc+1);
}else{
_d1=Move.columnToChar(_c9)+"x"+Move.columnToChar(_cb)+""+(_cc+1);
if(!this.boardPieces[_cb][_cc]){
_d1+=" e.p.";
}
}
}else{
if(_cf==ChessPiece.KING){
var _d2=Math.abs(_c9-_cb);
if(_d2==1||_d2==0){
_d1=_d0;
if(this.boardPieces[_cb][_cc]){
_d1+="x";
}
_d1+=Move.columnToChar(_cb)+""+(_cc+1);
}else{
if(_cb==6){
_d1="O-O";
}else{
_d1="O-O-O";
}
}
}else{
var _d3=[];
for(var row=0;row<8;row++){
for(var col=0;col<8;col++){
var cp=this.boardPieces[col][row];
if(cp&&cp.colour==_ce.colour&&cp.piece==_cf&&!(_ce.column==cp.column&&_ce.row==cp.row)){
var _d7=null;
if(this.currentMove){
_d7=this.currentMove.prev;
}
if(this.canMove(cp.makeLightWeight(),_cb,_cc,_d7,true)){
_d3.push(cp);
}
}
}
}
_d1=_d0;
if(_d3.length>0){
var _d8=false;
var _d9=false;
for(var i=0;i<_d3.length;i++){
if(_d3[i].row==_ca){
_d9=true;
}
if(_d3[i].column==_c9){
_d8=true;
}
}
if(_d9||!(_d9||_d8)){
_d1+=Move.columnToChar(_c9);
}
if(_d8){
_d1+=""+(_ca+1);
}
}
if(this.boardPieces[_cb][_cc]){
_d1+="x";
}
_d1+=Move.columnToChar(_cb)+""+(_cc+1);
}
}
var _db="";
var _dc="";
if(_cd){
var _dd=this.cloneBoard();
var _de=ChessPiece.WHITE;
if(_dd.boardPieces[_cd.fromColumn][_cd.fromRow].colour==ChessPiece.WHITE){
_de=ChessPiece.BLACK;
}
_dd.makeMove(_cd,_dd.boardPieces[_cd.fromColumn][_cd.fromRow],false,_dd.moveAnimationLength,false,false);
if(!_dd.isKingSafe(_de,_cd)){
_db="+";
if(_dd.isKingMated(_de,_cd)){
_db="#";
}
}
if(_cd.promotion){
_dc="="+((_cd.promotion+"").toUpperCase());
}
}
_d1+=_dc+_db;
return _d1;
};
Board.prototype.createMoveFromString=function(_df){
var _e0=0;
var _e1=false;
var _e2=null;
var _e3=_df.charCodeAt(_e0++);
var _e4=_df.charCodeAt(_e0++);
var _e5=_df.split("|");
var pgn=null;
if(_e5.length>1){
pgn=_e5[1];
_df=_e5[0];
}else{
_df=_e5[0];
}
if(_df.charAt(_e0)=="x"){
_e0++;
_e1=true;
}
var _e7=_df.charCodeAt(_e0++);
var _e8=_df.charCodeAt(_e0++);
if(_e0<_df.length){
_e2=_df.charAt(_e0);
}
var _e9=new Move(_e3-("a".charCodeAt(0)),_e4-("1".charCodeAt(0)),_e7-("a".charCodeAt(0)),_e8-("1".charCodeAt(0)),_e1,_e2,_df);
_e9.pgn=pgn;
return _e9;
};
Board.prototype.setForwardBack=function(){
var _ea=YAHOO.util.Dom.get(this.boardName+"-back");
var _eb=YAHOO.util.Dom.get(this.boardName+"-forward");
var end=YAHOO.util.Dom.get(this.boardName+"-end");
var _ed=YAHOO.util.Dom.get(this.boardName+"-start");
if(!this.currentMove){
if(_ea){
_ea.src=this.boardImagePath+"/images/resultset_previous_disabled"+this.getVersString()+".gif";
}
if(_ed){
_ed.src=this.boardImagePath+"/images/disabled_resultset_first"+this.getVersString()+".gif";
}
if(_eb){
_eb.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(_ea){
_ea.src=this.boardImagePath+"/images/resultset_previous_disabled"+this.getVersString()+".gif";
}
if(_ed){
_ed.src=this.boardImagePath+"/images/disabled_resultset_first"+this.getVersString()+".gif";
}
}else{
if(_ea){
_ea.src=this.boardImagePath+"/images/resultset_previous"+this.getVersString()+".gif";
}
if(_ed){
_ed.src=this.boardImagePath+"/images/resultset_first"+this.getVersString()+".gif";
}
}
if(this.currentMove.atEnd){
if(_eb){
_eb.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(_eb){
_eb.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(_ee){
var _ef=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 _f2=this.boardPieces[i][j];
var p=_f2.makeHeavyWeight();
this.boardPieces[i][j]=p;
p.setPosition(p.column,p.row,false,null,this.moveAnimationLength);
p.setVisible(true);
}
}
}
var _f4=this.moveArray[_ee];
while(_f4!=null){
if(_f4.taken){
_f4.taken=_f4.taken.makeHeavyWeight();
}
_f4=_f4.prev;
}
this.settingUpPosition=_ef;
};
MovesDisplay.prototype.setToMove=function(_f5){
this.toMove=_f5;
};
MovesDisplay.prototype.gotoMove=function(e){
if(this.board.tactics&&this.board.tactics.problemActive){
return;
}
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 _f8=t.id.substr((this.board.boardName+"-m").length);
if(clog){
console.log("got goto move index:"+_f8);
}
this.board.gotoMoveIndex(_f8);
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){
this.cachedMovesDisplay=YAHOO.util.Dom.get(this.board.boardName+"-moves");
this.allreadyCachedMovesDisplay=true;
}
return this.cachedMovesDisplay;
};
MovesDisplay.prototype.outputVariationStart=function(_f9,_fa,_fb,_fc){
var _fd="";
if(_fa>this.board.ml){
return _fd;
}
if(this.board.ml==1&&_fc>1){
return _fd;
}
var _fe=this.getMovesDisplay();
if(_fe){
if(_f9==0&&this.displayType==MovesDisplay.MAIN_ON_OWN_LINE){
if(this.firstNonMove){
_fd+="<div class=\"ct-mainline-commentary\"/>";
this.pendingLevelZeroCommentaryClose=true;
}
}
if(this.variationOnOwnLine){
_fd+="<br/>";
}
if(this.board.showBracketsOnVariation){
_fd+="<span>( </span>";
}
}
this.firstNonMove=false;
return _fd;
};
MovesDisplay.prototype.outputVariationEnd=function(_ff,_100,_101,_102){
var _103=this.getMovesDisplay();
var _104="";
if(_100>this.board.ml){
return _104;
}
if(this.board.ml==1&&_102>3){
return _104;
}
if(_103){
if(this.board.showBracketsOnVariation){
_104+="<span>) </span>";
}
}
if(_ff==1&&this.displayType==MovesDisplay.MAIN_ON_OWN_LINE){
}
this.firstNonMove=false;
return _104;
};
MovesDisplay.prototype.outputComment=function(_105,_106,_107){
var _108="";
if(this.board.ml==1){
return _108;
}
var _109=this.getMovesDisplay();
if(_109){
if(_106==0&&this.displayType==MovesDisplay.MAIN_ON_OWN_LINE){
if(this.firstNonMove){
_108+="<br/>";
}
_108+="<div class=\"ct-mainline-commentary\">";
this.pendingLevelZeroCommentaryClose=true;
}
var _10a="ct-board-move-comment";
if(_107){
_10a="ct-board-move-alt-comment";
}
_108+="<span class=\""+_10a+"\"> "+_105+" </span>";
if(_106==0&&this.displayType==MovesDisplay.MAIN_ON_OWN_LINE){
}
}
this.firstNonMove=false;
return _108;
};
MovesDisplay.prototype.outputNag=function(_10b){
var _10c="";
var _10d=this.getMovesDisplay();
if(_10d){
var _10e=null;
switch(_10b){
case 11:
_10e="=";
break;
case 14:
_10e="+=";
break;
case 15:
_10e="=+";
break;
case 16:
_10e="+/-";
break;
case 17:
_10e="-/+";
break;
case 18:
_10e="+-";
break;
case 19:
_10e="-+";
break;
case 20:
_10e="+--";
break;
case 21:
_10e="--+";
break;
default:
}
if(_10e){
_10c+="<span> "+_10e+" </span>";
}
}
return _10c;
};
MovesDisplay.prototype.outputResult=function(_10f){
return "<span class=\"ct-result\">"+_10f+"</span>";
};
MovesDisplay.prototype.outputMove=function(_110,_111,_112,_113,_114,_115,_116,move,_118,_119){
if(clog){
console.log("outputMove:"+_113+" hideScore:"+_118);
}
var _11a="";
var _11b=this.getMovesDisplay();
if(this.board.tr&&_111>0&&(_115>1||_116>3)&&!_114){
return _11a;
}
if(_111>0&&_115>this.board.ml){
return _11a;
}
if(_111>0&&_116>3&&this.board.ml==1){
return _11a;
}
if(_11b){
var _11c=""+Math.round(_112/2)+". ";
if(_112%2!=1){
if(clog){
console.log("firstRav:"+_114+" firstNonMove:"+this.firstNonMove);
}
if(_114||!this.firstNonMove){
_11c=Math.round(_112/2)+"... ";
}else{
_11c="";
}
}
if(this.displayType==MovesDisplay.MAIN_ON_OWN_LINE&&_111==0&&(!this.firstNonMove||_112%2==1)){
if(this.pendingLevelZeroCommentaryClose){
this.pendingLevelZeroCommentaryClose=false;
_11a+="</div>";
}
if(this.board.newlineForEachMainMove){
_11a+="<br/>";
}
}
var _11d="";
var _11e="";
if(move&&move.eg_move){
var res=this.board.egMoveToScoreString(move.eg_move);
_11d=res[0];
_11e=res[1];
}
var _120="";
if(_118){
_120="initially_hidden";
}
if(_11d!=""){
_11d=" "+_11d;
}
var _121="title";
if(_118){
_121="alt";
}
var _122="";
if(_119){
_122=" rel=\""+_113+"\" ";
_113="___";
}
_11a+="<span "+_122+_121+"=\""+_11e+"\" id=\""+this.board.boardName+"-m"+_110+"\" class=\""+((_111==0)?"ct-board-move-mainline":"ct-board-move-variation")+"\">"+_11c+_113+"<span id=\""+this.board.boardName+"-msc"+_110+"\" class=\""+_120+"\">"+_11d+"</span></span>";
}
this.firstNonMove=true;
return _11a;
};
Board.prototype.setMoveSeqLalg=function(_123,_124,_125,_126){
if(this.movesDisplay&&this.lastCount){
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 _129=this.cloneBoard();
this.movesDisplay.firstNonMove=false;
var _12a=new Array();
var _12b=new Array();
if(this.prev_move){
_129.makeMove(this.prev_move,_129.boardPieces[this.prev_move.fromColumn][this.prev_move.fromRow],false,_129.moveAnimationLength,false,false);
}
var _12c=_129.cloneBoard();
var _12d=_123.replace(/\s+$/g,"").split(" ");
var _12e=null;
var _12f=0;
var _130="";
var _131=false;
var _132=false;
var _133=0;
var _134=false;
var _135=new Array();
var _136=new Array();
_136[0]=0;
var _137=new Array();
var _138=new Array();
var _139=_125*2-1;
var _13a=new Array();
var _13b=ChessPiece.WHITE;
var _13c=0;
var eval="";
var _13e="";
var _13f="";
var time="";
var _141=-1;
for(var i=0;i<_12d.length;i++){
var _142=0;
if(_12d[i]=="ALT"){
_132=true;
continue;
}
if(_12d[i].indexOf("EVAL")==0){
eval=_12d[i].split(":")[1];
if(parseInt(eval)>=175&&_133>0&&_136[_133]>1){
_132=true;
}
continue;
}
if(_12d[i].indexOf("DEPTH")==0){
_13e=_12d[i].split(":")[1];
continue;
}
if(_12d[i].indexOf("NODES")==0){
_13f=_12d[i].split(":")[1];
continue;
}
if(_12d[i].indexOf("TIME")==0){
time=_12d[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 _144=e.split(" ");
_142=parseInt(_144[1]);
e=_js("mate")+" "+_144[1];
if(_136[_133]==1){
_141=_142;
}
}
if(_142<0){
_132=false;
}else{
if(_142>0&&_142<8&&_133>0&&_136[_133]>1){
_132=true;
}
}
var _145="";
if(_132){
_145=_js("ALT")+" ";
}
var t=parseInt(time);
var nps=" "+__js("nps:{NODES_PER_SECOND}",[["NODES_PER_SECOND",Math.round(parseInt(_13f)/(parseInt(time)/1000))]]);
if(!this.showNPS){
nps="";
}
if(!(_133>0&&_136[_133]>this.ml)){
_12d[i]=_145+e+" ("+__js("depth:{DEPTH}",[["DEPTH",_13e]])+nps+")";
}else{
_12d[i]="";
}
}
if(_12d[i]=="}"){
_131=false;
if(this.movesDisplay){
_130=_130.replace(/\s+$/g,"");
_13a.push(this.movesDisplay.outputComment(_130,_133,_132));
}
continue;
}else{
if(_131){
_130+=_12d[i]+" ";
continue;
}else{
if(_12d[i]=="{"){
_130="";
_131=true;
continue;
}else{
if(_12d[i]=="("){
if(!_136[_133+1]){
_136[_133+1]=0;
}
_136[_133+1]++;
if(this.movesDisplay){
_13a.push(this.movesDisplay.outputVariationStart(_133,_136[_133+1],_139,_135[0]));
}
_135[_133]=_139;
_137[_133]=_12e;
_138[_133]=_13b;
_12a[_133]=_129;
_12b[_133]=_12c;
_129=_12c.cloneBoard();
_133++;
_139--;
_134=true;
continue;
}else{
if(_12d[i]==")"){
if(this.movesDisplay){
_13a.push(this.movesDisplay.outputVariationEnd(_133,_136[_133],_139,_135[0]));
}
var _148=new Move();
_148.atEnd=true;
_12e.next=_148;
_148.prev=_12e;
_133--;
_139=_135[_133];
_12e=_137[_133];
_13b=_138[_133];
_129=_12a[_133];
_12c=_12b[_133];
_132=false;
continue;
}else{
if(_12d[i].charAt(0)=="$"){
if(this.movesDisplay){
_13a.push(this.movesDisplay.outputNag(parseInt(_12d[i].substring(1))));
}
continue;
}
}
}
}
}
}
var move=this.createMoveFromString(_12d[i]);
var _14a=false;
if(_139==1&&this.boardPieces[move.fromColumn][move.fromRow].colour==ChessPiece.BLACK){
_139++;
_14a=true;
_13b=ChessPiece.BLACK;
}
move.index=_12f;
var _14b=(move.pgn)?move.pgn:move.moveString;
if(move.pgn){
_14b=move.pgn;
}else{
_14b=_129.makeShortAlgabraic(move.fromColumn,move.fromRow,move.toColumn,move.toRow,move);
move.SAN=_14b;
}
_14b=this.moveToLocale(_14b);
if(this.movesDisplay){
this.movesDisplay.setToMove(_13b);
_13a.push(this.movesDisplay.outputMove(_12f,_133,_139,_14b+" ",_134,_136[_133],_135[0]));
}
_13b=(_13b==ChessPiece.BLACK)?ChessPiece.WHITE:ChessPiece.BLACK;
move.moveNum=_139;
_139++;
if(_133>0){
if(_134){
var _14c=_12e;
if(_14c==null){
alert("Got no previous move for variation:"+movesArra[i]);
}
if(_14c.numVars==0){
_14c.vars=new Array();
}
move.isAlt=_132;
_14c.vars[_14c.numVars++]=move;
move.prev=_14c.prev;
_134=false;
}else{
move.prev=_12e;
if(_12e!=null){
_12e.next=move;
}
}
}else{
move.prev=_12e;
if(_12e!=null){
_12e.next=move;
}
}
_136[_133+1]=0;
if(_133==0){
_13c=_12f;
}
_124[_12f++]=move;
_129.moveArray[_12f-1]=move;
_12e=move;
_12c=_129.cloneBoard();
_129.makeMove(move,_129.boardPieces[move.fromColumn][move.fromRow],false,_129.moveAnimationLength,false,false);
}
if(this.movesDisplay&&!this.disableMoveOutput){
var _14d=this.movesDisplay.getMovesDisplay();
_13a.push(this.movesDisplay.outputResult(_126));
this.pendingMovesOutput=_13a.join("");
this.pendingMovesOutputCount=_12f;
}
this.lastMoveIndex=_13c;
if(_12e!=null){
var _148=new Move();
_148.atEnd=true;
_12e.next=_148;
_148.prev=_12e;
}
this.lastCount=_12f;
};
Board.prototype.displayPendingMoveList=function(){
if(this.pendingMovesOutput&&this.movesDisplay){
var _14e=this.movesDisplay.getMovesDisplay();
if(_14e){
_14e.innerHTML=this.pendingMovesOutput;
var _14f=new YAHOO.util.Scroll(_14e,{scroll:{to:[0,0]}},0);
_14f.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);
}
}
}
}
};
Board.prototype.setMoveSequence=function(_152,_153,_154,_155){
this.tacticMoveArray=new Array();
this.moveArray=this.tacticMoveArray;
this.setMoveSeqLalg(_152,this.tacticMoveArray,_154,_155);
this.tacticsmoveArrayLastMoveIndex=this.lastMoveIndex;
if(false&&_153!="NA"){
this.fullmoveArray=new Array();
this.disableMoveOutput=true;
this.setMoveSeqLalg(_153,this.fullmoveArray,_154,_155);
this.disableMoveOutput=false;
this.fullmoveArrayLastMoveIndex=this.lastMoveIndex;
}else{
this.fullmoveArray=null;
}
this.lastMoveIndex=this.tacticsmoveArrayLastMoveIndex;
};
Board.prototype.resetVariationsPreviousNodes=function(_156,_157){
if(_156.numVars>0){
for(var i=0;i<_156.numVars;i++){
_156.vars[i].prev=_157;
this.resetVariationsPreviousNodes(_156.vars[i],_157);
}
}
};
Board.prototype.reconnectNextNodeVariations=function(_159,_15a){
if(!_15a){
return;
}
if(_15a.numVars>0){
for(var i=0;i<_15a.numVars;i++){
_15a.vars[i].prev=_159;
this.reconnectNextNodeVariations(_159,_15a.vars[i]);
}
}
};
Board.prototype.insertMoveAfter=function(_15c,_15d,_15e,_15f,_160,_161){
addToMovelist=!_15e;
if(clog){
console.log("addToMovelist:"+addToMovelist);
}
var _162="null";
if(_15c){
_162=_15c.output();
}
if(clog){
console.log("insert newMove:"+_15d.output()+" after:"+_162);
}
if(_15c==null){
this.currentMove=_15d;
_15d.atEnd=1;
_15d.prev=null;
_15d.next=null;
this.firstMove=_15d;
if(this.toMove==ChessPiece.WHITE){
this.currentMove.moveNum=1;
}else{
this.currentMove.moveNum=2;
}
}else{
_15d.atEnd=_15c.atEnd;
_15d.prev=_15c;
_15c.atEnd=0;
if(clog){
if(_15c.next){
console.log("prevMove.next:"+_15c.next.output());
}
}
if(_15d.equals(_15c.next)||_15d.equals(_15c)){
if(clog){
console.log("inserting move that already exists in variation:"+_15c.next.output());
}
var _163=_15c.next;
if(this.firstMove==_163){
this.firstMove=_15d;
}
if(_15d.equals(_15c)){
_163=_15c;
}
if(_163.prev&&(_163.prev.next==_163)){
_163.prev.next=_15d;
}
if(_163.next){
_163.next.prev=_15d;
}
addToMovelist=false;
_15d.moveNum=_163.moveNum;
_15d.ravLevel=_163.ravLevel;
_15d.index=_163.index;
_15d.fen=_163.fen;
_15d.nextFen=_163.nextFen;
_15d.bestMoves=_163.bestMoves;
_15d.correctMove=_163.correctMove;
_15d.wrongMove=_163.wrongMove;
_15d.next=_163.next;
_15d.vars=_163.vars;
_15d.numVars=_163.numVars;
this.reconnectNextNodeVariations(_15d,_163.next);
this.moveArray[_15d.index]=_15d;
if(this.currentMove==_163){
this.setCurrentMove(_15d);
}
}else{
_15d.moveNum=_15c.moveNum+1;
_15d.ravLevel=_15c.ravLevel;
_15d.next=_15c.next;
if(_15d.next){
_15d.next.prev=_15d;
}
}
_15c.next=_15d;
}
if(addToMovelist){
this.insertIntoMoveDisplay(_15c,_15d,_15f,_160,_161);
}
if(_15d.next==null){
var _164=this.createMoveFromString("i1i2");
_15d.next=_164;
_164.prev=_15d;
_164.moveNum=_15d.moveNum+1;
_164.ravLevel=_15d.ravLevel;
_164.next=null;
_164.atEnd=1;
_164.endNode=true;
if(clog){
console.log("created endmove node in insertAfterMove:"+_164.output());
}
}else{
if(clog){
console.log("allready had a node at end:"+_15d.next.output());
}
_15d.next.moveNum=_15d.moveNum+1;
}
};
function insertAfter(node,_166){
var _167=_166.parentNode;
_167.insertBefore(node,_166.nextSibling);
}
Board.prototype.replaceIntoMoveDisplay=function(_168,_169,_16a,_16b,_16c){
var _16d="null";
if(_168){
_16d=_168.output();
}
if(clog){
console.log("replace display newMove:"+_169.output()+" after:"+_16d+" hideScore:"+_16b);
}
if(!_168){
if(clog){
console.log("null oldMove");
}
this.insertIntoMoveDisplay(null,_169,false,_16b);
}else{
if(clog){
console.log("about to get movesdsiplay in replace into move display:"+this.movesDisplay);
}
var _16e=this.movesDisplay.getMovesDisplay();
if(clog){
console.log("got moves display");
}
if(!_16e){
if(clog){
console.log("no movesd disiplay in replace into move display");
}
return;
}
var san=_169.SAN;
if(!san){
if(clog){
console.log("about to make san");
}
san=this.makeShortAlgabraic(_169.fromColumn,_169.fromRow,_169.toColumn,_169.toRow,_169);
if(clog){
console.log("about to made san:"+san);
}
_169.SAN=san;
}
if(clog){
console.log("oldMove.index:"+_168.index);
}
var _170=YAHOO.util.Dom.get((this.boardName+"-ms"+_168.index));
if(_16a){
this.moveIndex++;
_169.index=this.moveIndex;
this.moveArray[this.moveIndex]=_169;
if(clog){
console.log("replace as variation old:"+_168.output()+" new:"+_169.output());
}
var _171=document.createElement("span");
var _172=this.movesDisplay.outputVariationStart(0,0,_169.moveNum,0);
_169.ravLevel=_168.ravlevel+1;
var _16d=this.moveToLocale(san);
if(_169.prev==null){
this.movesDisplay.firstNonMove=false;
}
var _173=this.movesDisplay.outputMove(this.moveIndex,_169.ravLevel,_169.moveNum,_16d,_16a,0,_169.moveNum,_169,_16b,_16c);
var _174=document.createElement("span");
_174.id=(this.boardName+"-ms"+_169.index);
_174.innerHTML=_173+"&nbsp;";
var _175=this.movesDisplay.outputVariationEnd(0,0,_169.moveNum,0);
this.movesDisplay.firstNonMove=true;
var _176=document.createElement("span");
_176.innerHTML=_172;
var _177=document.createElement("span");
_177.innerHTML=_175;
_171.appendChild(_176);
_171.appendChild(_174);
_171.appendChild(_177);
_170.appendChild(_171);
}else{
_169.index=_168.index;
this.moveArray[_169.index]=_169;
var _16d=this.moveToLocale(san);
if(_169.prev==null){
this.movesDisplay.firstNonMove=false;
}
var _173=this.movesDisplay.outputMove(_169.index,_169.ravLevel,_169.moveNum,_16d,_16a,0,_169.moveNum,_169,_16b,_16c);
var _174=document.createElement("span");
_174.innerHTML=_173+"&nbsp;";
_174.id=(this.boardName+"-ms"+_169.index);
var _178=[];
if(_170&&_170.childNodes){
for(var i=1;i<_170.childNodes.length;i++){
_178[i-1]=_170.childNodes[i];
}
}
if(clog){
console.log("replace as main line not variation old:"+_168.output()+" new:"+_169.output());
}
_170.parentNode.replaceChild(_174,_170);
if(_178){
for(var i=0;i<_178.length;i++){
_174.appendChild(_178[i]);
}
}
}
YAHOO.util.Event.removeListener(this.boardName+"-m"+_169.index);
YAHOO.util.Event.addListener((this.boardName+"-m"+_169.index),"click",this.movesDisplay.gotoMove,this.movesDisplay,true);
}
};
Board.prototype.insertIntoMoveDisplay=function(_17a,_17b,_17c,_17d,_17e){
var _17f=this.movesDisplay.getMovesDisplay();
if(!_17f){
return;
}
var _180="null";
if(_17a){
_180=_17a.output();
}
if(clog){
console.log("insert display newMove:"+_17b.output()+" after:"+_180);
}
var san=_17b.SAN;
if(!san){
san=this.makeShortAlgabraic(_17b.fromColumn,_17b.fromRow,_17b.toColumn,_17b.toRow,_17b);
_17b.SAN=san;
}
this.moveIndex++;
_17b.index=this.moveIndex;
this.moveArray[this.moveIndex]=_17b;
var _180=this.moveToLocale(san);
var _182=this.movesDisplay.outputMove(this.moveIndex,_17b.ravLevel,_17b.moveNum,_180,false,0,_17b.moveNum,_17b,_17d,_17e);
var _183=document.createElement("span");
_183.innerHTML=_182+"&nbsp;";
_183.id=(this.boardName+"-ms"+this.moveIndex);
if(_17c){
YAHOO.util.Dom.setStyle(_183,"visibility","hidden");
}
if(_17a){
if(clog){
console.log("prevMove.index:"+_17a.index+"prevMove:"+_17a.output());
}
var _184=YAHOO.util.Dom.get((this.boardName+"-ms"+_17a.index));
if(_184){
insertAfter(_183,_184);
}else{
_17f.appendChild(_183);
}
}else{
if(_17b.next){
var _185=YAHOO.util.Dom.get((this.boardName+"-ms"+_17b.next.index));
insertBefore(_183,_185);
}else{
_17f.appendChild(_183);
}
}
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(_186,_187,_188,_189,_18a,_18b){
var _18c="null";
if(_186){
_18c=_186.output();
}
if(clog){
console.log("replace newMove:"+_187.output()+" after:"+_18c+" replace as var"+_188+" rep move display:"+_189+" hideScore:"+_18a);
if(_186&&_186.prev){
console.log("replace oldMove.prev:"+_186.prev.output());
}
if(_186&&_186.next){
console.log("replace oldMove.next:"+_186.next.output());
}
}
var _18d=false;
var _18e=null;
var _18f=0;
if(_186.endNode){
if(clog){
console.log("asked to replace endNode,inserting before instead");
}
this.insertMoveAfter(_186.prev,_187,false,false,_18a,_18b);
_187.fen=_186.fen;
_187.nextFen=_186.nextFen;
return;
}
if(_187.equals(_186)){
if(clog){
console.log("new move is same as old move so not replacing as variation");
}
_188=false;
}else{
if(_186&&_186.numVars>0){
for(var i=0;i<_186.numVars;i++){
var _191=_186.vars[i];
if(_187.equals(_191)){
if(clog){
console.log("new move is same as an existing variation varNum:"+i);
console.log("variation:"+_191.output());
if(_191.next){
console.log("variation next:"+_191.next.output());
}
}
_18d=true;
_18e=_186;
_186=_191;
_18f=i;
break;
}
}
}
}
if(_186==null){
if(clog){
console.log("replaced new move with null oldmove");
}
this.currentMove=_187;
_187.atEnd=1;
_187.next=null;
_187.prev=null;
if(this.startPositionAfterOpponentMove){
_187.fen=this.startPositionAfterOpponentMove;
_187.nextFen=null;
}
if(this.toMove==ChessPiece.WHITE){
this.currentMove.moveNum=1;
}else{
this.currentMove.moveNum=2;
}
this.firstMove=_187;
}else{
var _192=false;
if(_186&&_186.prev&&_186.prev.next!=_186){
_192=true;
}
if(this.currentMove==_186&&!_188){
this.currentMove=_187;
}
_187.atEnd=_186.atEnd;
_187.prev=_186.prev;
_187.next=_186.next;
_187.fen=_186.fen;
_187.nextFen=_186.nextFen;
_187.bestMoves=_186.bestMoves;
_187.correctMove=_186.correctMove;
_187.wrongMove=_186.wrongMove;
_187.moveNum=_186.moveNum;
_187.ravLevel=_186.ravLevel;
_187.index=_186.index;
if(_18d){
_18e.vars[_18f]=_187;
_187.vars=_186.vars;
_187.numVars=_186.numVars;
this.reconnectNextNodeVariations(_187,_186.next);
if(_186.next){
_186.next.prev=_187;
}
this.moveArray[_187.index]=_187;
if(clog){
console.log("replacing existing sub variation of main line");
if(_187.next){
console.log("next of replacement variation:"+_187.next.output());
}
}
return;
}
if(!_188){
if(clog){
console.log("not replacing as variation");
}
if(!_192&&_186.prev){
_186.prev.next=_187;
}
if(_186.next){
_186.next.prev=_187;
}
_187.vars=_186.vars;
_187.numVars=_186.numVars;
this.reconnectNextNodeVariations(_187,_186.next);
if(this.firstMove==_186){
this.firstMove=_187;
}
this.moveArray[_187.index]=_187;
}else{
if(clog){
console.log("replacing as variation");
}
if(_186.numVars==0){
_186.vars=new Array();
}
_186.vars[_186.numVars++]=_187;
_186.atEnd=0;
_187.next=null;
var _193=this.createMoveFromString("i1i2");
_187.next=_193;
_193.prev=_187;
_193.next=null;
_193.atEnd=1;
_193.moveNum=_187.moveNum+1;
_193.ravLevel=_187.ravLevel;
_193.endNode=true;
}
}
if(_189){
this.replaceIntoMoveDisplay(_186,_187,_188,_18a,_18b);
}
};
Board.prototype.setCurrentMove=function(move,_195){
if(this.currentMove!=null&&this.currentMove.prev!=null){
YAHOO.util.Dom.removeClass(this.boardName+"-m"+this.currentMove.prev.index,"ct-board-move-current");
}
this.currentMove=move;
if(this.currentMove!=null&&this.currentMove.prev!=null){
var _196=this.boardName+"-m"+this.currentMove.prev.index;
if(clog){
console.log("setCurrentMove attempted highlight of id:"+_196+" for move:"+move.output());
}
var span=YAHOO.util.Dom.get(_196);
if(span){
var cls=span.className;
YAHOO.util.Dom.addClass(span,"ct-board-move-current");
if(this.autoScrollMoves){
if(cls.indexOf("ct-board-move-variation")==-1){
var _199=this.movesDisplay.getMovesDisplay();
if(_199){
var y=YAHOO.util.Dom.getY(span)-YAHOO.util.Dom.getY(_199);
var _19b=new YAHOO.util.Scroll(_199,{scroll:{by:[0,y]}},this.moveAnimationLength,YAHOO.util.Easing.easeOut);
_19b.animate();
}
}
}
}
}else{
if(move==null){
if(clog){
console.log("attempted to set current move on null node");
}
}
}
if(!_195){
this.setForwardBack();
}
};
Board.prototype.getCastlingString=function(_19c){
var _19d=_js("None");
if(this.canCastleKingSide[_19c]){
_19d="O-O";
}
if(this.canCastleQueenSide[_19c]){
if(_19d=="None"){
_19d="O-O-O";
}else{
_19d+=",O-O-O";
}
}
return _19d;
};
Board.prototype.updateToPlay=function(){
var _19e=YAHOO.util.Dom.get("toPlay");
if(_19e==null){
return;
}
if(this.toMove==ChessPiece.WHITE){
_19e.src="/images/whiteknight"+this.getVersString()+".gif";
_19e.alt=_js("White to play");
}else{
_19e.src="/images/blackknight"+this.getVersString()+".gif";
_19e.alt=_js("Black to play");
}
var _19f=YAHOO.util.Dom.get("fenStatus");
if(_19f){
var _1a0=this.getCastlingString(ChessPiece.BLACK);
var _1a1=this.getCastlingString(ChessPiece.WHITE);
var s="<div><span>"+_js("White Castling: ")+"</span><span>"+_1a1+"</span></div>"+"<div><span>"+_js("Black Castling: ")+"</span><span>"+_1a0+"</span></div>";
_19f.innerHTML=s;
}
};
Board.prototype.getBoardDiv=function(){
if(!this.boardDiv){
this.boardDiv=YAHOO.util.Dom.get("ctb-"+this.boardName);
}
return this.boardDiv;
};
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 _1a3=YAHOO.util.Dom.get(this.boardName+"-fileLabels");
var _1a4=YAHOO.util.Dom.get(this.boardName+"-rankLabels");
if(!_1a3||!_1a4){
return;
}
_1a4.innerHTML="";
_1a3.innerHTML="";
var _1a5=YAHOO.util.Dom.get(this.boardName+"-boardBorder");
if(!this.showCoordinates){
YAHOO.util.Dom.setStyle(_1a3,"display","none");
YAHOO.util.Dom.setStyle(_1a4,"display","none");
var _1a6=0;
YAHOO.util.Dom.setStyle(_1a5,"width",(this.pieceSize*8+_1a6)+"px");
YAHOO.util.Dom.setStyle(_1a5,"height",(this.pieceSize*8+_1a6)+"px");
return;
}
YAHOO.util.Dom.setStyle(_1a3,"display","block");
YAHOO.util.Dom.setStyle(_1a4,"display","block");
var _1a6=15;
var _1a7=0;
if(check_bad_msie()){
_1a7=4;
}
YAHOO.util.Dom.setStyle(_1a5,"width",(this.pieceSize*8+_1a6+_1a7)+"px");
YAHOO.util.Dom.setStyle(_1a5,"height",(this.pieceSize*8+_1a6)+"px");
this.coordinatesShown=true;
for(var i=0;i<8;i++){
var _1a9=document.createElement("div");
YAHOO.util.Dom.setStyle(_1a9,"height",this.pieceSize+"px");
YAHOO.util.Dom.setStyle(_1a9,"width","15px");
YAHOO.util.Dom.setStyle(_1a9,"text-align","center");
YAHOO.util.Dom.setStyle(_1a9,"line-height",this.pieceSize+"px");
if(this.isFlipped){
_1a9.innerHTML=""+(i+1);
}else{
_1a9.innerHTML=""+9-(i+1);
}
_1a4.appendChild(_1a9);
}
for(var i=0;i<9;i++){
var _1aa=document.createElement("span");
YAHOO.util.Dom.setStyle(_1aa,"float","left");
YAHOO.util.Dom.setStyle(_1aa,"height","15px");
if(i==0){
YAHOO.util.Dom.setStyle(_1aa,"width","15px");
YAHOO.util.Dom.setStyle(_1aa,"clear","both");
YAHOO.util.Dom.setStyle(_1aa,"margin-top","-5px");
if(_1a7){
YAHOO.util.Dom.setStyle(_1aa,"margin-left","-3px");
}else{
YAHOO.util.Dom.setStyle(_1aa,"margin-left","-2px");
}
var _1ab="";
if(this.isFlipped){
_1ab="whiteblack-flipper.png";
}else{
_1ab="blackwhite-flipper.png";
}
_1aa.innerHTML="<span><img id=\""+this.boardName+"-flipper\" title=\""+_js("Flip Board")+"\" src=\""+this.boardImagePath+"/images/"+_1ab+"\"/></span>";
YAHOO.util.Event.addListener(this.boardName+"-flipper","click",this.flipBoard,this,true);
}else{
YAHOO.util.Dom.setStyle(_1aa,"width",this.pieceSize+"px");
YAHOO.util.Dom.setStyle(_1aa,"text-align","center");
if(this.isFlipped){
_1aa.innerHTML=_js(Move.columnToChar(8-(i)));
}else{
_1aa.innerHTML=_js(Move.columnToChar((i-1)));
}
}
_1a3.appendChild(_1aa);
}
var _1ac=YAHOO.util.Dom.get(this.boardName+"-flipper");
if(_1ac){
fix_ie_png(_1ac);
}
};
Board.prototype.createBoardUI=function(){
var _1ad=this.boardName+"-container";
var _1ae=YAHOO.util.Dom.get(_1ad);
if(_1ae==null){
alert("Could not find board container:"+_1ad);
return;
}
YAHOO.util.Dom.addClass(_1ae,"ct-board-container");
this.boardDiv=null;
var _1af=document.createElement("div");
_1af.id=this.boardName+"-boardBorder";
YAHOO.util.Dom.addClass(_1af,"ct-board-border"+this.squareColorClass);
var _1b0=0;
if(this.showCoordinates){
_1b0=15;
}
YAHOO.util.Dom.setStyle(_1af,"width",(this.pieceSize*8+_1b0)+"px");
YAHOO.util.Dom.setStyle(_1af,"height",(this.pieceSize*8+_1b0)+"px");
var _1b1=document.createElement("div");
YAHOO.util.Dom.setStyle(_1b1,"float","left");
_1b1.id=this.boardName+"-rankLabels";
_1af.appendChild(_1b1);
var _1b2=document.createElement("div");
YAHOO.util.Dom.addClass(_1b2,"ct-board");
YAHOO.util.Dom.setStyle(_1b2,"width",(this.pieceSize*8)+"px");
YAHOO.util.Dom.setStyle(_1b2,"height",(this.pieceSize*8)+"px");
_1b2.id="ctb-"+this.boardName;
var _1b3="ct-white-square"+this.squareColorClass;
for(var i=7;i>=0;i--){
var _1b1=document.createElement("div");
for(var j=0;j<8;j++){
var _1b6=document.createElement("div");
_1b6.id=this.boardName+"-s"+j+""+i;
this[_1b6.id]=_1b6;
YAHOO.util.Dom.addClass(_1b6,_1b3);
YAHOO.util.Dom.setStyle(_1b6,"width",this.pieceSize+"px");
YAHOO.util.Dom.setStyle(_1b6,"height",this.pieceSize+"px");
var _1b7=(((j+1)*(i+1))%19/19*100);
var _1b8=((65-((j+1)*(i+1)))%19/19*100);
YAHOO.util.Dom.setStyle(_1b6,"background-position",_1b7+"% "+_1b8+"%");
_1b1.appendChild(_1b6);
_1b3=(_1b3=="ct-black-square"+this.squareColorClass)?"ct-white-square"+this.squareColorClass:"ct-black-square"+this.squareColorClass;
}
_1b3=(_1b3=="ct-black-square"+this.squareColorClass)?"ct-white-square"+this.squareColorClass:"ct-black-square"+this.squareColorClass;
_1b2.appendChild(_1b1);
}
var _1b9=document.createElement("div");
_1b9.id=this.boardName+"-fileLabels";
_1af.appendChild(_1b2);
_1af.appendChild(_1b9);
_1ae.appendChild(_1af);
this.createBoardCoords();
var _1ba=YAHOO.util.Dom.get(this.boardName+"-ct-nav-container");
if(!_1ba){
_1ba=document.createElement("div");
}else{
_1ba.innerHTML="";
}
_1ba.id=this.boardName+"-ct-nav-container";
if(!this.dontOutputNavButtons){
var _1bb="";
if(!this.problem||!this.problem.isEndgame){
_1bb="<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 _1bc="<div class=\"ct-nav-buttons\" id=\""+this.boardName+"-navButtons\"><span id=\"nav-buttons-only\">";
_1bc+="<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")+"\"/>"+"<img class=\"ct-back\" id=\""+this.boardName+"-back\" 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\" src=\""+this.boardImagePath+"/images/resultset_next"+this.getVersString()+".gif\" alt=\""+_js("Next Move")+"\" title=\""+_js("Go forward a move")+"\"/>"+_1bb;
_1bc+="</span></div>";
_1ba.innerHTML=_1bc;
}
_1ae.appendChild(_1ba);
var body=YAHOO.util.Dom.get("body");
if(body){
YAHOO.util.Dom.setStyle(body,"min-width",((this.pieceSize*8+_1b0)+300+250)+"px");
}
};
Board.prototype.getPieceDiv=function(){
var _1be=this.getBoardDiv();
var _1bf=document.createElement("div");
this.availPieceDivs[this.uptoId]=_1bf;
this.availIds[this.uptoId]=YAHOO.util.Dom.generateId(_1bf);
YAHOO.util.Dom.setStyle(_1bf,"visibility","hidden");
_1be.appendChild(_1bf);
this.uptoId++;
return _1bf;
};
Board.prototype.flipToMove=function(_1c0){
return (_1c0=="w")?"b":"w";
};
Board.prototype.pieceCharToPieceNum=function(_1c1){
var _1c2;
switch(_1c1){
case "K":
_1c2=ChessPiece.KING;
break;
case "Q":
_1c2=ChessPiece.QUEEN;
break;
case "R":
_1c2=ChessPiece.ROOK;
break;
case "B":
_1c2=ChessPiece.BISHOP;
break;
case "N":
_1c2=ChessPiece.KNIGHT;
break;
case "P":
_1c2=ChessPiece.PAWN;
break;
}
return _1c2;
};
Board.prototype.pieceTypeToChar=function(_1c3){
switch(_1c3){
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(_1c4,_1c5,_1c6,_1c7){
if(_1c4+2==_1c6&&_1c5+1==_1c7){
return true;
}
if(_1c4+2==_1c6&&_1c5-1==_1c7){
return true;
}
if(_1c4-2==_1c6&&_1c5+1==_1c7){
return true;
}
if(_1c4-2==_1c6&&_1c5-1==_1c7){
return true;
}
if(_1c4+1==_1c6&&_1c5+2==_1c7){
return true;
}
if(_1c4-1==_1c6&&_1c5+2==_1c7){
return true;
}
if(_1c4+1==_1c6&&_1c5-2==_1c7){
return true;
}
if(_1c4-1==_1c6&&_1c5-2==_1c7){
return true;
}
return false;
};
Board.prototype.canMovePawn=function(_1c8,_1c9,_1ca,_1cb,_1cc){
var _1cd=this.boardPieces[_1ca][_1cb];
var _1ce=this.boardPieces[_1c8][_1c9];
if(_1cc){
var _1cf=this.boardPieces[_1cc.toColumn][_1cc.toRow];
if(_1cf.piece==ChessPiece.PAWN){
if(_1cf.colour==ChessPiece.WHITE){
if(_1cc.fromRow==1&&_1cc.toRow==3){
if(_1ca==_1cc.fromColumn&&_1c9==3&&_1cb==2&&(_1c8==_1ca+1||_1c8==_1ca-1)){
return true;
}
}
}else{
if(_1cc.fromRow==6&&_1cc.toRow==4){
if(_1ca==_1cc.fromColumn&&_1c9==4&&_1cb==5&&(_1c8==_1ca+1||_1c8==_1ca-1)){
return true;
}
}
}
}
}
if(_1cd){
if(_1ce.colour==ChessPiece.WHITE){
if((_1c8==_1ca+1||_1c8==_1ca-1)&&(_1c9==_1cb-1)){
return true;
}
}else{
if((_1c8==_1ca+1||_1c8==_1ca-1)&&(_1c9==_1cb+1)){
return true;
}
}
}else{
if(_1c8==_1ca){
if(_1ce.colour==ChessPiece.WHITE){
if(_1c9==1){
if(_1cb==2){
return true;
}else{
if(_1cb==3&&this.boardPieces[_1ca][2]==null){
return true;
}
}
}else{
if(_1c9+1==_1cb){
return true;
}
}
}else{
if(_1c9==6){
if(_1cb==5){
return true;
}else{
if(_1cb==4&&this.boardPieces[_1ca][5]==null){
return true;
}
}
}else{
if(_1c9-1==_1cb){
return true;
}
}
}
}
}
return false;
};
Board.prototype.canMoveStraight=function(_1d0,_1d1,_1d2,_1d3,_1d4,_1d5){
var _1d6=_1d0;
var _1d7=_1d1;
var _1d8=0;
var _1d9=0;
if(_1d2>_1d0){
_1d8=1;
}else{
if(_1d2<_1d0){
_1d8=-1;
}
}
if(_1d3>_1d1){
_1d9=1;
}else{
if(_1d3<_1d1){
_1d9=-1;
}
}
if(clog){
console.log("deltaRow:"+_1d9+" deltaCol:"+_1d8+" fromCol:"+_1d0+" fromRow:"+_1d1+" toCol:"+_1d2+" toRow:"+_1d3);
}
if(_1d4==ChessPiece.ROOK&&(_1d8!=0&&_1d9!=0)){
return false;
}
if(_1d4==ChessPiece.BISHOP&&(_1d8==0||_1d9==0)){
return false;
}
var _1da=0;
while(true){
_1da++;
_1d0+=_1d8;
_1d1+=_1d9;
if(_1d4==ChessPiece.KING&&_1da>1){
if(clog){
console.log("king count:"+_1da+" toCol:"+_1d2+" toRow:"+_1d3);
}
if(_1da!=2){
return false;
}
if(_1d9!=0){
return false;
}
if(!(_1d2==6||_1d2==2)){
return false;
}
if(_1d2==2){
if(this.boardPieces[1][_1d1]||this.boardPieces[2][_1d1]||this.boardPieces[3][_1d1]){
return false;
}
if(!this.canCastleQueenSide[_1d5.colour]){
return false;
}
}else{
if(_1d2==6){
if(this.boardPieces[5][_1d1]||this.boardPieces[6][_1d1]){
if(clog){
console.log("king can't castle intervening piece");
}
return false;
}
if(!this.canCastleKingSide[_1d5.colour]){
if(clog){
console.log("king can't castle king side (made previously invalid) colour:"+_1d5.colour);
}
return false;
}
}else{
if(clog){
console.log("king not in col 2 or 6");
}
return false;
}
}
var _1db="";
_1db+=Move.columnToChar(_1d6);
_1db+=String.fromCharCode("1".charCodeAt(0)+_1d7);
_1db+=Move.columnToChar((_1d6+_1d8));
_1db+=String.fromCharCode("1".charCodeAt(0)+(_1d7+_1d9));
var move=this.createMoveFromString(_1db);
var _1dd=this.boardPieces;
var _1de=this.toMove;
var _1df=this.saveCastling();
this.boardPieces=this.copyBoardPieces(true);
this.makeMove(move,this.boardPieces[_1d6][_1d7],false,this.moveAnimationLength,false,false);
this.restoreCastling(_1df);
kingSafe=this.isKingSafe(_1d5.colour,move);
boardPool.putObject(this.boardPieces);
this.boardPieces=_1dd;
_1dd.count--;
this.toMove=_1de;
if(clog){
console.log("kingSafe1:"+kingSafe);
}
if(!kingSafe){
return false;
}
var _1db="";
_1db+=Move.columnToChar(_1d6);
_1db+=String.fromCharCode("1".charCodeAt(0)+_1d7);
_1db+=Move.columnToChar(_1d6);
_1db+=String.fromCharCode("1".charCodeAt(0)+_1d7);
var move=this.createMoveFromString(_1db);
var _1dd=this.boardPieces;
var _1de=this.toMove;
var _1df=this.saveCastling();
this.boardPieces=this.copyBoardPieces(true);
this.makeMove(move,this.boardPieces[_1d6][_1d7],false,this.moveAnimationLength,false,false);
this.restoreCastling(_1df);
kingSafe=this.isKingSafe(_1d5.colour,move);
boardPool.putObject(this.boardPieces);
this.boardPieces=_1dd;
_1dd.count--;
this.toMove=_1de;
if(clog){
console.log("kingSafe2:"+kingSafe);
}
if(!kingSafe){
return false;
}
}
if(_1d0==_1d2&&_1d1==_1d3){
return true;
}
if(_1d0<0||_1d0>7||_1d1<0||_1d1>7){
return false;
}
if(this.boardPieces[_1d0][_1d1]!=null){
return false;
}
}
};
Board.prototype.canMove=function(_1e0,_1e1,_1e2,_1e3,_1e4){
var _1e5=_1e0.column;
var _1e6=_1e0.row;
if(_1e1>7||_1e1<0||_1e2>7||_1e2<0){
if(clog){
console.log("can't move coz out of bounds");
}
return false;
}
var _1e7=this.boardPieces[_1e1][_1e2];
var _1e8=this.boardPieces[_1e5][_1e6];
if(_1e8==null){
return false;
}
if(_1e7&&_1e7.colour==_1e8.colour){
return false;
}
var _1e9=false;
if(_1e0.piece==ChessPiece.PAWN){
_1e9=this.canMovePawn(_1e5,_1e6,_1e1,_1e2,_1e3);
}else{
if(_1e0.piece==ChessPiece.KNIGHT){
_1e9=this.canMoveKnight(_1e5,_1e6,_1e1,_1e2);
}else{
_1e9=this.canMoveStraight(_1e5,_1e6,_1e1,_1e2,_1e0.piece,_1e0);
}
}
if(clog){
console.log("moveOk:"+_1e9);
}
var _1ea=true;
if(_1e9&&_1e4){
var _1eb="";
_1eb+=Move.columnToChar(_1e5);
_1eb+=String.fromCharCode("1".charCodeAt(0)+_1e6);
_1eb+=Move.columnToChar(_1e1);
_1eb+=String.fromCharCode("1".charCodeAt(0)+_1e2);
var move=this.createMoveFromString(_1eb);
var _1ed=this.boardPieces;
var _1ee=this.toMove;
var _1ef=this.saveCastling();
this.boardPieces=this.copyBoardPieces(true);
if(clog){
console.log("in canMove about to make move:"+move.output()+" fromCol:"+_1e5+" fromRow:"+_1e6);
}
this.makeMove(move,this.boardPieces[_1e5][_1e6],false,this.moveAnimationLength,false,false);
this.restoreCastling(_1ef);
_1ea=this.isKingSafe(_1e0.colour,move);
boardPool.putObject(this.boardPieces);
this.boardPieces=_1ed;
_1ed.count--;
this.toMove=_1ee;
}
return _1e9&&_1ea;
};
Board.prototype.isKingMated=function(_1f0,_1f1){
var _1f2=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==_1f0){
_1f2=bp;
break;
}
}
}
var _1f6=[[1,0],[1,1],[1,-1],[-1,0],[-1,1],[-1,-1],[0,1],[0,-1],[2,0],[-2,0]];
var bp=_1f2;
for(var k=0;k<_1f6.length;k++){
if(this.canMove(bp,bp.column+_1f6[k][0],bp.row+_1f6[k][1],_1f1,true)){
return false;
}
}
var _1f8=this.getCandidateMoves(_1f0,_1f1,true,true);
if(_1f8.length>0){
return false;
}
return true;
};
Board.prototype.getCandidateMoves=function(_1f9,_1fa,_1fb,_1fc){
var _1fd=new Array();
for(var i=0;i<8;i++){
for(var j=0;j<8;j++){
var bp=this.boardPieces[i][j];
var _201=[];
if(!bp||bp.colour!=_1f9){
continue;
}
switch(bp.piece){
case ChessPiece.KING:
if(_1fc){
continue;
}
_201=[[1,0],[1,1],[1,-1],[-1,0],[-1,1],[-1,-1],[0,1],[0,-1],[2,0],[-2,0]];
break;
case ChessPiece.KNIGHT:
_201=[[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++){
_201.push([1+k,1+k]);
_201.push([1+k,-1-k]);
_201.push([-1-k,1+k]);
_201.push([-1-k,-1-k]);
}
break;
case ChessPiece.QUEEN:
for(var k=0;k<8;k++){
_201.push([1+k,0]);
_201.push([1+k,1+k]);
_201.push([1+k,-1-k]);
_201.push([-1-k,0]);
_201.push([-1-k,1+k]);
_201.push([-1-k,-1-k]);
_201.push([0,-1-k]);
_201.push([0,1+k]);
}
break;
case ChessPiece.ROOK:
for(var k=0;k<8;k++){
_201.push([1+k,0]);
_201.push([-1-k,0]);
_201.push([0,-1-k]);
_201.push([0,1+k]);
}
break;
case ChessPiece.PAWN:
_201=[[0,1],[0,-1],[1,1],[1,-1],[-1,1],[-1,-1]];
break;
}
for(var k=0;k<_201.length;k++){
if(this.canMove(bp,bp.column+_201[k][0],bp.row+_201[k][1],_1fa,true)){
_1fd.push(new Move(bp.column,bp.row,bp.column+_201[k][0],bp.row+_201[k][1]));
if(_1fb){
return _1fd;
}
}
}
}
}
return _1fd;
};
Board.prototype.isKingSafe=function(_203,_204){
var _205=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==_203){
_205=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!=_203){
if(this.canMove(bp,_205.column,_205.row,_204,false)){
return false;
}
}
}
}
return true;
};
Board.prototype.cloneBoard=function(){
var _209=new Board();
_209.boardPieces=this.copyBoardPieces(true);
_209.moveArray=this.copyMoveArray();
_209.canCastleQueenSide=this.copyCastleQueenSide();
_209.canCastleKingSide=this.copyCastleKingSide();
_209.toMove=this.toMove;
_209.opponentColour=this.opponentColour;
_209.isFlipped=this.isFlipped;
_209.isUserFlipped=this.isUserFlipped;
_209.ignoreFlipping=this.ignoreFlipping;
_209.reverseFlip=this.reverseFlip;
_209.moveAnimationLength=this.moveAnimationLength;
return _209;
};
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(){
var _20a=new Array();
if(this.moveArray.length>0){
_20a=this.moveArray.slice(0);
}
return _20a;
};
Board.prototype.copyBoardPieces=function(_20b){
var _20c=Board.createBoardArray();
for(var i=0;i<8;i++){
for(var j=0;j<8;j++){
if(this.boardPieces[i][j]!=null){
if(_20b){
_20c[i][j]=this.boardPieces[i][j].makeLightWeight();
}else{
_20c[i][j]=this.boardPieces[i][j].copyPiece();
}
}else{
_20c[i][j]=null;
}
}
}
return _20c;
};
Board.prototype.createPiece=function(_20f,_210,_211){
if(_211){
return new LightweightChessPiece(null,_20f,_210,this);
}else{
return new ChessPiece(this.getPieceDiv(),_20f,_210,this);
}
};
Board.prototype.restoreCastling=function(_212){
this.canCastleKingSide=_212.kingSide;
this.canCastleQueenSide=_212.queenSide;
};
Board.prototype.saveCastling=function(){
var _213=[this.canCastleQueenSide[0],this.canCastleQueenSide[1]];
var _214=[this.canCastleKingSide[0],this.canCastleKingSide[1]];
return {queenSide:_213,kingSide:_214};
};
Board.prototype.setupFromFen=function(fen,_216,flip,_218){
this.settingUpPosition=true;
var ua=navigator.userAgent.toLowerCase(),_21a=(ua.indexOf("opera")>-1),_21b=(ua.indexOf("safari")>-1),_21c=(!_21a&&!_21b&&ua.indexOf("gecko")>-1),isIE=(!_21a&&ua.indexOf("msie")>-1);
var _21e=fen.split(" ");
var _21f=_21e[0].split("/");
var _220=0;
var row=8;
this.uptoId=0;
this.board_xy=null;
var _222=_21e[2];
this.canCastleQueenSide=[false,false];
this.canCastleKingSide=[false,false];
if(_222!="-"){
if(_222.indexOf("K")>=0){
this.canCastleKingSide[ChessPiece.WHITE]=true;
}
if(_222.indexOf("Q")>=0){
this.canCastleQueenSide[ChessPiece.WHITE]=true;
}
if(_222.indexOf("k")>=0){
this.canCastleKingSide[ChessPiece.BLACK]=true;
}
if(_222.indexOf("q")>=0){
this.canCastleQueenSide[ChessPiece.BLACK]=true;
}
}
if(_21e[1]=="w"){
this.toMove=ChessPiece.WHITE;
this.opponentColour=ChessPiece.WHITE;
this.isFlipped=false;
}else{
this.toMove=ChessPiece.BLACK;
this.opponentColour=ChessPiece.BLACK;
this.isFlipped=true;
}
if(_216){
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=_21f[i];
row--;
_220=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 _229=this.boardPieces[_220][row];
this.boardPieces[_220][row]=null;
_220++;
}
}else{
var _22a=(c+"").toLowerCase().charAt(0);
var _22b=ChessPiece.WHITE;
if(_22a==c){
_22b=ChessPiece.BLACK;
}
var cp;
switch(_22a){
case "k":
cp=this.createPiece(_22b,ChessPiece.KING,_218);
break;
case "q":
cp=this.createPiece(_22b,ChessPiece.QUEEN,_218);
break;
case "r":
cp=this.createPiece(_22b,ChessPiece.ROOK,_218);
break;
case "b":
cp=this.createPiece(_22b,ChessPiece.BISHOP,_218);
break;
case "n":
cp=this.createPiece(_22b,ChessPiece.KNIGHT,_218);
break;
case "p":
cp=this.createPiece(_22b,ChessPiece.PAWN,_218);
break;
default:
}
if(_21c||_21a){
cp.setPosition(_220,row,false,null,this.moveAnimationLength);
cp.setVisible(true);
}
this.boardPieces[_220][row]=cp;
this.pieces[this.uptoPiece]=cp;
this.pieces[this.uptoPiece].column=_220;
this.pieces[this.uptoPiece].row=row;
this.uptoPiece++;
_220++;
}
}
}
if(!_21c){
for(var i=0;i<this.uptoPiece;i++){
this.pieces[i].setPosition(this.pieces[i].column,this.pieces[i].row,false,null,0);
}
}
if(!_218){
for(var i=0;i<this.uptoPiece;i++){
this.pieces[i].setVisible(true);
}
}
this.createBoardCoords();
this.settingUpPosition=false;
};
Board.prototype.resetMoveListScrollPosition=function(){
var _22d=this.movesDisplay.getMovesDisplay();
if(_22d){
var _22e=new YAHOO.util.Scroll(_22d,{scroll:{to:[0,0]}},0);
_22e.animate();
}
};
Board.prototype.changePieceSet=function(_22f,_230){
var ua=navigator.userAgent.toLowerCase();
var _232=(ua.indexOf("opera")>-1);
if(!this.showedIE6Warning){
alert(_js("Depending on your browser you may need to reload the\n page for piece size changes to properly take effect."));
}
this.showedIE6Warning=true;
if(check_bad_msie()){
if(!this.showedIE6Warning){
alert(_js("Internet Explorer version 6 does not support dynamic piece size changes.\n Please reload page to view new settings."));
}
this.showedIE6Warning=true;
return;
}
var _233=this.pieceSize;
this.pieceSet=_22f;
this.pieceSize=_230;
var _234=YAHOO.util.Dom.get(this.boardName+"-boardBorder");
var _235=0;
if(this.showCoordinates){
_235=15;
}
_234.className="";
YAHOO.util.Dom.addClass(_234,"ct-board-border"+this.squareColorClass);
YAHOO.util.Dom.setStyle(_234,"width",(this.pieceSize*8+_235)+"px");
YAHOO.util.Dom.setStyle(_234,"height",(this.pieceSize*8+_235)+"px");
var _236=YAHOO.util.Dom.get("ctb-"+this.boardName);
YAHOO.util.Dom.setStyle(_236,"width",(this.pieceSize*8)+"px");
YAHOO.util.Dom.setStyle(_236,"height",(this.pieceSize*8)+"px");
var _237="ct-white-square"+this.squareColorClass;
for(var i=7;i>=0;i--){
for(var j=0;j<8;j++){
var _23a=this[this.boardName+"-s"+j+""+i];
_23a.className="";
YAHOO.util.Dom.addClass(_23a,_237);
YAHOO.util.Dom.setStyle(_23a,"width",this.pieceSize+"px");
YAHOO.util.Dom.setStyle(_23a,"height",this.pieceSize+"px");
var _23b=(((j+1)*(i+1))%19/19*100);
var _23c=((65-((j+1)*(i+1)))%19/19*100);
YAHOO.util.Dom.setStyle(_23a,"background-position",_23b+"% "+_23c+"%");
_237=(_237=="ct-black-square"+this.squareColorClass)?"ct-white-square"+this.squareColorClass:"ct-black-square"+this.squareColorClass;
}
_237=(_237=="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){
var _23e=cp.div;
_23e.innerHTML="<img src=\""+cp.icon+"\"/>";
var img=_23e.firstChild;
if(!_232){
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){
var _23e=cp.div;
_23e.innerHTML="<img src=\""+cp.icon+"\"/>";
YAHOO.util.Dom.setStyle([cp.div],"position","relative");
var img=_23e.firstChild;
if(!_232){
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;
}
}
var body=YAHOO.util.Dom.get("body");
if(body){
YAHOO.util.Dom.setStyle(body,"min-width",((this.pieceSize*8+_235)+300+250)+"px");
}
this.createBoardCoords();
};
Board.prototype.forwardMove=function(e){
if(this.blockFowardBack||this.deferredBlockForwardBack){
if(clog){
console.log("returning early from forward due to block forward on");
}
return;
}
var _244=false;
if(this.tactics&&this.tactics.problemActive){
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(!_244){
this.problem.processEndgame("",true);
}
this.toggleToMove();
this.updateToPlay();
}else{
if(clog){
console.log("forwarding move:"+move.output());
}
var _245=null;
piece=this.boardPieces[move.fromColumn][move.fromRow];
if(move.promotion){
_245=move.promotion;
piece.prePromotionColumn=null;
piece.prePromotionRow=null;
}
this.updatePiece(piece,move.toColumn,move.toRow,true,true,false,_245,true);
this.toggleToMove();
this.updateToPlay();
var _246=this.currentMove;
if(this.problem&&_246){
var _247=false;
if(_246.bestMoves){
if(_246.bestMoves.length>0){
var bm=_246.bestMoves[0];
if(bm.score!="draw"&&bm.score==0){
if(clog){
console.log("move is mate");
}
_247=true;
}
}else{
_247=true;
}
}
if(_247&&_246.endNode){
this.problem.clearBestMoves();
}else{
this.problem.showBestMoves(_246,_246.bestMoves,_246.correctMove,_246.wrongMove);
}
}
}
}else{
if(clog){
console.log("already at end");
}
}
this.blockForwardBack=false;
};
Board.prototype.setupEventHandlers=function(){
this.timesLostFocus=0;
YAHOO.util.Event.addListener(document,"blur",this.lostFocus,this,true);
YAHOO.util.Event.addListener(document,"keydown",function(e){
var _24a=(e.target)?e.target:e.srcElement;
if(_24a.form){
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);
};
Board.prototype.flipBoard=function(){
this.isUserFlipped=!this.isUserFlipped;
this.isFlipped=!this.isFlipped;
this.redrawBoard();
};
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.highlightFromTo){
if(!this.isFlipped){
var _250=YAHOO.util.Dom.get(this.boardName+"-s"+this.lastFromColumn+""+this.lastFromRow);
var _251=YAHOO.util.Dom.get(this.boardName+"-s"+this.lastToColumn+""+this.lastToRow);
}else{
var _250=YAHOO.util.Dom.get(this.boardName+"-s"+(7-this.lastFromColumn)+""+(7-this.lastFromRow));
var _251=YAHOO.util.Dom.get(this.boardName+"-s"+(7-this.lastToColumn)+""+(7-this.lastToRow));
}
this.updateFromTo(_250,_251,this.lastFromRow,this.lastFromColumn,this.lastToRow,this.lastToColumn);
}
};
Board.prototype.gotoMoveIndex=function(_252,_253){
var _254=this.boardName+"-piecestaken";
var _255=YAHOO.util.Dom.get(_254);
if(_255){
_255.innerHTML="";
}
if(_252==-1){
var flip=false;
if(this.prev_move){
flip=true;
}
this.setupFromFen(this.startFen,flip,false,false);
if(this.prev_move){
this.makeMove(this.prev_move,this.boardPieces[this.prev_move.fromColumn][this.prev_move.fromRow],true,this.moveAnimationLength,true,true);
this.updateToPlay();
}
if(this.moveArray&&this.moveArray.length>0){
this.setCurrentMove(this.moveArray[0],_253);
}else{
this.setCurrentMove(this.firstMove,_253);
}
if(!_253){
this.setForwardBack();
}
return;
}
var _257=new Array();
var move=this.moveArray[_252];
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.next:"+move.prev.output());
}
}
var _259=0;
if(move.next!=null){
this.setCurrentMove(move.next,_253);
}else{
if(clog){
console.log("move next null with move:"+move.output());
}
}
while(move!=null){
_257[_259++]=move;
move=move.prev;
}
var flip=false;
if(this.prev_move){
flip=true;
}
this.setupFromFen(this.startFen,flip,false,true);
if(this.prev_move){
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=_259-1;i>=1;i--){
var move=_257[i];
this.makeMove(move,this.boardPieces[move.fromColumn][move.fromRow],false,this.moveAnimationLength,true,true);
this.toggleToMove();
}
if(!_253){
this.convertPiecesFromLightWeight(_252);
}
var move=_257[0];
this.makeMove(move,this.boardPieces[move.fromColumn][move.fromRow],true,this.moveAnimationLength,true,true);
this.toggleToMove();
this.updateToPlay();
if(!_253){
this.setForwardBack();
}
};
Board.prototype.gotoStart=function(e){
this.gotoMoveIndex(-1);
if(this.problem){
if(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.tactics&&this.tactics.problemActive){
this.tactics.autoForward=false;
this.tactics.markProblem(false,false,"NULL","NULL");
}
this.gotoMoveIndex(this.lastMoveIndex);
};
Board.prototype.playMove=function(self){
if(!self.keepPlayingMoves||!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 _25f=".vers"+SITE_VERSION;
if(!this.addVersion){
_25f="";
}
return _25f;
};
Board.prototype.playMoves=function(e){
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.backMove=function(e){
if(this.blockFowardBack||this.deferredBlockForwardBack){
return;
}
if(this.tactics){
if(this.tactics.problemActive){
return;
}
}
this.blockForwardBack=true;
YAHOO.util.Dom.removeClass(this.lastFromSquare,"ct-from-square");
YAHOO.util.Dom.removeClass(this.lastToSquare,"ct-to-square");
this.lastFromRow=null;
if(this.currentMove&&this.currentMove.prev!=null){
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);
var _264=false;
if(piece.piece==ChessPiece.KING&&Math.abs(move.fromColumn-move.toColumn)>1){
_264=true;
}
if(takenPiece&&!_264){
this.board_xy=null;
var _265=move.toColumn;
var _266=move.toRow;
if(piece.piece==ChessPiece.PAWN&&move.fromColumn!=move.toColumn&&takenPiece.enPassant){
_266=move.fromRow;
this.boardPieces[move.toColumn][move.toRow]=null;
}
takenPiece.setPosition(_265,_266,false,null,this.moveAnimationLength);
this.boardPieces[_265][_266]=takenPiece;
move.taken=null;
this.processTaken(takenPiece,false);
}else{
this.boardPieces[move.toColumn][move.toRow]=null;
}
if(_264){
var _267=move.toRow;
var _268;
var _269;
if(move.fromColumn>move.toColumn){
_268=0;
_269=3;
}else{
_268=7;
_269=5;
}
var _26a=this.boardPieces[_269][_267];
_26a.setPosition(_268,_267,true,null,this.moveAnimationLength);
this.boardPieces[_268][_267]=_26a;
}
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");
}
}
}
if(this.problem&&this.problem.isEndgame){
if(this.currentMove){
if(this.currentMove.bestMoves){
var cm=this.currentMove;
this.problem.showBestMoves(cm,cm.bestMoves,cm.correctMove,cm.wrongMove);
}
}else{
if(this.problem.initialBestMoves){
this.problem.showBestMoves(this.currentMove,this.problem.initialBestMoves,null,null);
}
}
}
this.setCurrentMove(move);
this.setForwardBack();
}
this.blockForwardBack=false;
};
Board.prototype.processTaken=function(_26c,_26d){
var _26e=this.boardName+"-piecestaken";
var _26f=YAHOO.util.Dom.get(_26e);
if(_26f){
if(_26d){
var _270=get_image_str(ChessPiece.pieceIconNames[_26c.colour][_26c.piece],this.boardImagePath,this.pieceSet,this.pieceTakenSize,this.addVersion);
_26f.innerHTML=_26f.innerHTML+"<img src=\""+_270+"\"/>";
}else{
var _271=_26f.innerHTML.split("<");
_26f.innerHTML="";
for(var i=1;i<_271.length-1;i++){
_26f.innerHTML=_26f.innerHTML+"<"+_271[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();



