/***********************
* 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");
	
	//create array of text elements
	var txt=[];
	txt[0] = sym.$("txt0").css("pointer-events","none");
	txt[1] = sym.$("txt1").css("pointer-events","none");
	txt[2] = sym.$("txt2").css("pointer-events","none");
	txt[3] = sym.getSymbol("breakApart").getSymbol("sizeMc").$("txt3").css("pointer-events","none");
	txt[4] = sym.getSymbol("breakApart").getSymbol("sizeMc").$("txt4").css("pointer-events","none");
	txt[5] = sym.getSymbol("breakApart").getSymbol("sizeMc").$("txt5").css("pointer-events","none");
	txt[6] = sym.getSymbol("breakApart").getSymbol("breakPointMc").$("txt6").css("pointer-events","none");
	txt[7] = sym.getSymbol("breakApart").getSymbol("breakPointMc").$("txt7").css("pointer-events","none");
	txt[8] = sym.getSymbol("breakApart").getSymbol("breakPointMc").$("txt8").css("pointer-events","none");
	txt[9] = sym.getSymbol("breakApart").getSymbol("breakPointMc").$("txt9").css("pointer-events","none");
	txt[10] = sym.getSymbol("breakApart").getSymbol("breakPointMc").$("txt10").css("pointer-events","none");
	txt[11] = sym.getSymbol("breakApart").getSymbol("breakPointMc").$("txt11").css("pointer-events","none");
	txt[12] = sym.getSymbol("breakApart").getSymbol("breakPointMc").$("txt12").css("pointer-events","none");
	txt[13] = sym.getSymbol("breakApart").getSymbol("breakPointMc").$("txt13").css("pointer-events","none");
	txt[14] = sym.getSymbol("breakApart").getSymbol("breakPointMc").$("txt14").css("pointer-events","none");
	txt[15] = sym.getSymbol("breakApart").getSymbol("breakPointMc").$("txt15").css("pointer-events","none");
	txt[16] = sym.getSymbol("breakApart").getSymbol("breakPointMc").$("txt16").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: "GN31441.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<17; i++){
			txtArr[i]=$(xml).find('txt'+i).text();
			txt[i].html(txtArr[i]);
			}
			//sym.getSymbol("SYMBOL").$("txt").animate({top:yNUMBER - sym.getSymbol("SYMBOL").$("txt").height()+10}, 200);
		}
	}); // END XML
	
	
	// BUTTONS COUNT
	sym.$("plusBtn").on('touchstart click', function(e){
		e.stopPropagation(); e.preventDefault();
		btnClick();
	});
	sym.$("plusBtn").mouseover(function(){
		sym.getSymbol("plusBtn").$("btnRoundRed").fadeOut(200);
	});
	sym.$("plusBtn").mouseout(function(){
		sym.getSymbol("plusBtn").$("btnRoundRed").fadeIn(200);
	});
	
	var clicked = 0;	
	function btnClick() {
		if (clicked == 0) {
			sym.getSymbol("plusBtn").$("plus").fadeOut(200);
			sym.$("flashBtn").fadeOut(200);
			sym.getSymbol("breakApart").play();
			clicked = 1;
			flash = 1;
			flashClick();
		}else{
			var duration=sym.getSymbol("breakApart").getDuration();
			if(duration>500){
				sym.getSymbol("breakApart").playReverse(500);
			}else{
				sym.getSymbol("breakApart").playReverse();
			}
			sym.$("flashBtn").delay(1000).fadeIn(200);
			sym.getSymbol("plusBtn").$("plus").delay(1000).fadeIn(200);
			clicked = 0;
		}
	}
	
	// BUTTONS COUNT
	sym.$("flashBtn").on('touchstart click', function(e){
		e.stopPropagation(); e.preventDefault();
		flashClick();
	});
	sym.$("flashBtn").mouseover(function(){
		sym.getSymbol("flashBtn").$("btnRoundRed").fadeOut(200);
	});
	sym.$("flashBtn").mouseout(function(){
		sym.getSymbol("flashBtn").$("btnRoundRed").fadeIn(200);
	});
	
	var flash = 0;	
	function flashClick() {
		if (flash == 0) {
			sym.getSymbol("flashBtn").$("plus").fadeOut(200);
			sym.getSymbol("breakApart").getSymbol("lightsMc0").play(1);
			sym.getSymbol("breakApart").getSymbol("lightsMc1").play(1);
			sym.getSymbol("breakApart").getSymbol("lightsMc2").play(1);
			flash = 1;
		}else{
			sym.getSymbol("flashBtn").$("plus").fadeIn(200);
			sym.getSymbol("breakApart").getSymbol("lightsMc0").stop(0);
			sym.getSymbol("breakApart").getSymbol("lightsMc1").stop(0);
			sym.getSymbol("breakApart").getSymbol("lightsMc2").stop(0);
			flash = 0;
		}
	}
	
	//REPLAY BUTTON
	//sym.$("replayBtn").fadeOut(0);
	sym.$("replayBtn").delay(14500).fadeIn(500);
	sym.getSymbol("replayBtn").$("btnRoundRed").delay(15000).fadeIn(0);
	sym.$("replayBtn").on('touchstart click', function(e){
		e.stopPropagation(); e.preventDefault();
		sym.getSymbol("replayBtn").$("btnRoundRed").fadeOut(200);
		sym.getSymbol("pillPath").play();
		sym.getSymbol("replayBtn").$("btnRoundRed").delay(7500).fadeIn(200);
	});
	sym.$("replayBtn").mouseover(function(){
		sym.getSymbol("replayBtn").$("btnRoundRed").fadeOut(200);
	});
	sym.$("replayBtn").mouseout(function(){
		sym.getSymbol("replayBtn").$("btnRoundRed").fadeIn(200);
	});
	
	

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


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

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

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

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

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

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

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

   //=========================================================
   
   //Edge symbol: 'lightsMc'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 388, function(sym, e) {
         sym.play(110);

      });
      //Edge binding end

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

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

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

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

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

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

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