Array.prototype.contains=function(b){if(Array.prototype.indexOf){return this.indexOf(b)!=-1}for(var a in this){if(this[a]==b){return true}}return false};Array.prototype.setLength=function(a,c){c=typeof c!="undefined"?c:null;for(var b=0;b<a;b++){this[b]=c}return this};Array.prototype.addDimension=function(a,d){d=typeof d!="undefined"?d:null;var b=this.length;for(var c=0;c<b;c++){this[c]=[].setLength(a,d)}return this};Array.prototype.first=function(){return this[0]};Array.prototype.last=function(){return this[this.length-1]};Array.prototype.copy=function(){var c=[];var a=this.length;for(var b=0;b<a;b++){if(this[b] instanceof Array){c[b]=this[b].copy()}else{c[b]=this[b]}}return c};if(!Array.prototype.map){Array.prototype.map=function(b){var a=this.length;if(typeof b!="function"){throw new TypeError()}var e=new Array(a);var d=arguments[1];for(var c=0;c<a;c++){if(c in this){e[c]=b.call(d,this[c],c,this)}}return e}}if(!Array.prototype.filter){Array.prototype.filter=function(b){var a=this.length;if(typeof b!="function"){throw new TypeError()}var e=new Array();var d=arguments[1];for(var c=0;c<a;c++){if(c in this){var f=this[c];if(b.call(d,f,c,this)){e.push(f)}}}return e}}if(!Array.prototype.forEach){Array.prototype.forEach=function(b){var a=this.length;if(typeof b!="function"){throw new TypeError()}var d=arguments[1];for(var c=0;c<a;c++){if(c in this){b.call(d,this[c],c,this)}}}}if(!Array.prototype.every){Array.prototype.every=function(b){var a=this.length;if(typeof b!="function"){throw new TypeError()}var d=arguments[1];for(var c=0;c<a;c++){if(c in this&&!b.call(d,this[c],c,this)){return false}}return true}}if(!Array.prototype.some){Array.prototype.some=function(b){var a=this.length;if(typeof b!="function"){throw new TypeError()}var d=arguments[1];for(var c=0;c<a;c++){if(c in this&&b.call(d,this[c],c,this)){return true}}return false}}Array.from=function(c){var a=[];for(var b=0;b<c.length;b++){a[b]=c[b]}return a};Function.prototype.bind=function(b){var a=this;var c=Array.from(arguments).slice(1);return function(){return a.apply(b,c.concat(Array.from(arguments)))}};eidogo=window.eidogo||{};(function(){var b=navigator.userAgent.toLowerCase();var a=(b.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1];eidogo.browser={ua:b,ver:a,ie:/msie/.test(b)&&!/opera/.test(b),moz:/mozilla/.test(b)&&!/(compatible|webkit)/.test(b),safari3:/webkit/.test(b)&&parseInt(a,10)>=420};eidogo.util={byId:function(c){return document.getElementById(c)},makeQueryString:function(g){var c="";if(g&&typeof g=="object"){var f=[];for(var e in g){if(g[e]&&g[e].constructor==Array){for(var d=0;d<g[e].length;d++){f.push(encodeURIComponent(e)+"="+encodeURIComponent(g[e]))}}else{f.push(encodeURIComponent(e)+"="+encodeURIComponent(g[e]))}}c=f.join("&").replace(/%20/g,"+")}return c},ajax:function(c,d,f,m,h,p,k){c=c.toUpperCase();var o=window.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();var j=(f&&typeof f=="object"?eidogo.util.makeQueryString(f):null);if(j&&c=="GET"){d+=(d.match(/\?/)?"&":"?")+j;j=null}o.open(c,d,true);if(j){o.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}var e=false;var i=/webkit/.test(navigator.userAgent.toLowerCase());function n(q){try{return !q.status&&location.protocol=="file:"||(q.status>=200&&q.status<300)||q.status==304||i&&q.status==undefined}catch(s){}return false}function g(q){if(!e&&o&&(o.readyState==4||q=="timeout")){e=true;if(l){clearInterval(l);l=null}var r=q=="timeout"&&"timeout"||!n(o)&&"error"||"success";if(r=="success"){m.call(p,o)}else{h.call(p)}o=null}}var l=setInterval(g,13);if(k){setTimeout(function(){if(o){o.abort();if(!e){g("timeout")}}},k)}o.send(j);return o},addEventHelper:function(d,f,e){if(d.addEventListener){d.addEventListener(f,e,false)}else{if(!eidogo.util.addEventId){eidogo.util.addEventId=1}if(!e.$$guid){e.$$guid=eidogo.util.addEventId++}if(!d.events){d.events={}}var c=d.events[f];if(!c){c=d.events[f]={};if(d["on"+f]){c[0]=d["on"+f]}}c[e.$$guid]=e;d["on"+f]=eidogo.util.handleEvent}},handleEvent:function(f){var e=true;f=f||((this.ownerDocument||this.document||this).parentWindow||window).event;var c=this.events[f.type];for(var d in c){this.$$handleEvent=c[d];if(this.$$handleEvent(f)===false){e=false}}return e},addEvent:function(h,f,g,c,e){if(!h){return}if(e){g=g.bind(c)}else{if(c){var d=g;g=function(i){d(i,c)}}}eidogo.util.addEventHelper(h,f,g)},onClick:function(e,d,c){eidogo.util.addEvent(e,"click",d,c,true)},getElClickXY:function(h,d,f){var g=d.ownerDocument;if(!h.pageX){h.pageX=h.clientX+(g.documentElement.scrollLeft||g.body.scrollLeft);h.pageY=h.clientY+(g.documentElement.scrollTop||g.body.scrollTop)}var c=eidogo.util.getElXY(d,f);return[h.pageX-c[0],h.pageY-c[1]]},stopEvent:function(c){if(!c){return}if(c.stopPropagation){c.stopPropagation()}else{c.cancelBubble=true}if(c.preventDefault){c.preventDefault()}else{c.returnValue=false}},getTarget:function(d){var c=d.target||d.srcElement;return(c&&c.nodeName&&c.nodeName.toUpperCase()=="#TEXT")?c.parentNode:c},addClass:function(f,d){if(!d){return}var c=d.split(/\s+/);for(var e=0;e<c.length;e++){if(!eidogo.util.hasClass(f,c[e])){f.className+=(f.className?" ":"")+c[e]}}},removeClass:function(f,d){var c=f.className.split(/\s+/);var g=[];for(var e=0;e<c.length;e++){if(c[e]!=d){g.push(c[e])}}f.className=g.join(" ")},hasClass:function(f,d){var c=f.className.split(/\s+/);for(var e=0;e<c.length;e++){if(c[e]==d){return true}}return false},show:function(c,d){d=d||"block";if(typeof c=="string"){c=eidogo.util.byId(c)}if(!c){return}c.style.display=d},hide:function(c){if(typeof c=="string"){c=eidogo.util.byId(c)}if(!c){return}c.style.display="none"},getElXY:function(c,e){var d=c,g=0,f=0,l=c.parentNode,j=0,i=0,k=c.ownerDocument;if(c.getBoundingClientRect){var h=c.getBoundingClientRect();g=h.left+Math.max(k.documentElement.scrollLeft,k.body.scrollLeft);f=h.top+Math.max(k.documentElement.scrollTop,k.body.scrollTop)}else{while(d){g+=d.offsetLeft;f+=d.offsetTop;d=d.offsetParent?d.offsetParent:null}while(!e&&l&&l.tagName&&!/^body|html$/i.test(l.tagName)){j+=l.scrollLeft;i+=l.scrollTop;g-=l.scrollLeft;f-=l.scrollTop;l=l.parentNode}}return[g,f,j,i]},getElX:function(c){return this.getElXY(c)[0]},getElY:function(c){return this.getElXY(c)[1]},addStyleSheet:function(c){if(document.createStyleSheet){document.createStyleSheet(c)}else{var d=document.createElement("link");d.rel="stylesheet";d.type="text/css";d.href=c;document.getElementsByTagName("head")[0].appendChild(d)}},getPlayerPath:function(){var c=document.getElementsByTagName("script");var e;var d;for(var f=0;d=c[f];f++){if(/(all\.compressed\.js|eidogo\.js)/.test(d.src)){e=d.src.replace(/\/js\/[^\/]+$/,"")}}return e},numProperties:function(e){var d=0;for(var c in e){d++}return d}}})();eidogo=window.eidogo||{};eidogo.i18n=eidogo.i18n||{move:"Move",loading:"Loading",passed:"passed",resigned:"resigned",variations:"Variations",movetype:"Type","no variations":"none","ideal move":"Ideal Move","good move":"Good Move","bad move":"Bad Move","trick move":"Trick Move","question move":"Question","ideal move btn":"Ideal","good move btn":"Good","bad move btn":"Bad","trick move btn":"Trick","question move btn":"Question","saving msg":"Saving to server...",tool:"Tool",view:"Jump to Move",play:"Play",region:"Select Region",add_b:"Black Stone",add_w:"White Stone","edit comment":"Edit Comment","edit game info":"Edit Game Info",done:"Done",triangle:"Triangle",square:"Square",circle:"Circle",x:"X",letter:"Letter",number:"Number",label:"Custom Label",dim:"Dim",clear:"Clear Marker",score:"Score","score est":"Score Estimate",search:"Search","search corner":"Corner Search","search center":"Center Search","region info":"Click and drag to select a region.","two stones":"Please select at least two stones to search for.","two edges":"For corner searches, your selection must touch two adjacent edges of the board.","no search url":"No search URL provided.","close search":"close search","matches found":"matches found.","show games":"Show pro games with this position","save to server":"Save to Server","download sgf":"Download SGF","multi-game sgf":"Multi-game SGF: ","next game":"Next Game","previous game":"Previous Game","end of variation":"End of variation",white:"White","white rank":"White rank","white team":"White team",black:"Black","black rank":"Black rank","black team":"Black team",captures:"captures","time left":"time left",you:"You",game:"Game",handicap:"Handicap",komi:"Komi",result:"Result",date:"Date",info:"Info",place:"Place",event:"Event",round:"Round",overtime:"Overtime",opening:"Openning",ruleset:"Ruleset",annotator:"Annotator",copyright:"Copyright",source:"Source","time limit":"Time limit",transcriber:"Transcriber","created with":"Created with",january:"January",february:"February",march:"March",april:"April",may:"May",june:"June",july:"July",august:"August",september:"September",october:"October",november:"November",december:"December",gw:"Good for White",vgw:"Very good for White",gb:"Good for Black",vgb:"Very good for Black",dm:"Even position",dmj:"Even position (joseki)",uc:"Unclear position",te:"Tesuji",bm:"Bad move",vbm:"Very bad move","do":"Doubtful move",it:"Interesting move","black to play":"Black to play","white to play":"White to play",ho:"Hotspot","confirm delete":"You've removed all properties from this position.\n\nDelete this position and all sub-positions?","position deleted":"Position deleted","dom error":"Error finding DOM container","error retrieving":"There was a problem retrieving the game data.","invalid data":"Received invalid game data","error board":"Error loading board container","unsaved changes":"There are unsaved changes in this game. You must save before you can permalink or download.","bad path":"Don't know how to get to path: ","gnugo thinking":"GNU Go is thinking..."};eidogo.gameNodeIdCounter=100000;eidogo.GameNode=function(){this.init.apply(this,arguments)};eidogo.GameNode.prototype={init:function(c,b,d){this._id=(typeof d!="undefined"?d:eidogo.gameNodeIdCounter++);this._parent=c||null;this._children=[];this._preferredChild=0;this._myVote=[];for(var a=0;a<5;a++){this._myVote[a]=0}this._votes=[];for(var a=0;a<5;a++){this._votes[a]=[0,0]}if(b){this.loadJson(b)}},pushProperty:function(b,a){if(this[b]){if(!(this[b] instanceof Array)){this[b]=[this[b]]}if(!this[b].contains(a)){this[b].push(a)}}else{this[b]=a}},hasPropertyValue:function(c,b){if(!this[c]){return false}var a=(this[c] instanceof Array?this[c]:[this[c]]);return a.contains(b)},deletePropertyValue:function(e,c){var d=(c instanceof RegExp)?function(f){return c.test(f)}:function(f){return c==f};var b=(e instanceof Array?e:[e]);for(var a=0;e=b[a];a++){if(this[e] instanceof Array){this[e]=this[e].filter(function(f){return !d(f)});if(!this[e].length){delete this[e]}}else{if(d(this.prop)){delete this[e]}}}},loadJson:function(e){var f=[e],g=[this];var d,b;var c,a;while(f.length){d=f.pop();b=g.pop();b.loadJsonNode(d);a=(d._children?d._children.length:0);for(c=0;c<a;c++){f.push(d._children[c]);if(!b._children[c]){b._children[c]=new eidogo.GameNode(b)}g.push(b._children[c])}}},loadJsonNode:function(e){for(var g in e){if(g=="_id"){this[g]=e[g].toString();eidogo.gameNodeIdCounter=Math.max(eidogo.gameNodeIdCounter,parseInt(e[g],10));continue}if(g=="_mtype"){this[g]=e[g]}else{if(g=="_labels"){this["_labelids"]=e[g]}else{if(g=="_contins"){this["_continuationcount"]=e[g]}else{if(g=="_sources"){this["_sources"]=e[g]}else{if(g=="_talkCount"){this["_talkCount"]=e[g]}else{if(g=="_alllangs"){this["_alllangs"]=e[g]}else{if(g=="_lock"){this["_nodelock"]=e[g]}else{if(g=="_metalock"){this["_metalock"]=e[g]}else{if(g=="_ghosts"){this["_ghosts"]=e[g]}else{if(g=="_lang"){this["_lang"]=e[g]}else{if(g=="_myvotes"){for(var c=0;c<e[g].length;c++){var f=e[g][c][0];var a=e[g][c][1];this["_myVote"][f]=a}}else{if(g=="_votes"){for(var c=0;c<e[g].length;c++){var f=e[g][c][0];var b=e[g][c][1];var d=e[g][c][2];this["_votes"][f]=[b,d]}}else{if(g.charAt(0)!="_"){this[g]=e[g]}}}}}}}}}}}}}}},appendChild:function(a){a._parent=this;this._children.push(a)},getProperties:function(){var c={},d,e,a,b;for(d in this){isPrivate=(d.charAt(0)=="_");a=(typeof this[d]=="string");b=(this[d] instanceof Array);if(!isPrivate&&(a||b)){c[d]=this[d]}}return c},walk:function(d,f){var b=[this];var e;var c,a;while(b.length){e=b.pop();d.call(f||this,e);a=(e._children?e._children.length:0);for(c=0;c<a;c++){b.push(e._children[c])}}},getMove:function(){if(typeof this.W!="undefined"){return this.W}else{if(typeof this.B!="undefined"){return this.B}}return null},emptyPoint:function(d){var b=this.getProperties();var a=null;for(var c in b){if(c=="AW"||c=="AB"||c=="AE"){if(!(this[c] instanceof Array)){this[c]=[this[c]]}this[c]=this[c].filter(function(e){if(e==d){a=e;return false}return true});if(!this[c].length){delete this[c]}}else{if((c=="B"||c=="W")&&this[c]==d){a=this[c];delete this[c]}}}return a},getPosition:function(){if(!this._parent){return null}var b=this._parent._children;for(var a=0;a<b.length;a++){if(b[a]._id==this._id){return a}}return null},toSgf:function(){var c=(this._parent?"(":"");var b=this;function d(f){if(!f){return""}var g=";",e,h;for(e in f){if(f[e] instanceof Array){h=f[e].map(function(i){return i.toString().replace(/\]/g,"\\]")}).join("][")}else{h=f[e].toString().replace(/\]/g,"\\]")}g+=e+"["+h+"]"}return g}c+=d(b.getProperties());while(b._children.length==1){b=b._children[0];c+=d(b.getProperties())}for(var a=0;a<b._children.length;a++){c+=b._children[a].toSgf()}c+=(this._parent?")":"");return c}};eidogo.GameCursor=function(){this.init.apply(this,arguments)};eidogo.GameCursor.prototype={init:function(a){this.node=a},next:function(a){if(!this.hasNext()){return false}a=(typeof a=="undefined"||a==null?this.node._preferredChild:a);this.node._preferredChild=a;this.node=this.node._children[a];return true},previous:function(){if(!this.hasPrevious()){return false}this.node=this.node._parent;return true},hasNext:function(){return this.node&&this.node._children.length},hasPrevious:function(){return this.node&&this.node._parent&&this.node._parent._parent},getNextMoves:function(){if(!this.hasNext()){return null}var a={};var b,c;for(b=0;c=this.node._children[b];b++){a[c.getMove()]=b}return a},getNextColor:function(){if(!this.hasNext()){return null}var a,b;for(var a=0;b=this.node._children[a];a++){if(b.W||b.B){return b.W?"W":"B"}}return null},getNextNodeWithVariations:function(){var a=this.node;while(a._children.length==1){a=a._children[0]}return a},getPath:function(){var c=this.node,b=[],a=0;while(c&&c._parent&&c._parent._children.length==1&&c._parent._parent){a++;c=c._parent}b.push(a);while(c){if(c._parent&&(c._parent._children.length>1||!c._parent._parent)){b.push(c.getPosition()||0)}c=c._parent}return b.reverse()},getPathMoves:function(){var b=[];var c=new eidogo.GameCursor(this.node);b.push(c.node.getMove());while(c.previous()){var a=c.node.getMove();if(a){b.push(a)}}return b.reverse()},getMoveNumber:function(){var a=0,b=this.node;while(b){if(b.W||b.B){a++}b=b._parent}return a},getGameRoot:function(){if(!this.node){return null}var a=new eidogo.GameCursor(this.node);if(!this.node._parent&&this.node._children.length){return this.node._children[0]}while(a.previous()){}return a.node}};eidogo.SgfParser=function(){this.init.apply(this,arguments)};eidogo.SgfParser.prototype={init:function(b,a){a=(typeof a=="function")?a:null;this.sgf=b;this.index=0;this.root={_children:[]};this.parseTree(this.root);a&&a.call(this)},parseTree:function(a){while(this.index<this.sgf.length){var b=this.curChar();this.index++;switch(b){case";":a=this.parseNode(a);break;case"(":this.parseTree(a);break;case")":return;break}}},parseNode:function(a){var b={_children:[]};if(a){a._children.push(b)}else{this.root=b}b=this.parseProperties(b);return b},parseProperties:function(e){var d="";var a=[];var b=0;while(this.index<this.sgf.length){var f=this.curChar();if(f==";"||f=="("||f==")"){break}if(this.curChar()=="["){while(this.curChar()=="["){this.index++;a[b]="";while(this.curChar()!="]"&&this.index<this.sgf.length){if(this.curChar()=="\\"){this.index++;while(this.curChar()=="\r"||this.curChar()=="\n"){this.index++}}a[b]+=this.curChar();this.index++}b++;while(this.curChar()=="]"||this.curChar()=="\n"||this.curChar()=="\r"){this.index++}}if(e[d]){if(!(e[d] instanceof Array)){e[d]=[e[d]]}e[d]=e[d].concat(a)}else{e[d]=a.length>1?a:a[0]}d="";a=[];b=0;continue}if(f!=" "&&f!="\n"&&f!="\r"&&f!="\t"){d+=f}this.index++}return e},curChar:function(){return this.sgf.charAt(this.index)}};eidogo.Board=function(){this.init.apply(this,arguments)};eidogo.Board.prototype={WHITE:1,BLACK:-1,EMPTY:0,init:function(b,a){this.boardSize=a||19;this.stones=this.makeBoardArray(this.EMPTY);this.markers=this.makeBoardArray(this.EMPTY);this.captures={};this.captures.W=0;this.captures.B=0;this.cache=[];this.renderer=b||new eidogo.BoardRendererHtml();this.lastRender={stones:this.makeBoardArray(null),markers:this.makeBoardArray(null)}},reset:function(){this.init(this.renderer,this.boardSize)},clear:function(){this.clearStones();this.clearMarkers();this.clearCaptures()},clearStones:function(){for(var a=0;a<this.stones.length;a++){this.stones[a]=this.EMPTY}},clearMarkers:function(){for(var a=0;a<this.markers.length;a++){this.markers[a]=this.EMPTY}},clearCaptures:function(){this.captures.W=0;this.captures.B=0},makeBoardArray:function(a){return[].setLength(this.boardSize*this.boardSize,a)},commit:function(){this.cache.push({stones:this.stones.concat(),captures:{W:this.captures.W,B:this.captures.B}})},rollback:function(){if(this.cache.last()){this.stones=this.cache.last().stones.concat();this.captures.W=this.cache.last().captures.W;this.captures.B=this.cache.last().captures.B}else{this.clear()}},revert:function(a){a=a||1;this.rollback();for(var b=0;b<a;b++){this.cache.pop()}this.rollback()},addStone:function(b,a){this.stones[b.y*this.boardSize+b.x]=a},getStone:function(a){return this.stones[a.y*this.boardSize+a.x]},getRegion:function(d,c,b,e){var f=[].setLength(b*e,this.EMPTY);var g;for(var i=d;i<d+e;i++){for(var a=c;a<c+b;a++){g=(i-d)*b+(a-c);f[g]=this.getStone({x:a,y:i})}}return f},addMarker:function(b,a){this.markers[b.y*this.boardSize+b.x]=a},getMarker:function(a){return this.markers[a.y*this.boardSize+a.x]},render:function(a){var l=this.makeBoardArray(null);var d=this.makeBoardArray(null);var b,g;var f;if(!a&&this.cache.last()){var k=this.cache.last();f=this.stones.length;for(var e=0;e<f;e++){if(k.stones[e]!=this.lastRender.stones[e]){l[e]=k.stones[e]}}d=this.markers}else{l=this.stones;d=this.markers}var c;for(var j=0;j<this.boardSize;j++){for(var h=0;h<this.boardSize;h++){c=h*this.boardSize+j;if(d[c]!=null){this.renderer.renderMarker({x:j,y:h},d[c]);this.lastRender.markers[c]=d[c]}if(l[c]==null){continue}else{if(l[c]==this.EMPTY){b="empty"}else{b=(l[c]==this.WHITE?"white":"black")}}this.renderer.renderStone({x:j,y:h},b);this.lastRender.stones[c]=l[c]}}}};eidogo.BoardRendererHtml=function(){this.init.apply(this,arguments)};eidogo.BoardRendererHtml.prototype={init:function(a,h,c,g){if(!a){throw"No DOM container";return}this.boardSize=h||19;var f=document.createElement("div");f.className="board-gutter"+(this.boardSize==19?" with-coords":"");a.appendChild(f);var b=document.createElement("div");b.className="board size"+this.boardSize;b.style.position=(g&&eidogo.browser.ie?"static":"relative");f.appendChild(b);this.domNode=b;this.domGutter=f;this.domContainer=a;this.player=c;this.uniq=a.id+"-";this.renderCache={stones:[].setLength(this.boardSize,0).addDimension(this.boardSize,0),markers:[].setLength(this.boardSize,0).addDimension(this.boardSize,0)};this.pointWidth=0;this.pointHeight=0;this.margin=0;var e=this.renderStone({x:0,y:0},"black");this.pointWidth=e.offsetWidth;this.pointHeight=e.offsetWidth;if(this.pointHeight!=19){}if(this.pointHeight>100){this.pointHeight=19;this.pointWidth=19}this.renderStone({x:0,y:0},"white");this.renderMarker({x:0,y:0},"current");this.clear();this.margin=(this.domNode.offsetWidth-(this.boardSize*this.pointWidth))/2;if(this.margin>100){this.margin=5}this.scrollX=0;this.scrollY=0;if(g){this.crop(g);if(eidogo.browser.ie){var d=this.domNode.parentNode;while(d&&d.tagName&&!/^body|html$/i.test(d.tagName)){this.scrollX+=d.scrollLeft;this.scrollY+=d.scrollTop;d=d.parentNode}}}this.dom={};this.dom.searchRegion=document.createElement("div");this.dom.searchRegion.id=this.uniq+"search-region";this.dom.searchRegion.className="search-region";this.domNode.appendChild(this.dom.searchRegion);eidogo.util.addEvent(this.domNode,"mousemove",this.handleHover,this,true);eidogo.util.addEvent(this.domNode,"mousedown",this.handleMouseDown,this,true);eidogo.util.addEvent(this.domNode,"mouseup",this.handleMouseUp,this,true)},showRegion:function(a){this.dom.searchRegion.style.top=(this.margin+this.pointHeight*a[0])+"px";this.dom.searchRegion.style.left=(this.margin+this.pointWidth*a[1])+"px";this.dom.searchRegion.style.width=this.pointWidth*a[2]+"px";this.dom.searchRegion.style.height=this.pointHeight*a[3]+"px";eidogo.util.show(this.dom.searchRegion)},hideRegion:function(){eidogo.util.hide(this.dom.searchRegion)},clear:function(){this.domNode.innerHTML=""},renderStone:function(d,a){var b=document.getElementById(this.uniq+"stone-"+d.x+"-"+d.y);if(b){b.parentNode.removeChild(b)}if(a!="empty"){var f=document.createElement("div");f.id=this.uniq+"stone-"+d.x+"-"+d.y;f.className="point stone "+a;try{f.style.left=(d.x*this.pointWidth+this.margin-this.scrollX)+"px";f.style.top=(d.y*this.pointHeight+this.margin-this.scrollY)+"px"}catch(c){}this.domNode.appendChild(f);return f}return null},renderMarker:function(j,g){if(this.renderCache.markers[j.x][j.y]){var c=document.getElementById(this.uniq+"marker-"+j.x+"-"+j.y);if(c){c.parentNode.removeChild(c)}}if(g=="empty"||!g){this.renderCache.markers[j.x][j.y]=0;return null}this.renderCache.markers[j.x][j.y]=1;if(g){var i="";var b="";switch(g){case"triangle":case"square":case"circle":case"ex":case"territory-white":case"territory-black":case"dim":case"current":break;default:if(g.indexOf("var:")==0){i=g.substring(4);var d=i.indexOf(":");if(d>=0){b=i.substring(d+1);i=i.substring(0,d)}g="variation"}else{if(g.indexOf("ghost:")==0){b=g.substring(6)+" mtghost";i="x";g="variation"}else{i=g;g="label"}}break}var a=document.createElement("div");a.id=this.uniq+"marker-"+j.x+"-"+j.y;var h="point marker "+g;if(b!=""){h+=" mt"+b}a.className=h;try{a.style.left=(j.x*this.pointWidth+this.margin-this.scrollX)+"px";a.style.top=(j.y*this.pointHeight+this.margin-this.scrollY)+"px"}catch(f){}a.appendChild(document.createTextNode(i));this.domNode.appendChild(a);return a}return null},setCursor:function(a){this.domNode.style.cursor=a},handleHover:function(b){var a=this.getXY(b);this.player.handleBoardHover(a[0],a[1],a[2],a[3],b)},handleMouseDown:function(b){var a=this.getXY(b);this.player.handleBoardMouseDown(a[0],a[1],a[2],a[3],b)},handleMouseUp:function(b){var a=this.getXY(b);this.player.handleBoardMouseUp(a[0],a[1])},getXY:function(f){var c=eidogo.util.getElClickXY(f,this.domNode);var b=this.margin;var d=this.pointWidth;var g=this.pointHeight;var a=Math.round((c[0]-b-(d/2))/d);var h=Math.round((c[1]-b-(g/2))/g);return[a,h,c[0],c[1]]},crop:function(c){eidogo.util.addClass(this.domContainer,"shrunk");this.domGutter.style.overflow="hidden";var b=c.width*this.pointWidth+(this.margin*2);var a=c.height*this.pointHeight+(this.margin*2);this.domGutter.style.width=b+"px";this.domGutter.style.height=a+"px";this.player.dom.player.style.width=b+"px";this.domGutter.scrollLeft=c.left*this.pointWidth;this.domGutter.scrollTop=c.top*this.pointHeight}};eidogo.BoardRendererFlash=function(){this.init.apply(this,arguments)};eidogo.BoardRendererFlash.prototype={init:function(b,g,e,f){if(!b){throw"No DOM container";return}this.ready=false;this.swf=null;this.unrendered=[];var d=b.id+"-board";var h=new SWFObject(eidogo.playerPath+"/swf/board.swf",d,"421","421","8","#665544");h.addParam("allowScriptAccess","sameDomain");h.write(b);var a=0;var c=function(){swf=eidogo.util.byId(d);if(!swf||!swf.init){if(a>2000){throw"Error initializing board";return}setTimeout(arguments.callee.bind(this),10);a+=10;return}this.swf=swf;this.swf.init(e.uniq,g);this.ready=true}.bind(this);c()},showRegion:function(a){},hideRegion:function(){},clear:function(){if(!this.swf){return}this.swf.clear()},renderStone:function(c,a){if(!this.swf){this.unrendered.push(["stone",c,a]);return}for(var b=0;b<this.unrendered.length;b++){if(this.unrendered[b][0]=="stone"){this.swf.renderStone(this.unrendered[b][1],this.unrendered[b][2])}}this.unrendered=[];this.swf.renderStone(c,a)},renderMarker:function(c,b){if(!b){return}if(!this.swf){this.unrendered.push(["marker",c,b]);return}for(var a=0;a<this.unrendered.length;a++){if(this.unrendered[a][0]=="marker"){this.swf.renderMarker(this.unrendered[a][1],this.unrendered[a][2])}}this.unrendered=[];this.swf.renderMarker(c,b)},setCursor:function(a){},crop:function(){}};eidogo.BoardRendererAscii=function(a,b){this.init(a,b)};eidogo.BoardRendererAscii.prototype={pointWidth:2,pointHeight:1,margin:1,blankBoard:"+-------------------------------------+\n|. . . . . . . . . . . . . . . . . . .|\n|. . . . . . . . . . . . . . . . . . .|\n|. . . . . . . . . . . . . . . . . . .|\n|. . . . . . . . . . . . . . . . . . .|\n|. . . . . . . . . . . . . . . . . . .|\n|. . . . . . . . . . . . . . . . . . .|\n|. . . . . . . . . . . . . . . . . . .|\n|. . . . . . . . . . . . . . . . . . .|\n|. . . . . . . . . . . . . . . . . . .|\n|. . . . . . . . . . . . . . . . . . .|\n|. . . . . . . . . . . . . . . . . . .|\n|. . . . . . . . . . . . . . . . . . .|\n|. . . . . . . . . . . . . . . . . . .|\n|. . . . . . . . . . . . . . . . . . .|\n|. . . . . . . . . . . . . . . . . . .|\n|. . . . . . . . . . . . . . . . . . .|\n|. . . . . . . . . . . . . . . . . . .|\n|. . . . . . . . . . . . . . . . . . .|\n|. . . . . . . . . . . . . . . . . . .|\n+-------------------------------------+",init:function(a,b){this.domNode=a||null;this.boardSize=b||19;this.content=this.blankBoard},clear:function(){this.content=this.blankBoard;this.domNode.innerHTML="<pre>"+this.content+"</pre>"},renderStone:function(b,a){var c=(this.pointWidth*this.boardSize+this.margin*2)*(b.y*this.pointHeight+1)+(b.x*this.pointWidth)+2;this.content=this.content.substring(0,c-1)+"."+this.content.substring(c);if(a!="empty"){this.content=this.content.substring(0,c-1)+(a=="white"?"O":"#")+this.content.substring(c)}this.domNode.innerHTML="<pre>"+this.content+"</pre>"},renderMarker:function(b,a){}};eidogo.Rules=function(a){this.init(a)};eidogo.Rules.prototype={init:function(a){this.board=a;this.pendingCaptures=[]},check:function(b,a){if(this.board.getStone(b)!=this.board.EMPTY){return false}return true},apply:function(b,a){this.doCaptures(b,a)},doCaptures:function(c,b){var a=0;a+=this.doCapture({x:c.x-1,y:c.y},b);a+=this.doCapture({x:c.x+1,y:c.y},b);a+=this.doCapture({x:c.x,y:c.y-1},b);a+=this.doCapture({x:c.x,y:c.y+1},b);a-=this.doCapture(c,-b);if(a<0){b=-b;a=-a}b=b==this.board.WHITE?"W":"B";this.board.captures[b]+=a},doCapture:function(c,a){this.pendingCaptures=[];if(this.findCaptures(c,a)){return 0}var b=this.pendingCaptures.length;while(this.pendingCaptures.length){this.board.addStone(this.pendingCaptures.pop(),this.board.EMPTY)}return b},findCaptures:function(c,a){if(c.x<0||c.y<0||c.x>=this.board.boardSize||c.y>=this.board.boardSize){return 0}if(this.board.getStone(c)==a){return 0}if(this.board.getStone(c)==this.board.EMPTY){return 1}for(var b=0;b<this.pendingCaptures.length;b++){if(this.pendingCaptures[b].x==c.x&&this.pendingCaptures[b].y==c.y){return 0}}this.pendingCaptures.push(c);if(this.findCaptures({x:c.x-1,y:c.y},a)){return 1}if(this.findCaptures({x:c.x+1,y:c.y},a)){return 1}if(this.findCaptures({x:c.x,y:c.y-1},a)){return 1}if(this.findCaptures({x:c.x,y:c.y+1},a)){return 1}return 0}};(function(){if(!Array.prototype.indexOf){Array.prototype.indexOf=function(elt){var n=this.length;for(var i=0;i<n;++i){if(i in this&&this[i]===elt){return i}}return -1}}var t=eidogo.i18n,byId=eidogo.util.byId,ajax=eidogo.util.ajax,addEvent=eidogo.util.addEvent,onClick=eidogo.util.onClick,getElClickXY=eidogo.util.getElClickXY,stopEvent=eidogo.util.stopEvent,addClass=eidogo.util.addClass,removeClass=eidogo.util.removeClass,show=eidogo.util.show,hide=eidogo.util.hide,isMoz=eidogo.browser.moz,playerPath=eidogo.util.getPlayerPath();eidogo.players=eidogo.players||{};eidogo.delegate=function(pid,fn){var player=eidogo.players[pid];player[fn].apply(player,Array.from(arguments).slice(2))};eidogo.Player=function(){this.init.apply(this,arguments)};eidogo.Player.prototype={init:function(cfg){cfg=cfg||{};this.mode=cfg.mode?cfg.mode:"play";this.editMode=false;this.histMode=false;this.talkMode=false;this.viewGhosts=false;this.dom={};this.dom.container=(typeof cfg.container=="string"?byId(cfg.container):cfg.container);if(!this.dom.container){alert(t["dom error"]);return}this.uniq=0;this.doneEditWarning=false;this.regexpPosition=/\[([a-zA-Z]\d{1,2})\]/;this.regexpSource=/\[src:([\w\s,.]+)\]/;this.regexpPath=/\[path:([a-z]+)\]/;this.regexpHttp=/\[(http:[!\]]+)\]/;eidogo.players[this.uniq]=this;this.sgfPath=cfg.sgfPath;this.searchUrl=cfg.searchUrl;this.showingSearch=false;this.saveUrl=cfg.saveUrl;this.downloadUrl=cfg.downloadUrl;this.scoreEstUrl=cfg.scoreEstUrl;this.hooks=cfg.hooks||{};this.permalinkable=!!this.hooks.setPermalink;this.propertyHandlers={W:this.playMove,B:this.playMove,KO:this.playMove,MN:this.setMoveNumber,AW:this.addStone,AB:this.addStone,AE:this.addStone,CR:this.addMarker,LB:this.addMarker,TR:this.addMarker,MA:this.addMarker,SQ:this.addMarker,TW:this.addMarker,TB:this.addMarker,DD:this.addMarker,PL:this.setColor,C:this.showComments,N:this.showAnnotation,GB:this.showAnnotation,GW:this.showAnnotation,DM:this.showAnnotation,HO:this.showAnnotation,UC:this.showAnnotation,V:this.showAnnotation,BM:this.showAnnotation,DO:this.showAnnotation,IT:this.showAnnotation,TE:this.showAnnotation,BL:this.showTime,OB:this.showTime,WL:this.showTime,OW:this.showTime};this.infoLabels={GN:t.game,PW:t.white,WR:t["white rank"],WT:t["white team"],PB:t.black,BR:t["black rank"],BT:t["black team"],HA:t.handicap,KM:t.komi,RE:t.result,DT:t.date,GC:t.info,PC:t.place,EV:t.event,RO:t.round,OT:t.overtime,ON:t.opening,RU:t.ruleset,AN:t.annotator,CP:t.copyright,SO:t.source,TM:t["time limit"],US:t.transcriber,AP:t["created with"]};this.months=[t.january,t.february,t.march,t.april,t.may,t.june,t.july,t.august,t.september,t.october,t.november,t.december];this.mtypes=[uitext["ideal move"],uitext["good move"],uitext["bad move"],uitext["trick move"],uitext["question move"]];this.theme=cfg.theme;this.reset(cfg);this.renderer=cfg.renderer||"html";this.cropParams=null;this.shrinkToFit=cfg.shrinkToFit;if(this.shrinkToFit||cfg.cropWidth||cfg.cropHeight){this.cropParams={};this.cropParams.width=cfg.cropWidth;this.cropParams.height=cfg.cropHeight;this.cropParams.left=cfg.cropLeft;this.cropParams.top=cfg.cropTop;this.cropParams.padding=cfg.cropPadding||1}this.constructDom();if(cfg.enableShortcuts){addEvent(document,isMoz?"keypress":"keydown",this.handleKeypress,this,true)}addEvent(document,"mouseup",this.handleDocMouseUp,this,true);if(cfg.sgf||cfg.sgfUrl||(cfg.sgfPath&&cfg.gameName)){this.loadSgf(cfg)}this.hook("initDone")},hook:function(hook,params){if(hook in this.hooks){return this.hooks[hook].bind(this)(params)}},reset:function(cfg){this.gameName="";this.collectionRoot=new eidogo.GameNode();this.cursor=new eidogo.GameCursor();this.progressiveLoad=cfg.progressiveLoad?true:false;this.progressiveLoads=null;this.progressiveUrl=null;this.progressiveMode=cfg.progressiveLoad&&cfg.progressiveMode||"id";this.opponentUrl=null;this.opponentColor=null;this.opponentLevel=null;this.board=null;this.rules=null;this.currentColor=null;this.moveNumber=null;this.totalMoves=null;this.variations=null;this.timeB="";this.timeW="";this.regionTop=null;this.regionLeft=null;this.regionWidth=null;this.regionHeight=null;this.regionBegun=null;this.regionClickSelect=null;this.mouseDown=null;this.mouseDownX=null;this.mouseDownY=null;this.mouseDownClickX=null;this.mouseDownClickY=null;this.labelLastLetter=null;this.labelLastNumber=null;this.resetLastLabels();this.unsavedChanges=false;this.updatedNavTree=false;this.navTreeTimeout=null;this.searching=false;this.editingText=false;this.goingBack=false;this.problemMode=cfg.problemMode;this.problemColor=cfg.problemColor;this.prefs={};this.prefs.markCurrent=typeof cfg.markCurrent!="undefined"?!!cfg.markCurrent:true;this.prefs.markNext=typeof cfg.markNext!="undefined"?cfg.markNext:false;this.prefs.markVariations=typeof cfg.markVariations!="undefined"?!!cfg.markVariations:true;this.prefs.showGameInfo=!!cfg.showGameInfo;this.prefs.showPlayerInfo=!!cfg.showPlayerInfo;this.prefs.showTools=!!cfg.showTools;this.prefs.showComments=typeof cfg.showComments!="undefined"?!!cfg.showComments:true;this.prefs.showOptions=!!cfg.showOptions;this.prefs.showNavTree=!this.progressiveLoad&&typeof cfg.showNavTree!="undefined"?!!cfg.showNavTree:false},loadSgf:function(cfg,completeFn){cfg=cfg||{};this.nowLoading();this.reset(cfg);this.sgfPath=cfg.sgfPath||this.sgfPath;this.loadPath=cfg.loadPath&&cfg.loadPath.length?cfg.loadPath:[0,0];this.gameName=cfg.gameName||"";var noCb=false;if(typeof cfg.sgf=="string"){var sgf=new eidogo.SgfParser(cfg.sgf);this.load(sgf.root)}else{if(typeof cfg.sgf=="object"){this.load(cfg.sgf)}else{if(cfg.progressiveLoad&&cfg.progressiveUrl){this.progressiveLoads=0;this.progressiveUrl=cfg.progressiveUrl;this.saveNodeUrl=cfg.saveNodeUrl;this.labelUrl=cfg.labelUrl;this.sourceUrl=cfg.sourceUrl;this.fetchProgressiveData(completeFn);noCb=true}else{if(typeof cfg.sgfUrl=="string"||this.gameName){if(!cfg.sgfUrl){cfg.sgfUrl=this.sgfPath+this.gameName+".sgf"}this.remoteLoad(cfg.sgfUrl,null,false,null,completeFn);noCb=true;if(cfg.progressiveLoad){this.progressiveLoads=0;this.progressiveUrl=cfg.progressiveUrl||cfg.sgfUrl.replace(/\?.+$/,"")}}else{var boardSize=cfg.boardSize||"19";var komiMap={19:6.5,13:4.5,9:3.5,7:2.5};var blankGame={_children:[{SZ:boardSize,KM:cfg.komi||komiMap[boardSize]||6.5,_children:[]}]};if(cfg.opponentUrl){this.gameName="gnugo";this.opponentUrl=cfg.opponentUrl;this.opponentColor=cfg.opponentColor=="B"?cfg.opponentColor:"W";this.opponentLevel=cfg.opponentLevel||7;var root=blankGame._children[0];root.PW=this.opponentColor=="B"?t.you:"GNU Go";root.PB=this.opponentColor=="B"?"GNU Go":t.you;root.HA=parseInt(cfg.handicap,10)||0;if(root.HA){var handiCoords={19:[["pd","dp"],["pd","dp","pp"],["pd","dp","pp","dd"],["pd","dp","pp","dd","jj"],["pd","dp","pp","dd","dj","pj"],["pd","dp","pp","dd","dj","pj","jj"],["pd","dp","pp","dd","dj","pj","jd","jp"],["pd","dp","pp","dd","dj","pj","jd","jp","jj"]],13:[["jd","dj"],["jd","dj","jj"],["jd","dj","jj","dd"],["jd","dj","jj","dd","gg"],["jd","dj","jj","dd","dg","jg"],["jd","dj","jj","dd","dg","jg","gg"],["jd","dj","jj","dd","dg","jg","gd","gj"],["jd","dj","jj","dd","dg","jg","gd","gj","gg"]],9:[["cg","gc"],["cg","gc","gg"],["cg","gc","gg","cc"],["cg","gc","gg","cc","ee"],["cg","gc","gg","cc","ce","ge"],["cg","gc","gg","cc","ce","ge","ee"],["cg","gc","gg","cc","ce","ge","ec","eg"],["cg","gc","gg","cc","ce","ge","ec","eg","ee"]]};root.KM=0.5;if(root.HA>1){root.AB=handiCoords[boardSize][root.HA-2]}}}this.load(blankGame)}}}}if(!noCb&&typeof completeFn=="function"){completeFn()}},load:function(data,target){var newGame=false;if(!target){target=new eidogo.GameNode();this.collectionRoot=target}target.loadJson(data);target._cached=true;this.doneLoading();this.progressiveLoads--;if(!target._parent){var gameIndex=this.loadPath.length?parseInt(this.loadPath[0],10):0;this.initGame(target._children[gameIndex||0]);newGame=true}if(this.loadPath.length){this.goTo(this.loadPath,newGame);if(!this.progressiveLoad){this.loadPath=[0,0]}}else{this.refresh()}if(newGame&&this.problemMode){if(!this.problemColor){this.currentColor=this.problemColor=(this.cursor.getNextColor()||"B")}else{this.currentColor=this.problemColor}}},remoteLoad:function(url,target,useSgfPath,loadPath,completeFn){useSgfPath=useSgfPath=="undefined"?true:useSgfPath;completeFn=(typeof completeFn=="function")?completeFn:null;if(useSgfPath){if(!target){this.gameName=url}url=this.sgfPath+url+".sgf"}if(loadPath){this.loadPath=loadPath}var success=function(req){var data=req.responseText.replace(/^( |\t|\r|\n)*/,"");if(data.charAt(0)=="("){var me=this;var sgf=new eidogo.SgfParser(data,function(){me.load(this.root,target);completeFn&&completeFn()})}else{if(data.charAt(0)=="{"){data=eval("("+data+")");this.load(data,target);completeFn&&completeFn()}else{this.croak(t["invalid data"])}}};var failure=function(req){this.croak(t["error retrieving"])};ajax("get",url,null,success,failure,this,30000)},initGame:function(gameRoot){gameRoot=gameRoot||{};this.handleDisplayPrefs();var size=gameRoot.SZ||19;if(size!=7&&size!=9&&size!=13&&size!=19){size=19}if(this.shrinkToFit){this.calcShrinkToFit(gameRoot,size)}else{if(this.problemMode&&!this.cropParams){this.cropParams={width:size,height:size,top:0,left:0,padding:1}}}if(!this.board){this.createBoard(size);this.rules=new eidogo.Rules(this.board)}this.unsavedChanges=false;this.resetCursor(true);this.totalMoves=0;var moveCursor=new eidogo.GameCursor(this.cursor.node);while(moveCursor.next()){this.totalMoves++}this.totalMoves--;this.showGameInfo(gameRoot);this.enableNavSlider();this.selectTool(this.mode=="view"?"view":"play");this.hook("initGame")},handleDisplayPrefs:function(){(this.prefs.showGameInfo||this.prefs.showPlayerInfo?show:hide)(this.dom.info);(this.prefs.showGameInfo?show:hide)(this.dom.infoGame);(this.prefs.showPlayerInfo?show:hide)(this.dom.infoPlayers);(this.prefs.showTools?show:hide)(this.dom.toolsContainer);if(!this.showingSearch){(this.prefs.showComments?show:hide)(this.dom.comments)}(this.prefs.showOptions?show:hide)(this.dom.options);(this.prefs.showNavTree?show:hide)(this.dom.navTreeContainer)},createBoard:function(size){size=size||19;if(this.board&&this.board.renderer&&this.board.boardSize==size){return}try{this.dom.boardContainer.innerHTML="";var rendererProto=(this.renderer=="flash"?eidogo.BoardRendererFlash:eidogo.BoardRendererHtml);var renderer=new rendererProto(this.dom.boardContainer,size,this,this.cropParams);this.board=new eidogo.Board(renderer,size)}catch(e){if(e=="No DOM container"){this.croak(t["error board"]);return}}},calcShrinkToFit:function(gameRoot,size){var l=null,t=null,r=null,b=null;var points={};var me=this;gameRoot.walk(function(node){var prop,i,coord;for(prop in node){if(/^(W|B|AW|AB|LB)$/.test(prop)){coord=node[prop];if(!(coord instanceof Array)){coord=[coord]}if(prop!="LB"){coord=me.expandCompressedPoints(coord)}else{coord=[coord[0].split(/:/)[0]]}for(i=0;i<coord.length;i++){points[coord[i]]=""}}}});for(var key in points){var pt=this.sgfCoordToPoint(key);if(l===null||pt.x<l){l=pt.x}if(r===null||pt.x>r){r=pt.x}if(t===null||pt.y<t){t=pt.y}if(b===null||pt.y>b){b=pt.y}}this.cropParams.width=r-l+1;this.cropParams.height=b-t+1;this.cropParams.left=l;this.cropParams.top=t;var pad=this.cropParams.padding;for(var lpad=pad;l-lpad<0;lpad--){}if(lpad){this.cropParams.width+=lpad;this.cropParams.left-=lpad}for(var tpad=pad;t-tpad<0;tpad--){}if(tpad){this.cropParams.height+=tpad;this.cropParams.top-=tpad}for(var rpad=pad;r+rpad>size;rpad--){}if(rpad){this.cropParams.width+=rpad}for(var bpad=pad;b+bpad>size;bpad--){}if(bpad){this.cropParams.height+=bpad}},warnEditor:function(){if(userLoggedIn){return true}if(this.doneEditWarning){return true}var answer=confirm(uitext["edit warning"]);if(!answer){return false}this.doneEditWarning=true;return true},warnGoodyGoody:function(mtype){if(mtype!=1){return true}var nd=this.cursor.node;if(nd._parent._mtype!=1){return true}var nd=this.cursor.node;var answer=confirm(uitext["good move warning"]);if(!answer){return false}return true},setMoveType:function(mtype){if(!this.cursor.node._parent){alert("wtf no parent");return}if(this.cursor.node._parent._id>100000){alert(uitext.saveparent);return}if(!this.warnEditor()){return}if(!this.warnGoodyGoody(mtype)){return}this.nowLoading(t["saving msg"]);var nd=this.cursor.node;if(nd._isGhost!==undefined){delete nd._isGhost}var success=function(req){this.doneLoading();var conts=eval("("+req.responseText+")");if(conts._id!==undefined){nd._id=conts._id;$("#newNodeStuff").hide();$("#changeNodeStuff").show(1000);if(conts._respawned!==undefined){this.cursor.node._cached=false;this.fetchProgressiveData()}}this.refresh();if(nd._respawned!==undefined){this.fetchProgressiveData()}};var failure=function(req){this.croak(t["error retrieving"])};var root=this.cursor.getGameRoot();var params={type:mtype,parentid:nd._parent._id};if(nd._id<100000){params.id=nd._id}else{params.move=nd.getMove()}ajax("get",this.saveNodeUrl,params,success,failure,this,45000);nd._mtype=mtype;this.refresh()},doIdealMove:function(){this.setMoveType(0)},doGoodMove:function(){this.setMoveType(1)},doBadMove:function(){this.setMoveType(2)},doTrickMove:function(){this.setMoveType(3)},doQuestionMove:function(){this.setMoveType(4)},playProblemResponse:function(noRender){setTimeout(function(){this.variation(null,noRender);if(this.hooks.playProblemResponse){this.hook("playProblemResponse")}else{if(!this.cursor.hasNext()){this.prependComment(t["end of variation"])}}}.bind(this),200)},goTo:function(path,fromStart){fromStart=typeof fromStart!="undefined"?fromStart:true;if(fromStart&&path.length>1&&path[0]!=this.cursor.getGameRoot().getPosition()){this.updatedNavTree=false}if(fromStart){this.resetCursor(true)}var steps=parseInt(path,10);if(!(path instanceof Array)&&!isNaN(steps)){if(fromStart){steps++}for(var i=0;i<steps;i++){this.variation(null,true)}this.refresh();return}if(!(path instanceof Array)||!path.length){alert(t["bad path"]+" "+path);return}var position;var vars;if(isNaN(parseInt(path[0],10))){if(!this.cursor.node._parent){this.variation(0,true)}while(path.length){if(this.progressiveLoads>0){this.loadPath.push(position);return}position=path.shift();vars=this.getVariations();for(var i=0;i<vars.length;i++){if(vars[i].move==position){this.variation(vars[i].varNum,true);break}}}this.refresh();return}var first=true;while(path.length){position=parseInt(path.shift(),10);if(!path.length){for(var i=0;i<position;i++){this.variation(0,true)}}else{if(path.length){if(!first&&fromStart){while(this.cursor.node._children.length==1){this.variation(0,true)}}this.variation(position,true)}}first=false}this.refresh()},resetCursor:function(noRender,toGameRoot){if(this.board===null){alert("error loading javascript, please refresh page")}this.board.reset();this.resetCurrentColor();if(toGameRoot){this.cursor.node=this.cursor.getGameRoot()}else{this.cursor.node=this.collectionRoot}this.refresh(noRender)},resetCurrentColor:function(){this.currentColor=(this.problemMode?this.problemColor:"B");var root=this.cursor.getGameRoot();if(root&&root.HA>1){this.currentColor="W"}},refresh:function(noRender){if(this.progressiveLoads>0){var me=this;setTimeout(function(){me.refresh.call(me)},10);return}this.board.revert(1);this.execNode(noRender)},simpleRefresh:function(){this.execNode(false)},variation:function(varNum,noRender){if(this.cursor.next(varNum)){this.execNode(noRender);this.resetLastLabels();if(this.progressiveLoads>0){return false}return true}return false},calcInsignia:function(nd){var id=nd._id;var mt=nd._mtype;if(id<=1){return"empty"}if(mt==undefined){return"undef"}var pari=nd._parent.insignia;if(pari=="empty"){pari="joseki"}if(mt==4){return"question"}var par_settled=false;if(nd._parent._labelids!==undefined){for(var i=0;i<nd._parent._labelids.length;i++){if(nd._parent._labelids[i]==23){par_settled=true}}}if(pari=="joseki"){if(mt==0){if(par_settled){return"continuation"}return"joseki"}else{if(mt==1){return"goodseq"}else{if(mt==2){return"mistake"}else{if(mt==3){return"trick"}}}}}else{if(pari=="continuation"){if(mt==0){return"continuation"}else{if(mt==1){return"goodseq"}else{if(mt==2){return"mistake"}else{if(mt==3){return"trick"}}}}}else{if(pari=="goodseq"){if(mt==0||mt==1){return"goodseq"}else{if(mt==2){return"mistake"}else{if(mt==3){return"trick"}}}}else{if(pari=="mistake"){if(mt==0){return"refutation"}else{if(mt==1){return"refutation"}else{if(mt==2){return"multmistake"}else{if(mt==3){return"confused"}}}}}else{if(pari=="refutation"){if(mt==0){return"refutation"}else{if(mt==1){return"refutation"}else{if(mt==2){return"multmistake"}else{if(mt==3){return"confused"}}}}}else{if(pari=="trick"){if(mt==0){return"trickrefute"}else{if(mt==1){return"trickavoid"}else{if(mt==2){return"tricked"}else{if(mt==3){return"confused"}}}}}else{if(pari=="tricked"){if(mt==0){return"tricked"}else{if(mt==1){return"tricked"}else{if(mt==2){return"multmistake"}else{if(mt==3){return"confused"}}}}}else{if(pari=="trickrefute"||pari=="trickavoid"){if(mt==0){return pari}else{if(mt==1){return pari}else{if(mt==2){return"multmistake"}else{if(mt==3){return"confused"}}}}}else{if(pari=="multmistake"){return"multmistake"}else{if(pari=="confused"){return"confused"}}}}}}}}}}},wikiPosLinks:function(s){var ar;while((ar=this.regexpPath.exec(s))!=null){var pos_txt=ar[1];var x='<a class="poslink" href="/#path:'+pos_txt+'"><img src="/img/pos.php?path='+pos_txt+'" border=0 class="miniboard"></a>';x+='<div class="postip"><img src="/img/pos.php?path='+pos_txt+'" class="fullboard"></div>';s=s.replace(this.regexpPath,x)}return s},wikiSources:function(s){var ar;while((ar=this.regexpSource.exec(s))!=null){var src_txt=ar[1];var src_detail="";var comma=src_txt.indexOf(",");if(comma>0){src_detail=src_txt.substring(comma+1);src_txt=src_txt.substring(0,comma)}var x="undefined source";if(jsources[src_txt]!==undefined){if(jsources[src_txt].senseis!=""){x='<a class="iframesrc" href="http://senseis.xmp.net/?'+jsources[src_txt].senseis+'">'+jsources[src_txt].name+"</a>"}else{x=jsources[src_txt].name}if(src_detail.length>0){x+=" - "+src_detail}}x='<span class="sources">'+x+"</span>";s=s.replace(this.regexpSource,x)}return s},doViewNode:function(){this.editMode=false;this.histMode=false;this.talkMode=false;var nd=this.cursor.node;this.dom.comments.innerHTML='<div id="node_labels"></div><div id="node_comment"></div><br><div id="node_sources"></div>';if(nd.C!=undefined){var s=nd.C;var ar;s=this.wikiSources(s);while((ar=this.regexpPosition.exec(s))!=null){var pos_txt=ar[1];pos_txt=pos_txt.toLowerCase();var x=pos_txt.charCodeAt(0)-97;if(x>7){x--}var y=19-parseInt(pos_txt.substring(1));var varPt={x:x,y:y};var marker=this.board.getMarker(varPt);if(marker!=this.board.EMPTY){s=s.replace(this.regexpPosition,marker)}else{var coord=this.pointToSgfCoord(varPt);var markerText=coord+":"+this.labelLastLetter;this.addMarker(markerText,"LB");s=s.replace(this.regexpPosition,this.labelLastLetter);this.labelLastLetter=String.fromCharCode(this.labelLastLetter.charCodeAt(0)+1)}}s=this.wikiPosLinks(s);s=s.replace(/^(\n|\r|\t|\s)+/,"").replace(/\n/g,"<br />");$("#node_comment").append(s);$("a.poslink").tooltip({offset:[-70,70]});$("a.iframesrc").fancybox({frameWidth:900,frameHeight:600})}if(typeof nd._labelids!="undefined"){for(var i=0;i<nd._labelids.length;i++){labelid=nd._labelids[i];this.addLabelToView(labelid,false)}}if(typeof nd._sources!="undefined"){for(var i=0;i<nd._sources.length;i++){var sourceid=nd._sources[i][0];var txt=nd._sources[i][1];this.addSourceToView(sourceid,txt,false,nd._sources[i][2])}}},execNode:function(noRender,ignoreProgressive){if(!ignoreProgressive&&this.progressiveLoads>0){var me=this;setTimeout(function(){me.execNode.call(me,noRender)},10);return}if(!this.cursor.node){return}this.cursor.node.insignia=this.calcInsignia(this.cursor.node);if(!noRender){var nd=this.cursor.node;var mt=nd._mtype;this.board.clearMarkers();this.moveNumber=this.cursor.getMoveNumber();if(typeof mt!="undefined"){this.dom.movetypeLabel.innerHTML=this.mtypes[mt];this.dom.movetypeLabel.className="movetype-container-"+mt}else{this.dom.movetypeLabel.innerHTML=uitext.unsaved;if(nd._isGhost!==undefined){this.dom.movetypeLabel.innerHTML+=" ("+uitext["ghost position"]+")"}if(nd._parent._id>100000){this.dom.movetypeLabel.innerHTML+=" ("+uitext["parent unsaved"]+")"}this.dom.movetypeLabel.className="movetype-container-null"}if(uitext["insig_"+nd.insignia]==undefined){this.dom.insignia.innerHTML=""}else{this.dom.insignia.innerHTML=uitext["insig_"+nd.insignia]}if(this.editMode){this.doEditComment()}else{if(this.histMode){this.doEditHistory()}else{if(this.talkMode){this.doEditTalk()}else{this.doViewNode()}}}if(nd._talkCount!=undefined){$("#talkCount-0").text(" ("+nd._talkCount+")")}else{$("#talkCount-0").text("")}if(nd._continuationcount===undefined){$("#continuations-count-0").html("-")}else{$("#continuations-count-0").html(uitext["continuations number"].replace("%",nd._continuationcount))}if(mt!=4){$("#vote-name-0").html(uitext["vote correct"]);$("#vote-up-0").attr("title",uitext["vote correct up desc"]);$("#vote-down-0").attr("title",uitext["vote correct down desc"])}else{$("#vote-name-0").html(uitext["vote interesting"]);$("#vote-up-0").attr("title",uitext["vote interesting up desc"]);$("#vote-down-0").attr("title",uitext["vote interesting down desc"])}this.setVoteUI();$("#show-votes-0").attr("href","/find/nodevotes.php?nodeid="+nd._id)}if(this.moveNumber<1){this.resetCurrentColor()}var props=this.cursor.node.getProperties();if(true){for(var propName in props){if(this.propertyHandlers[propName]){(this.propertyHandlers[propName]).apply(this,[this.cursor.node[propName],propName,noRender])}}}if(noRender){this.board.commit()}else{this.markGhosts();this.findVariations();this.updateControls();this.board.commit();this.board.render()}if(!ignoreProgressive&&this.progressiveUrl){this.fetchProgressiveData()}if(this.problemMode&&this.currentColor&&this.currentColor!=this.problemColor&&!this.goingBack){this.playProblemResponse(noRender)}this.goingBack=false},fetchProgressiveData:function(completeFn){var loadNode=this.cursor.node||null;if(loadNode&&loadNode._cached){return}var loadId=(loadNode&&loadNode._id)||0;this.nowLoading();this.progressiveLoads++;var completeFnWrap=function(){var moveNum=this.cursor.getMoveNumber();if(completeFn&&typeof completeFn=="function"){completeFn()}}.bind(this);var url=this.progressiveUrl+"?"+eidogo.util.makeQueryString({id:loadId,pid:this.uniq});this.remoteLoad(url,loadNode,false,null,completeFnWrap)},findVariations:function(){this.variations=this.getVariations()},getVariations:function(){var vars=[],kids=this.cursor.node._children;for(var i=0;i<kids.length;i++){vars.push({move:kids[i].getMove(),varNum:i,mtype:kids[i]._mtype})}return vars},markGhosts:function(){if(!this.viewGhosts){return}var gs=this.cursor.node._ghosts;if(gs===undefined){return}for(var i=0;i<gs.length;i++){this.addMarker(gs[i].loc,"ghost:"+gs[i].mtype)}},back:function(e,obj,noRender){if(this.cursor.previous()){this.board.revert(1);this.goingBack=true;this.refresh(noRender);this.resetLastLabels()}},forward:function(e,obj,noRender){this.variation(null,noRender)},first:function(){if(!this.cursor.hasPrevious()){return}this.resetCursor(false,true)},last:function(){if(!this.cursor.hasNext()){return}while(this.variation(null,true)){}this.refresh()},pass:function(){if(!this.variations){return}for(var i=0;i<this.variations.length;i++){if(!this.variations[i].move||this.variations[i].move=="tt"){this.variation(this.variations[i].varNum);return}}this.createMove("tt")},handleBoardMouseDown:function(x,y,cx,cy,e){if(this.domLoading){return}if(!this.boundsCheck(x,y,[0,this.board.boardSize-1])){return}this.mouseDown=true;this.mouseDownX=x;this.mouseDownY=y;this.mouseDownClickX=cx;this.mouseDownClickY=cy;if(this.mode=="region"&&x>=0&&y>=0&&!this.regionBegun){this.regionTop=y;this.regionLeft=x;this.regionBegun=true}},handleBoardHover:function(x,y,cx,cy,e){if(this.domLoading){return}if(this.mouseDown||this.regionBegun){if(!this.boundsCheck(x,y,[0,this.board.boardSize-1])){return}var boardDiff=(x!=this.mouseDownX||y!=this.mouseDownY);var clickDiff=Math.abs(this.mouseDownClickX-cx)>=19||Math.abs(this.mouseDownClickY-cy)>=19;if(this.searchUrl&&!this.regionBegun&&boardDiff&&clickDiff){this.selectTool("region");this.regionBegun=true;this.regionTop=this.mouseDownY;this.regionLeft=this.mouseDownX}if(this.regionBegun){this.regionRight=x+(x>=this.regionLeft?1:0);this.regionBottom=y+(y>=this.regionTop?1:0);this.showRegion()}stopEvent(e)}},handleBoardMouseUp:function(x,y,e){if(this.domLoading){return}this.mouseDown=false;var coord=this.pointToSgfCoord({x:x,y:y});if(this.mode=="view"||this.mode=="play"){for(var i=0;i<this.variations.length;i++){var varPt=this.sgfCoordToPoint(this.variations[i].move);if(varPt.x==x&&varPt.y==y){this.variation(this.variations[i].varNum);stopEvent(e);return}}}if(this.mode=="view"){var root=this.cursor.getGameRoot(),path=[0,root.getPosition()],mn=0,node=root._children[0];while(node){if(node.getMove()==coord){path.push(mn);this.goTo(path);break}mn++;node=node._children[0]}return}if(this.mode=="play"){if(!this.rules.check({x:x,y:y},this.currentColor)){return}if(coord){var nextMoves=this.cursor.getNextMoves();if(nextMoves&&coord in nextMoves){this.variation(nextMoves[coord])}else{this.createMove(coord)}}}else{if(this.mode=="region"&&x>=-1&&y>=-1&&this.regionBegun){if(this.regionTop==y&&this.regionLeft==x&&!this.regionClickSelect){this.regionClickSelect=true;this.regionRight=x+1;this.regionBottom=y+1;this.showRegion()}else{this.regionBegun=false;this.regionClickSelect=false;this.regionBottom=(y<0?0:(y>=this.board.boardSize)?y:y+(y>this.regionTop?1:0));this.regionRight=(x<0?0:(x>=this.board.boardSize)?x:x+(x>this.regionLeft?1:0));this.showRegion();show(this.dom.searchButton,"inline");stopEvent(e)}}else{var prop;var stone=this.board.getStone({x:x,y:y});if(this.mode=="add_b"||this.mode=="add_w"){var deleted=this.cursor.node.emptyPoint(this.pointToSgfCoord({x:x,y:y}));if(stone!=this.board.BLACK&&this.mode=="add_b"){prop="AB"}else{if(stone!=this.board.WHITE&&this.mode=="add_w"){prop="AW"}else{if(this.board.getStone({x:x,y:y})!=this.board.EMPTY&&!deleted){prop="AE"}}}}else{switch(this.mode){case"tr":prop="TR";break;case"sq":prop="SQ";break;case"cr":prop="CR";break;case"x":prop="MA";break;case"dim":prop="DD";break;case"number":prop="LB";coord=coord+":"+this.labelLastNumber;this.labelLastNumber++;break;case"letter":prop="LB";coord=coord+":"+this.labelLastLetter;this.labelLastLetter=String.fromCharCode(this.labelLastLetter.charCodeAt(0)+1);break;case"label":prop="LB";coord=coord+":"+this.dom.labelInput.value;break;case"clear":this.cursor.node.deletePropertyValue(["TR","SQ","CR","MA","DD","LB"],new RegExp("^"+coord));break}if(this.cursor.node.hasPropertyValue(prop,coord)){this.cursor.node.deletePropertyValue(prop,coord);prop=null}}if(prop){this.cursor.node.pushProperty(prop,coord)}this.unsavedChanges=true;var deleted=this.checkForEmptyNode();this.refresh();if(deleted){this.prependComment(t["position deleted"])}}}},nukeChild:function(id){var index=0;this.cursor.node._children=this.cursor.node._children.filter(function(node,i){if(node._id==id){index=i;return false}else{return true}});if(index&&this.cursor.node._preferredChild==index){this.cursor.node._preferredChild--}},checkForEmptyNode:function(){if(!eidogo.util.numProperties(this.cursor.node.getProperties())){var killNode=window.confirm(t["confirm delete"]);if(killNode){var id=this.cursor.node._id;var index=0;this.back();this.cursor.node._children=this.cursor.node._children.filter(function(node,i){if(node._id==id){index=i;return false}else{return true}});if(index&&this.cursor.node._preferredChild==index){this.cursor.node._preferredChild--}return true}}return false},handleDocMouseUp:function(evt){if(this.domLoading){return true}if(this.mode=="region"&&this.regionBegun&&!this.regionClickSelect){this.mouseDown=false;this.regionBegun=false;show(this.dom.searchButton,"inline")}return true},boundsCheck:function(x,y,region){if(region.length==2){region[3]=region[2]=region[1];region[1]=region[0]}return(x>=region[0]&&y>=region[1]&&x<=region[2]&&y<=region[3])},getRegionBounds:function(){var l=this.regionLeft;var w=this.regionRight-this.regionLeft;if(w<0){l=this.regionRight;w=-w+1}var t=this.regionTop;var h=this.regionBottom-this.regionTop;if(h<0){t=this.regionBottom;h=-h+1}return[t,l,w,h]},showRegion:function(){var bounds=this.getRegionBounds();this.board.renderer.showRegion(bounds)},hideRegion:function(){this.board.renderer.hideRegion()},convertRegionPattern:function(region){return region.join("").replace(new RegExp(this.board.EMPTY,"g"),".").replace(new RegExp(this.board.BLACK,"g"),"x").replace(new RegExp(this.board.WHITE,"g"),"o")},compressPattern:function(pattern){var c=null;var pc="";var n=1;var ret="";for(var i=0;i<pattern.length;i++){c=pattern.charAt(i);if(c==pc){n++}else{ret=ret+pc+(n>1?n:"");n=1;pc=c}}ret=ret+pc+(n>1?n:"");return ret},uncompressPattern:function(pattern){var c=null;var s=null;var n="";var ret="";for(var i=0;i<pattern.length;i++){c=pattern.charAt(i);if(c=="."||c=="x"||c=="o"){if(s!=null){n=parseInt(n,10);n=isNaN(n)?1:n;for(var j=0;j<n;j++){ret+=s}n=""}s=c}else{n+=c}}n=parseInt(n,10);n=isNaN(n)?1:n;for(var j=0;j<n;j++){ret+=s}return ret},createMove:function(coord){var props={};props[this.currentColor]=coord;var isGhost=false;var ghost;var gs=this.cursor.node._ghosts;if(gs!==undefined){for(var i=0;i<gs.length;i++){if(gs[i].loc==coord){isGhost=true;ghost=gs[i];this.cursor.node._ghosts.splice(i,1);break}}}var varNode=new eidogo.GameNode(null,props);varNode._cached=true;if(isGhost){varNode._id=ghost.id;varNode._isGhost=true}this.totalMoves++;this.cursor.node.appendChild(varNode);this.unsavedChanges=[this.cursor.node._children.last(),this.cursor.node];this.updatedNavTree=false;this.variation(this.cursor.node._children.length-1);if(isGhost){}},handleKeypress:function(e){if(this.editingText){return true}var charCode=e.keyCode||e.charCode;if(!charCode||e.ctrlKey||e.altKey||e.metaKey){return true}var charKey=String.fromCharCode(charCode).toLowerCase();var varMoves=[];for(var i=0;i<this.variations.length;i++){var varMove=this.variations[i].move;var varPt=this.sgfCoordToPoint(varMove);var varLabel=""+(i+1);var marker=this.board.getMarker(varPt);if(varPt.x!=null&&marker!=this.board.EMPTY&&typeof marker=="string"&&!varMoves.contains(varMove)){varLabel=marker.toLowerCase()}varLabel=varLabel.replace(/^var:/,"");if(charKey==varLabel.charAt(0)){this.variation(this.variations[i].varNum);stopEvent(e);return}varMoves.push(varMove)}if(charCode==112||charCode==27){this.selectTool("play")}if(charKey=="i"){if(this.editMode){this.setMoveType(0);stopEvent(e)}}var stop=true;switch(charCode){case 39:if(e.shiftKey){var movesLeft=this.totalMoves-this.moveNumber;var steps=(movesLeft>9?9:movesLeft-1);for(var i=0;i<steps;i++){this.forward(null,null,true)}}this.forward();break;case 37:if(e.shiftKey){var steps=(this.moveNumber>9?9:this.moveNumber-1);for(var i=0;i<steps;i++){this.back(null,null,true)}}this.back();break;case 40:this.doVote(-1);break;case 38:this.doVote(1);break;case 192:this.pass();break;default:stop=false;break}if(stop){stopEvent(e)}},showGameInfo:function(gameInfo){this.hook("showGameInfo",gameInfo);if(!gameInfo){return}this.dom.infoGame.innerHTML="";this.dom.whiteName.innerHTML="";this.dom.blackName.innerHTML="";var dl=document.createElement("dl"),val;for(var propName in this.infoLabels){if(gameInfo[propName] instanceof Array){gameInfo[propName]=gameInfo[propName][0]}if(gameInfo[propName]){if(propName=="PW"){this.dom.whiteName.innerHTML=gameInfo[propName]+(gameInfo.WR?", "+gameInfo.WR:"");continue}else{if(propName=="PB"){this.dom.blackName.innerHTML=gameInfo[propName]+(gameInfo.BR?", "+gameInfo.BR:"");continue}}if(propName=="WR"||propName=="BR"){continue}val=gameInfo[propName];if(propName=="DT"){var dateParts=gameInfo[propName].split(/[\.-]/);if(dateParts.length==3){val=dateParts[2].replace(/^0+/,"")+" "+this.months[dateParts[1]-1]+" "+dateParts[0]}}var dt=document.createElement("dt");dt.innerHTML=this.infoLabels[propName]+":";var dd=document.createElement("dd");dd.innerHTML=val;dl.appendChild(dt);dl.appendChild(dd)}}this.dom.infoGame.appendChild(dl)},nodeInDB:function(){if(this.cursor.node._id==undefined){return false}return this.cursor.node._id<100000},violatesSymmetry:function(){var nd=this.cursor.node;var path=this.cursor.getPathMoves();for(var i=0;i<path.length;i++){var m=path[i];if(m=="tt"){continue}var p=this.sgfCoordToPoint(m);var x=18-p.x;var y=p.y;if(x==y){continue}return(x>y)}return false},doEditComment:function(){this.editMode=true;this.histMode=false;this.talkMode=false;var xxx=this;var nd=this.cursor.node;var s="";var invalid_sym=false;if(this.nodeInDB()){if(nd._isGhost!==undefined){if(userLevel<1000){invalid_sym=this.violatesSymmetry()}if(!invalid_sym){s+=uitext["reactivate position"]}}else{s+=uitext.reassign}}else{if(userLevel<1000){invalid_sym=this.violatesSymmetry()}if(!invalid_sym){s+=uitext["add pos btn"]}}if(invalid_sym){var p=this.sgfCoordToPoint(nd.getMove());var nx=18-p.y;var ny=18-p.x;p.x=nx;p.y=ny;var mirrored=this.pointToReadableCoord(p);s+=uitext["hint symmetry error"].replace("%",mirrored)}else{s+="<table border=0 cellspacing=0 cellpadding=0><tr><td><input type='button' id='ideal-move' class='ideal-move-button' value='"+uitext["ideal move btn"]+"' /></td><td><input type='button' id='good-move' class='good-move-button' value='"+uitext["good move btn"]+"' /></td><td><input type='button' id='bad-move' class='bad-move-button' value='"+uitext["bad move btn"]+"' /></td><td><input type='button' id='trick-move' class='trick-move-button' value='"+uitext["trick move btn"]+"' /></td><td><input type='button' id='question-move' class='question-move-button' value='"+uitext["question move btn"]+"' /></td></tr></table>"}if(!this.nodeInDB()){s+='<div id="newNodeStuff">'+uitext["newnode note"]+"</div>"}s+='<div id="changeNodeStuff">';s+="<fieldset><legend>"+uitext["group tagging"]+"</legend>";s+=labelSelect+" "+sourceSelect;s+='<div id="node_labels"></div><div id="node_sources"></div>';s+="</fieldset>";s+="<fieldset><legend>"+uitext["group description"]+"</legend>";s+=lang_choice;s+="<br>"+uitext.languages_label+': <span id="langsused">';if(nd._alllangs!==undefined&&nd._alllangs.length>0){for(var i=0;i<nd._alllangs.length;i++){if(i>0){s+=", "}s+=jlanguages[nd._alllangs[i]]}}else{s+=uitext["langs none"]}s+='</span><br clear="left" />';s+="<textarea id='editCommentsTA' class='comments-edit-ta' rows=3>";var commentHint=true;if(nd.C!=undefined&&nd.C.length>0){s+=nd.C;commentHint=false}else{s+=uitext["description hint"]}s+="</textarea>";s+="<button id='doneEditComments' disabled='disabled'>"+uitext["save description btn"]+"</button>";s+="</fieldset>";s+="<div><input type='checkbox' id='show_ghosts' "+(this.viewGhosts?"checked":"")+">"+uitext["show deleted checkbox"]+"</div>";s+="<br>";s+="<div id='deactiveatenode' class='comments-edit-done'>"+uitext["delete pos btn"];if(nd._nodelock!==undefined&&userLevel>=nd._nodelock){s+='<img src="/img/icon/lock_unlock.png" class="lockage" title="unlocked: '+nd._nodelock+'">'}else{s+='<img src="/img/icon/lock.png" class="lockage" title="locked: '+nd._nodelock+'">'}s+="</div>";s+="</div>";s+='<div class="modal" id="pro_prompt"><h2>'+uitext["add pro header"]+"</h2><p>"+uitext["add pro desc"]+"</p><form><table border=0><tr><td>"+uitext["add pro field player"]+'</td><td><input id="pro_name"/></td></tr><tr><td>'+uitext["add pro field context"]+'</td><td><input id="pro_context" style="display:none"/></td></tr><button type="submit" id="pro_ok" disabled> '+uitext["ok button"]+' </button><button type="button" class="close"> '+uitext["cancel button"]+" </button></form><br /></div>";this.dom.comments.innerHTML=s;var pro_id=0;$("#pro_name").autocomplete("/db/autoplayer.php",{width:260,selectFirst:false});function proSelected(event,data,formatted){$("#pro_ok").removeAttr("disabled");pro_id=data[1];$.getJSON("/db/player.php?action=get&id="+data[1],function(data){if(data.result==0){$("#pro_context").show()}})}$("#pro_name").result(proSelected);$("#show_ghosts").change(function(){xxx.viewGhosts=$(this).val()=="on";xxx.execNode(false)});$("#editCommentsTA").bind("keyup",function(){$("#doneEditComments").attr("disabled","")});$("#pro_prompt form").submit(function(e){$("#pro_prompt").overlay().close();xxx.nowLoading(t["saving msg"]);var sourceid="player"+pro_id;var src_loc=$("#pro_context").val();var pro_name=$("#pro_name").val();if(nd._sources==undefined){nd._sources=[]}nd._sources.push([sourceid,src_loc,pro_name]);xxx.addSourceToView(sourceid,src_loc,true,pro_name);var success=function(req){xxx.doneLoading()};var failure=function(req){xxx.croak(t["error retrieving"])};var params={action:"add",sourceid:sourceid,txt:src_loc,nodeid:nd._id};ajax("get",xxx.sourceUrl,params,success,failure,xxx,45000);return e.preventDefault()});$("#lang_choice").val(uilang);if(nd._lang!==undefined){$("#lang_choice").val(nd._lang)}if(!this.nodeInDB()){$("#changeNodeStuff").hide()}if(!commentHint){$("#editCommentsTA").css("color","black")}if(typeof nd._labelids!="undefined"){for(var i=0;i<nd._labelids.length;i++){labelid=nd._labelids[i];this.addLabelToView(labelid,true)}}if(typeof nd._sources!="undefined"){for(var i=0;i<nd._sources.length;i++){var sourceid=nd._sources[i][0];var txt=nd._sources[i][1];this.addSourceToView(sourceid,txt,true,nd._sources[i][2])}}var el=byId("deactiveatenode");$("#editCommentsTA").focus(function(){xxx.editingText=true;$(this).css("height",80).css("color","black");$("#addTalk").show(400);if(commentHint){$(this).val("")}commentHint=false});$("#editCommentsTA").blur(function(){xxx.editingText=false});$("#ideal-move").click(function(){xxx.setMoveType(0)});$("#good-move").click(function(){xxx.setMoveType(1)});$("#bad-move").click(function(){xxx.setMoveType(2)});$("#trick-move").click(function(){xxx.setMoveType(3)});$("#question-move").click(function(){xxx.setMoveType(4)});$("#source-select option:first").text(uitext.addsource);$("#source-select option:eq(0)").after('<option value="addpro">'+uitext["add pro source"]+"</option>");$("#source-select").change(function(){xxx.selectSource($(this).val())});$("#label-select").change(function(){xxx.selectLabel($(this).val())});$("#lang_choice").change(function(){$("#editCommentsTA").val(uitext.loading);$.getJSON("/db/description.php?action=get&lang="+$(this).val()+"&nodeid="+nd._id,function(data){$("#editCommentsTA").val(data.text)})});el=byId("doneEditComments");onClick(el,function(e){var txt=$("#editCommentsTA").val();var lang=$("#lang_choice").val();nd.C=txt;var success=function(req){this.doneLoading();if(nd._alllangs[lang]===undefined){s="";if(nd._alllangs.length>0){s=", "}else{$("#langsused").html("")}s+=jlanguages[lang];nd._alllangs[lang]=true;$("#langsused").append(s)}};var failure=function(req){this.croak(t["error retrieving"])};var params={action:"comment",comment:txt,language:lang,id:nd._id};ajax("get",this.saveNodeUrl,params,success,failure,this,45000);this.refresh()},this);el=byId("deactiveatenode");onClick(el,function(e){if(nd._nodelock!==undefined&&userLevel<nd._nodelock){alert("Your level ("+userLevel+") is not high enough to remove this node, which is locked at level "+nd._nodelock);return}var answer=confirm(uitext["confirm delete pos"]);if(!answer){return}var success=function(req){this.doneLoading()};var failure=function(req){this.croak(t["error retrieving"])};var params={action:"delete",id:nd._id};ajax("get",this.saveNodeUrl,params,success,failure,this,45000);this.back();this.nukeChild(nd._id);this.refresh()},this)},doEditHistory:function(){this.editMode=false;this.histMode=true;this.talkMode=false;if(!this.nodeInDB()){var s='<div id="newNodeStuff">'+uitext["newnode note"]+"</div>";this.dom.comments.innerHTML=s;return}this.dom.comments.innerHTML="Loading...";this.nowLoading("Getting history");var success=function(req){this.doneLoading();hist=eval("("+req.responseText+")");var s="<table id='history_list'>";for(var i=0;i<hist.length;i++){var h=hist[i];s+="<tr class='rowColor"+(i&1)+"'>";s+="<td>";switch(h.genre){case"n":s+=uitext["history delete"];break;case"L":s+=uitext["history label"];break;case"S":s+=uitext["history source"];break;case"s":s+=uitext["history remove source"];break;case"C":s+=uitext["history description"];break;case"l":s+=uitext["history remove label"];break;case"N":if(i<hist.length-1){s+=uitext["history type"]}else{s+=uitext["history create"]}break;case"F":s+=uitext["history flip"];break;case"T":s+=uitext["history transfer"];break}s+="</td>";s+="<td>"+h.date+"</td>";s+="<td>";if(h.username!=undefined){s+="<a class='iframe' href='/user/user_inline.php?uid="+h.userid+"'>"+h.username+"</a>"}else{s+=h.ip}s+="</td>";if(h.genre=="L"||h.genre=="l"){s+="<td>"+jlabels[h.labelid]+"</td>"}else{if(h.genre=="N"){s+="<td>"+this.mtypes[h.movetype]+"</td>"}else{if(h.genre=="S"||h.genre=="s"){s+="<td>";if(h.playername!==undefined){s+=h.playername}else{s+=jsources[h.sourceid].name}if(h.sourcetxt.length>0){s+=" - "+h.sourcetxt}s+="</td>"}else{if(h.genre=="C"){s+="<td>";s+=jlanguages[h.lang];s+="</td>"}else{if(h.genre=="T"){s+="<td>"+h.transfertxt+"</td>"}else{s+="<td></td>"}}}}}s+="</tr>";if((h.genre)=="C"){s+="<tr class='rowColor"+(i&1)+"'>";s+="<td colspan=4>"+h.comment+"</td></tr>"}}s+="</table>";this.dom.comments.innerHTML=s;$("a.iframe").fancybox()};var failure=function(req){this.croak(t["error retrieving"])};var root=this.cursor.getGameRoot();var params={nodeid:this.cursor.node._id};ajax("get","/db/history.php",params,success,failure,this,45000)},addTalkMsg:function(txt,ip,date,userid,username,id){var hasNuke=userLevel>=1000;var hasDelete=userLevel>=200||userid!=0&&userid==userID;var s="<tr class='talk-row'>";s+="<td class='talk-cell'>";s+='<span class="talk-hdr"><img src="/img/icon/comment.png"> '+uitext.talkby+" ";if(userid==0){s+=ip}else{s+='<a href="/user/user_inline.php?uid='+userid+'" class="user-'+userid+' iframe">'+username+"</a>"}s+=" "+uitext.talkondate+" "+date+"</span><br>";s+=this.wikiSources(this.wikiPosLinks(txt));if(id>0){if(hasDelete){s+='<br><a href="#" id="deleteTalk'+id+'">'+uitext.talkdelete+"</a>"}if(hasNuke){s+='<br><a href="#" id="nukeTalk'+id+'">nuke</a>'}}s+="</td></tr>";$("#talkmsgtable > tbody").prepend(s);$("a.iframe").fancybox();$("a.poslink").tooltip({offset:[-70,0]});$("a.iframesrc").fancybox({frameWidth:900,frameHeight:600});if(hasDelete){$("#deleteTalk"+id).click(function(){var answer=confirm("Delete this message?");if(!answer){return}$.getJSON("/db/talk.php?action=delete&id="+id+"&nodeid=1",function(data){});$(this).closest("tr").remove()})}if(hasNuke){$("#nukeTalk"+id).click(function(){var answer=confirm("Permanently delete this message?");if(!answer){return}$.getJSON("/db/talk.php?action=nuke&id="+id+"&nodeid=1",function(data){});$(this).closest("tr").remove()})}},doEditTalk:function(){this.editMode=false;this.histMode=false;this.talkMode=true;var nd=this.cursor.node;var s='<div id="talkpage" dir="ltr">';if(this.nodeInDB()){s+="<textarea id='talkTA' class='talk-edit-ta' rows=1>";s+=uitext["type new comment"];s+="</textarea>";s+="<div id='addTalk' class='styled-button'>Add Comment</div><br>";s+="<table width='100%' cellspacing=4 border=0 id='talkmsgtable'><tbody></tbody></table>"}else{s+='<div id="newNodeStuff">'+uitext["newnode note"]+"</div>"}s+="</div>";this.dom.comments.innerHTML=s;var xxx=this;var didTAfocus=false;$("#talkTA").focus(function(){xxx.editingText=true;$(this).css("height",80).css("color","black");$("#addTalk").show(400);if(!didTAfocus){$(this).val("")}didTAfocus=true});$("#talkTA").blur(function(){xxx.editingText=false});$("#addTalk").hide();var el=byId("addTalk");onClick(el,function(e){var txt=$("#talkTA").val();$("#talkTA").val("");this.addTalkMsg(txt,"me","now",0,"",0);$("#talkTA").css("height",14);$("#addTalk").hide(500);var success=function(req){this.doneLoading()};var failure=function(req){this.croak(t["error retrieving"])};var params={action:"add",text:txt,nodeid:nd._id};ajax("get","/db/talk.php",params,success,failure,this,45000)},this);if(this.nodeInDB()){this.nowLoading("Getting talk");var success=function(req){this.doneLoading();msgs=eval("("+req.responseText+")");var s="";if(msgs.result<0){s+="Failed to retrieve messages.";$("#talkpage").append(s)}else{for(var i=0;i<msgs.talk.length;i++){var msg=msgs.talk[i];this.addTalkMsg(msg.text,msg.ip,msg.date,msg.userid,msg.username,msg.id)}}};var failure=function(req){this.croak(t["error retrieving"])};var root=this.cursor.getGameRoot();var params={action:"get",nodeid:this.cursor.node._id};ajax("get","/db/talk.php",params,success,failure,this,45000)}},deleteLabel:function(x){alert(x);console.log(x)},addLabelToView:function(labelid,editMode){var s=jlabels[labelid];if(editMode){var elid="labelDelete"+labelid;elid+="_"+(new Date()).getTime();s+=' <a id="'+elid+'" href="#"><img src="/img/icon/delete.png" class="delicon"></a>'}this.prependComment(s);if(editMode){var nd=this.cursor.node;var el=byId(elid);onClick(el,function(e){var answer=confirm("Really remove this label?");if(!answer){return}var indx=nd._labelids.indexOf(labelid);nd._labelids.splice(indx,1);this.refresh();var success=function(req){this.doneLoading()};var failure=function(req){this.croak(t["error retrieving"])};var params={action:"delete",labelid:labelid,nodeid:nd._id,userid:userID};ajax("get",this.labelUrl,params,success,failure,this,45000)},this)}},addSourceToView:function(sourceid,src_loc,editMode,pro_name){var elid="sourceDelete"+sourceid;elid+="_"+(new Date()).getTime();if(sourceid.indexOf("player")==0){var s='<div class="sources">'+pro_name+"</a>"}else{var src=jsources[sourceid];var s='<div class="sources">';if(src.senseis!=""){s+="<a class='iframesrc' href='http://senseis.xmp.net/?"+src.senseis+"'>"+src.name+"</a>"}else{s+=src.name}}if(src_loc.length>0){s+=' - <span class="sourceloc">'+src_loc+"</span>"}if(editMode){s+=' <a id="'+elid+'" href="#"><img src="/img/icon/delete.png" class="delicon"></a>'}s+="</div>";$("#node_sources").append("<span class='src_hdr'>"+uitext.sources+"</span>");$("#node_sources").append(s);$("a.iframesrc").fancybox({frameWidth:900,frameHeight:600});if(editMode){var nd=this.cursor.node;var el=byId(elid);onClick(el,function(e){var indx=0;for(;indx<nd._sources.length;indx++){if(nd._sources[indx][0]==sourceid&&nd._sources[indx][1]==src_loc){break}}if(indx==nd._sources.length){alert("Could not find source: "+sourceid);return}var answer=confirm("Really remove this source?");if(!answer){return}nd._sources.splice(indx,1);this.refresh();var success=function(req){this.doneLoading()};var failure=function(req){this.croak(t["error retrieving"])};var params={action:"delete",sourceid:sourceid,txt:src_loc,nodeid:nd._id};ajax("get",this.sourceUrl,params,success,failure,this,45000)},this)}},selectLabel:function(labelid){$("#label-select option:first").attr("selected",true);$("#label-select").blur();var nd=this.cursor.node;if(!this.nodeInDB()){alert("You must save the position before adding comments.");return}if(!this.warnEditor()){return}this.nowLoading(t["saving msg"]);if(nd._labelids==undefined){nd._labelids=[]}nd._labelids.push(labelid);this.addLabelToView(labelid,true);var success=function(req){this.doneLoading()};var failure=function(req){this.croak(t["error retrieving"])};var params={action:"add",labelid:labelid,nodeid:this.cursor.node._id};ajax("get",this.labelUrl,params,success,failure,this,45000)},selectSource:function(sourceid){if(sourceid===""){return}$("#source-select option:first").attr("selected",true);var xxx=this;var nd=this.cursor.node;if(!this.nodeInDB()){alert("You must save the position before adding a source.");return}if(sourceid=="addpro"){var xyy=$("#pro_prompt");this.editingText=true;$("#pro_prompt").overlay({expose:{color:"#333",loadSpeed:200,opacity:0.9},closeOnClick:false,api:true,onClose:function(event){xxx.editingText=false}}).load();$("#pro_name").focus();return}var src_loc=prompt(uitext["book detail prompt"],"");if(src_loc==null){return}this.nowLoading(t["saving msg"]);if(nd._sources==undefined){nd._sources=[]}nd._sources.push([sourceid,src_loc]);this.addSourceToView(sourceid,src_loc,true);var success=function(req){this.doneLoading()};var failure=function(req){this.croak(t["error retrieving"])};var params={action:"add",sourceid:sourceid,txt:src_loc,nodeid:nd._id};ajax("get",this.sourceUrl,params,success,failure,this,45000)},selectTool:function(tool){var cursor;hide(this.dom.labelInput);if(tool=="region"){cursor="crosshair"}else{if(tool=="comment"){this.startEditComment()}else{if(tool=="gameinfo"){this.startEditGameInfo()}else{if(tool=="label"){show(this.dom.labelInput,"inline");this.dom.labelInput.focus()}else{cursor="default";this.regionBegun=false;this.hideRegion();hide(this.dom.searchButton);hide(this.dom.searchAlgo)}}}}this.board.renderer.setCursor(cursor);this.mode=tool;this.dom.toolsSelect.value=tool},startEditComment:function(){this.closeSearch();var div=this.dom.commentsEdit;div.style.position="absolute";div.style.top=this.dom.comments.offsetTop+"px";div.style.left=this.dom.comments.offsetLeft+"px";show(this.dom.shade);this.dom.comments.innerHTML="";show(div);show(this.dom.commentsEditDone);this.dom.commentsEditTa.value=this.cursor.node.C||"";this.dom.commentsEditTa.focus();this.editingText=true},finishEditComment:function(){this.editingText=false;var oldC=this.cursor.node.C;var newC=this.dom.commentsEditTa.value;if(oldC!=newC){this.unsavedChanges=true;this.cursor.node.C=newC}if(!this.cursor.node.C){delete this.cursor.node.C}hide(this.dom.shade);hide(this.dom.commentsEdit);show(this.dom.comments);this.selectTool("play");var deleted=this.checkForEmptyNode();this.refresh();if(deleted){this.prependComment(t["position deleted"])}},startEditGameInfo:function(){this.closeSearch();var div=this.dom.gameInfoEdit;div.style.position="absolute";div.style.top=this.dom.comments.offsetTop+"px";div.style.left=this.dom.comments.offsetLeft+"px";show(this.dom.shade);this.dom.comments.innerHTML="";show(div);show(this.dom.gameInfoEditDone);var root=this.cursor.getGameRoot();var html=["<table>"];for(var prop in this.infoLabels){html.push("<tr><td>"+this.infoLabels[prop]+':</td><td><input type="text" id="game-info-edit-field-'+prop+'" value="'+(root[prop]||"")+'"></td></tr>')}html.push("</table>");this.dom.gameInfoEditForm.innerHTML=html.join("");setTimeout(function(){byId("game-info-edit-field-GN").focus()},0);this.editingText=true},finishEditGameInfo:function(){this.editingText=false;hide(this.dom.shade);hide(this.dom.gameInfoEdit);show(this.dom.comments);var root=this.cursor.getGameRoot();var newval=null;for(var prop in this.infoLabels){newval=byId("game-info-edit-field-"+prop).value;if((root[prop]||"")!=newval){root[prop]=newval;this.unsavedChanges=true}}this.showGameInfo(root);this.dom.gameInfoEditForm.innerHTML="";this.selectTool("play");this.refresh()},updateControls:function(){this.dom.moveNumber.innerHTML=(this.moveNumber?uitext["move number"].replace("%",this.moveNumber):(this.permalinkable?uitext.permalink:""));this.dom.whiteCaptures.innerHTML=t.captures+": <span>"+this.board.captures.W+"</span>";this.dom.blackCaptures.innerHTML=t.captures+": <span>"+this.board.captures.B+"</span>";this.dom.whiteTime.innerHTML=t["time left"]+": <span>"+(this.timeW?this.timeW:"--")+"</span>";this.dom.blackTime.innerHTML=t["time left"]+": <span>"+(this.timeB?this.timeB:"--")+"</span>";removeClass(this.dom.controlPass,"pass-on");this.dom.variations.innerHTML="";for(var i=0;i<this.variations.length;i++){var varLabel=i+1;var overlapped=false;if(!this.variations[i].move||this.variations[i].move=="tt"){addClass(this.dom.controlPass,"pass-on")}else{if(this.prefs.markNext||this.variations.length>1){var varPt=this.sgfCoordToPoint(this.variations[i].move);if(this.board.getMarker(varPt)!=this.board.EMPTY){var marker=this.board.getMarker(varPt);if(marker.indexOf("var:")!==0){varLabel=marker}else{overlapped=true}}if(this.prefs.markVariations&&!overlapped){var s="var:"+varLabel;if(varLabel.toString().search(/^-?[0-9]+$/)==0){if(varLabel>=10){s="var:_"}}if(this.variations[i].mtype!=undefined){s+=":"+this.variations[i].mtype}this.board.addMarker(varPt,s)}}}if(false){var varNav=document.createElement("div");varNav.className="variation-nav";varNav.innerHTML=varLabel;addEvent(varNav,"click",function(e,arg){arg.me.variation(arg.varNum)},{me:this,varNum:this.variations[i].varNum});this.dom.variations.appendChild(varNav)}}if(this.variations.length<2&&false){this.dom.variations.innerHTML="<div class='variation-nav none'>"+t["no variations"]+"</div>"}if(this.cursor.hasNext()){addClass(this.dom.controlForward,"forward-on");addClass(this.dom.controlLast,"last-on")}else{removeClass(this.dom.controlForward,"forward-on");removeClass(this.dom.controlLast,"last-on")}if(this.cursor.hasPrevious()){addClass(this.dom.controlBack,"back-on");addClass(this.dom.controlFirst,"first-on")}else{removeClass(this.dom.controlBack,"back-on");removeClass(this.dom.controlFirst,"first-on");var info="";if(!this.prefs.showPlayerInfo){info+=this.getGameDescription(true)}if(!this.prefs.showGameInfo){info+=this.dom.infoGame.innerHTML}}if(!this.progressiveLoad){this.updateNavSlider()}if(this.prefs.showNavTree){this.updateNavTree()}var node=this.cursor.node,pos,html,js;if(node._parent&&!node._parent._parent&&node._parent._children.length>1){pos=node.getPosition();html=t["multi-game sgf"];js="javascript:eidogo.delegate("+this.uniq+', "goTo", [';if(pos){html+="<a href='"+js+(pos-1)+",0])'>"+t["previous game"]+"</a>"}if(node._parent._children[pos+1]){html+=(pos?" | ":"")+"<a href='"+js+(pos+1)+",0])'>"+t["next game"]+"</a>"}}},setColor:function(color){this.prependComment(color=="B"?t["black to play"]:t["white to play"]);this.currentColor=this.problemColor=color},setMoveNumber:function(num){this.moveNumber=num},playMove:function(coord,color,noRender){color=color||this.currentColor;this.currentColor=(color=="B"?"W":"B");color=color=="W"?this.board.WHITE:this.board.BLACK;var pt=this.sgfCoordToPoint(coord);if((!coord||coord=="tt"||coord=="")&&!noRender){this.prependComment((color==this.board.WHITE?t.white:t.black)+" "+t.passed,"comment-pass")}else{if(coord=="resign"){this.prependComment((color==this.board.WHITE?t.white:t.black)+" "+t.resigned,"comment-resign")}else{if(coord&&coord!="tt"){this.board.addStone(pt,color);this.rules.apply(pt,color);if(this.prefs.markCurrent&&!noRender){this.addMarker(coord,"current")}}}}},addStone:function(coord,color){if(!(coord instanceof Array)){coord=[coord]}coord=this.expandCompressedPoints(coord);for(var i=0;i<coord.length;i++){this.board.addStone(this.sgfCoordToPoint(coord[i]),color=="AW"?this.board.WHITE:color=="AB"?this.board.BLACK:this.board.EMPTY)}},addMarker:function(coord,type){if(!(coord instanceof Array)){coord=[coord]}coord=this.expandCompressedPoints(coord);var label;for(var i=0;i<coord.length;i++){switch(type){case"TR":label="triangle";break;case"SQ":label="square";break;case"CR":label="circle";break;case"MA":label="ex";break;case"TW":label="territory-white";break;case"TB":label="territory-black";break;case"DD":label="dim";break;case"LB":label=(coord[i].split(":"))[1];break;default:label=type;break}this.board.addMarker(this.sgfCoordToPoint((coord[i].split(":"))[0]),label)}},showTime:function(value,type){var tp=(type=="BL"||type=="OB"?"timeB":"timeW");if(type=="BL"||type=="WL"){var mins=Math.floor(value/60);var secs=(value%60).toFixed(0);secs=(secs<10?"0":"")+secs;this[tp]=mins+":"+secs}else{this[tp]+=" ("+value+")"}},showAnnotation:function(value,type){var msg;switch(type){case"N":msg=value;break;case"GB":msg=(value>1?t.vgb:t.gb);break;case"GW":msg=(value>1?t.vgw:t.gw);break;case"DM":msg=(value>1?t.dmj:t.dm);break;case"UC":msg=t.uc;break;case"TE":msg=t.te;break;case"BM":msg=(value>1?t.vbm:t.bm);break;case"DO":msg=t["do"];break;case"IT":msg=t.it;break;case"HO":msg=t.ho;break}this.prependComment(msg)},showComments:function(comments,junk,noRender){return;if(!comments||noRender){return}var s=comments.replace(/^(\n|\r|\t|\s)+/,"").replace(/\n/g,"<br />");$("#node_comment").append(s)},prependComment:function(content,cls){cls=cls||"comment-status";content="<div class='"+cls+"'>"+content+"</div>";$("#node_labels").append(content)},downloadSgf:function(evt){stopEvent(evt);if(this.downloadUrl){if(this.unsavedChanges){alert(t["unsaved changes"]);return}location.href=this.downloadUrl+this.gameName}else{if(isMoz){location.href="data:text/plain,"+encodeURIComponent(this.cursor.getGameRoot().toSgf())}}},save:function(evt){stopEvent(evt);var success=function(req){this.hook("saved",[req.responseText])};var failure=function(req){this.croak(t["error retrieving"])};var sgf=this.cursor.getGameRoot().toSgf();ajax("POST",this.saveUrl,{sgf:sgf},success,failure,this,30000)},constructDom:function(){this.dom.player=document.createElement("div");this.dom.player.className="eidogo-player"+(this.theme?" theme-"+this.theme:"");this.dom.player.id="player-"+this.uniq;this.dom.container.innerHTML="";eidogo.util.show(this.dom.container);this.dom.container.appendChild(this.dom.player);var domHtml="            <div id='board-container' class='board-container'></div>            <div id='controls-container' class='controls-container'>                <ul id='controls' class='controls'>                    <li id='control-first' class='control first' title='"+uitext["go-first tip"]+"'>First</li>                    <li id='control-back' class='control back' title='"+uitext["go-back tip"]+"'>Back</li>                    <li id='control-forward' class='control forward' title='"+uitext["go-forward tip"]+"'>Forward</li>                    <li id='control-last' class='control last' title='"+uitext["go-last tip"]+"'>Last</li>                    <li id='control-pass' class='control pass' title='"+uitext["pass tip"]+"'>Pass</li>                </ul>                <div id='move-number' class='move-number"+(this.permalinkable?" permalink":"")+"' title='"+uitext["permalink tip"]+"'></div>                <div id='continuations-count' class='continuation-cnt' title='"+uitext["continuations tip"]+"'></div>                <div id='nav-slider' class='nav-slider'>                    <div id='nav-slider-thumb' class='nav-slider-thumb'></div>                </div>                <div id='variations-container' class='variations-container'>                    <div id='variations-label' class='variations-label'>"+t.variations+":</div>                    <div id='variations' class='variations'></div>                </div>                <div id='movetype-container' class='movetype-container-null'><table border=0 width=100%><tr><td>                    <div id='insignia' class='insignia'>"+uitext.insig_joseki+"</div></td><td>                    <div id='movetype-label' class='movetype-label'>"+t.movetype+"</div></td><td align='right'> <table border=0><tr><td><a href='' id='vote-up-action'><img id='vote-up' src='/img/icon/arrow_up_grey.png' border=0></a></td></tr><tr><td><a href='' id='vote-down-action'><img id='vote-down' src='/img/icon/arrow_down_grey.png' border=0></a></td></tr></table></td><td><a class='iframesrc' href='/find/nodevotes.php' id='show-votes'><span class='votetotal'><span id='vote-total'>0</span> <span id='vote-name'>votes</span></span></a></td></tr><tr><td colspan=2>                    <div id='movetype' class='movetype'></div></td></tr></table>                </div>                <div class='controls-stop'></div>            </div>            <div id='tools-container' class='tools-container'"+(this.prefs.showTools?"":" style='display: none'")+">                <div id='tools-label' class='tools-label'>"+t.tool+":</div>                <select id='tools-select' class='tools-select'>                    <option value='play'>&#9658; "+t.play+"</option>                    <option value='view'>&#8594; "+t.view+"</option>                    <option value='add_b'>&#9679; "+t.add_b+"</option>                    <option value='add_w'>&#9675; "+t.add_w+"</option>                    "+(this.searchUrl?("<option value='region'>&#9618; "+t.region+"</option>"):"")+"                    "+(this.saveUrl&&!this.progressiveLoad?("<option value='comment'>&para; "+t["edit comment"]+"</option>"):"")+"                    "+(this.saveUrl?("<option value='gameinfo'>&#8962; "+t["edit game info"]+"</option>"):"")+"                    <option value='tr'>&#9650; "+t.triangle+"</option>                    <option value='sq'>&#9632; "+t.square+"</option>                    <option value='cr'>&#9679; "+t.circle+"</option>                    <option value='x'>&times; "+t.x+"</option>                    <option value='letter'>A "+t.letter+"</option>                    <option value='number'>5 "+t.number+"</option>                    <option value='label'>&Ccedil; "+t.label+"</option>                    <option value='dim'>&#9619; "+t.dim+"</option>                    <option value='clear'>&#9617; "+t.clear+"</option>                </select>                <select id='search-algo' class='search-algo'>                    <option value='corner'>"+t["search corner"]+"</option>                    <option value='center'>"+t["search center"]+"</option>                </select>                <input type='button' id='search-button' class='search-button' value='"+t.search+"' />                <input type='text' id='label-input' class='label-input' />            </div>            <div id='combox' class='edit-box'><ul id='tabnav'><li class='sel'><a href='#' id='edit-home'>"+uitext.pageview+"</a></li><li class='tab2'><a href='#' id='edit-com'>"+uitext.pageedit+"</a></li><li class=''><a href='#' id='edit-history'>"+uitext.pagehistory+"</a></li><li class='tab4'><a href='#' id='edit-talk'>"+uitext.pagetalk+"<span id='talkCount'></span></a></li></ul>              <div id='comments' class='comments'></div>            </div>            <div id='comments-edit' class='comments-edit'>                <textarea id='comments-edit-ta' class='comments-edit-ta'></textarea>                <div id='comments-edit-done' class='comments-edit-done'>"+t.done+"</div>            </div>            <div id='game-info-edit' class='game-info-edit'>                <div id='game-info-edit-form' class='game-info-edit-form'></div>                <div id='game-info-edit-done' class='game-info-edit-done'>"+t.done+"</div>            </div>            <div id='search-container' class='search-container'>                <div id='search-close' class='search-close'>"+t["close search"]+"</div>                <p class='search-count'><span id='search-count'></span>&nbsp;"+t["matches found"]+"                    Showing <span id='search-offset-start'></span>-<span id='search-offset-end'></span></p>                <div id='search-results-container' class='search-results-container'>                    <div class='search-result'>                        <span class='pw'><b>"+t.white+"</b></span>                        <span class='pb'><b>"+t.black+"</b></span>                        <span class='re'><b>"+t.result+"</b></span>                        <span class='dt'><b>"+t.date+"</b></span>                        <div class='clear'></div>                    </div>                    <div id='search-results' class='search-results'></div>                </div>            </div>            <div id='info' class='info'>                <div id='info-players' class='players'>                    <div id='white' class='player white'>                        <div id='white-name' class='name'></div>                        <div id='white-captures' class='captures'></div>                        <div id='white-time' class='time'></div>                    </div>                    <div id='black' class='player black'>                        <div id='black-name' class='name'></div>                        <div id='black-captures' class='captures'></div>                        <div id='black-time' class='time'></div>                    </div>                </div>                <div id='info-game' class='game'></div>            </div>            <div id='nav-tree-container' class='nav-tree-container'>                <div id='nav-tree' class='nav-tree'></div>            </div>            <div id='options' class='options'>                "+(this.saveUrl?"<a id='option-save' class='option-save' href='#'>"+t["save to server"]+"</a>":"")+"                "+(this.downloadUrl||isMoz?"<a id='option-download' class='option-download' href='#'>"+t["download sgf"]+"</a>":"")+"                <div class='options-stop'></div>            </div>            <div id='preferences' class='preferences'>                <div><input type='checkbox'> Show variations on board</div>                <div><input type='checkbox'> Mark current move</div>            </div>            <div id='footer' class='footer'></div>            <div id='shade' class='shade'></div>        ";domHtml=domHtml.replace(/ id='([^\']+)'/g," id='$1-"+this.uniq+"'");this.dom.player.innerHTML=domHtml;var re=/ id='([^']+)-\d+'/g;var match;var id;var jsName;while(match=re.exec(domHtml)){id=match[0].replace(/'/g,"").replace(/ id=/,"");jsName="";match[1].split("-").forEach(function(word,i){word=i?word.charAt(0).toUpperCase()+word.substring(1):word;jsName+=word});this.dom[jsName]=byId(id)}this.dom.movetypeLabel.innerHTML="unset";[["moveNumber","setPermalink"],["controlFirst","first"],["controlBack","back"],["controlForward","forward"],["controlLast","last"],["controlPass","pass"],["optionDownload","downloadSgf"],["optionSave","save"],["commentsEditDone","finishEditComment"],["gameInfoEditDone","finishEditGameInfo"],["navTree","navTreeClick"],].forEach(function(eh){if(this.dom[eh[0]]){onClick(this.dom[eh[0]],this[eh[1]],this)}}.bind(this));addEvent(this.dom.toolsSelect,"change",function(e){this.selectTool.apply(this,[(e.target||e.srcElement).value])},this,true);var xxx=this;$("#edit-home-0").click(function(event){event.preventDefault();$("#tabnav-0 li").removeClass("sel");$("#tabnav-0 li:eq(0)").addClass("sel");xxx.doViewNode()});$("#edit-com-0").click(function(event){event.preventDefault();$("#tabnav-0 li").removeClass("sel");$("#tabnav-0 li:eq(1)").addClass("sel");xxx.doEditComment()});$("#edit-history-0").click(function(event){event.preventDefault();$("#tabnav-0 li").removeClass("sel");$("#tabnav-0 li:eq(2)").addClass("sel");xxx.doEditHistory()});$("#edit-talk-0").click(function(event){event.preventDefault();$("#tabnav-0 li").removeClass("sel");$("#tabnav-0 li:eq(3)").addClass("sel");xxx.doEditTalk()});$("#vote-up-action-0").click(function(event){event.preventDefault();xxx.doVote(1)});$("#vote-down-action-0").click(function(event){event.preventDefault();xxx.doVote(-1)})},doVote:function(vote){if(!userLoggedIn){alert(uitext["vote login"]);return}var nd=this.cursor.node;var mt=nd._mtype;if(mt===undefined){return}if(nd._myVote[mt]==vote){nd._myVote[mt]=0;nd._votes[mt][0]--;nd._votes[mt][1]-=vote}else{nd._votes[mt][1]-=nd._myVote[mt];nd._myVote[mt]=vote;nd._votes[mt][0]++;nd._votes[mt][1]+=vote}$.getJSON("/db/vote.php?nodeid="+nd._id+"&vote="+nd._myVote[mt]+"&mtype="+mt,function(data){if(data.result==0){}});this.setVoteUI()},setVoteUI:function(){var nd=this.cursor.node;var mt=nd._mtype;if(mt!==undefined){$("#vote-up-0").show().attr("src","/img/icon/arrow_up_"+((nd._myVote[mt]==1)?"green":"grey")+".png");$("#vote-down-0").show().attr("src","/img/icon/arrow_down_"+((nd._myVote[mt]==-1)?"red":"grey")+".png");$("#vote-total-0").show().html(nd._votes[mt][1]);$("#vote-name-0").show()}else{$("#vote-up-0").hide();$("#vote-down-0").hide();$("#vote-total-0").hide();$("#vote-name-0").hide()}},enableNavSlider:function(){if(this.progressiveLoad){hide(this.dom.navSliderThumb);return}this.dom.navSlider.style.cursor="pointer";var sliding=false;var timeout=null;addEvent(this.dom.navSlider,"mousedown",function(e){sliding=true;stopEvent(e)},this,true);addEvent(document,"mousemove",function(e){if(!sliding){return}var xy=getElClickXY(e,this.dom.navSlider);clearTimeout(timeout);timeout=setTimeout(function(){this.updateNavSlider(xy[0])}.bind(this),10);stopEvent(e)},this,true);addEvent(document,"mouseup",function(e){if(!sliding){return true}sliding=false;var xy=getElClickXY(e,this.dom.navSlider);this.updateNavSlider(xy[0]);return true},this,true)},updateNavSlider:function(offset){var width=this.dom.navSlider.offsetWidth-this.dom.navSliderThumb.offsetHeight;var steps=this.totalMoves;var offsetGiven=!!offset;offset=offset||(this.moveNumber/steps*width);offset=offset>width?width:offset;offset=offset<0?0:offset;var moveOffset=parseInt(offset/width*steps,10);if(offsetGiven){this.nowLoading();var delta=moveOffset-this.cursor.getMoveNumber();for(var i=0;i<Math.abs(delta);i++){if(delta>0){this.variation(null,true)}else{if(delta<0){this.cursor.previous()}}}if(delta<0){this.board.revert(Math.abs(delta))}this.doneLoading();this.refresh()}offset=parseInt(moveOffset/steps*width,10)||0;this.dom.navSliderThumb.style.left=offset+"px"},updateNavTree:function(update){if(!this.prefs.showNavTree){return}if(this.updatedNavTree){this.showNavTreeCurrent();return}if(!update){if(this.navTreeTimeout){clearTimeout(this.navTreeTimeout)}this.navTreeTimeout=setTimeout(function(){this.updateNavTree(true)}.bind(this),eidogo.browser.ie?1000:500);return}this.updatedNavTree=true;var navGrid=[],gameRoot=this.cursor.getGameRoot();path=[gameRoot.getPosition()],cur=new eidogo.GameCursor(),maxx=0;var traverse=function(node,startx,starty){var y=starty,x=startx;var n=node,width=1;while(n&&n._children.length==1){width++;n=n._children[0]}while(navGrid[y]&&navGrid[y].slice(x,x+width+1).some(function(el){return(typeof el!="undefined")})){y++}do{if(!navGrid[y]){navGrid[y]=[]}cur.node=node;node._pathStr=path.join("-")+"-"+(x-startx);navGrid[y][x]=node;if(x>maxx){maxx=x}x++;if(node._children.length!=1){break}node=node._children[0]}while(node);for(var i=0;i<node._children.length;i++){path.push(i);traverse(node._children[i],x,y);path.pop()}};traverse(gameRoot,0,0);var html=["<table class='nav-tree'>"],node,td,cur=new eidogo.GameCursor(),x,y,showLine,ELBOW=1,LINE=2;for(x=0;x<maxx;x++){showLine=false;for(y=navGrid.length-1;y>0;y--){if(!navGrid[y][x]){if(typeof navGrid[y][x+1]=="object"){navGrid[y][x]=ELBOW;showLine=true}else{if(showLine){navGrid[y][x]=LINE}}}else{showLine=false}}}for(y=0;y<navGrid.length;y++){html.push("<tr>");for(x=0;x<navGrid[y].length;x++){node=navGrid[y][x];if(node==ELBOW){td="<div class='elbow'></div>"}else{if(node==LINE){td="<div class='line'></div>"}else{if(node){td=["<a href='#' id='navtree-node-",node._pathStr,"' class='",(typeof node.W!="undefined"?"w":(typeof node.B!="undefined"?"b":"x")),"'>",x,"</a>"].join("")}else{td="<div class='empty'></div>"}}}html.push("<td>");html.push(td);html.push("</td>")}html.push("</tr>")}html.push("</table>");this.dom.navTree.innerHTML=html.join("");setTimeout(function(){this.showNavTreeCurrent()}.bind(this),0)},showNavTreeCurrent:function(){var id="navtree-node-"+this.cursor.getPath().join("-"),current=byId(id);if(!current){return}if(this.prevNavTreeCurrent){this.prevNavTreeCurrent.className=this.prevNavTreeCurrentClass}this.prevNavTreeCurrent=current;this.prevNavTreeCurrentClass=current.className;current.className="current";var w=current.offsetWidth,h=current.offsetHeight,xy=eidogo.util.getElXY(current),navxy=eidogo.util.getElXY(this.dom.navTree),l=xy[0]-navxy[0],t=xy[1]-navxy[1],ntc=this.dom.navTreeContainer,maxl=ntc.scrollLeft,maxr=maxl+ntc.offsetWidth-100;maxt=ntc.scrollTop,maxb=maxt+ntc.offsetHeight-30;if(l<maxl){ntc.scrollLeft-=(maxl-l)}if(l+w>maxr){ntc.scrollLeft+=((l+w)-maxr)}if(t<maxt){ntc.scrollTop-=(maxt-t)}if(t+h>maxb){ntc.scrollTop+=((t+h)-maxb)}},navTreeClick:function(e){var target=e.target||e.srcElement;if(!target||!target.id){return}var path=target.id.replace(/^navtree-node-/,"").split("-");this.goTo(path,true);stopEvent(e)},resetLastLabels:function(){this.labelLastNumber=1;this.labelLastLetter="A"},getGameDescription:function(excludeGameName){var root=this.cursor.getGameRoot();if(!root){return}var desc=(excludeGameName?"":root.GN||this.gameName);if(root.PW&&root.PB){var wr=root.WR?" "+root.WR:"";var br=root.BR?" "+root.BR:"";desc+=(desc.length?" - ":"")+root.PW+wr+" vs "+root.PB+br}return desc},sgfCoordToPoint:function(coord){if(!coord||coord=="tt"){return{x:null,y:null}}var sgfCoords={a:0,b:1,c:2,d:3,e:4,f:5,g:6,h:7,i:8,j:9,k:10,l:11,m:12,n:13,o:14,p:15,q:16,r:17,s:18};return{x:sgfCoords[coord.charAt(0)],y:sgfCoords[coord.charAt(1)]}},pointToSgfCoord:function(pt){if(!pt||(this.board&&!this.boundsCheck(pt.x,pt.y,[0,this.board.boardSize-1]))){return null}var pts={0:"a",1:"b",2:"c",3:"d",4:"e",5:"f",6:"g",7:"h",8:"i",9:"j",10:"k",11:"l",12:"m",13:"n",14:"o",15:"p",16:"q",17:"r",18:"s"};return pts[pt.x]+pts[pt.y]},pointToReadableCoord:function(pt){if(!pt||(this.board&&!this.boundsCheck(pt.x,pt.y,[0,this.board.boardSize-1]))){return null}var pts={0:"A",1:"B",2:"C",3:"D",4:"E",5:"F",6:"G",7:"H",8:"J",9:"K",10:"l",11:"m",12:"N",13:"O",14:"P",15:"Q",16:"R",17:"S",18:"T"};return pts[pt.x]+(19-pt.y)},expandCompressedPoints:function(coords){var bounds;var ul,lr;var x,y;var newCoords=[];var hits=[];for(var i=0;i<coords.length;i++){bounds=coords[i].split(/:/);if(bounds.length>1){ul=this.sgfCoordToPoint(bounds[0]);lr=this.sgfCoordToPoint(bounds[1]);for(x=ul.x;x<=lr.x;x++){for(y=ul.y;y<=lr.y;y++){newCoords.push(this.pointToSgfCoord({x:x,y:y}))}}hits.push(i)}}coords=coords.concat(newCoords);return coords},setPermalink:function(){if(!this.permalinkable){return true}this.hook("setPermalink")},nowLoading:function(msg){if(this.croaked||this.problemMode){return}msg=msg||uitext.loading+"...";if(byId("eidogo-loading-"+this.uniq)){return}this.domLoading=document.createElement("div");this.domLoading.id="eidogo-loading-"+this.uniq;this.domLoading.className="eidogo-loading"+(this.theme?" theme-"+this.theme:"");this.domLoading.innerHTML=msg;this.dom.player.appendChild(this.domLoading)},doneLoading:function(){if(this.domLoading&&this.domLoading!=null&&this.domLoading.parentNode){this.domLoading.parentNode.removeChild(this.domLoading);this.domLoading=null}},croak:function(msg){this.doneLoading();if(this.board){alert(msg)}else{if(this.problemMode){this.prependComment(msg)}else{this.dom.player.innerHTML+="<div class='eidogo-error "+(this.theme?" theme-"+this.theme:"")+"'>"+msg.replace(/\n/g,"<br />")+"</div>";this.croaked=true}}}}})();(function(){var c=window.eidogoConfig||{};var a={theme:"problem",problemMode:true,markVariations:false,markNext:false,shrinkToFit:true};var b=eidogo.util.getPlayerPath();var d=eidogo.playerPath=(c.playerPath||b||"player").replace(/\/$/,"");if(!c.skipCss){eidogo.util.addStyleSheet(d+"/css/player.css");if(eidogo.browser.ie&&parseInt(eidogo.browser.ver,10)<=6){eidogo.util.addStyleSheet(d+"/css/player-ie6.css")}}eidogo.util.addEvent(window,"load",function(){eidogo.autoPlayers=[];var g=[];var l=document.getElementsByTagName("div");var k=l.length;for(var h=0;h<k;h++){if(eidogo.util.hasClass(l[h],"eidogo-player-auto")||eidogo.util.hasClass(l[h],"eidogo-player-problem")){g.push(l[h])}}var e;for(var h=0;e=g[h];h++){var j={container:e,enableShortcuts:false,theme:"compact"};if(eidogo.util.hasClass(e,"eidogo-player-problem")){for(var o in a){j[o]=a[o]}}for(var o in c){j[o]=c[o]}var m=e.getAttribute("sgf");if(m){j.sgfUrl=m}else{if(e.innerHTML){j.sgf=e.innerHTML}}var f=e.getAttribute("shrink");if(f){j.shrinkToFit=(f=="no"?false:true)}e.innerHTML="";eidogo.util.show(e);var n=new eidogo.Player(j);eidogo.autoPlayers.push(n)}})})();