fe.page={id:"game",onLoad:function(){if(this.activity){geewa.lite.params.activityID=this.activity.activityID;if(this.activity.type==2){geewa.lite.params.challengeRoomID="facebook:"+this.activity.activityID}}if(this.game.id=="duel"||this.game.id=="duel2"||this.game.id=="ghost"){geewa.lite.params.emotion="#cpt:{gc.messenger.currentPageTexts.inGame,{gc.games."+this.data.gameID+".info.name}}"}else{geewa.lite.params.emotion="#cpt:{gc.messenger.currentPageTexts.inGame,"+fe.utfText(this.data.name)+"}"}if(!this.gameBackground&&fe.mode==fe.MODE_WEB){this.gameBackground="url(/img/bg/geewa-blue.png) repeat"}var D=["live","casino","download","girls","kids"];var A;for(var C=0;C<this.data.tags.length;C++){for(var B=0;B<D.length;B++){if(this.data.tags[C]==D[B]){A=D[B]}}if(A){break}}if(A&&fe.pt){fe.pt._setCustomVar(5,"section",A,3)}},onUserServerReady:function(){if(this.page=="friends"){this.friends.show()}else{if(!this.page){this.page="home"}}this.share.init();if(this.competitions&&this.competitions.length>0){if(this.activity.type==1||this.activity.type==3){this.league.data=fe.getFirstFromArray(this.competitions,"type","ghostLeague")}else{if(this.activity.type==2){this.league.data=fe.getFirstFromArray(this.competitions,"type","duelLeague")}}}fe.fixPageHeight()},onLikeButton:function(){geewa.server.user.call("Game.InsertToLikes",this.data.gameID);if(fe.pt){fe.pt._trackEvent("facebook","like",this.data.gameID)}},onFacebookSession:function(){var A=fe.getIDs("likeGame");if(A[0]){A[0].innerHTML='<fb:like href="'+fe.gameUrl(this.data.gameID)+'" layout="standard" show_faces="false" width="380" action="like" colorscheme="light" on-create="fe.page.onLikeButton();"></fb:like>';FB.XFBML.parse(A[0])}},onEventServer:function(E,B){if(E.events){for(var G=0;G<E.events.length;G++){var A=E.events[G];switch(A.type){case 95:if(A.data.roomID==geewa.lite.params.challengeRoomID){this.challenge.onCount(A.data.activeChallenges)}break;case 96:if(A.data.roomID==geewa.lite.params.challengeRoomID){for(var F=A.data.messages.length-1;F>-1;F--){var D=A.data.messages[F];if(D.messageID>this.challenge._lastMessageID){switch(D.type){case 1:switch(D.data.type){case"createChallenge":case"acceptChallenge":case"removeChallenge":this.challenge.onMessage(D);break}break}this.challenge._lastMessageID=D.messageID}}}break;case 100:if(A.data.activityID==this.activity.activityID&&A.data.groupID==global.competitionGroupID){var C=[fe.tryValue(A,"data.league.scores.daily.value"),fe.tryValue(A,"data.league.scores.overall.value")];if(C[1]){var H=fe.tryValue(A,"data.league.scores.overall.dataID");var I="fe.page.publish.score({score:"+C[1]+(H?",dataID:'"+H+"'":"")+",type:4,from:'menu'});";this.share.addLink({id:"overallHighscore",title:l.gl("livegames.share.alltimeHighscoreText")+" "+fe.numFormat(C[1]),onclick:"fe.page.share.close();"+I})}if(C[0]&&C[0]<C[1]){var H=fe.tryValue(A,"data.league.scores.daily.dataID");var I="fe.page.publish.score({score:"+C[0]+(H?",dataID:'"+H+"'":"")+",type:1,from:'menu'});";this.share.addLink({id:"dailyHighscore",title:l.gl("livegames.share.dailyHighscoreText")+" "+fe.numFormat(C[0]),onclick:"fe.page.share.close();"+I})}this.league.data.myProfile=A.data;if(this.page!="game"&&this.page=="league"){this.league.show()}}break;case 102:if(this.league){this.league.data.myProfile=A.data;if(this.page!="game"){if(this.page=="friends"){this.friends.show()}else{if(this.page=="league"){this.league.show()}}}}if(A.data.activityID==this.activity.activityID&&A.data.groupID==global.competitionGroupID){this.matchResult.data=A.data;if(this.page!="game"&&global.theme=="lg"){this.matchResult.show()}}break}}}if(this.game.call){if(!B.body&&B.json){B.body=geewa.encodeJSON(B.json)}this.game.call("handleServerEvents",B.body)}},onHashChange:function(B){geewa.debug.log("ajax","fe.page.game.onHashChange");if(fe.mode==fe.MODE_FACEBOOK_APP&&!this.initGameSize()){return}if(this.page=="game"&&B.p!="game"){this.closeGame(true)}if(B.invite){this.game.start({type:"external",mode:"join",lobbyID:B.invite})}else{if(B.p){if(B.p=="game"&&this.page!="game"&&this.activity&&(this.activity.type==1||this.activity.type==2)){while(true){if(session.user.type!=fe.USER_TYPE_PRO&&this.data.premiumUntil&&(new Date()).valueOf()<this.data.premiumUntil){var A=this;fe.showProRequired({onClose:function(){location.href="#p="+A.page}});break}if(B.m=="invite"){this.game.start({type:"external",mode:"invite"});break}if(B.m=="shoutout"){this.game.start({type:"external",mode:"shoutout"});break}if(B.m=="league"){if(session.user.type<fe.USER_TYPE_USER){var A=this;fe.showRegistrationRequired({onClose:function(){location.href="#p="+A.page}});break}if(fe.tryValue(this,"league.data.myProfile.league.left")===0){var A=this;fe.page.showMatchesLimit({onClose:function(){location.href="#p="+A.page}});break}if(B.duel){this.game.start({ghostDataID:B.duel})}else{this.game.start({type:"league"})}break}this.game.start();break}}else{if(this.game.id=="ganymede"&&(B.p=="game"||B.p=="results")&&session.user.type<fe.USER_TYPE_USER){var C=this.page;fe.showRegistrationRequired({onClose:function(){location.href="#p="+C}})}else{if(B.p!=this.page||(B.m&&B.p==this.page&&B.m!=this.pageMode)){if(B.m){this.showPage(B.p,B.m)}else{this.showPage(B.p)}}}}}}},getRoom:function(){if(this.activity&&(this.activity.type==1||this.activity.type==2)){return{id:"hry:"+this.data.gameID}}var C=["casino","action","puzzle","simulation","shooting","sport","arcade","czech"];for(var B=0;B<this.data.tags.length;B++){for(var A=0;A<C.length;A++){if(this.data.tags[B]==C[A]){return{id:"hry:tag:"+C[A]}}}}return null},onResize:function(){if(document.getElementById("__geewa_ad")){this.onResizeAd()}else{if(this.game._onResize){this.game._onResize()}}},onResizeAd:function(){var D=fe.getIDs("page","__geewa_ad","messenger","__geewa_ad_main");if(!(D[0]&&D[1])){return}var C=D[3].offsetWidth;var A=D[3].offsetHeight;var B=(typeof(window.innerWidth)=="undefined"?document.documentElement.clientWidth:window.innerWidth)-(D[2]?D[2].offsetWidth:0);var E=(fe.mode==fe.MODE_FACEBOOK_APP?767:(typeof(window.innerHeight)=="undefined"?document.documentElement.clientHeight:window.innerHeight));D[1].style.width=C+"px";D[1].style.height=A+"px";D[0].style.top=parseInt((E-A)/2,10)+"px";D[0].style.left=parseInt((B-C)/2,10)+"px";D[0].style.width=(parseInt(C)+10)+"px";if(D[0].style.visibility=="hidden"){D[0].style.visibility="visible"}},showPage:function(A){if(A!="game"&&A!="buy"){var B=fe.getIDs(this.page+"Body",this.page+"Tab",A+"Body",A+"Tab");if(B[0]){B[0].style.display="none";if(B[1]){fe.removeStyle(B[1],"active")}}if(B[2]){B[2].style.display="block";if(B[3]){fe.addStyle(B[3],"active")}}fe.fixPageHeight()}if(fe.page.challenge){fe.page.challenge.setListeners(A=="challenge"?2:1)}switch(A){case"game":if(this.game){if(arguments.length>1&&arguments[1]=="league"){this.game.start({type:"league"})}else{this.game.start()}}break;case"friends":this.friends.show();break;case"challenge":this.challenge.show();break;case"league":if(session.user.type===fe.USER_TYPE_GUEST||fe.tryValue(this,"league.data.myProfile")){this.league.show()}break;case"comments":this.comments.show();break;case"stats":this.stats.show();break;case"shop":this.shop.show();break;case"buy":if(this.game){this.game.buy()}break;case"bonus":this.bonus.show();case"results":if(arguments.length>1){this.game.results(arguments[1])}else{this.game.results()}break;case"rules":this.game.showRules();break;case"gameplay":this.game.showGameplay();break}if(A=="game"&&this.game.id=="window"){location.href="#p="+this.page}else{if(fe.refreshAds){fe.refreshAds(A=="home")}this.page=A;if(arguments.length>1){this.pageMode=arguments[1]}}},inviteFriends:function(){var C="http://"+global.domain+"/"+fe.page.data.gameID+(fe.mode===fe.MODE_FACEBOOK_APP?"?fb_sig_in_iframe=1&fb_sig_added=1":"");var E=global.facebookAppUrl+this.data.gameID+"?from=inviteFriends";while(true){if(this.activity.type==2){var D=l.replaceTokens(l.gl("livegames.share.inviteFriends.live"),'<a href="'+E+'">'+this.data.name+"</a>");break}if(this.activity.type==1||this.activity.type==3){var B=fe.tryValue(this.league,"data.myProfile.league.scores.overall.value");if(B){var D=l.replaceTokens(l.gl("livegames.share.inviteFriends.highscore"),fe.numFormat(B),'<a href="'+E+'">'+this.data.name+"</a>");break}}var D=l.replaceTokens(l.gl("livegames.share.inviteFriends.highscore"),'<a href="'+E+'">'+this.data.name+"</a>");break}D+='<fb:req-choice url="'+E+'" label="'+l.gl("livegames.share.inviteFriends.actionButton")+'" />';D=D.replace(/"/g,"&quot;");var G=[];G.push('<div id="fbmlContent" style="width:620px;">');G.push("<fb:serverfbml>");G.push('<script type="text/fbml">');G.push('<fb:fbml style="width:600px;">');G.push('<fb:request-form action="'+C+'"');G.push(' method="POST"');G.push(' invite="true"');G.push(' type="Live Games"');G.push(' content="'+D+'">');G.push('<fb:multi-friend-selector showborder="false" actiontext="'+l.replaceTokens(l.gl("livegames.share.inviteFriends.actionText"),this.data.name)+'" cols="4" rows="3" bypass="cancel" email_invite="false" exclude_ids=""></fb:multi-friend-selector>');G.push("</fb:request-form>");G.push("</fb:fbml>");G.push("<\/script>");G.push("</fb:serverfbml>");G.push("</div>");var F={};F.title=l.gl("livegames.share.inviteFriends.title");F.body=G.join("");fe.popup.show(F);FB.XFBML.parse(document.getElementById("fbmlContent"));var A=this;setTimeout(A._changeFBML,2000)},_changeFBML:function(){try{var A=document.getElementById("fbmlContent").getElementsByTagName("iframe");if(A.length>0){A[0].style.width="620px"}}catch(A){}},sendToChat:function(A){if(global.competitionGroupID=="2hry"||global.theme=="c"){var E=[];E.push('<div style="width:550px;">');E.push("1. "+l.gl("game.friends.invitationStep1")+":");var B="http://"+global.domain+"/"+fe.page.data.gameID+"#invite="+A+"&from=invite";E.push('<br/><input id="invitatitonUrl" type="text" value="'+B+'" onclick="this.select();" style="width: 540px;"/>');if(typeof(clipboardData)!="undefined"&&clipboardData.setData){E.push(' <input id="embed-button" type="button" value="Copy" onclick="clipboardData.setData(\'Text\',\''+B+"');\"/>")}E.push('<div style="margin-top: 15px;">2. '+l.gl("game.friends.invitationStep2")+"</div>");E.push('<div style="margin-top: 15px;">3. '+l.gl("game.friends.invitationStep3")+"</div>");E.push("</div>");var D={};D.title=l.gl("game.friends.invitationTitle");D.body=E.join("");var C=this.page;D.onClose=function(){fe.page.game.show()};fe.popup.show(D);document.getElementById("invitatitonUrl").select()}else{var E=[];E.push('<div style="width:550px;">');E.push("1. "+l.gl("game.friends.invitationStep1")+":");var B=global.facebookAppUrl+fe.page.data.gameID+"?invite="+A+"&from=fb-invite";E.push('<br/><input id="invitatitonUrl" type="text" value="'+B+'" onclick="this.select();" style="width: 540px;"/>');if(typeof(clipboardData)!="undefined"&&clipboardData.setData){E.push(' <input id="embed-button" type="button" value="Copy" onclick="clipboardData.setData(\'Text\',\''+B+"');\"/>")}E.push('<div style="margin-top: 15px;">2. '+l.gl("game.friends.invitationStep2")+":</div>");E.push('<div style="width:550px;height:320px;margin:15px 0;">');E.push('<div id="chatWindowLoading"><img src="/img/loader.gif" alt="Loading" style="vertical-align: middle;" /> '+l.gl("livegames.loadingFBChat")+"</div>");E.push('<div id="chatWindow" style="display:none;"><iframe src="http://www.facebook.com/presence/popout.php" frameborder="0" align="left" marginwidth="0" marginheight="0" scrolling="no" style="width: 550px; height: 320px; border: 1px solid #BDC7D8;" onload="fe.page.onLoadChat();"></iframe></div>');E.push("</div>");E.push(l.gl("game.friends.invitationStep3"));E.push("</div>");var D={};D.title=l.gl("game.friends.invitationTitle");D.body=E.join("");D.onClose=function(){fe.page.game.show()};fe.popup.show(D);document.getElementById("invitatitonUrl").select()}},shoutOut:function(A){var C=[];C.push('<div style="width:580px;">');C.push('<img src="/img/share/invite.png" style="float: left; margin-right: 30px;" />');C.push(l.gl("game.popup.shoutOutBody"));C.push('<div class="break"></div></div>');var B={};B.title=l.gl("game.popup.shoutOutTitle");B.body=C.join("");B.onClose=function(){fe.page.game.show()};B.buttons='<input type="button" value="'+l.gl("game.friends.next")+'" onclick="fe.popup.close(true);fe.page.publish.invitation(\''+A+'\');"/><input type="button" value="'+l.gl("game.close")+'" onclick="fe.popup.close();" class="inputaux"/>';fe.popup.show(B)},onLoadChat:function(){var A=fe.getIDs("chatWindow","chatWindowLoading");if(A[0]&&A[1]){A[0].style.display="block";A[1].style.display="none"}},initGameSize:function(){if((this.data.profile.type=="frame")||(this.data.profile.width>738&&this.data.profile.resize=="none")){var D=[];D.push('<div style="width:430px; text-align: center;">');D.push("You can play <strong>"+this.data.name+"</strong> only in fullscreen mode!");var A="http://"+global.domain+"/"+(l.rewrite[this.data.gameID]?l.rewrite[this.data.gameID]:this.data.gameID)+"#p=game";D.push('<br/><a href="'+A+'" target="_top">Continue in fulscreen</a>');D.push('<br/><a href="javascript:void(0);" onclick="fe.popup.close();">Return back</a>');var C={};C.title="Fullscreen game";C.body=D.join("");C.onClose=function(){location.href="#p=home"};fe.popup.show(C);return false}if(!this._sizeInitialized){if(this.data.profile.width>738&&(this.data.profile.resize=="ratio"||this.data.profile.resize=="full")){this.data.profile.height=738*this.data.profile.height/this.data.profile.width;this.data.profile.width=738;this.data.profile.resize="none"}this.frameHeight=767;var B=parseInt(this.data.profile.height,10)+124;if(B>this.frameHeight){this.frameHeight=B}this._sizeInitialized=true}return true},startGame:function(){this.onPlay(false);fe.bubble.close();var B=fe.getIDs("main","mainPage","mainGame");this.gamePage=arguments[0];this.backPage=fe.page.page;if(fe.mode===fe.MODE_WEB){B[0].style.overflowY="hidden";if(session.messengerWidth===0){document.body.style.overflow="hidden"}if(this.gameBackground){document.body.style.background=this.gameBackground}}B[1].style.display="none";B[2].style.display="block";if(geewa.server.event&&this.game.id!="duel2"){geewa.server.event.setState(2)}this.page="game";if(global.adPositions&&global.adPositions.indexOf("0")>-1&&typeof(geewa.Ad)!="undefined"&&this.data.advertisement&&this.data.advertisement.preRoll=="none"&&session.user.type!=fe.USER_TYPE_PRO){var C=[];C.push('<div id="page" class="start-game x-shadows y-shadows" style="visibility:hidden;">');C.push('<div id="pageHeader" class="header"><div class="header-l"><div class="header-r"></div></div><hr class="hidden" /></div>');C.push('<div class="content"><div class="content-r">');C.push('<div id="__geewa_ad"></div>');C.push('</div><hr class="hidden" /></div>');C.push('<div id="pageFooter" class="footer"><div class="footer-l"><div class="footer-r"></div></div></div>');C.push("</div>");B[2].innerHTML=C.join("");geewa.ad=geewa.Ad.create();C=[];C.push('<div style="text-align: center; line-height: 25px; margin: 5px 0 10px 0;">');C.push('<span class="pro">&nbsp;</span> <a href="/help/professional-account" target="_blank" style="color:#000;" onclick="try{fe.pt._trackEvent(\'click\',\'no-ads\',\'preroll\'}catch(e){}">'+l.gl("game.noAds")+'</a> <span class="pro">&nbsp;</span>');C.push("</div>");geewa.ad.bottomHTML=C.join("");geewa.ad.language=l.id;var A=this;geewa.ad.onFinish=function(){A.onPreRollFinish.apply(A,arguments)};geewa.ad.insert("/t/"+global.theme+"/ad/"+l.id+"/preGame.aspx?gameID="+this.data.gameID,"__geewa_ad",function(){A.onResizeAd.apply(A,arguments)});if(fe.pt){fe.pt._trackEvent("ad","preroll")}}else{this.onPreRollFinish()}var A=this;if(fe.mode==fe.MODE_FACEBOOK_APP){fe.setFrameHeight(A.frameHeight);this.onResize()}else{window.onresize=function(){A.onResize.apply(A,arguments)}}},onPreRollFinish:function(){var B=fe.getIDs("mainGame","__geewa_ad");B[0].innerHTML=this.gamePage;if(global.adPositions&&global.adPositions.indexOf("4")>-1&&this.activity&&(this.activity.type==1||this.activity.type==2||this.activity.type==3||(!this.activity.type&&fe.tryValue(this.data,"profile.type")!="ganymede"))){this.ad.setBackground()}this.ad.start();delete this.gamePage;geewa.server.user.call("User.SetState",4,null);if(fe.pt){if(this.game.id=="duel"||this.game.id=="duel2"){fe.pt._trackEvent("game",this.data.gameID,this.game.data.type+(this.game.data.mode?"-"+this.game.data.mode:""))}else{fe.pt._trackEvent("game",this.data.gameID)}}if(typeof(pp_gemius_identifier)!="undefined"){try{geewa.stats.imageHit(pp_gemius_host+(new Date()).getTime()+"/rexdot.gif?l=30&id="+pp_gemius_identifier+gemius_parameters())}catch(B){}}if(typeof(gemiusStream)!="undefined"){try{gemiusStream.newStream("game",this.data.gameID,-1,[{name:"NAZEV",value:this.data.name},{name:"TYP",value:"Hra"},{name:"CIL",value:global.domain},{name:"KATEGORIE",value:"081"}],null,"pzCQ0nNSN3GI2DJFxVD2_sTWDorBFFsVM34b7EBrMlb.E7","http://scz.hit.gemius.pl");this.startTime=new Date().valueOf();gemiusStream.event("game",this.data.gameID,0,"playing")}catch(B){}}var A=this;window.setTimeout(function(){A.onResize.apply(A,arguments)},0)},closeGame:function(){geewa.server.user.call("User.SetState",3,null);if(typeof(pp_gemius_identifier)!="undefined"){try{geewa.stats.imageHit(pp_gemius_host+(new Date()).getTime()+"/rexdot.gif?l=30&id="+pp_gemius_identifier+gemius_parameters())}catch(C){}}if(typeof(gemiusStream)!="undefined"){try{var B=parseInt((new Date().valueOf()-this.startTime)/1000,10);gemiusStream.event("game",this.data.gameID,B,"complete");gemiusStream.closeStream("game",this.data.gameID,B)}catch(C){}}if(arguments.length==0&&global.adPositions&&global.adPositions.indexOf("1")>-1&&typeof(geewa.Ad)!="undefined"&&this.data.advertisement&&this.data.advertisement.postRoll=="none"&&session.user.type!=fe.USER_TYPE_PRO){var D=[];D.push('<div id="page" class="start-game x-shadows y-shadows" style="visibility:hidden;">');D.push('<div id="pageHeader" class="header"><div class="header-l"><div class="header-r"></div></div><hr class="hidden" /></div>');D.push('<div class="content"><div class="content-r">');D.push('<div id="__geewa_ad"></div>');D.push('</div><hr class="hidden" /></div>');D.push('<div id="pageFooter" class="footer"><div class="footer-l"><div class="footer-r"></div></div></div>');D.push("</div>");var C=fe.getIDs("mainGame");if(fe.mode===fe.MODE_WEB&&this.gameBackground){document.body.style.background=this.gameBackground}C[0].innerHTML=D.join("");geewa.ad=geewa.Ad.create();D=[];D.push('<div style="text-align: center; line-height: 25px; margin: 5px 0 10px 0;">');D.push('<span class="pro">&nbsp;</span> <a href="/help/professional-account" target="_blank" style="color:#000;" onclick="try{fe.pt._trackEvent(\'click\',\'no-ads\',\'postroll\'}catch(e){}">'+l.gl("game.noAds")+'</a> <span class="pro">&nbsp;</span>');D.push("</div>");geewa.ad.bottomHTML=D.join("");geewa.ad.language=l.id+"Post";geewa.ad.skipTime=0;if(global.theme=="h"){geewa.ad.bigSkipText="přeskoč tuto reklamu &raquo;"}geewa.ad.dontClickTime=1000;var A=this;geewa.ad.onFinish=function(){A.onPostRollFinish.apply(A,arguments)};geewa.ad.insert("/t/"+global.theme+"/ad/"+l.id+"/postGame.aspx?gameID="+this.data.gameID,"__geewa_ad",function(){A.onResizeAd.apply(A,arguments)});if(fe.pt){fe.pt._trackEvent("ad","postroll")}}else{this.onPostRollFinish()}},onPostRollFinish:function(){if(fe.mode===fe.MODE_FACEBOOK_APP&&this.game.id=="duel"&&this.game.data&&this.game.data.type=="external"&&this.game.data.mode=="join"){top.location.href=fe.fbGameUrl(this.data.gameID);return}document.location.href="#p="+this.backPage;var A=fe.getIDs("main","mainPage","mainGame");if(fe.mode===fe.MODE_WEB){A[0].style.overflowY="auto";if(session.messengerWidth===0){document.body.style.overflow=""}}document.body.style.background="";A[1].style.display="block";A[2].style.display="none";A[2].innerHTML="";this.page=this.backPage;delete this.backPage;if(fe.mode==fe.MODE_WEB){window.onresize=null}else{fe.setFrameHeight(document.body.offsetHeight)}if(geewa.server.event){geewa.server.event.setState(1)}fe.search.init();if(global.theme=="lg"){this.matchResult.show()}fe.updateUserPanel();switch(this.page){case"friends":this.friends.show();break;case"league":this.league.show();break;case"challenge":if(this.challenge){this.challenge.show()}break}if(fe.refreshAds){fe.refreshAds(this.page=="home")}},onPlay:function(B){var A=fe.getIDs("splash"+this.mode);if(B){fe.addStyle("splash","hover");fe.addStyle("playNow","hover")}else{fe.removeStyle("splash","hover");fe.removeStyle("playNow","hover")}},showMatchesLimit:function(){var B=[];B.push('<div style="width:400px;">'+geewa.stringAppend(l.gl("game.league.matchesLimit"),fe.page.data.name));B.push("</div>");var A=arguments.length>0?arguments[0]:{};A.title=l.gl("game.matchesLimit");A.body=B.join("");A.buttons='<input type="button" value="'+l.gl("game.close")+'" onclick="fe.popup.close();" class="inputaux"/>';fe.popup.show(A)},rateShow:function(A){document.getElementById("ratingMessage").innerHTML=l.gl("game.rating."+A)},rateClear:function(A){document.getElementById("ratingMessage").innerHTML=l.gl("game.rating."+A)},rateSet:function(B){if(session.user.type<fe.USER_TYPE_USER){fe.showRegistrationRequired();return}if(this.data.gameID&&session.user.userID){var A=this;geewa.server.user.call("Game.InsertRating",this.data.gameID,parseInt(arguments[0],10))}},reportServerUrl:"http://report.geewa.ws/action.ashx",actionStats:function(C,A,E,F,B){var D=[];D.push("userID="+session.user.userID);D.push("domain="+C);D.push("gameID="+fe.page.data.gameID);D.push("content="+escape(A+":"+E));D.push("action="+escape(F+"/"+B));geewa.stats.imageHit(this.reportServerUrl+"?"+D.join("&"))},topPanel:{show:function(){if((fe.page.data.gameID=="pool-2"||fe.page.data.gameID=="8-ball-pool")&&!session.topPanel){var A=fe.getIDs("topPanel");if(A[0]&&A[0].style.display!="block"){A[0].style.display="block"}}},close:function(){var A=fe.getIDs("topPanel");if(A[0]){A[0].style.display="none";fe.ls.call("setSession","topPanel|1")}}},comments:{PAGE_SIZE:20,page:0,MAX_CHARS:1024,disabled:false,show:function(){var A=[];A.push('<h5 id="commentLabel"></h5>');A.push('<textarea id="commentText" cols="80" rows="6" onkeypress="return fe.page.comments.onText(event);" onkeyup="fe.page.comments.checkLength(event);" style="width: 100%;"></textarea>');if(global.theme=="h"){A.push('<p class="button25-blue" style="float: right"><a href="/help/faq/'+fe.page.data.gameID+'" target="hryhelp">'+l.gl("comments.faq")+"</a></p>")}A.push('<p class="button25-orange"><a href="javascript:void(0);" onclick="fe.page.comments.send();" id="commentSubmit" >'+l.gl("comments.send")+"</a>");A.push(' <img id="commentSending" src="/img/loader.gif" style="display:none;"/>');A.push(' <span id="commentCharsLeft">'+geewa.stringAppend(l.gl("comments.charsLeft"),this.MAX_CHARS)+"</span></p>");A.push('<div id="commentList" class="comments"></div>');geewa.writeHTML("commentsBody",A.join(""));this.getPage(0)},onText:function(B){var A=(B?B:window.event).charCode;return(!this.disabled||A==0)},checkLength:function(){var A=fe.getIDs("commentText","commentCharsLeft","commentSubmit");if(A[0]&&A[1]&&A[2]){A[1].innerHTML=geewa.stringAppend(l.gl("comments.charsLeft"),this.MAX_CHARS-A[0].value.length);this.disabled=(this.MAX_CHARS-1)<A[0].value.length;A[2].disabled=this.disabled}},getPage:function(B){this.page=B;var A=this;geewa.server.ps.call(function(){A.onPage.apply(A,arguments)},"Game.GetComments",fe.page.data.gameID,l.id,false,0,B,this.PAGE_SIZE)},onPage:function(B,D){var F=fe.getIDs("commentLabel","commentList","commentsCount");if(F[2]){F[2].innerHTML="("+D.result.totalCount+")"}F[0].innerHTML=(D.result.count==0?l.gl("comments.noComments"):l.gl("comments.addYour"));var H=[];if(D.result.count>0){H.push("<h4>"+geewa.stringAppend(l.gl("comments.found"),D.result.totalCount)+"</h4>");var G=D.result.comments;for(var C=0;C<G.length;C++){var A=(C%2==0?"even":"odd");H.push('<div class="comment '+A+'">');var E=G[C].user.identity;E=E.substring(0,E.indexOf(":"));H.push("<div>");H.push(fe.userLink(G[C].user)+" "+fe.getFlag(G[C].user)+': <small class="date">'+fe.timeBefore(G[C].createTime)+(E==global.userGroup?"":" ("+E+")")+"</small>");if(session.user.userID==G[C].user.userID||session.user.type==fe.USER_TYPE_ADMIN||session.user.type==fe.USER_TYPE_SUPERADMIN){H.push('&nbsp;<small><a href="javascript:void(0);" onclick="fe.page.comments.remove('+G[C].commentID+');">'+l.gl("common.delete")+"</a></small>")}H.push("</div>");H.push("<div>"+G[C].text+"</div>");if(global.showAbuseLinks){H.push('<div class="report"><a href="http://'+global.domain+"/help/contact-form?nick="+escape(G[C].user.nick)+"&amp;userID="+G[C].user.userID+'" target="_blank">report abuse</a></div>')}H.push("</div>")}}H.push(this.paging(this.page,Math.ceil(D.result.count/this.PAGE_SIZE),5,"fe.page.comments.getPage"));F[1].innerHTML=H.join("");fe.fixPageHeight()},paging:function(A,D,F,B){var E=[];if(D>1){E.push('<p class="center">\n');if(A>0){E.push('<a href="javascript:void(0);" onclick="'+B+"("+(A-1)+');">&laquo; '+l.gl("gamesList.previous")+"</a> |\n")}for(var C=(A-F<0?0:A-F);C<A;C++){E.push('<a href="javascript:void(0);" onclick="'+B+"("+C+');">'+(C+1)+"</a> |\n")}E.push("<strong>"+(A+1)+"</strong>\n");for(var C=A+1;C<(A+F>D?D:A+F);C++){E.push('| <a href="javascript:void(0);" onclick="'+B+"("+C+');">'+(C+1)+"</a>\n")}if(A<(D-1)){E.push('| <a href="javascript:void(0);" onclick="'+B+"("+(A+1)+');">'+l.gl("gamesList.next")+" &raquo;</a>\n")}E.push("</p>")}return E.join("")},send:function(){if(session.user.type<fe.USER_TYPE_USER){fe.showRegistrationRequired();return}var B=fe.getIDs("commentText","commentSubmit","commentSending");if(B[0].value){var A=this;geewa.server.user.call(function(){A.onSend.apply(A,arguments)},"Game.InsertComment",fe.page.data.gameID,l.id,1,geewa.encodeXML(B[0].value));B[1].style.display="none";B[2].style.display="inline-block"}},onSend:function(A,B){var C=fe.getIDs("commentText","commentSubmit","commentSending");C[1].style.display="inline-block";C[2].style.display="none";if(B.error){fe.popup.show({title:"Chyba",body:"Komentář se nepodařilo z důvodu chyby odeslat:<br/>"+B.error.message})}else{C[0].value="";this.checkLength();this.getPage(0)}},remove:function(B){var A=this;geewa.server.user.call(function(){A.onRemove.apply(A,arguments)},"Game.RemoveComment",fe.page.data.gameID,B)},onRemove:function(){this.getPage(this.page)}},stats:{show:function(){var B=[];B.push("<div>");var A={width:694,height:400,movie:"/amline/amline.swf?data_file="+escape("http://public.geewa.ws/stats.ashx?activityIDs="+fe.page.activity.activityID+"&format=csv&tag=daily")+"&settings_file=/amline/amline_settings.xml"};B.push("<h2>"+l.gl("game.stats.usersDaily")+"</h2>");if(navigator.userAgent.indexOf("MSIE ")>-1){B.push('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+A.width+'" height="'+A.height+'" align="middle">');B.push('<param name="allowScriptAccess" value="sameDomain" />');B.push('<param name="movie" value="'+A.movie+'"/>');B.push('<param name="quality" value="high" />');B.push('<param name="wmode" value="transparent" />');B.push('<param name="bgcolor" value="#ffffff"/>');B.push("</object>")}else{B.push('<embed src="'+A.movie+'" quality="high" wmode="transparent" bgcolor="#ffffff" width="'+A.width+'" height="'+A.height+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />')}B.push("</div>");geewa.writeHTML("statsBody",B.join(""));fe.fixPageHeight()}},share:{init:function(){if(this.links){return}this.links=[];if(global.theme=="h"||global.theme=="c"){var A="http://"+global.domain+"/"+(l.rewrite[fe.page.data.gameID]?l.rewrite[fe.page.data.gameID]:fe.page.data.gameID);var B=fe.page.data.name;this.links.push({id:"game",title:"Facebook",onclick:"fe.page.share.close();fe.page.publish.game();",img:"/img/ico/sharing/facebook.png"});this.links.push({id:"myspace",title:"MySpace",href:geewa.stringAppend("http://www.myspace.com/Modules/PostTo/Pages/?u={0}&t={1}&c={2}&l=2",A,B,escape(fe.page.data.descriptionShort)),img:"/img/ico/sharing/myspace.png"});this.links.push({id:"digg",title:"Digg",href:geewa.stringAppend("http://digg.com/submit?url={0}&title={1}&topic=playable_web_games",A,B),img:"/img/ico/sharing/digg.png"});this.links.push({id:"delicious",title:"Delicious",href:geewa.stringAppend("http://del.icio.us/post?url={0}&title={1}",A,B),img:"/img/ico/sharing/delicious.png"});this.links.push({id:"stumble",title:"StumbleUpon",href:geewa.stringAppend("http://www.stumbleupon.com/submit?url={0}&title={1}",A,B),img:"/img/ico/sharing/stumble.png"});this.links.push({id:"linkuj",title:"Linkuj",href:geewa.stringAppend("http://linkuj.cz/?id=linkuj&url={0}&title={1}",A,B),img:"/img/ico/sharing/linkuj.png"});this.links.push({id:"jagg",title:"Jagg",href:geewa.stringAppend("http://www.jagg.cz/bookmarks.php?action=add&address={0}&title={1}",A,B),img:"/img/ico/sharing/Jagg.png"})}else{this.links.push({id:"game",title:l.gl("livegames.share.link"),onclick:"fe.page.share.close();fe.page.publish.game();",img:"/img/ico/sharing/facebook.png"});this.links.push({id:"embed",title:l.replaceTokens(l.gl("game.embedGame"),fe.page.data.name),onclick:"fe.page.showEmbed();"})}},click:function(){if(fe.page.activity&&fe.page.activity.type){return}fe.page.publish.game()},mouseover:function(){try{if(l.id!="cs"&&(!fe.page.activity||!fe.page.activity.type)){return}this.show()}catch(A){}},mouseout:function(){try{if(l.id!="cs"&&(!fe.page.activity||!fe.page.activity.type)){return}var D=document.getElementById("shareList");if(window.event){var C=window.event.toElement;if(C==D||C==D.firstChild){return}for(var B=0;B<D.firstChild.childNodes.length;B++){if(D.firstChild.childNodes[B]==C){return}}}this.close()}catch(A){}},show:function(){if(!this.links){return}var A=fe.getIDs("shareButton","shareList");if(A[0].className.indexOf("hover")==-1){A[1].innerHTML=this.getMenuHTML();fe.addStyle("shareButton","hover")}},close:function(){fe.removeStyle("shareButton","hover")},getMenuHTML:function(){var B=[];B.push('<ul class="reset">');for(var A=0;A<this.links.length;A++){B.push("<li>");if(this.links[A].img){B.push('<img src="'+this.links[A].img+'" alt="'+this.links[A].title+'" />&nbsp;')}B.push('<a href="'+(this.links[A].href?this.links[A].href:"javascript:void(0);")+'"');B.push(' onclick="'+(this.links[A].onclick?this.links[A].onclick:"")+";try{fe.pt._trackEvent('share','"+this.links[A].id+"','"+fe.page.data.gameID+"')}catch(e){};\">"+this.links[A].title+"</a>");B.push("</li>")}B.push("</ul>");return B.join("")},addLink:function(A){fe.removeFirstFromArray(this.links,"id",A.id);this.links.unshift(A)}},bonus:{show:function(){var A=[];A.push('<p style="line-height: 1.5;">Congratulations to all those players who made the <strong>Top 10</strong> last week! You have received your special award - <strong>7 days</strong><span class="pro">&nbsp;</span> <strong>membership</strong> - today. Extra special mention goes to the winner of the league, <strong> Mario</strong>, who is the very lucky recipient of one whole <strong>month of</strong><span class="pro">&nbsp;</span> <strong>membership!</strong> A full table with last week\'s league positions can be found on league tab - section "Previous".<br /><br />To find out exactly what being a<span class="pro">&nbsp;</span> on Live Games means, please visit <a href="'+fe.getTopUrl()+'pages/professional-account" target="_top">About Professional Accounts</a> section.</p>');geewa.writeHTML("bonusBody",A.join(""))}},publish:{init:function(){if(this.splashUrl){return}if(fe.page.data.languageResources.join(" ").indexOf("splash")!=-1){this.splashUrl=global.gamesServer+fe.page.data.gameID+"/res/"+fe.page.data.language+"/splash58.png"}else{if(fe.page.data.resources.join(" ").indexOf("splash")!=-1){this.splashUrl=global.gamesServer+fe.page.data.gameID+"/res/splash58.png"}else{this.splashUrl="http://www.geewa.com/img/default-game-splashscreen.jpg"}}this.gameUrl=global.facebookAppUrl+fe.page.data.gameID;this.imgShareUrl="http://livegames.geewa.com/img/share/"},invitation:function(B){this.init();var A=this;var E=l.gl("livegames.share.invitation.sTitle1");var C=this.addStats(this.gameUrl+"?invite="+B+"&from=shoutout","invitation");var D={method:"stream.publish",attachment:{name:l.replaceTokens(l.gl("livegames.share.invitation.sName1"),fe.page.data.name),href:C,description:l.replaceTokens(l.gl("livegames.share.invitation.sDesc1"),session.user.nick,fe.page.data.name),media:[{type:"image",src:A.imgShareUrl+"invite.png",href:C}]},action_links:[{text:l.gl("game.friends.acceptChallenge"),href:C}],user_message_prompt:E};if(global.shareInPopup){D.display="popup"}FB.ui(D,function(){A.onResponse.apply(A,arguments)})},lastWin:function(B){this.init();var J=this;var F="latestWin";var G=["winner.png","winner.png","winner.png","champ.png","champ.png","champ.png"];var A=this.getText(F,G.length,B.textIndex);var E=A.index;var H=l.replaceTokens(A.title,fe.page.data.name);var C=this.addStats(this.gameUrl,F);var D=G[E];if(fe.page.data.gameID=="8-ball-pool"){D=J.imgShareUrl+"winnerPool.png"}else{if(D){D=J.imgShareUrl+D}else{D=J.splashUrl}}var I={method:"stream.publish",attachment:{name:l.replaceTokens(A.name,session.user.nick,fe.page.data.name),href:C,description:l.replaceTokens(A.description,session.user.nick,fe.page.data.name,B.opponent,fe.page.data.descriptionShort),media:[{type:"image",src:D,href:C}]},action_links:[{text:l.replaceTokens(l.gl("game.friends.ptwPlay"),fe.page.data.name),href:C}],user_message_prompt:H};if(global.shareInPopup){I.display="popup"}FB.ui(I,function(){var K=Array.prototype.slice.call(arguments);K.push({type:F,i:E,state:B});J.onResponse.apply(J,K)})},score:function(state){var i;var title;var name;var description;var image;var type;var friendsID=null;if(state.type){if(state.beatenFriend){var bFriend=eval("("+state.beatenFriend+")");type="beatenFriends";var images=["highscore.png","highscore.png","highscore.png","highscore2.png","highscore2.png"];var r=this.getText(type,images.length,state.textIndex);i=r.index;title=l.replaceTokens(r.title,{friendGender:(bFriend.gender==2?"f":"m")},fe.page.data.name);name=r.name;description=l.replaceTokens(r.description,{friendGender:(bFriend.gender==2?"f":"m")},session.user.nick,bFriend.nick,fe.page.data.name);image=images[i];friendsID=bFriend.identity.replace("geewa:fb-","")}else{if(state.type==4){type="alltimeHighscore";var images=["highscore.png","highscore.png","highscore2.png","highscore2.png","highscore3.png"];var r=this.getText(type,images.length,state.textIndex);i=r.index;title=l.replaceTokens(r.title,fe.page.data.name);name=l.replaceTokens(r.name,session.user.nick,fe.page.data.name);description=l.replaceTokens(r.description,session.user.nick,fe.numFormat(state.score),fe.page.data.name);image=images[i]}else{type="dailyHighscore";var images=["unstoppable.png","yippee.png","yippee.png","yippee.png","yippee.png","yippee.png"];var r=this.getText(type,images.length,state.textIndex);i=r.index;title=l.replaceTokens(r.title,fe.page.data.name);name=l.replaceTokens(r.name,session.user.nick,fe.page.data.name);description=l.replaceTokens(r.description,fe.page.data.descriptionShort,session.user.nick);image=images[i]}}this.init();var instance=this;var title=title;var url=instance.gameUrl;if(state.dataID){url+="?duel="+state.dataID}if(image){image=instance.imgShareUrl+image}else{image=instance.splashUrl}url=this.addStats(url,type);var post={method:"stream.publish",attachment:{name:name,href:url,description:description,media:[{type:"image",src:image,href:url}]},action_links:[{text:l.gl("game.friends.beatThis"),href:url}],user_message_prompt:title,target_id:friendsID};if(global.shareInPopup){post.display="popup"}FB.ui(post,function(){var args=Array.prototype.slice.call(arguments);args.push({type:type,i:i,state:state});instance.onResponse.apply(instance,args)})}},game:function(){this.init();var A=this;var B={method:"stream.publish",attachment:{name:fe.page.data.name,href:A.gameUrl,description:fe.page.data.descriptionShort,media:[{type:"image",src:A.splashUrl,href:this.addStats(A.gameUrl,"game")}]},action_links:[{text:l.replaceTokens(l.gl("game.friends.ptwPlay"),fe.page.data.name),href:A.gameUrl}],user_message_prompt:l.replaceTokens(l.gl("game.friends.ptwDefaultTitle"),fe.page.data.name)};if(global.shareInPopup){B.display="popup"}FB.ui(B,function(){A.onResponse.apply(A,arguments)})},firstLeagueMatch:function(C){var F="enteringLeague";var G=["league.png"];var A=this.getText(F,G.length,C.textIndex);var E=A.index;this.init();var J=this;var H=l.replaceTokens(A.title,fe.page.data.name);var D=G[E];var B=this.addStats(J.gameUrl,F);if(D){D=J.imgShareUrl+D}else{D=J.splashUrl}var I={method:"stream.publish",attachment:{name:l.replaceTokens(A.name,session.user.nick,fe.page.data.name),href:B,description:l.replaceTokens(A.description,fe.page.data.name,fe.page.data.descriptionShort),media:[{type:"image",src:D,href:B}]},action_links:[{text:l.replaceTokens(l.gl("game.friends.ptwPlay"),fe.page.data.name),href:B}],user_message_prompt:H};if(global.shareInPopup){I.display="popup"}FB.ui(I,function(){var K=Array.prototype.slice.call(arguments);K.push({type:F,i:E,state:C});J.onResponse.apply(J,K)})},leaguePosition:function(C){this.init();var L=this;var F;var I;var D;var K;var E;var H;if(C.position==1){H="beingFirstInLeague";var G=["league1.png","league1.png"];var A=this.getText(H,G.length,C.textIndex);F=A.index;I=A.title;D=l.replaceTokens(A.name,session.user.nick,fe.page.data.name);K=l.replaceTokens(A.description,session.user.nick,C.points);E=G[F]}else{if(C.position==2){H="beingSecondInLeague";var G=["league2.png","league2.png"];var A=this.getText(H,G.length,C.textIndex);F=A.index;I=A.title;D=l.replaceTokens(A.name,session.user.nick);K=l.replaceTokens(A.description,session.user.nick,fe.page.data.name,fe.page.data.descriptionShort);E=G[F]}else{if(C.position==3){H="beingThirdInLeague";var G=["leagueTop10.png","leagueTop10.png","leagueTop10.png","leagueTop10.png","leagueTop10.png","leagueTop10.png"];var A=this.getText(H,G.length,C.textIndex);F=A.index;I=A.title;D=l.replaceTokens(A.name,session.user.nick,fe.page.data.name);K=l.replaceTokens(A.description,session.user.nick,fe.page.data.name,fe.page.data.descriptionShort);E=G[F]}else{if(C.position>=4&&C.position<=10){H="beingFourthToTenthInLeague";var G=["leagueTop10.png","leagueTop10.png","leagueTop10.png","leagueTop10.png","leagueTop10.png","leagueTop10.png"];var A=this.getText(H,G.length,C.textIndex);F=A.index;I=A.title;D=l.replaceTokens(A.name,fe.page.data.name,session.user.nick,C.position);K=l.replaceTokens(A.description,session.user.nick,fe.page.data.name,fe.page.data.descriptionShort);E=G[F]}else{H="moveXPositionsInLeague";var G=["congrats.png","congrats.png","league.png","league.png"];var A=this.getText(H,G.length,C.textIndex);F=A.index;I=A.title;D=l.replaceTokens(A.name,session.user.nick,C.positionsMoved,fe.page.data.name);K=l.replaceTokens(A.description,session.user.nick,C.positionsMoved,fe.page.data.name);E=G[F]}}}}var B=this.addStats(L.gameUrl,H);if(E){E=L.imgShareUrl+E}else{E=L.splashUrl}var J={method:"stream.publish",attachment:{name:D,href:B,description:K,media:[{type:"image",src:E,href:B}]},action_links:[{text:l.replaceTokens(l.gl("game.friends.ptwPlay"),fe.page.data.name),href:B}],user_message_prompt:I};if(global.shareInPopup){J.display="popup"}FB.ui(J,function(){var M=Array.prototype.slice.call(arguments);M.push({type:H,i:F,state:C});L.onResponse.apply(L,M)})},trophy:function(C){if(C=="debug"){C={trophy:{name:"Loose Cannon",trophyID:"looseCannon",description:"potopen\u00ed koule jinou vlastn\u00ed koul\u00ed",profile:{imageURL:"http://gc001.geewa.com/games3/pool-2/res/trophies/default_{medal}.png",medalRanges:[1,10,25]},priority:23,imageUrl:"deprecated"},eventType:"shareTrophy",count:3}}this.init();var K=this;var G;for(var E=0;E<C.trophy.profile.medalRanges.length;E++){if(C.count>=C.trophy.profile.medalRanges[E]){G=E}}var F;switch(G){case 1:F="silver";break;case 2:F="gold";break;default:F="bronze";break}var H=l.replaceTokens("trophy.{0}.{1}.{2}",fe.page.data.gameID,C.trophy.trophyID,F);var I=C.trophy.profile.imageURL.replace(/\{medal\}/g,G)+"?cacheKey="+fe.page.data.profile.custom.cacheKey;var D=0;if(G<C.trophy.profile.medalRanges.length-1){D=C.trophy.profile.medalRanges[G+1]-C.count}var A=this.getText(l.replaceTokens("trophy.{0}.{1}",fe.page.data.gameID,F),1);E=A.index;this.init();var K=this;var B=this.addStats(K.gameUrl,H);var J={method:"stream.publish",attachment:{name:l.replaceTokens(A.name,session.user.nick,C.trophy.name),href:B,description:l.replaceTokens(A.description,session.user.nick,C.trophy.name,C.trophy.description,D),media:[{type:"image",src:I,href:B}]},action_links:[{text:l.replaceTokens(l.gl("game.friends.ptwPlay"),fe.page.data.name),href:B}],user_message_prompt:A.title};if(global.shareInPopup){J.display="popup"}FB.ui(J,function(){var L=Array.prototype.slice.call(arguments);L.push({type:H,i:0,from:"game"});K.onResponse.apply(K,L)})},onResponse:function(){var B=fe.getIDs("mainGame");if(B[0].style.display=="block"&&fe.page.game.show){fe.page.game.show()}if(arguments[0]&&arguments[0]!="null"){var A=arguments[1];if(A){var C;if(A.state&&A.state.from){C=A.state.from}else{C="unknown"}fe.page.actionStats(global.domain,A.type,(A.i+1),C,"publish")}}},getText:function(C,D){var B=(typeof(arguments[2])!="undefined"?arguments[2]:(D>1?Math.round(Math.random()*(D-1)):0));var A={index:B,title:l.gl("livegames.share."+C+".sTitle"+(B+1)),name:l.gl("livegames.share."+C+".sName"+(B+1)),description:l.gl("livegames.share."+C+".sDesc"+(B+1))};return A},addStats:function(A,B){A+=(A.indexOf("?")>-1?"&":"?");A+="utm_source=facebook&utm_medium=stream&utm_content="+B+"&utm_campaign="+fe.page.data.gameID;return A}},matchResult:{imgShareUrl:"/img/share/",show:function(){if(!this.data||fe.page.page=="game"){return}var A=this.data;if(A.type.indexOf("ghost")>-1){if(A.highScore){this.highscore()}}else{if(A.type.indexOf("duel")>-1){while(true){if(A.type.indexOf("league")>-1){if(A.league.total==1){this.firstLeagueMatch();break}if(A.league.total>5){var B=[fe.tryValue(A,"league_previous.points.position"),fe.tryValue(A,"league.points.position")];if(B[1]<B[0]){this.leaguePosition();break}}}if(A.match.result==2){this.lastWin();break}break}}}delete this.data},highscore:function(){if(arguments[0]=="debug"){this.data={activityID:"wild-west",groupID:"livegames",userID:"1101@8589951306",type:"ghost|league|friend",league_previous:{scores:{overall:{position:7,time:1261398060000,value:38755,duelID:"386"}}},league:{createTime:1260880380000,accessTime:1266399660000,matchCounts:{daily:1,weekly:1,monthly:1,overall:4},scores:{daily:{position:1,time:1266399848767,value:38840,duelID:"5255",dataID:"800@261993426204"},weekly:{position:2,time:1266399848767,value:38840,duelID:"5255",dataID:"800@261993426204"},monthly:{position:3,time:1266399848767,value:38840,duelID:"5255",dataID:"800@261993426204"},overall:{position:7,time:1266399848767,value:38840,duelID:"5255",dataID:"800@261993426204"}},points:{position:1,time:1266399848767,value:100000}},match:{duelID:"5255",startTime:1266399660000,endTime:1266399848252,status:8,score:38840,result:2,points:2,dataID:"800@261993426204",opp_user:{userID:"1101@8589955042",identity:"geewa:fb-100000536230769",type:3,rank:6,nick:"Rastislav",gender:1,avatar:"http://resu-cz.geewa.ws/2/042/8589955042.png?a=8l&v=24",device:"pc|WinNT|5.0|web",domain:"beta.livegames.geewa.com",language:"en",location:{latitude:50.083,longitude:14.467,alpha3:"CZE",country:"Czech Republic",region:"52",city:"Prague"},reputation:50,state:{status:1}},opp_duelID:"4614"},highScore:4,beatenFriends:[{activityID:"wild-west",groupID:"livegames",user:{userID:"1101@8589955042",identity:"geewa:fb-100000536230769",type:3,rank:6,nick:"Rastislav",gender:1,avatar:"http://resu-cz.geewa.ws/2/042/8589955042.png?a=8l&v=24",device:"pc|WinNT|5.0|web",domain:"beta.livegames.geewa.com",language:"en",location:{latitude:50.083,longitude:14.467,alpha3:"CZE",country:"Czech Republic",region:"52",city:"Prague"},reputation:50,state:{status:1}},league:{createTime:1264177260000,accessTime:1266399660000,matchCounts:{daily:1,weekly:1,monthly:17,overall:28},scores:{monthly:{position:12,time:1265887140000,value:11466,duelID:"4614",dataID:"800@261993123698"},overall:{position:9,time:1264180620000,value:37446,duelID:"2947",dataID:"800@249108562842"}}}},{activityID:"wild-west",groupID:"livegames",user:{userID:"1101@8589954960",identity:"geewa:fb-100000532209325",type:2,rank:3,nick:"Tibor",gender:1,avatar:"http://gc001.geewa.com/flash/club/dev/avatar/defaultAvatars/boy.png?a=9z8k&v=6",device:"pc|WinNT|5.0|web",domain:"livegames.geewa.com",language:"en",location:{latitude:50.083,longitude:14.467,alpha3:"CZE",country:"Czech Republic",region:"52",city:"Prague"},reputation:50,state:{status:1}},league:{createTime:1263829380000,accessTime:1266103140000,matchCounts:{daily:0,weekly:0,monthly:6,overall:16},scores:{monthly:{position:9,time:1266103238013,value:14303,duelID:"4921",dataID:"800@261993256982"},overall:{position:12,time:1264723800000,value:33176,duelID:"3401",dataID:"800@253403407194"}}}}]}}var D=this.data.match.score;var N=this.data.match.dataID;var G;var H;var M;var P;var E;var K;if(this.data.beatenFriends){K="beatenFriends";var J=["highscore.png","highscore.png","highscore2.png","highscore2.png","highscore3.png"];var A=this.getText(K,J.length);H=A.index;M=A.title;P=A.text;E=J[H];if(this.data.beatenFriends.length==1){var I=this.data.beatenFriends[0].user;var L=geewa.encodeJSON(I);L=L.replace(/"/g,"&quot;");M=l.replaceTokens(M,I.nick);P=l.replaceTokens(P,"<strong>"+I.nick+"</strong>","<strong>"+I.nick+"</strong>");G="fe.page.publish.score({score:"+D+(N?",dataID:'"+N+"'":"")+",type:"+this.data.highScore+",textIndex:"+H+",beatenFriend:"+L+",from:'popup'});"}else{var C=[];C.push("<select id=\"beatenList\" onchange=\"if (document.getElementById('beatenFriend')) document.getElementById('beatenFriend').innerHTML = this[this.selectedIndex].text;\">");for(var F=0;F<this.data.beatenFriends.length;F++){var I=this.data.beatenFriends[F].user;var L=geewa.encodeJSON(I);L=L.replace(/"/g,"&quot;");C.push('<option value="'+L+'">'+I.nick+"</option>")}C.push("</select>");M=l.replaceTokens(M,l.gl("livegames.share.beatenFriends.yourFriends"));P=l.replaceTokens(P,C.join(""),'<strong><span id="beatenFriend">'+this.data.beatenFriends[0].user.nick+"</span></strong>");G="var list = document.getElementById('beatenList'); fe.page.publish.score({score:"+D+(N?",dataID:'"+N+"'":"")+",type:"+this.data.highScore+",textIndex:"+H+",beatenFriend:list[list.selectedIndex].value,from:'popup'});"}}else{if(this.data.highScore==4){K="alltimeHighscore";var J=["highscore.png","highscore.png","highscore2.png","highscore2.png","highscore3.png"];var A=this.getText(K,J.length);H=A.index;M=A.title;P=l.replaceTokens(A.text,session.user.nick,fe.page.data.name);E=J[H];G="fe.page.publish.score({score:"+D+(N?",dataID:'"+N+"'":"")+",type:"+this.data.highScore+",textIndex:"+H+",from:'popup'});"}else{K="dailyHighscore";var J=["unstoppable.png","yippee.png","yippee.png","yippee.png","yippee.png","yippee.png"];var A=this.getText(K,J.length);H=A.index;M=A.title;P=l.replaceTokens(A.text,fe.page.data.name);E=J[H];G="fe.page.publish.score({score:"+D+(N?",dataID:'"+N+"'":"")+",type:"+this.data.highScore+",textIndex:"+H+",from:'popup'});"}}fe.removeFirstFromArray(fe.page.share.links,"id","dailyHighscore");fe.removeFirstFromArray(fe.page.share.links,"id","overallHighscore");var D=[fe.tryValue(this.data,"league.scores.daily.value"),fe.tryValue(this.data,"league.scores.overall.value")];if(D[1]){var N=fe.tryValue(this.data,"league.scores.overall.dataID");var O="fe.page.publish.score({score:"+D[1]+(N?",dataID:'"+N+"'":"")+",type:4,from:'menu'});";fe.page.share.links.push({id:"overallHighscore",title:l.gl("livegames.share.alltimeHighscoreText")+" "+fe.numFormat(D[1]),onclick:"fe.page.share.close();"+O})}if(D[0]&&D[0]<D[1]){var N=fe.tryValue(this.data,"league.scores.daily.dataID");var O="fe.page.publish.score({score:"+D[0]+(N?",dataID:'"+N+"'":"")+",type:1,from:'menu'});";fe.page.share.links.push({id:"dailyHighscore",title:l.gl("livegames.share.dailyHighscoreText")+" "+fe.numFormat(D[0]),onclick:"fe.page.share.close();"+O})}var C=[];C.push('<div style="width:400px; text-align: center;">');if(E){C.push('<img src="'+this.imgShareUrl+E+'" alt="High Score" style="float: left;" />')}C.push('<div style="float: left; width: 250px; margin-top: 10px; margin-left: 25px;">');C.push(P);C.push('</div><div class="break"></div></div>');var B={};B.title=M;B.body=C.join("");B.buttons='<input type="button" value="'+l.gl("game.share")+'" onclick="'+G+"fe.popup.close();fe.page.actionStats('"+global.domain+"', '"+K+"', "+(H+1)+", 'popup', 'click');\"/><input type=\"button\" value=\""+l.gl("game.close")+'" onclick="fe.popup.close();" class="inputaux"/>';fe.popup.show(B);fe.page.actionStats(global.domain,K,(H+1),"popup","view")},lastWin:function(){if(arguments[0]=="debug"){this.data={activityID:"gomoku",groupID:"livegames",userID:"1101@8589954960",type:"duel|league|friend",league_previous:{points:{position:20,time:1264519523667,value:6},elo:{position:2,time:1264519523696,value:1015.97}},league:{createTime:1260882180000,accessTime:1264519560000,left:11,total:4,wins:3,draws:0,losts:0,matchCounts:{daily:4,weekly:4,monthly:4,overall:8},points:{position:5,time:1264519699285,value:6},elo:{position:7,time:1264519689117,value:997.72}},match:{duelID:"55662",startTime:1264519560000,endTime:1264519590454,status:8,points:0,opp_user:{userID:"1101@8589951933",identity:"geewa:fb-699764770",type:2,rank:2,nick:"Tibi",gender:1,avatar:"http://resu-cz.geewa.ws/2/933/8589951933.png?a=8lz13&v=11",device:"pc|WinNT|5.0|web",domain:"livegames.mygeewa.com",language:"en",location:{latitude:50.083,longitude:14.467,alpha3:"CZE",country:"Czech Republic",region:"52",city:"Prague"},reputation:50,state:{status:1}},opp_status:8,opp_duelID:"55661"}}}var E=fe.tryValue(this.data,"match.opp_user.nick","player");var G="latestWin";var H=["winner.png","winner.png","winner.png","champ.png","champ.png","champ.png"];var A=this.getText(G,H.length);var F=A.index;var I=l.replaceTokens(A.title,session.user.nick);var J=l.replaceTokens(A.text,E,fe.page.data.name);var D=(fe.page.data.gameID=="8-ball-pool"?"winnerPool.png":H[F]);fe.removeFirstFromArray(fe.page.share.links,"id","lastWin");fe.page.share.links.push({id:"lastWin",title:l.replaceTokens(l.gl("livegames.share.lastWin"),E),onclick:"fe.page.share.close();fe.page.publish.lastWin({opponent:'"+E+"',from:'menu'});"});var C=[];C.push('<div style="width:420px; text-align: center;">');if(D){C.push('<img src="'+this.imgShareUrl+D+'" alt="Winner" style="float: left;" />')}C.push('<div style="float: left; width: 270px; margin-top: 10px; margin-left: 25px;">');C.push(J);C.push('</div><div class="break"></div></div>');var B={};B.title=I;B.body=C.join("");B.buttons='<input type="button" value="'+l.gl("game.share")+'" onclick="fe.popup.close();fe.page.publish.lastWin({opponent:\''+E+"',textIndex:"+F+",from:'popup'});fe.page.actionStats('"+global.domain+"', '"+G+"', "+(F+1)+", 'popup', 'click');\"/><input type=\"button\" value=\""+l.gl("game.close")+'" onclick="fe.popup.close();" class="inputaux"/>';fe.popup.show(B);fe.page.actionStats(global.domain,G,(F+1),"popup","view")},leaguePosition:function(){if(arguments[0]=="debug"){this.data={activityID:"wild-west",groupID:"livegames",userID:"1101@8589951306",type:"ghostLeague",league_previous:{points:{value:20,position:15},scores:{overall:{position:1,time:1261398060000,value:38755,duelID:"386"}}},league:{createTime:1260880380000,accessTime:1264507980000,matchCounts:{daily:1,weekly:1,monthly:1,overall:3},points:{position:11,value:25},scores:{overall:{position:2,time:1261398060000,value:38755,duelID:"386",dataID:"800@236223345588"}}},match:{duelID:"3167",startTime:1264507980000,endTime:1264508003736,status:8,score:1528,result:2,points:2,dataID:"800@253403265344"}}}var I=[fe.tryValue(this.data,"league_previous.points.position"),fe.tryValue(this.data,"league.points.position")];if(!I[1]||(I[0]&&I[1]>=I[0])){return}var L;var F;var J;var K;var D;var G;if(I[1]==1){G="beingFirstInLeague";var H=["league1.png","league1.png"];var A=this.getText(G,H.length);F=A.index;J=A.title;K=l.replaceTokens(A.text,fe.page.data.name);D=H[F];L="fe.page.publish.leaguePosition({position:"+I[1]+",textIndex:"+F+",points:"+fe.tryValue(this.data,"league.points.value",0)+",from:'popup'});"}else{if(I[1]>=2&&I[1]<=10){if(I[1]==2){G="beingSecondInLeague";var H=["league2.png","league2.png"];var A=this.getText(G,H.length);F=A.index;J=A.title;K=l.replaceTokens(A.text,fe.page.data.name);D=H[F];L="fe.page.publish.leaguePosition({position:"+I[1]+",textIndex:"+F+",from:'popup'});"}else{if(I[1]==3){G="beingThirdInLeague";var H=["league3.png"];var A=this.getText(G,H.length);F=A.index;J=A.title;K=l.replaceTokens(A.text,session.user.nick,fe.page.data.name);D=H[F];L="fe.page.publish.leaguePosition({position:"+I[1]+",textIndex:"+F+",from:'popup'});"}else{G="beingFourthToTenthInLeague";var H=["leagueTop10.png","leagueTop10.png","leagueTop10.png","leagueTop10.png","leagueTop10.png","leagueTop10.png"];var A=this.getText(G,H.length);F=A.index;J=A.title;K=l.replaceTokens(A.text,I[1],fe.page.data.name,session.user.nick);D=H[F];L="fe.page.publish.leaguePosition({position:"+I[1]+",textIndex:"+F+",from:'popup'});"}}}else{if(I[0]&&I[1]<I[0]&&I[0]-I[1]>=25){G="moveXPositionsInLeague";var H=["congrats.png","congrats.png","league.png","league.png"];var A=this.getText(G,H.length);F=A.index;var E=(I[0]-I[1]);J=l.replaceTokens(A.title,fe.page.data.name);K=l.replaceTokens(A.text,E,fe.page.data.name,session.user.nick);D=H[F];L="fe.page.publish.leaguePosition({position:"+I[1]+",textIndex:"+F+",positionsMoved:"+E+",from:'popup'});"}else{return}}}var C=[];C.push('<div style="width:420px; text-align: center;">');if(D){C.push('<img src="'+this.imgShareUrl+D+'" alt="League Position" style="float: left;" />')}C.push('<div style="float: left; width: 270px; margin-top: 10px; margin-left: 25px;">');C.push(K);C.push('</div><div class="break"></div></div>');var B={};B.title=J;B.body=C.join("");B.buttons='<input type="button" value="'+l.gl("game.share")+'" onclick="fe.popup.close();'+L+"fe.page.actionStats('"+global.domain+"', '"+G+"', "+(F+1)+", 'popup', 'click');\"/><input type=\"button\" value=\""+l.gl("game.close")+'" onclick="fe.popup.close();" class="inputaux"/>';fe.popup.show(B);fe.page.actionStats(global.domain,G,(F+1),"popup","view")},firstLeagueMatch:function(){var F="enteringLeague";var G=["league.png"];var A=this.getText(F,G.length);var E=A.index;var J="fe.page.publish.firstLeagueMatch({textIndex:"+E+",from:'popup'});";var H=l.replaceTokens(A.title,fe.page.data.name);var I=l.replaceTokens(A.text,fe.page.data.name);var D=G[E];var C=[];C.push('<div style="width:420px; text-align: center;">');if(D){C.push('<img src="'+this.imgShareUrl+D+'" alt="First League Match" style="float: left;" />')}C.push('<div style="float: left; width: 270px; margin-top: 10px; margin-left: 25px;">');C.push(I);C.push('</div><div class="break"></div></div>');var B={};B.title=H;B.body=C.join("");B.buttons='<input type="button" value="'+l.gl("game.share")+'" onclick="fe.popup.close();'+J+"fe.page.actionStats('"+global.domain+"', '"+F+"', "+(E+1)+", 'popup', 'click');\"/><input type=\"button\" value=\""+l.gl("game.close")+'" onclick="fe.popup.close();" class="inputaux"/>';fe.popup.show(B);fe.page.actionStats(global.domain,F,(E+1),"popup","view")},getText:function(C,D){var B=(typeof(arguments[2])!="undefined"?arguments[2]:(D>1?Math.round(Math.random()*(D-1)):0));var A={index:B,title:l.gl("livegames.share."+C+".pTitle"+(B+1)),text:l.gl("livegames.share."+C+".pBody"+(B+1))};return A}},ad:{getOpenX:function(A){return'<iframe id="__geewa_ad_frame" width="574" height="80" frameborder="0" scrolling="no" src="/t/'+global.theme+"/ad/"+l.id+"/"+A+".aspx?cacheKey="+(new Date()).valueOf()+'"></iframe>'},showAd:function(){return(l.id=="cs"&&session.user.type!=fe.USER_TYPE_PRO)},getTopHTML:function(){var B=[];if(this.showAd()){try{fe.pt._trackEvent("ad","game-takeover_2010-08_Vodafone")}catch(A){}B.push('<div id="adTop" style="display: block; width: 574px; height: 80px; position: absolute; top: -90px; left: 50%; margin-left: -287px;" title="Stránka se otevře do nového okna, hra nebude narušena">');B.push(this.getOpenX("takeoverTop"));B.push("</div>")}return B.join("")},getBottomHTML:function(){var A=[];if(this.showAd()){A.push('<div id="adBottom" style="display: block; width: 574px; height: 80px;position: absolute; bottom: -90px; left: 50%; margin-left: -287px;" title="Stránka se otevře do nového okna, hra nebude narušena">');A.push(this.getOpenX("takeoverBottom"));A.push("</div>")}return A.join("")},getLogo:function(){var A=[];if(this.showAd()){A.push('<img src="/ad/takeover/vodafone/logo_vf.jpg" alt="Vodafone" style="display: block; position: absolute; bottom: 0; left: 0; z-index: -1;" />')}return A.join("")},setBackground:function(){if(this.showAd()){document.body.style.background="#fff url(/ad/takeover/vodafone/background.jpg) repeat scroll top left"}},start:function(){}},showEmbed:function(){var B=[];B.push('<textarea cols="100" rows="14" readonly="readonly" style="width: 98%;" onclick="this.select();">');B.push("&lt;!-- BEGIN - EMBED GAME FROM GEEWA.COM --&gt;\n");B.push('&lt;script type="text/javascript"&gt;\n');B.push("//YOU CAN CHANGE these game parameters\n");B.push("var __geewa_game = {};\n");B.push("__geewa_game.id = '"+fe.page.data.gameID+"';\n");B.push("__geewa_game.language = '"+fe.page.data.language+"';\n");B.push("//DON'T CHANGE!!!!!!!!\n");B.push("document.open();\n");B.push("document.write('&lt;scr' + 'ipt type=\"text/javascript\" src=\"http://gc001.geewa.com/ajax/common/insertGame.js?' + (new Date()).valueOf() + '\"&gt;&lt;/scr' + 'ipt&gt;');\n");B.push("document.close();\n");B.push("&lt;/script&gt;\n");B.push('&lt;noscript&gt;Free multiplayer games at &lt;a href="http://www.geewa.com"&gt;Geewa.com&lt;/a&gt;!&lt;/noscript&gt;\n');B.push("&lt;!-- END - EMBED GAME FROM GEEWA.COM --&gt;");B.push("</textarea>");var A={};A.title=l.replaceTokens(l.gl("game.embedGame"),fe.page.data.name);A.body=B.join("");A.buttons='<input type="button" value="'+l.gl("game.close")+'" onclick="fe.popup.close();" class="inputaux"/>';fe.popup.show(A)}};
fe.page.game={id:"duel",sizeMode:0,start:function(){fe.page.challenge.setListeners(0);this.data=arguments.length>0?arguments[0]:{};if(!this.data.type){this.data.type="random"}this.sizeMode=(fe.page.data.profile.resize=="alwaysRatio"||fe.page.data.profile.resize=="alwaysFull")?2:0;this.hidden=false;var A=[];if(global.adPositions&&global.adPositions.indexOf("4")>-1&&session.user.type!=fe.USER_TYPE_PRO){A.push(fe.page.ad.getLogo())}A.push('<div id="page" class="game" style="visibility:hidden;padding:0;position:absolute;border:none;">');if(global.adPositions&&global.adPositions.indexOf("5")>-1&&session.user.type!=fe.USER_TYPE_PRO){A.push(fe.page.ad.getTopHTML())}A.push(geewa.game.getHTML(this.gameParams()));if(global.adPositions&&global.adPositions.indexOf("6")>-1&&session.user.type!=fe.USER_TYPE_PRO){A.push(fe.page.ad.getBottomHTML())}A.push("</div>");if(fe.mode===fe.MODE_FACEBOOK_APP){A.push('<div class="privacy-terms"><a href="http://'+global.domain+'/help/contact-form?type=abuse" target="_blank">Report abuse</a> | <a href="http://'+global.domain+'/help/privacy-policy" target="_blank">Privacy Policy</a> | <a href="http://'+global.domain+'/help/terms-of-use" target="_blank">Terms of Use</a></div>')}fe.page.startGame(A.join(""),this.data.type=="random")},hide:function(){var A=fe.getIDs("page","__geewa_game_object");if(!(A[0]&&A[1])){return}A[1].width="1px";A[1].height="1px";this.hidden=true},show:function(){this.hidden=false;this._onResize()},_onResize:function(){if(this.hidden){return}var D=fe.getIDs("page","__geewa_game_object","messenger");if(!(D[0]&&D[1])){return}var C=parseInt(fe.page.data.profile.width,10);var A=parseInt(fe.page.data.profile.height,10);var E=this.sizeMode;var B=(typeof(window.innerWidth)=="undefined"?document.documentElement.clientWidth:window.innerWidth)-(D[2]?D[2].offsetWidth:0);var F=(fe.mode==fe.MODE_FACEBOOK_APP?767:(typeof(window.innerHeight)=="undefined"?document.documentElement.clientHeight:window.innerHeight));switch(E){case 0:D[1].width=C+"px";D[1].height=A+"px";D[0].style.top=parseInt((F-A)/2,10)+"px";D[0].style.left=parseInt((B-C)/2,10)+"px";if(fe.page.data.profile.resize&&(D[0].offsetTop<0||D[0].offsetLeft<0)){this.sizeMode=11;this._onResize();return}break;case 11:if(B>C&&F>A){this.sizeMode=0;this._onResize();return}case 1:if(B/F>C/A){D[1].width=F*C/A;D[1].height=F;D[0].style.top=0;D[0].style.left=parseInt((B-D[1].width)/2,10)+"px"}else{D[1].width=B;D[1].height=B*A/C;D[0].style.top=parseInt((F-D[1].height)/2,10)+"px";D[0].style.left=0}break;case 2:D[1].width=B+"px";D[1].height=F+"px";D[0].style.top=0;D[0].style.left=0;break}D[0].style.width=parseInt(D[1].width,10)+"px";if(D[0].style.visibility=="hidden"){D[0].style.visibility="visible";if(D[1]){D[1].focus()}}},gameParams:function(){geewa.game.version=global.flashComponentsVersion;var A={};A.identity=fe.getIdentity();A.language=l.id;A.statsGlobal=false;A.statsLocal=null;A.gameID=fe.page.data.gameID;A.runMode="simple";A.publicServerURL=global.publicServer;if(session){A.userServerSessionID=session.sessionID;if(session.user){A.userPictureURL="http://static.geewa.ws/t/?dest=jpg&url="+escape(session.user.avatar)}}if(fe.page.activity&&fe.page.activity.profile&&fe.page.activity.profile.roomServerUrl){A.userServerURL=fe.page.activity.profile.roomServerUrl}A.cacheKey=global.cacheKey;A.resizeMode=(fe.page.data.profile.resize!="none");A.closeButton=true;A.resizeButton=(fe.page.data.profile.resize!="none");A.externalEventListener="__geewa_onEvent";switch(this.data.type){case"external":case"challenge":A.autorun="invitation";A.playerCount="2-2-2";if(this.data.mode=="join"){A.invitationCode=this.data.lobbyID}else{A.invitationURL="hidden"}break;case"league":A.autorun="randomOpponent";A.multipleMatches=false;A.publicLobbyID=fe.page.league.data.profile.lobbyID;A.playerCount="2-2-2";A.matchParams={groupID:global.competitionGroupID,typeID:"duelLeague"};break;default:A.autorun="randomOpponent";break}if(!A.matchParams){A.matchParams={}}A.matchParams.joinMode=this.data.type;return A},close:function(){fe.page.challenge.removeOwnerChallenge();fe.page.closeGame();fe.page.challenge.setListeners(fe.page.page=="challenge"?2:1)},onEvent:function(){geewa.debug.log("ajax","fe.page.game.onEvent: "+arguments[0].eventType,geewa.encodeJSON(arguments[0]));switch(arguments[0].eventType){case"init":var E=fe.getIDs("__geewa_game_object");if(E[0]){E[0].focus()}break;case"close":this.close();break;case"resize":if(this.sizeMode==0){switch(fe.page.data.profile.resize){case"ratio":this.sizeMode=1;break;case"full":this.sizeMode=2;break}}else{this.sizeMode=0}this._onResize();break;case"privateLobbyJoin":switch(this.data.type){case"external":switch(this.data.mode){case"shoutout":this.data.lobbyID=arguments[0].privateLobbyID;this.hide();fe.page.shoutOut(this.data.lobbyID);break;case"invite":this.data.lobbyID=arguments[0].privateLobbyID;this.hide();fe.page.sendToChat(this.data.lobbyID);break;case"messenger":this.data.lobbyID=arguments[0].privateLobbyID;var C="http://"+global.domain+"/"+fe.page.data.gameID+"#invite="+arguments[0].privateLobbyID+"&fs=1";if(geewa.messenger){geewa.messenger.call("sendPrivateChatMessage",this.data.inviteUser.userID,geewa.stringAppend(l.gl("game.comeAndPlay"),fe.page.data.name)+": \n"+C)}break;case"join":break}break;case"challenge":if(this.data.mode=="join"){var D={type:"acceptChallenge",messageID:this.data.messageID,users:[]};D.users.push(this.data.challengeUser);geewa.server.user.call("ChallengeRoom.SendMessage",1,D)}else{this.data.lobbyID=arguments[0].privateLobbyID;var A=this;geewa.server.user.call(function(){fe.page.challenge.onCreate.apply(fe.page.challenge,arguments)},"ChallengeRoom.SendMessage",1,{type:"createChallenge",message:this.data.invitationMessage,lobbyID:this.data.lobbyID})}break}break;case"mpMatchStart":fe.popup.close();if(arguments[0].players.length==2&&geewa.messenger&&session.messengerWidth>0){var B=arguments[0].players[arguments[0].players[0].user.userID==session.user.userID?1:0].user;if(B.type!=fe.USER_TYPE_GUEST){geewa.messenger.call("showUserProfileByID",B.userID)}}break;case"mpMatchEnd":this.stats.analyzeMatchResult(arguments[0]);break;default:break}},stats:{wins:0,losses:0,matches:[],analyzeMatchResult:function(){this.DEBUG=arguments[0];var C=arguments[0].players;if(C.length==2&&C[0].status=="FINISHED"&&C[1].status=="FINISHED"){var B=(C[0].user.userID==session.user.userID?[C[0],C[1]]:[C[1],C[0]]);var A={players:B,time:new Date().valueOf(),roomID:arguments[0].roomID,matchID:arguments[0].matchID};this.matches.push(A);if(B[0].standing<B[1].standing){this.lastWin=this.matches[this.matches.length-1];this.wins++;this.losses=0}else{if(B[0].standing>B[1].standing){this.wins=0;this.losses++}else{this.wins=0;this.losses=0}}}}}};fe.page.challenge={items:[],updateTime:0,_listeners:0,_lastMessageID:-1,_count:0,create:function(){if(session.user.type==fe.USER_TYPE_GUEST){this.showRegistrationRequired();return}var B=fe.getIDs("invitationMessage");var A={type:"challenge",mode:"create"};if(B[0]){A.invitationMessage=B[0].value;B[0].value=""}fe.page.game.start(A)},onCreate:function(A,B){this._ownerChallengeID=B.result.messageID},onMessage:function(){var A=arguments[0];switch(A.data.type){case"createChallenge":if(A.user.userID==session.user.userID){break}else{if((geewa.server.time.now()-A.time)<600000){var B={id:A.messageID,time:A.time,lobbyID:A.data.lobbyID,users:[A.user]};if(A.data.message){B.text=A.data.message}B.updateTime=new Date().valueOf();this.items.unshift(B)}}break;case"acceptChallenge":var B=fe.getFirstFromArray(this.items,"id",A.data.messageID);if(B){B.users.push(A.user);B.updateTime=new Date().valueOf()}break;case"removeChallenge":fe.removeFirstFromArray(this.items,"id",A.data.messageID);break}this.show()},onCount:function(A){var B=fe.getIDs("challengeTabText","challengeTab","mainPage","contentBody");if(B[0]){B[0].innerHTML=l.gl("game.barChallenge")+(A>0?" ("+A+")":"")}if(B[1]&&B[2]&&(A-this._count)>0&&B[2].style.display!="none"&&fe.page.page!="challenge"&&B[3].style.display!="none"){fe.bubble.show(B[1],l.gl("game.challenge.newChallenge"),null,5000)}this._count=A},show:function(){var F=[];this.setListeners(2);var E=fe.getIDs("challengeMessages","challengeBody");if(!E[0]){return}var A=0;if(this.items.length===0){F.push("<br /><p>"+l.gl("game.challenge.defaultMessage")+"</p>")}else{var C=0;var B=geewa.server.time.now();while(C<this.items.length){if((B-this.items[C].time)>600000){this.items.splice(C,1)}else{var D=this.items[C];F.push('<div class="challenge">');F.push('<div class="players-list"><ul class="flex reset clearfix">');F.push("<li>"+this.getUserBoxHTML(D.users[0])+"</li>");if(D.users.length==1){F.push("<li>"+this.getUserBoxDefaultHTML(D.id)+"</li>")}else{F.push("<li>"+this.getUserBoxHTML(D.users[1])+"</li>")}F.push("</ul></div>");F.push('<div class="info">');if(D.users.length<2){if(D.text){F.push("<strong>"+D.text+"</strong><br/>")}F.push("<strong>"+D.users[0].nick+"</strong> "+l.gl("game.challenge.looking"));A++}else{F.push("<strong>"+D.users[0].nick+"</strong> "+l.gl("game.challenge.and")+" <strong>"+D.users[1].nick+"</strong> "+l.gl("game.challenge.playing"))}F.push("<br/>"+fe.timeBefore(D.time,B));F.push('</div><div class="break"></div></div>');C++;if(C>10){this.items.splice(C,this.items.length-C);break}}}}this.onCount(A);if(this.updateTime!=0||this.items.length>0){this.updateTime=new Date().valueOf()}if(E[1].style.display=="block"){fe.avatar.destroy();E[0].innerHTML=F.join("")}fe.fixPageHeight()},getUserBoxHTML:function(B){var A=[];A.push('<div class="in">');A.push(fe.avatar.getHTML(B,"left:10px;top:0;"));A.push('<p class="clearfix nick">');A.push("<strong>"+fe.userLink(B)+"</strong>");A.push('<span class="state">'+fe.getFlag(B)+"</span>");A.push("</p></div>");return A.join("")},getUserBoxDefaultHTML:function(A){var B=[];B.push('<div class="in">');B.push('<div class="avatar" style="position: relative; width: 100px; height: 100px; left: 10px; top: 0pt;">');B.push('<a href="javascript:void(0);" onclick="fe.page.challenge.join('+A+');"><img src="/img/waiting_icon.png" alt="Waiting" /></a>');B.push("</div>");B.push('<p class="button50-orange"><a href="javascript:void(0);" onclick="fe.page.challenge.join('+A+');">'+l.gl("game.challengeJoin")+"</a></p>");B.push("</div>");return B.join("")},join:function(A){if(session.user.type==fe.USER_TYPE_GUEST){fe.showRegistrationRequired();return}var B=fe.getFirstFromArray(this.items,"id",A);if(B){fe.page.game.start({type:"challenge",mode:"join",lobbyID:B.lobbyID,messageID:B.id,challengeUser:B.users[0]})}},removeOwnerChallenge:function(){if(this._ownerChallengeID){geewa.server.user.call("ChallengeRoom.SendMessage",1,{type:"removeChallenge",messageID:this._ownerChallengeID})}},setListeners:function(A){if(A!=this._listeners){if(this._listeners==2){this.items=[];this.updateTime=0;this._lastMessageID=-1;this._count=0}this._listeners=A;geewa.server.user.call("ChallengeRoom.SetListeners",A)}}};fe.page.friends={PAGE_SIZE:20,show:function(){var A=fe.getIDs("friendsBody");if(A[0]&&A[0].innerHTML==""){var B=[];B.push('<div id="friendsList" class="players-list"></div>');A[0].innerHTML=B.join("")}this.getPage(4,0,3)},getPage:function(){if(arguments.length>0){this.scoreType=arguments[0]}if(arguments.length>1){this.page=arguments[1]}if(arguments.length>2){this.sortBy=arguments[2]}for(var B=1;B<5;B++){var C=document.getElementById("friends"+B);if(B==this.scoreType){fe.addStyle(C,"active")}else{fe.removeStyle(C,"active")}}var A=this;geewa.server.user.call(function(){A.onPage.apply(A,arguments)},"Competition.GetFriends",this.scoreType,this.page,this.PAGE_SIZE,this.sortBy)},onPage:function(K,B){var F=fe.getIDs("friendsList");var A=[];if(B.result&&B.result.items&&B.result.items.length>0){var D=fe.page.activity.profile.score||fe.page.activity.profile.scores;var J="friend-better";A.push('<ul class="reset clearfix">');for(var E=0;E<B.result.items.length;E++){var I;var L=B.result.items[E];var H=[fe.tryValue(L,"friend.total",0),fe.tryValue(L,"friend.wins",0),fe.tryValue(L,"friend.draws",0),fe.tryValue(L,"friend.losts",0)];if(H[0]>0||L.user.userID!=session.user.userID){var C="";A.push('<li><div class="in">');if(L.user.userID==session.user.userID){J="default";C=" highlight"}else{if(J=="default"){J="friend-worse"}}A.push(fe.avatar.getHTML(L.user,"left:10px;top:0;",J));A.push('<p class="clearfix nick'+C+'">');if(H[0]>0){I=fe.tryValue(L,"friend.points.position");A.push('<strong class="rank">'+(I?I+".":"")+"</strong>");A.push('<strong class="rank2">'+(I?I+".":"")+"</strong>")}A.push("<strong>"+fe.userLink(L.user)+"</strong>");A.push('<span class="state">'+fe.getFlag(L.user)+"</span>");A.push("</p>");if(H[0]>0){I=fe.tryValue(L,"friend.points.value");var G=l.gl("bubble.game.win")+": "+H[1]+"<br/>";G+=l.gl("bubble.game.draw")+": "+H[2]+"<br/>";G+=l.gl("bubble.game.loss")+": "+H[3];A.push('<p class="clearfix"><span class="l smaller">'+l.gl("bubble.game.win")+':</span><strong class="r bigger">'+(I||I===0?I+"%":"NA")+"</strong></p>");A.push('<p class="clearfix small'+(D?"":" last")+'" onmouseover="fe.bubble.show(this, \''+G+'\');" onmouseout="fe.bubble.close(this);"><span class="l ">W | D | L:</span> <strong class="r">'+H[1]+" | "+H[2]+" | "+H[3]+"</strong></p>");if(D){I=fe.tryValue(L,"friend.score.value");I=(I>=0?fe.numFormat(I):"");A.push('<p class="clearfix small last"><span class="l">'+l.gl("game.score")+':</span><strong class="r">'+I+"</strong></p>")}}else{A.push('<p class="button50-orange"><a href="#p=game&m=invite">Play with<br />'+L.user.nick+"</a></p>")}A.push("</div></li>")}}A.push("</ul>")}else{A.push(geewa.stringAppend(l.gl("game.friends.liveDefaultMessage"),fe.page.data.name,'<a href="#p=game&m=invite" onmouseover="fe.bubble.show(this, \''+l.gl("bubble.game.friendsSendToChat")+"', 'bubble-orange');fe.page.onPlay(true);\" onmouseout=\"fe.page.onPlay(false);fe.bubble.close(this);\">","</a>",'<a href="javascript:void(0);" onclick="fe.bubble.close(this);fe.page.publish.invitation();" onmouseover="fe.bubble.show(this, \''+l.gl("bubble.game.friendsPublishToWall")+"', 'bubble-orange');\" onmouseout=\"fe.bubble.close(this);\">","</a>"))}F[0].innerHTML=A.join("");fe.fixPageHeight()},paging:function(A,D,F,B){var E=[];if(D>1){E.push('<p class="center">\n');if(A>0){E.push('<a href="javascript:void(0);" onclick="'+B+"("+(A-1)+');">&laquo; '+l.gl("gamesList.previous")+"</a> |\n")}for(var C=(A-F<0?0:A-F);C<A;C++){E.push('<a href="javascript:void(0);" onclick="'+B+"("+C+');">'+(C+1)+"</a> |\n")}E.push("<strong>"+(A+1)+"</strong>\n");for(var C=A+1;C<(A+F>D?D:A+F);C++){E.push('| <a href="javascript:void(0);" onclick="'+B+"("+C+');">'+(C+1)+"</a>\n")}if(A<(D-1)){E.push('| <a href="javascript:void(0);" onclick="'+B+"("+(A+1)+');">'+l.gl("gamesList.next")+" &raquo;</a>\n")}E.push("</p>")}return E.join("")}},fe.page.league={PAGE_SIZE:20,show:function(){var F=fe.tryValue(fe.page.league,"data.profile.roundMaxDuels",0);var E=[];E.push('<div class="my-results" style="float: left;">');E.push('<table border="0">');var A=fe.tryValue(this,"data.myProfile.league.points.position");E.push("<tr><td>"+l.gl("game.league.currentPosition")+":</td>");if(A){E.push("<td><strong>"+A+".</strong></td>")}else{if(fe.tryValue(this,"data.myProfile.league.total")){E.push('<td><strong onmouseover="fe.bubble.show(this, l.gl(\'bubble.game.na\'));" onmouseout="fe.bubble.close(this);">NA</strong></td>')}else{E.push('<td><strong onmouseover="fe.bubble.show(this, l.gl(\'bubble.game.dns\'));" onmouseout="fe.bubble.close(this);">DNS</strong></td>')}}E.push("</tr>");var B=fe.tryValue(this,"data.profile.roundMaxDuels",10);var C=fe.tryValue(this,"data.myProfile.league.left",B);E.push("<tr><td>"+l.gl("game.league.matchesRemainingToday")+":</td><td><span onmouseover=\"fe.bubble.show(this, '"+geewa.stringAppend(l.gl("bubble.game.leagueMatchesRemaining"),B)+'\');" onmouseout="fe.bubble.close(this);">');if(C===0){var D=new Date(geewa.server.time.now(true));D=24*60-(D.getHours()*60+D.getMinutes());D=[parseInt(D/60,10),D%60];E.push(geewa.stringAppend(l.gl("game.league.noMatchesLeftStartIn"),D[0],D[1]))}else{E.push("<strong>"+C+"</strong>")}E.push("</span></td></tr>");E.push("<tr><td>"+l.gl("game.league.matchRollover")+":</td><td>");if(session.user.type!=fe.USER_TYPE_PRO){E.push("<strong>"+l.gl("game.league.matchRolloverOff")+'</strong>&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" onclick="fe.payment.show(\'pro\',l.gl(\'player.profi.title\'));" onmouseover="fe.bubble.show(this, l.gl(\'bubble.game.leagueActiveRollover\'));" onmouseout="fe.bubble.close(this);">'+l.gl("game.league.activateRollover")+"</a>")}else{E.push("<strong>"+l.gl("game.league.matchRolloverOn")+"</strong>")}E.push("</td></tr>");E.push('<tr><td><a href="javascript:void(0);" onclick="fe.user.show(session.user,event);">'+l.gl("game.league.showMyMatches")+"</a></td><td>&nbsp;</td></tr>");E.push("</table>");E.push("</div>");E.push('<p class="buttons button50-orange" style="margin: 0 0 20px 20px; float: right;"><a href="#p=game&amp;m=league" onmouseover="fe.bubble.show(this, \''+geewa.stringAppend(l.gl("bubble.game.leaguePlayLeagueDuel"),B)+"', 'bubble-orange');\" onmouseout=\"fe.bubble.close(this);\">"+l.gl("game.playLeague")+"</a></p>");E.push('<div class="break"></div>');E.push('<p class="l sort">');E.push("<strong>"+l.gl("game.league.leagueText")+":</strong>");E.push('<a id="ranking1" href="javascript:void(0);" onclick="fe.page.league.showRanking(1);" class="first">'+l.gl("game.league.actual")+"</a>");E.push('<a id="ranking2" href="javascript:void(0);" onclick="fe.page.league.showRanking(2);">'+l.gl("game.league.previous")+"</a>");E.push("</p>");if(fe.page.activity.profile.score||fe.page.activity.profile.scores){E.push('<p class="l sort">');E.push("<strong>"+l.gl("game.league.globalHighscore")+":</strong>");E.push('<a id="ranking3" href="javascript:void(0);" onclick="fe.page.league.showRanking(3);" class="first">'+l.gl("game.league.daily")+"</a>");E.push('<a id="ranking4" href="javascript:void(0);" onclick="fe.page.league.showRanking(4);">'+l.gl("game.league.weekly")+"</a>");E.push('<a id="ranking5" href="javascript:void(0);" onclick="fe.page.league.showRanking(5);">'+l.gl("game.league.monthly")+"</a>");E.push('<a id="ranking6" href="javascript:void(0);" onclick="fe.page.league.showRanking(6);">'+l.gl("game.league.longTerm")+"</a>");E.push("</p>")}E.push('<p class="r sort">');E.push('<a id="ranking7" href="javascript:void(0);" onclick="fe.page.league.showRanking(7);" class="first">'+l.gl("game.league.hallOfFame")+"</a>");E.push('<a id="ranking8" href="javascript:void(0);" onclick="fe.page.league.showRanking(8);" onmouseover="fe.bubble.show(this, \''+l.gl("bubble.game.eloDesc")+'\');" onmouseout="fe.bubble.close(this);">'+l.gl("game.league.elo")+"</a>");E.push("</p>");E.push('<div class="break"></div>');E.push('<div id="leagueRanking" class="rank-list"></div>');geewa.writeHTML("leagueBody",E.join(""));this.showRanking(1)},showRanking:function(B){for(var C=1;C<9;C++){var D=document.getElementById("ranking"+C);if(C==B){fe.addStyle(D,"active")}else{fe.removeStyle(D,"active")}}var A=this;switch(B){case 1:this.type="points";this.subType=2;break;case 2:this.type="points";this.subType=4;break;case 3:this.type="scores";this.subType=1;break;case 4:this.type="scores";this.subType=2;break;case 5:this.type="scores";this.subType=3;break;case 6:this.type="scores";this.subType=4;break;case 7:this.type="points";this.subType=3;break;case 8:this.type="elo";this.subType=null;break}this.getPage(0)},getPage:function(B){this.page=B;var A=this;switch(this.type){case"points":geewa.server.ps.call(function(){A.onResponse.apply(A,arguments)},"Competition.GetPointsTable",fe.page.activity.activityID,global.competitionGroupID,this.subType==4?2:this.subType,B,this.PAGE_SIZE,this.subType==4?{league:"previous"}:null);break;case"scores":geewa.server.ps.call(function(){A.onResponse.apply(A,arguments)},"Competition.GetScoresTable",fe.page.activity.activityID,global.competitionGroupID,this.subType,B,this.PAGE_SIZE);break;case"elo":geewa.server.ps.call(function(){A.onResponse.apply(A,arguments)},"Competition.GetEloTable",fe.page.activity.activityID,global.competitionGroupID,B,this.PAGE_SIZE);break}},onResponse:function(B,E){this.response=E;var H=[];if(E.result.items){if(B.name=="Competition.GetScoresTable"){var G=["time","day,time","date,time","date,time"];H.push("<table>");H.push('<col width="10%" />');H.push('<col width="45%" />');H.push('<col width="5%" />');H.push('<col width="20%" />');H.push('<col width="20%" />');H.push("<thead>");H.push("<tr>");H.push('<th align="center">'+l.gl("game.league.position")+"</th>");H.push('<th align="left">'+l.gl("game.league.nick")+"</th>");H.push("<th>&nbsp;</th>");H.push('<th align="right">'+l.gl("game.league.time")+"</th>");H.push('<th align="right">'+l.gl("game.league.score")+"</th>");H.push("</tr>");H.push("</thead>");H.push("<tbody>");var C;for(var D=0;D<E.result.items.length;D++){var F=E.result.items[D];var A="";if(F.user.userID==session.user.userID){A="highlight"}if(D%2==1){A+=" even"}H.push('<tr class="'+A+'">');H.push('<td align="center">'+(!C||C!=F.score.position?F.score.position+".":"")+"</td>");C=F.score.position;H.push('<td align="left">'+fe.userLink(F.user)+"</td>");H.push('<td align="center">'+fe.getFlag(F.user)+"</td>");H.push('<td align="right">'+fe.timeBefore(new Date(F.score.time))+"</td>");H.push('<td align="right"><strong>'+fe.numFormat(F.score.value)+"</strong></td>");H.push("</tr>")}H.push("</tbody>");H.push("</table>");H.push('<p class="center small">'+l.gl("game.league.modified")+": "+fe.timeFormat(new Date(E.result.modified))+"</p>");H.push(this.paging(this.page,Math.ceil(E.result.count/this.PAGE_SIZE),5,"fe.page.league.getPage"));if(l.l["description.highScore"]){H.push('<div style="margin-top:20px;">'+l.gl("description.highScore")+"</div>")}}else{if(B.name=="Competition.GetPointsTable"&&B.arguments[2]==2){H.push("<table>");H.push('<col width="10%" />');H.push('<col width="25%" />');H.push('<col width="5%" />');H.push('<col width="10%" />');H.push('<col width="7%" />');H.push('<col width="10%" />');H.push('<col width="10%" />');H.push('<col width="10%" />');H.push('<col width="13%" />');H.push("<thead>");H.push("<tr>");H.push('<th align="center">'+l.gl("game.league.position")+"</th>");H.push('<th align="left">'+l.gl("game.league.nick")+"</th>");H.push("<th>&nbsp;</th>");H.push('<th align="right">'+l.gl("game.league.matches")+"</th>");H.push('<th align="right">'+l.gl("game.league.wins")+"</th>");H.push('<th align="right">'+l.gl("game.league.draws")+"</th>");H.push('<th align="right">'+l.gl("game.league.loses")+"</th>");H.push('<th align="right">'+l.gl("game.league.points")+"</th>");H.push('<th align="right">'+l.gl("game.league.maxPoints")+"</th>");H.push("</tr>");H.push("</thead>");H.push("<tbody>");var C;for(var D=0;D<E.result.items.length;D++){var F=E.result.items[D];var A="";if(F.user.userID==session.user.userID){A="highlight"}if(D%2==1){A+=" even"}H.push('<tr class="'+A+'">');H.push('<td align="center">'+(!C||C!=F.points.position?F.points.position+".":"")+"</td>");C=F.points.position;H.push('<td align="left">'+fe.userLink(F.user)+"</td>");H.push('<td align="center">'+fe.getFlag(F.user)+"</td>");H.push('<td align="right">'+F.duels+"</td>");H.push('<td align="right">'+F.duelWins+"</td>");H.push('<td align="right">'+F.duelDraws+"</td>");H.push('<td align="right">'+F.duelLosts+"</td>");H.push('<td align="right"><strong>'+F.points.value+"</strong></td>");H.push('<td align="right">'+F.points.valueMax+"</td>");H.push("</tr>")}H.push("</tbody>");H.push("</table>");H.push('<p class="center small">'+l.gl("game.league.modified")+": "+fe.timeFormat(new Date(E.result.modified))+"</p>");H.push(this.paging(this.page,Math.ceil(E.result.count/this.PAGE_SIZE),5,"fe.page.league.getPage"));if(l.l["description.league"]){H.push('<div style="margin-top:20px;">'+l.l["description.league"]+"</div>")}}else{if(B.name=="Competition.GetPointsTable"&&B.arguments[2]==3){H.push("<table>");H.push('<col width="10%" />');H.push('<col width="55%" />');H.push('<col width="5%" />');H.push('<col width="30%" />');H.push("<thead>");H.push("<tr>");H.push('<th align="center">'+l.gl("game.league.position")+"</th>");H.push('<th align="left">'+l.gl("game.league.nick")+"</th>");H.push("<th>&nbsp;</th>");H.push('<th align="right">'+l.gl("game.league.points")+"</th>");H.push("</tr>");H.push("</thead>");H.push("<tbody>");var C;for(var D=0;D<E.result.items.length;D++){var F=E.result.items[D];var A="";if(F.user.userID==session.user.userID){A="highlight"}if(D%2==1){A+=" even"}H.push('<tr class="'+A+'">');H.push('<td align="center">'+(!C||C!=F.points.position?F.points.position+".":"")+"</td>");C=F.points.position;H.push('<td align="left">'+fe.userLink(F.user)+"</td>");H.push('<td align="center">'+fe.getFlag(F.user)+"</td>");H.push('<td align="right"><strong>'+fe.numFormat(F.points.value)+"</strong></td>");H.push("</tr>")}H.push("</tbody>");H.push("</table>");H.push('<p class="center small">'+l.gl("game.league.modified")+": "+fe.timeFormat(new Date(E.result.modified))+"</p>");H.push(this.paging(this.page,Math.ceil(E.result.count/this.PAGE_SIZE),5,"fe.page.league.getPage"));if(l.l["description.hallOfFame"]){H.push('<div style="margin-top:20px;">'+l.l["description.hallOfFame"]+"</div>")}}else{if(B.name=="Competition.GetEloTable"){H.push("<table>");H.push('<col width="10%" />');H.push('<col width="55%" />');H.push('<col width="5%" />');H.push('<col width="30%" />');H.push("<thead>");H.push("<tr>");H.push('<th align="center">'+l.gl("game.league.position")+"</th>");H.push('<th align="left">'+l.gl("game.league.nick")+"</th>");H.push("<th>&nbsp;</th>");H.push('<th align="right">'+l.gl("game.league.elo")+"</th>");H.push("</tr>");H.push("</thead>");H.push("<tbody>");var C;for(var D=0;D<E.result.items.length;D++){var F=E.result.items[D];var A="";if(F.user.userID==session.user.userID){A="highlight"}if(D%2==1){A+=" even"}H.push('<tr class="'+A+'">');H.push('<td align="center">'+(!C||C!=F.elo.position?F.elo.position+".":"")+"</td>");C=F.elo.position;H.push('<td align="left">'+fe.userLink(F.user)+"</td>");H.push('<td align="center">'+fe.getFlag(F.user)+"</td>");H.push('<td align="right"><strong>'+fe.numFormat(F.elo.value.toFixed(2))+"</strong></td>");H.push("</tr>")}H.push("</tbody>");H.push("</table>");H.push('<p class="center small">'+l.gl("game.league.modified")+": "+fe.timeFormat(new Date(E.result.modified))+"</p>");H.push(this.paging(this.page,Math.ceil(E.result.count/this.PAGE_SIZE),5,"fe.page.league.getPage"));if(l.l["description.elo"]){H.push('<div style="margin-top:20px;">'+l.l["description.elo"]+"</div>")}}}}}}geewa.writeHTML("leagueRanking",H.join(""));fe.fixPageHeight()},paging:function(A,D,F,B){var E=[];if(D>1){E.push('<p class="center">\n');if(A>0){E.push('<a href="javascript:void(0);" onclick="'+B+"("+(A-1)+');">&laquo; '+l.gl("gamesList.previous")+"</a> |\n")}for(var C=(A-F<0?0:A-F);C<A;C++){E.push('<a href="javascript:void(0);" onclick="'+B+"("+C+');">'+(C+1)+"</a> |\n")}E.push("<strong>"+(A+1)+"</strong>\n");for(var C=A+1;C<(A+F>D?D:A+F);C++){E.push('| <a href="javascript:void(0);" onclick="'+B+"("+C+');">'+(C+1)+"</a>\n")}if(A<(D-1)){E.push('| <a href="javascript:void(0);" onclick="'+B+"("+(A+1)+');">'+l.gl("gamesList.next")+" &raquo;</a>\n")}E.push("</p>")}return E.join("")}};fe.page.getUserData=function(A,B){geewa.server.ps.call(function(){fe.page.onUserData(arguments[0],arguments[1],B)},"Competition.GetMatches",fe.page.activity.activityID,global.competitionGroupID,fe.page.league.data.type,A)};fe.page.onUserData=function(M,C,D){var B=[];B.push('<table style="margin-bottom: 1em;">');var K=fe.tryValue(C,"result.competition.elo");if(K){B.push("<tr><td><strong>ELO:</strong></td><td>"+parseInt(K.value,10)+" "+l.gl("game.league.playerInfo.points")+", "+K.position+". "+l.gl("game.league.playerInfo.position")+"</td></tr>")}K=fe.tryValue(C,"result.competition.score");if(K){B.push('<tr><td style="padding-right: 10px;"><strong>'+l.gl("game.league.playerInfo.bestScore")+":</strong></td><td>"+K.value+" "+l.gl("game.league.playerInfo.points")+", "+K.position+". "+l.gl("game.league.playerInfo.position")+", "+l.gl("game.league.playerInfo.reached")+" "+fe.timeBefore(K.time)+"</td></tr>")}B.push("<tr><td><strong>"+l.gl("game.league.playerInfo.league")+":</strong></td><td>"+l.gl("game.league.playerInfo.played")+" "+fe.tryValue(C,"result.competition.total",0)+" "+l.gl("game.league.playerInfo.matches")+" ( "+fe.tryValue(C,"result.competition.wins",0)+" - "+fe.tryValue(C,"result.competition.draws",0)+" - "+fe.tryValue(C,"result.competition.losts",0)+" )");K=fe.tryValue(C,"result.competition.points");if(K){B.push(", "+K.value+" "+l.gl("game.league.playerInfo.points")+", "+K.position+". "+l.gl("game.league.playerInfo.position")+"</td></tr>")}B.push("</table>");var G=C.result.competition.matches;if(fe.page.league.data&&G){var L=[l.gl("global.sunday"),l.gl("global.monday"),l.gl("global.tuesday"),l.gl("global.wednesday"),l.gl("global.thursday"),l.gl("global.friday"),l.gl("global.saturday")];var A=[l.gl("global.january"),l.gl("global.february"),l.gl("global.march"),l.gl("global.april"),l.gl("global.may"),l.gl("global.june"),l.gl("global.july"),l.gl("global.august"),l.gl("global.september"),l.gl("global.october"),l.gl("global.november"),l.gl("global.december")];var I=["I","II","III","IV","V"];B.push('<div class="league-my-results" style="margin-top: 10px; padding-top: 10px;">');B.push('<div class="actual-round" style="width: 100%; margin: 0;">');B.push('<table style="width: 630px; margin: 0; border-bottom:1px solid #CCCCCC;">');B.push('<col width="7%">');B.push('<col width="8%">');B.push('<col width="23%">');B.push('<col width="7%">');B.push('<col width="7%">');B.push('<col width="12%">');B.push('<col width="5%">');B.push('<col width="12%">');B.push('<col width="7%">');B.push('<col width="12%">');B.push("<tr>");B.push('<th align="center">#</th>');B.push('<th align="center">'+l.gl("game.league.time")+"</th>");B.push("<th>"+l.gl("game.league.opponent")+"</th>");B.push("<th>&nbsp;</th>");B.push("<th>&nbsp;</th>");B.push('<th align="right">'+((M.arguments[3]==session.user.userID)?l.gl("game.league.yourScore"):l.gl("game.league.player"))+"</th>");B.push('<th align="center">:</th>');B.push("<th>"+l.gl("game.league.opponentScore")+"</th>");B.push("<th>&nbsp;</th>");B.push('<th align="right">'+l.gl("game.league.points")+"</th>");B.push("</tr>");B.push("</table>");B.push('<div id="holderMatches" style="height:270px; overflow-y:scroll; overflow-x: hidden;">');B.push('<table id="listMatches" style="width: 630px; margin: 0;">');B.push('<col width="7%">');B.push('<col width="8%">');B.push('<col width="23%">');B.push('<col width="7%">');B.push('<col width="7%">');B.push('<col width="12%">');B.push('<col width="5%">');B.push('<col width="12%">');B.push('<col width="7%">');B.push('<col width="12%">');var J;for(var F=0;F<G.length;F++){var E=G[F];var N=new Date(E.startTime);if(N.getDay()!=J){J=N.getDay();B.push('<tr><td colspan="10" style="font-weight: bold; background-color: #eee;">'+L[J]+"</td></tr>")}B.push("<tr>");B.push('<td align="center">'+(F+1)+"</td>");B.push('<td align="center">'+fe.timeFormat(N)+"</td>");if(E.opp_user){B.push("<td>"+fe.userLink(E.opp_user)+"</td>")}else{B.push("<td>"+l.gl("game.league.playerInfo.computer")+"</td>")}B.push('<td align="center">'+fe.getFlag(E.opp_user)+"</td>");if(!E.status||E.status<5){B.push('<td colspan="5" style="font-size:9px;color:green;text-align:center;cursor:help;" title="'+l.gl("game.league.playerInfo.liveTitle")+'">LIVE</td>')}else{B.push(fe.page.getMatchStatusText(E.status,true));B.push('<td align="right">'+(fe.page.activity.profile.score&&typeof(E.score)!=="undefined"?fe.numFormat(E.score):"-")+"</td>");B.push('<td align="center">:</td>');B.push('<td align="left">'+(fe.page.activity.profile.score&&typeof(E.opp_score)!=="undefined"?fe.numFormat(E.opp_score):"-")+"</td>");B.push(fe.page.getMatchStatusText(E.opp_status,false))}B.push('<td align="right">'+(E.points==-1?"":E.points)+"</td>");B.push("</tr>")}B.push("</table></div>");B.push("</div>");B.push("</div>");B.push('<div class="break"></div>')}else{B.push(l.gl("game.league.noMatchesInLeagueUser"))}geewa.writeHTML(D,B.join(""));var H=fe.getIDs("holderMatches","listMatches");if(H[0]&&H[1]){H[0].scrollTop=H[1].offsetHeight}};fe.page.getMatchStatusText=function(B,A){var C=[];C.push('<td style="font-size:9px;text-align:center;cursor:help;');switch(B){case 5:C.push('color:red;" title="'+l.gl("game.league.playerInfo.leftTitle")+'">LEFT');break;case 6:C.push('color:gray;" title="'+l.gl("game.league.playerInfo.gupTitle")+'">G-UP');break;case 7:C.push('color:gray;" title="'+l.gl("game.league.playerInfo.drawTitle")+'">DRAW');break;case 9:C.push('color:gray;" title="'+l.gl("game.league.playerInfo.dnfTitle")+'">DNF');break;case 0:case 1:case 8:default:C.push('">&nbsp;');break}C.push("</td>");return C.join("")};fe.page.onMessenger=function(){var A=arguments[0];switch(A.eventType){case"invitation":if(A.type=="start"){fe.page.game.start({type:"external",mode:"messenger",inviteUser:A.user})}break}};function __geewa_onEvent(){var A=arguments;window.setTimeout(function(){fe.page.game.onEvent.apply(fe.page.game,A)},0)};
