//-------------------------------------------------------------------------RUNNERS
function GetRunners(){
soapRequest = ' \
\
\
\
' + tid + ' \
' + rac + ' \
\
\
';
$.ajax({
type: "POST",
url: wsUrl,
contentType: "text/xml",
dataType: "xml",
data: soapRequest,
complete: endGetRunners
});
}
function endGetRunners(xmlHttpRequest, status) {
stls = [];
psts = [];
nams = [];
imgs = [];
jkys = [];
$(xmlHttpRequest.responseXML).find('GetRunnersResult').each(function(){
exm = $(this).find('exm').text().toUpperCase();
nrn = $(this).find('nrn').text();
});
if(exm == "SUCCESS"){
RunData = 1;
$(xmlHttpRequest.responseXML).find('racrunnersinfo').each(function(){
var get_stl = $(this).find('stl').text();
var get_pst = $(this).find('pst').text();
var get_nam = $(this).find('nam').text();
var get_img = $(this).find('img').text();
var get_jky = $(this).find('jky').text();
stls.push(get_stl);
psts.push(get_pst);
nams.push(get_nam);
imgs.push(get_img);
jkys.push(get_jky);
});
}
else{
RunData = 0;
for(var i = 1; i <= mxr-1; i++) {
stls.push(i);
psts.push(i);
nams.push("n/a");
imgs.push("blank.png");
jkys.push("-");
}
}
DisplayRunners();
DisplayWagers();
res_tid = tid;
res_trk = trk;
res_dat = dat;
res_nrs = nrs;
GetRaceResult();
}
function DisplayRunners(){
ClearTable_Runners();
var table = document.getElementById('topTable');
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var cell1 = row.insertCell(0);
cell1.style.width = '50%';
cell1.style.textAlign = 'left';
cell1.innerHTML = "Runners";
var cell2 = row.insertCell(1);
cell2.style.width = '40%';
cell2.style.textAlign = 'left';
if(spt == "T" || spt == "H"){
cell2.innerHTML = "Jockeys";
}
else{
cell2.innerHTML = " ";
}
var cell2 = row.insertCell(2);
cell2.style.width = '10%';
cell2.style.textAlign = 'center';
cell2.innerHTML = " ";
if(rac == crc){
cell2.innerHTML = "Win";
}
else{
cell2.innerHTML = "(ML)";
}
addRunnerRow();
}
function MakeScratchRun(){
Scratch = [];
Scratch = scr.split(",");
}
function addRunnerRow() {
for(var i = 0; i <= mxr-1; i++) {
var table = document.getElementById('runnerTable');
table.style.border = '1px solid #CCCCCC';
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
row.style.cursor = "pointer";
row.value = psts[i];
for(var j = 0; j <= Scratch.length; j++) {
if(psts[i] == Scratch[j]){
table.rows[i].className = "active";
row.style.cursor = "not-allowed";
row.onmouseover=function(){
$(this).tooltip({title: 'Scratched'});
}
}
else{
row.onclick=function(){
SelectRunner(this.value);
}
}
}
var cell0 = row.insertCell(0);
cell0.style.width = '20px';
cell0.style.textAlign = 'left';
cell0.style.verticalAlign = 'middle';
var img = document.createElement('img');
if(RunData==1){
if(spt == "G"){
img.src = imgsrc_USG + imgnam[i];
}
if(spt == "T" || spt =="H"){
if(nat == "US"){
img.src = imgsrc_UST + imgnam[i];
}
else{
img.src = imgsrc_UKT + imgs[i];
}
}
}
else{
img.src = imgsrc_USG + "blank.png";
}
img.id = psts[i];
img.onclick=function(){RunnerInfo(this);};
cell0.appendChild(img);
var cell1 = row.insertCell(1);
cell1.style.width = '45%';
cell1.style.verticalAlign = 'middle';
cell1.innerHTML = psts[i] + ". " + nams[i];
cell1.style.textAlign = 'left';
var cell2 = row.insertCell(2);
cell2.style.width = '45%';
cell2.style.textAlign = 'left';
cell2.style.verticalAlign = 'middle';
if(spt == "T" || spt == "H"){
cell2.innerHTML = '' + jkys[i] + '';
}
else{
cell2.innerHTML = '-';
}
var cell3 = row.insertCell(3);
cell3.style.width = '10%';
cell3.style.textAlign = 'center';
cell3.style.verticalAlign = 'middle';
if(rac == crc){
if(win[i] != null){
cell3.innerHTML = '' + win[i];
}
else{
cell3.innerHTML = " ";
}
}
else{
cell3.innerHTML = " ";
}
}
Runners = "";
for(var k = 0; k <= rowCount; k++) {
if(table.rows[k].className != 'active'){
Runners += psts[k];
}
}
}
function ClearTable_Runners(){
DeleteTopRow();
var table = document.getElementById("runnerTable");
table.style.border = '1px #666666 hidden';
var rowCount = table.rows.length-1;
for(var i = 0; i <= rowCount; i++) {
var row = table.rows[i];
table.deleteRow(i);
rowCount--;
i--;
}
}
function DeleteTopRow(){
var table = document.getElementById("topTable");
var rowCount = table.rows.length-1;
for(var i = 0; i <= rowCount; i++) {
var row = table.rows[i];
table.deleteRow(i);
rowCount--;
i--;
}
}
//-------------------------------------------------------------------------RUNNER
function SelectRunner(a) {
if(lky=="#"){
buildBet("/");
}
else{
lky = postCodec(a,"");
txt += lky;
}
displayBet();
}
function GetRunner(a){
soapRequest = ' \
\
\
\
' + tid + ' \
' + rac + ' \
' + a + ' \
\
\
';
$.ajax({
type: "POST",
url: wsUrl,
contentType: "text/xml",
dataType: "xml",
data: soapRequest,
complete: endGetRunner
});
}
function endGetRunner(xmlHttpRequest, status) {
var x = $(this).find('GetRunnerResult').text();
alert(pst);
}