var pool_exacta;var pool_first4;var pool_quinella;function setLoading(b){if(b.options.length==0){return null}var a=b.options[b.selectedIndex].text;b.disabled=true;b.options[b.selectedIndex].text="Loading...";return a}function unsetLoading(b,a){if(b.options.length==0){return}b.options[b.selectedIndex].text=a;b.disabled=false}function emptyResponse(a){return(a.responseDocument==null||a.responseDocument.documentElement==null)}function hasPool(b,a){return a.indexOf(""+b+"")>-1}function getFormSingle(a,b){getForm(document.forms.betting.raceNo.value,a,b)}function getForm(raceNo,runnerNo,runName){var sUrl=g_sFormUrl;var formDate=document.forms.betting.meetingDate.value.substring(0,10);var _dateParts=formDate.split("/");if(_dateParts.length>2){var _partDay=_dateParts[0];if(_partDay.length<2){_partDay="0"+_partDay}formDate=_dateParts[2]+_dateParts[1]+_partDay}sUrl+="?horsename="+runName;sUrl+="&formdate="+formDate;with(new DialogWindow(sUrl)){Name="FormGuide";Width=Math.floor(window.screen.width*0.75);Height=Math.floor(window.screen.height*0.75);Scroll=true;Status=false;Resizable=true;RequiresLogin=false;Show()}}function BetCoster(){var n=4;var q;var t,r;var v;var e=0;var l=new Array(n);var d=0;this.costBet=function(y,B,x){var A=0;var z;var s=x;q=s.isBoxed();v=s.isFlexiBet();e=B.toPlace();d=B.toWin();for(var w=n-1;w>-1;--w){l[w]=null}for(var w=s.fieldCount()-1;w>-1;--w){l[w]=s.getRunnerSelection(w)}t=(l[0]==null)?0:l[0].count();r=(l[1]==null)?0:l[1].count();switch(y.selected()){case BetType.WINPLACE:A=p();break;case BetType.QUINELLA:A=m();break;case BetType.EXACTA:A=b();break;case BetType.FIRSTFOUR:A=c(4);break;case BetType.TRIFECTA:A=c(3);break;case BetType.MYSTERYTRIFECTA:A=d;break;case BetType.ALLUP:A=a();break;case BetType.QUADRELLA:A=u();break;case BetType.TRIWIN:A=f();break;default:A=k()}return A};var j=function(w,s){var x=w-s;return(x>-1)?(h(w)/h(x)):0};var o=function(){var w=(l[2]==null)?0:l[2].count();var s=(l[3]==null)?0:l[3].count();return t*r*w*s};var a=function(){return t*d};var b=function(){var s;var x=0;var w=0;if(q){s=t*(t-1);x=s*d}else{if(t>0&&r>0){w=l[0].combination().countDuplicatesIn(l[1].combination());s=(t*r)-w;x=s*d}}return x};var c=function(s){var w=(q)?j(t,s):g(l,new NumberCombination(),s);return(v)?((w>0)?d:0):w*d};var u=function(){var s=o();return(v)?((s>0)?d:0):s*d};var m=function(){var y;var A=0;var z=0;var w=(l[0]==null)?false:l[0].fieldSelected();var s=(l[1]==null)?false:l[1].fieldSelected();var x=q;if(x){if(t>0&&r>1){z=l[0].combination().countDuplicatesIn(l[1].combination());y=t*r-z;if(!w&&!s){y-=(z*(z-1)/2)}A=(y>=2)?y*d:0}else{if((t>1)&&(r==0)){y=(t*t)-t;A=((y*d)/2);if(w){A*=2}}}}else{y=(t*t)-t;A=((y*d)/2)}return A};var f=function(){return o()*d};var k=function(){return t*r*d};var p=function(){var s=0;s=(d*t)+(e*t);return s};var h=function(s){return(s<=1)?((s<0)?0:1):s*h(s-1)};var g=function(D,z,s){var B=0;var y=z.elementCount();var E=D[y];if(E!=null){E=E.combination();var C=E.elementCount();var w=E.elements();if(s>1){if(y==s-1){for(var A=0;A=0;--h){var j=arguments[h];if(e==j){g=true;break}}return g};this.select=function(g){e=c(g)?g:a};this.selectByCode=function(j){var g=false;for(var h=b.length-1;h>0;h>>>=1){g=b[h]==j;if(g){setType=this.select(h);break}}if(!g){this.select(a)}};this.selected=function(){return e};this.selectedCode=function(){return d(e)};this.singleLeg=function(){return !this.multiLeg()}}function ClassicControlNaming(){var o="Box";var h="events";var b="Field";var t="flexiBet";var j="mysteryType";var g="race";var l="runner";var u="allUpBetType";var e="legSelect";var v="A";var a="Z";var n=v.charCodeAt(0);var c=l.length;var m=l+b;var q=m.length;var k=function(w){return w.charAt(q)};var s=function(w){return w.charCodeAt(0)-n};var p=function(w){return w.charAt(c)};var f=function(w){return String.fromCharCode(w+n)};var d=function(w,x){return w.indexOf(x)==0};var r=function(y){var x=false;if(y!=null&&y.length>0){var w=y.charCodeAt(0);x=(w>=n&&w<=a.charCodeAt(0))}return x};this.allUpBetType=function(w){return u+w};this.box=function(){return l+o};this.flexiBet=function(){return t};this.eventId=function(){return h};this.field=function(w){return m+f(w)};this.group_field=function(w){return s(k(w))};this.group_runner=function(w){return s(p(w))};this.isNameOf_allUpBetType=function(w){var x=u.length;return(w.length==(x+1))&&d(w,u)&&(this.number_leg(w)>0)};this.isNameOf_box=function(w){return w==this.box()};this.isNameOf_eventId=function(w){return w==h};this.isNameOf_field=function(w){return(w.length==(q+1))&&d(w,m)&&r(k(w))};this.isNameOf_flexiBet=function(w){return w==t};this.isNameOf_legSelect=function(w){return(w.length==(e.length+1))&&(this.number_leg(w)>0)};this.isNameOf_mysteryAmount=function(w){return w==this.mysteryAmount()};this.isNameOf_mysteryRace=function(w){return w==this.mysteryRace()};this.isNameOf_runner=function(w){return(w.length>=(c+2))&&d(w,l)&&r(p(w))&&(this.number_runner(w)>0)};this.isFieldFromGroup=function(w,x){return this.isNameOf_field(w)&&(this.group_field(w)==x)};this.isRunnerFromGroup=function(w,x){return this.isNameOf_runner(w)&&(this.group_runner(w)==x)};this.legSelect=function(w){return e+w};this.mysteryAmount=function(){return j};this.mysteryRace=function(){return g};this.number_leg=function(w){return parseInt(w.substring(w.length-1))};this.number_runner=function(w){return parseInt(w.substring(c+1))};this.runner=function(x,w){return l+f(x)+w}}function RacecardSelection(){RacecardSelection.RACE_CURRENT="CURRENT";RacecardSelection.RACE_NEXT="15";var d=RacecardSelection.RACE_CURRENT;var e=false;var c=false;var f=false;var b=d;var a=new RunnerSelectionList();this.add=function(g,h){a.addSelection(g,h)};this.clear=function(){this.reveal();if(this.isBoxed()){this.setBoxed(false)}if(this.isFlexiBet()){this.setFlexi(false)}this.setRace(d);a.removeAll()};this.deselectField=function(g){a.deselectField(g)};this.fieldCount=function(){return a.count()};this.getRunnerSelection=function(g){return a.elementAt(g)};this.getBetType=function(){return _betType};this.getRace=function(){return b};this.getRaceNumber=function(j){var g=0;var h=a.elementAt(j);if(h!=null){g=h.getRaceNumber()}return g};this.getRaces=function(){var g=this.fieldCount();var j=new Array();for(var h=0;h-1&&fg){for(var f=g;f-1){if(f>=c.length){d(f+1)}g=e(f)}return g};this.add=function(){c.push(b())};this.addSelection=function(f,g){if(a(f)){c[f].select(g)}};this.count=function(){return c.length};this.deselectAll=function(f){if(this.deselectField(f)){c[f].deselectAll()}};this.deselectField=function(g){var f=false;if(e(g)){c[g].deselectField();f=true}return f};this.elementAt=function(f){return(e(f))?c[f]:null};this.removeAll=function(){c.length=0};this.removeAt=function(f){if(e(f)){switch(f){case 0:c.shift();break;case (c.length-1):c.pop();break;default:c=c.slice(0,f).concat(c.slice(f+1))}}};this.removeSelection=function(f,g){if(e(f)){c[f].deselect(g)}};this.selectAll=function(f){if(a(f)){c[f].selectField()}};this.setEventId=function(f,g){if(a(f)){c[f].setEventId(g)}};this.setRaceNumber=function(f,g){if(a(f)){c[f].setRaceNumber(g)}};this.setType=function(f,g){if(a(f)){c[f].setType(g)}}}function SpeedBetPlusTranslator(){var a=":";var b=a;var c="/";var d="/C";var k=" ";var q=k;var l="F";var p="F";var g="?TF";var j="+";var f=1;var m=3;var n=d.length;var e=function(t){var r=t.split(b)[0];return r.substr(r.length-n).toUpperCase()==d};var h=function(u){var t=u.split(b);var r=t.length;return((r>1)&&(t[r-1].toUpperCase()==p))};var o=function(r){return(r.substring(0,g.length).toUpperCase()==g)};this.betType=function(s){var r=new BetType();if(o(s)){r.select(BetType.MYSTERYTRIFECTA)}else{r.selectByCode(s.split(b)[0].split(q)[0])}return r};this.wagerAmount=function(u){var s=new WagerAmount();if(o(u)){s.setWin((e(u))?m:f)}else{var r=u.split(b);var t=r.length;if(t>1){s.setWin(r[1])}if((t>2)&&(r[2].toUpperCase()!=p)){s.setPlace(r[2])}}return s};this.selections=function(C){var E=new RacecardSelection();E.setFlexi(h(C));C=C.split(b)[0];if(e(C)){E.setBoxed(true);C=C.substring(0,C.length-n)}if(o(C)){var x=C.split(q);if(x.length>0){x=x[1].split(c);E.setRace((x==RacecardSelection.RACE_NEXT)?x:RacecardSelection.RACE_CURRENT)}E.shroud()}else{var D=C.split(q);var u=D.length;var y=(u>1)?u-1:-1;var z=(u>2)?1:-1;var w=(u>3)?2:-1;if(z>-1){var r=D[z].split(c);for(i=0;i-1){var A=D[w].split(c);for(i=0;i-1){D=D[y].split(c);var B,t;for(i=0;i0){E.add(i,t)}}}}}}return E};this.betString=function(v,u,L){var C=u;var x=L;var A="";var B="";var z="";var D=v;var F=D.fieldCount();var G="";if(D.isMystery()){G+=g+q;var H=D.getRace();G+=(H==RacecardSelection.RACE_CURRENT)?D.getRaceNumber(0):H}else{for(var K=0;K0){if(B.length>0){B+=c}B+=y;if(C.of(BetType.ALLUP)){if(z.length>0){z+=c}z+=E.getType()}}if(E.fieldSelected()){A+=l}else{var M=E.combination().elements();var I=M.length;for(var J=0;J0){B+=q}if(z.length>0){z+=q}G=C.selectedCode()+q+B+z+A}if(D.isBoxed()){G+=d}if(!D.isMystery()){G+=b+x.toWin();if(C.of(BetType.WINPLACE)){G+=b+x.toPlace()}if(D.isFlexiBet()){G+=b+p}}return G}}function WagerAmount(){WagerAmount.MAXIMUM=32000;var b=0;var c=0;var a=function(d){d=d*1;d*=2;d=Math.round(d);d/=2;d=(d>Math.floor(d))?d+"0":d;return parseFloat(d)};this.setPlace=function(d){d=parseFloat(d);if(this.validAmount(d)){b=d}};this.setWin=function(d){d=parseFloat(d);if(this.validAmount(d)){c=d}};this.toPlace=function(){return a(b)};this.toWin=function(){return a(c)};this.validAmount=function(d){return((d>=0)&&(d<=WagerAmount.MAXIMUM))}};