var noPlayers=10;var cardSelectionSuccessfull=true;var selectedTableCard=-1;var selectedCards=new Array();var isCardUsed=new Array();var disclaimer="Disclaimer/Terms of use:  The odds generated by this tool are usually calculated by a random simulation.  As such the odds will represent an approximation of the true odds.  While understanding the odds of a given poker hand being the best hand at the table is an important aspect of good poker strategy, it is not the only component of good strategy.  The use of this tool will in no way guarantee winning money at poker.  This tool is provided for use free of charge.  The provider of this tool does not guarantee the accuracy of the results and accepts no liability for any loss that may occur as a result of the use of this tool. By clicking OK, you have accepted the terms of this disclaimer, if you do not agree with the terms of this disclaimer, click Cancel";var disclaimerAccepted=false;var engineURL="/cgi-bin/test/Engine50CGI.cgi";var calcOddsNo=0;function getClientCardIndex(a,b){return(b-1)*4+a}function getSuitFromClientIndex(a){return((a-1)%4)+1}function getFaceFromClientIndex(a){return Math.floor((a-1)/4)+1}function getCardServerIndexFromClientIndex(e){var d=getFaceFromClientIndex(e);var c=getSuitFromClientIndex(e);var b=13-d;var a;if(c==1){a=0}if(c==2){a=3}if(c==3){a=2}if(c==4){a=1}return 13*a+b}function init(){for(i=0;i<25;i++){selectedCards[i+1]=-1}for(i=0;i<52;i++){isCardUsed[i+1]=false}}function deckCardClick(c,d){var b=getClientCardIndex(c,d);if(isCardUsed[b]){return}if(selectedTableCard==-1){alert("Please select a card on the table before selecting a card in the deck.");return}selectedCards[selectedTableCard]=b;setTableCardImage(selectedTableCard,"images/PokerCards/Cards/"+b+".png");setDeckCardVisable(b,false);var a=selectedTableCard;selectedTableCard=-1;if((a<=10)&&(selectedCards[a+10]==-1)){tableCardClick(a+10)}if((a>10)&&(a<=20)&&(selectedCards[21]==-1)){tableCardClick(21)}if((a>20)&&(a<=24)&&(selectedCards[a+1]==-1)){tableCardClick(a+1)}}function tableCardClick(a){if(selectedTableCard==a){return}if(selectedTableCard!=-1){setTableCardImage(selectedTableCard,"images/PokerCards/Cards/b1fv.png")}selectedTableCard=a;setTableCardImage(a,"images/PokerCards/Cards/b2fv.png");if(selectedCards[a]!=-1){setDeckCardVisable(selectedCards[a],true);selectedCards[a]=-1}}function setTableCardToUnselectedUnknown(a){if(selectedTableCard==a){selectedTableCard=-1}if(selectedCards[a]!=-1){setDeckCardVisable(selectedCards[a],true);selectedCards[a]=-1}setTableCardImage(a,"images/PokerCards/Cards/b1fv.png")}function setTableCardImage(c,b){if((c<1)||(c>25)){return}if(c<11){var a=document.getElementById("Play"+c+"C1");a.src=b}else{if(c<21){var a=document.getElementById("Play"+(c-10)+"C2");a.src=b}else{if(c<24){var a=document.getElementById("flop"+(c-20));a.src=b}else{if(c==24){document.getElementById("turn").src=b}else{if(c==25){document.getElementById("river").src=b}}}}}}function setPlayerCardsVisible(a,b){if(b){document.getElementById("Play"+a+"C1").style.display="block";document.getElementById("Play"+a+"C2").style.display="block";document.getElementById("Player"+a+"Text").style.display="block"}else{document.getElementById("Play"+a+"C1").style.display="none";document.getElementById("Play"+a+"C2").style.display="none";document.getElementById("Player"+a+"Text").style.display="none"}}function getDeckImageControlName(c){var b=getSuitFromClientIndex(c);var d=getFaceFromClientIndex(c);var e="";if(b==1){e+="C"}else{if(b==2){e+="S"}else{if(b==3){e+="H"}else{if(b==4){e+="D"}}}}if(d==1){e+="A"}else{if(d==2){e+="K"}else{if(d==3){e+="Q"}else{if(d==4){e+="J"}else{if(d==5){e+="T"}else{var a=15-d;e+=a}}}}}return e}function getDeckImageName(d){var c=getSuitFromClientIndex(d);var e=getFaceFromClientIndex(d);var a="images/PokerCards/Icons/";if(c==1){a+="Club/"}else{if(c==2){a+="Spade/"}else{if(c==3){a+="Heart/"}else{if(c==4){a+="Diamond/"}}}}if(e==1){a+="A"}else{if(e==2){a+="K"}else{if(e==3){a+="Q"}else{if(e==4){a+="J"}else{if(e==5){a+="T"}else{var b=15-e;a+=b}}}}}a+=".jpeg";return a}function setDeckCardVisable(b,a){if(a){isCardUsed[b]=false}else{isCardUsed[b]=true}if(a){document.getElementById(getDeckImageControlName(b)).src=getDeckImageName(b)}else{document.getElementById(getDeckImageControlName(b)).src="images/PokerCards/Icons/black.jpg"}}function selectNoPlayers(){noPlayers=document.getElementById("NoPlayersDD").selectedIndex+2;for(i=3;i<=10;i++){if(noPlayers<i){removeAdvanced(i);setPlayerCardsVisible(i,false);if(selectedTableCard==i){setTableCardImage(i,"images/PokerCards/Cards/b1fv.png");selectedTableCard==-1}if(selectedTableCard==10+i){setTableCardImage(10+i,"images/PokerCards/Cards/b1fv.png");selectedTableCard==-1}if(selectedCards[i]!=-1){setDeckCardVisable(selectedCards[i],true);selectedCards[i]=-1;setTableCardImage(i,"images/PokerCards/Cards/b1fv.png")}if(selectedCards[10+i]!=-1){setDeckCardVisable(selectedCards[10+i],true);selectedCards[10+i]=-1;setTableCardImage(10+i,"images/PokerCards/Cards/b1fv.png")}}else{if(_playersHandSpecs[i-1]==null){setPlayerCardsVisible(i,true)}}}var c=document.getElementById("AdvancedPlayerNoDD");var b=c.length;var a=c.selectedIndex;while(b>noPlayers){c.remove(noPlayers);b=c.length}while(b<noPlayers){c.options.add(new Option("Player "+(b+1),(b+1)));b=c.length}if(a>=noPlayers){c.selectedIndex=0;advancedSelectPlayerNo()}}function simulate(){document.getElementById("resultTable").innerHTML="";document.getElementById("HandTypeResults").innerHTML="";var b=false;for(i=1;i<=20;i++){if(selectedCards[i]>-1){b=true;break}}if(!disclaimerAccepted){if(!confirm(disclaimer)){return}else{disclaimerAccepted=true}}var a="NP="+noPlayers;for(j=1;j<=10;j++){if(_playersHandSpecs[j-1]!=null){a=a+"&P"+j+"HandSpec="+_playersHandSpecs[j-1].getHandRangeString("-")}else{if(selectedCards[j]>-1){a=a+"&P"+j+"C1="+getCardServerIndexFromClientIndex(selectedCards[j])}if(selectedCards[10+j]>-1){a=a+"&P"+j+"C2="+getCardServerIndexFromClientIndex(selectedCards[10+j])}}}for(i=1;i<=3;i++){if(selectedCards[20+i]>-1){a+="&F"+i+"="+getCardServerIndexFromClientIndex(selectedCards[20+i])}}if(selectedCards[24]>-1){a+="&T="+getCardServerIndexFromClientIndex(selectedCards[24])}if(selectedCards[25]>-1){a+="&R="+getCardServerIndexFromClientIndex(selectedCards[25])}calcOddsNo=calcOddsNo+1;a+="&CalcNo="+calcOddsNo+"&AdFor="+adFor;loadSimResult(a)}function clearDeck(){document.getElementById("resultTable").innerHTML="";document.getElementById("HandTypeResults").innerHTML="";if(selectedTableCard!=-1){setTableCardImage(selectedTableCard,"images/PokerCards/Cards/b1fv.png")}selectedTableCard=-1;for(i=1;i<=25;i++){setTableCardImage(i,"images/PokerCards/Cards/b1fv.png");if(selectedCards[i]!=-1){setDeckCardVisable(selectedCards[i],true);selectedCards[i]=-1}}for(i=0;i<noPlayers;i++){if(_playersHandSpecs[i]!=null){removeAdvanced(i+1)}}}function SetCookie(e,d,c){var b=new Date();var a=new Date();if(c==null||c==0){c=1}a.setTime(b.getTime()+3600000*24*c);document.cookie=e+"="+escape(d)+";expires="+a.toGMTString()}var xmlhttp;function loadSimResult(a){xmlhttp=null;if(window.XMLHttpRequest){xmlhttp=new XMLHttpRequest()}else{if(window.ActiveXObject){xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}}if(xmlhttp!=null){document.getElementById("SimulateButtonID").disabled=true;xmlhttp.onreadystatechange=setResult;xmlhttp.open("POST",engineURL,true);xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");xmlhttp.send(a)}else{alert("Error: Your browser does not support the technology to retrieve the simulation result.")}}function setResult(){var adString=getResultAdString();if(xmlhttp.readyState==4){document.getElementById("SimulateButtonID").disabled=false;if(xmlhttp.status==200){var jsondata=eval("{"+xmlhttp.responseText+"}");if(jsondata[0]==1){alert(jsondata[1]);return}document.getElementById("resultTable").innerHTML=jsondata[3]+'\n<div style="width:184px;">\n<center>\n\n<b>\n<br><center><a href="javascript:window.scrollTo(0, getHandTypePosition())">See Hand Types</a></center><br></b>\n</center>\n</div>\n'+jsondata[2]+adString;document.getElementById("HandTypeResults").innerHTML='<center><a name="hand_types_section"></a><br><hr><br><a href="javascript:window.scrollTo(0, getHandType1TopPosition())">Hand Types for Players and Winning Hands</a><br><br><a href="javascript:window.scrollTo(0, getHandType2TopPosition())">Hand Types for Players When That Player Has a Win or a Tie</a><br><br><a href="javascript:window.scrollTo(0, getHandType3TopPosition())">% Equity For Players When That Player Has a Given Hand Type</a><br><br><hr><div id="handtype"><a name="hand_types_for_players_section"><div style="font-size:13pt">Hand Types for Players and Winning Hands</div><br><br><div id="handTypeChart" class="chart" style="width: 590px; height: 300px;"></div><br><br>'+jsondata[4]+'\n<br></div><hr><div id="handtypewinner"><a name="hand_types_for__winning_players_section"><br><div style="font-size:13pt">Hand Types for Players When That Player Has a Win or a Tie</div><br><br><div id="winningHandTypeChart" class="chart" style="width: 590px; height: 300px;"></div><br><br>'+jsondata[5]+'\n\n<br></div><hr><div id="handtypeequity"><a name="hand_types_equity_section"><br><div style="font-size:13pt">% Equity For Players When That Player Has a Given Hand Type</div><br><br><div style="width:580px">Here we present %equity for players when that player observes a given hand type.  %Equity is basically %win with %tie divided between the number of players splitting the pot.  The data in this section should be considered a rough approximation only.  To understand the reason for this it is useful to consider how many rounds are being dealt in the simulation.  The number of rounds where a given player has, for example a full house is much less than the number of rounds dealt in the whole simulation.  With less rounds dealt, the number estimated from these rounds will be less accurate.  This is particularly the case for hand types that have a low percentage chance of occurring.  While understanding that these numbers should be treated as rough approximations, we do however believe this is some useful data to be looking at, so enjoy.</div><br><br><div id="equityHandTypeChart" class="chart" style="width: 590px; height: 300px;"></div><br><br>'+jsondata[6]+"\n<br></div><br><hr>";drawChart(jsondata)}else{alert("Problem retrieving simulation result:"+xmlhttp.statusText)}}}function drawChart(b){var f=b[7];var g=f[0].length;var d=new Array(12);d[0]="#FFFFFF";d[1]="#CC0000";d[2]="#FFFF00";d[3]="#666633";d[4]="#66FF00";d[5]="#FF9933";d[6]="#FF66FF";d[7]="#006633";d[8]="#3333CC";d[9]="#33FFCC";d[10]="#FFCCFF";d[11]="#00FF33";$("#handTypeChart").chartInit({painterType:"jsgraphics",backgroundColor:"black",textColor:"white",axesColor:"white",yMin:"0",yMax:f[2],xGrid:"0",yGrid:"10",xLabels:["High Card","Pair","2 Pair","3 Kind","Str8","Flush","Full H.","Quads","Sr8 Flush"],showLegend:false});for(i=0;i<g;i++){$("#handTypeChart").chartAdd({label:f[0][i],seriesNum:i,type:"Bar",color:d[i],values:f[1][i]})}$("#handTypeChart").chartClear().chartDraw();var e=b[8];var c=f[0].length;$("#winningHandTypeChart").chartInit({painterType:"jsgraphics",backgroundColor:"black",textColor:"white",axesColor:"white",yMin:"0",yMax:e[2],xGrid:"0",yGrid:"10",xLabels:["High Card","Pair","2 Pair","3 Kind","Str8","Flush","Full H.","Quads","Sr8 Flush"],showLegend:false});for(i=0;i<c;i++){$("#winningHandTypeChart").chartAdd({label:e[0][i],seriesNum:i,type:"Bar",color:d[i],values:e[1][i]})}$("#winningHandTypeChart").chartClear().chartDraw();var a=b[9];var h=f[0].length;$("#equityHandTypeChart").chartInit({painterType:"jsgraphics",backgroundColor:"black",textColor:"white",axesColor:"white",yMin:"0",yMax:a[2],xGrid:"0",yGrid:"10",xLabels:["High Card","Pair","2 Pair","3 Kind","Str8","Flush","Full H.","Quads","Sr8 Flush"],showLegend:false});for(i=0;i<h;i++){$("#equityHandTypeChart").chartAdd({label:a[0][i],seriesNum:i,type:"Bar",color:d[i],values:a[1][i]})}$("#equityHandTypeChart").chartClear().chartDraw()}init();
