/***********************
* 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) {
//get the id of the clicked item  // insert code to be run when the composition is fully loaded here

         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 txt1;
         var txt1txt = sym.$("txt1").css("pointer-events","none");
         var txt2;
         var txt2txt = sym.$("txt2").css("pointer-events","none");
         var txt3;
         var txt3txt = sym.getSymbol("mainMc").$("txt3").css("pointer-events","none");
         var txt4;
         var txt4txt = sym.getSymbol("mainMc").$("txt4").css("pointer-events","none");
         var txt5;
         var txt5txt = sym.getSymbol("mainMc").$("txt5").css("pointer-events","none");
         var txt6;
         var txt6txt = sym.getSymbol("mainMc").$("txt6").css("pointer-events","none");
         var txt7;
         var txt7txt = sym.getSymbol("mainMc").$("txt7").css("pointer-events","none");
         var txt8;
         var txt8txt = sym.getSymbol("mainMc").$("txt8").css("pointer-events","none");
         var txt9;
         var txt9txt = sym.getSymbol("mainMc").$("txt9").css("pointer-events","none");
         var txt10;
         var txt10txt = sym.getSymbol("mainMc").$("txt10").css("pointer-events","none");
         var txt11;
         var txt11txt = sym.getSymbol("mainMc").$("txt11").css("pointer-events","none");
         var txt12;
         var txt12txt = sym.getSymbol("mainMc").$("txt12").css("pointer-events","none");
         var txt13;
         var txt13txt = sym.getSymbol("mainMc").getSymbol("pointersMc").$("txt13").css("pointer-events","none");
         var txt14;
         var txt14txt = sym.getSymbol("mainMc").getSymbol("pointersMc").$("txt14").css("pointer-events","none");
         var txt15;
         var txt15txt = sym.getSymbol("mainMc").getSymbol("pointersMc").$("txt15").css("pointer-events","none");
         var txt16;
         var txt16txt = sym.getSymbol("mainMc").getSymbol("pointersMc").$("txt16").css("pointer-events","none");
         var txt17;
         var txt17txt = sym.getSymbol("mainMc").getSymbol("pointersMc").$("txt17").css("pointer-events","none");
         var txt18;
         var txt18txt = sym.getSymbol("mainMc").getSymbol("pointersMc").$("txt18").css("pointer-events","none");
         var txt19;
         var txt19txt = sym.getSymbol("mainMc").getSymbol("pointersMc").$("txt19").css("pointer-events","none");
         var txt20;
         var txt20txt = sym.getSymbol("mainMc").getSymbol("pointersMc").$("txt20").css("pointer-events","none");
         var txt21;
         var txt21txt = sym.getSymbol("mainMc").$("txt21").css("pointer-events","none");
         var txt22;
         var txt22txt = sym.getSymbol("mainMc").$("txt22").css("pointer-events","none");
         var txt23;
         var txt23txt = sym.getSymbol("mainMc").$("txt23").css("pointer-events","none");
         var txt24;
         var txt24txt = sym.getSymbol("mainMc").$("overTxt0").css("pointer-events","none");
         var txt25;
         var txt25txt = sym.getSymbol("mainMc").$("overTxt1").css("pointer-events","none");
         var txt26;
         var txt26txt = sym.getSymbol("mainMc").$("overTxt2").css("pointer-events","none");
         var txt27;
         var txt27txt = sym.getSymbol("mainMc").$("overTxt3").css("pointer-events","none");
         var txt28;
         var txt28txt = sym.getSymbol("mainMc").$("overTxt4").css("pointer-events","none");
         var txt29;
         var txt29txt = sym.getSymbol("mainMc").$("overTxt5").css("pointer-events","none");
         var txt30;
         var txt30txt = sym.getSymbol("mainMc").$("overTxt6").css("pointer-events","none");
         var txt31;
         var txt31txt = sym.getSymbol("mainMc").$("overTxt7").css("pointer-events","none");
         var txt32;
         var txt32txt = sym.getSymbol("mainMc").$("overTxt8").css("pointer-events","none");

           //AJAX retrieves data from xml source specified in url, maps xml variable to DOM object variable
           $.ajax({	
         	type: "GET",
         	url: "GN29835.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);
         		txt1 = $(xml).find('txt1').text();
         		txt1txt.html(txt1);
         		txt2 = $(xml).find('txt2').text();
         		txt2txt.html(txt2);
         		txt3 = $(xml).find('txt3').text();
         		txt3txt.html(txt3);
         		txt4 = $(xml).find('txt4').text();
         		txt4txt.html(txt4)
         		txt5 = $(xml).find('txt5').text();
         		txt5txt.html(txt5);
         		txt6 = $(xml).find('txt6').text();
         		txt6txt.html(txt6);
         		txt7 = $(xml).find('txt7').text();
         		txt7txt.html(txt7);
         		txt8 = $(xml).find('txt8').text();
         		txt8txt.html(txt8);
         		txt9 = $(xml).find('txt9').text();
         		txt9txt.html(txt9);
         		txt10 = $(xml).find('txt10').text();
         		txt10txt.html(txt10);
         		txt11 = $(xml).find('txt11').text();
         		txt11txt.html(txt11);
         		txt12 = $(xml).find('txt12').text();
         		txt12txt.html(txt12);
         		txt13 = $(xml).find('txt13').text();
         		txt13txt.html(txt13);
         		txt14 = $(xml).find('txt14').text();
         		txt14txt.html(txt14);
         		txt15 = $(xml).find('txt15').text();
         		txt15txt.html(txt15);
         		txt16 = $(xml).find('txt16').text();
         		txt16txt.html(txt16);
         		txt17 = $(xml).find('txt17').text();
         		txt17txt.html(txt17);
         		txt18 = $(xml).find('txt18').text();
         		txt18txt.html(txt18);
         		txt19 = $(xml).find('txt19').text();
         		txt19txt.html(txt19);
         		txt20 = $(xml).find('txt20').text();
         		txt20txt.html(txt20);
         		txt21 = $(xml).find('txt21').text();
         		txt21txt.html(txt21);
         		txt22 = $(xml).find('txt22').text();
         		txt22txt.html(txt22);
         		txt23 = $(xml).find('txt23').text();
         		txt23txt.html(txt23);
         		txt24 = $(xml).find('txt24').text();
         		txt24txt.html(txt24);
         		txt25 = $(xml).find('txt25').text();
         		txt25txt.html(txt25);
         		txt26 = $(xml).find('txt26').text();
         		txt26txt.html(txt26);
         		txt27 = $(xml).find('txt27').text();
         		txt27txt.html(txt27);
         		txt28 = $(xml).find('txt28').text();
         		txt28txt.html(txt28);
         		txt29 = $(xml).find('txt29').text();
         		txt29txt.html(txt29);
         		txt30 = $(xml).find('txt30').text();
         		txt30txt.html(txt30);   
         		txt31 = $(xml).find('txt31').text();
         		txt31txt.html(txt31);   
         		txt32 = $(xml).find('txt32').text();
         		txt32txt.html(txt32);  
         		}
         	}); // END XML

// MOVE HAND AT START
	sym.$("handMc").animate ({opacity: 0}, 0);
	sym.$("handMc").delay(14000).animate ({opacity: 1, left: 70, top:536}, 1500);
	sym.$("handMc").delay(200).animate ({left: 472, top:364}, 1500);
	sym.$("handMc").delay(200).animate ({left: 537, top:252}, 1500);

// STOP ELEMENTS INTERACTING WITH MOUSE
	sym.$("handMc").css("pointer-events","none");
	sym.$("diveMc").hide();

// HIDE ELEMENTS
        sym.$("videoPanel").fadeOut(0);
        sym.$("playBtnBtn").fadeOut(0);
	sym.$("closeBtn").fadeOut(0);
	sym.$("playBtnBtn").delay(14000).fadeIn(0);

// MENU BUTTONS --------------------------------------------	
         menuArray = [];
         var view = 0;

         for (var m = 0; m < 9; m++){
         	 // Create an instance element of a symbol as a child of the given parent element
         	 var menuBtnSymbols = sym.getSymbol("mainMc").getSymbol("btnMc" +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 = ["overTxt0","overTxt1","overTxt2","overTxt3","overTxt4","overTxt5","overTxt6","overTxt7","overTxt8"];
			$.each(menu_arr, function(index, value) {
			sym.getSymbol("mainMc").$(value).fadeOut(0);
			});
         	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("mainMc").$("btnMc" + selectedMenu_id).animate ({opacity: 1}, 0);
		sym.getSymbol("mainMc").$("overTxt" + selectedMenu_id).fadeIn(0);
		if (selectedMenu_id == view){
         	resetMenu();
         	selectedMenu_id = 10;
         	}
         	view = selectedMenu_id;
         }
         function menuShow (e){
        	sym.$("handMc").hide();
         	var selectedMenu_id = (e.data.menuId); //get the id of the over button
         	sym.getSymbol("mainMc").$("overTxt" + selectedMenu_id).fadeIn(0);
         	sym.getSymbol("mainMc").$("btnMc" + selectedMenu_id).animate ({opacity: 1}, 0);
         }
         function menuHide (e){
         	var selectedMenu_id = (e.data.menuId); //get the id of the out button
		sym.getSymbol("mainMc").$("overTxt" + selectedMenu_id).fadeOut(0);
		sym.getSymbol("mainMc").$("btnMc" + selectedMenu_id).animate ({opacity: 0.5}, 0);
         }

// Embed a movie: create text variable 
	var vid = $("<video width='640' height='480' controls='controls' id='vid1'>" +
	"<source src='media/redbull.mp4' type='video/mp4' />" +
	"<source src='media/redbull.ogg' type='video/ogg' />" +
	"<source src='media/redbull.webm' type='video/webm' />" +
	"This browser is not compatible with HTML 5" +
	"</video>");
	// stage symbol lookup, and append the above vid object to it;
	// in other words, get the div called 'videobox' and attach the video control to it;
	sym.getSymbol("videoPanel").$("videobox").append(vid);


// VIDEO PLAY BUTTON
	Symbol.bindElementAction(compId, symbolName, "${_playBtnBtn}", "click", function(sym, e) {
		sym.$("handMc").hide();
		sym.$("videoPanel").fadeIn(300);
		sym.$("closeBtn").fadeIn(300);
		document.getElementById('vid1').play();
	});
	Symbol.bindElementAction(compId, symbolName, "${_closeBtn}", "click", function(sym, e) {
		sym.$("videoPanel").fadeOut(300);
		sym.$("closeBtn").fadeOut(300);
		document.getElementById('vid1').pause();
	});

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


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

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

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

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

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

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

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

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

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

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