/***********************
* 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) {
         // insert code to be run when the composition is fully loaded here
          
                  /*var menu_arr = ["txt7","txt8","txt9","txt10"];
                  $.each(menu_arr, function(index, value) {
                  sym.$(value).css('line-height', '146%');
                  });*/
             
	// Text boxes in styleMc movie clip         
	var headline;
	var headlinetxt = sym.getSymbol("styleMc").$("headlineTxt").css("pointer-events","none");
	var stand;
	var standtxt = sym.getSymbol("styleMc").$("standTxt").css("pointer-events","none");
	var source;
	var sourcetxt = sym.getSymbol("styleMc").$("sourceTxt").css("pointer-events","none");
	var pictures;
	var picturestxt = sym.getSymbol("styleMc").$("picturesTxt").css("pointer-events","none");
	 
	// Text boxes on stage
	var txt1;
	var txt1txt = sym.$("txt1").css("pointer-events","none");
         
	// Text boxes in rollBtnsMc movie clip
	var rollTxt0;
	var rollTxt0txt = sym.getSymbol("rollBtnsMc").$("rollTxt0").css("pointer-events","none");
	var rollTxt1;
	var rollTxt1txt = sym.getSymbol("rollBtnsMc").$("rollTxt1").css("pointer-events","none");
	var rollTxt2;
	var rollTxt2txt = sym.getSymbol("rollBtnsMc").$("rollTxt2").css("pointer-events","none");
	var rollTxt3;
	var rollTxt3txt = sym.getSymbol("rollBtnsMc").$("rollTxt3").css("pointer-events","none");
	var rollTxt4;
	var rollTxt4txt = sym.getSymbol("rollBtnsMc").$("rollTxt4").css("pointer-events","none");
         
	//VARIABLES: cellMc
	var cell1;
	var cell1Txt = sym.getSymbol("cellMc").$("cell1Txt").css("pointer-events","none");
	var cell2;
	var cell2Txt = sym.getSymbol("cellMc").$("cell2Txt").css("pointer-events","none");
	var cell3;
	var cell3Txt = sym.getSymbol("cellMc").$("cell3Txt").css("pointer-events","none");
         
	//VARIABLES: dnaMc
	var dna1;
	var dna1Txt = sym.getSymbol("dnaMc").$("dna1Txt").css("pointer-events","none");
	var dna2;
	var dna2Txt = sym.getSymbol("dnaMc").$("dna2Txt").css("pointer-events","none");
	
	//VARIABLES: histoneMc
	var hist0;
	var hist0Txt = sym.getSymbol("histoneMc").$("hist0Txt").css("pointer-events","none");
	var hist1;
	var hist1Txt = sym.getSymbol("histoneMc").$("hist1Txt").css("pointer-events","none");
	var hist2;
	var hist2Txt = sym.getSymbol("histoneMc").$("hist2Txt").css("pointer-events","none");
	var hist3;
	var hist3Txt = sym.getSymbol("histoneMc").$("hist3Txt").css("pointer-events","none");
	var hist4;
	var hist4Txt = sym.getSymbol("histoneMc").$("hist4Txt").css("pointer-events","none");
	var hist5;
	var hist5Txt = sym.getSymbol("histoneMc").$("hist5Txt").css("pointer-events","none");
	var hist6;
	var hist6Txt = sym.getSymbol("histoneMc").$("hist6Txt").css("pointer-events","none");
	var hist7;
	var hist7Txt = sym.getSymbol("histoneMc").$("hist7Txt").css("pointer-events","none");
	 
                  
           
           //AJAX retrieves data from xml source specified in url, maps xml variable to DOM object variable
           $.ajax({	
         	type: "GET",
         	url: "GN29764.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);
         		pictures = $(xml).find('pictures').text();
         		picturestxt.html(pictures);
         		txt1 = $(xml).find('txt1').text();
         		txt1txt.html(txt1);
         		
         		
			// Text boxes in rollBtnsMc movie clip 
         		rollTxt0 = $(xml).find('rollTxt0').text();
         		rollTxt0txt.html(rollTxt0);
         		rollTxt1 = $(xml).find('rollTxt1').text();
         		rollTxt1txt.html(rollTxt1);
         		rollTxt2 = $(xml).find('rollTxt2').text();
         		rollTxt2txt.html(rollTxt2);
         		rollTxt3 = $(xml).find('rollTxt3').text();
         		rollTxt3txt.html(rollTxt3);
         		rollTxt4 = $(xml).find('rollTxt4').text();
         		rollTxt4txt.html(rollTxt4);
         		
         		// Text boxes in cellMc movie clip 
			cell1 = $(xml).find('cell1').text();
         		cell1Txt.html(cell1);
         		cell2 = $(xml).find('cell2').text();
         		cell2Txt.html(cell2);
         		cell3 = $(xml).find('cell3').text();
         		cell3Txt.html(cell3);
         		
         		// Text boxes in dnaMc movie clip 
         		dna1 = $(xml).find('dna1').text();
         		dna1Txt.html(dna1);
         		dna2 = $(xml).find('dna2').text();
         		dna2Txt.html(dna2);
         		
         		// Text boxes in histoneMc movie clip 
         		hist0 = $(xml).find('hist0').text();
         		hist0Txt.html(hist0);
         		hist1 = $(xml).find('hist1').text();
         		hist1Txt.html(hist1);
         		hist2 = $(xml).find('hist2').text();
         		hist2Txt.html(hist2);
         		hist3 = $(xml).find('hist3').text();
         		hist3Txt.html(hist3);
         		hist4 = $(xml).find('hist4').text();
         		hist4Txt.html(hist4);
         		hist5 = $(xml).find('hist5').text();
         		hist5Txt.html(hist5);
         		hist6 = $(xml).find('hist6').text();
         		hist6Txt.html(hist6);
         		hist7 = $(xml).find('hist7').text();
         		hist7Txt.html(hist7);
         		 
         		}
         	}); // END XML
         	
         	// these control animation delays and final left/top positions

		sym.$("rollBtnsMc").css({opacity: 0});
		sym.$("histoneMc").css({opacity: 0});
		
		//rollBtnsMc -- change delay as needed (15000)= 15 seconds        	
         	sym.$("rollBtnsMc").delay(15000).animate({opacity: 1}, 2000);
         	
         	//histoneMc -- change delay as needed        	
         	sym.$("histoneMc").delay(17000).animate({opacity: 1}, 2000);
         	
         	//handMc -- change left and top coordinates as needed
         	//Use rulers to establish coordinates
         	sym.$("handMc").delay(15000).animate({left:115, top:210}, 2000);
         	sym.$("handMc").css("pointer-events","none");
         	
         	// show/hide sequence
         	$(this.lookupSelector("box")).hide();

         	

	// MENU BUTTONS --------------------------------------------	
         //the array that will hold references to the buttons.
         menuArray = [];
         var view = 0;
         
	// Change "m < 5;" if there are more than four expanding text boxes
         for (var m = 0; m < 5; m++){
         	 // Create an instance element of a symbol as a child of the
         	 // given parent element
         	 var menuBtnSymbols = sym.getSymbol("rollBtnsMc").getSymbol("rollBtn" +m);
         	 //set the value of a Symbol variable
         	 menuBtnSymbols.setVariable("menuId", m);
         	 //push it into the array
         	 menuArray.push(menuBtnSymbols);
         }

         //a 'for each' loop through the newly populated array.
         $.each(menuArray, function( count, btnInTheArray ){
         	 //create jQuery reference to the item.
         	 var menuBtnItem = $(btnInTheArray);
         	 //create a jQuery reference to the DIV element inside the symbol.
         	 var menuBtnElement = btnInTheArray.getSymbolElement();
         	 //now you can bind interactivity to the menu items' DIVs
         	 menuBtnElement.bind ("click", {menuId:count}, menuBtnClick);
         	 menuBtnElement.bind ("mouseover", {menuId:count}, menuShow);
         	 menuBtnElement.bind ("mouseout", {menuId:count}, menuHide);
         	}
         )
         
         function resetMenu (){
		for (var m=0; m<menuArray.length; m++){
			var menu_arr = ["rollTxt0","rollTxt1","rollTxt2","rollTxt3","rollTxt4"];
			$.each(menu_arr, function(index, value) {
			sym.getSymbol("rollBtnsMc").$(value).css('opacity', '0');
			sym.getSymbol("rollBtnsMc").$(value).css("pointer-events","none");
			});
         	menuArray[m].getSymbolElement().css({opacity: 0.5});
		}
         }
	resetMenu();
	
        function menuBtnClick (e){
         	resetMenu(); //set them all back to normal state
		//get the id of the clicked item
		sym.$("handMc").hide();
         	var selectedMenu_id = (e.data.menuId); 
		sym.getSymbol("rollBtnsMc").$("rollTxt" + selectedMenu_id). animate ({opacity: 1}, 0);
		sym.getSymbol("rollBtnsMc").$("rollBtn" + selectedMenu_id). animate ({opacity: 1}, 0);
		if (selectedMenu_id == view){
         	resetMenu();
         	selectedMenu_id = 5;
         	}
         	view = selectedMenu_id;
         }
         function menuShow (e){
        	sym.$("handMc").hide();
         	var selectedMenu_id = (e.data.menuId); //get the id of the over button
         	sym.getSymbol("rollBtnsMc").$("rollTxt" + selectedMenu_id). animate ({opacity: 1}, 0);
         	sym.getSymbol("rollBtnsMc").$("rollBtn" + selectedMenu_id). animate ({opacity: 1}, 0);
         }
         function menuHide (e){
         	var selectedMenu_id = (e.data.menuId); //get the id of the out button
		sym.getSymbol("rollBtnsMc").$("rollTxt" + selectedMenu_id). animate ({opacity: 0}, 0);
		sym.getSymbol("rollBtnsMc").$("rollBtn" + selectedMenu_id). animate ({opacity: 0.5}, 0);
         }

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


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

      });
      //Edge binding end

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

//=========================================================
   //Edge symbol: 'handMc'
   (function(symbolName) {

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

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

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

   //=========================================================
   
   //Edge symbol: 'rollBtn'
   (function(symbolName) {   

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

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

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

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

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

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

   //=========================================================
   
   //Edge symbol: 'histoneMc'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 1000, function(sym, e) {
         sym.play("playHistone");

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_playHistone}", "click", function(sym, e) {
         sym.play("playHistone");
         
         
         
         

      });
      //Edge binding end

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

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 4930, function(sym, e) {
         sym.play("playUnwind");

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_playUnwind}", "click", function(sym, e) {
         sym.play("playUnwind");
         

      });
      //Edge binding end

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

      });
      //Edge binding end

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

      });
      //Edge binding end

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

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