(function(){var p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,F,a="a",b="img",c="info",d="#",e="<br />",f="id",g="loading",h="",i="text",j="20",k="submit",l="dt",m="date",n="input",o="U";C=Ext;t=C.data;p=t.Record;w=C.util;A=C.state;x=C.form;s=new w.MixedCollection();z=[];v=null;F={id:0};B="login";y="username";q="DESC";C.useShims=false;C.num=function(E){return parseInt(E,10)};r={showLoginForm:function(){var E,G,H,I,J,K,L,M,N;I=C.getBody();M="password";K="rememberMe";I.addClass(B);if(!v){u=_tr;E=C.getDom;J=E(y);H=new x.TextField({id:y,fieldLabel:u(y),tabIndex:1,autoCreate:{tag:n,type:i,size:j},value:J.value});J=E(M);N=new x.TextField({id:M,fieldLabel:u(M),value:J.value,inputType:M,tabIndex:2,autoCreate:{tag:n,type:i,size:j}});C.fly(J.form).remove();v=new C.FormPanel({id:B,labelWidth:100,frame:true,items:[H,N,{xtype:"checkbox",id:K,fieldLabel:u(K)},{xtype:"fieldset",title:u("notRegistered"),collapsible:true,collapsed:true,autoHeight:true,labelWidth:49,html:u("regInfo")+"<br/>"+u("regInfoAfter")}],buttons:[{text:u(B),tabIndex:3,iconCls:g,listeners:{click:function(){G.click()}}}],listeners:{render:function(P){var O;O=P.getForm().getEl();G=O.createChild({tag:n,type:k,cls:k}).dom}},onSubmit:function(Q){var O,P,R,S;Q.stopEvent();O=H.getValue();R=N.getValue();S=C.getCmp(K);if(O!==h&&R!==h){R=w.MD5(R);if(S&&S.getValue()){r.setLoginCookie(O,R)}r.Client.signon(O,R);P=v.buttons[0];P.setIconClass(g);P.setText(Ext.LoadMask.prototype.msg);P.disable()}},renderTo:I});L=v.getComponent(3);L.header.child("span").on("click",L.toggleCollapse,L);H.focus()}else{C.fly(c).hide();v.show()}return v},hideLoginForm:function(){if(v){v.hide()}},getLoginForm:function(){return v},user:null,addPlayer:function(E){if(!r.playerExists(E.id)){s.add(E.id,E)}},getPlayer:function(E){if(r.playerExists(E)){return s.get(E)}throw new Error("No player with id "+E)},playerExists:function(E){return s.containsKey(E)},M:{add:function(E){z.push(E)},clear:function(){z=[]},show:function(){var E;E=C.fly(c);if(E){E.update(z.join(e));E.show()}else{E=C.DomHelper.append(C.getBody(),{id:c,html:z.join(e)})}r.M.clear()},hide:function(){C.fly(c).hide()}},init:function(){var E,G,H,I,J,K,L,M,N,O,P;G="/images/default/s.gif";O=C.getBody();L="lastmove";M="logout";u=_tr;C.BLANK_IMAGE_URL=G;O.addClass("desktop");O.createChild({id:"x-desktop",cn:[{tag:"dl",id:"x-shortcuts",cn:[{tag:l,id:"gamelist-win-shortcut",cn:[{tag:a,href:d,cn:[{tag:b,src:G},{html:u("gameList")}]}]},{tag:l,id:"players-win-shortcut",cn:[{tag:a,href:d,cn:[{tag:b,src:G},{html:u("players")}]}]}]}]});O.createChild({id:"ux-taskbar",cn:[{id:"ux-taskbar-start"},{id:"ux-taskbar-panel-wrap",cn:[{id:"ux-quickstart-panel"},{id:"ux-taskbuttons-panel"}]},{cls:"x-clear"}]});I="int";E=p.create([{name:f,type:I},{name:"id_x",type:I},{name:"id_o",type:I},{name:"size",type:I},{name:L,type:m,dateFormat:o},{name:"onmove",type:I},{name:"started",type:I},{name:"type",type:I},"net"]);P=p.create([{name:f,type:I},y,{name:"lastlogin",type:m,dateFormat:o}]);J=new t.Store({recordType:E,sortInfo:{field:L,direction:q}});K=new t.Store({recordType:E,sortInfo:{field:L,direction:q}});H=new t.Store({recordType:E,sortInfo:{field:L,direction:q}});N=new t.Store({recordType:E,sortInfo:{field:L,direction:q}});C.apply(r,new C.app.App({init:function(){C.QuickTips.init();D=r.Client;D.loadSound()},getModules:function(){return[new r.GameListWindow(),new r.PlayersWindow(),new r.GameWindowModule(),new r.PlayerWindowModule(),new r.NewGameWindowModule(),new r.ChatWindowModule()]},startConfig:{title:u("XOGame"),iconCls:"user",toolItems:[{text:u(M),iconCls:M,handler:function(){(new A.CookieProvider()).clearCookie(B);location.reload()}}]},dateFormat:"j. n. Y",dateTimeFormat:"j. n. Y G:i",GameRecord:E,PlayerRecord:P,games:J,archivedGames:K,publicGames:H,openedGames:N,getGameRecord:function(R){var Q;Q=J.getById(R)||N.getById(R)||K.getById(R)||H.getById(R);if(!Q){throw new Error("No game with id "+R)}return Q},getGame:function(Q){if(F.id!=Q){F=r.getGameInstance(r.getGameRecord(Q))}return F},gameExists:function(S){var Q;try{Q=r.getGame(S)}catch(R){}return typeof Q==="object"},removeGame:function(T,R){var Q,S;if(R!==false){D.removeGame(T)}Q=r.games;Q.remove(Q.getById(T));S=r.getGameWindow(T,false);if(S){S.close()}},refuseGame:function(Q){D.refuseGame(Q);r.removeGame(Q,false)},showGame:function(S){var Q,R;R=r.getGame(S);Q=R.isNew();if(R.isNetLoaded()||Q){if(Q){R.setNet([])}r.getGameWindow(S).show()}else{D.getNet(S)}},makeMove:function(R,T){var Q,S;Q=r.getGame(R);if(Q.hasWinner()){S="1"}else{if(Q.isTieMove()){S="2"}}D.makeMove(R,T,S)},newGame:function(R,S,Q,T){D.newGame(R,S,Q,T)},showPlayer:function(Q){var R;if(r.playerExists(Q)){R=r.getPlayer(Q);if(R.needRefresh()){D.getPlayerInfo(Q)}else{r.getPlayerWindow(Q).show()}}else{throw new Error("No player "+Q)}},notify:function(){r.notifySound.start()},fillGrid:function(R,T,U,S){var Q;Q=R.getStore();Q.removeAll();Q.add(T);Q.totalLength=S;R.loadMask.onLoad();R.getBottomToolbar().onLoad(Q,T,{params:{start:U}})},getGameWindow:function(R,Q){return r.getModule("game-win").getWindow({gameId:R},Q)},getPlayerWindow:function(R,S,Q){Q=C.apply({playerId:R},Q);return r.getModule("player-win").getWindow(Q,S)},getNewGameWindow:function(R,S,Q){Q=C.apply({playerId:R},Q);return r.getModule("new-game-win").getWindow(Q,S)},getGameListWindow:function(){return r.getModule("gamelist-win").getWindow()},getPlayersModule:function(){return r.getModule("players-win")},getPlayersWindow:function(){return r.getPlayersModule().getWindow()},getChatWindow:function(){return r.getModule("chat-win").getWindow()},util:{parseLastLogin:function(Q){if(!Q||!Q.format){return u("never")}return Q.format(r.dateTimeFormat)}}}));delete r.init}};XOGame=r}());(function(){var f,g,j,k,l,m,a='"',b="?callback=",c=".",d="aflaxCallFunction";k=0;j=Ext.num;m="/static/aflax.swf";f={"true":true,"false":false,"undefined":undefined,"null":null,"NaN":NaN};function i(){var n;if(navigator.plugins&&navigator.mimeTypes.length){n=navigator.plugins["Shockwave Flash"];if(n&&n.description){return j(n.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,c).split(c)[0])}}else{if(window.ActiveXObject){try{n=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");return j(n.GetVariable("$version").split(" ")[1].split(",")[0])}catch(o){}}}return 0}function e(){this.id="aflax_"+k++}l=e.prototype;l.getHTML=function(p,n,o,q){if(i()<8){return'<div class="noflash">To play Live XO you need to install <a target="_blank" href="http://www.adobe.com/go/getflashplayer">Flash Player version 8.0 or higher</a>.</div>'}return'<object width="'+p+'" height="'+n+'" id="'+this.id+'" type="application/x-shockwave-flash" data="'+m+b+q+'"><param name="allowScriptAccess" value="sameDomain" /><param name="bgcolor" value="'+o+'" /><param name="movie" value="'+m+b+q+'" /><param name="scale" value="noscale" /><param name="salign" value="lt" /></object>'};l.F=function(){var n=this;if(!n.f){n.f=document[n.id]}return n.f};l.callFunction=function(o){var n,p;n=this.F().CallFunction('<invoke name="'+o+'" returntype="javascript">'+__flash__argumentsToXML(arguments,1)+"</invoke>");if(f.hasOwnProperty(n)){n=f[n]}else{if(n.charAt(0)==a){p=n.length-1;if(n.charAt(p)==a){n=n.substring(1,p)}}else{n=n-0}}return n};l.callStaticFunction=function(){return this.callFunction("ACallStaticFunction",arguments)};function h(o,n){this.a=o;this.id=o.callFunction("aflaxCreateObject",[n])}g=h.prototype;g.callFunction=function(q){var n,o,p,r;o=[this.id,q];for(p=1,n=arguments.length;p<n;p++){r=arguments[p];if(r===null){r="null"}else{if(r.id){r="ref:"+r.id}}o[p+1]=r}return this.a.callFunction(d,o)};g.exposeFunction=function(n){this[n]=function(){var o,p,q;p=[this.id,n];for(q=0,o=arguments.length;q<o;q++){p[q+2]=arguments[q]}return this.a.callFunction(d,p)}};e.getSocket=function(q,o,p,r){var n;n=new h(q,"XMLSocket");q.F().aflaxAttachSocketEvents([n.id,o,p,r]);n.exposeFunction("connect");n.exposeFunction("close");n.exposeFunction("send");return n};e.FlashObject=h;XOGame.A=e})();(function(){var a,b;a={};_tr=function(c){return a[c]||"{"+c+"}"};b={set:function(d){var c;for(c in d){a[c]=d[c]}if(b.onset){b.onset()}}};XOGame.T=b}());Ext.util.MD5=function(){var o,p,q,r,s,t,u,v,w,a=32,b=23,c=22,d=21,e=20,f=17,g=16,h=15,i=14,j=13,k=12,l=11,m=10,n=65535;q="0123456789abcdef";u=function(y,x){var z,A;A=(y&n)+(x&n);z=(y>>g)+(x>>g)+(A>>g);return(z<<g)|(A&n)};o=function(x,y){return(x<<y)|(x>>>(a-y))};s=function(D,A,z,y,C,B){return u(o(u(u(A,D),u(y,B)),C),z)};t=function(A,z,E,D,y,C,B){return s((z&E)|((~z)&D),A,z,y,C,B)};w=function(A,z,E,D,y,C,B){return s((z&D)|(E&(~D)),A,z,y,C,B)};p=function(A,z,E,D,y,C,B){return s(z^E^D,A,z,y,C,B)};r=function(A,z,E,D,y,C,B){return s(E^(z|(~D)),A,z,y,C,B)};v=function(I,D){var y,z,A,B,C,E,F,G,H;I[D>>5]|=128<<((D)%a);I[(((D+64)>>>9)<<4)+i]=D;H=1732584193;G=4023233417;F=2562383102;E=271733878;for(A=0;A<I.length;A+=g){C=H;B=G;z=F;y=E;H=t(H,G,F,E,I[A],7,3614090360);E=t(E,H,G,F,I[A+1],k,3905402710);F=t(F,E,H,G,I[A+2],f,606105819);G=t(G,F,E,H,I[A+3],c,3250441966);H=t(H,G,F,E,I[A+4],7,4118548399);E=t(E,H,G,F,I[A+5],k,1200080426);F=t(F,E,H,G,I[A+6],f,2821735955);G=t(G,F,E,H,I[A+7],c,4249261313);H=t(H,G,F,E,I[A+8],7,1770035416);E=t(E,H,G,F,I[A+9],k,2336552879);F=t(F,E,H,G,I[A+m],f,4294925233);G=t(G,F,E,H,I[A+l],c,2304563134);H=t(H,G,F,E,I[A+k],7,1804603682);E=t(E,H,G,F,I[A+j],k,4254626195);F=t(F,E,H,G,I[A+i],f,2792965006);G=t(G,F,E,H,I[A+h],c,1236535329);H=w(H,G,F,E,I[A+1],5,4129170786);E=w(E,H,G,F,I[A+6],9,3225465664);F=w(F,E,H,G,I[A+l],i,643717713);G=w(G,F,E,H,I[A],e,3921069994);H=w(H,G,F,E,I[A+5],5,3593408605);E=w(E,H,G,F,I[A+m],9,38016083);F=w(F,E,H,G,I[A+h],i,3634488961);G=w(G,F,E,H,I[A+4],e,3889429448);H=w(H,G,F,E,I[A+9],5,568446438);E=w(E,H,G,F,I[A+i],9,3275163606);F=w(F,E,H,G,I[A+3],i,4107603335);G=w(G,F,E,H,I[A+8],e,1163531501);H=w(H,G,F,E,I[A+j],5,2850285829);E=w(E,H,G,F,I[A+2],9,4243563512);F=w(F,E,H,G,I[A+7],i,1735328473);G=w(G,F,E,H,I[A+k],e,2368359562);H=p(H,G,F,E,I[A+5],4,4294588738);E=p(E,H,G,F,I[A+8],l,2272392833);F=p(F,E,H,G,I[A+l],g,1839030562);G=p(G,F,E,H,I[A+i],b,4259657740);H=p(H,G,F,E,I[A+1],4,2763975236);E=p(E,H,G,F,I[A+4],l,1272893353);F=p(F,E,H,G,I[A+7],g,4139469664);G=p(G,F,E,H,I[A+m],b,3200236656);H=p(H,G,F,E,I[A+j],4,681279174);E=p(E,H,G,F,I[A],l,3936430074);F=p(F,E,H,G,I[A+3],g,3572445317);G=p(G,F,E,H,I[A+6],b,76029189);H=p(H,G,F,E,I[A+9],4,3654602809);E=p(E,H,G,F,I[A+k],l,3873151461);F=p(F,E,H,G,I[A+h],g,530742520);G=p(G,F,E,H,I[A+2],b,3299628645);H=r(H,G,F,E,I[A],6,4096336452);E=r(E,H,G,F,I[A+7],m,1126891415);F=r(F,E,H,G,I[A+i],h,2878612391);G=r(G,F,E,H,I[A+5],d,4237533241);H=r(H,G,F,E,I[A+k],6,1700485571);E=r(E,H,G,F,I[A+3],m,2399980690);F=r(F,E,H,G,I[A+m],h,4293915773);G=r(G,F,E,H,I[A+1],d,2240044497);H=r(H,G,F,E,I[A+8],6,1873313359);E=r(E,H,G,F,I[A+h],m,4264355552);F=r(F,E,H,G,I[A+6],h,2734768916);G=r(G,F,E,H,I[A+j],d,1309151649);H=r(H,G,F,E,I[A+4],6,4149444226);E=r(E,H,G,F,I[A+l],m,3174756917);F=r(F,E,H,G,I[A+2],h,718787259);G=r(G,F,E,H,I[A+9],d,3951481745);H=u(H,C);G=u(G,B);F=u(F,z);E=u(E,y)}return[H,G,F,E]};return function(C){var x,y,z,A,B;A=[];z=0;x=C.length*8;for(;z<x;z+=8){A[z>>5]|=(C.charCodeAt(z/8)&n)<<(z%a)}B=v(A,x);y="";for(z=0;z<g;z++){y+=q.charAt((B[z>>2]>>((z%4)*8+4))&h)+q.charAt((B[z>>2]>>((z%4)*8))&h)}return y}}();(function(){var m,n,o,s,t,w,x,z,B,C,F,G,H,I,K,M,O,P,V,Y,Z,aa,ab,ad,ae,af,a="list",b="errorConnecting",c="plist",d="f",e="net",g=100,h="ref",i="c",j=1000,k="1",l="new";x=Ext;m=XOGame;o=_tr;Y=x.state;ae=x.num;ad=new m.A();H=String.fromCharCode;B=Array.prototype.slice;F=H(30);af=H(29);n="91.185.195.54";V=9090;M=false;s=false;w=false;G=0;I={};P=240000;K="connecting";C="login";function p(){return B.call(arguments,0).join(F)}function W(){return B.call(arguments,0).join(af)}function ac(){return ab||(new Y.CookieProvider()).get(C)}m.setLoginCookie=function(E,f){(new Y.CookieProvider()).set(C,E+F+f)};function ag(E){var f,T,X,ah;E=E.split(F);ah=ae(E[0]);f=ae(E[1]);X=ae(E[3]);if(!m.playerExists(f)){new m.Player(f,E[2])}if(!m.playerExists(X)){new m.Player(X,E[4])}T=new x.util.MixedCollection();T.add("empty",true);return new m.GameRecord({id:ah,id_x:f,id_o:X,size:ae(E[5]),lastmove:new Date(j*E[6]),onmove:ae(E[7]),started:ae(E[8]),type:ae(E[9]),net:T},ah)}function N(X){var f,E,T,ah,ai,aj,ak,al,am;al=3;T=[];ak=X[0];E=ae(X[1]);am=ae(X[2]);aj=ak?ae(ak):0;ai=m.getGameListWindow();f=ai.getComponent(0).getComponent(aj);while((ah=X[al++])){T[T.length]=ag(ah)}m.fillGrid(f,T,E,am);ai.show()}function S(E){var f,T,X,ah;X=ag(E[1]);f=m.getGameInstance(X);ah="gamelist-win-";if(f.isPublicList()){ah+="public"}else{ah+="mine"}T=x.getCmp(ah);if(T.getBottomToolbar().cursor===0){T.getStore().insert(0,X);T.checkNumGames()}}function v(aj){var f,E,T,X,ah,ai,ak;X=ae(aj[1]);T=m.getGame(X);ai=I[X];T.setNet(aj[2].split(F));ak=m.getGameWindow(X);if(ai){for(ah=0,E=ai.length;ah<E;ah++){f=ai[ah];ak.addMsg(f.msg,f.player)}delete I[X]}ak.show()}function L(X){var f,E,T,ah,ai;E=ae(X[1]);if(m.gameExists(E)){ai=X[2];T=X[3];f=m.getGame(E);if(f.isSimulation()){f.makeSimMove(ai,T)}else{ah=m.getGameWindow(E,false);f.updateField(ai,T);if(ah){ah.update()}if(m.getGameListWindow().playSound){m.notify()}}}}function q(T){var f,E,X,ah;T=T.split(F);if(T.length!=2&&T.length!=3){throw new Error("Protocol error")}f=ae(T[0]);ah=T[1];X=T[2]||null;if(X){X=new Date(j*X)}if(m.playerExists(f)){E=m.getPlayer(f);if(X){E.updateData({lastlogin:X})}}else{E=new m.Player(f,ah,X)}return E}function J(ah){var f,E,T,X,ai,aj,ak,al,am;ak=3;X=[];T=ae(ah[1]);al=ae(ah[2]);am=m.PlayerRecord;f=m.getPlayersModule().getListPanel();while((E=ah[ak++])){aj=q(E);ai=aj.id;X[X.length]=new am({id:ai,username:aj.username,lastlogin:aj.lastlogin},ai)}m.fillGrid(f,X,T,al)}function A(E){var f,T,X,ah;ah=0;f=[];while((T=E[ah++])){f.push(q(T))}X=m.getPlayersModule();X.setOnlinePlayers(f);X.showWindow()}function Q(T){var f,E;E=T[1];if(E===k){f=q(T[2])}else{f={id:T[2]}}m.getPlayersModule().updateOnlineStatus(f,E)}function u(f){m.removeGame(f[1],false)}function D(ai){var f,E,T,X,ah,aj,ak;ah=ai[1];E=ai[2];ak=ai[3];X=m.getPlayer(E);if(ah===""){m.getChatWindow().chat.addMsg(ak,X)}else{if(ah.slice(0,1)==="g"){T=ah.slice(1);f=m.getGame(T);if(f.isNetLoaded()){aj=m.getGameWindow(T);aj.addMsg(ak,X);aj.show()}else{I[T]=I[T]||[];I[T].push({msg:ak,player:X});z.getNet(T)}}}}function r(f){switch(f[1]){case"4":alert("Field is not empty");break;case"3":alert("Persmission denied");break;case"2":alert("Wrong username or password");break;case k:alert("Uknown command");break;case"0":w=true;alert("Too many connections");break;case"5":w=true;alert("No activity timeout");break;default:alert("Unknown error")}}function R(f){if(M){aa.send(f);Z()}}function U(){z.onConnect(false)}function y(){R("a")}Z=function(){if(t){clearInterval(t)}t=setInterval(y,P)};z={onConnect:function(ah){var f,E,T,X,ai;T=m.getLoginForm();if(T){f=T.buttons[0]}if(ah){M=true;G=0;m.M.hide();E=ac();if(s){s=false;if(m.getDesktop){ai=m.getDesktop();ai.unmask();ai.showTaskbar()}}if(E){X=E.split(F);z.signon(X[0],X[1])}else{f.setIconClass("game-my-turn");f.setText(o(C));f.enable()}}else{if(f){f.setIconClass("game-not-my-turn");f.setText(o(b))}else{m.M.add(o(b));m.M.show()}}clearTimeout(O);O=null},onClose:function(){var f;M=false;s=true;if(m.getDesktop){f=m.getDesktop();f.hideTaskbar();f.mask(o("connLost"))}m.user=null;if(!w){setTimeout(function(){z.connect()},G);G+=5000}},onData:function(T){var f,E,X;E=T.split(af);switch(E[0]){case"uf":L(E);break;case i:D(E);break;case"uol":Q(E);break;case e:v(E);break;case"pdata":f=q(E[1]);if(!m.user){m.hideLoginForm();x.getBody().removeClass(C);f.updateData({lastlogin:new Date()});m.user=f;m.pageSize=ae(E[2]);m.init();X=2;while((E[++X])){}A(E.slice(3,X));N(E.slice(X));m.getChatWindow().show()}else{m.getPlayerWindow(f.id,true,{forceUpdate:true}).show()}break;case l:S(E);break;case a:N(E.slice(1));break;case c:J(E);break;case h:u(E);break;case"err":r(E)}},c:function(){var f;x.fly(d).setLeftTop(-g,-g);z.connect();if(!ac()){f=m.showLoginForm().buttons[0];f.disable();f.setText(o(K))}delete z.c},loadSound:function(){var f;f=new m.A.FlashObject(ad,"Sound");f.callFunction("loadSound","/static/s1.mp3",false);f.exposeFunction("start");m.notifySound=f},connect:function(){var f;if(!M){m.M.add(o(K));m.M.show();if(!aa){f="XOGame.Client.on";aa=m.A.getSocket(ad,f+"Connect",f+"Data",f+"Close")}aa.connect(n,V);O=setTimeout(U,10000)}},disconnect:function(){if(M){aa.close();z.onClose()}},signon:function(f,E){ab=p(f,E);R(W("signon",ab))},getNet:function(f){R(W(e,f))},newGame:function(E,T,f,X){R(W(l,p(E,T,f,X)))},removeGame:function(f){R(W("rem",f))},refuseGame:function(f){R(W(h,f))},makeMove:function(f,X,E){var T;T=[f,X];if(E){T.push(E)}R(W("mm",p.apply(window,T)))},getGamesList:function(f,E){R(W(a,p(f,E)))},stopPublic:function(){R("pub")},getPlayersList:function(f,E){R(W(c,E))},getPlayerInfo:function(f){R(W("p",f))},chat:function(E,f){R(W(i,f,E))}};m.Client=z;m.T.onset=function(){x.getBody().createChild({id:d}).insertHtml("beforeEnd",ad.getHTML(1,1,"#3D71B8","XOGame.Client.c"))}}());