/***********************
* 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.$("txt0").css({"pointer-events":"none",});
	txt[1] = sym.$("txt1").css({"pointer-events":"none"});
	txt[2] = sym.$("txt2").css({"pointer-events":"none"});
	txt[3] = sym.$("txt3").css({"pointer-events":"none"});
	txt[4] = sym.$("txt4").css({"pointer-events":"none"});
	txt[5] = sym.getSymbol("pixelMc").$("txt5").css({"pointer-events":"none"});
	txt[6] = sym.getSymbol("pixelMc").$("txt6").css({"pointer-events":"none","background-color":"rgba(255,255,255,1)"});
	txt[7] = sym.getSymbol("pixelMc").$("txt7").css({"pointer-events":"none"});
	txt[8] = sym.getSymbol("pixelMc").$("txt8").css({"pointer-events":"none","background-color":"rgba(255,255,255,1)"});
	txt[9] = sym.getSymbol("pixelMc").$("txt9").css({"pointer-events":"none","background-color":"rgba(255,255,255,1)"});
	txt[10] = sym.$("txt10").css({"pointer-events":"none"});
	txt[11] = sym.getSymbol("pointMc").$("txt11").css({"pointer-events":"none"});
	txt[12] = sym.getSymbol("pointMc").$("txt12").css({"pointer-events":"none"});
	txt[13] = sym.getSymbol("pointMc").$("txt13").css({"pointer-events":"none"});
	txt[14] = sym.getSymbol("pointMc").$("txt14").css({"pointer-events":"none"});
	txt[15] = sym.getSymbol("pointMc").$("txt15").css({"pointer-events":"none"});
	txt[16] = sym.getSymbol("pointMc").$("txt16").css({"pointer-events":"none"});
	txt[17] = sym.getSymbol("pointMc").$("txt17").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: "GN31960.xml",
		dataType: "xml",
		success: function(xml) {
			custonCol = $(xml).find('customColour').text();
			sym.getSymbol("styleHead").$("headerBox").css("background-color",custonCol);
			headline = $(xml).find('headline').text();
			headlinetxt.html(headline);
			stand = $(xml).find('stand').text();
			standtxt.html(stand);
			source = $(xml).find('source').text();
			sourcetxt.html(source);
	
			//create array from xml, put it into array of text elements
			for (var i=0; i<18; i++){
			txtArr[i]=$(xml).find('txt'+i).text();
			txt[i].html(txtArr[i]);
			}
	
			sym.$("txt0").animate({top:208 - sym.$("txt0").height()+10},0);
			sym.$("txt3").animate({top:524 - sym.$("txt3").height()/2},0);
			sym.$("pixelMc").animate({top:46 + sym.$("txt4").height()+15},0);
			sym.$("txt10").animate({top:398 - sym.$("txt10").height()+0},0);
			sym.getSymbol("pointMc").$("txt11").animate({top:105 - sym.getSymbol("pointMc").$("txt11").height()+0},0);
			sym.getSymbol("pointMc").$("txt12").animate({top:198 - sym.getSymbol("pointMc").$("txt12").height()+0},0);
	
		}
	}); // END XML
	
	sym.$("pointMc").stop().animate ({opacity:0}, 0);
	
	// BUTTONS COUNT
	var watchView = 0;
	sym.$("btnRnd").on('touchstart click', function(e){
	e.stopPropagation(); e.preventDefault();
	if (watchView == 0){
		sym.getSymbol("btnRnd").$("btnArrow").stop().animate({ rotate:90}, {
			step: function(now,fx) {
			$(this).css('-webkit-transform','rotate('+now+'deg)'); 
			$(this).css('-moz-transform','rotate('+now+'deg)');
			$(this).css('transform','rotate('+now+'deg)');
			},duration:'slow', easing:'easeOutCubic'});
		sym.$("topLayer").stop().animate ({opacity:0}, 100);
		sym.$("txt4").stop().animate ({opacity:0}, 500);
		sym.$("pixelMc").stop().animate ({opacity:0}, 500);
		sym.$("txt10").stop().animate ({opacity:0}, 500);
		sym.$("finger").stop().animate ({left:805}, 1000);
		sym.$("txt3").stop().animate ({opacity:0}, 500);
		sym.$("apple").stop().animate ({opacity:0}, 500);
		sym.$("pan6").stop().animate ({top:78}, 500, 'easeOutCubic');
		sym.$("pan5").stop().animate ({top:166}, 500, 'easeOutCubic');
		sym.$("pan4").stop().animate ({top:260}, 500, 'easeOutCubic');
		sym.$("pan3").stop().animate ({top:313}, 500, 'easeOutCubic');
		sym.$("pan2").stop().animate ({top:376}, 500, 'easeOutCubic', function(){
			sym.$("pointMc").stop().animate ({opacity:1}, 300);
		});
		watchView = 1;
	}else{
		sym.getSymbol("btnRnd").$("btnArrow").stop().animate({ rotate:-90}, {
			step: function(now,fx) {
			$(this).css('-webkit-transform','rotate('+now+'deg)'); 
			$(this).css('-moz-transform','rotate('+now+'deg)');
			$(this).css('transform','rotate('+now+'deg)');
			},duration:'slow', easing:'easeOutCubic'});
		sym.$("pointMc").stop().animate ({opacity:0}, 100);
		sym.$("txt4").stop().animate ({opacity:1}, 500);
		sym.$("pixelMc").stop().animate ({opacity:1}, 500);
		sym.$("txt10").stop().animate ({opacity:1}, 500);
		sym.$("txt3").stop().animate ({opacity:1}, 500);
		sym.$("apple").stop().animate ({opacity:1}, 500);
		sym.$("pan6").stop().animate ({top:416}, 500, 'easeOutCubic');
		sym.$("pan5").stop().animate ({top:414}, 500, 'easeOutCubic');
		sym.$("pan4").stop().animate ({top:414}, 500, 'easeOutCubic');
		sym.$("pan3").stop().animate ({top:414}, 500, 'easeOutCubic');
		sym.$("pan2").stop().animate ({top:414}, 350, 'easeOutCubic', function(){
	
			sym.$("topLayer").stop().animate ({opacity:1}, 0);
			sym.$("finger").stop().animate ({left:519}, 500);
		});
		watchView = 0;
	}
	});
	sym.$("btnRnd").mouseover(function(){
		sym.getSymbol("btnRnd").$("btnOut").fadeOut(200);
	});
	sym.$("btnRnd").mouseout(function(){
		sym.getSymbol("btnRnd").$("btnOut").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: 'btnRnd'
   (function(symbolName) {   
   
   })("btnRnd");
   //Edge symbol end:'btnRnd'

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

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

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