/***********************
* Adobe Edge Animate Composition Actions
*
* Edit this file with caution, being careful to preserve 
* function signatures and comments starting with 'Edge' to maintain the 
* ability to interact with these actions from within Adobe Edge Animate
*
***********************/
(function($, Edge, compId){
var Composition = Edge.Composition, Symbol = Edge.Symbol; // aliases for commonly used Edge classes

   //Edge symbol: 'stage'
   (function(symbolName) {
      
      
      Symbol.bindElementAction(compId, symbolName, "document", "compositionReady", function(sym, e) {
         var raceID = 899971; //AUS 899891, 899902, 899917, 899927, 900015, 900034, 899953, 900050, 900065, 900073, 900088, 900096, 900117, 899967, *899971, 900132, 899988, 900001, 891276
         var gnNo = 31261;
         var yearNo=2014;
         var raceDate= Date.UTC(2014,09,05,06,59,59);
         var gpDate= Date.UTC(2014,09,03,01,59,59);//Practice sessions start 2 days before race
         
         var headline;
         	var headlinetxt = sym.getSymbol("styleHead").$("headlineTxt").css("pointer-events","none");
         	var counterTxt = sym.getSymbol("circuitMc").getSymbol("status").$("statusTxt").css("pointer-events","none");
         	//CREATE ARRAYS FOR TEXT ELEMENTS
         	//KEY START
         		var keyTxt=[];
         	for (var k=0; k<6; k++){
         		keyTxt[k]=sym.getSymbol("circuitMc").getSymbol("keyBase").$("key"+k).css("pointer-events","none");
         	}
         	//MENU START
         	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");
         	}
         	//CAPTIONS START
         	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");
         	//CAPTIONS - LIVE
         	var liveTxt=[];
         	liveTxt[0] = sym.getSymbol("liveMc").getSymbol("latestMc").$("txt0").css("pointer-events","none"); //laps
         	liveTxt[1] = sym.getSymbol("liveMc").getSymbol("latestMc").$("txt2").css("pointer-events","none"); //time
         	liveTxt[2] = sym.getSymbol("liveMc").getSymbol("latestMc").$("txt1").css("pointer-events","none"); //weather
         	liveTxt[3] = sym.getSymbol("liveMc").getSymbol("latestMc").getSymbol("pitstop").$("txt").css("pointer-events","none"); //pitstop
         	liveTxt[4] = sym.getSymbol("liveMc").getSymbol("timingMc").$("txt4").css("pointer-events","none"); //time
         
         	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"); //race session
         	liveTxt[10] = sym.getSymbol("liveMc").getSymbol("timingMc").$("txt5").css("pointer-events","none"); //race session
         	liveTxt[11] = sym.getSymbol("liveMc").getSymbol("phaseBtn2").$("gridTxt").css("pointer-events","none"); //grid text on phase button
         	//CAPTIONS - RESULTS
         	var resTxt=[];
         for (var n=0;n<6;n++){
         	resTxt[n] = sym.getSymbol("resultsMc").$("resultTxt"+n).css("pointer-events","none");//results
         }
         
         	//CORNERS START
         	var corners;
         	var cornerTxt=[];
         	for (var c=0;c<16;c++){
         		cornerTxt[c]= sym.getSymbol("circuitMc").$("corner"+c).css("pointer-events","none");
         	}
         	//RE-USABLE TEXT FROM XML
         	var menuIconArr =[];
         	var keyArr=[];
         	var menuTxtArr=[];
         	var capsArr=[];
         	var txtArr=[];
         	var resArr=[];
         	var stat;
         	var statCap;
         	//AJAX retrieves data from xml source specified in url, maps xml variable to DOM object variable
         	$.ajax({	
         		type: "GET",
         		url: "GN31395.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]);
         		}
         	}); // END XML
         
         // STOP ELEMENTS INTERACTING WITH MOUSE
         	sym.$("handMc").css("pointer-events","none");
         
         sym.getSymbol("liveMc").getSymbol("latestMc").$("leadDriver").fadeOut(0);
         
         // MENU BUTTONS --------------------------------------------	
         menuArray = []; //the array that will hold references to the buttons.
         for (var h = 0; h < 3; h++){
         		var menuBtnSymbols = sym.getSymbol("styleHead").getSymbol("menuBtn" +h); // Create an instance element of a symbol as a child of the given parent element
         		menuBtnSymbols.setVariable("menuId", h); //set the value of a Symbol variable
         		menuArray.push(menuBtnSymbols); //push it into the array
         	}
         $.each(menuArray, function( count, menuInTheArray ){ //a 'for each' loop through the newly populated array
         		var menuBtnItem = $(menuInTheArray); //create jQuery reference to the item
         		var menuBtnElement = menuInTheArray.getSymbolElement(); //create a jQuery reference to the DIV element inside the symbol
         		//menuBtnElement.on ("click", {menuId:count}, menuBtnClick);
         		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(); //set them all back to normal state
         		var menuMenu_id = (e.data.menuId); //get the id of the clicked item
         		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){ //May 10 - show grid from menu button
         								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); //get the id of the over button
         		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); //get the id of the out button
         		sym.getSymbol("styleHead").getSymbol("menuBtn" + menuMenu_id).$("btnOver").fadeOut(0);
         		menuTxt[menuMenu_id].fadeOut(0);
         		sym.getSymbol("circuitMc").$("status").fadeIn(0);
         }
         // DISABLE MENU BUTTONS THAT ARE ONLY AVAILABLE AFTER RACE START
         sym.getSymbol("styleHead").$("menuBtn1").off("touchstart click");
         sym.getSymbol("styleHead").$("menuBtn2").off("touchstart click");
         // MAKE MENU 0 VISIBLE
         sym.getSymbol("styleHead").getSymbol("menuBtn0").$("btnClick").fadeIn(0);
         
         // PLAY/PAUSE BTN
         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);
         }
         //setTimeout(function(){ sym.getSymbol("circuitMc").play(1); }, 2500);
         
         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]);
         }
         //STATUS COUNTDOWN - TIME
         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){//March 26
         			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());//April 29
         	sym.getSymbol("circuitMc").getSymbol("status").$("statusTxt").stop().animate({'left':statWidth},0);
         }
         function leadingZero(time) {
             return (time < 10) ? "0" + time : time;
         }
         counter=setInterval(countDown,1000);
         // PHASE BUTTONS
         var phArr=["F","Q","R"];
         var phaseArray = ["FP","Q","R"];
         
         //LIVE DATA
         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){ //to handle lexical scope
         							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)"});
         							}																														
         						}
         						//Show starting grid caption in phasebtn
         				}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){	//if its the race
         							sym.getSymbol("liveMc").$("gridMc"). fadeOut(1000);
         							sym.getSymbol("liveMc").$("timingMc"). fadeOut(1000);
         							sym.getSymbol("liveMc").$("latestMc"). fadeIn(1000);
         							}else{ 							//if its starting grid
         							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){//Elements if race finished
         							sym.getSymbol("styleHead").$("menuBtn2").on("touchstart click", {menuId:2}, menuBtnClick); //enable third menu button
         							menuTxt[2].html(menuTxtArr[2]);
         							sym.getSymbol("liveMc").getSymbol("phaseBtn2").$("txt").html(statCap[3]);//Change phaseBtn text to Race
         							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(); //get latest standings 
         							clearInterval(raceInterval);
         							raceInterval=setInterval(getRace,600000);
         							raceFinished=1;
         }
         function sessLiveOrFin(latest){//Elements to show if live or finished
         						sym.getSymbol("circuitMc").getSymbol("status").$("statusTxt").html(latest);
         }
         //GET race weekend data
         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){//May 16
         					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;//April 11
         						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){//show nothing
         							sessLive=0;
         							sessFin=0;
         							sessStarted=0;
         							nullSession=1;		//April 11												
         						}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){//April 11
         							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); 
         										//show start grid on phase btn
         									}else{
         										//getFunction=showLive(phase,raceStage+n,sessionNo);//March 14
         										getFunction=showPhase(phase,raceStage+n,sessionNo);//April 4
         									}
         									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){//April19
         										notStarted=1;
         									}else{
         										getInfo(phase);//April19
         										getLive(phase);//April19
         									}
         								}
         							}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)"}); //SESSION NUMBER?
         								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);
         						}//April 11
         				}//end for
         			phaseNo=phaseBtnNo;
         			//
         			if (notStarted==1){
         			getInfo(raceID);
         			getStartList();
         				}			
         			}else{//June 15
         			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;
         //GET individual phase info for laps/live race conditions
         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(); // Empty weather symbol
         							liveTxt[0].fadeOut(0);
         							sym.getSymbol("liveMc").getSymbol("latestMc").$("lapCounter").fadeOut(0);
         						if(data){//June 15	
         							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); // Add weather symbol
         							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:"";
         							//Angle per lap:
         								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');
         								}	
         							//End moved March 24										
         							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(); // Empty weather symbol
         								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);	
         								//clearInterval(raceInterval);
         								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);
         							}
         							//End March 24
         			}else{//June 15
         								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(); // Empty weather symbol
         								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);	
         								//clearInterval(raceInterval);
         								showMc=0;
         			}
         		}
         	});
         }
         
         
         //GET Start list if race hasn't started
         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){ //show lead driver details
         							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);
         							}
         
         							//create graph for each driver and for final results
         							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)'});
                         }
         		}
         	});
         }
         //GET individual phase data for live and final result
         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;
         					 //Ensure all drivers will fit in graph
         					 nRaceDrivers = raceData.length;
         					 if (raceData.length>20){
         					 barHeight = ((420/raceData.length)-2);
         					 }else{
         					 barHeight = 19;
         					 }
         					 //calculate relative length of each bar
         					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){//during other phases	
         					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){ //show lead driver details
         							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);
         						}
         					//create graph for each driver and for final results
         					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)'});
                         }
                         //$('#time' + i).text(raceData[i].c_Result);//March 31 - time caption conditional: see below
         
                        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) {	//if minTime=mxm=item Time that means that there is just 1 item with valid time. show this graph as max
         							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){
         						//var lapslc= txtArr[0].toLowerCase();
         						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){
         								//$('#time' + i).text("+"+raceData[i].n_LapsRel+" "+lapslc.substr(0,4)); March 14
         							}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){ //final results only
         					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]);
         					//Ensure all drivers will fit in graph
         					 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) {	//if minTime=mxm=item Time that means that there is just 1 item with valid time. show this graph as 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'});
         					}
                     }
         		});
         }
         // GRID BUTTON
         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%'});
                        }										
         			}
         	});
         }
         
          // CIRCUIT BUTTONS & TIMELINE FUNCTIONS
         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){
         			//show grid March 31
                  					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;//height divided by number of drivers
         					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(); }); //make images undraggable

      });
      //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("275");

      });
      //Edge binding end

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 10, function(sym, e) {
         sym.getComposition().getStage().speedChange(100,300,1200);
         sym.getComposition().getStage().gearChange(1,7,1150);

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 1300, function(sym, e) {
         sym.getComposition().getStage().speedChange(300,130,400);
         sym.getComposition().getStage().gearChange(7,3,400);

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 1800, function(sym, e) {
         sym.getComposition().getStage().speedChange(130,240,300);
         sym.getComposition().getStage().gearChange(3,5,300);

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 2200, function(sym, e) {
         sym.getComposition().getStage().speedChange(240,210,200);
         sym.getComposition().getStage().gearChange(5,5,200);

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 2400, function(sym, e) {
         sym.getComposition().getStage().speedChange(210,260,3200);
         sym.getComposition().getStage().gearChange(5,6,2000);

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 5700, function(sym, e) {
         sym.getComposition().getStage().speedChange(260,140,200);
         sym.getComposition().getStage().gearChange(6,3,200);

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 6000, function(sym, e) {
         sym.getComposition().getStage().speedChange(140,275,800);
         sym.getComposition().getStage().gearChange(3,6,800);

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 6900, function(sym, e) {
         sym.getComposition().getStage().speedChange(275,70,200);
         sym.getComposition().getStage().gearChange(6,2,200);

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 7200, function(sym, e) {
         sym.getComposition().getStage().speedChange(70,295,1900);
         sym.getComposition().getStage().gearChange(2,6,1200);

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 9200, function(sym, e) {
         sym.getComposition().getStage().speedChange(295,185,800);
         sym.getComposition().getStage().gearChange(6,4,500);

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 10100, function(sym, e) {
         sym.getComposition().getStage().speedChange(185,305,1900);
         sym.getComposition().getStage().gearChange(4,7,1200);

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 12100, function(sym, e) {
         sym.getComposition().getStage().speedChange(305,290,800);
         sym.getComposition().getStage().gearChange(7,6,800);

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 13400, function(sym, e) {
         sym.getComposition().getStage().speedChange(290,95,300);
         sym.getComposition().getStage().gearChange(6,2,300);

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 13800, function(sym, e) {
         sym.getComposition().getStage().speedChange(95,275,1000);
         sym.getComposition().getStage().gearChange(2,6,1000);

      });
      //Edge binding end

   })("CircuitMc");
   //Edge symbol end:'CircuitMc'

})(jQuery, AdobeEdge, "GraphicNews31395");