/***********************
* 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 stages=[837653,837654,837655,837656,837657,837658,837659,837660,837662,837663,837664,837665,837666,837667,837668,837669,837671,837672,837673,837674,837675];//Vuelta
sym.$("results").animate ({top:610});
var todayDate = new Date();
var startDate= Date.UTC(2013,07,24,06,00,01);
if (todayDate<startDate){
//sym.$("stageMc").animate({left:345});
		sym.$("calMc").animate ({left:586}, 0, 'easeOutCubic');
		sym.$("stageMc").animate ({left:820}, 0, 'easeOutCubic');
		sym.$("upBtn").animate ({top:610}, 0, 'easeOutCubic');
		sym.$("downBtn").animate ({top:610}, 0, 'easeOutCubic');
}
var todayStage=0;
         var headline;
         var headlinetxt = sym.getSymbol("styleHead").$("headlineTxt").css("pointer-events","none");
         var source;
         var sourcetxt = sym.getSymbol("styleBase").$("sourceTxt").css("pointer-events","none");
         var menuIcon0;
         var menuIcon0txt = sym.getSymbol("styleHead").getSymbol("menuBtn0").$("txt").css("pointer-events","none");
         var menuIcon1;
         var menuIcon1txt = sym.getSymbol("styleHead").getSymbol("menuBtn1").$("txt").css("pointer-events","none");
         var menuIcon2;
         var menuIcon2txt = sym.getSymbol("styleHead").getSymbol("menuBtn2").$("txt").css("pointer-events","none");
         var menuIcon3;
         var menuIcon3txt = sym.getSymbol("styleHead").getSymbol("menuBtn3").$("txt").css("pointer-events","none");
         var menuTxt0;
         var menuTxt0txt = sym.getSymbol("styleHead").$("menuTxt0").css("pointer-events","none");
         var menuTxt1;
         var menuTxt1txt = sym.getSymbol("styleHead").$("menuTxt1").css("pointer-events","none");
         var menuTxt2;
         var menuTxt2txt = sym.getSymbol("styleHead").$("menuTxt2").css("pointer-events","none");
         var menuTxt3;
         var menuTxt3txt = sym.getSymbol("styleHead").$("menuTxt3").css("pointer-events","none");
         var nameShort0;
         var nameShort0txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams1Mc").$("nameShort0").css("pointer-events","none");
         var nameShort1;
         var nameShort1txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams1Mc").$("nameShort1").css("pointer-events","none");
         var nameShort2;
         var nameShort2txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams1Mc").$("nameShort2").css("pointer-events","none");
         var nameShort3;
         var nameShort3txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams1Mc").$("nameShort3").css("pointer-events","none");
         var nameShort4;
         var nameShort4txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams1Mc").$("nameShort4").css("pointer-events","none");
         var nameShort5;
         var nameShort5txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams2Mc").$("nameShort5").css("pointer-events","none");
         var nameShort6;
         var nameShort6txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams2Mc").$("nameShort6").css("pointer-events","none");
         var nameShort7;
         var nameShort7txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams2Mc").$("nameShort7").css("pointer-events","none");
         var nameShort8;
         var nameShort8txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams2Mc").$("nameShort8").css("pointer-events","none");
         var nameShort9;
         var nameShort9txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams2Mc").$("nameShort9").css("pointer-events","none");
         var nameShort10;
         var nameShort10txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams3Mc").$("nameShort10").css("pointer-events","none");
         var nameShort11;
         var nameShort11txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams3Mc").$("nameShort11").css("pointer-events","none");
         var nameShort12;
         var nameShort12txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams3Mc").$("nameShort12").css("pointer-events","none");
         var nameShort13;
         var nameShort13txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams3Mc").$("nameShort13").css("pointer-events","none");
         var nameShort14;
         var nameShort14txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams3Mc").$("nameShort14").css("pointer-events","none");
         var nameShort15;
         var nameShort15txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams4Mc").$("nameShort15").css("pointer-events","none");
         var nameShort16;
         var nameShort16txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams4Mc").$("nameShort16").css("pointer-events","none");
         var nameShort17;
         var nameShort17txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams4Mc").$("nameShort17").css("pointer-events","none");
         var nameShort18;
         var nameShort18txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams4Mc").$("nameShort18").css("pointer-events","none");
         var nameShort19;
         var nameShort19txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams4Mc").$("nameShort19").css("pointer-events","none");
         var nameShort20;
         var nameShort20txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams5Mc").$("nameShort20").css("pointer-events","none");
         var nameShort21;
         var nameShort21txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams5Mc").$("nameShort21").css("pointer-events","none");
         var nameShort22;
         var nameShort22txt = sym.getSymbol("teamsMc").getSymbol("teamsSlider").getSymbol("teamsSlideClip").getSymbol("teams5Mc").$("nameShort22").css("pointer-events","none");
         var name;
         var nametxt = sym.getSymbol("teamsMc").$("name").css("pointer-events","none");
         var country;
         var countrytxt = sym.getSymbol("teamsMc").$("country").css("pointer-events","none");
         var riders;
         var riderstxt = sym.getSymbol("teamsMc").$("riders").css("pointer-events","none");

         var txt1;
         var txt1txt = sym.getSymbol("routeMc").$("txt1").css("pointer-events","none");
         var txt2;
         var txt2txt = sym.getSymbol("routeMc").$("txt2").css("pointer-events","none");
         var txt3;
         var txt3txt = sym.$("txt3").css("pointer-events","none");
         var txt4;
         var txt4txt = sym.$("txt4").css("pointer-events","none");
         var txt5;
         var txt5txt = sym.$("txt5").css("pointer-events","none");
         var txt6;
         var txt6txt = sym.getSymbol("teamsMc").$("txt6").css("pointer-events","none");
			var txt7;
         var txt7txt = sym.getSymbol("calMc").$("txt7").css("pointer-events","none");
         var txt8;
         var txt8txt = sym.getSymbol("calMc").$("txt8").css("pointer-events","none");
         var txt9;
         var txt9txt = sym.getSymbol("calMc").$("txt9").css("pointer-events","none");
         var txt10;
         var txt10txt = sym.getSymbol("calMc").$("txt10").css("pointer-events","none");
         var txt11;
         var txt11txt = sym.$("txt11").css("pointer-events","none");
         var txt12;
         var txt12txt = sym.getSymbol("calMc").$("txt12").css("pointer-events","none");
         var txt14;
         var txt14txt = sym.$("txt14").css("pointer-events","none");
			var txt15;
         var stagetxt0 = sym.getSymbol("stageMc").getSymbol("stagesHead").$("stageTxt0").css("pointer-events","none");
         var stagetxt1 = sym.getSymbol("stageMc").getSymbol("stagesHead").$("stageTxt1").css("pointer-events","none");        
         var stagetxt2 = sym.getSymbol("stageMc").getSymbol("stagesHead").$("stageTxt2").css("pointer-events","none");
         var txt16;
         var classtxt= sym.getSymbol("results").getSymbol("classificationsBtn").$("phaseTxt").css("pointer-events","none");
			var txt17;
         var txt17txt = sym.getSymbol("results").$("txt17").css("pointer-events","none");
         var txt18;
         var txt18txt = sym.getSymbol("results").$("txt18").css("pointer-events","none");         
			var txt19;
			var classtxt0=sym.getSymbol("results").getSymbol("classBtn0").$("classTxt").css("pointer-events","none");
			var classtxt1=sym.getSymbol("results").getSymbol("classBtn1").$("classTxt").css("pointer-events","none");
			var classtxt2=sym.getSymbol("results").getSymbol("classBtn2").$("classTxt").css("pointer-events","none");
			var classtxt3=sym.getSymbol("results").getSymbol("classBtn3").$("classTxt").css("pointer-events","none");
			var classtxt4=sym.getSymbol("results").getSymbol("classBtn4").$("classTxt").css("pointer-events","none");
			var txt20;
			var txt21;
			var txt21txt = sym.$("txt21").css("pointer-events","none");
			var txt22;
			var txt22txt = sym.getSymbol("calMc").$("txt22").css("pointer-events","none");
			var txt23;
			var txt23txt = sym.getSymbol("calMc").$("txt23").css("pointer-events","none");
			var txt24;
			var txt24txt = sym.$("txt24").css("pointer-events","none");
			var txt25;
			var txt25txt = sym.$("txt25").css("pointer-events","none");
			var txt26;
			var txt26txt = sym.$("txt26").css("pointer-events","none");
			var txt27;
			var txt27txt = sym.$("txt27").css("pointer-events","none");
			var txt28;
			var txt28txt = sym.$("txt28").css("pointer-events","none");
			var txt29;
			var txt29txt = sym.getSymbol("calMc").$("txt29").css("pointer-events","none");
			var txt30;
			var txt30txt = sym.getSymbol("calMc").$("txt30").css("pointer-events","none");
			var txt31;
			var txt31txt = sym.getSymbol("calMc").$("txt31").css("pointer-events","none");
			var txt32;
			var txt32txt = sym.getSymbol("stageMc").$("txt32").css("pointer-events","none");
			var txt33;
			var txt33txt = sym.$("txt33").css("pointer-events","none");  
			var txt34;
			var txt34txt = sym.$("txt34").css("pointer-events","none");  
			var txt35;
			var txt35txt = sym.$("txt35").css("pointer-events","none");  
			var stagetxt3 = sym.getSymbol("stageMc").getSymbol("stagesHead").$("stageTxt3").css("pointer-events","none");
			var string0;
			var string1;
			var string2;
			var string3;
			var string4;
			var string5;
			var stagestring;
			var datestring;
			var tablestring;
			var resultstring0;
			var resultstring1;
			var resultstring2;

			var distance;
			var distancemap;
			var mediterranean;
//Stage array (includes map and profile captions)
			var profilekey;
			var mapkey;
			var keystring;

//stage0
			var stage0arr=[];
			for (var i = 0; i < 6; i++) {
				stage0arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_0").$("stage0_txt"+i));
			}
//stage1
			var stage1arr=[];
			for (var i = 0; i < 12; i++) {
				stage1arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_1").$("stage1_txt"+i));
			}

//stage2
			var stage2arr=[];
			for (var i = 0; i < 10; i++) {
				stage2arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_2").$("stage2_txt"+i));
			}	

//stage3
			var stage3arr=[];
			for (var i = 0; i < 12; i++) {
				stage3arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_3").$("stage3_txt"+i));
			}
//stage4
			var stage4arr=[];
			for (var i = 0; i < 14; i++) {
				stage4arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_4").$("stage4_txt"+i));
			}
//stage5
			var stage5arr=[];
			for (var i = 0; i < 10; i++) {
				stage5arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_5").$("stage5_txt"+i));
			}
//stage6
			var stage6arr=[];
			for (var i = 0; i < 10; i++) {
				stage6arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_6").$("stage6_txt"+i));
			}
//stage7
			var stage7arr=[];
			for (var i = 0; i < 10; i++) {
				stage7arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_7").$("stage7_txt"+i));
			}
//stage8
			var stage8arr=[];
			for (var i = 0; i < 12; i++) {
				stage8arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_8").$("stage8_txt"+i));
			}
//stage9
			var stage9arr=[];
			for (var i = 0; i < 12; i++) {
				stage9arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_9").$("stage9_txt"+i));
			}
//stage10
			var stage10arr=[];
			for (var i = 0; i < 6; i++) {
				stage10arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_10").$("stage10_txt"+i));
			}
//stage11
			var stage11arr=[];
			for (var i = 0; i < 12; i++) {
				stage11arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_11").$("stage11_txt"+i));
			}
//stage12
			var stage12arr=[];
			for (var i = 0; i < 14; i++) {
				stage12arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_12").$("stage12_txt"+i));
			}
//stage13
			var stage13arr=[];
			for (var i = 0; i < 16; i++) {
				stage13arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_13").$("stage13_txt"+i));
			}
//stage14
			var stage14arr=[];
			for (var i = 0; i < 16; i++) {
				stage14arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_14").$("stage14_txt"+i));
			}
//stage15
			var stage15arr=[];
			for (var i = 0; i < 14; i++) {
				stage15arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_15").$("stage15_txt"+i));
			}
//stage16
			var stage16arr=[];
			for (var i = 0; i < 14; i++) {
				stage16arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_16").$("stage16_txt"+i));
			}
//stage17
			var stage17arr=[];
			for (var i = 0; i < 18; i++) {
				stage17arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_17").$("stage17_txt"+i));
			}
//stage18
			var stage18arr=[];
			for (var i = 0; i < 14; i++) {
				stage18arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_18").$("stage18_txt"+i));
			}
//stage19
			var stage19arr=[];
			for (var i = 0; i < 16; i++) {
				stage19arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_19").$("stage19_txt"+i));
			}
//stage20
			var stage20arr=[];
			for (var i = 0; i < 10; i++) {
				stage20arr.push(sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").getSymbol("profileMc_20").$("stage20_txt"+i));
			}


			var mapStart;
			var mapFinish;


           //AJAX retrieves data from xml source specified in url, maps xml variable to DOM object variable
           $.ajax({	
         	type: "GET",
         	url: "GN30875.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);
         		menuIcon3 = $(xml).find('menuIcon3').text();
         		menuIcon3txt.html(menuIcon3);
         		menuTxt0 = $(xml).find('menuTxt0').text();
         		menuTxt0txt.html(menuTxt0);  
         		menuTxt1 = $(xml).find('menuTxt1').text();
         		menuTxt1txt.html(menuTxt1);  
         		menuTxt2 = $(xml).find('menuTxt2').text();
         		menuTxt2txt.html(menuTxt2);
         		menuTxt3 = $(xml).find('menuTxt3').text();
         		var menuTxt4=$(xml).find('txt11').text();
         		if (todayDate<startDate){
						menuTxt3txt.html(menuTxt4);
					}else{
						menuTxt3txt.html(menuTxt3);
					}
         		nameShort0 = $(xml).find('nameShort0').text();
         		nameShort0txt.html(nameShort0);
         		nameShort1 = $(xml).find('nameShort1').text();
         		nameShort1txt.html(nameShort1);
         		nameShort2 = $(xml).find('nameShort2').text();
         		nameShort2txt.html(nameShort2);
         		nameShort3 = $(xml).find('nameShort3').text();
         		nameShort3txt.html(nameShort3);
         		nameShort4 = $(xml).find('nameShort4').text();
         		nameShort4txt.html(nameShort4);
         		nameShort5 = $(xml).find('nameShort5').text();
         		nameShort5txt.html(nameShort5);
         		nameShort6 = $(xml).find('nameShort6').text();
         		nameShort6txt.html(nameShort6);
         		nameShort7 = $(xml).find('nameShort7').text();
         		nameShort7txt.html(nameShort7);
         		nameShort8 = $(xml).find('nameShort8').text();
         		nameShort8txt.html(nameShort8);
         		nameShort9 = $(xml).find('nameShort9').text();
         		nameShort9txt.html(nameShort9);
         		nameShort10 = $(xml).find('nameShort10').text();
         		nameShort10txt.html(nameShort10);
         		nameShort11 = $(xml).find('nameShort11').text();
         		nameShort11txt.html(nameShort11);
         		nameShort12 = $(xml).find('nameShort12').text();
         		nameShort12txt.html(nameShort12);
         		nameShort13 = $(xml).find('nameShort13').text();
         		nameShort13txt.html(nameShort13);
         		nameShort14 = $(xml).find('nameShort14').text();
         		nameShort14txt.html(nameShort14);
         		nameShort15 = $(xml).find('nameShort15').text();
         		nameShort15txt.html(nameShort15);
         		nameShort16 = $(xml).find('nameShort16').text();
         		nameShort16txt.html(nameShort16);
         		nameShort17 = $(xml).find('nameShort17').text();
         		nameShort17txt.html(nameShort17);
         		nameShort18 = $(xml).find('nameShort18').text();
         		nameShort18txt.html(nameShort18);
         		nameShort19 = $(xml).find('nameShort19').text();
         		nameShort19txt.html(nameShort19);
         		nameShort20 = $(xml).find('nameShort20').text();
         		nameShort20txt.html(nameShort20);
         		nameShort21 = $(xml).find('nameShort21').text();
         		nameShort21txt.html(nameShort21);
         		nameShort22 = $(xml).find('nameShort22').text();
         		nameShort22txt.html(nameShort22);
         		country = $(xml).find('country1').text();
         		countrytxt.html(country);
         		name = $(xml).find('name1').text();
         		nametxt.html(name + country);
         		riders = $(xml).find('riders1').text();
         		riderstxt.html(riders);
         		txt1 = $(xml).find('txt1').text();
         		txt1txt.html(txt1);
         		txt2 = $(xml).find('txt2').text();
         		txt2txt.html(txt2);
         		txt3 = $(xml).find('txt3').text();
         		txt3txt.html(txt3);
         		txt4 = $(xml).find('txt4').text();
         		txt4txt.html(txt4)
         		txt5 = $(xml).find('txt5').text();
         		txt5txt.html(txt5);
         		txt6 = $(xml).find('txt6').text();
         		txt6txt.html(txt6);
					txt7 = $(xml).find('txt7').text();
         		txt7txt.html(txt7);
         		txt8 = $(xml).find('txt8').text();
         		txt8txt.html(txt8);
         		txt9 = $(xml).find('txt9').text();
         		txt9txt.html(txt9);
         		string0 = $(xml).find('txt8').text(); 
         		stagestring=string0.split("<br>");
         		string1 = $(xml).find('txt9').text(); 
         		datestring=string1.split("<br>");         		
         		txt10 = $(xml).find('txt10').text();
         		txt10txt.html(txt10);
         		txt11 = $(xml).find('txt11').text();
         		txt11txt.html(txt11);
         		txt12 = $(xml).find('txt12').text();
         		txt12txt.html(txt12);
         		txt14 = $(xml).find('txt14').text();
         		txt14txt.html(txt14);       		
         		string2 = $(xml).find('txt15').text(); 
         		tablestring=string2.split(",");   		
         		stagetxt0.text(stagestring[0]+" "+stagestring[1]+" - "+datestring[0]+" "+datestring[1]);
         		stagetxt1.text(tablestring[0]);
         		stagetxt2.text(tablestring[1]);
         		//stagetxt3.text(tablestring[1]);
         		profilekey= $(xml).find('profilekey').text();
         		keystring=profilekey.split(",");

         		txt16 = $(xml).find('txt16').text();
					classtxt.html(txt16);
         		string3 = $(xml).find('txt17').text(); 
         		resultstring0=string3.split(",");
					txt17txt.text(resultstring0[0]+stagestring[1]);

         		string4 = $(xml).find('txt18').text(); 
         		resultstring1=string4.split(","); 
         		txt18txt.html(resultstring1[0]);
         		txt20 = $(xml).find('txt20').text();
         		txt21 = $(xml).find('txt21').text();
					txt21txt.html(txt21);
					txt22 = $(xml).find('txt22').text();
					txt22txt.html(txt22);
					txt23 = $(xml).find('txt23').text();
					txt23txt.html(txt23);
					txt24 = $(xml).find('txt24').text();
					txt24txt.html(txt24);
					txt25 = $(xml).find('txt25').text();
					txt25txt.html(txt25);
					txt26 = $(xml).find('txt26').text();
					txt26txt.html(txt26);
					txt27 = $(xml).find('txt27').text();
					txt27txt.html(txt27);
					txt28 = $(xml).find('txt28').text();
					txt28txt.html(txt28);

					txt29 = $(xml).find('txt29').text();
					txt29txt.html(txt29);
					txt30 = $(xml).find('txt30').text();
					txt30txt.html(txt30);   
					txt31 = $(xml).find('txt31').text();
					txt31txt.html(txt31);   
					txt32 = $(xml).find('txt32').text();
					txt32txt.html(txt32);   
					txt33 = $(xml).find('txt33').text();
					txt33txt.html(txt33);  
					/*txt34 = $(xml).find('txt34').text();
					txt34txt.html(txt34);  
					txt35 = $(xml).find('txt35').text();
					txt35txt.html(txt35);    
         		*/
         		stagetxt3.text(txt20+" "+datestring[0]+" "+datestring[1]);
					string5 = $(xml).find('txt19').text(); 
         		resultstring1=string5.split(",");   
					classtxt0.text(resultstring1[0]);
					classtxt1.text(resultstring1[1]);
					classtxt2.text(resultstring1[2]);
					classtxt3.text(resultstring1[3]);
					classtxt4.text(resultstring1[4]);

					distance = $(xml).find('distance').text();
					distancemap = $(xml).find('distancemap').text();
					mediterranean = $(xml).find('mediterranean').text();
					//map start/finish must come before stage arrays
					mapStart = $(xml).find('mapStart').text();
					mapFinish = $(xml).find('mapFinish').text();

			// stage0	
					stage0_distance = $(xml).find('stage0_distance').text();
					distancestage0 = stage0_distance.split("*");
					stage0_route = $(xml).find('stage0_route').text();
					routestage0 = stage0_route.split("*");
					stage0arr[0].html(routestage0[0]);
					stage0arr[1].html(routestage0[1]);
					stage0arr[2].html(routestage0[2]);
					stage0arr[3].html(distance);
					stage0arr[4].html(distancestage0[0]);
					stage0arr[5].html(distancestage0[1]);
			// stage1	
					stage1_distance = $(xml).find('stage1_distance').text();
					distancestage1 = stage1_distance.split("*");
					stage1_route = $(xml).find('stage1_route').text();
					routestage1 = stage1_route.split("*");
					stage1arr[0].html(routestage1[0]);
					stage1arr[1].html(routestage1[1]);
					stage1arr[2].html(routestage1[2]);
					stage1arr[3].html(routestage1[3]);
					stage1arr[4].html(routestage1[4]);
					stage1arr[5].html(routestage1[5]);
					stage1arr[6].html(distance);
					stage1arr[7].html(distancestage1[0]);
					stage1arr[8].html(distancestage1[1]);
					stage1arr[9].html(distancestage1[2]);
					stage1arr[10].html(distancestage1[3]);
					stage1arr[11].html(distancestage1[4]);
		// stage2	
					stage2_distance = $(xml).find('stage2_distance').text();
					distancestage2 = stage2_distance.split("*");
					stage2_route = $(xml).find('stage2_route').text();
					routestage2 = stage2_route.split("*");
					stage2arr[0].html(routestage2[0]);
					stage2arr[1].html(routestage2[1]);
					stage2arr[2].html(routestage2[2]);
					stage2arr[3].html(routestage2[3]);
					stage2arr[4].html(routestage2[4]);
					stage2arr[5].html(distance);
					stage2arr[6].html(distancestage2[0]);
					stage2arr[7].html(distancestage2[1]);
					stage2arr[8].html(distancestage2[2]);
					stage2arr[9].html(distancestage2[3]);
				// stage3	
					stage3_distance = $(xml).find('stage3_distance').text();
					distancestage3 = stage3_distance.split("*");
					stage3_route = $(xml).find('stage3_route').text();
					routestage3 = stage3_route.split("*");
					stage3arr[0].html(routestage3[0]);
					stage3arr[1].html(routestage3[1]);
					stage3arr[2].html(routestage3[2]);
					stage3arr[3].html(routestage3[3]);
					stage3arr[4].html(routestage3[4]);
					stage3arr[5].html(routestage3[5]);
					stage3arr[6].html(distance);
					stage3arr[7].html(distancestage3[0]);
					stage3arr[8].html(distancestage3[1]);
					stage3arr[9].html(distancestage3[2]);
					stage3arr[10].html(distancestage3[3]);
					stage3arr[11].html(distancestage3[4]);
		// stage4	
					stage4_distance = $(xml).find('stage4_distance').text();
					distancestage4 = stage4_distance.split("*");
					stage4_route = $(xml).find('stage4_route').text();
					routestage4 = stage4_route.split("*");
					stage4arr[0].html(routestage4[0]);
					stage4arr[1].html(routestage4[1]);
					stage4arr[2].html(routestage4[2]);
					stage4arr[3].html(routestage4[3]);
					stage4arr[4].html(routestage4[4]);
					stage4arr[5].html(routestage4[5]);
					stage4arr[6].html(routestage4[6]);
					stage4arr[7].html(distance);
					stage4arr[8].html(distancestage4[0]);
					stage4arr[9].html(distancestage4[1]);
					stage4arr[10].html(distancestage4[2]);
					stage4arr[11].html(distancestage4[3]);
					stage4arr[12].html(distancestage4[4]);
					stage4arr[13].html(distancestage4[5]);
  	// stage5	
					stage5_distance = $(xml).find('stage5_distance').text();
					distancestage5 = stage5_distance.split("*");
					stage5_route = $(xml).find('stage5_route').text();
					routestage5 = stage5_route.split("*");
					stage5arr[0].html(routestage5[0]);
					stage5arr[1].html(routestage5[1]);
					stage5arr[2].html(routestage5[2]);
					stage5arr[3].html(routestage5[3]);
					stage5arr[4].html(routestage5[4]);
					stage5arr[5].html(distance);
					stage5arr[6].html(distancestage5[0]);
					stage5arr[7].html(distancestage5[1]);
					stage5arr[8].html(distancestage5[2]);
					stage5arr[9].html(distancestage5[3]);
		// stage6	
					stage6_distance = $(xml).find('stage6_distance').text();
					distancestage6 = stage6_distance.split("*");
					stage6_route = $(xml).find('stage6_route').text();
					routestage6 = stage6_route.split("*");
					stage6arr[0].html(routestage6[0]);
					stage6arr[1].html(routestage6[1]);
					stage6arr[2].html(routestage6[2]);
					stage6arr[3].html(routestage6[3]);
					stage6arr[4].html(routestage6[4]);
					stage6arr[5].html(distance);
					stage6arr[6].html(distancestage6[0]);
					stage6arr[7].html(distancestage6[1]);
					stage6arr[8].html(distancestage6[2]);
					stage6arr[9].html(distancestage6[3]);
		// stage7	
					stage7_distance = $(xml).find('stage7_distance').text();
					distancestage7 = stage7_distance.split("*");
					stage7_route = $(xml).find('stage7_route').text();
					routestage7 = stage7_route.split("*");
					stage7arr[0].html(routestage7[0]);
					stage7arr[1].html(routestage7[1]);
					stage7arr[2].html(routestage7[2]);
					stage7arr[3].html(routestage7[3]);
					stage7arr[4].html(routestage7[4]);
					stage7arr[5].html(distance);
					stage7arr[6].html(distancestage7[0]);
					stage7arr[7].html(distancestage7[1]);
					stage7arr[8].html(distancestage7[2]);
					stage7arr[9].html(distancestage7[3]);
		// stage8	
					stage8_distance = $(xml).find('stage8_distance').text();
					distancestage8 = stage8_distance.split("*");
					stage8_route = $(xml).find('stage8_route').text();
					routestage8 = stage8_route.split("*");
					stage8arr[0].html(routestage8[0]);
					stage8arr[1].html(routestage8[1]);
					stage8arr[2].html(routestage8[2]);
					stage8arr[3].html(routestage8[3]);
					stage8arr[4].html(routestage8[4]);
					stage8arr[5].html(routestage8[5]);
					stage8arr[6].html(distance);
					stage8arr[7].html(distancestage8[0]);
					stage8arr[8].html(distancestage8[1]);
					stage8arr[9].html(distancestage8[2]);
					stage8arr[10].html(distancestage8[3]);
					stage8arr[11].html(distancestage8[4]);
		// stage9	
					stage9_distance = $(xml).find('stage9_distance').text();
					distancestage9 = stage9_distance.split("*");
					stage9_route = $(xml).find('stage9_route').text();
					routestage9 = stage9_route.split("*");
					stage9arr[0].html(routestage9[0]);
					stage9arr[1].html(routestage9[1]);
					stage9arr[2].html(routestage9[2]);
					stage9arr[3].html(routestage9[3]);
					stage9arr[4].html(routestage9[4]);
					stage9arr[5].html(routestage9[5]);
					stage9arr[6].html(distance);
					stage9arr[7].html(distancestage9[0]);
					stage9arr[8].html(distancestage9[1]);
					stage9arr[9].html(distancestage9[2]);
					stage9arr[10].html(distancestage9[3]);
					stage9arr[11].html(distancestage9[4]);
		// stage10	
					stage10_distance = $(xml).find('stage10_distance').text();
					distancestage10 = stage10_distance.split("*");
					stage10_route = $(xml).find('stage10_route').text();
					routestage10 = stage10_route.split("*");
					stage10arr[0].html(routestage10[0]);
					stage10arr[1].html(routestage10[1]);
					stage10arr[2].html(routestage10[2]);
					stage10arr[3].html(distance);
					stage10arr[4].html(distancestage10[0]);
					stage10arr[5].html(distancestage10[1]);
		// stage11	
					stage11_distance = $(xml).find('stage11_distance').text();
					distancestage11 = stage11_distance.split("*");
					stage11_route = $(xml).find('stage11_route').text();
					routestage11 = stage11_route.split("*");
					stage11arr[0].html(routestage11[0]);
					stage11arr[1].html(routestage11[1]);
					stage11arr[2].html(routestage11[2]);
					stage11arr[3].html(routestage11[3]);
					stage11arr[4].html(routestage11[4]);
					stage11arr[5].html(routestage11[5]);
					stage11arr[6].html(distance);
					stage11arr[7].html(distancestage11[0]);
					stage11arr[8].html(distancestage11[1]);
					stage11arr[9].html(distancestage11[2]);
					stage11arr[10].html(distancestage11[3]);
					stage11arr[11].html(distancestage11[4]);
		// stage12	
					stage12_distance = $(xml).find('stage12_distance').text();
					distancestage12 = stage12_distance.split("*");
					stage12_route = $(xml).find('stage12_route').text();
					routestage12 = stage12_route.split("*");
					stage12arr[0].html(routestage12[0]);
					stage12arr[1].html(routestage12[1]);
					stage12arr[2].html(routestage12[2]);
					stage12arr[3].html(routestage12[3]);
					stage12arr[4].html(routestage12[4]);
					stage12arr[5].html(routestage12[5]);
					stage12arr[6].html(routestage12[6]);
					stage12arr[7].html(distance);
					stage12arr[8].html(distancestage12[0]);
					stage12arr[9].html(distancestage12[1]);
					stage12arr[10].html(distancestage12[2]);
					stage12arr[11].html(distancestage12[3]);
					stage12arr[12].html(distancestage12[4]);
					stage12arr[13].html(distancestage12[5]);
		// stage13	
					stage13_distance = $(xml).find('stage13_distance').text();
					distancestage13 = stage13_distance.split("*");
					stage13_route = $(xml).find('stage13_route').text();
					routestage13 = stage13_route.split("*");
					stage13arr[0].html(routestage13[0]);
					stage13arr[1].html(routestage13[1]);
					stage13arr[2].html(routestage13[2]);
					stage13arr[3].html(routestage13[3]);
					stage13arr[4].html(routestage13[4]);
					stage13arr[5].html(routestage13[5]);
					stage13arr[6].html(routestage13[6]);
					stage13arr[7].html(routestage13[7]);
					stage13arr[8].html(distance);
					stage13arr[9].html(distancestage13[0]);
					stage13arr[10].html(distancestage13[1]);
					stage13arr[11].html(distancestage13[2]);
					stage13arr[12].html(distancestage13[3]);
					stage13arr[13].html(distancestage13[4]);
					stage13arr[14].html(distancestage13[5]);
					stage13arr[15].html(distancestage13[6]);
		// stage14	
					stage14_distance = $(xml).find('stage14_distance').text();
					distancestage14 = stage14_distance.split("*");
					stage14_route = $(xml).find('stage14_route').text();
					routestage14 = stage14_route.split("*");
					stage14arr[0].html(routestage14[0]);
					stage14arr[1].html(routestage14[1]);
					stage14arr[2].html(routestage14[2]);
					stage14arr[3].html(routestage14[3]);
					stage14arr[4].html(routestage14[4]);
					stage14arr[5].html(routestage14[5]);
					stage14arr[6].html(routestage14[6]);
					stage14arr[7].html(routestage14[7]);
					stage14arr[8].html(distance);
					stage14arr[9].html(distancestage14[0]);
					stage14arr[10].html(distancestage14[1]);
					stage14arr[11].html(distancestage14[2]);
					stage14arr[12].html(distancestage14[3]);
					stage14arr[13].html(distancestage14[4]);
					stage14arr[14].html(distancestage14[5]);
					stage14arr[15].html(distancestage14[6]);
		// stage15	
					stage15_distance = $(xml).find('stage15_distance').text();
					distancestage15 = stage15_distance.split("*");
					stage15_route = $(xml).find('stage15_route').text();
					routestage15 = stage15_route.split("*");
					stage15arr[0].html(routestage15[0]);
					stage15arr[1].html(routestage15[1]);
					stage15arr[2].html(routestage15[2]);
					stage15arr[3].html(routestage15[3]);
					stage15arr[4].html(routestage15[4]);
					stage15arr[5].html(routestage15[5]);
					stage15arr[6].html(routestage15[6]);
					stage15arr[7].html(distance);
					stage15arr[8].html(distancestage15[0]);
					stage15arr[9].html(distancestage15[1]);
					stage15arr[10].html(distancestage15[2]);
					stage15arr[11].html(distancestage15[3]);
					stage15arr[12].html(distancestage15[4]);
					stage15arr[13].html(distancestage15[5]);
		// stage16	
					stage16_distance = $(xml).find('stage16_distance').text();
					distancestage16 = stage16_distance.split("*");
					stage16_route = $(xml).find('stage16_route').text();
					routestage16 = stage16_route.split("*");
					stage16arr[0].html(routestage16[0]);
					stage16arr[1].html(routestage16[1]);
					stage16arr[2].html(routestage16[2]);
					stage16arr[3].html(routestage16[3]);
					stage16arr[4].html(routestage16[4]);
					stage16arr[5].html(routestage16[5]);
					stage16arr[6].html(routestage16[6]);
					stage16arr[7].html(distance);
					stage16arr[8].html(distancestage16[0]);
					stage16arr[9].html(distancestage16[1]);
					stage16arr[10].html(distancestage16[2]);
					stage16arr[11].html(distancestage16[3]);
					stage16arr[12].html(distancestage16[4]);
					stage16arr[13].html(distancestage16[5]);
		// stage17	
					stage17_distance = $(xml).find('stage17_distance').text();
					distancestage17 = stage17_distance.split("*");
					stage17_route = $(xml).find('stage17_route').text();
					routestage17 = stage17_route.split("*");
					stage17arr[0].html(routestage17[0]);
					stage17arr[1].html(routestage17[1]);
					stage17arr[2].html(routestage17[2]);
					stage17arr[3].html(routestage17[3]);
					stage17arr[4].html(routestage17[4]);
					stage17arr[5].html(routestage17[5]);
					stage17arr[6].html(routestage17[6]);
					stage17arr[7].html(routestage17[7]);
					stage17arr[8].html(routestage17[8]);
					stage17arr[9].html(distance);
					stage17arr[10].html(distancestage17[0]);
					stage17arr[11].html(distancestage17[1]);
					stage17arr[12].html(distancestage17[2]);
					stage17arr[13].html(distancestage17[3]);
					stage17arr[14].html(distancestage17[4]);
					stage17arr[15].html(distancestage17[5]);
					stage17arr[16].html(distancestage17[6]);
					stage17arr[17].html(distancestage17[7]);
		// stage18	
					stage18_distance = $(xml).find('stage18_distance').text();
					distancestage18 = stage18_distance.split("*");
					stage18_route = $(xml).find('stage18_route').text();
					routestage18 = stage18_route.split("*");
					stage18arr[0].html(routestage18[0]);
					stage18arr[1].html(routestage18[1]);
					stage18arr[2].html(routestage18[2]);
					stage18arr[3].html(routestage18[3]);
					stage18arr[4].html(routestage18[4]);
					stage18arr[5].html(routestage18[5]);
					stage18arr[6].html(routestage18[6]);
					stage18arr[7].html(distance);
					stage18arr[8].html(distancestage18[0]);
					stage18arr[9].html(distancestage18[1]);
					stage18arr[10].html(distancestage18[2]);
					stage18arr[11].html(distancestage18[3]);
					stage18arr[12].html(distancestage18[4]);
					stage18arr[13].html(distancestage18[5]);
		// stage19	
					stage19_distance = $(xml).find('stage19_distance').text();
					distancestage19 = stage19_distance.split("*");
					stage19_route = $(xml).find('stage19_route').text();
					routestage19 = stage19_route.split("*");
					stage19arr[0].html(routestage19[0]);
					stage19arr[1].html(routestage19[1]);
					stage19arr[2].html(routestage19[2]);
					stage19arr[3].html(routestage19[3]);
					stage19arr[4].html(routestage19[4]);
					stage19arr[5].html(routestage19[5]);
					stage19arr[6].html(routestage19[6]);
					stage19arr[7].html(routestage19[7]);
					stage19arr[8].html(distance);
					stage19arr[9].html(distancestage19[0]);
					stage19arr[10].html(distancestage19[1]);
					stage19arr[11].html(distancestage19[2]);
					stage19arr[12].html(distancestage19[3]);
					stage19arr[13].html(distancestage19[4]);
					stage19arr[14].html(distancestage19[5]);
					stage19arr[15].html(distancestage19[6]);
		// stage20	
					stage20_distance = $(xml).find('stage20_distance').text();
					distancestage20 = stage20_distance.split("*");
					stage20_route = $(xml).find('stage20_route').text();
					routestage20 = stage20_route.split("*");
					stage20arr[0].html(routestage20[0]);
					stage20arr[1].html(routestage20[1]);
					stage20arr[2].html(routestage20[2]);
					stage20arr[3].html(routestage20[3]);
					stage20arr[4].html(routestage20[4]);
					stage20arr[5].html(distance);
					stage20arr[6].html(distancestage20[0]);
					stage20arr[7].html(distancestage20[1]);
					stage20arr[8].html(distancestage20[2]);
					stage20arr[9].html(distancestage20[3]);


					sym.$("txt21").animate ({top:578 - sym.$("txt21").height()-50}, 0); 
					$(".hrule hr").css({'color':'#CCCCCC','background-color':'#CCCCCC'});
         		}
         	}); // END XML

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

	for (var h = 0; h < 4; 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
	//now you can bind interactivity to the menu items' DIVs
	menuBtnElement.bind ("click", {menuId:count}, menuBtnClick);
	menuBtnElement.bind ("touchstart", {menuId:count}, menuBtnClick);
	menuBtnElement.bind ("mouseover", {menuId:count}, menuShow);
	menuBtnElement.bind ("mouseout", {menuId:count}, menuHide);
})
sym.getSymbol("styleHead").$("menuBtn3").unbind("click");

function resetmenu(){
	for (var h=0; h<4; h++){
		var resetmenu_arr = ["menuTxt0","menuTxt1","menuTxt2","menuTxt3"];
		$.each(resetmenu_arr, function(index, value) {
			sym.getSymbol("styleHead").$(value).fadeOut(0);
		});
		menuArray[h].$("btnClick").fadeOut(0);
		menuArray[h].$("btnOver").fadeOut(0);
	}
}
resetmenu();

function menuBtnClick (e){
		var menuMenu_id = (e.data.menuId); //get the id of the clicked item
		sym.$("results").stop().animate ({top:610}, 400, 'easeOutCubic');
		resetmenu(); //set them all back to normal state	
		sym.getSymbol("styleHead").getSymbol("menuBtn" + menuMenu_id).$("btnClick").fadeIn(0);
		sym.getSymbol("styleHead").$("menuTxt" + menuMenu_id).fadeIn(0);
		if (clicked!=menuMenu_id){
		sym.$("calMc").animate ({left:820}, 400, 'easeOutCubic');
		sym.$("stageMc").animate ({left:820}, 400, 'easeOutCubic');
		sym.$("upBtn").animate ({top:610}, 0, 'easeOutCubic');
		sym.$("downBtn").animate ({top:610}, 0, 'easeOutCubic');

		sym.$("teamsMc").animate ({left:820}, {duration:400, complete:  function() { resetTeams(); }});
		}
		if (menuMenu_id==0) {
			sym.$("stageMc").animate ({left:345}, 550, 'easeOutCubic');
			clicked=0;
		}
		if (menuMenu_id==1) {
			sym.$("teamsMc").animate ({left:492}, 400, 'easeOutCubic');
			sym.$("upBtn").delay(700).animate ({top:560}, 0, 'easeOutCubic');
			sym.$("downBtn").delay(700).animate ({top:560}, 0, 'easeOutCubic');
			sym.getSymbol("downBtn").$("btnOver").fadeOut(0);
			clicked=1;
		}
		if (menuMenu_id==2) {
			sym.$("calMc").stop().animate ({left:586}, 400, 'easeOutCubic');
			clicked=2;
		}
		if (menuMenu_id==3) {
			sym.$("results").stop().animate ({top:39}, 400, 'easeOutCubic');
			clicked=3;
		}
	}
	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);
				sym.getSymbol("styleHead").$("menuTxt" + menuMenu_id).fadeIn(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);
				sym.getSymbol("styleHead").$("menuTxt" + menuMenu_id).fadeOut(0);
	}
	if (todayDate<startDate){
		sym.getSymbol("styleHead").getSymbol("menuBtn2").$("btnOver").fadeIn(0);
	}else{
		sym.getSymbol("styleHead").getSymbol("menuBtn0").$("btnOver").fadeIn(0);
	}
// STAGE BUTTONS --------------------------------------------	
// MAP BUTTON START
	sym.getSymbol("stageMc").getSymbol("stagesHead").$("mapBtn").fadeOut(0);
	sym.getSymbol("stageMc").getSymbol("stagesHead").$("profBtn").fadeOut(0);

// ADD NUMBERS
	for (var x=0; x<21; x++){
		sym.getSymbol("routeMc").getSymbol("stageBtn"+x).$("txt").html(x+1)
	}
// SET STAGE PROFILE POSITIONS
	for (var p=0; p<21; p++){
		sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").getSymbol("stageProfileMc").$("profileMc_"+p).animate({left:p*495});
	}

var resultChanger = function(stage){ //to handle lexical scope
							return function (e) {
							getClassification(stage);
						};
};

stageBtnArray = []; //the array that will hold references to the buttons.
         for (var s = 0; s < 21; s++){
         	 var stageBtnSymbols = sym.getSymbol("routeMc").getSymbol("stageBtn" +s); // Create an instance element of a symbol as a child of the given parent element
         	 stageBtnSymbols.setVariable("stageBtnId", s); //set the value of a Symbol variable
         	 stageBtnArray.push(stageBtnSymbols); //push it into the array
         }

         $.each(stageBtnArray, function( count, stageBtnInTheArray ){ //a 'for each' loop through the newly populated array
         	 var stageBtnItem = $(stageBtnInTheArray); //create jQuery reference to the item
         	 var stageBtnElement = stageBtnInTheArray.getSymbolElement(); //create a jQuery reference to the DIV element inside the symbol
         	 //now you can bind interactivity to the stageBtn items' DIVs
         	 stageBtnElement.bind ("click", {stageBtnId:count}, stageBtnClick);
         	 stageBtnElement.bind ("touchstart", {stageBtnId:count}, stageBtnClick);
         	 stageBtnElement.bind ("mouseover", {stageBtnId:count}, stageBtnShow);
         	 stageBtnElement.bind ("mouseout", {stageBtnId:count}, stageBtnHide);
         	})

	function resetstageBtn(){
		for (var s=0; s<21; s++){
         stageBtnArray[s].$("btnClick").fadeOut(0);
         stageBtnArray[s].$("btnOver").fadeOut(0);
         stageBtnArray[s].$("btnStart").fadeOut(0);
		}
	}
	resetstageBtn();

	function stageBtnClick (e){
		resetstageBtn(); //set them all back to normal state
		var stageBtn_id = (e.data.stageBtnId); //get the id of the clicked item
		sym.getSymbol("routeMc").getSymbol("stageBtn" + stageBtn_id).$("btnClick").fadeIn(0);
		sym.getSymbol("routeMc").$("stageBtnTxt" + stageBtn_id).fadeIn(0);

		resetmenu(); //set menu back to normal state	
		sym.getSymbol("styleHead").getSymbol("menuBtn0").$("btnClick").fadeIn(0);
		if (clicked!=0){
		sym.$("txt13").fadeIn(500);
		sym.$("teamsMc").animate ({left:820}, {duration:600, complete:  function() { resetTeams(); }});
		sym.$("stageMc").animate ({left:345}, 600, 'easeOutCubic');
		sym.$("upBtn").animate ({top:610}, 0, 'easeOutCubic');
		sym.$("downBtn").animate ({top:610}, 0, 'easeOutCubic');
		sym.$("calMc").animate ({left:800}, 400, 'easeOutCubic');
		}
		sym.$("stageMc").animate ({left:345}, 600, 'easeOutCubic');
		clicked=0;
		for (var i=0; i<21; i++){
			if(i==stageBtn_id){
				if (i <8) {
					stagetxt0.text(stagestring[0]+" "+stagestring[i+1]+" - "+datestring[0]+" "+datestring[i+1]);
					stagetxt3.text(txt20+" "+datestring[0]+" "+datestring[i+1]);
				}else{
					stagetxt0.text(stagestring[0]+" "+stagestring[i+1]+" - "+datestring[22]+" "+datestring[i+1]);
					stagetxt3.text(txt20+" "+datestring[22]+" "+datestring[i+1]);
				}
         	stagetxt1.text(tablestring[2]);
         	//sym.getSymbol("stageMc").getSymbol("mapsSliderMc").$("stageMapMc").stop().animate ({left:i*-300}, 900, 'easeOutCubic');
				sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").$("stageProfileMc").stop().animate ({left:i*-495}, 900, 'easeOutCubic');
				todayStage=i;	
         	getClassification(stages[i]);
				}
		}
	}
	function stageBtnShow (e){
         	var stageBtn_id = (e.data.stageBtnId); //get the id of the over button
         	sym.$('handMc').hide();
				sym.getSymbol("routeMc").getSymbol("stageBtn" + stageBtn_id).$("btnOver").fadeIn(0);
	}
	function stageBtnHide (e){
         	var stageBtn_id = (e.data.stageBtnId); //get the id of the out button
				sym.getSymbol("routeMc").getSymbol("stageBtn" + stageBtn_id).$("btnOver").fadeOut(0);
	}

//----------------- TEAM BUTTONS ------------------------
teamBtnArray = []; //the array that will hold references to the buttons.
for (var h = 0; h < 5; h++){
         	 var teamBtnSymbols = sym.getSymbol("teamsMc").getSymbol("teamBtn" +h); // Create an instance element of a symbol as a child of the given parent element
         	 teamBtnSymbols.setVariable("teamBtnId", h); //set the value of a Symbol variable
         	 teamBtnArray.push(teamBtnSymbols); //push it into the array
         }

$.each(teamBtnArray, function( count, teamBtnInTheArray ){ //a 'for each' loop through the newly populated array
         	 var teamBtnItem = $(teamBtnInTheArray); //create jQuery reference to the item
         	 var teamBtnElement = teamBtnInTheArray.getSymbolElement(); //create a jQuery reference to the DIV element inside the symbol
         	 //now you can bind interactivity to the teamBtn items' DIVs
         	 teamBtnElement.bind ("click", {teamBtnId:count}, teamBtnClick);
         	 teamBtnElement.bind ("touchstart", {teamBtnId:count}, teamBtnClick);
         	 teamBtnElement.bind ("mouseover", {teamBtnId:count}, teamBtnShow);
         	 teamBtnElement.bind ("mouseout", {teamBtnId:count}, teamBtnHide);
         	})

	function resetteamBtn(){
		for (var h=0; h<5; h++){
      		teamBtnArray[h].$("btnClick").fadeOut(0);
		teamBtnArray[h].$("btnOver").fadeOut(0);
		}
	}
	resetteamBtn();

	function teamBtnClick (e){
		resetteamBtn(); //set them all back to normal state
		var teamBtn_id = (e.data.teamBtnId); //get the id of the clicked item
		sym.getSymbol("teamsMc").getSymbol("teamBtn" + teamBtn_id).$("btnClick").fadeIn(0);
		teamCount = teamBtn_id; // 
		teamClick();
		}
	function teamBtnShow (e){
         	var teamBtn_id = (e.data.teamBtnId); //get the id of the over button
         	sym.$('handMc').hide();
				sym.getSymbol("teamsMc").getSymbol("teamBtn" + teamBtn_id).$("btnOver").fadeIn(0);
	}
	function teamBtnHide (e){
         	var teamBtn_id = (e.data.teamBtnId); //get the id of the out button
				sym.getSymbol("teamsMc").getSymbol("teamBtn" + teamBtn_id).$("btnOver").fadeOut(0);
	}

// SET COUNTER	
	var panelCal = 0;
	var teamCount = 0;
	var teamPanel = 0;
	var boxCount = 17;
	var teamSlide = -510;

// TEAM UP/DOWN BTNS
	sym.$("downBtn").on('touchstart click', function(e){
	e.stopPropagation(); e.preventDefault();
	sym.$("handMc").fadeOut(0);
	teamPanel++;
	slideClick();
	sym.getSymbol("upBtn").$("btnOver").fadeOut(0);
	});
	Symbol.bindElementAction(compId, symbolName, "${_downBtn}", "mouseover", function(sym, e) {
	sym.getSymbol("downBtn").$("btnOver").fadeIn(200);
	});
	Symbol.bindElementAction(compId, symbolName, "${_downBtn}", "mouseout", function(sym, e) {
	sym.getSymbol("downBtn").$("btnOver").fadeOut(200);
	});

	sym.$("upBtn").on('touchstart click', function(e){
	e.stopPropagation(); e.preventDefault();
	sym.$("handMc").fadeOut(0);
	teamPanel--;
	slideClick();
	sym.getSymbol("downBtn").$("btnOver").fadeOut(0);
	});
	Symbol.bindElementAction(compId, symbolName, "${_upBtn}", "mouseover", function(sym, e) {
	sym.getSymbol("upBtn").$("btnOver").fadeIn(200);
	});
	Symbol.bindElementAction(compId, symbolName, "${_upBtn}", "mouseout", function(sym, e) {
	sym.getSymbol("upBtn").$("btnOver").fadeOut(200);
	});

	function slideClick(){
	resetteamBtn();
	sym.getSymbol("teamsMc").getSymbol("teamsSlider").$("teamsSlideClip").stop().animate ({top:teamPanel*teamSlide}, 600, 'easeOutCubic');
	sym.getSymbol("teamsMc").$("numbersBox").stop().animate ({left:teamPanel*boxCount}, 500, 'easeOutCubic');
	if (teamPanel == 0) {
			panelCal=0;
			sym.$("upBtn").fadeOut(0);
			sym.$("downBtn").fadeIn(0);
	}
	if (teamPanel == 1) {
			panelCal = 5;
			sym.$("upBtn").fadeIn(0);
			sym.$("downBtn").fadeIn(0);
	}
	if (teamPanel == 2) {
			panelCal = 10;
			sym.$("upBtn").fadeIn(0);
			sym.$("downBtn").fadeIn(0);
	}
	if (teamPanel == 3) {
			panelCal = 15;
			sym.$("upBtn").fadeIn(0);
			sym.$("downBtn").fadeIn(0);
	}
	if (teamPanel == 4) {
			panelCal = 20;
			sym.$("upBtn").fadeIn(0);
			sym.$("downBtn").fadeOut(0);
			sym.getSymbol("teamsMc").$("teamBtn2").fadeOut(0);
			sym.getSymbol("teamsMc").$("teamBtn3").fadeOut(0);
			sym.getSymbol("teamsMc").$("teamBtn4").fadeOut(0);
	}else{
			sym.getSymbol("teamsMc").$("teamBtn3").fadeIn(0);
			sym.getSymbol("teamsMc").$("teamBtn4").fadeIn(0);
	}
	}
	slideClick();

// ACTIONS FOR BUTTON CLICKS
	function teamClick(){
		$.ajax({	
         	type: "GET",
         	url: "GN30875.xml",
         	dataType: "xml",
         	success: function(xml) {
				country = $(xml).find('country' + (teamCount+panelCal)).text();
				countrytxt.html(country);
				name = $(xml).find('name' + (teamCount+panelCal)).text();
				nametxt.html(name + country);
				riders = $(xml).find('riders' + (teamCount+panelCal)).text();
				riderstxt.html(riders);
				}
		});
		var team_arr = ["MOV","EUS","ALM","BEL","SKY","KAT","LAM","TST","RLT","CJR","VCD","AST","GRS","OPQ","COF","LTB","BMC","CAN","FDJ","ARG","OGE","TNE"];// HIDE/SHOW TEAM IMAGES + TEXT		
		sym.getSymbol("teamsMc").$("teamJersey").fadeOut(0);
		sym.getSymbol("teamsMc").$("teamJersey").attr('src','teams/'+team_arr[teamCount+panelCal]+'.jpg');
		sym.getSymbol("teamsMc").$("teamJersey").fadeIn(500);
	}
	teamClick();

	// RESET TEAMS
		function resetTeams(){
		panelCal = 0;
		teamCount = 0;
		teamPanel = 0;
		slideClick();
		teamClick();
		sym.getSymbol("teamsMc").getSymbol("teamBtn0").$("btnClick").fadeIn(0);
		sym.getSymbol("downBtn").$("btnOver").fadeOut(0);
		}

//LIVE DATA
function resetPhases(){
	for (var i=0;i<21;i++){
		sym.getSymbol("results").getSymbol("phaseBtn"+i).$("phaseTxt").fadeOut(0);
	}
	sym.getSymbol("results").getSymbol("classificationsBtn").$("tab").css({'background-color':'rgb(206,206,206)'});
	sym.getSymbol("results").getSymbol("classificationsBtn").$("phaseTxt").css({'color':'rgb(100,100,100)'});
}
resetPhases();
var phaseClicker = function(stage,number){ //to handle lexical scope
							return function (e) {
							getPhase(stage);
							for (var i=0;i<21;i++){
								if (i==number){
									sym.getSymbol("results").getSymbol("phaseBtn"+i).$("tab").css({'background-color':'rgb(255,255,255)'});
									sym.getSymbol("results").getSymbol("phaseBtn"+i).$("phaseTxt").css({'color':'rgb(0,0,0)'});
									txt17txt.text(resultstring0[0]+" "+stagestring[i+1]);
								}else{
									sym.getSymbol("results").getSymbol("phaseBtn"+i).$("tab").css({'background-color':'rgb(206,206,206)'});
									sym.getSymbol("results").getSymbol("phaseBtn"+i).$("phaseTxt").css({'color':'rgb(100,100,100)'});
								}
							}
							sym.getSymbol("results").$("leadTeam").fadeIn(0);
							sym.getSymbol("results").getSymbol("classificationsBtn").$("tab").css({'background-color':'rgb(206,206,206)'});
							sym.getSymbol("results").getSymbol("classificationsBtn").$("phaseTxt").css({'color':'rgb(100,100,100)'});
						};
};
var classClicker = function(stage,id){ //to handle lexical scope
							return function (e) {
							getPhase(stage,id);
							sym.getSymbol("results").$("leadTeam").fadeOut(0);
							for (var i=0;i<21;i++){
									sym.getSymbol("results").getSymbol("phaseBtn"+i).$("tab").css({'background-color':'rgb(206,206,206)'});
									sym.getSymbol("results").getSymbol("phaseBtn"+i).$("phaseTxt").css({'color':'rgb(100,100,100)'});								
							}
							for (i=0;i<5;i++){
									if (i==id){
										sym.getSymbol("results").getSymbol("classBtn"+i).$("classTxt").css({'font-weight':700,'color':'rgb(0,0,0)'});
										sym.getSymbol("results").$("classBtn"+i).css({'border':'solid 1px rgb(255,0,0)'});
										txt17txt.text(resultstring0[i+1]);

									}else{
										sym.getSymbol("results").getSymbol("classBtn"+i).$("classTxt").css({'font-weight':400,'color':'rgb(100,100,100)'});
										sym.getSymbol("results").$("classBtn"+i).css({'border':'solid 1px rgb(255,255,255)'});
									}								
							}
							sym.getSymbol("results").getSymbol("classificationsBtn").$("tab").css({'background-color':'rgb(255,255,255)'});
							sym.getSymbol("results").getSymbol("classificationsBtn").$("phaseTxt").css({'color':'rgb(0,0,0)'});
						};
};
//var thisStage;
var classifications=[800977, 896171, 896172, 896173, 896175]; // four more still to come
var dataURL = ('http:'==document.location.protocol?"http://www2.graphicnews.com/":"https://www.graphicnews.org/")+ "infostradasports/api.php";
//GET race stage list data
function getRace(){
	$.ajax({ type: "GET", 
					url: dataURL,
               data: "gn=30875&type=cycling&yr=2013&q=stages",
               contentType: "text/plain", dataType: "jsonp", jsonp: "callback",
               async: true,
               crossDomain: true,
               success: function (data) {
               sym.getSymbol("styleHead").$("menuBtn3").unbind('click');
					sym.getSymbol("results").$("classificationsBtn").unbind();
					for (var c=0;c<5;c++){
					sym.getSymbol("results").$("classBtn"+c).unbind();
					}
for (var i=0; i<21; i++){
	sym.getSymbol("results").$("phaseBtn"+i).unbind();											
	var thisStage=data[i].n_PhaseID;
	if(data[i].b_Finished==true){
		if(data[i].b_Current==true){
			todayStage=i;
		}
		if (data[i].b_Started==true){
			todayStage=i;
			sym.getSymbol("results").$("phaseBtn"+i).click(phaseClicker(thisStage,i)); //bind to stage button
			sym.getSymbol("results").$("phaseBtn"+i).css({'cursor':'pointer'});
			sym.getSymbol("results").getSymbol("phaseBtn"+i).$("phaseTxt").fadeIn(0);
			sym.getSymbol("results").getSymbol("phaseBtn"+i).$("phaseTxt").css({'color':'rgb(100,100,100)'});
		}	
		sym.getSymbol("styleHead").$("menuBtn3").bind ("click", {menuId:3}, menuBtnClick);
		}	
	}
	var latestStage=data[todayStage].n_PhaseID;
	sym.getSymbol("styleHead").$("menuBtn3").bind ("click", getPhase(latestStage));
	if(data[todayStage].n_PointsClassificationID>0){ //if any points have been awarded									
		sym.getSymbol("results").$("classBtn1").click(classClicker(classifications[1],1));							  
	}
	if(data[todayStage].n_MountainClassificationID>0){ //if any mountain points have been awarded
		sym.getSymbol("results").$("classBtn2").click(classClicker(classifications[2],2));	
	}
	if(data[todayStage].n_CombinationClassificationID>0){ //if any combination points have been awarded
		sym.getSymbol("results").$("classBtn3").click(classClicker(classifications[3],3));	
	}
	sym.getSymbol("results").getSymbol("phaseBtn"+todayStage).$("tab").css({'background-color':'rgb(255,255,255)'});
	sym.getSymbol("results").getSymbol("phaseBtn"+todayStage).$("phaseTxt").css({'color':'rgb(0,0,0)'});
	txt17txt.text(resultstring0[0]+" "+stagestring[todayStage+1]);
	sym.getSymbol("routeMc").getSymbol("stageBtn" + todayStage).$("btnClick").fadeIn(0);
	//sym.getSymbol("stageMc").getSymbol("mapsSliderMc").$("stageMapMc").css({'left':todayStage*-300});
	sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").$("stageProfileMc").css({'left':todayStage*-495});
	if (todayStage <2) {
		stagetxt0.text(stagestring[0]+" "+stagestring[todayStage+1]+" - "+datestring[0]+" "+datestring[todayStage+1]);
		stagetxt3.text(txt20+" "+datestring[0]+" "+datestring[todayStage+1]);
	}else{
		stagetxt0.text(stagestring[0]+" "+stagestring[todayStage+1]+" - "+datestring[22]+" "+datestring[todayStage+1]);
		stagetxt3.text(txt20+" "+datestring[22]+" "+datestring[todayStage+1]);
	}
	sym.getSymbol("results").$("classificationsBtn").click(classClicker(classifications[0],0));//bind classification buttons
	sym.getSymbol("results").$("classificationsBtn").css({'cursor':'pointer'});
	sym.getSymbol("results").$("classBtn0").click(classClicker(classifications[0],0));
	//sym.getSymbol("results").$("classBtn3").click(classClicker(classifications[3],3));
	sym.getSymbol("results").$("classBtn4").click(classClicker(classifications[4],4));
	getClassification(800977);								
	}
   });
}
getRace();
intervalId = setInterval(getRace,300000);

function getClassification(stageID){
$.ajax({ type: "GET", 
					url: dataURL,
               data: "gn=30875&yr=2013&stage="+stageID,
               contentType: "text/plain", dataType: "jsonp", jsonp: "callback",
               async: true,
               crossDomain: true,
               success: function (data) {
						var classData = data;
						sym.getSymbol("stageMc").$("graph").empty();					
						for (var i = 0; i < classData.length; i++) {
							//create graph for each rider and for final results
							var tableText ="<div class='race'><div id='riderdata"+i+"'><table style='width:100%; border:none; border-collapse:collapse; padding:0; margin:0'><tr><td id='rank"+i+"' width='30px'></td><td id='rider"+i+"'width='110px'></td><td id='team"+i+"' style='font-style:italic' width='50px'></td><td id='time"+i+"'></td></tr></table></div></div>";
							sym.getSymbol("stageMc").$("graph").append(tableText);
							$('#rank' + i).text(classData[i].c_Rank);
							$('#rider' + i).text(classData[i].c_ParticipantShort);
							$('#team' + i).text(classData[i].c_TeamShort);
							if(classData[i].c_Result!=null){
							$('#time' + i).text(classData[i].c_Result);
							}else{
							$('#time' + i).text("");
							}
						$(".race").css({'font-size':'13px', 'font-family':'pragmatica-web, sans-serif', 'width':'98%'});
						if (i==0){
						$('#rider' + i).css({'font-weight':'bold'});
						}
						if (i%2==0){
								$("#riderdata" + i).css({'background-color':'rgb(213,218,224)','padding-left':'3px', 'border-top':'solid 1px rgb(255,255,255)','border-bottom':'solid 1px rgb(150,150,150)'});
						}else{
								$("#riderdata" + i).css({'background-color':'rgb(239,239,239)','padding-left':'3px', 'border-top':'solid 1px rgb(255,255,255)','border-bottom':'solid 1px rgb(150,150,150)'});							
						}
						$("#team" + i).css({'text-align':'center','background-color':'rgb(255,255,255)'});
						$("#time" + i).css({'text-align':'right', 'padding-right':'5px'});
						}
						},
						error: function(){
						sym.getSymbol("stageMc").$("graph").empty();					
						}
	});
}
function getPhase(stageID,classID){
$.ajax({ type: "GET", 
					url: dataURL,
               data: "gn=30875&yr=2013&stage="+stageID,
               contentType: "text/plain", dataType: "jsonp", jsonp: "callback",
               async: true,
               crossDomain: true,
               success: function (data) {                
						var raceStage = data;
						var scale;
						if (classID==1||classID==2){
							var max = raceStage[0].n_Points;
							var minTime = (max!=null) ? max : 0;
								for (var n=0; n<raceStage.length; n++) {
									if (raceStage[n].n_Points!=null && raceStage[n].n_Points<minTime) {
									minTime = raceStage[n].n_Points;
									}
									if (raceStage[n].n_Points!=null && raceStage[n].n_Points>max) {
									max = raceStage[n].n_Points;									
									}
								}								
						}else if(classID==3){//Combination
							var minTime = raceStage[0].n_Points;
							var max = (minTime!=null) ? minTime : 0;
								for (var n=0; n<raceStage.length; n++) {
									if (raceStage[n].n_Points!=null && raceStage[n].n_Points>max) {
									max = raceStage[n].n_Points;
									}
									if (raceStage[n].n_Points!=null && raceStage[n].n_Points<minTime) {
									minTime = raceStage[n].n_Points;									
									}
								}	
						}else{
							var minTime = raceStage[0].n_TimeAbs;
							var max = (minTime!=null) ? minTime : 0;
								for (var n=0; n<raceStage.length; n++) {
									if (raceStage[n].n_TimeAbs!=null && raceStage[n].n_TimeAbs>max) {
									max = raceStage[n].n_TimeAbs;
									}
									if (raceStage[n].n_TimeAbs!=null && raceStage[n].n_TimeAbs<minTime) {
									minTime = raceStage[n].n_TimeAbs;									
									}
								}						
						}
						sym.getSymbol("results").$("table").empty();
							for (var i = 0; i < raceStage.length; i++) {
								var stageText ="<div class='stg'><div id='stgdata"+i+"'><table style='width:100%; border:none; border-collapse:collapse; padding:0; margin:0'><tr><td id='stgrank"+i+"' width='35px'></td><td id='stgrider"+i+"' width='180px'></td><td id='stgflag"+i+"' width='30px'></td><td id='stgteam"+i+"' style='font-style:italic' width='50px'></td><td id='stgtime"+i+"'></td></tr></table></div></div>";
								if (classID==1||classID==2){								
									if (max==minTime && raceStage[i].n_Points==max) {
										scale=100;
									}else if(raceStage[i].n_Points==null){
										scale=59;
									}else{
										scale = 59+((raceStage[i].n_Points-minTime)*41/(max-minTime));
									}
								}else if(classID==3){//Combination
									if (minTime==max && raceStage[i].n_Points==minTime) {
										scale=100;
									}else if(raceStage[i].n_Points==null){
										scale=59;
									}else{
										scale = 100-((raceStage[i].n_Points-minTime)*41/(max-minTime));
									}								
								}else{
								if (minTime==max && raceStage[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
										scale=100;
									}else if(raceStage[i].n_TimeAbs==null){
										scale=59;
									}else{
										scale = 100-((raceStage[i].n_TimeAbs-minTime)*41/(max-minTime));
									}
								}
								sym.getSymbol("results").$("table").append(stageText);
								$('#stgrank' + i).text(raceStage[i].c_Rank);
								$('#stgrider' + i).text(raceStage[i].c_Participant);
								$('#stgteam' + i).text(raceStage[i].c_TeamShort);
								$('#stgflag' + i).text(raceStage[i].c_NOCShort);
								if(raceStage[i].c_Result!=null){
									$('#stgtime' + i).text(raceStage[i].c_Result);
								}else{
									$('#stgtime' + i).text("");
								}
								$(".stg").css({'font-size':'13px', 'font-family':'pragmatica-web, sans-serif', 'width':'99%'});
								if (i==0){
									$('#stgrider' + i).css({'font-weight':'bold'});
								}
								if (i%2==0){
									$("#stgdata" + i).css({'width':scale+'%','background-color':'rgb(213,218,224)','padding-left':'3px', 'border-top':'solid 1px rgb(255,255,255)','border-bottom':'solid 1px rgb(150,150,150)'});
								}else{
									$("#stgdata" + i).css({'width':scale+'%','background-color':'rgb(239,239,239)','padding-left':'3px', 'border-top':'solid 1px rgb(255,255,255)','border-bottom':'solid 1px rgb(150,150,150)'});							
								}
								$("#stgteam" + i).css({'text-align':'center','background-color':'rgb(255,255,255)'});
								$("#stgtime" + i).css({'text-align':'right', 'padding-right':'5px'});

						}
						var leadTeamShort=raceStage[0].c_TeamShort;
						var leadTeam=raceStage[0].c_Team;
						sym.getSymbol("results").getSymbol("leadTeam").$("leadJersey").attr('src','teams/'+leadTeamShort+'.jpg');
						sym.getSymbol("results").getSymbol("leadTeam").$("leadTeamTxt").text(leadTeam);
               }
			});
}

//LEFT RIGHT STAGE BUTTONS
function changeStage(){
		//stagetxt0.text(stagestring[0]+" "+stagestring[todayStage+1]+" - "+datestring[0]+" "+datestring[todayStage+1]);
		if (todayStage <8) {
			stagetxt0.text(stagestring[0]+" "+stagestring[todayStage+1]+" - "+datestring[0]+" "+datestring[todayStage+1]);
			stagetxt3.text(txt20+" "+datestring[0]+" "+datestring[todayStage+1]);
		}else{
			stagetxt0.text(stagestring[0]+" "+stagestring[todayStage+1]+" - "+datestring[22]+" "+datestring[todayStage+1]);
			stagetxt3.text(txt20+" "+datestring[22]+" "+datestring[todayStage+1]);
		}
      stagetxt1.text(tablestring[2]);
      resetstageBtn();
		sym.getSymbol("routeMc").getSymbol("stageBtn" + (todayStage)).$("btnClick").fadeIn(0);
      //sym.getSymbol("stageMc").getSymbol("mapsSliderMc").$("stageMapMc").stop().animate ({left:todayStage*-300}, 900, 'easeOutCubic');
		sym.getSymbol("stageMc").getSymbol("profileSliderMc").getSymbol("profileClipMc").$("stageProfileMc").stop().animate ({left:todayStage*-495}, 900, 'easeOutCubic');
		setTimeout(function() { getClassification(stages[todayStage]); }, 2000);

}
sym.getSymbol("stageMc").$("stageRight").on('click', function(e){
	e.stopPropagation(); e.preventDefault();
		if (todayStage<20){
		todayStage++;
		changeStage();
      }
	});
sym.getSymbol("stageMc").$("stageRight").mouseover(function(){
	sym.getSymbol("stageMc").getSymbol("stageRight").$("btnOver").fadeIn(0);
	});
sym.getSymbol("stageMc").$("stageRight").mouseout(function(){
	sym.getSymbol("stageMc").getSymbol("stageRight").$("btnOver").fadeOut(0);
	});	
sym.getSymbol("stageMc").$("stageLeft").on('click', function(e){
	e.stopPropagation(); e.preventDefault();
		if (todayStage>0){		
			todayStage--;
			changeStage();
			}
		});
sym.getSymbol("stageMc").$("stageLeft").mouseover(function(){
	sym.getSymbol("stageMc").getSymbol("stageLeft").$("btnOver").fadeIn(0);
	});
sym.getSymbol("stageMc").$("stageLeft").mouseout(function(){
	sym.getSymbol("stageMc").getSymbol("stageLeft").$("btnOver").fadeOut(0);
	});
sym.getSymbol("stageMc").getSymbol("stageLeft").$("btnOver").fadeOut(0);
sym.getSymbol("stageMc").getSymbol("stageRight").$("btnOver").fadeOut(0);

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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