/***********************
* 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 headline;
         var headlinetxt = sym.getSymbol("styleMc").$("headlineTxt").css("pointer-events","none");
         var source;
         var sourcetxt = sym.getSymbol("styleMc").$("sourceTxt").css("pointer-events","none");
         var menuIcon0;
         var menuIcon0txt = sym.getSymbol("styleMc").getSymbol("menuBtn0").$("txt").css("pointer-events","none");
         var menuIcon1;
         var menuIcon1txt = sym.getSymbol("styleMc").getSymbol("menuBtn1").$("txt").css("pointer-events","none");
         var menuIcon2;
         var menuIcon2txt = sym.getSymbol("styleMc").getSymbol("menuBtn2").$("txt").css("pointer-events","none");
         var menuTxt0;
         var menuTxt0txt = sym.$("menuTxt0").css("pointer-events","none");
         var menuTxt1;
         var menuTxt1txt = sym.$("menuTxt1").css("pointer-events","none");
         var menuTxt2;
         var menuTxt2txt = sym.$("menuTxt2").css("pointer-events","none");
         var teamstxt = sym.$("teamsTxt").css("pointer-events","none");
         var txt1;
         var txt1txt = sym.$("txt1").css("pointer-events","none");
         var txt2;
         var txt2txt = sym.$("txt2").css("pointer-events","none");
         var txt3;
         var txt3txt = sym.getSymbol("screen3").$("txt3").css("pointer-events","none");
         var txt4txt = sym.getSymbol("screen3").$("txt4").css("pointer-events","none");

         var countstring;
         var countdown;
         var timetxt0 = sym.getSymbol("screen0").$("timeTxt0").css("pointer-events","none");
         var timetxt1 = sym.getSymbol("screen0").$("timeTxt1").css("pointer-events","none");
         var timetxt2 = sym.getSymbol("screen0").$("timeTxt2").css("pointer-events","none");
         var timetxt3 = sym.getSymbol("screen0").$("timeTxt3").css("pointer-events","none");
         var timetxt4 = sym.getSymbol("screen0").$("timeTxt4").css("pointer-events","none");
         var txt5;
         var txt5txt = sym.getSymbol("screen3").$("txt5").css("pointer-events","none");
         var txt6;
         var txt6txt = sym.getSymbol("screen3").$("txt6").css("pointer-events","none");
         var txt7;
         var txt7txt = sym.getSymbol("screen3").$("txt7").css("pointer-events","none");
         var txt8;
         var txt8txt = sym.getSymbol("screen3").$("txt8").css("pointer-events","none");
         var txt9;
         var txt9txt = sym.getSymbol("screen3").$("txt9").css("pointer-events","none");
         var txt10;
         var txt10txt = sym.getSymbol("screen3").$("txt10").css("pointer-events","none");
         var txt11;
         var txt11txt = sym.getSymbol("screen3").$("txt11").css("pointer-events","none");
         var txt12;
         var txt12txt = sym.getSymbol("screen3").$("txt12").css("pointer-events","none");
         var txt13;
         var txt13txt = sym.getSymbol("screen3").$("txt13").css("pointer-events","none");
         var txt14;
         var txt14txt = sym.$("txt14").css("pointer-events","none");
         var txt15;
         var txt15txt = sym.$("txt15").css("pointer-events","none");
         var txt16;
         var txt16txt = sym.$("txt16").css("pointer-events","none");
         var txt17;
         var txt17txt = sym.$("txt17").css("pointer-events","none");
         var txt18;
         var txt18txt = sym.$("txt18").css("pointer-events","none");
         var txt19;
         var txt19txt = sym.$("txt19").css("pointer-events","none");
         var txt20;
         var txt20txt = sym.$("txt20").css("pointer-events","none");
         var string;
         var teams;
			var string1;
			var teamshort;
			var teamname;
			var longname;

           //AJAX retrieves data from xml source specified in url, maps xml variable to DOM object variable
           $.ajax({	
         	type: "GET",
         	url: "GN30292.xml",
         	dataType: "xml",
         	success: function(xml) {
					headline = $(xml).find('headline').text();
         		headlinetxt.html(headline);
         		source = $(xml).find('source').text();
         		sourcetxt.html(source);
         		menuIcon0 = $(xml).find('menuIcon0').text();
         		menuIcon0txt.html(menuIcon0);
         		menuIcon1 = $(xml).find('menuIcon1').text();
         		menuIcon1txt.html(menuIcon1);  
         		menuIcon2 = $(xml).find('menuIcon2').text();
         		menuIcon2txt.html(menuIcon2);
         		menuTxt0 = $(xml).find('menuTxt0').text();
         		menuTxt0txt.html(menuTxt0);  
         		menuTxt1 = $(xml).find('menuTxt1').text();
         		menuTxt1txt.html(menuTxt1);  
         		menuTxt2 = $(xml).find('menuTxt2').text();
         		menuTxt2txt.html(menuTxt2);
         		string = $(xml).find('teams').text(); 
         		teams=string.split(",");
         		teamstxt.text(teams[0]);
         		longname=teams[0];
         		string1 = $(xml).find('teamshort').text(); 
         		teamshort=string1.split(",");
         		teamname= teamshort[0];         		
         		//DEFAULT BUTTONS
					for (i=0; i<11; i++){
						sym.getSymbol("teamBtns").$("teamBtn"+i).click(showTeam(teamshort[i],teams[i]));
					}
					countstring = $(xml).find('countdown0').text();
					countdown=countstring.split(",");
					timetxt0.text(countdown[0]);
					timetxt1.text(countdown[1]);
					timetxt2.text(countdown[2]);
					timetxt3.text(countdown[3]);
					timetxt4.text(countdown[4]);

         		txt1 = $(xml).find('txt1').text();
         		txt1txt.html(txt1);
         		txt2 = $(xml).find('txt2').text();
         		txt2txt.html(txt2);
         		txt3 = $(xml).find('txt3').text();
         		txt3txt.html(txt3);
         		txt4txt.html(txt3)
         		txt5 = $(xml).find('txt5').text();
         		txt5txt.html(txt5);
         		txt6txt.html(txt5);
         		txt7 = $(xml).find('txt7').text();
         		txt7txt.html(txt7);
         		txt8 = $(xml).find('txt8').text();
         		txt8txt.html(txt8);
         		txt9 = $(xml).find('txt9').text();
         		txt9txt.html(txt9);
         		txt10 = $(xml).find('txt10').text();
         		txt10txt.html(txt10);
         		txt11 = $(xml).find('txt11').text();
         		txt11txt.html(txt11);
         		txt12 = $(xml).find('txt12').text();
         		txt12txt.html(txt12);
         		txt13 = $(xml).find('txt13').text();
         		txt13txt.html(txt13);
         		txt14 = $(xml).find('txt14').text();
         		txt14txt.html(txt14);
         		txt15 = $(xml).find('txt15').text();
         		txt15txt.html(txt15);
         		txt16 = $(xml).find('txt16').text();
         		txt16txt.html(txt16);
         		txt17 = $(xml).find('txt17').text();
         		txt17txt.html(txt17);
         		txt18 = $(xml).find('txt18').text();
         		txt18txt.html(txt18);
         		txt19 = $(xml).find('txt19').text();
         		txt19txt.html(txt19);
         		txt20 = $(xml).find('txt20').text();
         		txt20txt.html(txt20);
         		teamtxt0 = $(xml).find('RBR').text();

         		}
         	}); // END XML

// STOP ELEMENTS INTERACTING WITH MOUSE
	sym.$("handMc").css("pointer-events","none");

// MAKE ELEMENTS INVISIBLE
	sym.$("handMc").animate({opacity: 0}, 0);
	sym.$("screen2").fadeOut(0);
	sym.$("screen3").fadeOut(0);


//SHOW TEAM DETAILS	
var showTeam = function(teamdetails,longteam){ //to handle lexical scope
	return function (e) {
		if (carPos==0){
         carPos=1;
         hidden=0;
      }else{
         carPos=0;
         hidden=1;
      }
		teamstxt.html("<b>"+longteam+"</b>");		
		sym.getSymbol("screen3").$("driveCar"+carPos).css({'left':-525});	
		sym.getSymbol("screen3").getSymbol("driveCar"+carPos).$("mainCar").attr("src","cars/"+teamdetails+"big.png");
		sym.getSymbol("screen3").getSymbol("driveCar"+carPos).$("reflection").attr("src","cars/"+teamdetails+"big.png");
		sym.getSymbol("screen3").getSymbol("driveCar"+carPos).$("driverHead").attr("src","drivers/"+teamdetails+".png");
		sym.getSymbol("screen3").getSymbol("driveCar"+carPos).$("bkwheel").attr("src","cars/"+teamdetails+"bk.png");
		sym.getSymbol("screen3").getSymbol("driveCar"+carPos).$("frwheel").attr("src","cars/"+teamdetails+"fr.png");
		sym.$("screen1").fadeOut(500);
		sym.$("screen2").fadeOut(500);
		sym.$("screen3").fadeIn(500);
		sym.$("teamBtns").fadeIn(500);
		sym.$("txt1").fadeOut(500);
		sym.$("txt2").fadeOut(500);
		sym.$("teamsTxt").fadeIn(500);
		sym.getSymbol("screen3").$("driveCar"+carPos).delay(500).animate ({left:65}, 1000);	
		sym.getSymbol("screen3").getSymbol("driveCar"+carPos).play();
		sym.getSymbol("screen3").$("driveCar"+hidden).delay(50).animate ({left:700}, 1000);
		sym.getSymbol("screen3").getSymbol("driveCar"+hidden).play();		
		getStats(teamdetails);
		e.preventDefault()
	};
};
function hideTeamBtn(){
		$(this).fadeOut(0);
		$(this).delay(1000).fadeIn(500);		
}

//GET LIVE DRIVERS STANDINGS

var dataURL = ('http:'==document.location.protocol?"http://www2.graphicnews.com/":"https://www.graphicnews.org/")+ "infostradasports/api.php";
var barHeight;
var nRaceDrivers;
var maxPoints;
var scale;
function getDriverStandings(){
	$.ajax({ type:"GET",
			url:dataURL,
			data:  "gn=30146&q=champdrivers&yr=2013&race=",
         contentType: "text/plain", dataType: "jsonp", jsonp: "callback",
         async: true,
         crossDomain: true,
         success: function (data) {
					var rankData = data;
					//Ensure all drivers will fit in graph
					nRaceDrivers = rankData.length;
					if (rankData.length>20){
					barHeight = ((450/rankData.length)-2);
					}else{
					barHeight = 20;
					}
					//calculate relative length of each bar
					maxPoints = rankData[0].n_PointsSort;
					var min = (maxPoints!=null) ? maxPoints : 0;
						for (var n=0; n<rankData.length; n++) {
							if (rankData[n].n_PointsSort!=null && rankData[n].n_PointsSort<min) {
								min = rankData[n].n_PointsSort;									
								}
						}					
					for (var i = 0; i < rankData.length; i++) {
						if(i==0){ //show lead driver details
							sym.getSymbol("screen1").$("graph").empty();
							var drivershort = rankData[i].c_PersonShort;
							var driverID = rankData[i].n_PersonID;
							var imgCar = rankData[i].c_TeamShort;
							var leadDriver = '<b>' +rankData[i].c_Person+ '</b> <span style="font-size:12px"><i>' +rankData[i].c_NOCShort+ '</i></span>';
							sym.getSymbol("screen1").$("drivertxt0").html(leadDriver);
							sym.getSymbol("screen1").$("drivertxt1").text(rankData[i].c_ConstructorTeam);
							sym.getSymbol("screen1").$("helmetPic").attr("src","drivers/"+driverID+".png");
							sym.getSymbol("screen1").$("driverPic").attr("src","drivers/"+driverID+".jpg");
							sym.getSymbol("screen1").getSymbol("carPic").$("mainCar").attr("src","cars/"+imgCar+"big.png");
							sym.getSymbol("screen1").getSymbol("carPic").$("reflection").attr("src","cars/"+imgCar+"big.png");
							sym.getSymbol("screen1").getSymbol("carPic").$("driverHead").attr("src","drivers/"+driverID+".png");
							sym.getSymbol("screen1").getSymbol("carPic").$("bkwheel").attr("src","cars/"+imgCar+"bk.png");
							sym.getSymbol("screen1").getSymbol("carPic").$("frwheel").attr("src","cars/"+imgCar+"fr.png");
						}
			var tableText ="<div class='driverschamp'><div id='driverdata"+i+"'><table style='width:100%; border:none; border-collapse:collapse; padding:0; margin:0'><tr><td id='driverrnk"+i+"' width='25px' style='font-weight:bold'></td><td id='driverNm"+i+"'width='155px'></td><td id='driverteam"+i+"' style='font-style:italic'></td><td id='driverpts"+i+"' style='font-weight:bold'></td></tr></table></div></div>";
			sym.getSymbol("screen1").$("graph").append(tableText);
         $('#driverrnk' + i).text(rankData[i].n_Rank);		
			$('#driverNm' + i).text(rankData[i].c_Person);
         $('#driverteam' + i).text(rankData[i].c_TeamShort);
         $('#driverpts' + i).text(rankData[i].c_Points);					                                        
			if (maxPoints==min && rankData[i].n_PointsSort==maxPoints) {
				scale=100;
			}else if(rankData[i].n_PointsSort==null){
				scale=54;
			}else{
				scale = 100-((maxPoints-rankData[i].n_PointsSort)*45/(maxPoints-min));
			}
         $(".driverschamp").css({'font-size':'13px', 'font-family':'pragmatica-web, sans-serif', 'width':'100%', 'margin-bottom':'2px'});
			$("#driverdata" + i).css({'height':barHeight+'px','width':'54%', 'background-color':'rgba(230,225,215,0.8)', 'padding-left':'3px', 'box-shadow':'3px 2px 5px rgba(100,100,100,0.75)'});
			$("#driverpts" + i).css({'text-align':'right', 'padding-right':'5px'});
			$("#driverdata" + i).animate({width:scale+'%'},1500);
						}
			}
	});
}
getDriverStandings();
intervalId = setInterval(getDriverStandings,300000);
var nTeams;
var teamBar
function getConsStandings(){
	$.ajax({ type:"GET",
			url:dataURL,
			data:  "gn=30146&q=champteams&yr=2013&race=",
         contentType: "text/plain", dataType: "jsonp", jsonp: "callback",
         async: true,
         crossDomain: true,
         success: function (data) {
			var teamData = data;
			//Ensure all teams will fit in graph
			nTeams = teamData.length;
			if (teamData.length>11){
				teamBar = ((440/teamData.length)-2);
			}else{
				teamBar = 25;
			}
			//calculate relative length of each bar
			teamPoints = teamData[0].n_PointsSort;
			var minpts = (teamPoints!=null) ? teamPoints : 0;
			for (var n=0; n<teamData.length; n++) {
						if (teamData[n].n_PointsSort!=null && teamData[n].n_PointsSort<minpts) {
							minpts = teamData[n].n_PointsSort;									
						}
			}					
			for (var i = 0; i < teamData.length; i++) {
			teamname=teamData[i].c_TeamShort;
			longname=teamData[i].c_Team;
			sym.getSymbol("teamBtns").$("teamBtn"+i).unbind("click");
			sym.getSymbol("styleMc").$("menuBtn2").unbind("click",showTeam);
			if(i==0){ //show lead team details
						sym.getSymbol("screen2").$("graph").empty();
						var imgCar = teamData[i].c_TeamShort;
						sym.getSymbol("screen2").getSymbol("carPic").$("mainCar").attr("src","cars/"+imgCar+"big.png");
						sym.getSymbol("screen2").getSymbol("carPic").$("reflection").attr("src","cars/"+imgCar+"big.png");
						sym.getSymbol("screen2").getSymbol("carPic").$("driverHead").attr("src","drivers/"+imgCar+".png");
						sym.getSymbol("screen2").getSymbol("carPic").$("bkwheel").attr("src","cars/"+imgCar+"bk.png");
						sym.getSymbol("screen2").getSymbol("carPic").$("frwheel").attr("src","cars/"+imgCar+"fr.png");
						sym.getSymbol("styleMc").$("menuBtn2").click(showTeam(teamname,longname));
			}
			var constructorsText ="<div class='teamchamp'><div id='teamdata"+i+"'><table style='width:100%; border:none; border-collapse:collapse; padding:0; margin:0'><tr><td id='teamrnk"+i+"' width='20px' style='font-weight:bold'></td><td id='teamNm"+i+"'></td><td id='teampts"+i+"' style='font-weight:bold'></td></tr></table></div></div>";
			sym.getSymbol("screen2").$("graph").append(constructorsText);
         $('#teamrnk' + i).text(teamData[i].n_Rank);		
			$('#teamNm' + i).text(teamData[i].c_Team);
         $('#teampts' + i).text(teamData[i].c_Points);					                                        
						if (teamPoints==minpts && teamData[i].n_PointsSort==teamPoints) {
						scale=100;
						}else if(teamData[i].n_PointsSort==null){
						scale=39;
						}else{
						scale = 100-((teamPoints-teamData[i].n_PointsSort)*61/(teamPoints-minpts));
						}
         $(".teamchamp").css({'font-size':'13px', 'font-family':'pragmatica-web, sans-serif', 'width':'98%', 'height': '34px','margin-bottom':'2px', 'margin-top':'7px'});
			$("#teamdata" + i).css({'height':'21px','width':scale+'%', 'background-color':'rgba(230,225,215,0.8)', 'padding-left':'3px', 'box-shadow':'3px 2px 5px rgba(100,100,100,0.75)'});
			$("#teampts" + i).css({'text-align':'right', 'padding-right':'5px'});
			sym.getSymbol("teamBtns").$("teamBtn"+i).attr("src","images/"+teamData[i].c_TeamShort+".png");
			sym.getSymbol("teamBtns").$("teamBtn"+i).css({"cursor":'pointer'});
			sym.getSymbol("teamBtns").$("teamBtn"+i).click(showTeam(teamname,longname));
			sym.getSymbol("teamBtns").$("teamBtn"+i).click(hideTeamBtn);
						}
			}
	});
}
getConsStandings();
intervalId = setInterval(getConsStandings,300000);

function getStats(teamdetails){
		$.ajax({	
         	type: "GET",
         	url: "GN30292.xml",
         	dataType: "xml",
         	success: function(xml) {
         	   txt5 = $(xml).find(teamdetails+'1no').text();
         		txt5txt.html(txt5);
         		txt6 = $(xml).find(teamdetails+'1').text();
         		txt6txt.html(txt6);
         		txt7 = $(xml).find(teamdetails+'1details').text();
         		txt7txt.html(txt7);
         		txt8 = $(xml).find(teamdetails+'2no').text();
         		txt8txt.html(txt8);
         		txt9 = $(xml).find(teamdetails+'2').text();
         		txt9txt.html(txt9);
         		txt10 = $(xml).find(teamdetails+'2details').text();
         		txt10txt.html(txt10);
         		txt11 = $(xml).find(teamdetails+'car').text();
         		txt11txt.html(txt11);
         		txt12 = $(xml).find(teamdetails+'1flag').text();
         		txt12txt.html(txt12);
         		txt13 = $(xml).find(teamdetails+'2flag').text();
         		txt13txt.html(txt13);
         		var driver1= $(xml).find(teamdetails+'1id').text();
         		sym.getSymbol("screen3").$("driverpic1").attr("src","drivers/"+driver1+".jpg");
         		var driver2= $(xml).find(teamdetails+'2id').text();
         		sym.getSymbol("screen3").$("driverpic2").attr("src","drivers/"+driver2+".jpg");
         		sym.getSymbol("screen3").$("driverHelmet1").attr("src","drivers/"+driver1+".png");
         		sym.getSymbol("screen3").$("driverHelmet2").attr("src","drivers/"+driver2+".png");
         	}
         });
}

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

for (var h = 0; h < 3; h++){
	var menuBtnSymbols = sym.getSymbol("styleMc").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
	//now you can bind interactivity to the menu items' DIVs
	menuBtnElement.bind ("click 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++){
			var resetmenu_arr = ["menuTxt0","menuTxt1","menuTxt2"];
			$.each(resetmenu_arr, function(index, value) {
			sym.$(value).fadeOut(0);
			sym.$(value).css("color",'rgb(0,0,0)');
			});
         menuArray[h].$("btnClick").fadeOut(0);
         menuArray[h].$("btnOver").fadeOut(0);
		}
	}
	resetmenu();

var firstCar = sym.getSymbol("screen3").$("driveCar0");
var secondCar = sym.getSymbol("screen3").$("driveCar1");
var screen2play=0;
var screen3play=0;
sym.getSymbol("screen1").$("carPic").delay(500).animate({left:163},1000);	
sym.getSymbol("screen1").getSymbol("carPic").play();
var carPos=0;
var hidden=1;
var diff=0;
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("styleMc").getSymbol("menuBtn" + menuMenu_id).$("btnClick").fadeIn(0);
		sym.$("menuTxt" + menuMenu_id).fadeIn(0);
		if (menuMenu_id==0) {
			if (diff<=0){
			sym.$("screen1").fadeIn(500);
			sym.$("screen2").fadeOut(500);
			sym.$("screen3").fadeOut(500);
			sym.$("teamBtns").fadeOut(500);
			sym.$("txt1").fadeIn(500);
			sym.$("txt2").fadeOut(500);
			sym.$("teamsTxt").fadeOut(500);
			}else{
			sym.$("screen0").fadeIn(500);
			sym.$("screen3").fadeOut(500);
			sym.$("teamBtns").fadeOut(500);
			sym.$("txt1").fadeIn(500);
			sym.$("txt2").fadeOut(500);
			timetxt4.html(txt1+" "+countdown[4]);
			timetxt4.fadeIn(500);
			sym.$("teamsTxt").fadeOut(500);			
			sym.$("menuTxt0").css("color",'rgb(255,255,255)');
			sym.$("menuTxt1").css("color",'rgb(255,255,255)');
			sym.$("menuTxt2").css("color",'rgb(255,255,255)');
			counter=setInterval(countDown,1000);	
			}
		}
		if (menuMenu_id==1) {
			if (diff<=0){
			sym.$("screen1").fadeOut(500);
			sym.$("screen2").fadeIn(500);
			sym.$("screen3").fadeOut(500);
			sym.$("teamBtns").fadeIn(500);
			sym.$("txt1").fadeOut(500);
			sym.$("txt2").fadeIn(500);
			sym.$("teamsTxt").fadeOut(500);
			if (screen2play==0){
				sym.getSymbol("screen2").$("carPic").delay(500).animate ({left:163}, 1000);	
				sym.getSymbol("screen2").getSymbol("carPic").play();
				}
			screen2play=1;
			}else{
			sym.$("screen0").fadeIn(500);
			sym.$("screen3").fadeOut(500);
			sym.$("teamBtns").fadeIn(500);
			sym.$("txt1").fadeOut(500);
			sym.$("txt2").fadeIn(500);
			timetxt4.html(txt2+" "+countdown[4]);
			timetxt4.fadeIn(500);
			sym.$("teamsTxt").fadeOut(500);
			sym.$("menuTxt0").css("color",'rgb(255,255,255)');
			sym.$("menuTxt1").css("color",'rgb(255,255,255)');
			sym.$("menuTxt2").css("color",'rgb(255,255,255)');
			counter=setInterval(countDown,1000);
			}
		}
		if (menuMenu_id==2) {
		sym.$("screen0").fadeOut(500);
		sym.$("screen1").fadeOut(500);
		sym.$("screen2").fadeOut(500);
		sym.$("screen3").fadeIn(500);
		sym.$("teamBtns").fadeIn(500);
		sym.$("txt1").fadeOut(500);
		sym.$("txt2").fadeOut(500);
		sym.$("teamsTxt").fadeIn(500);
		sym.$("menuTxt0").css("color",'rgb(0,0,0)');
		sym.$("menuTxt1").css("color",'rgb(0,0,0)');
		sym.$("menuTxt2").css("color",'rgb(0,0,0)');
		clearInterval(counter);
		showTeam(teamname,longname);
		}
	}
	function menuShow (e){
         	var menuMenu_id = (e.data.menuId); //get the id of the over button
         	sym.$('handMc').hide();
				sym.getSymbol("styleMc").getSymbol("menuBtn" + menuMenu_id).$("btnOver").fadeIn(0);
				sym.$("menuTxt" + menuMenu_id).fadeIn(0);
	}
	function menuHide (e){
         	var menuMenu_id = (e.data.menuId); //get the id of the out button
				sym.getSymbol("styleMc").getSymbol("menuBtn" + menuMenu_id).$("btnOver").fadeOut(0);
				sym.$("menuTxt" + menuMenu_id).fadeOut(0);
	}

	// MOVE HAND
sym.$("handMc").delay(1500).animate ({opacity:1, left:495, top:20}, 2000);
sym.$("handMc").delay(500).animate ({opacity:1, left:525, top:20}, 500);
sym.$("handMc").delay(500).animate ({opacity:1, left:575, top:20}, 500);


	//COUNTDOWN
var firstRace= Date.UTC(2013,02,17,06,00,01);
var counter;
var dd1=sym.getSymbol("screen0").$("dd1");
var dd2=sym.getSymbol("screen0").$("dd2");
var hh1=sym.getSymbol("screen0").$("hh1");
var hh2=sym.getSymbol("screen0").$("hh2");
var mm1=sym.getSymbol("screen0").$("mm1");
var mm2=sym.getSymbol("screen0").$("mm2");
var ss1=sym.getSymbol("screen0").$("ss1");
var ss2=sym.getSymbol("screen0").$("ss2");

function countDown(){
var todayDate = new Date();
if (todayDate>=firstRace){
	sym.$("screen0").fadeOut(0);
	clearInterval(counter);
}else{
	sym.$("menuTxt0").css("color",'rgb(255,255,255)');
	sym.$("menuTxt1").css("color",'rgb(255,255,255)');
	sym.$("menuTxt2").css("color",'rgb(255,255,255)');
	diff = firstRace-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();
   dd1.attr("src","numbers/"+dd.substring(0,1)+".png");
   dd2.attr("src","numbers/"+dd.substring(1)+".png");
   hh1.attr("src","numbers/"+hh.substring(0,1)+".png");
   hh2.attr("src","numbers/"+hh.substring(1)+".png");
   mm1.attr("src","numbers/"+mm.substring(0,1)+".png");
   mm2.attr("src","numbers/"+mm.substring(1)+".png");
   ss1.attr("src","numbers/"+ss.substring(0,1)+".png");
   ss2.attr("src","numbers/"+ss.substring(1)+".png");
	}
}
function leadingZero(time) {
    return (time < 10) ? "0" + time : time;
}
countDown();
counter=setInterval(countDown,1000);
if (diff<=0){
	sym.getSymbol("styleMc").getSymbol("menuBtn0").$("btnClick").fadeIn(0);
}else{
	sym.getSymbol("styleMc").getSymbol("menuBtn2").$("btnClick").fadeIn(0);

}

         	});//Edge binding end	

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

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

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

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

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

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

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

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

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

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

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

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

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