//-------------------------------------------------------------------------BET FUNCTIONS
var ps = "";
var pl = "";
var pn = "";
//-------------------------------------------------------------------------DISPLAY POOLS
function DisplayWagers(){
var Pools = document.getElementById("PoolsPanel");
Pools.innerHTML = "";
poolLong = [];
poolShort = [];
pls = plss[rac];
pll = plls[rac];
poolLong = pll.split(",");
poolShort = pls.split(",");
poolMinUnit = [];
poolMinBet = [];
pmu = pmus[rac];
pmb = pmbs[rac];
poolMinUnit = pmu.split(",");
poolMinBet = pmb.split(",");
for(var i = 0; i <= poolLong.length-1; i++) {
var element1 = document.createElement('input');
element1.type = 'button';
element1.name = 'PoolBtns' + i;
element1.id = i;
element1.value = poolLong[i];
element1.className = 'btn btn-primary';
element1.style.height = '25px';
element1.style.textAlign = 'center';
element1.style.letterSpacing = '1px';
element1.style.fontSize = '11px';
element1.style.margin = '1px';
element1.onclick=function(){
SelectPool(this.id);
};
Pools.appendChild(element1);
}
}
//-------------------------------------------------------------------------SELECT POOL
function SelectPool(a){
ClearBet();
tps = poolShort[a];
tpl = poolLong[a];
tmu = poolMinUnit[a];
tmb = poolMinBet[a];
if(tps=="DD" ||tps=="DB"||tps=="TT"||tps=="TS"){leg = 1; }
else if(tps=="P3" || tps=="PK3"){leg=2;}
else if(tps=="P4" || tps=="PK4"||tps=="Q4"||tps=="J4"){leg=3;}
else if(tps=="P5" || tps=="PK5"){leg=4;}
else if(tps=="P6" || tps=="PK6"||tps=="C6"||tps=="T6"||tps=="J6"||tps=="V6"||tps=="W6"){leg=5;}
else if(tps=="P7" || tps=="PK7"||tps=="C7"||tps=="V7"){leg=6;}
else if(tps=="P8" || tps=="PK8"){leg=7;}
else if(tps=="P9" || tps=="PK9"){leg=8;}
else if(tps=="PA"){leg=6;}
else {leg=0;}
if(leg > 0){
document.getElementById("withBtn").innerHTML = "Next Leg";
}
else{
document.getElementById("withBtn").innerHTML = "With";
}
document.getElementById('wagertxt').value = tps;
DisplayBet();
}
//-------------------------------------------------------------------------SELECT DOLLAR
function SelectDol(a){
//toggle cash add switch if n=99
if(a==99){
if(csw==0){csw=1;}
else{csw=0;}
}
else {
if(csw==1){
dol=(dol + dx[a]);
}
else {
dol = dx[a];
}
csw=0;
document.getElementById('doltxt').value = "$ " + dol;
}
}
function ClearDol(){
document.getElementById('doltxt').value = "$";
dol = "";
}
//-------------------------------------------------------------------------SET BET
function SetBet(){
leg=0;
lex=0;
checkBet();
amt = bct*dol;
amt = Math.round(amt * 100) / 100;
if(amt < tmb) {
$('#InfoModal').modal('show');
document.getElementById('exmtxt').innerHTML = 'Insufficient Stake ' + '( $' + amt + ' )';
document.getElementById('bettxt1').innerHTML = tpl + ' - Minimum Bet Amount is $' + tmb;
document.getElementById('bettxt1').className = 'text-danger';
document.getElementById('bettxt2').innerHTML = ' ';
document.getElementById('bettxt3').innerHTML = ' ';
document.getElementById('bettxt4').innerHTML = ' ';
}
else if(dol < tmu) {
$('#InfoModal').modal('show');
document.getElementById('exmtxt').innerHTML = 'Insufficient Stake ' + '( $' + dol + ' )';
document.getElementById('bettxt1').innerHTML = tpl + ' - Minimum Bet Unit is $' + tmu;
document.getElementById('bettxt1').className = 'text-danger';
document.getElementById('bettxt2').innerHTML = ' ';
document.getElementById('bettxt3').innerHTML = ' ';
document.getElementById('bettxt4').innerHTML = ' ';
}
else{
displayBet();
ClearTable_Ticket();
$('#TicketModal').modal('show');
var table = document.getElementById('TicketTable');
var row0 = table.insertRow(0);
var cell0 = row0.insertCell(0);
cell0.style.paddingLeft = "25px";
cell0.innerHTML = '
' + trk + " Race " + rac + '
';
var row1 = table.insertRow(1);
var cell1 = row1.insertCell(0);
cell1.style.paddingLeft = "50px";
cell1.innerHTML = '' + "$ " + dol + " " + tpl + " " + tzt + '
';
var row2 = table.insertRow(2);
var cell2 = row2.insertCell(0);
cell2.style.paddingLeft = "50px";
cell2.innerHTML = '' + "Total Bet: " + ext + amt + '
';
}
}
//-------------------------------------------------------------------------DISPLAY BET
function displayBet(){
if(txt != ""){
var a = ""; //each character
var b = ""; //postcoded char
var c = ""; //last char
var i = 0;
tzt = "";
for(i = 0; i < txt.length; i++){ //---------------convert xx/xxx /xxx => x,x/x,x,x/x,x,x
a = txt.substr(i,1);
if(a == "/"){
tzt += a;
c = a;
}
else if(a == "#"){
tzt += "ALL";
}
else {
b = postCodec(0,a);
if(c == "/" || i==0){
tzt += b;
}
else {
tzt += "," + b;
}
c=a;
}
}
}//note last char
if(prm == "BOX"){
a="BOX";
}
else{
a="";
}
if(tzt == ""){
tzt = " ";
}
document.getElementById('wagertxt').value = tps + " " + a + " " + tzt;
}
//-------------------------------------------------------------------------BUILD BET
function buildBet(a){
if(stx == 0){ //if not in bet-set mode
//------------------ALL can only be followed by /
if(lky == "#"){
a = "/";
}
//------------------
if (a == "/"){
if(lky != "/"){
prm = "KEY";
lky = "/";
txt += "/";
//-----decrement leg count/increment leg index
if(leg > 0 && lex < leg){
lex++;
leg_rac = rac*1+lex;
GetLegRunners(leg_rac);
}
}
}
else if(a == "ALL"){
if(lky == "/"){
txt += "#";
}
else{
txt += "#";
}
lky = "#";
atx = "";
//for(var j = 1; j<=mxr; j++){
//atx += postCodec(j, "");
//}
atx = Runners;
}
else if(a == "BOX"){
prm = "BOX";
}
displayBet();
}
}
//-------------------------------------------------------------------------CHECK BET calculate number of bet combinations
function checkBet() {
var a = "";
var b = "";
var c = "";
var d = "";
var i = 0;
var j = 0;
var k = 0;
var m = 0;
var np = 0; //upper bound of split bettxtx string
var pp = 0; //parts count
var xa = 0; //length of parts
var xb = 0;
var xc = 0;
var xd = 0;
//split the bet text and convert to option base1 for convenience up to 9 parts
var pt = new Array();
var p = new Array();
if(txt.indexOf("/") > 0){
p = txt.split("/");
np = p.length;
//-----------------------------------------------------------------------------------
if(tps == "TRI" || tps == "TR" && np == 2){
txt += "/" + p[1];
p = txt.split("/");
np = p.length;
}
else if(tps == "SUP" || tps == "SU" && np==2){
if(np==2){
txt += "/" + p[1] + "/" + p[1];
p = txt.split("/");
np = p.length;
}
if(np==3){
txt += "/" + p[1];
p = txt.split("/");
np = p.length;
}
}
//-----------------------------------------------------------------------------------
for(i = 0; i = 0){
pt[i+1]=atx;
}
else{
pt[i+1]=p[i];
}
}
}
else if(txt.indexOf('#') >= 0){
pt[1] = atx;
}
else{
pt[1] = txt;
}
//-------------------------------------------------------------------------------count No in part 1
bct=0;
xa = pt[1].length;
//--------------------------------------------------------------------------------no elements=no count
if(xa == 0) {
bct = 0;
}
else {
//--------------------------------------------------------------------------------------WIN-PLC-SHW
if(tps=="WIN" || tps=="WN" || tps=="PLC" || tps == "PL" || tps=="SHW" || tps=="SH") {
bct = xa;
pp = 1;
}
else if(tps=="WP" || tps=="WS" || tps=="PS"){
bct=xa*2;
pp = 1;
}
else if(tps=="WPS"){
bct = xa*3;
pp = 1;
}
//--------------------------------------------------------------------------------------QUINIELA
else if(tps == "QU" || tps == "QN" || tps == "SW"){
if(prm == "KEY") {
for(i = 0; i 1){
i = xa;
bct = i*(i - 1);
}
else {
bct=0;
pp=1;
}
}
else {
if(xa > 2) {
xa = 2;
txt = txt.substr(0, 2);
}
bct = 1;
pp = 1;
}
}
//--------------------------------------------------------------------------------------DAILY DOUBLE
else if(tps == "DBL" || tps == "DB" || tps == "DD" || tps == "DDL" || tps == "TT" || tps == "TS"){
if(prm=="KEY"){
xb = pt[2].length;
bct = xa*xb;
pp = 2;
}
else {
bct = 1;
pp = 1;
}
}
//--------------------------------------------------------------------------------------TRIFECTA
else if(tps == "TRI" || tps == "TR"){
if(prm == "KEY") {
xb = pt[2].length;
if(xb == 0) {
bct = 0;
}
else {
//----------------------------------------------------------------------------------------complete the bet
xc = pt[3].length;
for(i = 0; i < xa; i++) {
a = pt[1].substr(i, 1);
for(j = 0; j < xb; j++) {
b = pt[2].substr(j, 1);
for(k = 0; k < xc; k++) {
c=pt[3].substr(k, 1);
if(a != b && a != c && b != c) {
bct++;
pp = 3;
}
}
}
}
}
}
else if(prm == "BOX") {
if(xa > 2) {
i = xa;
bct = i*(i - 1)*(i - 2);
}
else {
bct=0;
pp=1;
}
}
else {
if(xa > 3) {
xa=3;txt = txt.substr(0, 3);
}
bct = 1;
}
}
//--------------------------------------------------------------------------------------SUPERFECTA
else if(tps == "SUP" || tps == "SU"){
if(prm == "KEY") {
xb = pt[2].length;
if(xb == 0) {
bct = 0;
}
else {
//----------------------------------------------------------------------------------------complete the bet
xc = pt[3].length;
xd = pt[4].length;
for(i = 0; i < xa; i++) {
a = pt[1].substr(i, 1);
for(j = 0; j 3) {
i = xa;
bct = i*(i - 1)*(i - 2)*(i - 3);
}
else {
bct = 0;
}
pp = 1;
}
else {
if(xa > 4) {
xa = 4;
txt = txt.substring(0, 4);
}
bct = 1;
pp = 1;
}
}
//--------------------------------------------------------------------------------------PICKn
else if(tps == "PK3" || tps=="P3"){
bct = pt[1].length;
for(i = 2; i <= 3; i++) {
bct = bct*pt[i].length;
}
}
else if(tps == "PK4" || tps == "P4" || tps == "Q4" || tps=="J4"){
bct = pt[1].length;
for(i = 2; i <= 4; i++) {
bct = bct*pt[i].length;
}
pp = 4;
}
else if(tps == "PK5" || tps == "P5"){
bct = pt[1].length;
for(i = 2; i <= 5; i++) {
bct = bct*pt[i].length;
}
pp = 5;
}
else if(tps == "PK6" || tps == "P6" || tps == "C6" || tps == "T6" || tps == "J6" || tps == "V6" || tps == "W6"){
bct = pt[1].length;
for(i = 2; i <= 6; i++) {
bct = bct*pt[i].length;
}
pp = 6;
}
else if(tps == "PK7" || tps == "P7" || tps == "C7" || tps == "V7"){
bct = pt[1].length;
for(i = 2; i <= 7; i++) {
bct= bct*pt[i].length;
}
pp = 7;
}
else if(tps == "PK8" || tps == "P8"){
bct = pt[1].length;
for(i = 2; i <= 8; i++) {
bct = bct*pt[i].length;
}
pp = 8;
}
else if(tps == "PK9" || tps == "P9"){
bct = pt[1].length;
for(i = 2; i <= 9; i++) {
bct = bct*pt[i].length;
}
pp = 9;
}
}
}
//-------------------------------------------------------------------------code post numbers
function postCodec(ipost,apost) {
/* convert interger (1 to 40) into single string char
used when evaluating combination bets
If iPost has a value then convert to alpha
else if apost<>"" then convert to numeric digits*/
var a = "";
if(ipost>0){
a = dec.substr(ipost, 1);
}
else if(apost != ""){
a = dec.indexOf(apost);
}
else {
a = "0";
}
return a;
}
//-------------------------------------------------------------------------replace
function Replace(a,b,c){
var f = "";
var i = 0;
var v = a.split(b);
for (i = 0; i x,x/x,x,x/x,x,x
for(i=0;i \
'+ aBet+ ' \
' + exr + ' \
\
\
';
$.ajax({
type: "POST",
url: wsUrl,
contentType: "text/xml",
dataType: "xml",
data: soapRequest,
complete: endPlaceBet
});
}
function endPlaceBet(xmlHttpRequest, status) {
var info_dat = "";
var info_trk = "";
var info_rac = "";
var info_dol = "";
var info_tpl = "";
var info_txt = "";
var info_amt = "";
$(xmlHttpRequest.responseXML).find('PlaceBetResult').each(function(){
exm = $(this).find('exm').text().toUpperCase();
ser = $(this).find('ser').text();
info_trk = $(this).find('trk').text();
info_rac = $(this).find('rac').text();
info_dol = $(this).find('dol').text();
info_tpl = $(this).find('tpl').text();
info_txt = $(this).find('txt').text();
info_amt = $(this).find('amt').text();
});
if(exm == "SUCCESS"){
//document.getElementById('baltxt').innerHTML = '$' + bal;
document.getElementById('exmtxt').innerHTML = 'Bet Confirmed';
document.getElementById('bettxt1').innerHTML = 'Serial Number: ' + ser;
document.getElementById('bettxt1').className = 'text-primary';
document.getElementById('bettxt2').innerHTML = info_trk + ' Race ' + info_rac;
document.getElementById('bettxt3').innerHTML = '$' + info_dol + ' ' + info_tpl + ' - ' + info_txt;
document.getElementById('bettxt4').innerHTML = 'Total: $' + info_amt;
document.getElementById('wagertxt').value = " ";
}
else{
document.getElementById('exmtxt').innerHTML = exm;
document.getElementById('bettxt1').innerHTML = '!';
document.getElementById('bettxt1').className = 'text-danger';
document.getElementById('bettxt2').innerHTML = ' ';
document.getElementById('bettxt3').innerHTML = ' ';
document.getElementById('bettxt4').innerHTML = ' ';
}
GetBalance();
ResetLegRace(crc);
$('#TicketModal').modal('hide');
$('#InfoModal').modal('show');
}
//-------------------------------------------------------------------------CANCEL BET
function CancelBet(a){
soapRequest = ' \
\
\
\
' + lid + ' \
' + ven + ' \
' + dat + ' \
' + a + ' \
' + true + ' \
\
\
';
$.ajax({
type: "POST",
url: wsUrl,
contentType: "text/xml",
dataType: "xml",
data: soapRequest,
complete: endGetBetStatus
});
}
function endGetBetStatus(xmlHttpRequest, status) {
var info_dat = "";
var info_trk = "";
var info_rac = "";
var info_dol = "";
var info_tps = "";
var info_txt = "";
$(xmlHttpRequest.responseXML).find('GetBetStatusResult').each(function(){
exm = $(this).find('exm').text().toUpperCase();
ser = $(this).find('ser').text();
info_trk = $(this).find('trk').text();
info_rac = $(this).find('rac').text();
info_dol = $(this).find('dol').text();
info_tps = $(this).find('tps').text();
info_txt = $(this).find('txt').text();
info_amt = $(this).find('amt').text();
});
info_dol = Math.round(info_dol * 100) / 100;
if(exm == "SUCCESS"){
//document.getElementById('baltxt').innerHTML = '$' + bal;
document.getElementById('exmtxt').innerHTML = 'Bet Cancel Confirmed';
document.getElementById('bettxt1').innerHTML = 'Serial Number: ' + ser;
document.getElementById('bettxt1').className = 'text-primary';
document.getElementById('bettxt2').innerHTML = info_trk + ' Race ' + info_rac;
document.getElementById('bettxt3').innerHTML = '$' + info_dol + ' ' + info_tps + ' - ' + info_txt;
document.getElementById('bettxt4').innerHTML = ' ';
}
else{
document.getElementById('exmtxt').innerHTML = exm;
document.getElementById('bettxt1').innerHTML = '!';
document.getElementById('bettxt1').className = 'text-danger';
document.getElementById('bettxt2').innerHTML = ' ';
document.getElementById('bettxt3').innerHTML = ' ';
document.getElementById('bettxt4').innerHTML = ' ';
}
GetBalance();
$('#HistoryModal').modal('hide');
$('#InfoModal').modal('show');
}
//-------------------------------------------------------------------------CLEAR
function ClearTable_Ticket(){
var table = document.getElementById("TicketTable");
var rowCount = table.rows.length-1;
for(var i = 0; i <= rowCount; i++) {
var row = table.rows[i];
table.deleteRow(i);
rowCount--;
i--;
}
}
function ClearBet(){
document.getElementById('wagertxt').value = " ";
amt = 0;
bct = 0;
leg = 0;
lex = 0;
lky = "";
prm = "";
tpl = "";
tps = "";
tmu = "";
tmb = "";
txt = "";
tzt = "";
ScratchLeg = [];
RunnersLeg = "";
leg_stls = [];
leg_psts = [];
leg_nams = [];
leg_imgs = [];
leg_jkys = [];
leg_rac = "";
leg_nrn = "";
leg_scr = "";
ResetLegRace(rac);
document.getElementById("withBtn").innerHTML = "With";
document.getElementById('exmtxt').innerHTML = ' ';
document.getElementById('bettxt1').innerHTML = ' ';
document.getElementById('bettxt2').innerHTML = ' ';
document.getElementById('bettxt3').innerHTML = ' ';
document.getElementById('bettxt4').innerHTML = ' ';
}