var displayErrorMessage=true;var soundEnabled=true;var tapEventName="click";var touchEventName="mousedown";var jsCommonVersion=0.5;var targetUsrID;var ignoreRotation=false;var withinIFrame=(top!=self);var usergamedata;var xService;var contextPath="";var currentBalance=0;var itemList=eval("[['beer',100,true],['kiss',100,true],['cigar',150,true],['martini',250,true],['whiskey',300,true],['cocktail',500,true],['champagne',1000,true],['cristal',5000,true],['TagAquaracer',2000,true],['balblair89',2000,true],['lvShades',2500,true],['lvBag1',3000,true],['lvBag2',3000,true],['goldRing',5000,true],['rolex',10000,true],['diamond',50000,true],['luxuryPhone',100000,true],['TheFreak',100000,true],['GoldCoins',200000,true],['porsche911Turbo',200000,true],['Ferrari458',300000,true],['luxuryPhone2',500000,true],['luxuryPhone2Pink',500000,true],['lamborghini',1000000,true],['BugattiVeyron',1300000,false],['gold',5000000,true],['mansion',15000000,true],['privateJet',100000000,true],['island1',200000000,true],['island2',500000000,true],['megaYacht',1000000000,true],['vipCard',-1,false],['penfolds',0,false],['macallan1947',0,false],['krug',0,false],['diamondSkull',0,false],['greekArtifact',0,false],['greekStatue',0,false],['allKnowingEye',0,false],['hublotDiamond',2000000,false]]");var balanceClassifications=eval("[[100,'DESTITUTE',''],[500,'POOR',''],[1000,'ROOKIE','krug'],[10000,'LEARNER','TagAquaracer'],[100000,'MODERATE','lvShades'],[250000,'PLAYER','luxuryPhone'],[500000,'SKILLED','penfolds'],[1000000,'PRO','Ferrari458'],[5000000,'MILLIONAIRE','macallan1947'],[10000000,'MULTI MILLIONAIRE','hublotDiamond'],[50000000,'WEALTHY','BugattiVeyron'],[100000000,'RICH','diamondSkull'],[500000000,'VERY RICH','greekArtifact'],[1000000000,'SUPER RICH','greekStatue'],[1700000000,'BILLIONAIRE','allKnowingEye']]");var heightPerFactor=130;var myErrorHandler=function(b,a){if(b=="NotEnoughCreditException"){$("#getMoreChipsDialog").show();log("SHOW buyChips dialog")}else{if(b=="FullTableException"){$(".objForPlayer").hide();$(".watcherPanel").show()}else{if(b=="No data received from server"){connectionLost()}else{if(b=="NotInRoomException"){connectionLost()}else{if(b=="NotLoggedInException"){showWarning("Reloading");backToGameLobby()}else{var c=getStackTraceAsStr(a);showWarning(c)}}}}}};function playSound(b){if(b==null||!soundEnabled){return}try{b.play()}catch(a){}}function stopSound(b){if(b==null){return}try{b.pause()}catch(a){}}function loadSound(a){var b=document.createElement("audio");try{b.setAttribute("src",a);b.load();b.addEventListener("load",function(){b.play();$(".duration span").html(b.duration);$(".filename span").html(b.src)},true)}catch(c){b=null}return b}function setCommonListeners(){makeChipsDraggable();makeGiftDraggable($("#selectedGift"));$(".hideChatBtn").bind(tapEventName,function(){hideChatPanel()});$(".chatBtnIcon").bind(tapEventName,function(){showChatPanel()});$(".smallChatSendBtn").bind(tapEventName,function(){sendChatMessage()});$(".showGiftsBtn").bind(tapEventName,function(){openGiftPanel()});$(".closeInnerDialogBtn").bind(tapEventName,function(){$(".giftPanel").hide()});$(".infoDialog .okBtn").live(tapEventName,function(){$(this).parent().remove()});$(".giftPanelItem").live(tapEventName,function(){if(!canAffordItem(this)){showWarning("You can't afford that item",600);return}$(".giftPanel").hide();var c=$(this).attr("id");var b=c.split("_")[1];log("selected "+b);if(targetUsrID!=null){sendGift(targetUsrID,b);targetUsrID=null}else{selectedChipValue=null;var a='';$(".selectedGiftImg").html(a);$(".selectedGiftActiveBg").show();$(".chipMenuBg").hide();selectedGiftName=b}})}function getNumberOfItems(b){var a=0;for(p in b.usergameprops){if(p.substring(0,2)=="G#"){a++}}return a}function openGiftPanel(){if($(".giftPanel").attr("data-populated")!="1"){for(i=0;i=b){return true}else{return false}}catch(a){return false}}function canBuyItem(b){var c=$(".giftPanelItemPrice",b).html();try{if(c.substring(1)!="?"){return true}else{return false}}catch(a){return false}}function sendGift(a,b){var c=$("#gift_"+b);if(a!=localPlayerID&&!canBuyItem(c)){showWarning("You can sent that gift to others")}else{if(canAffordItem(c)){xService.sendGift(a,b)}else{showWarning("You can't afford that item")}}}function makeGiftDraggable(a){a.bind(tapEventName,function(){$(".selectedGiftActiveBg").show();$(".chipMenuBg").hide()});a.draggable({start:function(d,e){var b=$("#selectedGift").position().left;var f=$("#selectedGift").position().top;$(".selectedGiftActiveBg").hide();$(".chipMenuBg").hide();var c=$(this).clone();$(this).parent().append(c);c.css({left:b+"px",top:f+"px"});makeGiftDraggable(c);$(this).css({"z-index":10});$(this).attr("id","draggedGift");$("#selectedGift > .selectedGiftActiveBg").show();log(a.attr("id")+" >>>START DRAG: **** "+selectedGiftName+" "+d.clientX+"Top: "+d.clientY)},stop:function(b,c){log("END DRAG GIFT: "+selectedGiftName);endDragGift(selectedGiftName,b.clientX,b.clientY,$(this));$(this).remove()}})}function endDragGift(e,d,c,b){var a=false;$(".playerInGame").each(function(k){var o=$(this).position().left;var m=$(this).position().top;var q=$(this).width();var j=$(this).height();var f=$(this).attr("usrID");if(f!=undefined){if(o<=d&&d<=o+q&&m<=c&&c<=m+j){a=true;log("GIFT SENT TO "+f);sendGift(targetUsrID,giftName);return}if(b!=undefined){var n=b.position();var g=b.width();var l=b.height();if(rectangleIntersects(o,m,q,j,n.left,n.top,g,l)){log("- GIFT SENT TO "+f);a=true;sendGift(f,e);return}}}});if(a){return}$(".selectedGiftActiveBg").hide();selectedChipValue=availableBetChips[0];$("#chipBg_"+selectedChipValue).show();log("NOBODY HERE TO SEND GIFT")}var selectedChipValue=0;var selectedGiftName="beer";function isChipSelectedMode(){return !$(".selectedGiftActiveBg").is(":visible")}var showDragAlert=true;function makeChipDraggable(b,a){b.bind(tapEventName,function(){$(".selectedGiftActiveBg").htapEventName;$(".chipMenuBg").hide();$("#chipBg_"+a).show();selectedChipValue=a});b.draggable({start:function(e,f){if(showDragAlert){showDragAlert=false}var c=$(this).position().left;var g=$(this).position().top;$(".selectedGiftActiveBg").hide();var d=$(this).clone();$(this).parent().append(d);d.css({left:c+"px",top:g+"px"});makeChipDraggable(d,a);selectedChipValue=a;$(this).css({"z-index":10});$(this).attr("id","draggedChip");$(".chipMenuBg").hide();$("#chipBtn_"+a+"> #chipBg_"+a).show();selectedChipValue=a},stop:function(c,d){$(this).remove();log("END DRAG");endDragChip(c,d)}})}function hideChatPanel(){$("#smallChat").hide();$(document).focus()}function showChatPanel(){$("#smallChat").show();$("#smallChatInputText").focus()}function sendChatMessage(){var textVal=$("#smallChatInputText").val();if(textVal.substring(0,2)=="./"){eval(textVal.substring(2))}else{if(textVal.substring(0,1)=="."){if(textVal==".help"){showWarning(".debug - show log
.testconn - testCallbacks
.sendlog - send the log")}else{if(textVal==".debug"){$("#logging").toggle()}else{if(textVal==".testconn"){lobbyService.testCallbacks()}else{if(textVal==".sendlog"){log(getVersion());$.post("/error",{subject:gamename+" console",error:$("#logging").html()},function(res){showWarning("Log sent to server "+res)})}}}}return}}if(textVal==null||textVal.length==0){hideChatPanel();return}else{$("#smallChatInputText").val("");var player=getPlayerHavingID(localPlayerID);if(player!=null){var playerSeat=player.seat;addChatMessage(textVal,playerSeat)}hideChatPanel();xService.chat(textVal)}}function setSelectedChip(a){selectedChipValue=a;$("#chipBg_"+a).show();$(".selectedGiftActiveBg").hide()}function makeChipsDraggable(){makeChipDraggable($("#chipBtn_1"),1);makeChipDraggable($("#chipBtn_5"),5);makeChipDraggable($("#chipBtn_25"),25);makeChipDraggable($("#chipBtn_50"),50)}function createChipsPile(a,m){a.html("");var d=m;var c=a;var f=0;for(var k=0;k");c.append(l);c=l;f++}d-=e*g;if(d<=0){break}}if(f>1){var b=$('
'+formatAccount(m)+"
");a.append(b);b.css({left:(a.width()-b.width())/2+"px"})}}function animateChips(h,g,e,d){var b=parseInt(h.position().left);var c=parseInt(h.position().top);var a=g-b;var f=e-c;h.css("display","inline");h.animate({left:"+="+a+"px",top:"+="+f+"px"},600,function(){if(d){h.remove()}})}var f0=20;var fstep=2;var levels=new Array();var generateUpTo=10;function generateLevelPoints(b){levels[0]=0;for(var a=1;ausergamedata.prevBestBalance){usergamedata.prevBestBalance=j;if(currentBalance!=0&&d>f[0]){var a=ctx+"/games_gfx/JoyplayCasino/items/"+c[2]+".png";var e=c[1];var g="Well done!";var b="You just moved up to the next wealth level with $"+j+"!
Share now.";showFlashingPanel2(g,b,a,function(k){if(k){var l={name:"Free bonus Item for ",link:"http://apps.facebook.com/JoyplayCasino?code=fromAchievement&ref="+localPlayerID,picture:a,caption:Joyplay.getFirstname()+" has just moved up to the next wealth level with $"+j,description:"",message:"",actions:[{name:"Play Stakez Casino now!",link:"http://apps.facebook.com/JoyplayCasino?ref="+localPlayerID}]};Joyplay.postToFeed(function(m){},l)}showChipTargetPanel()},"share","share")}}currentBalance=j}function animateBalance(a,b,e,c,d){if(e==0){if(c==false){$(""+a).html(b)}else{$(""+a).html("$"+formatAccount(b))}}else{adjustFieldVal(a,b,e,c,20,d)}}function adjustFieldVal(a,c,h,f,d,g){if(h!=0){var e=getBalanceStepAniation(h,d);var b=30;if(f==false){$(""+a).html(c+e)}else{$(""+a).html("$"+formatAccount(c+e))}setTimeout(function(){adjustFieldVal(a,c+e,h-e,f,(d-1),g)},b)}else{if(g!=null){g()}}}function getBalanceStepAniation(b,a){if(a==0){return b}else{return Math.floor(b/a)}}function getAvatarURL(a){var b="";if(a==null||a==""){b=contextPath+"/usergfx/default.gif"}else{if(a.indexOf("http://")<0){b=contextPath+a}else{if(a.indexOf("#FB_")==0){return"http://graph.facebook.com/"+a.substr(4)+"/picture"}else{return a}}}return b}var serverPostfix=["#","@"];function getUserName(d,b){if(b!=null&&b!=""){return b}else{if(d!=null&&d!=""){for(var c=0;c0){return d.substr(0,a)}}return d}else{return"user"}}}var days=24*60*60;var hours=60*60;function formatTime(d){if(d<0){return""}var c="";var e=d;var f=parseInt(e/days);if(f>0){c=f+"d ";e=e-days*f}var a=parseInt(e/hours);if(a>0){c+=a+":";e=e-hours*a}var b=parseInt(e/60);e=e-b*60;c+=(b>=10?b:"0"+b)+":"+(e>=10?e:"0"+e);return c}function formatTime2(d){if(d<0){return""}var c="";var e=d;var f=parseInt(e/days);if(f>0){c=f+" days ";e=e-days*f}var a=parseInt(e/hours);if(a>0){if(a==1){c+=a+" hour "}else{c+=a+" hours "}e=e-hours*a}var b=parseInt(e/60);e=e-b*60;if(b>0){c+=b+" minutes"}return c}function setExperiencePoints(h){try{var c=getLevel(h);var e=levels[c-1];var b=levels[c];var j=h-e;var d=parseInt((j/(b-e))*100);if($(".gameBar2 .experience").is(":visible")){$(".gameBar2 .experience .experienceText").html(h+"/"+b);var g=0;try{g=parseInt($(".gameBar2 .experienceLabel").html())}catch(f){log(f)}$(".gameBar2 .experienceLabel").html(c);if(g!=0&&c>g){var a={width:d+"%"};a.backgroundColor="#FFC500";$(".gameBar2 .experienceProgressBar").css("background","yellow");$(".gameBar2 .experienceProgressBar .star").show();$(".gameBar2 .experienceProgressBar .star").effect("puff",{},700,function(){$(".gameBar2 .experienceProgressBar").animate({width:"100%"},500).animate({width:"0%"},1000).animate(a,800,function(){$(".gameBar2 .experienceProgressBar").css("background","");var l=c*c*100;var k="You get a level up bonus of
"+l+" chips";showLevelNotificationDialog(h)})})}else{var a={width:d+"%"};a.backgroundColor="#FFC500";$(".gameBar2 .experienceProgressBar").css("background","yellow");$(".gameBar2 .experienceProgressBar .star").show();$(".gameBar2 .experienceProgressBar .star").effect("puff",{},500,function(){$(".gameBar2 .experienceProgressBar").animate(a,800,function(){$(".gameBar2 .experienceProgressBar").css("background","")})})}}}catch(f){error(f)}}function rcvGift(j,g,k){var t=j.from;var s=j.to;var u=j.giftName;var m=j.value;var l=getPlayerHavingID(t);var h=getPlayerHavingID(s);$("#giftReceived_"+s).remove();var n=$("
");var e='';n.html(e);n.attr("id","giftReceived_"+s);if(l!=null&&h!=null){g.append(n);var d=l.playerDiv.position().left+(l.playerDiv.width()-n.width())/2;var c=l.playerDiv.position().top+(l.playerDiv.height()-n.height())/2;n.css({left:d+"px",top:c+"px"});var o=n.clone();o.css("top",getStyleProp("giftPos"+h.seat,"top"));o.css("left",getStyleProp("giftPos"+h.seat,"left"));o.css("z-index",k);o.addClass("giftPos"+h.seat);o.addClass("invisible");h.playerDiv.append(o);var f=h.getGiftPosition(n);var b=o.offset().left;var a=o.offset().top;var r=b-d;var q=a-c;n.animate({opacity:1},200).animate({opacity:1},500).animate({left:"+="+r+"px",top:"+="+q+"px"},500,function(){n.css({left:b+"px",top:a+"px"});if(k!=undefined){o.removeClass("invisible");o.addClass("giftPos"+h.seat);o.css("top","");o.css("left","");o.css("right","");n.remove()}});if(t!=s&&s==localPlayerID){addChatMessage(l.playerShortName+" sent you a "+u,h.seat)}h.gift=n}else{if(l==null&&h!=null){var f=h.getGiftPosition(n);var b=f[0];var a=f[1];g.append(n);n.css({left:b+"px",top:a+"px"});if(k!=undefined){n.css("z-index",k)}h.gift=n}}if(s==localPlayerID){usergamedata.usergameprops["G#"+u]="1"}return n}function getUsergamedata(){return usergamedata}function showBonusPrizeDialog(a){if(a.usrID==localPlayerID){var c=getPlayerHavingID(a.usrID);c.setChips(a.balance);var b=Math.random();if(b<0.2){showCroupierMessage("Hey! I've just given you a $"+a.prize+" bonus because you're great!",2500)}else{if(b<0.4){showCroupierMessage("Have a $"+a.prize+" bonus because I'm feeling kind!",2500)}else{if(b<0.6){showCroupierMessage("I've just awarded you a $"+a.prize+" bonus because we love you!",2500)}else{if(b<0.8){showCroupierMessage("Thanks for playing! have a $"+a.prize+" bonus on the house!",2500)}else{showCroupierMessage("Here's a $"+a.prize+" bonus from me",2500)}}}}}setNextBonusTime(a.timePlayed*1000);log(a.timePlayed+" -----RCV PLAY BONUS="+a.prize+" NEW balance="+a.balance)}var connected=true;var reconnectTimeout;function connectionLost(){connected=false;showWarning("Reconnecting...",1500);log("About to try and rejoin the room");if(reconnectTimeout==null){log("setTimeout to try and rejoin room");reconnectTimeout=setTimeout(function(){if(gameInit==null){showWarning("gameInit is null")}reconnectTimeout=null;xService.start(getTargetRoomId(),hotel,Joyplay.getAccessToken(),{callback:gameInit,errorHandler:function(b,a){}})},1000)}else{log("reconnectTimeout is not null")}}var timeToSendPing=null;var pingSentTime=null;var pingConfirmTime=null;var pingDuration=20*1000;function sendPing(){var a=new Date();if(timeToSendPing==null){timeToSendPing=a.getTime()+pingDuration}else{if(timeToSendPinga&&pingConfirmTime==null){connectionLost();return true}return false}function getPlayerSeat(a){for(var b=0;b10){log("Image "+b+" failed to load. There is probably no internet connection at this time. Please refresh this page to try again later.");showWarning("Problem trying to load image "+b+" the internet connection is probably slow at this time. Please refresh if you experience problems");return}else{c++}}setTimeout(function(){loadImage(b,c,a)},1000)};a.src=b;return a}function imgLoaded(b){imgLoadedCount++;var a=(imgLoadedCount/imgToBeLoaded)*loadingBarWidth;if(a>loadingBarWidth){a=loadingBarWidth}debug(imgLoadedCount+" ["+a+" "+loadingBarWidth+"] loaded image "+b);$("#waitTimerBar").width(a);if(imgLoadedCount>=imgToBeLoaded-1){$("#firstScreen").animate({opacity:1},1500).animate({opacity:0.3},300,function(){$("#firstScreen").hide();$("#gameTable").show()})}}function setNextBonusTime(a){nextBonusTime=(new Date()).getTime()+a}var nextBonusTime=null;function showBonusTimeInfo(){if(nextBonusTime!=null){var b=new Date();var a=parseInt((nextBonusTime-b.getTime())/1000);if(a>0){$(".bonusTime").html("bonus in "+formatTime(a))}else{$(".bonusTime").html("bonus soon")}}}var values=[1,5,10,25,50,100,250,1000,5000,10000,50000,250000,1000000,10000000,100000000];var valArray=[1000000,250000,50000,10000,5000,1000,250,100,50,25,10,5,1];var availableBetChips=values.slice(0,3);function adjustChipsBetPanel(d){var l=parseInt(d/10);var j=values.length-1;for(var g=values.length-1;g>=0;g--){if(values[g]>=l&&g-1>=0&&values[g-1]").attr("id","chipBtn_"+a);var c=$("
").attr("id","chipBg_"+a);c.html('');var e=$("
");e.attr("data-chipVal",a);e.html('');b.append(c);b.append(e);$(".chipsPanel").append(b);makeChipDraggable(b,a);if(selectedChipValue!=null&&selectedChipValue==a){n=true}}if(h){if(n){setSelectedChip(selectedChipValue)}else{var m=values[j];for(var g=j;(gselectedChipValue){break}else{m=values[g]}}setSelectedChip(m)}}}var commonReadyCalled=false;var commonReady=function(){if(commonReadyCalled){return}commonReadyCalled=true;log("Setting socialListeners");$(".callInviteFriends").live(tapEventName,Joyplay.inviteFriends);$(".callUpdateFeed").live(tapEventName,Joyplay.postToFeed);$(".callSetStatus").live(tapEventName,Joyplay.setStatus);$(".callFanPage").live(tapEventName,Joyplay.fanPage);$(window).live("beforeunload",function(){displayErrorMessage=false});$("#menuBtn").live(tapEventName,function(){var b={};$("#menuContents").toggle()});$(".dialogPanel .close").live(tapEventName,function(){$("#menuContents").hide()});$(".hideOnClick").live(tapEventName,function(b){$(this).hide()});$("#lostConnectionBtn").live(tapEventName,backToGameLobby);$(".backToGameLobby").live(tapEventName,backToGameLobby);try{$(".goToMainLobby").live(tapEventName,goToMainLobby)}catch(a){}$("#openTellFriends").live(tapEventName,function(){$("#menuContents").hide()});$(".about").live(tapEventName,function(){$("#menuContents").hide();showWarning(gamename+" v"+getVersion())});$(".showHelp").live(tapEventName,function(){$("#menuContents").hide();showHelp()});$(".openAchievements").live(tapEventName,function(){$("#menuContents").hide();$(".extPanel").hide();try{$(".achievement").each(function(){var c=$(this).attr("data-achievement-type");for(i in usergamedata.achievements){if(usergamedata.achievements[i].name==c){$(".count",this).html("DONE")}}})}catch(b){error(b)}$("#achievementsPanel").show()})};function setLocalAvatar(a){$(".gameBar2 .avatar").attr("src",getAvatarURL(a))}function openUserProfile(a){openUserProfile2(a.usrID,getAvatarURL(a.avatar),getUserName(a.fullUserName,a.displayName),getLevel(a.experience),formatAccount(a.chips),a.uid)}function openUserProfile2(a,c,f,e,b,d){$(".profile").attr("data-usrId",a);$(".profile .avatar").html("");$(".profile .profileUsername").html(f);$(".profile .achievements").html();$(".profile .exp").html(e);$(".profile .profileBalance").html(b);$(".profile").show();$(".profile .openFullProfile").unbind(tapEventName);$(".profile .openFullProfile").bind(tapEventName,function(){Joyplay.showFullProfile(d);$(".profile").hide()});if($("#gameTable").length==0){$(".profile .openSendGift").hide()}else{$(".profile .openSendGift").show();$(".profile .openSendGift").bind(tapEventName,function(){targetUsrID=a;openGiftPanel();$(".profile").hide()})}}function showLevelNotificationDialog(b){var d=getLevel(b);var g="Level "+d+"!";var e="Great progress!
Share your fortune by sending your friends some chips!";var c=showInfoDialog;if(d>3){c=showFlashingPanel}var a="http://joyplay.com/games_gfx/JoyplayCasino/level"+d+".png";if(d>12){a="http://joyplay.com/games_gfx/JoyplayCasino/starPlayer.png"}c(g,e,function(f){if(f){var h={name:"10,000 free chips for first 5 clicks from friends!",link:"http://apps.facebook.com/JoyplayCasino?ref="+localPlayerID,picture:a,caption:"I just moved up to level "+d+" in Casino Party!",description:"That means friends of mine can get free chips now!",message:"",actions:[{name:"Play Stakez Casino!",link:"http://apps.facebook.com/JoyplayCasino?ref="+localPlayerID}]};Joyplay.postToFeed(function(j){},"",h)}},"levelUp","share")}function closeWindowCallback(a){log("closeWindowCallback recieved");showWarning("You are no longer active in this room, returning to the lobby");backToGameLobby()}var backToGameLobby=function(){showWarning("Returning to the lobby...",5000,"loadingRoom");leaveRoom();try{goToGameLobby()}catch(a){window.location.reload()}};function getVersion(){var c="?";try{c=getGameVersion()}catch(b){log("unable to getGameVersion")}var a="?";try{a=getLobbyVersion()}catch(b){log("unable to getGameVersion")}return jspVersion+"-"+jsCommonVersion+"-"+a+"-"+c}function achievementCallback(c){if(c.usrId==localPlayerID){var b=c.name+"! Well done!";var a="You win "+c.prize+"
Tell your friends now.";showFlashingPanel(b,a,function(d){if(d){var e={name:"First 5 clicks get 10,000 free chips",link:"http://apps.facebook.com/JoyplayCasino?code=fromAchievement&ref="+localPlayerID,picture:"http://joyplay.com/games_gfx/JoyplayCasino/bigDollarSymbol.png",caption:Joyplay.getFirstname()+" just completed the "+c.name+" achievement in Casino Party and won "+c.prize,description:"",message:"",actions:[{name:"Play Stakez Casino!",link:"http://apps.facebook.com/JoyplayCasino?ref="+localPlayerID}]};Joyplay.postToFeed(function(f){},e)}},"share","share");getMyPlayer().setChips(getMyPlayer().playerInfo.chips+c.prize)}}function showInfoDialog(g,a,h,j,k,b){if(j!=null&&$(".dialog[data-tag='"+j+"']").length>0){return}if(g==null||g==undefined){g=""}if(a==null||a==undefined){a=""}if(k==null||k==undefined){k="ok"}if(b==null||b==undefined){b="cancel"}var c=$('
'+g+'
'+a+"
");var e=$('
'+k+"
");var f=$('
'+b+"
");e.bind(tapEventName,function(){removeDialog(c);if(h!=undefined&&h!=null){h(true)}});f.bind(tapEventName,function(){removeDialog(c);if(h!=undefined&&h!=null){h(false)}});if(j!=null){c.attr("data-tag",j)}c.append(e);c.append(f);$("body").prepend(c);openDialog(c)}function showInfoDialog2(k,e,b,h,a,g,l){if(l!=null&&$(".dialog[data-tag='"+l+"']").length>0){return}if(k==null||k==undefined){k=""}if(e==null||e==undefined){e=""}if(b==null||b==undefined){b="ok"}if(a==null||a==undefined){a="ok"}var j=$('
'+k+'
'+e+"
");var f=$('
'+b+"
");var c=$('
'+a+"
");f.bind(tapEventName,function(){j.remove();if(h!=undefined&&h!=null){h(true)}});c.bind(tapEventName,function(){j.remove();if(g!=undefined&&g!=null){g(false)}});if(l!=null){j.attr("data-tag",l)}j.append(f);j.append(c);$("body").prepend(j);j.show()}function showOkInfoDialog(g,f,c,h,a){if(a!=null&&$(".infoDialog[data-tag='"+a+"']").length>0){return}if(g==null||g==undefined){g=""}if(f==null||f==undefined){f=""}var e=$('");var b=$('
'+c+"
");b.bind(tapEventName,function(){e.remove();if(h!=undefined&&h!=null){h(true)}});if(a!=null){e.attr("data-tag",a)}e.append(b);$("body").prepend(e);openDialog(e)}function showSpecialDialog(h,g,j,b,a){if(b!=null&&$(".dialog[data-tag='"+b+"']").length>0){return}if(h==null||h==undefined){h=""}if(g==null||g==undefined){g=""}if(a==null||a==undefined){a="ok"}var f=$('
'+h+'
'+g+"
");var c=$('
'+a+"
");var e=$('
continue
');c.bind(tapEventName,function(){f.remove();if(j!=undefined&&j!=null){j(true)}});e.bind(tapEventName,function(){f.remove();if(j!=undefined&&j!=null){j(false)}});if(b!=null){f.attr("data-tag",b)}f.append(c);f.append(e);$("body").prepend(f);f.show()}function showFlashingPanel(g,b,h,k){var e=$('
'+g+'
'+b+'
Share
continue
');if(k!=null){e.attr("data-tag",k)}$("body").append(e);$(".specialDialog .okBtn").bind(tapEventName,function(){e.remove();h(true)});$(".specialDialog .no").bind(tapEventName,function(){e.remove();h(false)});var j=11;var a=21;var f='';$(".specialDialog .sideLights").html("");for(var c=0;c
'+g+'
'+b+'
Share
continue
');if(l!=null){e.attr("data-tag",l)}$("body").append(e);$(".specialDialog .okBtn").bind(tapEventName,function(){e.remove();h(true)});$(".specialDialog .no").bind(tapEventName,function(){e.remove();h(false)});var j=11;var a=21;var f='';$(".specialDialog .sideLights").html("");for(var c=0;c0){b-=1}return balanceClassifications[b]}}return[a*2,"GOD",""]}function getStatusIcon(a){return getCurrentBalanceClass(a)[2]+".png"}function getNextBalanceClassAmount(a){return getNextBalanceClass(a)[0]}function getNextBalanceClass(a){for(var b=0;b
");$("body").append(c);var a=c.css("left");c.css("left","-15em");c.show();c.animate({left:a},300,function(){$(".msg",c).show();setTimeout(function(){$(".msg",c).hide();c.animate({left:"+=15em"},300,function(){c.remove()})},b)})}function closeWindowCallback(){backToGameLobby()}function initStatusPanel(f){$(".closeStatusPanel, .openGetChips").bind(tapEventName,function(){$(".statusPanel").hide()});var b=formatAccount(f.balance);var c=getBalanceClassification(f.balance);$(".statusPanel .status").html(c);$(".statusPanel #wealth").html("Wealth - $"+b);var h=((getHeightFromChips(f.balance)-(heightPerFactor-30))/1000)*100;$(".statusPanel #wealthBarInner").css("width",h+"%");if(f.prevBestBalance>f.balance){var g=formatAccount(f.prevBestBalance);$(".statusPanel #prevBest").html(g);$(".buyPrevBest").bind(tapEventName,function(j){Joyplay.redeem(575,"PREV_BEST","Return to your previous best balance",gamename)})}else{$(".previousBest").hide()}var e=getLevel(f.experience);var a=e*3;if(a>100){a=100}$(".statusPanel #experience").html(e);$(".statusPanel #expBarInner").css("width",a+"%");var d=parseInt(f.achievements.length);if(d>0){d=d/10}$(".statusPanel #challengesBarInner").css("width",d+"%");$(".statusPanel").show()}function notificationMsgCallback(a){showInfoDialog(a)}function recordPostToUser(e,g){try{var h="giftsSent";var a=new Object();var k="uid"+e;var j=$.cookie(h);if(j!=null&&j!=""){a=$.parseJSON(j)}var b=0;if(a[k]!=null){b=parseInt(a[k])}var d=1000*60*60*4;if(new Date().getTime()>b+d){a[k]=new Date().getTime();var c=JSON.stringify(a);$.cookie(h,c);return true}else{return false}}catch(f){error(f);return true}}var dialogQueue=new Array();function openDialog(b,a){var c=$(".dialog:visible");if($(".dialog:visible").length==0&&dialogQueue.length==0){$(b).show();if(a!=null){setTimeout(function(){$(b).hide()},2000)}}else{log("Dialog "+b+" pushed onto queue");dialogQueue.push(b)}}function forceOpenDialog(a,b){$(a).show()}function hideDialog(a){$(a).hide();showNextDialog()}function removeDialog(a){$(a).remove();showNextDialog()}function showNextDialog(){var a=dialogQueue.shift();if(a!=null){log("Dialog "+a+" retreived and displayed from queue");setTimeout(function(){$(a).show()},2500)}};