/***********************
* Adobe Edge 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
*
***********************/
(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 clickEventType = ('ontouchstart' in document.documentElement ? "touchstart" : "click");
	
	var headline;
	var headlinetxt = sym.getSymbol("styleHead").$("headlineTxt").css("pointer-events","none");
	var stand;
	var standtxt = sym.getSymbol("styleHead").$("standTxt").css("pointer-events","none");
	var source;
	var sourcetxt = sym.getSymbol("styleBase").$("sourceTxt").css("pointer-events","none");
	var pictures;
	var picturestxt = sym.getSymbol("styleBase").$("picturesTxt").css("pointer-events","none");
	
	
	// MENU TEXT START
	var menuTxt=[];
	menuTxt[0] = sym.$("menuTxt0").css({"pointer-events":"none",});
	menuTxt[1] = sym.$("menuTxt1").css({"pointer-events":"none"});
	menuTxt[2] = sym.$("menuTxt2").css({"pointer-events":"none"});
	menuTxt[3] = sym.$("menuTxt2").css({"pointer-events":"none"});
	var menuArr=[];
	
	var btnNo = 0;
	for (var b=0;b<4; b++){
		sym.getSymbol("menuBtnsMc").getSymbol("menuBtn"+b).$("menuIcon").attr("src", "images/menuIcon" + b + ".png");
	} // MENU TEXT END
	
	// TEAM TEXT
	var teamName=sym.getSymbol("teamsMc").$("teamName");
	var driver1=sym.getSymbol("teamsMc").$("driver1");
	var driver2=sym.getSymbol("teamsMc").$("driver2");
	var principal=sym.getSymbol("teamsMc").$("principal");
	var director=sym.getSymbol("teamsMc").$("director");
	
	// STYLING TEXT	
	// "box-shadow":"5px 5px 5px rgba(0,0,0,0.3)"
	// "border-width":"1px","border-style":"solid","border-color":"rgba(0,0,0,1, "border-radius":"1px"
	// "background-color":"rgba(255,255,255,1)"
	// "padding":"6px"
	
	var txt=[];
	txt[0] = sym.getSymbol("carMainMc").$("txt0").css({"pointer-events":"none",});
	txt[1] = sym.getSymbol("carMainMc").getSymbol("carTxtMc").$("txt1").css({"pointer-events":"none"});
	txt[2] = sym.getSymbol("carMainMc").getSymbol("carTxtMc").$("txt2").css({"pointer-events":"none"});
	txt[3] = sym.getSymbol("carMainMc").getSymbol("carTxtMc").$("txt3").css({"pointer-events":"none"});
	txt[4] = sym.getSymbol("carMainMc").getSymbol("carTxtMc").$("txt4").css({"pointer-events":"none"});
	txt[5] = sym.getSymbol("carMainMc").getSymbol("carTxtMc").$("txt5").css({"pointer-events":"none"});
	txt[6] = sym.getSymbol("carMainMc").getSymbol("carTxtMc").$("txt6").css({"pointer-events":"none"});
	txt[7] = sym.getSymbol("carMainMc").getSymbol("carTxtMc").$("txt7").css({"pointer-events":"none"});
	txt[8] = sym.getSymbol("carMainMc").getSymbol("carTxtMc").$("txt8").css({"pointer-events":"none"});
	txt[9] = sym.getSymbol("teamsMc").$("txt9").css({"pointer-events":"none"});
	txt[10] = sym.getSymbol("teamsMc").getSymbol("teamBtn0").$("teamName").css({"pointer-events":"none"});
	txt[11] = sym.getSymbol("teamsMc").getSymbol("teamBtn1").$("teamName").css({"pointer-events":"none"});
	txt[12] = sym.getSymbol("teamsMc").getSymbol("teamBtn2").$("teamName").css({"pointer-events":"none"});
	txt[13] = sym.getSymbol("teamsMc").getSymbol("teamBtn3").$("teamName").css({"pointer-events":"none"});
	txt[14] = sym.getSymbol("teamsMc").getSymbol("teamBtn4").$("teamName").css({"pointer-events":"none"});
	txt[15] = sym.getSymbol("teamsMc").getSymbol("teamBtn5").$("teamName").css({"pointer-events":"none"});
	txt[16] = sym.getSymbol("teamsMc").getSymbol("teamBtn6").$("teamName").css({"pointer-events":"none"});
	txt[17] = sym.getSymbol("teamsMc").getSymbol("teamBtn7").$("teamName").css({"pointer-events":"none"});
	txt[18] = sym.getSymbol("teamsMc").getSymbol("teamBtn8").$("teamName").css({"pointer-events":"none"});
	txt[19] = sym.getSymbol("teamsMc").getSymbol("teamBtn9").$("teamName").css({"pointer-events":"none"});
	txt[20] = sym.getSymbol("teamsMc").$("txt20").css({"pointer-events":"none"});
	txt[21] = sym.$("txt21").css({"pointer-events":"none"});
	txt[22] = sym.$("txt22").css({"pointer-events":"none"});
	txt[23] = sym.getSymbol("circuitsMc").getSymbol("circuitBtn0").$("country").css({"pointer-events":"none"});
	txt[24] = sym.getSymbol("circuitsMc").getSymbol("circuitBtn1").$("country").css({"pointer-events":"none"});
	txt[25] = sym.getSymbol("circuitsMc").getSymbol("circuitBtn2").$("country").css({"pointer-events":"none"});
	txt[26] = sym.getSymbol("circuitsMc").getSymbol("circuitBtn3").$("country").css({"pointer-events":"none"});
	txt[27] = sym.getSymbol("circuitsMc").getSymbol("circuitBtn4").$("country").css({"pointer-events":"none"});
	txt[28] = sym.getSymbol("circuitsMc").getSymbol("circuitBtn5").$("country").css({"pointer-events":"none"});
	txt[29] = sym.getSymbol("circuitsMc").getSymbol("circuitBtn6").$("country").css({"pointer-events":"none"});
	txt[30] = sym.getSymbol("circuitsMc").getSymbol("circuitBtn7").$("country").css({"pointer-events":"none"});
	txt[31] = sym.getSymbol("circuitsMc").getSymbol("circuitBtn8").$("country").css({"pointer-events":"none"});
	txt[32] = sym.getSymbol("circuitsMc").getSymbol("circuitBtn9").$("country").css({"pointer-events":"none"});
	//txt[32] = sym.$("txt32").css({"pointer-events":"none"});
	txt[33] = sym.getSymbol("circuitsMc").$("txt33").css({"pointer-events":"none", "padding":"3px","border-width":"1px","border-style":"solid","border-color":"rgba(0,0,0,1)"});
	txt[34] = sym.getSymbol("circuitsMc").$("txt34").css({"pointer-events":"none", "padding":"3px","border-width":"1px","border-style":"solid","border-color":"rgba(0,0,0,1)"});
	txt[35] = sym.getSymbol("circuitsMc").$("txt35").css({"pointer-events":"none", "padding":"3px","border-width":"1px","border-style":"solid","border-color":"rgba(0,0,0,1)"});
	txt[36] = sym.getSymbol("circuitsMc").$("txt36").css({"pointer-events":"none", "padding":"3px","border-width":"1px","border-style":"solid","border-color":"rgba(0,0,0,1)"});
	txt[37] = sym.getSymbol("circuitsMc").$("txt37").css({"pointer-events":"none", "padding":"3px","border-width":"1px","border-style":"solid","border-color":"rgba(0,0,0,1)"});
	txt[38] = sym.getSymbol("circuitsMc").$("txt38").css({"pointer-events":"none", "padding":"3px","border-width":"1px","border-style":"solid","border-color":"rgba(0,0,0,1)"});
	txt[39] = sym.getSymbol("circuitsMc").$("txt39").css({"pointer-events":"none", "padding":"3px","border-width":"1px","border-style":"solid","border-color":"rgba(0,0,0,1)"});
	txt[40] = sym.getSymbol("circuitsMc").$("txt40").css({"pointer-events":"none", "padding":"3px","border-width":"1px","border-style":"solid","border-color":"rgba(0,0,0,1)"});
	txt[41] = sym.getSymbol("circuitsMc").$("txt41").css({"pointer-events":"none", "padding":"3px","border-width":"1px","border-style":"solid","border-color":"rgba(0,0,0,1)"});
	txt[42] = sym.getSymbol("circuitsMc").$("txt42").css({"pointer-events":"none", "padding":"3px","border-width":"1px","border-style":"solid","border-color":"rgba(0,0,0,1)"});
	txt[43] = sym.$("txt43").css({"pointer-events":"none"});
	txt[44] = sym.$("txt44").css({"pointer-events":"none"});
	txt[45] = sym.$("txt45").css({"pointer-events":"none"});
	txt[46] = sym.$("txt46").css({"pointer-events":"none"});
	txt[47] = sym.$("txt47").css({"pointer-events":"none"});
	txt[48] = sym.$("txt48").css({"pointer-events":"none"});
	txt[49] = sym.$("txt49").css({"pointer-events":"none"});
	
	var txtArr=[];
	var teamNameArr=[];
	var driver1Arr=[];
	var driver2Arr=[];
	var principalArr=[];
	var directorArr=[];
	
	var circuitTrackArr=[];
	var circuitDateArr=[];
	var circuitTurnsArr=[];
	var circuitKmArr=[];
	var circuitKeyArr=[];
	var circuitPlaceArr=[];
	
	//AJAX retrieves data from xml source specified in url, maps xml variable to DOM object variable
	$.ajax({	
		type: "GET",
		url: "GN32133.xml",
		dataType: "xml",
		success: function(xml) {
			custonCol = $(xml).find('customColour').text();
			sym.getSymbol("styleHead").$("headerBox").css("background-color",custonCol);
			headline = $(xml).find('headline').text();
			headlinetxt.html(headline);
			stand = $(xml).find('stand').text();
			standtxt.html(stand);
			source = $(xml).find('source').text();
			sourcetxt.html(source);
			pictures = $(xml).find('pictures').text();
			picturestxt.html(pictures);
	
	
			// MENU TEXT START
			for (var i=0; i<4; i++){
			menuArr[i]=$(xml).find('menuTxt'+i).text();
			menuTxt[i].html(menuArr[i]);
			} // MENU TEXT END
	
			for (var i=0; i<50; i++){
			txtArr[i]=$(xml).find('txt'+i).text();
			txt[i].html(txtArr[i]);
			}
	
			for (var t=0;t<10;t++){			//get details for each team
				$(xml).find("team"+t).each(function(){
					var $teams = $(this);
					teamNameArr[t]=$teams.find('teamName').text();
					driver1Arr[t]=$teams.find('driver1').text();
					driver2Arr[t]=$teams.find('driver2').text();
					principalArr[t]=$teams.find('principal').text();
					directorArr[t]=$teams.find('director').text();
				});
			}
	
			teamName.html(teamNameArr[0]);
			driver1.html(driver1Arr[0]);
			driver2.html(driver2Arr[0]);
			principal.html(principalArr[0]);
			director.html(directorArr[0]);
	
	
			for (var t=0;t<10;t++){			//get details for each circuit
				//var x=(t>3)?t+1:t;
				var x=t;
				$(xml).find("circuit"+t).each(function(){
					var $circuits = $(this);
	
					circuitDateArr[t]=$circuits.find('circuitDate').text();
					circuitTurnsArr[t]=$circuits.find('circuitTurns').text();
					circuitKmArr[t]=$circuits.find('circuitKm').text();
					circuitKeyArr[t]=$circuits.find('circuitKey').text();
					circuitPlaceArr[t]=$circuits.find('circuitPlace').text();
	
					sym.getSymbol("circuitsMc").getSymbol("circuit" + x + "Mc").$("circuitTurns").html(txtArr[44] + " " + circuitTurnsArr[t] + "<br>" + txtArr[45] + " " + circuitKmArr[t]);
					sym.getSymbol("circuitsMc").getSymbol("circuit" + x + "Mc").$("circuitPlace").html(circuitPlaceArr[t]);
					sym.getSymbol("circuitsMc").getSymbol("circuit" + x + "Mc").$("circuitKey").html(circuitKeyArr[t]);
					sym.getSymbol("circuitsMc").getSymbol("circuit" + x + "Mc").$("circuitPit").html(txtArr[46]);
					sym.getSymbol("circuitsMc").$("circuitTrack").html(txtArr[33] + " " + txtArr[43]);
					sym.getSymbol("circuitsMc").$("circuitDate").html(circuitDateArr[circuitNo]);
				});
			}
	
	
			//sym.getSymbol("SYMBOL").$("txt").animate({top:yNUMBER - sym.getSymbol("SYMBOL").$("txt").height()+10}, 200);
	
		}
	}); // END XML
	
	//   ************************************************************************************************************************* 
	//   ****************************************************  SET STAGE  ****************************************************
	//   ************************************************************************************************************************* 
	
	sym.$("teamsMc").stop().fadeOut(0);
	sym.$("videoMc").stop().fadeOut(0);
	sym.$("circuitsMc").stop().fadeOut(0);
	
	//   ************************************************************************************************************************* 
	//   ****************************************************  MENU BUTTONS  ****************************************************
	//   ************************************************************************************************************************* 
	menuArray = []; //the array that will hold references to the buttons.
	
	for (var h = 0; h < 4; h++){
		var menuBtnSymbols = sym.getSymbol("menuBtnsMc").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.bind ("click", {menuId:count}, menuBtnClick);
		menuBtnElement.bind ("touchstart", {menuId:count}, menuBtnClick);
		menuBtnElement.bind ("mouseover", {menuId:count}, menuShow);
		menuBtnElement.bind ("mouseout", {menuId:count}, menuHide);
	})
	
	function resetmenu(){
		for (var h=0; h<menuArray.length; h++){
         menuArray[h].$("btnClick").fadeOut(0);
         menuArray[h].$("btnOver").fadeOut(0);
		}
	}
	resetmenu();

	function menuBtnClick (e){

		resetmenu(); //set them all back to normal state
		var menuMenu_id = (e.data.menuId); //get the id of the clicked item
		sym.getSymbol("menuBtnsMc").getSymbol("menuBtn" + menuMenu_id).$("btnClick").fadeIn(0);
		//btnNo = menuMenu_id;
		sym.$("teamsMc").stop().fadeOut(500);
		sym.$("videoMc").stop().fadeOut(500);
		sym.$("circuitsMc").stop().fadeOut(500);
		if (menuMenu_id==0) {
			car = 0;
			carMove();
		}
		if (menuMenu_id==1) {
			car = 1;
			carMove();
			sym.$("teamsMc").stop().fadeIn(500);
		}
		if (menuMenu_id==2) {
			car = 1;
			carMove();
			sym.$("circuitsMc").stop().fadeIn(500);
		}
		if (menuMenu_id==3) {
			car = 1;
			carMove();
			sym.$("videoMc").stop().fadeIn(500);
		}
	}

	function menuShow (e){
		var menuMenu_id = (e.data.menuId); //get the id of the over button
		sym.getSymbol("menuBtnsMc").getSymbol("menuBtn" + menuMenu_id).$("btnOver").fadeIn(0);
		btnNo = menuMenu_id;
		sym.getSymbol("menuBtnsMc").$("menuTxt").empty();
		sym.getSymbol("menuBtnsMc").$("menuTxt").append(menuArr[btnNo]);
	}
	function menuHide (e){
		var menuMenu_id = (e.data.menuId); //get the id of the out button
		sym.getSymbol("menuBtnsMc").getSymbol("menuBtn" + menuMenu_id).$("btnOver").fadeOut(0);
		sym.getSymbol("menuBtnsMc").$("menuTxt").empty();
	}
// MAKE MENU 0 VISIBLE
	sym.getSymbol("menuBtnsMc").getSymbol("menuBtn0").$("btnClick").fadeIn(0);

//   ************************************************************************************************************************* 
//   ****************************************************  CAR START  ****************************************************
//   ************************************************************************************************************************* 
$.fn.animateRotate = function(angle, duration, easing, complete) {
    return this.each(function() {
        var $elem = $(this);
        $({deg: 0}).animate({deg: angle}, {
            duration: duration,
            easing: easing,
            step: function(now) {
                $elem.css({
                  '-moz-transform':'rotate('+now+'deg)',
                  '-webkit-transform':'rotate('+now+'deg)',
                  '-o-transform':'rotate('+now+'deg)',
                  '-ms-transform':'rotate('+now+'deg)',
                  'transform':'rotate('+now+'deg)'
                });
            },
            complete: complete || $.noop
        });
    });
};

	var car = 0;
	var speed = 0;
	var ease = 0;

	function carMove() {
	if (car == 0){
			sym.$("carMainMc").stop().fadeIn(500);
			ease = 'easeOutCubic';
			speed = 1500;
			sym.getSymbol("carMainMc").$("carMc").stop().animate ({left:77, top:82}, speed, 'easeOutCubic', function(){ sym.getSymbol("carMainMc").$("carTxtMc").stop().animate ({opacity:1}, 500) });
			car = 1;
		}else{
			ease = 'easeInCubic';
			speed = 500;
			sym.getSymbol("carMainMc").$("carTxtMc").stop().animate ({opacity:0}, 0);
			sym.getSymbol("carMainMc").$("carMc").stop().animate ({left:800, top:545}, speed, 'easeInCubic', function(){ sym.getSymbol("carMainMc").$("carMc").stop().animate ({left:-660, top:-470}, 0) });
			car = 0;
			sym.$("carMainMc").stop().fadeOut(500);
		}
		for (var b=0;b<4; b++){
			sym.getSymbol("carMainMc").getSymbol("carMc").getSymbol("wheel"+b).$("wheel").animateRotate(0,0);
			sym.getSymbol("carMainMc").getSymbol("carMc").getSymbol("wheel"+b).$("wheel").animateRotate(720, speed, ease);
		}

	}

	sym.$("videoMc").stop().fadeOut(0);
	sym.getSymbol("carMainMc").$("carTxtMc").stop().animate ({opacity:0}, 0);
	sym.getSymbol("carMainMc").$("carMc").stop().animate ({left:-660, top:-470}, 0);
	carMove();

//   ************************************************************************************************************************* 
//   ****************************************************  GALLERY START  ****************************************************
//   ************************************************************************************************************************* 
	var galNo = 0;
	for (var b=0;b<5; b++){
		sym.getSymbol("videoMc").getSymbol("galBtnsMc").getSymbol("galBtn"+b).$("btnIcon").attr("src", "images/gal" + b + ".jpg");
	}


// GALLERY BUTTONS --------------------------------------------	
	galArray = []; //the array that will hold references to the buttons.

	for (var a = 0; a < 5; a++){
		var galBtnSymbols = sym.getSymbol("videoMc").getSymbol("galBtnsMc").getSymbol("galBtn" +a); // Create an instance element of a symbol as a child of the given parent element
		galBtnSymbols.setVariable("galId", a); //set the value of a Symbol variable
		galArray.push(galBtnSymbols); //push it into the array
	}

	$.each(galArray, function( count, galInTheArray ){ //a 'for each' loop through the newly populated array
		var galBtnItem = $(galInTheArray); //create jQuery reference to the item
		var galBtnElement = galInTheArray.getSymbolElement(); //create a jQuery reference to the DIV element inside the symbol
		galBtnElement.bind ("click", {galId:count}, galBtnClick);
		galBtnElement.bind ("touchstart", {galId:count}, galBtnClick);
		galBtnElement.bind ("mouseover", {galId:count}, galBtnShow);
		galBtnElement.bind ("mouseout", {galId:count}, galBtnHide);
	})

	function resetGal(){
		for (var a=0; a<galArray.length; a++){
        	galArray[a].$("btnClick").fadeOut(0);
       	galArray[a].$("btnOver").fadeOut(0);
		}
	}
	resetGal();

	function galBtnClick (e){
		resetGal(); //set them all back to normal state
		var gal_id = (e.data.galId); //get the id of the clicked item
		sym.getSymbol("videoMc").getSymbol("galBtnsMc").getSymbol("galBtn" + gal_id).$("btnClick").fadeIn(0);
		galNo = gal_id;
		sym.getSymbol("videoMc").$("imgHolder").fadeOut(150, function() {
				sym.getSymbol("videoMc").$("imgHolder").attr("src", "images/gal" + galNo + ".jpg");
    			sym.getSymbol("videoMc").$("imgHolder").fadeIn(200);
  			});
		}

	function galBtnShow (e){
		var gal_id = (e.data.galId); //get the id of the over button
		sym.getSymbol("videoMc").getSymbol("galBtnsMc").getSymbol("galBtn" + gal_id).$("btnOver").fadeIn(0);
	}
	function galBtnHide (e){
		var gal_id = (e.data.galId); //get the id of the out button
		sym.getSymbol("videoMc").getSymbol("galBtnsMc").getSymbol("galBtn" + gal_id).$("btnOver").fadeOut(0);
	}

// MAKE gal0 VISIBLE
	sym.getSymbol("videoMc").getSymbol("galBtnsMc").getSymbol("galBtn0").$("btnClick").fadeIn(0);

//   ************************************************************************************************************************* 
//   ****************************************************  TEAM START  ****************************************************
//   ************************************************************************************************************************* 
	var teamNo = 0;
	for (var b=0;b<10; b++){
		sym.getSymbol("teamsMc").getSymbol("teamBtn"+b).$("teamImgOver").attr("src", "teams/team" + b + ".jpg");
		sym.getSymbol("teamsMc").getSymbol("teamBtn"+b).$("teamImgClick").attr("src", "teams/team" + b + ".jpg");
	}

	teamArray = []; //the array that will hold references to the buttons.

	for (var a = 0; a < 10; a++){
		var teamBtnSymbols = sym.getSymbol("teamsMc").getSymbol("teamBtn" +a); // Create an instance element of a symbol as a child of the given parent element
		teamBtnSymbols.setVariable("teamId", a); //set the value of a Symbol variable
		teamArray.push(teamBtnSymbols); //push it into the array
	}

	$.each(teamArray, function( count, teamInTheArray ){ //a 'for each' loop through the newly populated array
		var teamBtnItem = $(teamInTheArray); //create jQuery reference to the item
		var teamBtnElement = teamInTheArray.getSymbolElement(); //create a jQuery reference to the DIV element inside the symbol
		teamBtnElement.bind ("click", {teamId:count}, teamBtnClick);
		teamBtnElement.bind ("touchstart", {teamId:count}, teamBtnClick);
		teamBtnElement.bind ("mouseover", {teamId:count}, teamBtnShow);
		teamBtnElement.bind ("mouseout", {teamId:count}, teamBtnHide);
	})

	function resetTeam(){
		for (var a=0; a<teamArray.length; a++){
        	teamArray[a].$("teamImgClick").fadeOut(100);
       	teamArray[a].$("btnOut").fadeIn(100);
		}
	}
	resetTeam();

	function teamBtnClick (e){
		resetTeam(); //set them all back to normal state
		var team_id = (e.data.teamId); //get the id of the clicked item
		sym.getSymbol("teamsMc").getSymbol("teamBtn" + team_id).$("teamImgClick").fadeIn(0);
		teamNo = team_id;
		CarIn();
	}

	function teamBtnShow (e){
		var team_id = (e.data.teamId); //get the id of the over button
		sym.getSymbol("teamsMc").getSymbol("teamBtn" + team_id).$("btnOut").fadeOut(100);
	}
	function teamBtnHide (e){
		var team_id = (e.data.teamId); //get the id of the out button
		sym.getSymbol("teamsMc").getSymbol("teamBtn" + team_id).$("btnOut").fadeIn(100);
	}

// MAKE team0 VISIBLE
	sym.getSymbol("teamsMc").getSymbol("teamBtn0").$("teamImgClick").fadeIn(0);

function CarIn() {
	sym.getSymbol("teamsMc").$("logoHolder").stop().fadeOut(0);
	sym.getSymbol("teamsMc").$("logoHolder").attr("src", "teams/" + (teamName[teamNo]) + ".jpg");
	sym.getSymbol("teamsMc").$("logoHolder").stop().fadeIn(300);
	sym.getSymbol("teamsMc").$("driverImg1").stop().fadeOut(0);
	sym.getSymbol("teamsMc").$("driverImg1").attr("src", "teams/driver" + ([teamNo + teamNo]) + ".jpg");
	sym.getSymbol("teamsMc").$("driverImg1").stop().fadeIn(300);
	sym.getSymbol("teamsMc").$("driverImg2").stop().fadeOut(0);
	sym.getSymbol("teamsMc").$("driverImg2").attr("src", "teams/driver" + ([teamNo + teamNo + 1]) + ".jpg");
	sym.getSymbol("teamsMc").$("driverImg2").stop().fadeIn(300);
	sym.getSymbol("teamsMc").$("logoHolder").stop().fadeOut(0);
	sym.getSymbol("teamsMc").$("logoHolder").attr("src", "teams/logo" + ([teamNo]) + ".jpg");
	sym.getSymbol("teamsMc").$("logoHolder").stop().fadeIn(300);
	sym.getSymbol("teamsMc").$("teamName").empty();
	sym.getSymbol("teamsMc").$("teamName").append(teamNameArr[teamNo]);
	sym.getSymbol("teamsMc").$("driver1").empty();
	sym.getSymbol("teamsMc").$("driver1").append(driver1Arr[teamNo]);
	sym.getSymbol("teamsMc").$("driver2").empty();
	sym.getSymbol("teamsMc").$("driver2").append(driver2Arr[teamNo]);
	sym.getSymbol("teamsMc").$("principal").empty();
	sym.getSymbol("teamsMc").$("principal").append(principalArr[teamNo]);
	sym.getSymbol("teamsMc").$("director").empty();
	sym.getSymbol("teamsMc").$("director").append(directorArr[teamNo]);
	//sym.getSymbol("teamsMc").getSymbol("teamCarMc")

	for (var b=0;b<2; b++){
		sym.getSymbol("teamsMc").getSymbol("teamCarMc").$("wheel"+b).stop().animateRotate(360,700, 'easeInCubic');
	}
	for (var d=2;d<4; d++){
		sym.getSymbol("teamsMc").getSymbol("teamCarMc").$("wheel"+d).stop().animateRotate(-360,700, 'easeInCubic');
	}

	sym.getSymbol("teamsMc").$("teamCarMc").stop().delay(0).animate ({left:800}, 500, 'easeInCubic', function(){ 
	sym.getSymbol("teamsMc").getSymbol("teamCarMc").$("carMain").attr("src", "teams/car" + teamNo + ".png");
	sym.getSymbol("teamsMc").getSymbol("teamCarMc").$("carMainReflect").attr("src", "teams/car" + teamNo + ".png");
	sym.getSymbol("teamsMc").$("teamCarMc").stop().animate ({left:-800}, 0);
	sym.getSymbol("teamsMc").$("teamCarMc").stop().delay(0).animate ({left:0}, 1000, 'easeOutCubic');
	for (var b=0;b<2; b++){
		sym.getSymbol("teamsMc").getSymbol("teamCarMc").$("wheel"+b).stop().animateRotate(360,1000, 'easeOutCubic');
	}
	for (var d=2;d<4; d++){
		sym.getSymbol("teamsMc").getSymbol("teamCarMc").$("wheel"+d).stop().animateRotate(-360,1000, 'easeOutCubic');
	}
	});
}
CarIn();

//   ************************************************************************************************************************* 
//   ****************************************************  CIRCUITS START  ***************************************************
//   ************************************************************************************************************************* 
var circuitNo = 0;
// CIRCUIT NUMBERS
	for (var h=0;h<10; h++){
		//var x=(h>3)?h+1:h;
		var x=h
		sym.getSymbol("circuitsMc").getSymbol("circuitBtn"+h).$("number").html(h+1);
		sym.getSymbol("circuitsMc").getSymbol("circuitBtn"+h).$("flag").attr("src", "images/flag" + x + ".jpg");
	}

	circuitArray = []; //the array that will hold references to the buttons.

	for (var a = 0; a < 10; a++){
		var circuitBtnSymbols = sym.getSymbol("circuitsMc").getSymbol("circuitBtn" +a); // Create an instance element of a symbol as a child of the given parent element
		circuitBtnSymbols.setVariable("circuitId", a); //set the value of a Symbol variable
		circuitArray.push(circuitBtnSymbols); //push it into the array
	}

	$.each(circuitArray, function( count, circuitInTheArray ){ //a 'for each' loop through the newly populated array
		var circuitBtnItem = $(circuitInTheArray); //create jQuery reference to the item
		var circuitBtnElement = circuitInTheArray.getSymbolElement(); //create a jQuery reference to the DIV element inside the symbol
		circuitBtnElement.bind ("click", {circuitId:count}, circuitBtnClick);
		circuitBtnElement.bind ("touchstart", {circuitId:count}, circuitBtnClick);
		circuitBtnElement.bind ("mouseover", {circuitId:count}, circuitBtnShow);
		circuitBtnElement.bind ("mouseout", {circuitId:count}, circuitBtnHide);
	})

	function resetCircuit(){
		for (var a=0; a<circuitArray.length; a++){
        	circuitArray[a].$("btnClick").fadeOut(0);
       	circuitArray[a].$("btnOver").fadeOut(0);
       	circuitArray[a].$("country").css({"color":"black"});
		}
		for (var h=0;h<10; h++){
		sym.getSymbol("circuitsMc").$("circuit"+h+"Mc").fadeOut(100);
		sym.getSymbol("circuitsMc").getSymbol("circuit"+h+"Mc").stop();
		sym.getSymbol("circuitsMc").$("txt" + (h+33)).css({"background-color":"white"});
		sym.getSymbol("circuitsMc").$("txt" + (h+33)).css({"color":"black"});
		}
	}
	resetCircuit();

	function circuitBtnClick (e){
		resetCircuit(); //set them all back to normal state
		var circuit_id = (e.data.circuitId); //get the id of the clicked item
		sym.getSymbol("circuitsMc").getSymbol("circuitBtn" + circuit_id).$("btnClick").fadeIn(0);
		sym.getSymbol("circuitsMc").getSymbol("circuitBtn" + circuit_id).$("country").css({"color":"white"});
		circuitNo = circuit_id;
		loadCircuits();
	}

	function circuitBtnShow (e){
		var circuit_id = (e.data.circuitId); //get the id of the over button
		sym.getSymbol("circuitsMc").getSymbol("circuitBtn" + circuit_id).$("btnOver").fadeIn(0);
	}
	function circuitBtnHide (e){
		var circuit_id = (e.data.circuitId); //get the id of the out button
		sym.getSymbol("circuitsMc").getSymbol("circuitBtn" + circuit_id).$("btnOver").fadeOut(0);
	}

// MAKE circuit0 VISIBLE
	sym.getSymbol("circuitsMc").getSymbol("circuitBtn0").$("btnClick").fadeIn(0);
	sym.getSymbol("circuitsMc").getSymbol("circuitBtn0").$("country").css({"color":"white"});

function loadCircuits() {
	//var x=(circuitNo>3)?circuitNo+1:circuitNo;
	var x=circuitNo;
	sym.getSymbol("circuitsMc").$("txt" + (circuitNo + 33)).css({"color":"white"});
	sym.getSymbol("circuitsMc").$("txt" + (circuitNo + 33)).css({"background-color":"black"});
	sym.getSymbol("circuitsMc").$("circuit"+x+"Mc").fadeIn(100);
	sym.getSymbol("circuitsMc").getSymbol("circuit"+x+"Mc").play();
	sym.getSymbol("circuitsMc").$("circuitTrack").html(txtArr[33 + circuitNo] + " " + txtArr[43]);
	sym.getSymbol("circuitsMc").$("circuitDate").html(circuitDateArr[circuitNo]);
}
loadCircuits();

         	});//Edge binding end	
		
		// VIDEO BTN 1 =========================================================
         	
			
         	
         		
         	
			
			
         	// VIDEO BTN 2 =========================================================
         	
         	
         	
         		
         	
         	


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

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

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

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

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

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

   //=========================================================
   
   //Edge symbol: 'menuBtn_1'
   (function(symbolName) {   
   
      })("galBtn");
   //Edge symbol end:'galBtn'

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

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

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

   //=========================================================
   
   //Edge symbol: 'wheel_1'
   (function(symbolName) {   
   
   })("wheelTyre");
   //Edge symbol end:'wheelTyre'

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

   //=========================================================
   
   //Edge symbol: 'videoMc'
   (function(symbolName) {   
         

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

   //=========================================================
   
   //Edge symbol: 'auxBtnsMc_1'
   (function(symbolName) {   
   
      })("galBtnsMc");
   //Edge symbol end:'galBtnsMc'

   //=========================================================
   
   //Edge symbol: 'auxBtn_1'
   (function(symbolName) {   
   
         })("auxBtn");
   //Edge symbol end:'auxBtn'

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

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

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

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

   //=========================================================
   
   //Edge symbol: 'wheel_2'
   (function(symbolName) {   
   
      })("wheelReflect");
   //Edge symbol end:'wheelReflect'

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

   //=========================================================
   
   //Edge symbol: 'menuBtn_1'
   (function(symbolName) {   
   
      })("circuitBtn");
   //Edge symbol end:'circuitBtn'

   //=========================================================
   
   //Edge symbol: 'circuit0Mc'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 12000, function(sym, e) {
         sym.play(1);

      });
      //Edge binding end

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

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

   //=========================================================
   
   //Edge symbol: 'circuit0Mc_1'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 12000, function(sym, e) {
         sym.play(1);

      });
      //Edge binding end

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

   //=========================================================
   
   //Edge symbol: 'circuit1Mc_1'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 12000, function(sym, e) {
         sym.play(1);

      });
         //Edge binding end

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

   //=========================================================
   
   //Edge symbol: 'circuit2Mc_1'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 12000, function(sym, e) {
         sym.play(1);

      });
            //Edge binding end

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

   //=========================================================
   
   //Edge symbol: 'circuit4Mc_1'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 12000, function(sym, e) {
         sym.play(1);

      });
            //Edge binding end

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

   //=========================================================
   
   //Edge symbol: 'circuit5Mc_1'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 12000, function(sym, e) {
         sym.play(1);

      });
            //Edge binding end

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

   //=========================================================
   
   //Edge symbol: 'circuit6Mc_1'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 12000, function(sym, e) {
         sym.play(1);

      });
            //Edge binding end

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

   //=========================================================
   
   //Edge symbol: 'circuit7Mc_1'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 12000, function(sym, e) {
         sym.play(1);

      });
            //Edge binding end

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

   //=========================================================
   
   //Edge symbol: 'circuit8Mc_1'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 12000, function(sym, e) {
         sym.play(1);

      });
            //Edge binding end

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

   //=========================================================
   
   //Edge symbol: 'circuit5Mc_1'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 12000, function(sym, e) {
         sym.play(1);

      });
            //Edge binding end

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

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

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