
(function($,Edge,compId){var Composition=Edge.Composition,Symbol=Edge.Symbol;
//Edge symbol: 'stage'
(function(symbolName){Symbol.bindElementAction(compId,symbolName,"document","compositionReady",function(sym,e){var raceID=900050;var gnNo=31261;var yearNo=2014;var raceDate=Date.UTC(2014,05,22,11,59,59);var gpDate=Date.UTC(2014,05,20,07,59,59);var headline;var headlinetxt=sym.getSymbol("styleHead").$("headlineTxt").css("pointer-events","none");var counterTxt=sym.getSymbol("circuitMc").getSymbol("status").$("statusTxt").css("pointer-events","none");var keyTxt=[];for(var k=0;k<6;k++){keyTxt[k]=sym.getSymbol("circuitMc").getSymbol("keyBase").$("key"+k).css("pointer-events","none");}
var menuIcon=[];var menuTxt=[]
for(var m=0;m<3;m++){menuIcon[m]=sym.getSymbol("styleHead").getSymbol("menuBtn"+m).$("txt").css("pointer-events","none");menuTxt[m]=sym.getSymbol("styleHead").$("menuTxt"+m).css("pointer-events","none");}
var capsTxt=[];capsTxt[0]=sym.getSymbol("styleHead").$("standTxt").css("pointer-events","none");capsTxt[1]=sym.getSymbol("styleBase").$("sourceTxt").css("pointer-events","none");capsTxt[2]=sym.getSymbol("circuitMc").$("distance").css("pointer-events","none");capsTxt[3]=sym.getSymbol("circuitMc").$("lap").css("pointer-events","none");capsTxt[4]=sym.getSymbol("circuitMc").$("drs").css("pointer-events","none");capsTxt[5]=sym.getSymbol("circuitMc").$("circuit").css("pointer-events","none");capsTxt[6]=sym.getSymbol("circuitMc").$("pit").css("pointer-events","none");var liveTxt=[];liveTxt[0]=sym.getSymbol("liveMc").getSymbol("latestMc").$("txt0").css("pointer-events","none");liveTxt[1]=sym.getSymbol("liveMc").getSymbol("latestMc").$("txt2").css("pointer-events","none");liveTxt[2]=sym.getSymbol("liveMc").getSymbol("latestMc").$("txt1").css("pointer-events","none");liveTxt[3]=sym.getSymbol("liveMc").getSymbol("latestMc").getSymbol("pitstop").$("txt").css("pointer-events","none");liveTxt[4]=sym.getSymbol("liveMc").getSymbol("timingMc").$("txt4").css("pointer-events","none");liveTxt[5]=sym.getSymbol("liveMc").getSymbol("latestMc").$("driverTxt").css("pointer-events","none");liveTxt[6]=sym.getSymbol("liveMc").getSymbol("latestMc").$("teamTxt").css("pointer-events","none");liveTxt[7]=sym.getSymbol("liveMc").getSymbol("timingMc").$("driverTxt").css("pointer-events","none");liveTxt[8]=sym.getSymbol("liveMc").getSymbol("timingMc").$("teamTxt").css("pointer-events","none");liveTxt[9]=sym.getSymbol("liveMc").getSymbol("latestMc").$("txt3").css("pointer-events","none");liveTxt[10]=sym.getSymbol("liveMc").getSymbol("timingMc").$("txt5").css("pointer-events","none");liveTxt[11]=sym.getSymbol("liveMc").getSymbol("phaseBtn2").$("gridTxt").css("pointer-events","none");var resTxt=[];for(var n=0;n<6;n++){resTxt[n]=sym.getSymbol("resultsMc").$("resultTxt"+n).css("pointer-events","none");}
var corners;var cornerTxt=[];for(var c=0;c<16;c++){cornerTxt[c]=sym.getSymbol("circuitMc").$("corner"+c).css("pointer-events","none");}
var menuIconArr=[];var keyArr=[];var menuTxtArr=[];var capsArr=[];var txtArr=[];var resArr=[];var stat;var statCap;$.ajax({type:"GET",url:"GN31388.xml",dataType:"xml",success:function(xml){headline=$(xml).find('headline').text();headlinetxt.html(headline);for(var k=0;k<6;k++){keyArr[k]=$(xml).find('key'+k).text();keyTxt[k].html(keyArr[k]);}
for(var n=0;n<12;n++){txtArr[n]=$(xml).find('txt'+n).text();}
for(var l=0;l<5;l++){liveTxt[l].html(txtArr[l]);}
var statCapString=$(xml).find('statusCap').text();statCap=statCapString.split(";")
for(var i=0;i<3;i++){menuIconArr[i]=$(xml).find('menuIcon'+i).text();menuIcon[i].html(menuIconArr[i]);menuTxtArr[i]=$(xml).find('menuTxt'+i).text();menuTxt[i].html(menuTxtArr[i]);sym.getSymbol("liveMc").getSymbol("phaseBtn"+i).$("txt").html(statCap[i]);}
for(var c=0;c<capsTxt.length;c++){capsArr[0]=$(xml).find('stand').text();capsArr[1]=$(xml).find('source').text();capsArr[2]=$(xml).find('distance').text();capsArr[3]=$(xml).find('lap').text();capsArr[4]=$(xml).find('drs').text();capsArr[5]=$(xml).find('circuit').text();capsArr[6]=$(xml).find('pit').text();capsTxt[c].html(capsArr[c]);}
for(var r=0;r<5;r++){resArr[r]=$(xml).find('results'+r).text();resTxt[r].html(resArr[r]);}
keyTxt[2].animate({left:5+keyTxt[1].width()+5},0);keyTxt[3].animate({left:5+keyTxt[1].width()+keyTxt[2].width()+20},0);keyTxt[4].animate({left:5+keyTxt[1].width()+keyTxt[2].width()+keyTxt[3].width()+30},0);keyTxt[5].animate({left:5+keyTxt[1].width()+keyTxt[2].width()+keyTxt[3].width()+keyTxt[4].width()+40},0);var cornerString=$(xml).find('corners').text();corners=cornerString.split(";");for(var i=0;i<corners.length;i++){cornerTxt[i].html(corners[i]);}
var statusString=$(xml).find('status').text();stat=statusString.split(";");liveTxt[11].html(statCap[5]);}});sym.$("handMc").css("pointer-events","none");sym.getSymbol("liveMc").getSymbol("latestMc").$("leadDriver").fadeOut(0);menuArray=[];for(var h=0;h<3;h++){var menuBtnSymbols=sym.getSymbol("styleHead").getSymbol("menuBtn"+h);menuBtnSymbols.setVariable("menuId",h);menuArray.push(menuBtnSymbols);}
$.each(menuArray,function(count,menuInTheArray){var menuBtnItem=$(menuInTheArray);var menuBtnElement=menuInTheArray.getSymbolElement();menuBtnElement.on("touchstart click",{menuId:count},menuBtnClick);menuBtnElement.on("mouseover",{menuId:count},menuShow);menuBtnElement.on("mouseout",{menuId:count},menuHide);})
function resetmenu(){for(var h=0;h<menuArray.length;h++){$.each(menuTxt,function(index,value){$(value).fadeOut(0);});for(var i=0;i<3;i++){sym.getSymbol('liveMc').getSymbol('phaseBtn'+i).$('bg').css({'background-color':'rgb(182,175,157)'});sym.getSymbol('liveMc').getSymbol('phaseBtn'+i).$('txt').css({'font-weight':400});sym.getSymbol("liveMc").getSymbol("phaseBtn"+i).$("top").fadeIn(0);sym.getSymbol("liveMc").getSymbol("phaseBtn"+i).$("top").css({"cursor":"pointer"});}
menuArray[h].$("btnClick").fadeOut(0);menuArray[h].$("btnOver").fadeOut(0);}}
resetmenu();function menuBtnClick(e){e.preventDefault();e.stopPropagation();resetmenu();var menuMenu_id=(e.data.menuId);var menuPhaseLive=(e.data.phaseLive);var sessLive=(e.data.sessionLive);var numPhases;sym.getSymbol("styleHead").getSymbol("menuBtn"+menuMenu_id).$("btnClick").fadeIn(0);menuTxt[menuMenu_id].fadeIn(0);for(var i=0;i<mcArr.length;i++){if(i==menuMenu_id){sym.$(mcArr[i]).fadeIn(1000);showMc=menuMenu_id;if(menuMenu_id==1){console.log(menuPhaseLive);sym.getSymbol("liveMc").getSymbol("latestMc").$("leadDriver").delay(500).fadeIn(1000);sym.getSymbol('liveMc').getSymbol('phaseBtn'+menuPhaseLive).$('bg').css({'background-color':'rgb(255,255,255)'});sym.getSymbol('liveMc').getSymbol('phaseBtn'+menuPhaseLive).$('txt').css({'font-weight':700});sym.getSymbol("liveMc").getSymbol("phaseBtn"+menuPhaseLive).$("top").fadeOut(0);sym.getSymbol("liveMc").getSymbol("phaseBtn"+menuPhaseLive).$("top").css({"cursor":"auto"});sym.getSymbol("liveMc").$("timingMc").fadeOut(0);sym.getSymbol("liveMc").$("latestMc").fadeIn(0);sym.getSymbol("liveMc").$("gridMc").fadeOut(0);if(menuPhaseLive==2){numPhases=2;if(sessLive==0){sym.getSymbol("liveMc").$("latestMc").fadeOut(0);sym.getSymbol("liveMc").$("gridMc").fadeIn(0);}}else{numPhases=3;}
for(n=0;n<numPhases;n++){if(menuPhaseLive<2){nos=n+1;}else{nos=n;}
if(nos==sessLive){sym.getSymbol("liveMc").getSymbol("phaseBtn"+menuPhaseLive).getSymbol(phaseArray[menuPhaseLive]+nos).$("live").css({"background-color":"rgb(119,192,61)","border-style":"solid","border-width":"2px","border-color":"rgb(76,129,0) rgb(119,192,61) rgb(119,192,61) rgb(76,129,0)"});sym.getSymbol("liveMc").getSymbol("phaseBtn"+menuPhaseLive).getSymbol(phaseArray[menuPhaseLive]+nos).$("fin").css({"background-color":"rgb(255,45,0)","border-style":"solid","border-width":"2px","border-color":"rgb(134,20,0) rgb(255,180,150) rgb(255,180,150) rgb(134,20,0)"});}else{sym.getSymbol("liveMc").getSymbol("phaseBtn"+menuPhaseLive).getSymbol(phaseArray[menuPhaseLive]+nos).$("live").css({"background-color":"rgb(119,192,61)","border-style":"solid","border-width":"2px","border-color":"rgb(119,192,61) rgb(76,129,0) rgb(76,129,0) rgb(119,192,61)"});sym.getSymbol("liveMc").getSymbol("phaseBtn"+menuPhaseLive).getSymbol(phaseArray[menuPhaseLive]+nos).$("fin").css({"background-color":"rgb(255,45,0)","border-style":"solid","border-width":"2px","border-color":"rgb(255,180,150) rgb(134,20,0) rgb(134,20,0) rgb(255,180,150)"});}}}else{if(menuMenu_id==2){for(m=0;m<10;m++){var carMove=43+m*420/nRaceDrivers;sym.getSymbol("resultsMc").$("car"+m).animate({'top':carMove},1000);}}
sym.getSymbol("liveMc").getSymbol("latestMc").$("leadDriver").fadeOut(1000);}}else{sym.$(mcArr[i]).fadeOut(1000);}}
sym.getSymbol("circuitMc").$("status").fadeOut(0);}
function menuShow(e){var menuMenu_id=(e.data.menuId);sym.$('handMc').hide();sym.getSymbol("styleHead").getSymbol("menuBtn"+menuMenu_id).$("btnOver").fadeIn(0);menuTxt[menuMenu_id].fadeIn(0);sym.getSymbol("circuitMc").$("status").fadeOut(0);}
function menuHide(e){var menuMenu_id=(e.data.menuId);sym.getSymbol("styleHead").getSymbol("menuBtn"+menuMenu_id).$("btnOver").fadeOut(0);menuTxt[menuMenu_id].fadeOut(0);sym.getSymbol("circuitMc").$("status").fadeIn(0);}
sym.getSymbol("styleHead").$("menuBtn1").off("touchstart click");sym.getSymbol("styleHead").$("menuBtn2").off("touchstart click");sym.getSymbol("styleHead").getSymbol("menuBtn0").$("btnClick").fadeIn(0);sym.getSymbol("circuitMc").$("playPause").fadeOut(0);sym.getSymbol("circuitMc").$("playPause").on('touchstart click',function(e){e.stopPropagation();e.preventDefault();playIt();});function playIt(){sym.$("introMc").fadeOut(300);sym.getSymbol("circuitMc").play(1);sym.getSymbol("circuitMc").getSymbol("carMc").play();sym.getSymbol("circuitMc").$("playPause").fadeOut();}
sym.fadeIt=function(){sym.$("introMc").fadeOut(300);}
sym.stopIt=function(){sym.getSymbol("circuitMc").stop();sym.getSymbol("circuitMc").getSymbol("carMc").stop();sym.getSymbol("circuitMc").$("playPause").fadeIn(500);}
var sessNo=["-","I","II","III"];for(var i=0;i<3;i++){sym.getSymbol("liveMc").getSymbol("phaseBtn0").getSymbol("FP"+(i+1)).$("phaseTxt").html(sessNo[i+1]);sym.getSymbol("liveMc").getSymbol("phaseBtn1").getSymbol("Q"+(i+1)).$("phaseTxt").html(sessNo[i+1]);sym.getSymbol("liveMc").getSymbol("phaseBtn"+i).$("top").css({"cursor":"pointer"});}
for(var r=0;r<2;r++){sym.getSymbol("liveMc").getSymbol("phaseBtn2").getSymbol("R"+(r)).$("phaseTxt").html(sessNo[r]);}
var counter;var diff=0;var statWidth;function countDown(){var todayDate=new Date();diff=raceDate-todayDate;var days=Math.floor(diff/86400000);var hours=Math.floor((diff%86400000)/3600000);var mins=Math.floor((diff%86400000)%3600000/60000);var secs=Math.floor((diff%86400000)%3600000%60000/1000);var dd=leadingZero(days).toString();var hh=leadingZero(hours).toString();var mm=leadingZero(mins).toString();var ss=leadingZero(secs).toString();if(todayDate<gpDate){var gpdiff=gpDate-todayDate;var gpdays=Math.floor(gpdiff/86400000);counterTxt.html(statCap[3]+": "+days+" "+stat[0]+" "+hh+":"+mm+":"+ss);if(gpdays>1){menuTxt[1].html(menuTxtArr[1]+": "+gpdays+" "+stat[0]+" "+stat[4]);}else{menuTxt[1].html(menuTxtArr[1]+": "+gpdays+" "+stat[5]+" "+stat[4]);}
menuTxt[2].html(menuTxtArr[2]+": "+days+" "+stat[0]+" "+stat[4]);}
statWidth=195-(sym.getSymbol("circuitMc").getSymbol("status").$("statusTxt").width());sym.getSymbol("circuitMc").getSymbol("status").$("statusTxt").stop().animate({'left':statWidth},0);}
function leadingZero(time){return(time<10)?"0"+time:time;}
counter=setInterval(countDown,1000);var phArr=["F","Q","R"];var phaseArray=["FP","Q","R"];var dataURL=('http:'==document.location.protocol?"http://www.graphicnews.com/":"https://www.graphicnews.org/")+"infostradasports/api.php";var raceData;var timer;var barHeight;var order;var raceFinished=0;var firstPhase;var phase;var resultCar;var scaleresult;var minTime;var scale;var nRaceDrivers;var points;var raceStage;var phaseNo;var showMc=0;var gridClicker=function(phaseNo){return function(e){getGrid(phaseNo);sym.getSymbol('liveMc').getSymbol('phaseBtn0').$('bg').css({'background-color':'rgb(182,175,157)'});sym.getSymbol('liveMc').getSymbol('phaseBtn1').$('bg').css({'background-color':'rgb(182,175,157)'});sym.getSymbol('liveMc').getSymbol('phaseBtn2').$('bg').css({'background-color':'rgb(255,255,255)'});for(n=0;n<2;n++){if(n==0){sym.getSymbol("liveMc").getSymbol('phaseBtn2').getSymbol(phaseArray[2]+(n)).$("live").css({"background-color":"rgb(119,192,61)","border-style":"solid","border-width":"2px","border-color":"rgb(76,129,0) rgb(119,192,61) rgb(119,192,61) rgb(76,129,0)"});sym.getSymbol("liveMc").getSymbol('phaseBtn2').getSymbol(phaseArray[2]+(n)).$("fin").css({"background-color":"rgb(255,45,0)","border-style":"solid","border-width":"2px","border-color":"rgb(134,20,0) rgb(255,180,150) rgb(255,180,150) rgb(134,20,0)"});}else{sym.getSymbol("liveMc").getSymbol('phaseBtn2').getSymbol(phaseArray[2]+(n)).$("live").css({"background-color":"rgb(119,192,61)","border-style":"solid","border-width":"2px","border-color":"rgb(119,192,61) rgb(76,129,0) rgb(76,129,0) rgb(119,192,61)"});sym.getSymbol("liveMc").getSymbol('phaseBtn2').getSymbol(phaseArray[2]+(n)).$("fin").css({"background-color":"rgb(255,45,0)","border-style":"solid","border-width":"2px","border-color":"rgb(255,180,150) rgb(134,20,0) rgb(134,20,0) rgb(255,180,150)"});}}
sym.getSymbol("liveMc").$("gridMc").fadeIn(1000);sym.getSymbol("liveMc").$("timingMc").fadeOut(1000);sym.getSymbol("liveMc").$("latestMc").fadeOut(1000);e.preventDefault();e.stopPropagation();};};var showPhase=function(phaseNo,stage,session){return function(e){getPhases(phaseNo);var ps=stage.substr(0,1);var nos;for(var i=0;i<3;i++){var button="phaseBtn"+i;if(i==2){var numPhases=2;}else{var numPhases=3;}
if(ps==phArr[i]){sym.getSymbol("liveMc").getSymbol(button).$("top").fadeOut(0);sym.getSymbol('liveMc').getSymbol(button).$('bg').css({'background-color':'rgb(255,255,255)'});sym.getSymbol('liveMc').getSymbol(button).$('txt').css({'font-weight':700});sym.getSymbol("liveMc").getSymbol(button).$("top").css({"cursor":"auto"});liveTxt[10].html(statCap[4]+" "+sessNo[session]);for(n=0;n<numPhases;n++){if(i<2){nos=n+1;}else{nos=n;}
if(nos==session){sym.getSymbol("liveMc").getSymbol(button).getSymbol(phaseArray[i]+(nos)).$("live").css({"background-color":"rgb(119,192,61)","border-style":"solid","border-width":"2px","border-color":"rgb(76,129,0) rgb(119,192,61) rgb(119,192,61) rgb(76,129,0)"});sym.getSymbol("liveMc").getSymbol(button).getSymbol(phaseArray[i]+(nos)).$("fin").css({"background-color":"rgb(255,45,0)","border-style":"solid","border-width":"2px","border-color":"rgb(134,20,0) rgb(255,180,150) rgb(255,180,150) rgb(134,20,0)"});}else{sym.getSymbol("liveMc").getSymbol(button).getSymbol(phaseArray[i]+(nos)).$("live").css({"background-color":"rgb(119,192,61)","border-style":"solid","border-width":"2px","border-color":"rgb(119,192,61) rgb(76,129,0) rgb(76,129,0) rgb(119,192,61)"});sym.getSymbol("liveMc").getSymbol(button).getSymbol(phaseArray[i]+(nos)).$("fin").css({"background-color":"rgb(255,45,0)","border-style":"solid","border-width":"2px","border-color":"rgb(255,180,150) rgb(134,20,0) rgb(134,20,0) rgb(255,180,150)"});}}}else{sym.getSymbol("liveMc").getSymbol(button).$("top").fadeIn(0);sym.getSymbol('liveMc').getSymbol(button).$('bg').css({'background-color':'rgb(182,175,157)'});sym.getSymbol('liveMc').getSymbol(button).$('txt').css({'font-weight':400});sym.getSymbol("liveMc").getSymbol(button).$("top").css({"cursor":"pointer"});for(n=0;n<numPhases;n++){if(i<2){nos=n+1;}else{nos=n;}
sym.getSymbol("liveMc").getSymbol(button).getSymbol(phaseArray[i]+(nos)).$("live").css({"background-color":"rgb(40,142,86)","border":"solid 2px rgba(182,175,157,1.00)"});sym.getSymbol("liveMc").getSymbol(button).getSymbol(phaseArray[i]+(nos)).$("fin").css({"background-color":"rgb(216,89,80)","border":"solid 2px rgba(182,175,157,1.00)"});}}}
sym.getSymbol("liveMc").$("gridMc").fadeOut(1000);sym.getSymbol("liveMc").$("timingMc").fadeIn(1000);sym.getSymbol("liveMc").$("latestMc").fadeOut(1000);showMc=1;e.preventDefault();e.stopPropagation();}}
var showLive=function(phaseNo,stage){return function(e){var ps=stage.substr(0,1);var session=stage.substr(-1);var nos;for(var i=0;i<3;i++){var button="phaseBtn"+i;if(i==2){var numPhases=2;}else{var numPhases=3;}
if(ps==phArr[i]){sym.getSymbol("liveMc").getSymbol(button).$("top").fadeOut(0);sym.getSymbol('liveMc').getSymbol(button).$('bg').css({'background-color':'rgb(255,255,255)'});sym.getSymbol('liveMc').getSymbol(button).$('txt').css({'font-weight':700});sym.getSymbol("liveMc").getSymbol(button).$("top").css({"cursor":"auto"});if(ps=="R"){if(stage.substr(1,1)==1){sym.getSymbol("liveMc").$("gridMc").fadeOut(1000);sym.getSymbol("liveMc").$("timingMc").fadeOut(1000);sym.getSymbol("liveMc").$("latestMc").fadeIn(1000);}else{sym.getSymbol("liveMc").$("gridMc").fadeIn(1000);sym.getSymbol("liveMc").$("timingMc").fadeOut(1000);sym.getSymbol("liveMc").$("latestMc").fadeOut(1000);}}else{sym.getSymbol("liveMc").$("gridMc").fadeOut(1000);sym.getSymbol("liveMc").$("timingMc").fadeOut(1000);sym.getSymbol("liveMc").$("latestMc").fadeIn(1000);}
for(n=0;n<numPhases;n++){if(i<2){nos=n+1;}else{nos=n;}
if(nos==session){sym.getSymbol("liveMc").getSymbol(button).getSymbol(phaseArray[i]+(nos)).$("live").css({"background-color":"rgb(119,192,61)","border-style":"solid","border-width":"2px","border-color":"rgb(76,129,0) rgb(119,192,61) rgb(119,192,61) rgb(76,129,0)"});sym.getSymbol("liveMc").getSymbol(button).getSymbol(phaseArray[i]+(nos)).$("fin").css({"background-color":"rgb(255,45,0)","border-style":"solid","border-width":"2px","border-color":"rgb(134,20,0) rgb(255,180,150) rgb(255,180,150) rgb(134,20,0)"});}else{sym.getSymbol("liveMc").getSymbol(button).getSymbol(phaseArray[i]+(nos)).$("live").css({"background-color":"rgb(119,192,61)","border-style":"solid","border-width":"2px","border-color":"rgb(119,192,61) rgb(76,129,0) rgb(76,129,0) rgb(119,192,61)"});sym.getSymbol("liveMc").getSymbol(button).getSymbol(phaseArray[i]+(nos)).$("fin").css({"background-color":"rgb(255,45,0)","border-style":"solid","border-width":"2px","border-color":"rgb(255,180,150) rgb(134,20,0) rgb(134,20,0) rgb(255,180,150)"});}}}else{sym.getSymbol("liveMc").getSymbol(button).$("top").fadeIn(0);sym.getSymbol('liveMc').getSymbol(button).$('bg').css({'background-color':'rgb(182,175,157)'});sym.getSymbol('liveMc').getSymbol(button).$('txt').css({'font-weight':400});sym.getSymbol("liveMc").getSymbol(button).$("top").css({"cursor":"pointer"});for(n=0;n<numPhases;n++){if(i<2){nos=n+1;}else{nos=n;}
sym.getSymbol("liveMc").getSymbol(button).getSymbol(phaseArray[i]+(nos)).$("live").css({"background-color":"rgb(40,142,86)","border":"solid 2px rgba(182,175,157,1.00)"});sym.getSymbol("liveMc").getSymbol(button).getSymbol(phaseArray[i]+(nos)).$("fin").css({"background-color":"rgb(216,89,80)","border":"solid 2px rgba(182,175,157,1.00)"});}}}
showMc=1;e.preventDefault();e.stopPropagation();}}
function showFinished(latest){sym.getSymbol("styleHead").$("menuBtn2").on("touchstart click",{menuId:2},menuBtnClick);menuTxt[2].html(menuTxtArr[2]);sym.getSymbol("liveMc").getSymbol("phaseBtn2").$("txt").html(statCap[3]);sym.getSymbol("liveMc").getSymbol("latestMc").$("pitstop").fadeIn(0);sym.getSymbol("liveMc").getSymbol("latestMc").$("txt0").fadeIn(0);sym.getSymbol("liveMc").getSymbol("latestMc").$("lapCounter").fadeIn(0);sym.getSymbol("circuitMc").getSymbol("status").$("statusTxt").css({"background-color":"rgb(255,45,0)","box-shadow":"0px 0px 10px 10px rgba(255,255,255,0.2)"});sym.getSymbol("circuitMc").getSymbol("status").$("statusTxt").html(latest+" "+txtArr[6].toLowerCase());getStandings();clearInterval(raceInterval);raceInterval=setInterval(getRace,600000);raceFinished=1;}
function sessLiveOrFin(latest){sym.getSymbol("circuitMc").getSymbol("status").$("statusTxt").html(latest);}
function getRace(){sym.getSymbol("styleHead").$("menuBtn1").off("click touchstart");sym.getSymbol("styleHead").$("menuBtn2").off("click touchstart");$.ajax({type:"GET",url:dataURL,data:"gn="+gnNo+"&yr="+yearNo+"&q=race&race="+raceID,contentType:"text/plain",dataType:"jsonp",jsonp:"callback",async:true,crossDomain:true,success:function(data){for(var z=0;z<3;z++){sym.getSymbol("liveMc").getSymbol("phaseBtn"+z).$('top').unbind("click");sym.getSymbol("liveMc").getSymbol("phaseBtn0").$("FP"+(z+1)).unbind("click");sym.getSymbol("liveMc").getSymbol("phaseBtn1").$("Q"+(z+1)).unbind("click");sym.getSymbol("liveMc").getSymbol("phaseBtn2").$("R"+z).unbind("click");}
var racePhases=data;var n;var latestPhase;var getFunction;var phaseBtnNo;if(racePhases){for(var i=0;i<racePhases.length;i++){phase=racePhases[i].n_PhaseID;var sessionNo=(racePhases[i].n_SessionNr>0)?racePhases[i].n_SessionNr:"";var sessLive=(racePhases[i].b_Current==true)?1:0;var sessStarted=(racePhases[i].b_Started==true)?1:0;var sessFin=(racePhases[i].b_Finished==true)?1:0;var nullSession=0;var notStarted;if(racePhases[i].b_FreePractice==true){n=racePhases[i].n_Phase1Nr;phaseBtnNo="0";raceStage="FP";latestPhase=statCap[0];}else if(racePhases[i].b_Qualifying==true&&racePhases[i].n_Phase2Nr==null){sessLive=0;sessFin=0;sessStarted=0;nullSession=1;}else if(racePhases[i].b_Qualifying==true&&racePhases[i].n_Phase2Nr>0){n=racePhases[i].n_Phase2Nr;phaseBtnNo="1";raceStage="Q";latestPhase=statCap[1];}else if(racePhases[i].b_StartingGrid==true){n="0";phaseBtnNo="2";raceStage="R";latestPhase=statCap[2];}else if(racePhases[i].b_Race==true){n="1";phaseBtnNo="2";raceStage="R";latestPhase=statCap[3];}
if(nullSession<1){sym.getSymbol("liveMc").getSymbol("phaseBtn"+phaseBtnNo).$("top").unbind("click");if(sessLive==1){sessLiveOrFin(latestPhase);if(sessStarted==1){getInfo(phase);getLive(phase);menuTxt[1].html(menuTxtArr[1]);if(racePhases[i].b_Race==true){sym.getSymbol("liveMc").getSymbol("phaseBtn2").$("txt").html(statCap[3]);getFunction=showLive(phase,raceStage+n);}else if(racePhases[i].b_StartingGrid==true){getFunction=gridClicker(phase);}else{getFunction=showPhase(phase,raceStage+n,sessionNo);}
if(sessFin==1){sym.getSymbol("liveMc").getSymbol("phaseBtn"+phaseBtnNo).getSymbol(raceStage+n).$("fin").show();if(racePhases[i].b_Race==true){showFinished(latestPhase);}else if(racePhases[i].b_StartingGrid==true){sym.getSymbol("circuitMc").getSymbol("status").$("statusTxt").css({"background-color":"rgb(119,192,61)","box-shadow":"0px 0px 10px 10px rgba(255,255,255,0.2)"});}else{sym.getSymbol("circuitMc").getSymbol("status").$("statusTxt").css({"background-color":"rgb(255,45,0)","box-shadow":"0px 0px 10px 10px rgba(255,255,255,0.2)"});}}else{sym.getSymbol("liveMc").getSymbol("phaseBtn"+phaseBtnNo).getSymbol(raceStage+n).$("live").show();sym.getSymbol("styleHead").$("menuBtn2").off("touchstart click");sym.getSymbol("circuitMc").getSymbol("status").$("statusTxt").css({"background-color":"rgb(119,192,61)","box-shadow":"0px 0px 10px 10px rgba(255,255,255,0.2)"});}}else{if(raceStage=="FP"&&n==1){notStarted=1;}else{getInfo(phase);getLive(phase);}}}else if(sessFin==1){sessLiveOrFin(latestPhase);sym.getSymbol("liveMc").getSymbol("phaseBtn"+phaseBtnNo).getSymbol(raceStage+n).$("fin").show();sym.getSymbol("circuitMc").getSymbol("status").$("statusTxt").css({"background-color":"rgb(255,45,0)","box-shadow":"0px 0px 10px 10px rgba(255,255,255,0.2)"});if(racePhases[i].b_Race==true){showFinished(latestPhase);getInfo(phase);getLive(phase);getFunction=showLive(phase,raceStage+n);}else if(racePhases[i].b_StartingGrid==true){getFunction=gridClicker(phase);}else{liveTxt[4].fadeIn(0);getFunction=showPhase(phase,raceStage+n,sessionNo);}}
sym.getSymbol("liveMc").getSymbol("phaseBtn"+phaseBtnNo).$(raceStage+n).css({"cursor":"pointer"});sym.getSymbol("liveMc").getSymbol("phaseBtn"+phaseBtnNo).$(raceStage+n).click(getFunction);sym.getSymbol("liveMc").getSymbol("phaseBtn"+phaseBtnNo).$("top").click(getFunction);}}
phaseNo=phaseBtnNo;if(notStarted==1){getInfo(raceID);getStartList();}}else{getInfo(raceID);getStartList();}}});}
getRace();raceInterval=setInterval(getRace,60000);sym.getSymbol("liveMc").getSymbol("latestMc").$("weather").append('<img src="images/weather0.png" width="27px" height="27px">');var gridPhase=0;function getInfo(phaseID){$.ajax({type:"GET",url:dataURL,data:"gn="+gnNo+"&yr="+yearNo+"&q=info&race="+phaseID,contentType:"text/plain",dataType:"jsonp",jsonp:"callback",async:true,crossDomain:true,success:function(data){sym.getSymbol("liveMc").getSymbol("latestMc").$("weather").empty();liveTxt[0].fadeOut(0);sym.getSymbol("liveMc").getSymbol("latestMc").$("lapCounter").fadeOut(0);if(data){if(data[0].n_WeatherConditionType!=null){var weather='<img src="images/weather'+data[0].n_WeatherConditionType+'.png" width="24px" height="24px">';sym.getSymbol("liveMc").getSymbol("latestMc").$("weather").append(weather);liveTxt[2].fadeIn(0);}else{sym.getSymbol("liveMc").getSymbol("latestMc").$("weather").empty();liveTxt[2].fadeOut(0);}
var sessionNo=(data[0].n_SessionNr>0)?data[0].n_SessionNr:"";var laps=data[0].n_LapsScheduled;var lapsDriven=data[0].n_LapsDriven;var lapsAngle=360*lapsDriven/laps;liveTxt[0].html(txtArr[0]+" <b>"+lapsDriven+"/"+laps+"</b>");if(lapsDriven/laps<0.5){sym.getSymbol("liveMc").getSymbol("latestMc").getSymbol("lapCounter").$("laps1").animate({rotate:lapsAngle},{step:function(now,fx){$(this).css('-webkit-transform','rotate('+now+'deg)');$(this).css('-moz-transform','rotate('+now+'deg)');$(this).css('-ms-transform','rotate('+now+'deg)');$(this).css('-op-transform','rotate('+now+'deg)');$(this).css('transform','rotate('+now+'deg)');},duration:'fast'},'linear');}else if(lapsDriven/laps>=0.5){sym.getSymbol("liveMc").getSymbol("latestMc").getSymbol("lapCounter").$("laps1").animate({rotate:180},{step:function(now,fx){$(this).css('-webkit-transform','rotate(180deg)');$(this).css('-moz-transform','rotate(180deg)');$(this).css('-moz-transform','rotate(180deg)');$(this).css('-ms-transform','rotate(180deg)');$(this).css('-op-transform','rotate(180deg)');$(this).css('transform','rotate(180deg)');},duration:'fast'},'linear');sym.getSymbol("liveMc").getSymbol("latestMc").getSymbol("lapCounter").$("laps2").show();sym.getSymbol("liveMc").getSymbol("latestMc").getSymbol("lapCounter").$("laps2").animate({rotate:lapsAngle},{step:function(now,fx){$(this).css('-webkit-transform','rotate('+now+'deg)');$(this).css('-moz-transform','rotate('+now+'deg)');$(this).css('-ms-transform','rotate('+now+'deg)');$(this).css('-op-transform','rotate('+now+'deg)');$(this).css('transform','rotate('+now+'deg)');},duration:'fast'},'linear');}
sym.getSymbol("styleHead").$("menuBtn1").off("touchstart click");clearInterval(raceInterval);if(data[0].b_FreePractice==true){sym.getSymbol("styleHead").$("menuBtn1").on("touchstart click",{menuId:1,"phaseLive":0,"sessionLive":sessionNo},menuBtnClick);liveTxt[1].html(txtArr[4]);liveTxt[9].html(statCap[0]+" "+sessionNo);phaseNo=0;showMc=1;}else if(data[0].b_Qualifying==true){sym.getSymbol("styleHead").$("menuBtn1").on("touchstart click",{menuId:1,"phaseLive":1,"sessionLive":sessionNo},menuBtnClick);liveTxt[1].html(txtArr[4]);liveTxt[9].html(statCap[1]+" "+sessionNo);phaseNo=1;showMc=1;}else if(data[0].b_StartingGrid==true){sym.getSymbol("styleHead").$("menuBtn1").on("click touchstart",{menuId:1,"phaseLive":2,"sessionLive":0},menuBtnClick);phaseNo=2;showMc=1;gridPhase=phaseID;}else if(data[0].b_Race==true){phaseNo=2;sym.getSymbol("styleHead").$("menuBtn1").on("touchstart click",{menuId:1,"phaseLive":2,"sessionLive":1},menuBtnClick);liveTxt[1].html(txtArr[1]);liveTxt[11].fadeIn(0);liveTxt[0].fadeIn(0);sym.getSymbol("liveMc").getSymbol("latestMc").$("lapCounter").fadeIn(0);if(data[0].b_Finished==true){liveTxt[9].html(txtArr[6]);showMc=2;}else{liveTxt[9].html(txtArr[5]);showMc=1;}}else{sym.getSymbol("styleHead").$("menuBtn1").on("touchstart click",{menuId:1,"phaseLive":0,"sessionLive":1},menuBtnClick);liveTxt[1].html(txtArr[4]);liveTxt[9].html(statCap[0]);liveTxt[0].html(txtArr[0]);liveTxt[0].fadeIn(0);sym.getSymbol("liveMc").getSymbol("latestMc").$("weather").empty();sym.getSymbol("liveMc").getSymbol("latestMc").$("weather").append('<img src="images/weather1.png" width="24px" height="24px">');sym.getSymbol("liveMc").getSymbol("latestMc").$("lapCounter").fadeIn(0);sym.getSymbol("liveMc").getSymbol("latestMc").getSymbol("lapCounter").$("laps1").fadeOut(0);sym.getSymbol("liveMc").getSymbol("latestMc").getSymbol("lapCounter").$("laps2").fadeOut(0);showMc=0;}
if(data[0].b_Finished==true){raceInterval=setInterval(getRace,300000);}else if(data[0].b_Started==true){raceInterval=setInterval(getRace,45000);}else{raceInterval=setInterval(getRace,300000);}}else{sym.getSymbol("styleHead").$("menuBtn1").on("touchstart click",{menuId:1,"phaseLive":0,"sessionLive":1},menuBtnClick);liveTxt[1].html(txtArr[4]);liveTxt[9].html(statCap[0]);liveTxt[0].html(txtArr[0]);liveTxt[0].fadeIn(0);sym.getSymbol("liveMc").getSymbol("latestMc").$("weather").empty();sym.getSymbol("liveMc").getSymbol("latestMc").$("weather").append('<img src="images/weather1.png" width="24px" height="24px">');sym.getSymbol("liveMc").getSymbol("latestMc").$("lapCounter").fadeIn(0);sym.getSymbol("liveMc").getSymbol("latestMc").getSymbol("lapCounter").$("laps1").fadeOut(0);sym.getSymbol("liveMc").getSymbol("latestMc").getSymbol("lapCounter").$("laps2").fadeOut(0);showMc=0;}}});}
function getStartList(){$.ajax({type:"GET",url:dataURL,data:"gn="+gnNo+"&yr="+yearNo+"&q=startlist&race=",contentType:"text/plain",dataType:"jsonp",jsonp:"callback",async:true,crossDomain:true,success:function(data){var startData=data;if(startData.length>20){barHeight=((420/startData.length)-2);}else{barHeight=19;}
for(var i=0;i<startData.length;i++){if(i==0){sym.getSymbol("liveMc").getSymbol("latestMc").$("graph").empty();sym.getSymbol("liveMc").getSymbol("latestMc").$("helmetPic").empty();sym.getSymbol("liveMc").getSymbol("latestMc").$("driverPic").empty();sym.getSymbol("liveMc").getSymbol("latestMc").$("carPic").empty();sym.getSymbol("liveMc").getSymbol("latestMc").$("helmetPic").empty();sym.getSymbol("liveMc").getSymbol("latestMc").$("driverPic").empty();var imgHelmet='<img src="drivers/'+startData[i].n_PersonID+'.png" width="105px" height="82px">';var imgDriver='<img src="drivers/'+startData[i].n_PersonID+'.jpg" width="105px">';var imgCar='<img src="cars/'+startData[i].c_TeamShort+'.png" width="330px">';var leadDriver='<b>'+startData[i].c_Person+'</b> <span style="font-size:12px"><i>'+startData[i].c_NOCShort+'</i></span>';liveTxt[5].html(leadDriver);var conText=(startData[i].c_ConstructorTeam=="RedBull - Renault")?"Red Bull - Renault":startData[i].c_ConstructorTeam;liveTxt[6].text(conText);sym.getSymbol("liveMc").getSymbol("latestMc").$("helmetPic").append(imgHelmet);sym.getSymbol("liveMc").getSymbol("latestMc").$("driverPic").append(imgDriver);sym.getSymbol("liveMc").getSymbol("latestMc").$("carPic").append(imgCar);}
var tableText="<div class='race'>";tableText+="<div id='driverdata"+i+"'>";tableText+="<table style='width:100%; border:none; border-collapse:collapse; padding:0; margin:0'><tr>";tableText+="<td id='driverNo"+i+"'></td>";tableText+="<td id='driver"+i+"'width='130px'></td>";tableText+="<td id='team"+i+"' style='font-style:italic' width='35px'></td>";tableText+="<td id='pitstops"+i+"' style='font-weight:bold' width='20px'></td>";tableText+="</tr></table>";tableText+="</div></div>";sym.getSymbol("liveMc").getSymbol("latestMc").$("graph").append(tableText);$('#driver'+i).text(startData[i].c_Person);$('#team'+i).text(startData[i].c_TeamShort);$('#pitstops'+i).text("0");$('#pitstops'+i).css({'font-weight':'bold','text-align':'center','color':'rgb(255,255,255)','background-color':'rgba(0,0,0,0.15)'});$('#driverNo'+i).text(startData[i].c_ShirtNr);$(".race").css({'font-size':'13px','font-family':'pragmatica-web, sans-serif','width':'100%','margin-bottom':'2px'});$("#driverNo"+i).css({'width':'10%','padding-right':'5px'});$("#driverdata"+i).css({'height':barHeight+'px','width':'55%','background-color':'rgb(230,225,215)','padding-left':'5px','box-shadow':'3px 2px 5px rgba(100,100,100,0.75)'});}}});}
function getLive(phaseID){$.ajax({type:"GET",url:dataURL,data:"gn="+gnNo+"&yr="+yearNo+"&race="+phaseID,contentType:"text/plain",dataType:"jsonp",jsonp:"callback",async:true,crossDomain:true,success:function(data){raceData=data;nRaceDrivers=raceData.length;if(raceData.length>20){barHeight=((420/raceData.length)-2);}else{barHeight=19;}
if(raceStage=="R"){minTime=raceData[0].n_TimeRel;var mxm=(minTime!=null)?minTime:0;var timeRel=0;for(var n=0;n<raceData.length;n++){if(raceData[n].n_TimeRel!=null&&raceData[n].n_TimeRel>mxm){mxm=raceData[n].n_TimeRel;}}}else if(raceData[0].n_TimeAbs!=undefined){minTime=raceData[0].n_TimeAbs;var mxm=(minTime!=null)?minTime:0;var timeRel=1;for(var n=0;n<raceData.length;n++){if(raceData[n].n_TimeAbs!=null&&raceData[n].n_TimeAbs>mxm){mxm=raceData[n].n_TimeAbs;}
if(raceData[n].n_TimeAbs!=null&&raceData[n].n_TimeAbs<minTime){minTime=raceData[n].n_TimeAbs;}}}
sym.getSymbol("resultsMc").$("graph").empty();sym.getSymbol("resultsMc").$("helmetPic").empty();sym.getSymbol("resultsMc").$("driverPic").empty();for(var i=0;i<raceData.length;i++){if(i==0){sym.getSymbol("liveMc").getSymbol("latestMc").$("graph").empty();sym.getSymbol("liveMc").getSymbol("latestMc").$("helmetPic").empty();sym.getSymbol("liveMc").getSymbol("latestMc").$("driverPic").empty();sym.getSymbol("liveMc").getSymbol("latestMc").$("carPic").empty();sym.getSymbol("liveMc").getSymbol("latestMc").$("helmetPic").empty();sym.getSymbol("liveMc").getSymbol("latestMc").$("driverPic").empty();var imgHelmet='<img src="drivers/'+raceData[i].n_PersonID+'.png" width="105px" height="82px">';var imgDriver='<img src="drivers/'+raceData[i].n_PersonID+'.jpg" width="105px">';var imgCar='<img src="cars/'+raceData[i].c_TeamShort+'.png" width="330px">';var leadDriver='<b>'+raceData[i].c_Person+'</b> <span style="font-size:12px"><i>'+raceData[i].c_NOCShort+'</i></span>';liveTxt[5].html(leadDriver);liveTxt[6].text(raceData[i].c_ConstructorTeam);sym.getSymbol("liveMc").getSymbol("latestMc").$("helmetPic").append(imgHelmet);sym.getSymbol("liveMc").getSymbol("latestMc").$("driverPic").append(imgDriver);sym.getSymbol("liveMc").getSymbol("latestMc").$("carPic").append(imgCar);sym.getSymbol("resultsMc").$("helmetPic").append(imgHelmet);sym.getSymbol("resultsMc").$("driverPic").append(imgDriver);resTxt[5].html(leadDriver);}
var tableText="<div class='race'>";tableText+="<div id='driverdata"+i+"'>";tableText+="<table style='width:100%; border:none; border-collapse:collapse; padding:0; margin:0'><tr>";tableText+="<td id='driver"+i+"'width='130px'></td>";tableText+="<td id='team"+i+"' style='font-style:italic' width='35px'></td>";tableText+="<td id='pitstops"+i+"' style='font-weight:bold' width='20px'></td>";tableText+="<td id='time"+i+"'></td>";tableText+="</tr></table>";tableText+="</div></div>";var resultsText="<div class='resultrace'>";resultsText+="<div id='resultdata"+i+"'>";resultsText+="<table style='width:100%; border:none; border-collapse:collapse; padding:0; margin:0'><tr>";resultsText+="<td id='resultorder"+i+"' width='20px'></td>";resultsText+="<td id='resultdriver"+i+"' width='140px'></td>";resultsText+="<td id='resultteam"+i+"' style='font-style:italic' width='30px'></td>";resultsText+="<td id='points"+i+"'></td>";resultsText+="</tr></table>";resultsText+="</div>";resultsText+="</div>";sym.getSymbol("liveMc").getSymbol("latestMc").$("graph").append(tableText);$('#driver'+i).text(raceData[i].c_Person);$('#team'+i).text(raceData[i].c_TeamShort);if(raceData[i].n_PitStops){$('#pitstops'+i).text(raceData[i].n_PitStops);$('#pitstops'+i).css({'font-weight':'bold','text-align':'center','color':'rgb(255,255,255)','background-color':'rgba(0,0,0,0.15)'});}
if(timeRel==1){var hrs=(raceData[i].n_TimeAbs>3600000)?Math.floor(raceData[i].n_TimeAbs/3600000)+":":"";var mins=(raceData[i].n_TimeAbs>3600000)?Math.floor((raceData[i].n_TimeAbs%3600000)/60000):Math.floor(raceData[i].n_TimeAbs/60000);if(mins<10){mins="0"+mins+":";}else if(mins<1){mins="00:";}else{mins=mins+":";}
var secs=(raceData[i].n_TimeAbs>3600000)?(raceData[i].n_TimeAbs%3600000%60000)/1000:(raceData[i].n_TimeAbs%60000%60000)/1000;if(secs<10){secs="0"+secs;}
var timing=hrs+mins+secs;$('#time'+i).text(timing);if(minTime==mxm&&raceData[i].n_TimeAbs==mxm){scale=100;}else if(raceData[i].n_TimeAbs==null){scale=57;}else{scale=100-((raceData[i].n_TimeAbs-minTime)*43/(mxm-minTime));}}else if(timeRel==0){if(raceData[i].n_RankSort==1&&raceData[i].n_TimeAbs==null){scale=100;$('#time'+i).text();}else if(raceData[i].n_TimeRel==null){scale=57;if(raceData[i].c_ResultSuffix==null){}else{$('#time'+i).text(raceData[i].c_ResultSuffix);}}else{scale=100-(raceData[i].n_TimeRel*43/mxm);$('#time'+i).text(raceData[i].c_Result);}}
$(".race").css({'font-size':'13px','font-family':'pragmatica-web, sans-serif','width':'100%','margin-bottom':'2px'});$("#driverdata"+i).css({'height':barHeight+'px','width':scale+'%','background-color':'rgb(230,225,215)','padding-left':'5px','box-shadow':'3px 2px 5px rgba(100,100,100,0.75)'});$("#time"+i).css({'text-align':'right','padding-right':'5px'});if(raceFinished==1){sym.getSymbol("resultsMc").$("graph").append(resultsText);sym.getSymbol("resultsMc").$("car"+i).empty();resultCar='<img src="cars/'+raceData[i].c_TeamShort+'o.png" width="30px">';order=raceData[i].n_RankSort;if(raceData[i].c_ChampionshipPoints!=undefined){points=raceData[i].c_ChampionshipPoints;}else{points=0;}
if(order<11){scaleresult=94-(i*6);}else{scaleresult=37;}
$('#resultorder'+i).html("<b>"+order+"</b>");$('#resultdriver'+i).text(raceData[i].c_Person);$('#resultteam'+i).text(raceData[i].c_TeamShort);$('#points'+i).html("<b>"+points+"</b>");$(".resultrace").css({'font-size':'13px','font-family':'pragmatica-web, sans-serif','width':'100%','margin-bottom':'2px'});$("#resultdata"+i).css({'height':barHeight+'px','width':scaleresult+'%','background-color':'rgb(230,225,215)','box-shadow':'3px 2px 5px rgba(100,100,100,0.75)','padding-left':'3px'});$("#points"+i).css({'text-align':'right','padding-right':'5px'});sym.getSymbol("resultsMc").$("car"+i).append(resultCar);}}
menuTxt[1].html(menuTxtArr[1]);}});}
var scalePhase;function getPhases(phaseID){sym.getSymbol("liveMc").$("loader-bar").fadeIn(0);$.ajax({type:"GET",url:dataURL,data:"gn="+gnNo+"&yr="+yearNo+"&race="+phaseID,contentType:"text/plain",dataType:"jsonp",jsonp:"callback",async:true,crossDomain:true,success:function(data){sym.getSymbol("liveMc").$("loader-bar").fadeOut(0);var phaseData=data;sym.getSymbol("liveMc").getSymbol("timingMc").$("graph").empty();sym.getSymbol("liveMc").getSymbol("timingMc").$("helmetPic").empty();sym.getSymbol("liveMc").getSymbol("timingMc").$("driverPic").empty();sym.getSymbol("liveMc").getSymbol("timingMc").$("carPic").empty();menuTxt[2].html(menuTxtArr[2]);if(phaseData.length>20){barHeight=(420/phaseData.length)-2;}else{barHeight=19;}
minTime=phaseData[0].n_TimeAbs;var max=(minTime!=null)?minTime:0;for(var n=0;n<phaseData.length;n++){if(phaseData[n].n_TimeAbs!=null&&phaseData[n].n_TimeAbs>max){max=phaseData[n].n_TimeAbs;}
if(phaseData[n].n_TimeAbs!=null&&phaseData[n].n_TimeAbs<minTime){minTime=phaseData[n].n_TimeAbs;}}
for(var i=0;i<phaseData.length;i++){if(i==0){var imgHelmet='<img src="drivers/'+phaseData[i].n_PersonID+'.png" width="105px" height="82px">';var imgDriver='<img src="drivers/'+phaseData[i].n_PersonID+'.jpg" width="105px">';var imgCar='<img src="cars/'+phaseData[i].c_TeamShort+'.png" width="330px">';var leadDriver='<b>'+phaseData[i].c_Person+'</b> <span style="font-size:12px"><i>'+phaseData[i].c_NOCShort+'</i></span>';liveTxt[7].html(leadDriver);liveTxt[8].text(phaseData[i].c_ConstructorTeam);sym.getSymbol("liveMc").getSymbol("timingMc").$("helmetPic").append(imgHelmet);sym.getSymbol("liveMc").getSymbol("timingMc").$("driverPic").append(imgDriver);sym.getSymbol("liveMc").getSymbol("timingMc").$("carPic").append(imgCar);}
var phaseText="<div class='phaserace'>";phaseText+="<div id='phasedriverdata"+i+"'>";phaseText+="<table style='width:100%; border:none; border-collapse:collapse; padding:0; margin:0'><tr>";phaseText+="<td id='phasedriver"+i+"' style='width:150px'></td>";phaseText+="<td id='phaseteam"+i+"' style='font-style:italic' width='40px'></td>";phaseText+="<td id='phasetime"+i+"'></td>";phaseText+="</tr></table>";phaseText+="</div>";phaseText+="</div>";sym.getSymbol("liveMc").getSymbol("timingMc").$("graph").append(phaseText);$('#phasedriver'+i).text(phaseData[i].c_Person);$('#phaseteam'+i).text(phaseData[i].c_TeamShort);var mins=Math.floor(phaseData[i].n_TimeAbs/60000)+":";var secs=(phaseData[i].n_TimeAbs%60000%60000)/1000;if(secs<10){secs="0"+secs;}
$('#phasetime'+i).text(mins+secs);if(minTime==max&&phaseData[i].n_TimeAbs==max){scalePhase=100;}else if(phaseData[i].n_TimeAbs==null){scalePhase=59;}else{scalePhase=100-((phaseData[i].n_TimeAbs-minTime)*41/(max-minTime));}
$(".phaserace").css({'font-size':'13px','font-family':'pragmatica-web, sans-serif','width':'100%','margin-bottom':'2px'});$("#phasedriverdata"+i).css({'height':barHeight+'px','width':scalePhase+'%','background-color':'rgb(230,225,215)','box-shadow':'3px 2px 5px rgba(100,100,100,0.75)',});$("#phasetime"+i).css({'text-align':'right','padding-right':'5px'});}}});}
function getGrid(phaseID){$.ajax({type:"GET",url:dataURL,data:"gn="+gnNo+"&yr="+yearNo+"&race="+phaseID,contentType:"text/plain",dataType:"jsonp",jsonp:"callback",async:true,crossDomain:true,success:function(data){var gridData=data;var gridMove;var go;for(var i=0;i<gridData.length;i++){sym.getSymbol("liveMc").getSymbol("gridMc").$("grid"+i).empty();var gridText="<div class='gridlist'><table style='width:100%; border:none; border-collapse:collapse; padding:0; margin:0'><tr><td id='gridorder"+i+"' width='10%'></td><td id='griddriver"+i+"' width='62%'></td><td id='gridteam"+i+"' width='28%' font-style:italic'></td></tr></table></div>";if(i<12){sym.getSymbol("liveMc").getSymbol("gridMc").$("grid1txt").append(gridText);}else{sym.getSymbol("liveMc").getSymbol("gridMc").$("grid2txt").append(gridText);}
var gridCar='<img src="cars/'+gridData[i].c_TeamShort+'o.png" width="24px">';var order=gridData[i].n_RankSort;$('#gridorder'+i).html("<b>"+order+"</b>");$('#griddriver'+i).text(gridData[i].c_Person);$('#gridteam'+i).text(gridData[i].c_TeamShort);$(".gridlist").css({'font-size':'13px','font-family':'pragmatica-web, sans-serif','width':'100%','height':'35px'});sym.getSymbol("liveMc").getSymbol("gridMc").$("grid"+i).append(gridCar);if(i<12){go=i;}else{go=i-12;}
if(i%2==0){gridMove=5+go*35;}else{gridMove=-15+go*35;}
sym.getSymbol("liveMc").getSymbol("gridMc").$("grid"+i).delay(i*400).animate({'top':gridMove},1000);}}});}
function getStandings(){$.ajax({type:"GET",url:dataURL,data:"gn="+gnNo+"&q=champdrivers&yr="+yearNo+"&race=",contentType:"text/plain",dataType:"jsonp",jsonp:"callback",async:true,crossDomain:true,success:function(data){var rankData=data;for(var i=0;i<rankData.length;i++){if(i<10){if(i%2==0){var rankText="<div class='rankingeven'><table style='width:98%; border:none; border-collapse:collapse; padding:0; margin:0'><tr><td id='rank"+i+"' width='20%'></td><td id='rankdriver"+i+"' width='55%' style='font-weight:600'></td><td id='rankpoints"+i+"' width='20%' style='text-align:right; font-style:italic'></td></tr></table></div>";}else{var rankText="<div class='rankingodd'><table style='width:98%; border:none; border-collapse:collapse; padding:0; margin:0'><tr><td id='rank"+i+"' width='20%'></td><td id='rankdriver"+i+"' width='55%' style='font-weight:600'></td><td id='rankpoints"+i+"' width='20%' style='text-align:right; font-style:italic'></td></tr></table></div>";}}
sym.getSymbol("resultsMc").$("standings").append(rankText);$('#rank'+i).text(rankData[i].n_RankSort);$('#rankdriver'+i).text(rankData[i].c_PersonShort);$('#rankpoints'+i).text((rankData[i].n_PointsSort)/1000);$(".rankingeven").css({'background-color':'rgb(150,210,255)','font-size':'13px','font-family':'pragmatica-web, sans-serif','width':'100%'});$(".rankingodd").css({'background-color':'rgb(213,239,255)','font-size':'13px','font-family':'pragmatica-web, sans-serif','width':'100%'});}}});}
sym.gearChange=function(gearIn,gearOut,duration){sym.$({countNum:gearIn}).animate({countNum:gearOut},{duration:duration,easeOut:'cubic',step:function(){sym.getSymbol("circuitMc").$("gear").text(Math.round(this.countNum));},});}
sym.speedChange=function(speedIn,speedOut,duration){sym.$({countNum:speedIn}).animate({countNum:speedOut},{duration:duration,easeOut:'cubic',step:function(){sym.getSymbol("circuitMc").$("speed").html(Math.round(this.countNum));},});}
var mcArr=['circuitMc','liveMc','resultsMc'];function startPanel(){for(var i=0;i<3;i++){if(showMc==i){sym.$(mcArr[i]).fadeIn(1000);sym.getSymbol("styleHead").getSymbol("menuBtn"+i).$("btnClick").fadeIn(0);if(i==0){setTimeout(function(){sym.getSymbol("circuitMc").play(1);},2850);clearInterval(panelInterval);}else if(i==1){if(gridPhase>0){sym.getSymbol("liveMc").$("gridMc").fadeIn(1000);sym.getSymbol("liveMc").$("timingMc").fadeOut(0);sym.getSymbol("liveMc").$("latestMc").fadeOut(0);getGrid(gridPhase);clearInterval(panelInterval);}else{sym.getSymbol("liveMc").getSymbol("latestMc").$("leadDriver").delay(500).fadeIn(1000);}}else if(i==2){for(m=0;m<10;m++){var carMove=43+m*420/22;sym.getSymbol("resultsMc").$("car"+m).animate({'top':carMove},1000);}}}else{sym.$(mcArr[i]).fadeOut(1000);sym.getSymbol("styleHead").getSymbol("menuBtn"+i).$("btnClick").fadeOut(0);}}}
var panelInterval=setInterval(startPanel,2000);$('img').on('dragstart',function(e){e.preventDefault();});});
//Edge binding end
})("stage");
//Edge symbol end:'stage'

//=========================================================

//Edge symbol: 'StyleBase'
(function(symbolName){})("StyleBase");
//Edge symbol end:'StyleBase'

//=========================================================

//Edge symbol: 'styleHead'
(function(symbolName){})("styleHead");
//Edge symbol end:'styleHead'

//=========================================================

//Edge symbol: 'menuBtn'
(function(symbolName){})("menuBtn");
//Edge symbol end:'menuBtn'

//=========================================================

//Edge symbol: 'status'
(function(symbolName){})("Status");
//Edge symbol end:'Status'

//=========================================================

//Edge symbol: 'Phase'
(function(symbolName){})("Phase");
//Edge symbol end:'Phase'

//=========================================================

//=========================================================

//Edge symbol: 'Phase1'
(function(symbolName){})("Phase1");
//Edge symbol end:'Phase1'

//=========================================================

//Edge symbol: 'Grid'
(function(symbolName){})("GridMc");
//Edge symbol end:'GridMc'

//=========================================================

//Edge symbol: 'Phase0'
(function(symbolName){})("Phase0");
//Edge symbol end:'Phase0'

//=========================================================

//Edge symbol: 'results'
(function(symbolName){})("PhasesMc");
//Edge symbol end:'PhasesMc'

//=========================================================

//Edge symbol: 'Phase3'
(function(symbolName){})("Phase2");
//Edge symbol end:'Phase2'

//=========================================================

//=========================================================

//Edge symbol: 'resLive'
(function(symbolName){})("LatestMc");
//Edge symbol end:'LatestMc'

//=========================================================

//Edge symbol: 'pitstop'
(function(symbolName){})("Pitstop");
//Edge symbol end:'Pitstop'

//=========================================================

//Edge symbol: 'lapCounter'
(function(symbolName){})("lapCounter");
//Edge symbol end:'lapCounter'

//=========================================================

//=========================================================

//Edge symbol: 'Results'
(function(symbolName){})("Results");
//Edge symbol end:'Results'

//=========================================================

//Edge symbol: 'TimmingMc'
(function(symbolName){})("TimingMc");
//Edge symbol end:'TimingMc'

//=========================================================

//Edge symbol: 'Preloader'
(function(symbolName){})("Preloader");
//Edge symbol end:'Preloader'

//=========================================================

//=========================================================

//Edge symbol: 'introMc'
(function(symbolName){Symbol.bindTriggerAction(compId,symbolName,"Default Timeline",2850,function(sym,e){sym.getComposition().getStage().fadeIt();});
//Edge binding end
})("introMc");
//Edge symbol end:'introMc'

//=========================================================

//Edge symbol: 'playPause'
(function(symbolName){})("playPause");
//Edge symbol end:'playPause'

//=========================================================

//Edge symbol: 'Down-level'
(function(symbolName){})("Down-level");
//Edge symbol end:'Down-level'

//=========================================================

//Edge symbol: 'keyMc'
(function(symbolName){})("keyMc");
//Edge symbol end:'keyMc'

//=========================================================

//=========================================================

//Edge symbol: 'carMc'
(function(symbolName){Symbol.bindTriggerAction(compId,symbolName,"Default Timeline",1000,function(sym,e){sym.play();});
//Edge binding end
})("carMc");
//Edge symbol end:'carMc'

//=========================================================

//Edge symbol: 'circuitMc'
(function(symbolName){Symbol.bindTriggerAction(compId,symbolName,"Default Timeline",15000,function(sym,e){sym.stop();var mySymbolObject=sym.getSymbol("carMc").stop(1);sym.getComposition().getStage().stopIt();sym.$("speed").html("280");});
//Edge binding end
Symbol.bindTriggerAction(compId,symbolName,"Default Timeline",10,function(sym,e){sym.getComposition().getStage().speedChange(100,300,900);sym.getComposition().getStage().gearChange(1,7,700);});
//Edge binding end
Symbol.bindTriggerAction(compId,symbolName,"Default Timeline",1000,function(sym,e){sym.getComposition().getStage().speedChange(300,120,400);sym.getComposition().getStage().gearChange(7,2,400);});
//Edge binding end
Symbol.bindTriggerAction(compId,symbolName,"Default Timeline",1500,function(sym,e){sym.getComposition().getStage().speedChange(120,295,2600);sym.getComposition().getStage().gearChange(2,6,2200);});
//Edge binding end
Symbol.bindTriggerAction(compId,symbolName,"Default Timeline",4200,function(sym,e){sym.getComposition().getStage().speedChange(295,65,400);sym.getComposition().getStage().gearChange(6,2,400);});
//Edge binding end
Symbol.bindTriggerAction(compId,symbolName,"Default Timeline",4700,function(sym,e){sym.getComposition().getStage().speedChange(65,290,2700);sym.getComposition().getStage().gearChange(2,6,2400);});
//Edge binding end
Symbol.bindTriggerAction(compId,symbolName,"Default Timeline",7000,function(sym,e){sym.getComposition().getStage().speedChange(290,100,500);sym.getComposition().getStage().gearChange(7,2,500);});
//Edge binding end
Symbol.bindTriggerAction(compId,symbolName,"Default Timeline",7600,function(sym,e){sym.getComposition().getStage().speedChange(100,255,1000);sym.getComposition().getStage().gearChange(2,5,900);});
//Edge binding end
Symbol.bindTriggerAction(compId,symbolName,"Default Timeline",8800,function(sym,e){sym.getComposition().getStage().speedChange(255,210,1000);sym.getComposition().getStage().gearChange(5,4,1000);});
//Edge binding end
Symbol.bindTriggerAction(compId,symbolName,"Default Timeline",9900,function(sym,e){sym.getComposition().getStage().speedChange(210,175,500);sym.getComposition().getStage().gearChange(5,4,500);});
//Edge binding end
Symbol.bindTriggerAction(compId,symbolName,"Default Timeline",10500,function(sym,e){sym.getComposition().getStage().speedChange(175,280,2000);sym.getComposition().getStage().gearChange(4,6,1600);});
//Edge binding end
Symbol.bindTriggerAction(compId,symbolName,"Default Timeline",12600,function(sym,e){sym.getComposition().getStage().speedChange(280,195,300);sym.getComposition().getStage().gearChange(6,4,300);});
//Edge binding end
Symbol.bindTriggerAction(compId,symbolName,"Default Timeline",13000,function(sym,e){sym.getComposition().getStage().speedChange(195,215,300);sym.getComposition().getStage().gearChange(4,4,300);});
//Edge binding end
Symbol.bindTriggerAction(compId,symbolName,"Default Timeline",13400,function(sym,e){sym.getComposition().getStage().speedChange(215,145,300);sym.getComposition().getStage().gearChange(4,3,300);});
//Edge binding end
Symbol.bindTriggerAction(compId,symbolName,"Default Timeline",13700,function(sym,e){sym.getComposition().getStage().speedChange(145,280,1100);sym.getComposition().getStage().gearChange(3,6,1000);});
//Edge binding end
})("CircuitMc");
//Edge symbol end:'CircuitMc'
})(jQuery,AdobeEdge,"GraphicNews31388");