var dZ=false;var dR="";var cN="Track Name";var dc=12;var eg=17;var fF=eg;var dh;var dI;var cK;var fd;var cL;var df;var dK;var dC=[[-90,2],[90,1],[181,2]];var eA;var B;var ju=[];var dJ;var cd;var jM=[];var dr=[];var ck=[];var eI=['#00FFFF','#FF0000','#00FF00','#0000FF','#FFFF00','#FFFFFF','#FF00FF','#666666','#FF9999','#99CCFF','#AA99FF','#AAAAAA','#009900','#AA33AA','#DDDDDD'];var iA=2010;var hJ="2.26";var lz;var en=false;var isIE=false;var hdata;var hdata_race;var hdata_horse;var map;var mapOverlay;var iL=0;var cb=0;var v=0;var ct=new Array();var L=new Array();var ec;var cj;var cJ;var fi;var ev;var fM=0,fO=0;var kc=true;var dH=[0,0,0,0];var gV=0;var gs=1;var gL=2;var gW=3;var eV=1,fm=1,ej=1;var jE,jw;var cw=0;var dU=false;var dW=false;var dT=false;var fC=false;var gj=0;var bX=0;var fH=0;var raceDuration=0;var cf=0;var di;var cx;var timerDiv;var cQ;var D='<div class="floatLabelLeft"><div>xxxx<\/div><\/div>';var C='<div class="floatLabelRight"><div>xxxx<\/div><\/div>';var eh;var jp;var dm=0;var dP=1;var fw= -1;var optMarkerGroup=1;var cn,cq;var ea=0;var cl=false;var cg= -1;var graphEnergy,graphSpeed,graphError;var cW=true;var cO=false;var cG=true;var cV=false;var dF=false;var dw=false;var dE=false;var cy=[0,5];var cz=100;eZ=2.44;jh=1;dY=0;cF=1;ew=0;cs=1;cA=2;cI=3;ek=4;ge=5;fU=0;fv=1;fs=2;fj=3;gc=4;eJ=5;eE=6;fo=7;eY=8;gp=["MRGN","WIDE","RDST","ADST","SPED","STIM","SPLT","SLAG","BLCK","N/A"];function loadPanels(){var largeMap=document.getElementById('largeMap');var iG=document.getElementById('flashZoom');var legend=document.getElementById('legend');var statistics=document.getElementById('statistics');var timer=document.getElementById('timerDiv');aC();fF==eg;aS();bT(largeMap,iG,legend,statistics,timer);if(!dZ)az("No data available for this track");dW=true;};function bT(mapLayer,zoomMapLayer,fn,iU,hO){var jH="flash/"+dR+".swf";var F,flashvars={},attributes={},params={};params.allowscriptaccess="always";swfobject.embedSWF("flash/flashSoundFX.swf","flashSoundFX","1","1","8.0.0",false,flashvars,params,attributes);swfobject.embedSWF("flash/audioLoader.swf","flashAudio","1","1","8.0.0",false,flashvars,params,attributes);swfobject.embedSWF(jH,"flashZoom","300","300","8.0.0",false,flashvars,params,attributes);_mPreferMetric=true;mapLayer.style.height=(bt()-83)+"px";var lo={zoom:eg,center:dI,mapTypeId:google.maps.MapTypeId.SATELLITE,draggableCursor:'default',backgroundColor:'#535965',mapTypeControl:false,navigationControl:true,navigationControlOptions:{style:google.maps.NavigationControlStyle.SMALL,position:google.maps.ControlPosition.BOTTOM_LEFT},scaleControl:false};map=new google.maps.Map(mapLayer,lo);cL=(fd.length==1||fd[0]==hdata_race.course)?0:1;if(typeof(eA)!='undefined'&&eA!=null)bk(map,eA);if(typeof(B)!='undefined'&&B!=null)B.setMap(map);var cU=document.getElementById('mapTitle');var date=hdata_race.date.substr(6,2)+"/"+hdata_race.date.substr(4,2)+"/"+hdata_race.date.substr(0,4);cU.innerHTML=date+"&#160;&#160;"+cN+" Race Track - Race "+hdata_race.number+"&#160;&#160;("+hdata_race.distance+" metres)";setTimeout("aY(hdata_race.audio)",2000);G();mapOverlay=new google.maps.OverlayView();mapOverlay.draw=function(){};mapOverlay.setMap(map);cK=ad(hdata[1][1][0],hdata[1][1][1]);cd=hdata_race.distance;dJ=hdata_race.duration;cb=iL=hdata_horse.length;v=0;for(var ix=0;ix<hdata_horse.length;ix++){if(hdata_horse[ix][1]>0)v++;}aH();L=[new Array(),new Array(),new Array(),new Array(),new Array()];F={labelClass:"floatLabel",labelText:D,visible:false,percentOpacity:65,ll:false};cn=new TMarker(map,new google.maps.LatLng(0,0),F);F={labelClass:"floatLabel",labelText:C,visible:false,percentOpacity:65,ll:false};cq=new TMarker(map,new google.maps.LatLng(0,0),F);bz(fn);kq(map.getZoom());aA(map);ah();ak(false);aB();timerDiv=hO;google.maps.event.addListener(map,'click',function(event){if(co==cA||co==cI){var map_point=event.latLng;var dp=mapOverlay.getProjection().fromLatLngToDivPixel(map_point);if(dP==1||dp.x!=fM||dp.y!=fO){if(dp.x!=fM||dp.y!=fO)bl(map_point,false);}else{bD(map_point,false);}fM=dp.x;fO=dp.y;}});google.maps.event.addListener(map,'zoom_changed',function(){eg=map.getZoom();if(Y)ku(eg);});};function bD(cr,dn){var dj=aJ(cr,dn);if(dj.length==1){dm=1;ae("click1");return;}ae("winclose");dm=(dm==dP)?1: ++dm;bX=dj[dm-1];aZ();};function bk(gK,eR){if(typeof(eR[0])=="undefined")eR.setMap(gK);else for(var ix=0;ix<eR.length;ix++)eR[ix].setMap(gK);};function aA(gK){var ix,F,dB,ds,dD,fX,hC;var options,color,weight=3,opacity;dN=null;optMarkerGroup=1;fw= -1;fi=new Array(),ev=new Array();if(dP>1){F={labelText:"LAP&#160;1",labelClass:"lapLabel",g:new google.maps.Size(-30,-10),kw:3};eh=new TMarker(map,dh,F);eh.setMap(map);}for(ix=0;ix<bY.length;ix++){ds=ad(bY[ix][1],bY[ix][2]);dD=ad(bY[ix][3],bY[ix][4]);if(ix==0||ix==bY.length-1)color="#CCCC00",opacity=0.6;else color="#CCCCCC",opacity=0.5;options={path:[ds,dD],strokeColor:color,strokeOpacity:opacity,strokeWeight:weight};fi[ix]=new google.maps.Polyline(options);fi[ix].setMap(map);L[3].push(fi[ix]);fX=bA(bY[ix][5]);if(bY[ix][0]==0){hC="Finish&#160;Line";}else{if(ix==bY.length-1){hC="Start&#160;Line";}else{hC=(bY[ix][0])+"&#160;metres";}}F={labelText:hC,lj:dD,jX:fX,kw:3};ev[ix]=new TMarker(map,ds,F);}setTimeout("aM()",1000);};function aM(){if(dP<2)return;var fP=(bX<cC[1])?1:(bX<cC[2])?2:3;if(fP==fw)return;var je=(bX<cC[2])?1:2;optMarkerGroup=(fP==1)?2:1;eh.setContents("LAP&#160;"+(je));for(var ix=0;ix<bY.length;ix++){if(bY[ix][6]==0)continue;if(fP==1){if(bY[ix][6]==2){ev[ix].show();fi[ix].setMap(map);}else{ev[ix].hide();fi[ix].setMap(null);}}else{if(bY[ix][6]==1){ev[ix].show();fi[ix].setMap(map);}else{ev[ix].hide();fi[ix].setMap(null);}}}fw=fP;};function bA(jg){var ix=0;while(ix<dC.length-1&&jg>dC[ix][0]){ix++;}return dC[ix][1];};function bl(cr,dn){var dj,ci=0;if(co==cA||co==cI){dj=aJ(cr,dn);var ix,dL=0,gM=999999;for(ix=0;ix<dj.length;ix++){if(Math.abs(dj[ix]-bX)<gM){dL=ix;gM=Math.abs(dj[ix]-bX);}}dm=dL+1;ci=bX=dj[dL];aZ();}return ci;};function aZ(){cx=hdata[bX][0];cf=ab(hdata[bX][0]);if(bX<3)bX=3;ae("click1");ac(bX,true);};function ak(hq){var ix,db=[];var cU,fL,gk=10;if(hq){if(bX<10||bX>=ce.length)return;if(co==cs&&dH[gs]++ %3!=0)return;db=am(bX);}else{db=am(0);}if(db.length<10)gk=db.length;for(ix=0;ix<gk;ix++){fL=1+ix;cU=document.getElementById("leaderIcon"+fL);aQ(cU,db[ix].n);}return;};function aQ(cU,bW){var lm=(bW-1)*24;cU.style.backgroundPosition="-"+(lm)+"px 0px";cU.innerHTML=bW;};function am(ci){var ix,jx,ki,db=[];for(ix=0;ix<ce[2].length;ix++){db[ix]=new Array();db[ix].n=ct[ix];db[ix].i=ix;if(ci==0){db[ix].z=50-ct[ix];}else{if(ce[ci][ix].s>0){db[ix].z=ce[ci][ix].z;}else{db[ix].z=0;}}}db.sort(bK);return db;};function bK(a,b){return b.z-a.z;};function bz(fn){var ix,cP,cZ=0,ih,eK,fk;var du='<table cellpadding="0" cellspacing="1">';cQ=new Array();ck=new Array;for(jx=0;jx<eI.length;jx++)ck[jx]=eI[jx];ct=[];for(ix=0;ix<hdata_horse.length;ix++)ct[ix]=ix+1;for(ix=0;ix<hdata_horse.length;ix++){if(hdata_horse[ix][1]>0)cZ++;eK=(hdata_horse[ix][1]>0)?' onclick="an('+cZ+')"':'';fk=(hdata_horse[ix][1]>0)?' onclick="an(0)"':'';ho=(hdata_horse[ix][1]>0)?' onclick="aX('+cZ+')"':'';ih=(hdata_horse[ix][1]>0)?ck[ix]:ck[ck.length-1];du+='<tr>';if(hdata_horse[ix][1]>0){du+='<td'+fk+'><input id="chkCompetitorPath'+cZ+'" type="checkbox" /></td>';}else{du+='<td'+fk+'><input type="checkbox" /></td>';}du+='<td'+ho+'><a style="display:block; width:11px; height:11px; margin:0px 2px 0px 2px; border:solid 1px #333333; background: '+ih+'; cursor:pointer" /></td>';du+='<td style="text-align:right"'+eK+'>'+(ix+1)+'.&#160;</td>';if(hdata_horse[ix][1]>0){cP='>'+hdata_horse[ix][0]+' ('+hdata_horse[ix][1]+')';du+='<td'+eK+'><div class="truncate" id="legendCompetitor'+(cZ)+'"'+cP+'</div></td>';}else{cP=' style="text-decoration:line-through">'+hdata_horse[ix][0];du+='<td'+eK+'><div class="truncate"'+cP+'</div></td>';}du+='</tr>';}du+='</table>';fn.innerHTML=du;for(ix=hdata_horse.length-1;ix>=0;ix--){if(hdata_horse[ix][1]==0){hdata_horse.splice(ix,1);ck.splice(ix,1);ct.splice(ix,1);}}cb=v;};function aB(){var du,jC,hp,ja;ec=new Array();var ci=1,cU,iu,ir,eS,gP=0,fy=[];var ix,jx,fL=21,db=[],race_dist,eq=0;var eU=[200,400,600,800,1000,1200,1400,1600,1800,2000,2400,2600];eq=cd%200;if(eq>20)eq-=200;jC=' width="50"';hp=' width="60"';ja=' width="24"';du='<table border="0" width="286">';for(ix=0;ix<cH.length;ix++){eq+= +200;race_dist=cd-eq;ci=bo(eq,ci);if(ci>=hdata.length)break;ec[ix]=hdata[ci][0];fy[ix]=ci;eS=cH[ix][ce[ci].w-1].t;if(+eS<0){jx=0;db=am(ci);while(+eS<0&&jx<db.length){var kn=db.length;var ko=db[jx].n;eS=cH[ix][db[jx++].i].t}}iu=ag(eS,3).substr(1);ir=ag(eS-gP,3).substr(3);gP=eS;du+='</tr><tr>';if(race_dist==0)du+='<td'+jC+'><div style="font-weight:bold">Finish:</div></td>';else du+='<td'+jC+'><div style="font-weight:bold">'+race_dist+'m:</div></td>';du+='<td'+hp+'><div id="ec'+Math.round(ix+1)+'">'+iu+'</div></td>';du+='<td'+hp+'><div id="splitDiff'+Math.round(ix+1)+'">('+ir+')</div></td>';du+='<td>&#160;</td>';for(jx=0;jx<3;jx++){du+='<td'+ja+'><div class="leaderIcon" id="leaderIcon'+(fL++)+'"></div></td>';}fL+=7;jC=hp=ja="";du+='</tr>';if(ci>=hdata.length-1||race_dist==0||hdata[ci+1][0]>dJ)break;}du+='</table>';cU=document.getElementById("leaderPanel");cU.innerHTML=du;for(ix=0;ix<fy.length;ix++){db=am(fy[ix]);for(jx=0;jx<3;jx++){fL=1+jx+10*(ix+2);cU=document.getElementById("leaderIcon"+fL);aQ(cU,db[jx].n);}}};function bo(eU,ci){var ix,jx,hH=0;for(ix=ci;ix<ce.length;ix++){for(jx=0;jx<v;jx++){if(ce[ix][jx].s>0&&ce[ix][jx].z>eU){if(hH<ce[ix][jx].z){hH=ce[ix][jx].z;}}}if(hH!=0)break;}return ix;};function aG(){if(bX==0||bX>=hdata.length)return;var ix,cU,gn;for(ix=0;ix<ec.length;ix++){if(hdata[bX][0]<ec[ix])gn="#FFFFFF";else gn="#FFFF33";cU=document.getElementById("ec"+Math.round(ix+1));cU.style.background=gn;cU=document.getElementById("splitDiff"+Math.round(ix+1));cU.style.background=gn;}};function checkColumnChange(ht){var cU=document.getElementById("statColumn"+ht);if(ht==1)cy[0]=cU.selectedIndex;else cy[1]=cU.selectedIndex;ah();};function ah(){var du,hp;if(co==cs&&dH[gV]++ %5!=0)return;cJ=0;cj=0;if(bX>0&&bX<ce.length){cj=parseInt((ce[bX][ce[bX].w-1].z-cd%200)/200);cJ=200*cj+cd%200;if(cJ>=cd)cj=Math.floor(cd/200);}du='<table cellpadding="2" cellspacing="1" border="0"><tr>';du+='<td width="180" style="font-weight:bold; text-decoration:underline"><div>Horse</div></td>';for(var ix=0;ix<cy.length;ix++){du+='<td style="font-weight:bold; text-align:center; text-decoration:underline;">'+gp[cy[ix]]+'</td>';}du+='</tr>';for(var jx=1;jx<=v;jx++){du+='<td style="text-align:left"><div class="trunc_stats_name">'+hdata_horse[jx-1][0]+'</div></td>';if(ax(jx)=='N'){hp=ja=ka="";}else{ja=aF(jx,0);ka=aF(jx,1);if(ax(jx)!='G')hp=" color:#FF0000;";else hp="";}du+='<td style="text-align:center;'+hp+'">'+ja+'</td>';du+='<td style="text-align:center;'+hp+'">'+ka+'</td>';du+='</tr>';}du+='</table>';if(co!=cs||dH[gW]++ %5==0){var eb=bi();var gC=(hdata.length-1)*cb;var iT=eb[0]+eb[1]+eb[2];var eT=204/gC;if((eV=Math.round(eb[0]*eT))==0)eV=1;if((fm=Math.round(eb[1]*eT))==0)fm=1;if((ej=Math.round(eb[2]*eT))==0)ej=1;}du+='<div id="error_bar" onclick="showGraph(\'error\')">'+'<div id="error_bar1" style="width:'+eV+'px"></div>'+'<div id="error_bar2" style="width:'+fm+'px"></div>'+'<div id="error_bar3" style="width:'+ej+'px"></div></div>';var div=document.getElementById('statisticsContent');div.innerHTML=du;};function aF(bW,ia){if(bX==0)return "";var result="n/a";switch(cy[ia]){case fU:result=bR(bW);break;case fv:result=aT(bW);break;case fj:result=aD(bW);break;case fs:result=aI(bW);break;case gc:result=e(bG(bW,bX));break;case eJ:result=aP(bW);break;case eE:result=aN(bW);break;case fo:result=aR(bW);break;case eY:break;}return result;};function bR(bW){var hd=ce[bX].w;if(hd==0)return "";return e((ce[bX][hd-1].z-ce[bX][bW-1].z)/eZ,1);};function aT(bW){return Math.round(ce[bX][bW-1].r)+1;};function aD(bW){var hd=e(hdata[bX][bW][3]);if(hd==0)return "";return hd;};function aI(bW){if(ax(bW)!='G')return "";return e(ce[bX][bW-1].z);};function bG(bW,ci){var result,dk=0,cS=0,fb=0,es=0,ix,kx,jx=bW-1;if(ci<31)return 0;kx=bW;ix=ci;while(ix<hdata.length){if(hdata[ix][kx][2]=="G"){cS=ce[ix][jx].z;es=ab(hdata[ix][0]);break;}ix++;}if(cS==0)return 0;ix=ci-30;while(ix>0){if(hdata[ix][kx][2]=="G"){dk=ce[ix][jx].z;fb=ab(hdata[ix][0]);break;}ix--;}if(dk==0||es-fb<10)return 0;result=3600*(cS-dk)/(es-fb);if(result>75)result=75;if(result<20)result=20;return result;};function aP(bW){if(cj<=0)return "";if(ce[bX][bW-1].z<cJ)return "";if(cH[cj-1][bW-1].t<0)return "";var cP=ag(cH[cj-1][bW-1].t,2).substr(1,7);if(cP.substr(0,1)=="0")cP=cP.substr(2);return cP;};function aN(bW){if(cj<=0)return "";if(ce[bX][bW-1].z<cJ)return "";var fN=0;fN=(cj>1)?cH[cj-2][bW-1].t:0;if(fN<0)return "";var cP=ag(cH[cj-1][bW-1].t-fN,2).substr(1,7);if(cP.substr(0,1)=="0")cP=cP.substr(2);return cP;};function aR(bW){if(cj<=0)return "";if(ce[bX][bW-1].z<cJ)return "";if(cH[cj-1][bW-1].z<0)return "";return e((cH[cj-1][bW-1].z/eZ),1);};function ax(hW){return(bX>0)?hdata[bX][hW][2]:"N";};function bS(bW,ci){var gO=0;var ix,jx,cR=false;jx=bW;for(ix=1;ix<=bX;ix++){if(hdata[ix][jx][2]=="G"){cR=true;}else{if(cR){gO++;}}}return gO;};function bi(){var gr=[0,0,0,0];var ix,jx,cR,eP=3;for(jx=1;jx<=cb;jx++){cR=false;for(ix=1;ix<=bX;ix++){switch(hdata[ix][jx][2]){case 'G':eP=0;cR=true;break;case 'B':eP=1;break;case 'N':eP=2;break;}if(cR)gr[eP]++;}}return gr;};function aL(message){if(cv==message){bM();if(bX==0){bX=1;}var gT=aW(bX);if(bX!=gT){bX=gT;ac(bX,true);}}};function resetMapCoords(kB){switch(kB){case 0:map.setZoom(fF);map.panTo(dI);break;case 1:map.panTo(dI);break;case 2:if(bX>0)map.panTo(bE(0,bX));else map.panTo(bE(0,10));break;}};function ac(da,gJ){if(da<1||da>=hdata.length)return;var ix,eM;aM();for(ix=0;ix<cb;ix++){eM=bE(ix,da);if(!Y)dr[ix].setPoint(eM);if(cl&&ix==cg-1){cn.setPoint(eM,cn.hS,cn.gG);cq.setPoint(eM,0,cq.gG);}}setHorseCoords(da,cg);timerDiv.innerHTML=hdata[da][0].substr(0,8);if(gJ){ak(true);if(cO)ah();if(cV)aG();}av(false);if(co!=cs){if(dw)be();if(dE)bq();}};function aW(ib){var ci=ib;if(cw==cF){while(ci<hdata.length-1&& +raceDuration> +ab(hdata[ci][0])){gj++;ci++;}if(ci>=hdata.length-1){ci=hdata.length-1;sendFlashVar('PAUSE',0);}}else{while(ci>1&&raceDuration<ab(hdata[ci][0])){ci--;}if(ci<=1){ci=1;sendFlashVar('PAUSE',0);}}return ci;};function av(iZ){if(!cl){cn.hide();cq.hide();return;}if(!iZ&&co==cs&&dH[gL]++ %14!=0)return;var ee= +ea+180;if((ee>100&&ee<160)||(ee>235&&ee<360)){cn.hide();cq.show();}else{cq.hide();cn.show();}};function bM(){di=(new Date()).getTime();if(cw==cF){raceDuration=((di-cx)*cB)+(+cf);}else{raceDuration=cf-((di-cx)*cB);}};function aX(bW){var kC=bW-1;var options,fq,dB,gpoint_prev=new google.maps.LatLng(1,1),dQ=bW-1;ae("mech1");if(cQ[dQ]==null){fq=new Array();for(ix=1;ix<hdata.length;ix++){if(hdata[ix][bW][2]!="G")continue;dB=ad(hdata[ix][bW][0],hdata[ix][bW][1]);if(dB.lat()!=gpoint_prev.lat()||dB.lng()!=gpoint_prev.lng())fq.push(dB);gpoint_prev=dB;}options={path:fq,strokeColor:ck[kC],strokeOpacity:1.0,strokeWeight:2};cQ[dQ]=new google.maps.Polyline(options);cQ[dQ].setMap(map);L[4].push(cQ[dQ]);}else{cQ[dQ].setMap(null);cQ[dQ]=null;}};function showLeaderLabel(iJ){if(iJ>v)return;var K=document.getElementById('leaderIcon'+iJ).innerHTML;for(var ix=0;ix<ct.length;ix++){if(K==ct[ix]){K=ix+1;break;}}an(K);};function an(K){ae("click3");if(K==0){if(dF)bp();return;}var jx,div;cT=K;if(K==cg){div=document.getElementById('legendCompetitor'+K);if(cl==false){cl=true;setHorseCoords(bX,K-1);div.style.background='#006699';div.style.color='#FFFFFF';}else{cl=false;setHorseCoords(bX,0);div.style.background=div.offsetParent.style.background;div.style.color=div.offsetParent.style.color;}}else{for(jx=1;jx<=cb;jx++){div=document.getElementById('legendCompetitor'+jx);if(jx!=K){div.style.background=div.offsetParent.style.background;div.style.color=div.offsetParent.style.color;}else{div.style.background='#006699';div.style.color='#FFFFFF';}}var iF=hdata_horse[K-1][0];var gi=D;gi=gi.replace(/xxxx/gi,iF);cn.setContents(gi);gi=C;gi=gi.replace(/xxxx/gi,iF);cq.setContents(gi);cg=K;cl=true;setHorseCoords(bX,K-1);}av(true);if(co==cA||co==cI){if(bX>0){ac(bX,false);}}};function bO(cP){var gI="";var fJ=cP.replace(/&#160;/gi," ");if(fJ.length<14)return cP;var hI=fJ.indexOf(" ");if(hI<0)return cP;var jq=Math.round(fJ.length/2);var iE=fJ.lastIndexOf(" ");if(jq-hI>iE-jq)gI=fJ.substr(0,iE)+"<br>"+fJ.substr(iE);else gI=fJ.substr(0,hI)+"<br>"+fJ.substr(hI);return gI.replace(/ /gi,"&#160;");};function aa(race_code){sendFlashVar('STOP',0);closeModelessWindows();az("Please wait a few moments<br>while the data is loading...");hdata=[];var head=document.getElementsByTagName('head').item(0);var gR=document.getElementById('rdata');if(gR)head.removeChild(gR);var script=document.createElement('script');script.src="data/"+race_code.substr(0,4)+"/"+race_code+".txt";script.type='text/javascript';script.id='rdata';head.appendChild(script);setTimeout(at,500);};function at(){try{if(hdata.length<100||hdata[1][1][0]==undefined){setTimeout(at,500);return;}}catch(kb){setTimeout(at,500);return;}bf();};function bf(){var cU=document.getElementById('mapTitle');var date=hdata_race.date.substr(6,2)+"/"+hdata_race.date.substr(4,2)+"/"+hdata_race.date.substr(0,4);cU.innerHTML=date+"&#160;&#160;"+cN+" Race Track - Race "+hdata_race.number+"&#160;&#160;("+hdata_race.distance+" metres)";aY(hdata_race.audio);cK=ad(hdata[1][1][0],hdata[1][1][1]);cd=hdata_race.distance;dJ=hdata_race.duration;cL=(fd.length==1||fd[0]==hdata_race.course)?0:1;cl=false;cg= -1;cT=1;cb=iL=hdata_horse.length;v=0;for(var ix=0;ix<hdata_horse.length;ix++){if(hdata_horse[ix][1]>0)v++;}deleteTrackOverlays(0);if(typeof(eA)!='undefined'&&eA!=null)bk(map,eA);if(typeof(B)!='undefined'&&B!=null)B.setMap(map);aH();cn.hide();cq.hide();bz(document.getElementById('legend'));kq(map.getZoom());aA(map);ah();ak(false);aB();loadCompleted();az();};function deleteTrackOverlays(iI){for(var ix=iI;ix<L.length;ix++){for(var jx=L[ix].length-1;jx>=0;jx--){if(typeof(L[ix][jx].setMap)=="function"){L[ix][jx].setMap(null);L[ix][jx]=null;L[ix].splice(jx,1);}}}if(iI>=4){ae("mech1");cQ=new Array();dN=null;}if(iI==0)deleteHorseOverlay();};function newWindow(url){window.open(url,'','');};function topWindow(url){var popup=window.open(url,"modalWin3","modal=0, resizable=1, width=676, height=496");};function helpWindow(url){var popup=window.open(url,"modalWin3","modal=0, resizable=1, width=800, height=750");};function toggleAudioOnOff(){ae("click2");var div=document.getElementById("audioToggle");if(dT= !dT){div.style.backgroundPosition="-18px 0px";if(co==cs){bC(bX);}}else{div.style.backgroundPosition="0px 0px";playAudio('stop');}};function showGraph(type){var url;ae("winopen");switch(type){case 'speed':if(graphSpeed&&graphSpeed.focus){graphSpeed.focus();return;}url='speedGraph.php?';if(window.showModelessDialog)graphSpeed=window.showModelessDialog(url,window,"dialogWidth:684px;dialogHeight:414px;center:1;resizable:0;status:0");else graphSpeed=document.open(url,"modelessWinSpeed","modal=no, dialog=no, z-lock=1, alwaysRaised=yes, dependent=1, resizable=no, width=700, height=432");break;case 'energy':if(graphEnergy&&graphEnergy.focus){graphEnergy.focus();return;}url='energyGraph.php?';if(window.showModelessDialog)graphEnergy=window.showModelessDialog(url,window,"dialogWidth:684px;dialogHeight:414px;center:1;resizable:0;status:0");else graphEnergy=document.open(url,"modelessWinEnergy","modal=no, dialog=no, z-lock=1, alwaysRaised=yes, dependent=1, resizable=no, width=700, height=432");break;case 'error':if(graphError&&graphError.focus){graphError.focus();return;}url='errorGraph.php?';if(window.showModelessDialog)graphError=window.showModelessDialog(url,window,"dialogWidth:684px;dialogHeight:414px;center:1;resizable:0;status:0");else graphError=document.open(url,"modelessWinError","modal=no, dialog=no, z-lock=1, alwaysRaised=yes, dependent=1, resizable=no, width=700, height=432");break;}};function graphLoaded(type){switch(type){case 'speed':dF=true;break;case 'energy':dw=true;break;case 'error':dE=true;break;}};function graphUnloaded(type){ae("winclose");switch(type){case 'speed':dF=false;graphSpeed="";break;case 'energy':dw=false;graphEnergy="";break;case 'error':dE=false;graphError="";break;}};function bp(){if(!graphSpeed)return;graphSpeed.updateGraph(buildSpeedArray());};function buildSpeedArray(){var ix,jx,iz,kx=0,fc,ky=0;var gY,gy=[],bZ=[];bZ[0]=new Array();bZ[0][1]=hdata_race.number;bZ[0][2]=ar(hdata_race.date);bZ[0][3]=cN;bZ[0][4]="SPEED GRAPH";bZ[0][5]=0;bZ[0][6]=200*Math.ceil(cd/200);bZ[0][7]=200;bZ[0][8]="metres";bZ[0][11]=5;bZ[0][12]="km/hour";bZ[0][13]=25;for(jx=0;jx<cb;jx++){jT=document.getElementById('chkCompetitorPath'+Math.round(jx+1));if(jT.checked&&hdata_horse[jx][1]>0)gy[kx++]=jx;}if(gy.length==0){for(jx=0;jx<cb;jx++){if(hdata_horse[jx][1]>0)gy[kx++]=jx;}}for(kx=1;kx<=gy.length;kx++){jx=gy[kx-1];bZ[kx]=new Array();bZ[kx][1]=hdata_horse[jx][0];bZ[kx][2]=ck[jx].substr(1);gY=25;ix=1;iz=3;while(gY<=cd){while(ix<ce.length){if(ce[ix][jx].z>gY){fc=bG(jx+1,ix);bZ[kx][iz++]=e(fc);if(ky<fc)ky=fc;break;}ix++;}gY+=25;}bZ[kx][0]=iz;}ky=5*Math.ceil(ky/5);bZ[0][9]=ky-25;bZ[0][10]=ky;bZ[0][0]=bZ.length;return bZ;};function be(){if(!graphEnergy||bX<6)return;graphEnergy.updateGraph(buildEnergyArray());};function buildEnergyArray(){var O=(bX>10)?bX:10;var ix,jx,kx=1,eC,eB,bZ=[];var dk,cS,eG,ca,eQ=99999999,eN=0;bZ[0]=new Array();bZ[0][0]=hdata_race.number;bZ[0][1]=ar(hdata_race.date);bZ[0][2]=cN;bZ[0][3]="ENERGY GRAPH";bZ[0][4]=0;bZ[0][5]=cd;bZ[0][6]=cd;ix=ce[O].w-1;bZ[0][7]="Energy Spent at "+Math.round(ce[O][ix].z)+" metres";bZ[0][8]=0;bZ[0][9]=40;bZ[0][10]=10;bZ[0][11]="Percent";bZ[0][12]=5;for(jx=1;jx<=cb;jx++){if(hdata_horse[jx-1][1]>0){bZ[kx]=new Array();bZ[kx][0]=hdata_horse[jx-1][0];bZ[kx][1]=ck[jx-1].substr(1);bZ[kx][2]=0;ca=0;for(ix=5;ix<O&&ix<hdata.length;ix++){eC=eB=0;while(ix<O){if(hdata[ix][jx][2]=="G"){eC=ix;break;}ix++;}ix++;while(ix<O){if(hdata[ix][jx][2]=="G"){eB=ix;break;}ix++;}if(eC!=0&&eB!=0){dk=hdata[eB][jx][0]-hdata[eC][jx][0];cS=hdata[eB][jx][1]-hdata[eC][jx][1];eG=ab(hdata[eB][0])-ab(hdata[eC][0]);if(eG>0){ca+=(dk*dk+cS*cS)/(eG*eG);}}}ca=Math.round(ca/100);bZ[kx++][2]=ca;if(ca<eQ)eQ=ca;if(ca>eN)eN=ca;}}eQ=10*Math.floor(eQ/10);eN=10*Math.ceil(eN/10);if(eN==0)eN=50;var ff=50/(eN-eQ);for(kx=1;kx<bZ.length;kx++){bZ[kx][2]=(bZ[kx][2]-eQ)*ff+50;}bZ[0][8]=50;bZ[0][9]=100;bZ[0][10]=10;return bZ;};function bq(){if(!graphError)return;graphError.updateGraph(buildErrorArray());};function buildErrorArray(){var jx,kx=1,bZ=[];var gu,ed=0;bZ[0]=new Array();bZ[0][0]=hdata_race.number;bZ[0][1]=ar(hdata_race.date);bZ[0][2]=cN;bZ[0][3]="ERROR GRAPH";bZ[0][4]=0;bZ[0][5]=cd;bZ[0][6]=cd;bZ[0][7]="Errors at "+Math.round(ce[bX][0].z)+" metres";bZ[0][8]=0;bZ[0][9]=50;bZ[0][10]=10;bZ[0][11]="Data Error Count";bZ[0][12]=5;for(jx=0;jx<cb;jx++){if(hdata_horse[jx][1]>0){bZ[kx]=new Array();bZ[kx][0]=hdata_horse[jx][0];bZ[kx][1]=ck[jx].substr(1);gu=bS(jx+1,bX);bZ[kx++][2]=gu;if(+gu> +ed)ed=gu;}}bZ[0][9]=(+ed>50)? +ed+20:50;bZ[0][10]=(+ed>50)?Math.round((ed+20)/60)*10:10;return bZ;};function toggleDivVisibility(ey,panelLayerName,ei){var eD;var visible;if(ey!="zoomMap")visible=bn(ey,panelLayerName,ei,'hugeMap');ae("zip1");switch(ey){case "raceControl":cW=visible;eD="bRaceControl";break;case "statistics":if(cO=visible)ah();eD="bStatistics";break;case "zoomMap":var hG=document.getElementById("zoomMap");var kP=document.getElementById("flashZoom");cG=visible= !cG;eD="bZoomMap";if(visible){hG.style.marginTop='0px';hG.style.marginBottom='0px';}else{hG.style.marginTop='-600px';hG.style.marginBottom='300px';}break;case "leaderBoard":if(cV=visible)aG();eD="bLeaderBoard";break;}var div=document.getElementById(eD);if(visible)div.style.backgroundPosition="0px 0px";else div.style.backgroundPosition="-14px 0px";};function aS(){var cu;cu=al("no_audio");if(!cu)toggleAudioOnOff();cu=al("vis_rcont");if(cu)cW=true;cu=al("vis_stats");if(cu)cO=true;cu=al("vis_zoom");if(cu)cG=true;cu=al("vis_rinf");if(cu)cV=true;cu=al("throttle");if(cu){cu=parseInt(cu);if(cu<100)cz=cu;}cu=al("gscale");if(cu){cu=parseInt(cu);if(cu>15&&cu<25)eg=cu;}cu=al("dcol_1");cy[0]=0;if(cu){cu=Math.round(cu);if(cu<20)cy[0]=cu;}document.getElementById('statColumn1').selectedIndex=cy[0];checkColumnChange(1);cu=al("dcol_2");cy[1]=5;if(cu){cu=Math.round(cu);if(cu<20)cy[1]=cu;}document.getElementById('statColumn2').selectedIndex=cy[1];checkColumnChange(2);if(!cW)toggleDivVisibility('raceControl','leftPanel','raceControlHeader');if(!cO)toggleDivVisibility('statistics','leftPanel','statisticsHeader');if(!cG)toggleDivVisibility('zoomMap','rightPanel','smallMapHeader');if(!cV)toggleDivVisibility('leaderBoard','rightPanel','raceInfo');en=true;};function saveCookieVariables(){var eX=50;if(!dT)aj("no_audio","true",eX);else au("no_audio");if(cW)aj("vis_rcont","true",eX);else au("vis_rcont");if(cO)aj("vis_stats","true",eX);else au("vis_stats");if(cG)aj("vis_zoom","true",eX);else au("vis_zoom");if(cV)aj("vis_rinf","true",eX);else au("vis_rinf");if(cz<100)aj("throttle",cz.toString(),eX);else au("throttle");if(eg>15&&eg<25)aj("gscale",eg.toString(),eX);else au("gscale");aj("dcol_1",cy[0].toString(),eX);aj("dcol_2",cy[1].toString(),eX);};function closeModelessWindows(){if(graphSpeed)graphSpeed.close();if(graphEnergy)graphEnergy.close();if(graphError)graphError.close();}