/***********************
* 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", "box-shadow":"5px 5px 5px rgba(0,0,0,0.3)", "border-width":"1px","border-style":"solid","border-color":"rgba(255,255,255,1)", "border-radius":"5px", "background-color":"rgba(0,125,196,1)"});
	txt[1] = sym.getSymbol("topMc").getSymbol("topPointMc").$("txt1").css({"pointer-events":"none"});
	txt[2] = sym.getSymbol("topMc").getSymbol("topPointMc").$("txt2").css({"pointer-events":"none"});
	txt[3] = sym.getSymbol("topMc").getSymbol("topPointMc").$("txt3").css({"pointer-events":"none"});
	txt[4] = sym.getSymbol("topMc").getSymbol("topPointMc").$("txt4").css({"pointer-events":"none"});
	txt[5] = sym.getSymbol("moduleMc").getSymbol("modulePointMc").$("txt5").css({"pointer-events":"none"});
	txt[6] = sym.getSymbol("moduleMc").getSymbol("modulePointMc").$("txt6").css({"pointer-events":"none"});
	txt[7] = sym.getSymbol("moduleMc").getSymbol("modulePointMc").$("txt7").css({"pointer-events":"none"});
	txt[8] = sym.getSymbol("moduleMc").getSymbol("modulePointMc").$("txt8").css({"pointer-events":"none"});
	txt[9] = sym.getSymbol("moduleMc").getSymbol("modulePointMc").$("txt9").css({"pointer-events":"none"});
	txt[10] = sym.$("txt10").css({"pointer-events":"none"});    
	txt[11] = sym.getSymbol("rearPointMc").$("txt11").css({"pointer-events":"none"});
	txt[12] = sym.getSymbol("rearPointMc").$("txt12").css({"pointer-events":"none"});
	txt[13] = sym.getSymbol("rearPointMc").$("txt13").css({"pointer-events":"none"});
	txt[14] = sym.getSymbol("rearPointMc").$("txt14").css({"pointer-events":"none"});
	txt[15] = sym.$("txt15").css({"pointer-events":"none", "box-shadow":"5px 5px 5px rgba(0,0,0,0.3)", "border-width":"1px","border-style":"solid","border-color":"rgba(255,255,255,1)", "border-radius":"5px", "background-color":"rgba(0,125,196,1)"});
	txt[16] = sym.getSymbol("rearPointMc").$("txt16").css({"pointer-events":"none"});
	txt[17] = sym.getSymbol("rearPointMc").$("txt17").css({"pointer-events":"none"});
	txt[18] = sym.getSymbol("rearPointMc").$("txt18").css({"pointer-events":"none"});
	txt[19] = sym.getSymbol("rearPointMc").$("txt19").css({"pointer-events":"none"});
	txt[20] = sym.$("txt20").css({"pointer-events":"none"});
	txt[21] = sym.$("txt21").css({"pointer-events":"none"});
	txt[22] = sym.$("txt22").css({"pointer-events":"none"});
	txt[23] = sym.$("txt23").css({"pointer-events":"none"});
	txt[24] = sym.getSymbol("topMc").getSymbol("topPointMc").$("txt24").css({"pointer-events":"none"});
	txt[25] = sym.$("txt25").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: "GN32145.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);
	
			for (var i=0; i<26; i++){
			txtArr[i]=$(xml).find('txt'+i).text();
			txt[i].html(txtArr[i]);
			}
	
			sym.$("txt0").animate({left:119 - sym.$("txt0").width()+0}, 0);
			sym.$("txt15").animate({left:767 - sym.$("txt15").width()+0}, 0);
			sym.getSymbol("rearMc").$("phoneRearShadowOpen").stop().fadeOut(0);
	
		}
	}); // END XML
	
	sym.getSymbol("topMc").$("topPointMc").fadeOut(0);
	sym.$("rearPointMc").fadeOut(0);
	sym.$("moduleMc").stop().animate ({opacity:0}, 0);
	sym.getSymbol("topMc").$("top0").stop().delay(200).animate ({left:71, top:147}, speed, 'easeOutCubic');
		sym.getSymbol("topMc").$("top1").stop().delay(200).animate ({left:47, top:92}, speed, 'easeOutCubic');
		sym.getSymbol("topMc").$("top2").stop().delay(200).animate ({left:29, top:34}, speed, 'easeOutCubic');
		sym.getSymbol("topMc").$("top3").stop().delay(200).animate ({left:28, top:20}, speed, 'easeOutCubic');
		sym.getSymbol("topMc").$("top4").stop().delay(200).animate ({left:30, top:5}, speed, 'easeOutCubic');
		sym.getSymbol("topMc").$("top5").stop().delay(200).animate ({left:29, top:34}, speed, 'easeOutCubic');
		sym.getSymbol("topMc").$("top6").stop().delay(200).animate ({left:11, top:-12}, speed, 'easeOutCubic');
		sym.getSymbol("topMc").$("top7").stop().delay(200).animate ({left:71, top:147}, speed, 'easeOutCubic', function(){ 
			sym.getSymbol("topMc").$("topPointMc").stop().fadeIn(300); 
		});
	
	var clicked = 1;
	var speed = 500;
	
	function topOpen(){	
	if (clicked == 0){
	// MODULE CLOSE
		sym.getSymbol("swapBtn").$("btnPlus").stop().fadeIn(200);
		sym.getSymbol("moduleMc").$("modulePointMc").stop().delay(0).animate ({opacity:0}, 100);
		sym.getSymbol("moduleMc").$("module1").stop().delay(0).animate ({left:0, top:0}, speed, 'easeOutCubic');
		sym.getSymbol("moduleMc").$("module3").stop().delay(0).animate ({left:0, top:0}, speed, 'easeOutCubic');
		sym.getSymbol("moduleMc").$("module4").stop().delay(0).animate ({left:0, top:0}, speed, 'easeOutCubic');
		sym.getSymbol("moduleMc").$("module5").stop().delay(0).animate ({left:0, top:0}, speed, 'easeOutCubic', function(){
			sym.$("moduleMc").stop().delay(0).animate ({opacity:0}, 0);
			sym.getSymbol("rearMc").$("phoneRearShadowOpen").stop().fadeOut(300);
			sym.getSymbol("rearMc").$("rear4").stop().fadeIn(0);
			// TOP OPEN
			sym.getSymbol("topMc").$("top0").stop().delay(0).animate ({left:71, top:147}, speed, 'easeOutCubic');
			sym.getSymbol("topMc").$("top1").stop().delay(0).animate ({left:47, top:92}, speed, 'easeOutCubic');
			sym.getSymbol("topMc").$("top2").stop().delay(0).animate ({left:29, top:34}, speed, 'easeOutCubic');
			sym.getSymbol("topMc").$("top3").stop().delay(0).animate ({left:28, top:20}, speed, 'easeOutCubic');
			sym.getSymbol("topMc").$("top4").stop().delay(0).animate ({left:30, top:5}, speed, 'easeOutCubic');
			sym.getSymbol("topMc").$("top5").stop().delay(0).animate ({left:29, top:34}, speed, 'easeOutCubic');
			sym.getSymbol("topMc").$("top6").stop().delay(0).animate ({left:11, top:-12}, speed, 'easeOutCubic');
			sym.getSymbol("topMc").$("top7").stop().delay(0).animate ({left:71, top:147}, speed, 'easeOutCubic', function(){ 
				sym.getSymbol("topMc").$("topPointMc").stop().fadeIn(300); 
			});
			// REAR CLOSE
			sym.$("rearPointMc").stop().fadeOut(300);
			sym.getSymbol("rearMc").$("rear1").stop().delay(0).animate ({left:72, top:3}, speed, 'easeOutCubic');
			sym.getSymbol("rearMc").$("rear2").stop().delay(60).animate ({left:37, top:100}, speed, 'easeOutCubic');
			sym.getSymbol("rearMc").$("rear3").stop().delay(100).animate ({left:18, top:198}, speed, 'easeOutCubic');
			sym.getSymbol("rearMc").$("rear4").stop().delay(150).animate ({left:0, top:247, width:71, height:59}, speed, 'easeOutCubic');
			sym.getSymbol("rearMc").$("rear5").stop().delay(0).animate ({left:143, top:3}, speed, 'easeOutCubic');
			sym.getSymbol("rearMc").$("rear6").stop().delay(60).animate ({left:107, top:52}, speed, 'easeOutCubic');
			sym.getSymbol("rearMc").$("rear7").stop().delay(100).animate ({left:72, top:150}, speed, 'easeOutCubic');
			sym.getSymbol("rearMc").$("rear8").stop().delay(150).animate ({left:55, top:248}, speed, 'easeOutCubic');
		});
		clicked = 1;
	}else{
		// TOP CLOSE
		sym.getSymbol("swapBtn").$("btnPlus").stop().fadeOut(200);
		sym.getSymbol("topMc").$("topPointMc").fadeOut(50);
		sym.getSymbol("topMc").$("top0").stop().delay(0).animate ({left:0, top:0}, speed, 'easeOutCubic');
		sym.getSymbol("topMc").$("top1").stop().delay(0).animate ({left:0, top:0}, speed, 'easeOutCubic');
		sym.getSymbol("topMc").$("top2").stop().delay(0).animate ({left:0, top:0}, speed, 'easeOutCubic');
		sym.getSymbol("topMc").$("top3").stop().delay(0).animate ({left:0, top:0}, speed, 'easeOutCubic');
		sym.getSymbol("topMc").$("top4").stop().delay(0).animate ({left:0, top:0}, speed, 'easeOutCubic');
		sym.getSymbol("topMc").$("top5").stop().delay(0).animate ({left:0, top:0}, speed, 'easeOutCubic');
		sym.getSymbol("topMc").$("top6").stop().delay(0).animate ({left:0, top:0}, speed, 'easeOutCubic');
		sym.getSymbol("topMc").$("top7").stop().delay(0).animate ({left:0, top:0}, speed, 'easeOutCubic');
		// REAR OPEN
		sym.getSymbol("rearMc").$("phoneRearShadowOpen").stop().delay(350).fadeIn(1000);
		sym.getSymbol("rearMc").$("rear1").stop().delay(0).animate ({left:65, top:3}, speed, 'easeOutCubic');
		sym.getSymbol("rearMc").$("rear2").stop().delay(60).animate ({left:2, top:100}, speed, 'easeOutCubic');
		sym.getSymbol("rearMc").$("rear3").stop().delay(100).animate ({left:-27, top:198}, speed, 'easeOutCubic');
		sym.getSymbol("rearMc").$("rear4").stop().delay(150).animate ({left:-131, top:240, width:81, height:64}, speed, 'easeOutCubic');
		sym.getSymbol("rearMc").$("rear5").stop().delay(0).animate ({left:183, top:3}, speed, 'easeOutCubic');
		sym.getSymbol("rearMc").$("rear6").stop().delay(60).animate ({left:167, top:52}, speed, 'easeOutCubic');
		sym.getSymbol("rearMc").$("rear7").stop().delay(100).animate ({left:152, top:150}, speed, 'easeOutCubic');
		sym.getSymbol("rearMc").$("rear8").stop().delay(150).animate ({left:155, top:248}, speed, 'easeOutCubic', function(){ 
			// MODULE OPEN
			sym.getSymbol("rearMc").$("rear4").stop().fadeOut(0);
			sym.$("moduleMc").stop().delay(0).animate ({opacity:1}, 0);
			sym.getSymbol("moduleMc").$("module1").stop().delay(0).animate ({left:-12, top:-33}, speed, 'easeOutCubic');
			sym.getSymbol("moduleMc").$("module3").stop().delay(0).animate ({left:-25, top:-70}, speed, 'easeOutCubic');
			sym.getSymbol("moduleMc").$("module4").stop().delay(0).animate ({left:-37, top:-106}, speed, 'easeOutCubic');
			sym.getSymbol("moduleMc").$("module5").stop().delay(0).animate ({left:-12, top:-33}, speed, 'easeOutCubic', function(){ 
				sym.getSymbol("moduleMc").$("modulePointMc").stop().delay(0).animate ({opacity:1}, 100);
				sym.$("rearPointMc").stop().fadeIn(300);
			});
			clicked = 0;
		});
	}
	}
	
	sym.$("swapBtn").on('touchstart click', function(e){
	e.stopPropagation(); e.preventDefault();
	topOpen();
	});
	sym.$("swapBtn").mouseover(function(){
		sym.getSymbol("swapBtn").$("btnCol").stop().fadeOut(200);
	});
	sym.$("swapBtn").mouseout(function(){
		sym.getSymbol("swapBtn").$("btnCol").stop().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: 'rearMc'
   (function(symbolName) {   
   
   })("rearMc");
   //Edge symbol end:'rearMc'

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

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

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

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

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

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

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