﻿//FT_330_general.js_v3.3

function drawInfoTable(record)
{return'<td class="mainContent">'+'<table cellspacing="0" cellpadding="0" border="0">\x0A<tr>'+'<td width="101" class="subtitle">Venue:</td>\x0A'+'<td width="202" class="subtitle">'+record[1]+'</td>\x0A'+'<td width="115" class="subtitle">FTD:</td>\x0A'+'<td width="435" class="subtitle">'+record[6]+'</td>\x0A'+'</tr>\x0A'+'<tr>\x0A'+'<td width="101" class="subtitle">Event Name:</td>\x0A'+'<td width="202" class="subtitle">'+record[2]+'</td>\x0A'+'<td width="115" class="subtitle">Followed By:</td>\x0A'+'<td width="435" class="subtitle">'+record[7]+'</td>\x0A'+'</tr>\x0A'+'<tr>\x0A'+'<td width="101" class="subtitle">Date:</td>\x0A'+'<td width="202" class="subtitle">'+record[3]+'</td>\x0A'+'<td width="115" class="subtitle">Drivers:</td>\x0A'+'<td width="435" class="subtitle">'+record[8]+'</td>\x0A'+'</tr>\x0A<tr>\x0A<td width="101" class="subtitle">Chair:</td>\x0A'+'<td width="202" class="subtitle">'+record[4]+'</td>\x0A'+'<td width="115" class="subtitle">Runs:</td>\x0A'+'<td width="435" class="subtitle">'+record[9]+'</td>\x0A'+'</tr>\x0A'+'<tr>\x0A'+'<td width="101" class="subtitle">Event Status:</td>\x0A'+'<td width="202" class="subtitle">'+record[5]+'</td>\x0A'+'<td width="115" class="subtitle">First Car Off:</td>\x0A'+'<td width="435" class="subtitle">'+record[14]+'</script></td>\x0A'+'</tr>\x0A'+'<tr>\x0A'+'<td width="101" class="subtitle">Last Update:</td>\x0A'+'<td colspan="2" width="202" class="subtitle">'+record[11]+'</td>\x0A'+'</tr>\x0A'+'</table>\x0A';}
function rectime(sec,timeFormat){if(sec==0){return"";}
if(timeFormat==1){var hr=Math.floor(sec/3600);var min=Math.floor((sec-(hr*3600))/60);sec-=((hr*3600)+(min*60));sec+='';min+='';hr=(hr)?hr+':':'';var timeArr=roundStringResult(sec).split('.');var xSec=timeArr[0]+"";var xTh=timeArr[1]+"";while(xTh.length<3){xTh=xTh+'0';}
while(xSec.length<2){xSec='0'+xSec;}
return min+':'+xSec+"."+xTh;}
return roundStringResult(sec);}
function noPenalty(theField)
{if(theField=="")
{return"-";}else
{return theField;}}
function roundStringResult(num)
{var n;n=Number(num)
return n.toFixed(3);}
function roundResult(num)
{return num.toFixed(3);}
function paxTime(index,time,timeFormat)
{var x;x=time*index;var s=roundResult(x)+"";return rectime(s,timeFormat)}
function variance(best,time)
{var x;x=time-best;if(x==0)
{return'<< Your Best!';}
return roundResult(x);}
function compVariance(best,time)
{var x;x=time-best;if(x==0)
{return'0.000';}
return roundResult(x);}
function drawErrorBox(errMessage)
{return'<table class="messageTable" <tr><td height="100" align=center width="500">'+errMessage+' Please wait!</td></tr></table>';}
var globalTimerRef;function getStatus(){s=document.getElementById('status').title
if(s=='LIVE'){return true}
return false}
function initFullResults(){var browserType=whichBrs();getResults('fullResults.txt','renderPage')
if(getStatus()){self.clearInterval(globalTimerRef)
globalTimerRef=self.setInterval("getResults('fullResults.txt','renderPage')",61251)}}
function initBestPax(){getResults('bestpax.txt','renderPaxResults')
if(getStatus()){self.clearInterval(globalTimerRef)
globalTimerRef=window.setInterval("getResults('bestpax.txt','renderPaxResults')",61251)}}
function initBestRuns(){getResults('bestruns.txt','renderBestRuns')
if(getStatus()){self.clearInterval(globalTimerRef)
globalTimerRef=window.setInterval("getResults('bestruns.txt','renderBestRuns')",61251)}}
function initTopDrivers(){getResults('top.txt','renderTopDrivers')
if(getStatus()){self.clearInterval(globalTimerRef)
globalTimerRef=window.setInterval("getResults('top.txt','renderTopDrivers')",61251)}}
function getResults(pURL,pFunc)
{if(window.XMLHttpRequest)
{xmlhttp=new XMLHttpRequest();eval('xmlhttp.onreadystatechange='+pFunc+';');xmlhttp.open("GET",pURL,true);xmlhttp.send(null);}else if(window.ActiveXObject)
{xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');if(xmlhttp){eval('xmlhttp.onreadystatechange='+pFunc+';');xmlhttp.open('GET',pURL,false);xmlhttp.send();}}}
function updateMenuBar()
{document.getElementById("results").className=""
document.getElementById("pax").className=""
document.getElementById("bestruns").className=""
document.getElementById("topdrivers").className=""
document.getElementById("about").className=""}
function makeCursor(par)
{par.style.cursor="pointer";}
function printPage(text)
{text=document;print(text);}
function trim(stringToTrim){return stringToTrim.replace(/^\s+|\s+$/g,"");}
function ltrim(stringToTrim){return stringToTrim.replace(/^\s+/,"");}
function rtrim(stringToTrim){return stringToTrim.replace(/\s+$/,"");}
function hostType(){s=whichBrs();if(s=='handheld'){window.location="m.htm";}else{window.location="dt.htm";}}
function whichBrs(){var agt=navigator.userAgent.toLowerCase();if(agt.indexOf("iphone")!=-1)return'handheld';if(agt.indexOf("ipod")!=-1)return'handheld';if(agt.indexOf("android")!=-1)return'handheld';if(agt.indexOf("palm")!=-1)return'handheld';if(agt.indexOf("openwave")!=-1)return'handheld';if(agt.indexOf("blackberry")!=-1)return'handheld';if(agt.indexOf("ericsson")!=-1)return'handheld';if(agt.indexOf("nokia")!=-1)return'handheld';if(agt.indexOf("samsung")!=-1)return'handheld';if(agt.indexOf("panasonic")!=-1)return'handheld';if(agt.indexOf("sanyo")!=-1)return'handheld';return'desktop';}
