(function(B){var A=function(){var G=0,E=3,C=[0,0,0],J={cherry:[2,5,10],orange:[0,15,30],prune:[0,40,50],bell:[0,50,80],bar1:[0,0,100],bar2:[0,0,150],bar3:[0,0,250],seven:[0,0,500],anybar:[0,0,80]},I=[["orange","bell","orange","bar2","prune","orange","bar3","prune","orange","bar1","bell","cherry","orange","prune","bell","bar1","cherry","seven","orange","prune","orange","bell","orange"],["chery","prune","orange","bell","bar1","cherry","prune","bar3","cherry","bell","orange","bar1","seven","cherry","bar2","cherry","bell","prune","cherry","orange","cherry","prune","orange"],["cherry","orange","bell","prune","bar2","cherry","prune","orange","bar3","cherry","bell","orange","cherry","orange","cherry","prune","bar1","seven","bell","cherry","cherry","orange","bell"]],K=function(){B.ajax({type:"POST",url:"/ajax/coins.php",data:{func:"getCoins"},dataType:"json",success:function(N){if(N.coinsCount>0){G=N.coinsCount;B("#slotCredits").html(G);E=false;B("#slotSplash").animate({top:-130},1000,"bounceOut");if(G>=4){B("#slotTrigger").removeClass("slotTriggerDisabled")}else{B("#slotTrigger").addClass("slotTriggerDisabled")}B.ajax({type:"POST",url:"/ajax/coins.php",data:{func:"startSlotmachine"}})}else{B("#msg").text("Du bist nicht eingeloggt oder hast keine Punkte.").show();B("#msg").addClass("problem");B("#slotTrigger").addClass("slotTriggerDisabled")}}});this.blur();return false},D=function(){B("#slotSplash").animate({top:0},1000,"bounceOut")},H=function(N){B.ajax({type:"POST",url:"/ajax/coins.php",data:{func:"creditSlotmachineCoins",key:L,value:N},dataType:"json",success:function(P){if(P.key){updateGaime();L=P.key;N=P.incrementedBy;var O=G;G=P.coinsCount;B("#slotCredits").css("credit",0).animate({credit:N},{duration:400+N,easing:"easeOut",step:function(Q){B(this).html(parseInt(O+Q,10))},complete:function(){B(this).html(G)}})}else{B("#msg").text("Du bist nicht eingeloggt.").show();B("#msg").addClass("problem");B("#slotTrigger").addClass("slotTriggerDisabled")}}})},C=function(){this.blur();if(E==false){B.ajax({type:"POST",url:"/ajax/coins.php",data:{func:"debitSlotmachineCoins"},dataType:"json",success:function(N){if(N.key){L=N.key;G=N.coinsCount;E=3;B("#slotCredits").html(G);C[0]=parseInt(Math.random()*23);C[1]=parseInt(Math.random()*23);C[2]=parseInt(Math.random()*23);B("#slotTrigger").addClass("slotTriggerDisabled");B("img.slotSpinAnimation").show();B("#wheel1 img:first").css("top",-(C[0]*32+16)+"px");B("#wheel2 img:first").css("top",-(C[1]*32+16)+"px");B("#wheel3 img:first").css("top",-(C[2]*32+16)+"px");setTimeout(function(){M(1)},1500+parseInt(1500*Math.random()));setTimeout(function(){M(2)},1500+parseInt(1500*Math.random()));setTimeout(function(){M(3)},1500+parseInt(1500*Math.random()))}else{B("#msg").text("Du bist nicht eingeloggt.").show();B("#msg").addClass("problem");B("#slotTrigger").addClass("slotTriggerDisabled")}}})}return false},M=function(N){B("#wheel"+N).find("img:last").hide().end().find("img:first").animate({top:-C[N-1]*32},{duration:500,easing:"elasticOut",complete:function(){E--;if(E==0){F()}}})},F=function(){var P=I[0][C[0]],R=1,O=/bar/.test(P)?1:0,N=0,Q=10;if(P==I[1][C[1]]){R++;if(P==I[2][C[2]]){R++}else{if(O!=0&&/bar/.test(I[2][C[2]])){O++}}}else{if(O!=0&&/bar/.test(I[1][C[1]])){O++;if(/bar/.test(I[2][C[2]])){O++}}}if(R!=3&&O==3){P="anybar";R=3}var N=J[P][R-1];if(N>0){H(N);Q=410+N}setTimeout(function(){if(G<=3){setTimeout(function(){D()},1000)}else{B("#slotTrigger").removeClass("slotTriggerDisabled");E=false}},Q)},L=null;return{init:function(){B("#slotSplash a").bind("click",K);B("#slotTrigger").bind("mousedown",function(){B(this).addClass("slotTriggerDown")}).bind("click",C);B(document).bind("mouseup",function(){B("#slotTrigger").removeClass("slotTriggerDown")});B("#wheel1 img:first").css("top",-(parseInt(Math.random()*23)*32)+"px");B("#wheel2 img:first").css("top",-(parseInt(Math.random()*23)*32)+"px");B("#wheel3 img:first").css("top",-(parseInt(Math.random()*23)*32)+"px")}}}();B.extend(B.easing,{bounceOut:function(D,E,C,G,F){if((E/=F)<(1/2.75)){return G*(7.5625*E*E)+C}else{if(E<(2/2.75)){return G*(7.5625*(E-=(1.5/2.75))*E+0.75)+C}else{if(E<(2.5/2.75)){return G*(7.5625*(E-=(2.25/2.75))*E+0.9375)+C}else{return G*(7.5625*(E-=(2.625/2.75))*E+0.984375)+C}}}},easeOut:function(D,E,C,G,F){return -G*(E/=F)*(E-2)+C},elasticOut:function(D,F,C,J,I){var G=1.70158;var H=0;var E=J;if(F==0){return C}if((F/=I)==1){return C+J}if(!H){H=I*0.3}if(E<Math.abs(J)){E=J;var G=H/4}else{var G=H/(2*Math.PI)*Math.asin(J/E)}return E*Math.pow(2,-10*F)*Math.sin((F*I-G)*(2*Math.PI)/H)+J+C}});B(document).ready(A.init)})(jQuery);
