CGW={};CGW.lang={};CGW.version="2.50";CGW.License=window.location.hostname;CGW.COPYRIGHT="Copyrigth 2010 cgw.dk, CGW Player";CGW.PROGRAM="CGW-Player";CGW.update="";var G=[];var CGWLang;var boardThemeColor="#FFF";var boardThemeFontWeight="normal";var boardThemeFontSize="80%";var boardThemeFrameBorder="inset #4d3219";var boardThemeFontFamily="Verdana, Geneva, Arial, Helvetica, sans-serif";var boardThemeFrameBorderSize="1px";var _file_is_loaded=false;var _cgw_board_counter=0;var dh=Ext.DomHelper;window.onError=function(A){};var LoadCSS=function(A,C){var B=document.createElement("link");B.setAttribute("rel","stylesheet");B.setAttribute("type","text/css");B.setAttribute("href",A);if(C){B.setAttribute("id",C)}if(typeof B!="undefined"){document.getElementsByTagName("head")[0].appendChild(B)}};var LoadJS=function(A,C){var B=document.createElement("script");B.setAttribute("type","text/javascript");B.setAttribute("src",A);if(C){B.setAttribute("id",C)}if(typeof B!="undefined"){document.getElementsByTagName("head")[0].appendChild(B)}return B};function loadLanguages(B){if(!B.lang){B.lang="en"}var A=B.lang.split(",");for(var C=0;C<A.length;C++){LoadJS(B.pgnPlayerPath+"/js/lang/"+A[C]+".js","Lang_"+A[0])}_file_is_loaded=true;return A[0]}var loadLicense=function(){var B=Ext.Cookie.get("license");var C=Ext.Cookie.get("update");if(B){CGW.License=B;CGW.update=C}else{var A=new Ext.data.Store({remoteSort:true,proxy:new Ext.data.ScriptTagProxy({url:"http://www.cgw.dk/MODULER/License/LicenseCreator2.0.php"})});A.load({params:{hostname:window.location.hostname,version:CGW.version,program:CGW.PROGRAM}})}};function programCallback(B,A,C){if(A){CGW.License=A}if(C){CGW.update=C}Ext.Cookie.set("license",A,30,"/");Ext.Cookie.set("update",C,30,"/")}var cgw_resizeAll=function(D){for(var F=0;F<G.length;F++){if(G[F]&&G[F].win){if(D=="window resize"&&!G[F].lockMoveOld){G[F].lockMove=false}var B=" addToBody:"+G[F].p.addToBody+", maximized:"+G[F].win.maximized+", lockMove:"+G[F].lockMove+", lockResize:"+G[F].lockResize;G[F].boardSize=G[F].boardContainer.getWidth();G[F].board.setSize(G[F].boardSize);G[F].board.resizeBoard();if(!G[F].p.addToBody&&!G[F].win.maximized&&!G[F].lockMove&&!G[F].lockResize){var A=G[F].mainContainer.getX();var E=G[F].mainContainer.getY();G[F].win.setPagePosition(A,E);var C=G[F].win.getHeight();if(G[F].TargetObj){G[F].TargetObj.setHeight(C)}if(G[F].mainContainer){G[F].mainContainer.setHeight(C)}}G[F].win.render();G[F].navigatorResize();G[F].win.bbar.repaint();G[F].win.syncShadow()}}};Ext.Cookie=[];Ext.Cookie.set=function(B,D,H,F,C,E){if(H){var A=new Date();A.setTime(A.getTime()+(H*24*60*60*1000))}else{var A=""}document.cookie=B+"="+escape(D)+((A)?"; expires="+A.toGMTString():"")+((F)?"; path="+F:"")+((C)?"; domain="+C:"")+((E)?"; secure":"")};Ext.Cookie.get=function(C){var B=document.cookie;var E=C+"=";var D=B.indexOf("; "+E);if(D==-1){D=B.indexOf(E);if(D!=0){return null}}else{D+=2}var A=document.cookie.indexOf(";",D);if(A==-1){A=B.length}return unescape(B.substring(D+E.length,A))};Ext.Cookie.del=function(A,C,B){if(getCookie(A)){document.cookie=A+"="+((C)?"; path="+C:"")+((B)?"; domain="+B:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT"}};CGW.tools=function(){};CGW.tools.prototype={doJSON:function(D){try{var F=Ext.util.JSON.decode(D);return F}catch(E){Ext.MessageBox.alert("ERROR","Could not decode "+D)}},GetServerSelf:function(){var D=window.location.protocol+"//"+window.location.hostname+window.location.pathname;var E=D.lastIndexOf("/")+1;var F=D.substr(0,E);return F},GetUrlParam:function(F){var D=new RegExp("[?&]"+F+"=([^&]+)","i");var E=D.exec(unescape(window.location.search));if(E&&E.length>1){return E[1]}else{return""}},odd:function(B){return B/2==parseInt(B/2,10)},even:function(B){return !this.odd(B)}};String.prototype.trim=function(){a=this.replace(/^\s+/,"");return a.replace(/\s+$/,"")};Number.prototype.odd=function(){return this/2!=parseInt(this/2,10)};Number.prototype.even=function(){return this/2==parseInt(this/2,10)};function showObject(B){if(typeof B!="object"){B=Ext.get(B)}var C="";var D=function(F){for(var E in B){if(B[E]&&!B[E].id){B[E].id=Ext.id()}if(B[E]&&typeof B[E]=="object"){var F="<a href=\"JavaScript:SO('"+B[E].id+"');\">"+B[E]+"</a>"}else{var F=B[E]}C+="<span style='color: red;'>"+E+"</span> = <span style='color: blue;'>"+F+"</span><br><br>"}return C};D(B);var A=new Ext.Window({title:"ObjectViewer",width:600,height:400,autoScroll:true,closeAction:"close",resizable:true,maximizable:true,constrain:true,bodyStyle:"padding:5px;",modal:true,html:C});A.show()}SO=showObject;Ext.apply(Ext.Element.prototype,function(){return{replaceTagValue:function(A,C,D){var B=this.dom.getElementsByTagName(A);for(o in B){if(B[o][C]){B[o][C]=D}}}}}());Ext.QuickTips.init();function loadOnSite(E,A){if(!A){A=Ext.getBody()}if(A.HAS){G[A.HAS].win.show();return true}var D=Ext.get(A);var J=D.getWidth();D.addClass("cgw_game_container");var I=D.getX();var H=D.getY();var B=document.createElement("DIV",D);B.style.left=I+"px";B.style.top=H+"px";B.style.width=J+"px";B.style.position="absolute";Ext.getBody().appendChild(B);var F=document.createElement("DIV",D);F.id="cgw_game_container_"+_cgw_board_counter;F.className="cgw_game_container";F.style.left="0px";F.style.top="0px";F.style.position="relative";B.appendChild(F);if(typeof game_default=="object"){for(attrname in game_default){if(!E[attrname]){E[attrname]=game_default[attrname]}}}if(!E.lang){E.lang="en"}if(!_file_is_loaded){E.langSet=loadLanguages(E)}CGWLang=Ext.Cookie.get("language");if(!CGWLang){CGWLang=E.langSet}function C(){if(!CGW.lang||!CGW.lang[CGWLang]||!CGW.lang[CGWLang].langCode){setTimeout(C,100)}else{G[_cgw_board_counter]=new CGW.Game(_cgw_board_counter);G[_cgw_board_counter].mainContainer=D;G[_cgw_board_counter].targetX=I;G[_cgw_board_counter].targetY=H;G[_cgw_board_counter].setUpGame(_cgw_board_counter,E);G[_cgw_board_counter].languageButtonImg=Ext.Cookie.get("languageButtonImg");_cgw_board_counter++}}C()}function loadAsLinkPopup(A){}function loadAsLinkElement(A){if(typeof game_default=="object"){for(attrname in game_default){if(!A[attrname]){A[attrname]=game_default[attrname]}}}if(!A.lang){A.lang="en"}if(!_file_is_loaded){A.langSet=loadLanguages(A)}CGWLang=Ext.Cookie.get("language");if(!CGWLang){CGWLang=A.langSet}function B(){if(!CGW.lang||!CGW.lang[CGWLang]||!CGW.lang[CGWLang].langCode){setTimeout(B,100)}else{cgw_start_direct(A,999)}}B()}var cgw_start_direct=function(B,A){if(G[A]){G[A].win.close()}if(!G[A]){G[A]=new CGW.Game(A)}G[A].setUpGame(A,B);G[A].languageButtonImg=Ext.Cookie.get("languageButtonImg")};Ext.onReady(function(){CGWbodyMargin=Ext.getBody().getMargins();var A=CGWbodyMargin.top+"px "+CGWbodyMargin.right+"px "+CGWbodyMargin.bottom+"px "+CGWbodyMargin.left+"px";Ext.getBody().setStyle("margin",A);var B=function(){window.scrollBy(0,-50000);if(!Ext){setTimeout(B,100)}Ext.EventManager.on(window,"resize",function(){cgw_resizeAll("window resize")},this);Ext.EventManager.on(window.document,"keydown",function(F){var D=F.getKey();var C=Ext.WindowMgr.getActive();if(!C||!C.scope){return false}var E=C.scope.GC;if((D==39||D==102)&&!F.ctrlKey&&!F.shiftKey){G[E].newPos(1,G[E])}if(((D==39||D==102)&&F.ctrlKey&&!F.shiftKey)||D==97||D==35){G[E].endPos(G[E])}if(((D==39||D==102)&&F.shiftKey&&!F.ctrlKey)||D==105||D==33){G[E].newPos(5,G[E])}if((D==37||D==100)&&!F.ctrlKey&&!F.shiftKey){G[E].newPos(-1,G[E])}if(((D==37||D==100)&&F.ctrlKey&&!F.shiftKey)||D==103||D==36){G[E].startPos(G[E])}if(((D==37||D==100)&&F.shiftKey&&!F.ctrlKey)||D==99||D==34){G[E].newPos(-5,G[E])}if(D==98||D==40){G[E].newVariant(-1,G[E])}if(D==104||D==38){G[E].newVariant(1,G[E])}},this)};setTimeout(B,1000)});var cgw_start_function=function(B,A){G[A]=new CGW.Game(A);G[A].setUpGame(A,B)};CGW.notation=function(){};CGW.notation.prototype={1:"!",2:"?",3:"!!",4:"??",5:"!?",6:"?!",7:"Forced move (all others lose quickly).",8:"Singular move (no reasonable alternatives).",9:"Worst move.",10:"Drawish position.",11:"=",12:"~",13:"unclear position.",14:"White has a slight advantage.",15:"Black has a slight advantage.",16:"White has a moderate advantage.",17:"Black has a moderate advantage.",18:"White has a decisive advantage.",19:"Black has a decisive advantage.",20:"White has a crushing advantage (Black should resign).",21:"Black has a crushing advantage (White should resign).",22:"White is in zugzwang.",23:"Black is in zugzwang.",24:"White has a slight space advantage.",25:"Black has a slight space advantage.",26:"White has a moderate space advantage.",27:"Black has a moderate space advantage.",28:"White has a decisive space advantage.",29:"Black has a decisive space advantage.",30:"White has a slight time (development) advantage.",31:"Black has a slight time (development) advantage.",32:"White has a moderate time (development) advantage.",33:"Black has a moderate time (development) advantage.",34:"White has a decisive time (development) advantage.",35:"Black has a decisive time (development) advantage.",36:"hvid har initiativet.",37:"sort har initiativet.",38:"White has a lasting initiative.",39:"Black has a lasting initiative.",40:"White has the attack.",41:"Black has the attack.",42:"White has insufficient compensation for material deficit.",43:"Black has insufficient compensation for material deficit.",44:"White has sufficient compensation for material deficit.",45:"Black has sufficient compensation for material deficit.",46:"White has more than adequate compensation for material deficit.",47:"Black has more than adequate compensation for material deficit.",48:"White has a slight center control advantage.",49:"Black has a slight center control advantage.",50:"White has a moderate center control advantage.",51:"Black has a moderate center control advantage.",52:"White has a decisive center control advantage.",53:"Black has a decisive center control advantage.",54:"White has a slight kingside control advantage.",55:"Black has a slight kingside control advantage.",56:"White has a moderate kingside control advantage.",57:"Black has a moderate kingside control advantage.",58:"White has a decisive kingside control advantage.",59:"Black has a decisive kingside control advantage.",60:"White has a slight queenside control advantage.",61:"Black has a slight queenside control advantage.",62:"White has a moderate queenside control advantage.",63:"Black has a moderate queenside control advantage.",64:"White has a decisive queenside control advantage.",65:"Black has a decisive queenside control advantage.",66:"White has a vulnerable first rank.",67:"Black has a vulnerable first rank.",68:"White has a well protected first rank.",69:"Black has a well protected first rank.",70:"White has a poorly protected king.",71:"Black has a poorly protected king.",72:"White has a well protected king.",73:"Black has a well protected king.",74:"White has a poorly placed king.",75:"Black has a poorly placed king.",76:"White has a well placed king.",77:"Black has a well placed king.",78:"White has a very weak pawn structure.",79:"Black has a very weak pawn structure.",80:"White has a moderately weak pawn structure.",81:"Black has a moderately weak pawn structure.",82:"White has a moderately strong pawn structure.",83:"Black has a moderately strong pawn structure.",84:"White has a very strong pawn structure.",85:"Black has a very strong pawn structure.",86:"White has poor knight placement.",87:"Black has poor knight placement.",88:"White has good knight placement.",89:"Black has good knight placement.",90:"White has poor bishop placement.",91:"Black has poor bishop placement.",92:"White has good bishop placement.",93:"Black has good bishop placement.",94:"White has poor rook placement.",95:"Black has poor rook placement.",96:"White has good rook placement.",97:"Black has good rook placement.",98:"White has poor queen placement.",99:"Black has poor queen placement.",100:"White has good queen placement.",101:"Black has good queen placement.",102:"White has poor piece coordination.",103:"Black has poor piece coordination.",104:"White has good piece coordination.",105:"Black has good piece coordination.",106:"White has played the opening very poorly.",107:"Black has played the opening very poorly.",108:"White has played the opening poorly.",109:"Black has played the opening poorly.",110:"White has played the opening well.",111:"Black has played the opening well.",112:"White has played the opening very well.",113:"Black has played the opening very well.",114:"White has played the middlegame very poorly.",115:"Black has played the middlegame very poorly.",116:"White has played the middlegame poorly.",117:"Black has played the middlegame poorly.",118:"White has played the middlegame well.",119:"Black has played the middlegame well.",120:"White has played the middlegame very well.",121:"Black has played the middlegame very well.",122:"White has played the ending very poorly.",123:"Black has played the ending very poorly.",124:"White has played the ending poorly.",125:"Black has played the ending poorly.",126:"White has played the ending well.",127:"Black has played the ending well.",128:"White has played the ending very well.",129:"Black has played the ending very well.",130:"White has slight counterplay.",131:"Black has slight counterplay.",132:"White has moderate counterplay.",133:"Black has moderate counterplay.",134:"White has decisive counterplay.",135:"Black has decisive counterplay.",136:"White has moderate time control pressure.",137:"Black has moderate time control pressure.",138:"White has severe time control pressure.",139:"Black has severe time control pressure.",145:"\u20ac"};CGW.board=function(A){this.parentScope=A;this.piece_container=document.createElement("DIV");this.piece_container.style.display="none";Ext.getBody().appendChild(this.piece_container);this.piece_container=Ext.get(this.piece_container)};CGW.board.prototype={setSize:function(A){if(this.frameContainer!=undefined){A=this.frameContainer.getWidth()}A=A-parseInt(boardThemeFrameBorderSize,10)*2;this.fieldSize=parseInt(A/9,10);this.iFrame=this.fieldSize*8+(parseInt(boardThemeFrameBorderSize,10)*2);this.border=parseInt(this.fieldSize/2,10)+1;this.oFrame=this.iFrame+this.border*2;this.fontsize=parseInt(A/20,10)},fill:function(B){var A=document.createElement("IMG");A.src=this.parentScope.p.graficObject.piecePath+B+".png";A.className="cgw-board-piece "+B;A.boardField="";A.pieceColor=B.charAt(0);A.pieceType=B.charAt(1);A.piece=(B.charAt(0)=="w")?B.charAt(1).toUpperCase():B.charAt(1);this.piece_container.appendChild(A)},createBoardContent:function(){this.outherFrame=document.createElement("DIV");this.outherFrame.className="CGW-outherFrame";this.outherFrame=Ext.get(this.outherFrame);this.outherFrameImg=document.createElement("IMG");this.outherFrameImg.className="CGW-outherFrame";this.outherFrameImg.src=this.parentScope.p.graficObject.board;this.outherFrame.appendChild(this.outherFrameImg);this.outherFrameImg=Ext.get(this.outherFrameImg);this.createFrameDescription();this.innerFrame=document.createElement("DIV");this.innerFrame.className="CGW-innerFramme";this.innerFrame.style.border=boardThemeFrameBorderSize+" "+boardThemeFrameBorder;this.createFields(this.innerFrame);this.outherFrame.appendChild(this.innerFrame);this.innerFrame=Ext.get(this.innerFrame);var A=new Ext.Panel({title:"",border:true,style:"position: relative;",border:"none",resizable:this.parentScope.p.resizeable,draggable:false,items:[this.outherFrame]});return A},createFrameDescription:function(){if(this.parentScope.p.frameDescription==false){return false}this.frameDescriptionId=[];for(var B=0;B<8;B++){this.frameDescriptionId[B]=document.createElement("DIV");this.frameDescriptionId[B].className="cgw-board-description";this.frameDescriptionId[B].style.color=boardThemeColor;this.frameDescriptionId[B].style.fontWeight=boardThemeFontWeight;this.frameDescriptionId[B].style.fontSize=boardThemeFontSize;this.frameDescriptionId[B].style.fontFamily=boardThemeFontFamily;var A=document.createTextNode(B+1);this.frameDescriptionId[B].appendChild(A);this.outherFrame.appendChild(this.frameDescriptionId[B]);this.frameDescriptionId[B]=Ext.get(this.frameDescriptionId[B]);this.frameDescriptionId[B+8]=document.createElement("DIV");this.frameDescriptionId[B+8].className="cgw-board-description";this.frameDescriptionId[B+8].style.color=boardThemeColor;this.frameDescriptionId[B+8].style.fontWeight=boardThemeFontWeight;this.frameDescriptionId[B+8].style.fontSize=boardThemeFontSize;this.frameDescriptionId[B+8].style.fontFamily=boardThemeFontFamily;var A=document.createTextNode(String.fromCharCode(B+97));this.frameDescriptionId[B+8].appendChild(A);this.outherFrame.appendChild(this.frameDescriptionId[B+8]);this.frameDescriptionId[B+8]=Ext.get(this.frameDescriptionId[B+8])}},resizeBoard:function(){if(!this.oFrame){return false}this.outherFrame.setWidth(this.oFrame);this.outherFrame.setHeight(this.oFrame);this.outherFrame.setStyle("font-size",this.fontsize+"px");this.outherFrameImg.setWidth(this.oFrame);this.outherFrameImg.setHeight(this.oFrame);this.innerFrame.setWidth(this.iFrame);this.innerFrame.setHeight(this.iFrame);this.innerFrame.setLeft(this.border);this.innerFrame.setTop(this.border);var B=this.fieldSize*0.17;var F=this.iFrame+this.border;for(var H=0;H<8;H++){var E=this.fieldSize*((this.parentScope.p.reverse)?H:7-H)+this.fieldSize*0.75;this.frameDescriptionId[H].setTop(E);this.frameDescriptionId[H].setLeft(B)}for(var H=0;H<8;H++){var E=this.fieldSize*((this.parentScope.p.reverse)?7-H:H)+this.fieldSize*0.9;this.frameDescriptionId[H+8].setTop(F);this.frameDescriptionId[H+8].setLeft(E)}for(var A=0;A<8;A++){for(var J=0;J<8;J++){var I=J*8+A;this.FieldArray[A][J].setWidth(this.fieldSize);this.FieldArray[A][J].setHeight(this.fieldSize);this.FieldArray[A][J].setLeft(this.fieldSize*((this.parentScope.p.reverse)?7-A:A));this.FieldArray[A][J].setTop(this.fieldSize*((this.parentScope.p.reverse)?7-J:J));this.FieldImgArray[I].setWidth(this.fieldSize);this.FieldImgArray[I].setHeight(this.fieldSize);this.FieldImgArray[I].setLeft(this.fieldSize*((this.parentScope.p.reverse)?7-A:A));this.FieldImgArray[I].setTop(this.fieldSize*((this.parentScope.p.reverse)?7-J:J))}}},createFields:function(H){this.FieldArray=[];this.FieldImgArray=[];for(var A=0;A<8;A++){this.FieldArray[A]=[];for(var I=0;I<8;I++){var F=I*8+A;var B=(A+I)/2==parseInt((A+I)/2,10);this.FieldImgArray[F]=document.createElement("IMG");var E=this.parentScope.lang.PieceAlt.F+String.fromCharCode(A+97)+(8-I);var D=this.parentScope.lang.PieceAlt.f+String.fromCharCode(A+97)+(8-I);this.FieldImgArray[F].alt=(B)?E:D;this.FieldImgArray[F].src=(B)?this.parentScope.p.graficObject.white:this.parentScope.p.graficObject.black;this.FieldImgArray[F].className="cgw-board-field";this.innerFrame.appendChild(this.FieldImgArray[F]);this.FieldImgArray[F]=Ext.get(this.FieldImgArray[F]);this.FieldArray[A][I]=document.createElement("DIV");this.FieldArray[A][I].x=A;this.FieldArray[A][I].y=I;this.FieldArray[A][I].title=String.fromCharCode(A+97)+(8-I);this.FieldArray[A][I].className="cgw-board-field slot";this.FieldArray[A][I].boardField=F;this.innerFrame.appendChild(this.FieldArray[A][I]);this.FieldArray[A][I]=Ext.get(this.FieldArray[A][I])}}},getFromBox:function(A){var B=this.piece_container.query("."+A);if(B.length==0){this.fill(A);var B=this.piece_container.query("."+A)}return B[0]},insertPieces:function(I){this.innerFrame.board=I;for(var C=0;C<I.length;C++){var A=I.charAt(C).toLowerCase();var F=(A==I.charAt(C))?"b":"w";var H=parseInt(C/8,10);var J=C-H*8;var E=this.FieldArray[J][H];if(A=="-"){if(E.dom.hasChildNodes()){var B=Ext.get(E.dom.firstChild.id);this.piece_container.appendChild(B)}}else{if(E.f!=I.charAt(C)){if(E.dom.hasChildNodes()){var B=Ext.get(E.dom.firstChild.id);this.piece_container.appendChild(B)}var D=this.getFromBox(F+A);D.fields=[];E.appendChild(D)}}E.f=I.charAt(C)}}};CGW.pgn=function(B,A){this.scope=B;this.GC=A;this.lang=CGW.lang[CGWLang];this.notation=new CGW.notation();this.boardArray=[]};CGW.pgn.prototype={fen_to_board:function(I,F){if(!I.FEN){I.FEN="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"}var H=I.FEN.split(" ");var J=/\//g;var E=H[0].replace(J,"");E=E.split("1").join("-").split("2").join("--").split("3").join("---").split("4").join("----").split("5").join("-----").split("6").join("------").split("7").join("-------").split("8").join("--------");F.startBoard=E;F.boardConfig={startColor:H[1],castling:H[2],enpassant:H[3],lastPawn:H[4],fullmove:parseInt(H[5],10),realMoveNumber:(parseInt(H[5],10)*2)-((H[1]=="w")?2:1)}},startElmCreate:function(E,C){var H=document.createElement("SPAN");H.id=C.BoardID+"_Move_Board_0_0_0";var B=document.createElement("A");B.href="JavaScript: G["+this.GC+"].moveToPos(0,-1,"+C.gameNr+",G["+this.GC+"]);";var F=document.createElement("IMG");F.src=E.p.graficObject.start_note_board;F.style.border="none";B.appendChild(F);H.appendChild(B);var D=document.createTextNode(" ");H.appendChild(D);C.GameNoteArray.appendChild(H)},nrElmCreate:function(D,C){if(this.variant==0){var H="cgw_mainvariation_nr"}else{var H="cgw_subvariation_nr"}var F=document.createElement("SPAN");F.className=H;var E=document.createTextNode(D+" ");F.appendChild(E);C.GameNoteArray.appendChild(F)},udskiftSprog:function(B){B=B.replace("R",this.scope.lang.pgn_lang[0]);B=B.replace("N",this.scope.lang.pgn_lang[1]);B=B.replace("B",this.scope.lang.pgn_lang[2]);B=B.replace("Q",this.scope.lang.pgn_lang[3]);B=B.replace("K",this.scope.lang.pgn_lang[4]);return B},moveElmCreate:function(E,B){if(this.variant==0){var J="cgw_mainvariation"}else{var J="cgw_subvariation"}if(this.moveNr.even()){var I=(parseInt(this.moveNr/2,10)+1)+"."}else{var I=(parseInt(this.moveNr/2,10)+1)+"..."}var K=document.createElement("SPAN");K.id="Move_"+B.boardNr+"_"+B.gameNr+"_"+this.variant+"_"+this.moveNr;K.className=J;K.title=I+this.udskiftSprog(E);var H=document.createElement("A");H.href="JavaScript: G["+this.GC+"].moveToPos("+this.variant+","+(this.moveNr)+","+B.gameNr+",G["+this.GC+"]);";var F=document.createTextNode(this.udskiftSprog(E));H.appendChild(F);K.appendChild(H);var F=document.createTextNode(" ");K.appendChild(F);B.GameNoteArray.appendChild(K)},setupClock:function(H,B,D){var E=H.indexOf("[%clk");var F=H.indexOf("]",E);var C=H.substr(E,F-E+1);var A=H.replace(C,"");return A},textElmCreate:function(B,A){var D=document.createElement("SPAN");D.className="cgw_text";var C=document.createTextNode(B+" ");D.appendChild(C);A.GameNoteArray.appendChild(D)},signElmCreate:function(F,C){var I=parseInt(F.substr(1),10);var J="";J=this.notation[I];if(this.variant==0){var L="cgw_mainvariation_text"}else{var L="cgw_subvariation_text"}var K=document.createElement("SPAN");K.className=L;var H=document.createTextNode(J+" ");K.appendChild(H);C.GameNoteArray.appendChild(K)},init_pgn:function(O,L,I){this.gameNr=L;var F=O.p.gameArray[L];I.GameNoteArray=document.createElement("DIV");I.BoardID=Ext.id();this.moveNr=I.boardConfig.realMoveNumber;this.startElmCreate(O,I);this.variant=0;I.arrayPgn=[];I.arrayText=[];I.arrayKom=[];I.arrayPgn[this.variant]=[];I.arrayText[this.variant]=[];I.arrayKom[this.variant]=[];this.variantStart=[];var J=[];var D=[];var E=0;var H="";var K=false;var M;var N=F.Game.trim().split("\n").join(" ").split("\r").join("").split(".").join(". ").split(". . . ").join("... ").split("(").join("( ").split(")").join(" )").split("{").join("{ ").split("}").join(" }").split("  ").join(" ").split(" ");for(var C=0;C<N.length;C++){if(N[C]=="}"){K=false;H=this.setupClock(H,this.variant,this.moveNr);I.arrayText[this.variant][this.moveNr]=H;this.textElmCreate(H,I);H=""}if(K){H+=" "+N[C]}else{if(N[C]=="{"){K=true}else{if(N[C]==")"){this.textElmCreate(")",I);this.variant=D.pop()}else{if(N[C].match(/^\d/)){if(N[C].match(/\.\.\./)){M=false}else{M=true}this.moveNr=parseInt(N[C],10)*2-2;this.nrElmCreate(N[C],I)}else{if(N[C].charAt(0)=="$"){(I.arrayKom[this.variant][this.moveNr])?I.arrayKom[this.variant][this.moveNr]+=N[C]:I.arrayKom[this.variant][this.moveNr]=N[C];this.signElmCreate(N[C],I)}else{if(N[C].charAt(0).match(/^[a-hKQNBROo]/)){if(!M){this.moveNr++}I.arrayPgn[this.variant][this.moveNr]=N[C];this.moveElmCreate(N[C],I);if(M){M=false}}else{if(N[C]=="("){this.textElmCreate("(",I);E++;J[E]=this.variant;D.push(this.variant);this.oldVariantValue=this.variant;this.variant=E;if(!I.arrayPgn[this.variant]){I.arrayPgn[this.variant]=new Array()}this.variantStart[this.variant]=this.oldVariantValue;if(!I.arrayText[this.variant]){I.arrayText[this.variant]=new Array()}if(!I.arrayKom[this.variant]){I.arrayKom[this.variant]=new Array()}}}}}}}}}},rokade:function(){if(this.traek=="O-O"){(this.hvid)?this.kode="47677757":this.kode="40607050"}if(this.traek=="O-O-O"){(this.hvid)?this.kode="47270737":this.kode="40200030"}this.braet[parseInt(this.kode.charAt(1),10)*8+parseInt(this.kode.charAt(0),10)]="-";this.braet[parseInt(this.kode.charAt(3),10)*8+parseInt(this.kode.charAt(2),10)]=(this.hvid)?"K":"k";this.braet[parseInt(this.kode.charAt(5),10)*8+parseInt(this.kode.charAt(4),10)]="-";this.braet[parseInt(this.kode.charAt(7),10)*8+parseInt(this.kode.charAt(6),10)]=(this.hvid)?"R":"r"},pawn:function(){var H,E,D,C,F;var B="abcdefgh";var A="87654321";(this.hvid)?F=1:F=-1;(this.hvid)?this.brik="P":this.brik="p";if(B.indexOf(this.traek.charAt(1))>-1){H=B.indexOf(this.traek.charAt(1));E=A.indexOf(this.traek.charAt(2))}else{H=B.indexOf(this.traek.charAt(0));E=A.indexOf(this.traek.charAt(1))}if(this.braet[(E+F)*8+H]==this.brik){C=E+F}else{if(this.braet[(E+F+F)*8+H]==this.brik){C=E+F+F}}D=H;if(this.traek.length>=3){this.traek=this.traek.split("=").join("");if("RNBQK".indexOf(this.traek.charAt(this.traek.length-1))>-1){(this.hvid)?this.brik=this.traek.charAt(this.traek.length-1):this.brik=this.traek.charAt(this.traek.length-1).toLowerCase()}C=E+F;D=B.indexOf(this.traek.charAt(0));if(this.braet[E*8+H]=="-"){this.braet[C*8+H]="-"}}this.braet[C*8+D]="-";this.braet[E*8+H]=this.brik},tjekForNull:function(K,D,J,H){var F,E,C,I;if(this.brik.toLowerCase()=="n"){return true}E=((H-K)==0)?0:(H-K)/Math.abs(H-K);F=((J-D)==0)?0:(J-D)/Math.abs(J-D);I=K+E;C=D+F;if((H==I)&&(J==C)){return true}while((H!=I)||(J!=C)){if((H==I)&&(J==C)){return true}if(this.braet[I*8+C]!="-"){return false}I+=E;C+=F}return true},findBrik:function(F,D){var H,M,C,L,K,J,E,I;if(this.traek.length==2){K="abcdefgh".indexOf(this.traek.charAt(0));J="87654321".indexOf(this.traek.charAt(1))}if(this.traek.length==3){K="abcdefgh".indexOf(this.traek.charAt(1));J="87654321".indexOf(this.traek.charAt(2))}if(this.traek.length==4){K="abcdefgh".indexOf(this.traek.charAt(2));J="87654321".indexOf(this.traek.charAt(3))}if(!this.hvid){this.brik=this.brik.toLowerCase()}H=F;M=D;L=-1;C=-1;for(x=0;x<H.length;x++){E=J+M[x];I=K+H[x];if(E>=0&&E<=7&&I>=0&&I<=7){if(L==-1&&C==-1&&this.braet[E*8+I]==this.brik){if(this.tjekForNull(E,I,K,J)){C=I;L=E}}}}if(this.traek.length==4){if("abcdefgh".indexOf(this.traek.charAt(1))>-1){C="abcdefgh".indexOf(this.traek.charAt(1));L=-1;for(x=0;x<M.length;x++){E=J+M[x];if(E>=0&&E<=7){if(L==-1&&this.braet[E*8+C]==this.brik){if(this.tjekForNull(E,C,K,J)){L=E}}}}}if("87654321".indexOf(this.traek.charAt(1))>-1){L="87654321".indexOf(this.traek.charAt(1));C=-1;for(x=0;x<H.length;x++){I=K+H[x];if(I>=0&&I<=7){if(C==-1&&this.braet[L*8+I]==this.brik){if(this.tjekForNull(L,I,K,J)){C=I}}}}}}this.braet[L*8+C]="-";this.braet[J*8+K]=this.brik},officer:function(){var I=new Array(1,1,1,0,0,-1,-1,-1);var H=new Array(1,0,-1,1,-1,1,0,-1);var K=new Array(1,2,3,4,5,6,7,-1,-2,-3,-4,-5,-6,-7,1,2,3,4,5,6,7,-1,-2,-3,-4,-5,-6,-7,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,0,0,0,0,0,0,0,-1,-2,-3,-4,-5,-6,-7);var J=new Array(1,2,3,4,5,6,7,-1,-2,-3,-4,-5,-6,-7,-1,-2,-3,-4,-5,-6,-7,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,0,0,0,0,0,0,-1,-2,-3,-4,-5,-6,-7,0,0,0,0,0,0,0);var D=new Array(0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,0,0,0,0,0,0,0,-1,-2,-3,-4,-5,-6,-7);var C=new Array(0,1,2,3,4,5,6,7,0,0,0,0,0,0,0,-1,-2,-3,-4,-5,-6,-7,0,0,0,0,0,0,0);var F=new Array(1,2,3,4,5,6,7,-1,-2,-3,-4,-5,-6,-7,1,2,3,4,5,6,7,-1,-2,-3,-4,-5,-6,-7);var E=new Array(1,2,3,4,5,6,7,-1,-2,-3,-4,-5,-6,-7,-1,-2,-3,-4,-5,-6,-7,1,2,3,4,5,6,7);var B=new Array(2,2,1,1,-1,-1,-2,-2);var A=new Array(1,-1,2,-2,2,-2,1,-1);if(this.brik=="K"){this.findBrik(I,H)}if(this.brik=="Q"){this.findBrik(K,J)}if(this.brik=="R"){this.findBrik(D,C)}if(this.brik=="B"){this.findBrik(F,E)}if(this.brik=="N"){this.findBrik(B,A)}},calcBoard:function(A){this.brik=this.traek.charAt(0);if(this.brik=="O"){this.rokade()}else{if("abcdefgh".indexOf(this.brik)>=0){this.pawn()}else{if("RNBQK".indexOf(this.brik)>=0){this.officer()}}}return this.braet.join("")},calcVariant:function(L,H){function J(A){for(I=0;I<A.length;I++){if(A[I]){return I}}}H.cgw_Move_Start[L]=J(H.arrayPgn[L]);H.cgw_Move_End[L]=H.arrayPgn[L].length-1;var F=H.cgw_Move_Start[L]-1;if(L>0){var K=this.variantStart[L];this.braet=H.boards[K][F].split("")}for(var I=H.cgw_Move_Start[L];I<H.arrayPgn[L].length;I++){if(H.arrayPgn[L][I]){this.hvid=I.even();this.traek=H.arrayPgn[L][I].replace(/\+|#|x/g,"");H.boards[L][I]=this.calcBoard(H)}}},calcAllBoard:function(D,C){this.braet=C.startBoard.split("");C.boards=[];for(var B=0;B<C.arrayPgn.length;B++){C.boards[B]=[];this.calcVariant(B,C)}},initGame:function(B){var A=B.p.gameNr;if(!this.boardArray[A]){this.boardArray[A]={};this.boardArray[A].gameNr=A;this.boardArray[A].boardNr=B.GC;this.boardArray[A].variant=0;this.boardArray[A].moveNr=B.p.startPosition;this.boardArray[A].cgw_Move_Start=[];this.boardArray[A].cgw_Move_End=[];this.fen_to_board(B,this.boardArray[A]);this.init_pgn(B,A,this.boardArray[A]);this.calcAllBoard(B,this.boardArray[A])}}};CGW.Game=function(A){this.GC=A;this.scope=this;this.tool=new CGW.tools();this.lang=CGW.lang[CGWLang];this.board=new CGW.board(this);this.pgn=new CGW.pgn(this,this.GC)};CGW.Game.prototype={setUpGame:function(A,B){var C=document.body;loadMask=new Ext.LoadMask(C,{msg:"Indlæser pgn program til visning af skakpartier ..."});loadMask.show();this.p=B;this.setConfig();if(this.p.addToBody){this.addToBodyConfig(A)}else{this.addToElementConfig(A)}this.loadJob()},loadFinish:function(A,B){this.gameParser(A);if(this.p.gameNr>this.p.gameArray.length){this.p.gameNr=this.p.gameArray.length}if(this.p.gameNrRandom){this.p.gameNr=parseInt(Math.random()*this.p.gameArray.length,10)}this.pgn.initGame(this);if(this.p.startPosition>=this.pgn.boardArray[this.p.gameNr].arrayPgn[0].length){this.p.startPosition=this.pgn.boardArray[this.p.gameNr].arrayPgn[0].length-1}this.createWindow();this.moveToPos(0,this.p.startPosition,this.p.gameNr,this);window.scrollBy(0,-50000);this.lockResize=false;this.lockMove=false;this.lockMoveOld=false;cgw_resizeAll("loadFinish");if(this.GC==G.length-1){loadMask.hide()}},addToBodyConfig:function(){this.TargetObjCenter=true;if(this.p.width.indexOf("%")>-1){this.targetWidth=Ext.getBody().getWidth()*parseInt(this.p.width,10)/100}else{this.targetWidth=this.p.width}var A=Ext.getBody().getWidth()/2-(parseInt(this.p.width,10)/2);var B=Ext.getBody().getHeight()/4;this.TargetObjXY=[A,B];this.setBoard()},addToElementConfig:function(A){this.TargetObj=Ext.get("cgw_game_container_"+A);if(!this.TargetObj){this.addToBodyConfig();return false}this.TargetObj.setStyle("width",this.p.width);this.TargetObj.addClass("CGW-float-"+this.p.documentFloat);this.targetWidth=this.TargetObj.getWidth();this.TargetObjXY=Array();this.TargetObjXY[0]=this.targetX;this.TargetObjXY[1]=this.targetY;this.TargetObjCenter=false;this.setBoard()},setBoard:function(){this.boardSize=(this.p.boardPlace=="l"||this.p.boardPlace=="r")?parseInt(this.targetWidth/2,10)-8:this.targetWidth-8;this.board.setSize(this.boardSize);this.boardContent=this.board.createBoardContent();this.board.resizeBoard()},setConfig:function(){this.url=this.tool.GetServerSelf();this.p.title=(this.p.title==undefined||!this.p.title)?this.lang.title:this.p.title;this.p.theme=(this.p.theme==undefined||!this.p.theme)?"default":this.p.theme;this.p.url_utf8=(this.p.url_utf8==undefined||!this.p.url_utf8)?"":this.p.url_utf8;this.p.url=(this.p.url==undefined||!this.p.url)?"":this.p.url;if(this.p.url==""&&this.p.url_utf8==""){this.p.url="./pgnPlayerPath/pgn/demo.pgn"}this.p.boardTheme=(this.p.boardTheme==undefined||!this.p.boardTheme)?"default":this.p.boardTheme;this.p.pieceTheme=(this.p.pieceTheme==undefined||!this.p.pieceTheme)?"default":this.p.pieceTheme;this.p.gameNr=(this.p.gameNr==undefined||!this.p.gameNr||this.p.gameNr<1)?1:this.p.gameNr;this.p.gameNr--;this.p.startPosition=(this.p.startPosition==undefined||!this.p.startPosition||this.p.startPosition<0)?-1:parseInt(this.p.startPosition,10);this.p.width=(this.p.width==undefined||!this.p.width)?"100%":this.p.width;this.p.boardPlace=(this.p.boardPlace==undefined||!this.p.boardPlace)?"l":this.p.boardPlace;this.p.documentFloat=(this.p.documentFloat==undefined||!this.p.documentFloat)?"none":this.p.documentFloat;this.p.ButtonImg=(this.p.ButtonImg==undefined||!this.p.ButtonImg)?"default":this.p.ButtonImg;this.p.pieceFolder=(this.p.pieceFolder==undefined||!this.p.pieceFolder)?"default":this.p.pieceFolder;this.p.draggable=(this.p.draggable==undefined||this.p.draggable)?true:false;this.p.resizeable=(this.p.resizeable==undefined||this.p.resizeable==1)?true:this.p.resizeable;this.p.maximizable=(this.p.maximizable==undefined||!this.p.maximizable)?false:this.p.maximizable;this.p.maximize=(this.p.maximize==undefined||!this.p.maximize)?false:true;this.p.closable=(this.p.closable==undefined||!this.p.closable)?false:this.p.closable;this.p.help=(this.p.help==undefined||this.p.help)?true:false;this.p.showButtonText=(this.p.showButtonText==undefined||this.p.showButtonText)?true:false;this.p.padding=(this.p.padding==undefined||!this.p.padding)?"5px":this.p.padding;this.p.margin=(this.p.margin==undefined||!this.p.margin)?"":this.p.margin;this.p.fontSize=(this.p.fontSize==undefined||!this.p.fontSize)?"inherit":this.p.fontSize;this.p.commentField=(this.p.commentField==undefined)?true:this.p.commentField;this.p.BackgroundPath=this.p.pgnPlayerPath+"/boardTheme/"+this.p.boardTheme+"/board/background/";this.p.pathToButtonImg=this.p.pgnPlayerPath+"/theme/"+this.p.theme+"/button/";this.p.markDestinationField=(this.p.markDestinationField==undefined||this.p.markDestinationField)?true:false;this.p.addToBody=(this.p.addToBody==undefined||!this.p.addToBody||this.p.addToBody<1)?false:true;if(!this.p.addToBody){this.p.closable=false}this.p.reverse=false;this.p.pgnPlayerPath=this.p.pgnPlayerPath+"/";this.p.frameDescription=(this.p.frameDescription==undefined||this.p.frameDescription)?true:false;this.p.graficObject={board:this.p.BackgroundPath+"frame.jpg",white:this.p.BackgroundPath+"whiteSquare.jpg",black:this.p.BackgroundPath+"blackSquare.jpg",piecePath:this.p.pgnPlayerPath+"pieceTheme/"+this.p.pieceTheme+"/",start_note_board:this.p.pgnPlayerPath+"images/start_braet.gif"};this.p.gameArray=[];if(!this.lang.SEC){this.lang.SEC="Sec."}}};CGW.Game.prototype.gameParser=function(S){var K=navigator.appName=="Microsoft Internet Explorer";var N=S.indexOf("[");S=S.substr(N);var S=S.split(" [").join("[");var R=S.split("\n");var T=0;var O=new Array();O[T]=new Array();var L=false;var Q="";for(var M=0;M<R.length;M++){if(R[M].charAt(0)!="%"&&R[M].length>0){if(R[M].charAt(0)=="["&&R[M].charAt(1)!="%"){if(L){O[T]["Game"]=Q;L=false;T++;O[T]=new Array();var Q=""}var P=R[M].replace(/\[/g,"");var P=P.split('"');P[0]=P[0].replace(/ /g,"");O[T][P[0]]=P[1]}else{L=true;Q+=" "+R[M]}}}O[T]["Game"]=Q;this.p.gameArray=this.p.gameArray.concat(O)};CGW.Game.prototype.loadJob=function(){var C=function(D,E){Ext.Ajax.request({url:D,success:function(F){A.p.pgn=F.responseText;A.loadFinish(A.p.pgn,A)},failure:function(F){Ext.MessageBox.alert("Read error","Error! can't read pgn file: "+D)}})};var B=this.loadFinish;var A=this;if(this.p.url_utf8!=""){C(this.p.url_utf8,B)}else{C(this.p.url,B)}};CGW.Game.prototype.moveToPos=function(C,B,A,E){if(E.p.commentField){E.setSmallNote(C,B,A)}var D=Ext.get("Move_"+E.pgn.boardArray[A].boardNr+"_"+E.pgn.boardArray[A].gameNr+"_"+E.pgn.boardArray[A].variant+"_"+E.pgn.boardArray[A].moveNr);if(D){D.removeClass("cgw_selected_move")}if(B>E.pgn.boardArray[A].arrayPgn[C].length-1){B=E.pgn.boardArray[A].arrayPgn[C].length-1}if(B<-1){B=-1}E.pgn.boardArray[A].variant=C;E.pgn.boardArray[A].moveNr=B;E.pgn.boardArray.gameNr=A;var F=Ext.get("Move_"+E.pgn.boardArray[A].boardNr+"_"+E.pgn.boardArray[A].gameNr+"_"+E.pgn.boardArray[A].variant+"_"+E.pgn.boardArray[A].moveNr);if(F){F.addClass("cgw_selected_move")}if(B>=0&&C>=0){E.board.insertPieces(E.pgn.boardArray[A].boards[C][B])}else{E.board.insertPieces(E.pgn.boardArray[A].startBoard)}};CGW.Game.prototype.newPos=function(C,E){var B=E.pgn.boardArray.gameNr;var D=E.pgn.boardArray[B].variant;var A=E.pgn.boardArray[B].moveNr+C;if(A<-1){A=-1}if(E.pgn.boardArray[B].boards[D][A]||A==-1){this.moveToPos(D,A,B,E)}else{if(C>0){A=E.pgn.boardArray[B].cgw_Move_End[D]}else{A=E.pgn.boardArray[B].cgw_Move_Start[D]}this.moveToPos(D,A,B,E)}};CGW.Game.prototype.endPos=function(D){var B=D.pgn.boardArray.gameNr;var C=D.pgn.boardArray[B].variant;var A=D.pgn.boardArray[B].cgw_Move_End[C];if(D.pgn.boardArray[B].boards[C][A]||A==-1){this.moveToPos(C,A,B,D)}};CGW.Game.prototype.startPos=function(D){var B=D.pgn.boardArray.gameNr;var C=D.pgn.boardArray[B].variant;if(C==0){var A=-1}else{var A=D.pgn.boardArray[B].cgw_Move_Start[C]}if(D.pgn.boardArray[B].boards[C][A]||A==-1){this.moveToPos(C,A,B,D)}};CGW.Game.prototype.newVariant=function(C,E){var B=E.pgn.boardArray.gameNr;var D=E.pgn.boardArray[B].variant+C;if(D<0){D=0}if(!E.pgn.boardArray[B].cgw_Move_Start[D]&&D!=0){return false}if(D==0){var A=-1}else{var A=E.pgn.boardArray[B].cgw_Move_Start[D]}if(E.pgn.boardArray[B].boards[D][A]||A==-1){this.moveToPos(D,A,B,E)}};CGW.Game.prototype.showPreviousGame=function(A){if(this.p.gameNr<=0){return false}else{this.p.gameNr--}this.pgn.initGame(this);this.pgn.boardArray[this.p.gameNr].moveNr=0;this.pgn.boardArray[this.p.gameNr].variant=0;this.selectedNewGame()};CGW.Game.prototype.showNextGame=function(A){if(this.p.gameNr==this.p.gameArray.length-1){return false}else{this.p.gameNr++}this.pgn.initGame(this);this.pgn.boardArray[this.p.gameNr].moveNr=0;this.pgn.boardArray[this.p.gameNr].variant=0;this.selectedNewGame()};CGW.Game.prototype.newLangSetUp=function(D,A){if(!A){return false}var C=this;this.lang=CGW.lang[A];Ext.Cookie.set("language",A,365);Ext.Cookie.set("languageButtonImg",D,365);this.aboutBut.setText(this.lang.ABOUT);this.aboutBut.setHandler(function(){var F="<div class='about_headline'>CGW-player</div><div class='about_version'>Version "+CGW.version+"</div><br><div class='about_text'>"+this.lang.ABOUT_TEXT+"</div><br><div class='about_copyright'>"+CGW.COPYRIGHT+"</div><div class='about_url'><a href='http://www.cgw.dk/' target='_blank'>cwg.dk</a></div><br><div class='about_LICENSE'>Licensee: <span class='LicenseHolder'>"+CGW.License+"</span></div><br><div class='about_LICENSE'>updates: "+CGW.update+"</div><br>";var H=new Ext.Window({title:this.lang.ABOUT+" cgw-player",closeAction:"close",width:300,bodyStyle:"padding: 5px;",modal:true,html:F,buttons:[{text:"Close",handler:function(){H.hide()}}]});H.show()},this);this.helpBut.setText(this.lang.HELP);this.helpBut.setHandler(function(){var F=new Ext.Window({title:this.lang.HELP_TITLE,closeAction:"close",width:600,modal:true,html:this.lang.HELP_TEXT,buttons:[{text:this.lang.CLOSE,cls:"x-btn-text",handler:function(){F.hide()}}]});F.show()},this);n=0;for(var B=0.5;B<10;B+=0.5){this.timeMenu.items.items[n].setText(B+" "+this.lang.SEC);n++}this.downloadBut.setText(this.lang.DOWNLOAD);this.nextGameBut.setTooltip(this.lang.NEXT+" "+this.lang.tagType.tagsGame.toLowerCase());this.previousGameBut.setTooltip(this.lang.PREVIOUS+" "+this.lang.tagType.tagsGame.toLowerCase());var E=this.p.lang.split(",");this.tbar.remove(this.languageBut);this.languageBut=this.setLanguage();this.tbar.insertButton(this.tbar.items.length,this.languageBut);this.tbar.remove(this.selectGamesBut);this.selectGamesBut=this.selectGames();this.tbar.insertButton(0,this.selectGamesBut);this.tbar.doLayout();this.selectedNewGame();this.win.render()};CGW.Game.prototype.setTags=function(H,J,F){var K="<table><tbody>";for(var I in J){if(typeof H[I]=="undefined"||typeof H[I]==""){H[I]="?"}if(H[I]=="?"&&!F){K+=""}else{K+='<tr class="tagsLine"><td class="tagName">'+J[I]+': </td><td class="tagValue">'+H[I]+"</td></tr>"}}K+="</tbody></table>";return K};CGW.Game.prototype.setTabView=function(){var A=this.p.gameArray[this.p.gameNr];var K=new Array();K.tagsSRT=this.setTags(A,this.lang.tagsSRT,true);K.tagsPlayer=this.setTags(A,this.lang.tagsPlayer,false);K.tagsEvent=this.setTags(A,this.lang.tagsEvent,false);K.tagsGame=this.setTags(A,this.lang.tagsGame,false);K.tagsDIF=this.setTags(A,this.lang.tagsDIF,false);K.tagsExtra=this.setTags(A,this.lang.tagsExtra,false);var I=[];for(var H in K){if(K[H]!="<table><tbody></tbody></table>"&&this.lang.tagType[H]!=undefined){var J={title:this.lang.tagType[H],autoHeight:true,html:'<div class="x-panel-body tagContainer">'+K[H]+"</div>"};I.push(J)}}return I};CGW.Game.prototype.getTabContainer=function(){this.tabView=this.setTabView();this.tabPanel=new Ext.TabPanel({xtype:"tabpanel",autoHeight:true,deferredRender:true,activeItem:0,items:this.tabView,border:false,scope:this});this.tabPanel.on("tabchange",function(){})};CGW.Game.prototype.getNoteContainer=function(){this.gameNotes=Ext.get(this.pgn.boardArray[this.p.gameNr].GameNoteArray);this.noteContainer=new Ext.Panel({title:"",autoHeight:false,columnWidth:(this.p.boardPlace=="l"||this.p.boardPlace=="r")?0.5:1,cls:"cgw-notes-container",deferredRender:true,border:false,items:[this.gameNotes]});if(this.noteContainer.items&&this.noteContainer.items.items&&this.noteContainer.items.items[0]&&this.noteContainer.items.items[0].bwrap){this.noteContainer.items.items[0].bwrap.remove()}this.noteContainer.on("resize",function(){cgw_resizeAll("noteContainer resize")})};CGW.Game.prototype.setSmallNote=function(B,A,C){if(A.even()){var F=(parseInt(A/2,10)+1)+"."}else{var F=(parseInt(A/2,10)+1)+"..."}if(this.pgn.boardArray[C].arrayText[B][A]){var H=" - "+this.pgn.boardArray[C].arrayText[B][A]}else{var H=""}if(A==-1){var E=this.lang.buttonAlt.l1}else{var E=F+this.pgn.udskiftSprog(this.pgn.boardArray[C].arrayPgn[B][A])+H}if(this.p.commentField){this.smallNote.dom.innerHTML=E}};CGW.Game.prototype.showGame=function(){this.getTabContainer();this.getNoteContainer();this.contentContainer=new Ext.Panel({layout:"fit",title:"",autoHeight:false,width:"100%",border:false,columnWidth:(this.p.boardPlace=="l"||this.p.boardPlace=="r")?0.5:1,items:[this.tabPanel,this.noteContainer]})};CGW.Game.prototype.selectedNewGame=function(){this.contentContainer.remove(this.tabPanel);this.contentContainer.remove(this.noteContainer);this.getTabContainer();this.contentContainer.add(this.tabPanel);var A=this.pgn.boardArray[this.p.gameNr].moveNr;var C=this.pgn.boardArray[this.p.gameNr].variant;this.pgn.boardArray=null;this.pgn.boardArray=[];this.pgn.initGame(this);this.getNoteContainer();this.contentContainer.add(this.noteContainer);this.contentContainer.layout.layout();this.pgn.boardArray.gameNr=this.p.gameNr;var B=this.win.getSize();this.win.setSize(B.width+1,B.height+1);this.win.setSize(B.width,B.height);this.newPos(0,this);cgw_resizeAll("selectedNewGame")};CGW.Game.prototype.selectGames=function(){var H=[];var A=this.p.gameArray;for(var F=0;F<A.length;F++){var C=A[F].White+" - "+A[F].Black+" "+A[F].Result+"("+A[F].Round+")";var B=A[F].Round.replace(/[A-Za-z]/gi,"");var E=this.lang.WHITE+": "+A[F].White+"<br>"+this.lang.BLACK+": "+A[F].Black+"<br>"+this.lang.RESULT+": "+A[F].Result+"<br>"+this.lang.ROUND.toLowerCase()+": "+B;H.push([F,C,E])}var D=new Ext.form.ComboBox({tpl:'<tpl for="."><div ext:qtip="{title}" class="x-combo-list-item">{name}</div></tpl>',store:new Ext.data.SimpleStore({fields:["value","name","title"],data:H}),valueField:"value",displayField:"name",listWidth:400,typeAhead:true,mode:"local",triggerAction:"all",emptyText:this.lang.GAMELIST,selectOnFocus:true,scope:this,initList:function(){this.constructor.prototype.initList.apply(this,arguments);this.list.setWidth("auto");this.innerList.setWidth("auto")}});D.on("select",function(I){I.scope.p.gameNr=I.getValue();I.scope.pgn.boardArray.gameNr=I.scope.p.gameNr;I.scope.pgn.initGame(I.scope);I.scope.pgn.boardArray[I.scope.p.gameNr].moveNr=0;I.scope.pgn.boardArray[I.scope.p.gameNr].variant=0;I.scope.selectedNewGame()});return D};CGW.Game.prototype.download=function(){var A=new Ext.Button({scope:this,cls:(this.p.showButtonText)?"x-btn-text-icon":"x-btn-icon",icon:this.p.pgnPlayerPath+"/theme/"+this.p.theme+"/button/disk.png",text:(this.p.showButtonText)?this.lang.DOWNLOAD:"",handler:function(C,B,E){var D=window.open(this.p.url,"pgn");D.focus()}});return A};CGW.Game.prototype.help=function(){var A=new Ext.Button({scope:this,cls:(this.p.showButtonText)?"x-btn-text-icon":"x-btn-icon",icon:this.p.pgnPlayerPath+"/theme/"+this.p.theme+"/button/icon-question.png",text:(this.p.showButtonText)?this.lang.HELP:"",handler:function(){var B=new Ext.Window({title:this.lang.HELP_TITLE,closeAction:"close",width:600,modal:true,html:this.lang.HELP_TEXT,buttons:[{text:this.lang.CLOSE,cls:"x-btn-text",handler:function(){B.hide()}}]});B.show()}});return A};CGW.Game.prototype.nextGame=function(){var A=new Ext.Button({scope:this,cls:"x-btn-icon",icon:this.p.pgnPlayerPath+"/theme/"+this.p.theme+"/grid/page-next.gif",tooltip:this.lang.NEXT+" "+this.lang.tagType.tagsGame.toLowerCase(),handler:function(){this.showNextGame()}});return A};CGW.Game.prototype.previousGame=function(){var A=new Ext.Button({scope:this,cls:"x-btn-icon",icon:this.p.pgnPlayerPath+"/theme/"+this.p.theme+"/grid/page-prev.gif",tooltip:this.lang.PREVIOUS+" "+this.lang.tagType.tagsGame.toLowerCase(),handler:function(){this.showPreviousGame()}});return A};CGW.Game.prototype.setLanguage=function(){var E=[];if(!this.languageButtonImg){this.languageButtonImg=0}var C=this.p.lang.split(",");if(C.length<2){return false}for(var D=0;D<C.length;D++){var B={scope:this,lang:C,langNr:D,cls:"x-btn-text-icon",icon:this.p.pgnPlayerPath+"images/flag/"+C[D]+".png",text:C[D],handler:function(F){this.languageButtonImg=F.langNr;this.newLangSetUp(F.langNr,F.lang[F.langNr])}};E.push(B)}var A=new Ext.Button({scope:this,cls:"x-btn-text-icon",icon:this.p.pgnPlayerPath+"images/flag/"+C[this.languageButtonImg]+".png",text:this.lang.THISLANG,menu:E});return A};CGW.Game.prototype.about=function(){var B="<div class='about_headline'>CGW-player</div><div class='about_version'>Version "+CGW.version+"</div><br><div class='about_text'>"+this.lang.ABOUT_TEXT+"</div><br><div class='about_copyright'>"+CGW.COPYRIGHT+"</div><div class='about_url'><a href='http://www.cgw.dk/' target='_blank'>cwg.dk</a></div><br><div class='about_LICENSE'>Licensee: <span class='LicenseHolder'>"+CGW.License+"</span></div><br><div class='about_LICENSE'>updates: "+CGW.update+"</div><br>";var A=new Ext.Button({scope:this,cls:(this.p.showButtonText)?"x-btn-text-icon":"x-btn-icon",icon:this.p.pgnPlayerPath+"/theme/"+this.p.theme+"/button/icon-info.png",text:(this.p.showButtonText)?this.lang.ABOUT:"",handler:function(){var C=new Ext.Window({title:this.lang.ABOUT+" cgw-player",closeAction:"close",width:300,bodyStyle:"padding: 5px;",modal:true,html:B,buttons:[{text:"Close",handler:function(){C.hide()}}]});C.show()}});return A};CGW.Game.prototype.createNavigatorButtons=function(){var B=(this.p.boardSize-128)/21;if(B>13){B=13}if(B<9){B=9}this.autoTime=1;this.autoPlay=false;this.autoPlayFunction=new Ext.util.DelayedTask(function(){if(!this.autoPlay){return false}this.newPos(1,this);this.autoPlayFunction.delay(this.autoTime*1000)},this);this.timeMenu=new Ext.menu.Menu();for(var A=0.5;A<10;A+=0.5){this.timeMenu.add({text:A+" "+this.lang.SEC,checked:A==1,group:"timedelay",style:"text-align: right;",value:A,thisObj:this,checkHandler:function(C){this.thisObj.autoTime=this.value}})}this.navigatorButtons=new Ext.Panel({scope:this,baseCls:"x-plain",split:true,height:28,layout:"fit",margins:"4 4 4 4",items:[{anchor:"100%",baseCls:"x-plain",layout:"hbox",layoutConfig:{padding:"2",align:"middle"},defaults:{margins:"0 0 0 0",pressed:false,allowDepress:false},items:[new Ext.SplitButton({start:false,text:'<img id="cgw_autoplay_button_'+this.GC+'" class="CGW-button-img CGW-button-img_'+this.GC+'" alt="Auto play" src="'+this.p.pathToButtonImg+'pausePlay.png">',handler:function(E){this.autoPlay=(this.autoPlay==false);if(this.autoPlay){var C=this.p.pathToButtonImg+"autoPlay.png";this.autoPlayFunction.delay()}else{var C=this.p.pathToButtonImg+"pausePlay.png"}var D=Ext.get("cgw_autoplay_button_"+this.GC);D.dom.src=C},arrowAlign:"right",scope:this,parent:this.scope,flex:1.3,menu:this.timeMenu}),{xtype:"button",text:'<img class="CGW-button-img CGW-button-img_'+this.GC+'" alt="'+this.lang.buttonAlt.l1+'" src="'+this.p.pathToButtonImg+'moveToBegin.png">',handler:function(){this.startPos(this)},flex:1,scope:this},{xtype:"button",text:'<img class="CGW-button-img CGW-button-img_'+this.GC+'" alt="'+this.lang.buttonAlt.l2+'" src="'+this.p.pathToButtonImg+'moveStepAtBegin.png">',handler:function(){this.newPos(-5,this)},flex:1,scope:this},{xtype:"button",text:'<img class="CGW-button-img CGW-button-img_'+this.GC+'" alt="'+this.lang.buttonAlt.l3+'" src="'+this.p.pathToButtonImg+'moveAtBegin.png">',handler:function(){this.newPos(-1,this)},flex:1,scope:this},{xtype:"button",text:'<img class="CGW-button-img CGW-button-img_'+this.GC+'" alt="'+this.lang.buttonAlt.r3+'" src="'+this.p.pathToButtonImg+'moveAtEnd.png">',handler:function(){this.newPos(1,this)},flex:1,scope:this},{xtype:"button",text:'<img class="CGW-button-img CGW-button-img_'+this.GC+'" alt="'+this.lang.buttonAlt.r2+'" src="'+this.p.pathToButtonImg+'moveStepAtEnd.png">',handler:function(){this.newPos(5,this)},flex:1,scope:this},{xtype:"button",text:'<img class="CGW-button-img CGW-button-img_'+this.GC+'" alt="'+this.lang.buttonAlt.r1+'" src="'+this.p.pathToButtonImg+'moveToEnd.png">',handler:function(){this.endPos(this)},flex:1,scope:this},{xtype:"button",text:'<img class="CGW-button-img CGW-button-img_'+this.GC+'" alt="'+this.lang.buttonAlt.reverse+'" src="'+this.p.pathToButtonImg+'reverseBoard.png">',handler:function(){this.p.reverse=!this.p.reverse;this.board.resizeBoard()},flex:1,scope:this}]}]})};CGW.Game.prototype.navigatorResize=function(){var B=this.navigatorButtons.getWidth();var C=Ext.query(".CGW-button-img_"+this.GC);var A=parseInt(14*B/400,10);var D=(B<400)?A:14;if(B<200){A--}for(var E=0;E<C.length;E++){Ext.get(C[E]).setHeight(D)}};CGW.Game.prototype.getTbar=function(){this.selectGamesBut=this.selectGames();this.previousGameBut=this.previousGame();this.nextGameBut=this.nextGame();this.downloadBut=this.download();this.helpBut=this.help();this.aboutBut=this.about();this.languageBut=this.setLanguage();var A=[];A.push(this.selectGamesBut);A.push(this.previousGameBut);A.push(this.nextGameBut);A.push("-");if(this.p.download){A.push(this.downloadBut);A.push("-")}if(this.p.help){A.push(this.helpBut)}A.push(this.aboutBut);if(this.languageBut){A.push("->");A.push(this.languageBut)}var A=new Ext.Toolbar({style:"width:100%;",items:A});return A};CGW.Game.prototype.createWindow=function(){this.tbar=this.getTbar();this.showGame();this.createNavigatorButtons();this.commentId=Ext.id();var D=new Ext.Panel({title:"",border:false,layout:"fit",style:"position: relative;",draggable:false,html:'<div class="smallNote" id="'+this.commentId+'">test</div>'});var A=[this.boardContent];A.push(this.navigatorButtons);if(this.p.commentField){A.push(D)}this.boardContainer=new Ext.Panel({title:"",autoHeight:true,columnWidth:(this.p.boardPlace=="l"||this.p.boardPlace=="r")?0.5:1,border:false,items:A});var B=[];if(this.p.boardPlace=="l"||this.p.boardPlace=="t"){B.push(this.boardContainer);B.push(this.contentContainer)}else{B.push(this.contentContainer);B.push(this.boardContainer)}var C=[{cls:"x-btn-text-icon",text:CGW.COPYRIGHT,handler:function(){var E=window.open("http://www.cgw.dk/","cgw")}}];this.win=new Ext.Window({title:this.p.title,tbar:this.tbar,x:this.TargetObjXY[0],y:this.TargetObjXY[1],autoHeight:true,layout:"column",draggable:this.p.draggable,closable:this.p.closable,closeAction:"hide",resizable:this.p.resizeable,bufferResize:50,maximizable:this.p.maximizable,maximized:this.p.maximize,constrain:this.TargetObjCenter,width:this.targetWidth,style:"position: absolute;",bbar:C,scope:this,items:B});this.win.show();this.contentContainer.on("resize",function(){cgw_resizeAll("contentContainer resize")},this);this.win.on("maximize",function(){Ext.getBody().removeClass("x-window-maximized-ct");cgw_resizeAll("maximize");window.scrollBy(0,-50000);Ext.getBody().addClass("x-window-maximized-ct");if(Ext.isIE){Ext.getBody().dom.scroll="no"}},this);this.win.on("restore",function(){cgw_resizeAll("restore");if(Ext.isIE){Ext.getBody().dom.scroll="yes"}var E=this.win.el.getTop();window.scrollBy(0,E)},this);this.win.on("resize",function(){if(!this.win.maximized){this.lockResize=true}cgw_resizeAll("resize")},this);this.win.on("move",function(){this.lockMoveOld=this.lockMove;this.lockMove=true},this);this.navigatorResize();this.oldWidth=this.win.getWidth();if(this.p.commentField){this.smallNote=Ext.get(this.commentId)}};