/***********************
* 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) {
	for (var i=0;i<2; i++){
		sym.getSymbol("styleHead").getSymbol("menuBtn"+i).$("menuIcon").attr("src", "images/menuIcon" + i + ".png");
	}
	var zoom = 0;
	sym.$("zoomMc").stop().delay(0).animate ({opacity:0}, 0, 'easeOutCubic');
	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");
	
	// STYLING TEXT
	//.css({"border-width":"1px","border-style":"solid","border-color":"rgba(0,0,0,1)",
	//    "background-color":"rgba(255,255,255,1)","border-radius":"1px","padding":"6px","padding-right":"28px"});
	
	var txt=[];
	txt[0] = sym.getSymbol("satMc").$("txt0").css("pointer-events","none");
	txt[1] = sym.getSymbol("satMc").$("txt1").css("pointer-events","none");
	txt[2] = sym.getSymbol("satMc").$("txt2").css("pointer-events","none");
	txt[3] = sym.getSymbol("satMc").$("txt3").css("pointer-events","none");
	txt[4] = sym.getSymbol("satMc").$("txt4").css("pointer-events","none");
	txt[5] = sym.getSymbol("satMc").$("txt5").css("pointer-events","none");
	txt[6] = sym.getSymbol("satMc").$("txt6").css("pointer-events","none");
	txt[7] = sym.getSymbol("satMc").$("txt7").css({"border-width":"0px","background-color":"rgba(255,255,255,0.3)","border-radius":"3px","padding":"3px"});
	txt[8] = sym.getSymbol("satMc").$("txt8").css("pointer-events","none");
	txt[9] = sym.getSymbol("satMc").$("txt9").css({"border-width":"0px","background-color":"rgba(255,255,255,0.3)","border-radius":"3px","padding":"3px"});
	txt[10] = sym.getSymbol("satMc").$("txt10").css("pointer-events","none");
	txt[11] = sym.getSymbol("satMc").$("txt11").css({"border-width":"0px","background-color":"rgba(255,255,255,0.3)","border-radius":"3px","padding":"3px"});
	txt[12] = sym.getSymbol("satMc").$("txt12").css("pointer-events","none");
	txt[13] = sym.getSymbol("zoomMc").$("txt13").css("pointer-events","none");
	txt[14] = sym.getSymbol("satMc").$("txt14").css("pointer-events","none");
	txt[15] = sym.getSymbol("satMc").$("txt15").css("pointer-events","none");
	txt[16] = sym.getSymbol("satMc").$("txt16").css({"border-width":"1px","border-style":"solid","border-color":"rgba(255,255,255,1)","background-color":"rgba(252,194,0,1)","border-radius":"6px","padding":"6px"});
	txt[17] = sym.getSymbol("satMc").$("txt17").css({"border-width":"1px","border-style":"solid","border-color":"rgba(255,255,255,1)","background-color":"rgba(252,194,0,1)","border-radius":"6px","padding":"6px"});
	txt[18] = sym.getSymbol("satMc").$("txt18").css("pointer-events","none");
	txt[19] = sym.getSymbol("satMc").$("txt19").css("pointer-events","none");
	txt[20] = sym.getSymbol("satMc").$("txt20").css("pointer-events","none");
	txt[21] = sym.getSymbol("satMc").$("txt21").css("pointer-events","none");
	txt[22] = sym.getSymbol("satMc").$("txt22").css("pointer-events","none");
	txt[23] = sym.getSymbol("zoomMc").$("txt23").css("pointer-events","none");
	txt[24] = sym.getSymbol("zoomMc").$("txt24").css("pointer-events","none");
	txt[25] = sym.getSymbol("zoomMc").$("txt25").css("pointer-events","none");
	txt[26] = sym.getSymbol("zoomMc").$("txt26").css("pointer-events","none");
	txt[27] = sym.getSymbol("zoomMc").$("txt27").css("pointer-events","none");
	txt[28] = sym.getSymbol("zoomMc").$("txt28").css("pointer-events","none");
	txt[29] = sym.getSymbol("zoomMc").$("txt29").css("pointer-events","none");
	txt[30] = sym.getSymbol("zoomMc").$("txt30").css("pointer-events","none");
	txt[31] = sym.getSymbol("zoomMc").$("txt31").css("pointer-events","none");
	txt[32] = sym.getSymbol("zoomMc").$("txt32").css("pointer-events","none");
	txt[33] = sym.getSymbol("zoomMc").$("txt33").css("pointer-events","none");
	txt[34] = sym.getSymbol("zoomMc").$("txt34").css("pointer-events","none");
	txt[35] = sym.getSymbol("zoomMc").$("txt35").css("pointer-events","none");
	txt[36] = sym.getSymbol("zoomMc").$("txt36").css("pointer-events","none");
	txt[37] = sym.getSymbol("zoomMc").$("txt37").css("pointer-events","none");
	txt[38] = sym.getSymbol("zoomMc").$("txt38").css("pointer-events","none");
	txt[39] = sym.getSymbol("zoomMc").$("txt39").css("pointer-events","none");
	txt[40] = sym.getSymbol("zoomMc").$("txt40").css("pointer-events","none");
	txt[41] = sym.getSymbol("zoomMc").$("txt41").css("pointer-events","none");
	txt[42] = sym.getSymbol("zoomMc").$("txt42").css("pointer-events","none");
	txt[43] = sym.getSymbol("zoomMc").$("txt43").css("pointer-events","none");
	txt[44] = sym.getSymbol("zoomMc").$("txt44").css("pointer-events","none");
	txt[45] = sym.getSymbol("zoomMc").$("txt45").css({"border-width":"0px","background-color":"rgba(189,208,232,1)","border-radius":"3px","padding":"3px"});
	txt[46] = sym.getSymbol("zoomMc").$("txt46").css("pointer-events","none");
	txt[47] = sym.getSymbol("zoomMc").$("txt47").css("pointer-events","none");
	txt[48] = sym.getSymbol("zoomMc").$("txt48").css({"padding-right":"30px"});
	txt[49] = sym.$("txt49").css("pointer-events","none");
	txt[50] = sym.$("txt50").css("pointer-events","none");
	txt[51] = sym.$("txt51").css("pointer-events","none");
	txt[52] = sym.$("txt52").css("pointer-events","none");
	txt[53] = sym.$("txt53").css("pointer-events","none");
	txt[54] = sym.$("txt54").css("pointer-events","none");
	txt[55] = sym.getSymbol("satMc").$("txt55").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: "GN31598.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<56; i++){
			txtArr[i]=$(xml).find('txt'+i).text();
			txt[i].html(txtArr[i]);
			}
			sym.getSymbol("satMc").$("txt7").animate({left:308 - sym.getSymbol("satMc").$("txt7").width()+10}, 0);
		}
	}); // END XML
	//MAP BUTTON
	sym.$('mapBtn').on('click',mapMove);
	sym.$('mapBtn').css({'cursor':'pointer'});
	var mapPos=0;
	function mapMove(){
		if (mapPos==0){
			sym.$('satMc').stop().animate({'top':'-5px'},1000,'easeOutCirc');
			sym.getSymbol('mapBtn').$('btnArrowDown').css({'transform':'rotate(180deg)','-webkit-transform:':'rotate(180deg)','-ms-transform':'rotate(180deg)',});
			mapPos=1;
		}else{
			sym.$('satMc').stop().animate({'top':'93px'},600,'easeOutCirc');
			sym.getSymbol('mapBtn').$('btnArrowDown').css({'transform':'rotate(0deg)','-webkit-transform:':'rotate(0deg)','-ms-transform':'rotate(0deg)',});
			mapPos=0;
		}
	}
	
	// MENU BUTTONS --------------------------------------------	
	menuArray = []; //the array that will hold references to the buttons.
	for (var h = 0; h < 2; 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
		menuBtnElement.bind ("click", {menuId:count}, menuBtnClick);
		menuBtnElement.bind ("touchstart", {menuId:count}, menuBtnClick);
		menuBtnElement.bind ("mouseover", {menuId:count}, menuShow);
		menuBtnElement.bind ("mouseout", {menuId:count}, menuHide);
	})
	
	function resetmenu(){
		for (var h=0; h<menuArray.length; h++){
         menuArray[h].$("btnClick").fadeOut(0);
         menuArray[h].$("btnOver").fadeOut(0);
		}
	}
	resetmenu();

sym.setVariable("clicked", 0);	
	function menuBtnClick (e){
		resetmenu(); //set them all back to normal state
		var menuMenu_id = (e.data.menuId); //get the id of the clicked item
		sym.getSymbol("styleHead").getSymbol("menuBtn" + menuMenu_id).$("btnClick").fadeIn(0);
		sym.getSymbol("styleHead").$("menuTxt" + menuMenu_id).fadeIn(0);
		if (menuMenu_id==0) {
			sym.getSymbol("zoomMc").stop(1383);
			sym.getSymbol("zoomMc").playReverse();
			sym.$('mapBtn').fadeIn(2000);
			zoom = 0;
			sym.setVariable("clicked", 0);	
		}
		if (menuMenu_id==1) {
			sym.$("zoomMc").stop().delay(100).animate ({opacity:1}, 500, 'easeOutCubic', function(){ sym.getSymbol("zoomMc").play(1); });
			sym.$('mapBtn').fadeOut(800);
			zoomIt();
			sym.setVariable("clicked", 1);	
		}
	}
	function menuShow (e){
		var menuMenu_id = (e.data.menuId); //get the id of the over button
		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);
	}

// MAKE MENU 0 VISIBLE
sym.getSymbol("styleHead").getSymbol("menuBtn0").$("btnClick").fadeIn(0);

sym.getSymbol("zoomMc").getSymbol("btnNext").$("btnReplay").fadeOut(0);	

sym.getSymbol("zoomMc").$("btnNext").on('touchstart click', function(e){
	e.stopPropagation(); e.preventDefault();
	sym.getSymbol("zoomMc").play();
	zoom++;
	zoomIt();
	});
sym.getSymbol("zoomMc").$("btnNext").mouseover(function(){
	sym.getSymbol("zoomMc").getSymbol("btnNext").$("btnOut").fadeOut(200);
	});
sym.getSymbol("zoomMc").$("btnNext").mouseout(function(){
	sym.getSymbol("zoomMc").getSymbol("btnNext").$("btnOut").fadeIn(200);
	});

function zoomIt() {
			sym.getSymbol("zoomMc").getSymbol("btnNext").$("btnReplay").fadeOut(0);
			sym.getSymbol("zoomMc").getSymbol("btnNext").$("btnOut").fadeIn(0);
			sym.getSymbol("zoomMc").getSymbol("btnNext").$("btnOver").fadeIn(0);
		if (zoom == 6){
			sym.getSymbol("zoomMc").getSymbol("btnNext").$("btnReplay").fadeIn(0);
			sym.getSymbol("zoomMc").getSymbol("btnNext").$("btnOut").fadeOut(0);
			sym.getSymbol("zoomMc").getSymbol("btnNext").$("btnOver").fadeOut(0);
		}
		if (zoom == 7){
			sym.getSymbol("zoomMc").getSymbol("btnNext").$("btnReplay").fadeOut(0);
			sym.getSymbol("zoomMc").getSymbol("btnNext").$("btnOut").fadeIn(0);
			sym.getSymbol("zoomMc").getSymbol("btnNext").$("btnOver").fadeIn(0);
			sym.getSymbol("zoomMc").play(1383);
			zoom = 0;
		}
	$.ajax({	
		type: "GET",
		url: "GN31598.xml",
		dataType: "xml",
		success: function(xml) {

		sym.getSymbol("zoomMc").$("txt48").empty();

		txtArr[48]=$(xml).find('txt48').text();
		txt[48].html(txtArr[zoom + 48]);
		txt[48] = sym.getSymbol("zoomMc").$("txt48").css({"padding-right":"30px"});
		}
	}); // END XML
}

         	});//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: 'menuBtn_2'
   (function(symbolName) {   
   
   })("menuBtn");
   //Edge symbol end:'menuBtn'

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

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

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

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

   //=========================================================
   
   //Edge symbol: 'satMc'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 8000, function(sym, e) {
         
         var btnClicked = sym.getComposition().getStage().getVariable("clicked");
         if(btnClicked==0){
         	sym.getComposition().getStage().$('mapBtn').fadeIn(400);
         }

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 4000, function(sym, e) {
         sym.getSymbol('planeNorth').play();

      });
      //Edge binding end

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

   //=========================================================
   
   //Edge symbol: 'planeNorth'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 9000, function(sym, e) {
         

      });
      //Edge binding end

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

   //=========================================================
   
   //Edge symbol: 'zoomMc'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 2655, function(sym, e) {
         sym.stop();

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 1750, function(sym, e) {
         sym.stop();

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 7693, function(sym, e) {
         sym.stop();

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 5350, function(sym, e) {
         sym.stop();

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 5622, function(sym, e) {
         sym.stop();

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 8576, function(sym, e) {
         sym.stop();

      });
      //Edge binding end

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

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