/***********************
* 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("styleHead").$("headlineTxt").css("pointer-events","none");
	var stand;
	var standtxt = sym.getSymbol("styleHead").$("standTxt").css("pointer-events","none");
	var source;
	var sourcetxt = sym.getSymbol("styleBase").$("sourceTxt").css("pointer-events","none");
	
	var txt=[];
	txt[0] = sym.getSymbol("carPointMc").$("txt0").css("pointer-events","none");
	txt[1] = sym.getSymbol("carPointMc").$("txt1").css("pointer-events","none");
	txt[2] = sym.getSymbol("carPointMc").$("txt2").css("pointer-events","none");
	txt[3] = sym.getSymbol("carPointMc").$("txt3").css("pointer-events","none");
	txt[4] = sym.getSymbol("carPointMc").$("txt4").css("pointer-events","none");
	txt[5] = sym.getSymbol("carPointMc").$("txt5").css("pointer-events","none");
	txt[6] = sym.getSymbol("carPointMc").$("txt6").css("pointer-events","none");
	txt[7] = sym.getSymbol("carPointMc").$("txt7").css("pointer-events","none");
	txt[8] = sym.getSymbol("carPointMc").$("txt8").css("pointer-events","none");
	txt[9] = sym.getSymbol("carPointMc").$("txt9").css("pointer-events","none");
	txt[10] = sym.getSymbol("engineMc").$("txt10").css({"border-width":"1px","border-style":"solid","border-color":"rgba(0,0,0,1)","background-color":"rgba(27,121,184,1)","border-radius":"5px","padding":"5px"});
	txt[11] = sym.getSymbol("engineMc").$("txt11").css("pointer-events","none");
	txt[12] = sym.getSymbol("engineMc").$("txt12").css("pointer-events","none");
	txt[13] = sym.getSymbol("engineMc").$("txt13").css("pointer-events","none");
	txt[14] = sym.getSymbol("engineMc").$("txt14").css("pointer-events","none");
	txt[15] = sym.getSymbol("engineMc").$("txt15").css({"border-width":"1px","border-style":"solid","border-color":"rgba(0,0,0,1)","background-color":"rgba(247,172,0,1)","border-radius":"10px","padding":"5px"});
	txt[16] = sym.getSymbol("engineMc").$("txt16").css("pointer-events","none");
	txt[17] = sym.getSymbol("engineMc").$("txt17").css("pointer-events","none");
	txt[18] = sym.getSymbol("engineMc").$("txt18").css("pointer-events","none");
	txt[19] = sym.getSymbol("engineMc").$("txt19").css("pointer-events","none");
	txt[20] = sym.getSymbol("engineMc").$("txt20").css("pointer-events","none");
	var txtArr=[];
	
	//AJAX retrieves data from xml source specified in url, maps xml variable to DOM object variable
	$.ajax({	
		type: "GET",
		url: "GN31494.xml",
		dataType: "xml",
		success: function(xml) {
			headline = $(xml).find('headline').text();
			headlinetxt.html(headline);
			stand = $(xml).find('stand').text();
			standtxt.html(stand);
			source = $(xml).find('source').text();
			sourcetxt.html(source);
	
			//create array from xml, put it into array of text elements
			for (var i=0; i<21; i++){
			txtArr[i]=$(xml).find('txt'+i).text();
			txt[i].html(txtArr[i]);
			}
			sym.getSymbol("carPointMc").$("txt0").animate({top:118 - sym.getSymbol("carPointMc").$("txt0").height()+10}, 0);
			sym.getSymbol("carPointMc").$("txt1").animate({top:178 - sym.getSymbol("carPointMc").$("txt1").height()+10}, 0);
			sym.getSymbol("carPointMc").$("txt2").animate({top:246 - sym.getSymbol("carPointMc").$("txt2").height()+10}, 0);
			sym.getSymbol("carPointMc").$("txt9").animate({top:102 - sym.getSymbol("carPointMc").$("txt9").height()+10}, 0);
			sym.getSymbol("engineMc").$("txt15").animate({left:340 - sym.getSymbol("engineMc").$("txt15").width()/2}, 0);
		}
	}); // END XML
	
	sym.$("carMc").animate ({left:775, top:-188}, 0);
	sym.$("carMc").stop().delay(500).animate ({opacity:1, left:75, top:106}, 3000, 'easeOutCubic');
	sym.$("trackMc").stop().animate ({opacity:1}, 1500);
	sym.$("windMc").stop().delay(3500).animate ({opacity:1}, 1500);
	sym.$("carPointMc").stop().delay(3500).animate ({opacity:1}, 1500);
	sym.$("btn").delay(4500).animate ({left:530}, 0);
	
	
	var carView = 1;
	
	function engineClick(){
		if (carView==0) {
			sym.$("engine").stop().animate ({opacity:0}, 500);
			sym.$("btn").animate ({left:800}, 0);
			sym.getSymbol("btn").$("btnPlus").fadeIn(0);
			sym.$("engineMc").stop().animate ({opacity:0}, 0);
			sym.$("carMc").animate ({left:775, top:-188}, 0);
			sym.$("carMc").stop().delay(500).animate ({opacity:1, left:75, top:106}, 3000, 'easeOutCubic');
			sym.$("trackMc").stop().animate ({opacity:1}, 1500);
			sym.$("windMc").stop().delay(3500).animate ({opacity:1}, 1500);
			sym.$("carPointMc").stop().delay(3500).animate ({opacity:1}, 1500);
			sym.$("btn").delay(3500).animate ({left:535}, 0);
			carView = 1;
		}else{
			sym.$("engine").stop().animate ({opacity:1, left:460, top:187, width:143, height:143}, 0);
			sym.$("engine").stop().animate ({opacity:1, left:190, top:90, width:493, height:493}, 1000, 'easeOutCubic');
			sym.$("btn").animate ({left:800}, 0);
			sym.getSymbol("btn").$("btnPlus").fadeOut(0);
			sym.$("engineMc").stop().delay(1000).animate ({opacity:1}, 1000);
			sym.$("carMc").animate ({left:-653, top:461}, 1000, 'easeInCubic');
			sym.$("trackMc").stop().animate ({opacity:0}, 1000);
			sym.$("windMc").stop().animate ({opacity:0}, 200);
			sym.$("carPointMc").stop().animate ({opacity:0}, 0);
			sym.$("btn").delay(1000).animate ({left:535}, 0);
			carView = 0;
	}
	}
	
// BUTTON
	sym.$("btn").on('touchstart click', function(e){
	e.stopPropagation(); e.preventDefault();
		engineClick();
	});
	sym.$("btn").mouseover(function(){
		sym.getSymbol("btn").$("btnOver").fadeOut(200);
	});
	sym.$("btn").mouseout(function(){
		sym.getSymbol("btn").$("btnOver").fadeIn(200);
	});


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


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

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

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

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

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

   //=========================================================
   
   //Edge symbol: 'wheelMc'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 75, function(sym, e) {
         // play the timeline from the given position (ms or label)
         sym.play(0);

      });
      //Edge binding end

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

   //=========================================================
   
   //Edge symbol: 'Symbol_1'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 364, function(sym, e) {
         // play the timeline from the given position (ms or label)
         sym.play(1);

      });
      //Edge binding end

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

   //=========================================================
   
   //Edge symbol: 'wheelMc_1'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 75, function(sym, e) {
         // play the timeline from the given position (ms or label)
         sym.play(0);

      });
      //Edge binding end

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

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

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

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

   //=========================================================
   
   //Edge symbol: 'roadMc'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 1500, function(sym, e) {
         // play the timeline from the given position (ms or label)
         sym.play(0);

      });
      //Edge binding end

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

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

   //=========================================================
   
   //Edge symbol: 'windMc'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 2727, function(sym, e) {
         // play the timeline from the given position (ms or label)
         sym.play(2273);

      });
      //Edge binding end

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

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

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

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

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