var kA=new RaceTimer();var cv='';var co=cI;var fG=0;var cB=1;var jA=true;var eF;var jv=null;var jO=false;var iQ=0;var lx=0;function sendFlashVar(dX,hX){var div=document.getElementById('remoteStatus');var dq=cv;ae("click2");if(eF)clearTimeout(eF);cv=dX;switch(dX){case 'PLAY':co=cs;if(dq!='PLAY'){if(dq!='FASTFORWARD'&&dq!='REWIND'){if(bX<=1||bX>=hdata.length-1){cf=0;}if(bX>=hdata.length-1){bX=1;}}else{cf=raceDuration;}cx=(new Date()).getTime();cB=1;cw=cF;div.innerHTML='PLAY';}break;case 'FASTFORWARD':co=ek;if(dq!='PAUSE'){if(bX==0){cx=(new Date()).getTime();cf=0;}else{cx=di;cf=raceDuration;}if(cw==dY){cB=1;}if(cB<64){cB*=2;}cw=cF;div.innerHTML='FFWDx'+cB;}else{cB=1;cw=cF;cv='PAUSE';dX='STOP';div.innerHTML='NEXT';if(bX<hdata.length-1){if(bX>0){cx=hdata[bX][0];cf=ab(hdata[bX][0]);}bX++;ac(bX,true);}}break;case 'REWIND':co=ew;if(dq!='PAUSE'){if(bX==0){cx=(new Date()).getTime();cf=0;}else{cx=di;cf=raceDuration;}if(cw==cF){cB=1;}if(cB<64){cB*=2;}cw=dY;div.innerHTML='REWx'+cB;}else{cB=1;cw=dY;cv='PAUSE';dX='STOP';div.innerHTML='PREV';if(bX>1){bX--;if(bX<hdata.length-1){cx=hdata[bX][0];cf=ab(hdata[bX][0]);}ac(bX,true);}}break;case 'PAUSE':co=cA;cf=raceDuration;cx=di;div.innerHTML='PAUSE';break;case 'STOP':co=cI;raceDuration=0;cf=0;cx=null;if(!Y){for(var jx=0;jx<cb;jx++){if(hdata_horse[jx][1]>0)dr[jx].setPoint(cK);}}bX=3;ac(bX,true);timerDiv.innerHTML='';cB=1;cw=cF;div.innerHTML='STOP';ak(false);break;}aq(co);if(dW&&dT){if(dX!='PLAY'){playAudio('stop');}else{if(bX==0){playAudio('play');}else{bC(bX);}}}dU=false;if(dX=='STOP'||dX=='PAUSE')if(dq!='STOP'&&dq!='PAUSE')dU=true;kA.processIncomingMessage(cv,hX);eF=setTimeout(bd,1500);};function bC(ci){var eS=ab(hdata[ci][0]);eS=eS*0.012+(+10);if(ci>0)playAudio(Math.round(eS));};function aq(mode){var ix,gq,cD=[5];cD[ew]=document.getElementById('rewindButton');cD[cs]=document.getElementById('playButton');cD[cA]=document.getElementById('pauseButton');cD[cI]=document.getElementById('stopButton');cD[ek]=document.getElementById('forwardButton');for(ix=0;ix<cD.length;ix++){gq= -ix*20;if(ix==mode)cD[ix].style.backgroundPosition="-30px "+(gq)+"px";else cD[ix].style.backgroundPosition="0px "+(gq)+"px";;}};function bd(){var div=document.getElementById('remoteStatus');if(cv=='STOP'||cv=='PLAY'){div.innerHTML='';if(cv=='STOP'){aq(ge);}}else if(cv=='PAUSE'){co=cA;aq(co);div.innerHTML=cv;}};function machineTest(){if(co!=cI&&co!=cA){alert("Animation must be stopped before\nthe Performance Test can be run.");return;}if(!confirm("The Performance Test will run for about 10 seconds.\nDo you wish to proceed?"))return;fC=true;setTimeout(bQ,10000);fH=bX;bX=50;fG=co;co=cs;setTimeout(bH,10);};function checkThrottle(){var throttle=window.prompt("Enter a throttle percentage between 50% and 100%.",cz);if(throttle==null)return;throttle=parseInt(throttle);if(throttle>100)throttle=100;if(throttle<50)throttle=50;if(cz!=throttle){cz=throttle;bj();}};function bj(){kA.throttleFrameRate(cz);var cU=document.getElementById('throt');cU.innerHTML="Throttle ["+cz+"%]";};function bH(){ac(bX++,true);if(fC)setTimeout(bH,10);};function bQ(){fC=false;var jI=ab(hdata[bX][0])-ab(hdata[50][0]);alert("Speed Test = "+Math.round(jI/100)+"%");bX=fH;co=fG;ac(++bX,true);ac(--bX,true);};function receiveFlashVar(hA){if(cv==hA){switch(hA){case 'PLAY':case 'FASTFORWARD':if(bX>hdata.length-2){bX=1;return false;}aL(hA);break;case 'REWIND':if(bX<1){bX=1;return false;}aL(hA);break;case 'STOP':case 'PAUSE':return false;}}if(dU){dU=false;return false;}return true;};function RaceTimer(){this.ln=0;this.kr=100;};RaceTimer.prototype.initialize=function(){};RaceTimer.prototype.processIncomingMessage=function(cv,hX){if(hX==0||cv=='STOP'){clearInterval(this.ln);return;}this.ln=setInterval("receiveFlashVar('"+cv+"')",this.kr);};RaceTimer.prototype.throttleFrameRate=function(fp){if(fp==undefined||fp==null||fp>100)this.kr=100;else if(fp<50)this.kr=50;else this.kr=fp;} 