/***********************
* 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");
	
	for (var b=0;b<3; b++){
			sym.$("canalMc" + b).animate ({opacity:0}, 0);
	}
	
	// STYLING TEXT	
	// "box-shadow":"5px 5px 5px rgba(0,0,0,0.3)"
	// "border-width":"1px","border-style":"solid","border-color":"rgba(0,0,0,1, "border-radius":"1px"
	// "background-color":"rgba(255,255,255,1)"
	// "padding":"6px"
	
	var txt=[];
	txt[0] = sym.getSymbol("graphMc").$("txt0").css({"pointer-events":"none",});
	txt[1] = sym.getSymbol("graphMc").$("txt1").css({"pointer-events":"none"});
	txt[2] = sym.getSymbol("graphMc").$("txt2").css({"pointer-events":"none", "background-color":"rgba(255,193,14,1)", "padding":"6px", "border-width":"1px","border-style":"solid","border-color":"rgba(255,255,255,1)", "border-radius":"5px", "box-shadow":"5px 5px 5px rgba(0,0,0,0.3)"});
	txt[3] = sym.getSymbol("graphMc").$("txt3").css({"pointer-events":"none"});
	txt[4] = sym.$("txt4").css({"pointer-events":"none"});
	txt[5] = sym.$("txt5").css({"pointer-events":"none"});
	txt[6] = sym.$("txt6").css({"pointer-events":"none"});
	txt[7] = sym.$("txt7").css({"pointer-events":"none"});
	txt[8] = sym.$("txt8").css({"pointer-events":"none"});
	txt[9] = sym.getSymbol("canalMc0").$("txt9").css({"pointer-events":"none"});
	txt[10] = sym.getSymbol("canalMc0").$("txt10").css({"pointer-events":"none"});
	txt[11] = sym.getSymbol("canalMc0").$("txt11").css({"pointer-events":"none"});
	txt[12] = sym.getSymbol("canalMc0").$("txt12").css({"pointer-events":"none"});
	txt[13] = sym.getSymbol("canalMc0").$("txt13").css({"pointer-events":"none"});
	txt[14] = sym.getSymbol("canalMc0").$("txt14").css({"pointer-events":"none", "background-color":"rgba(255,193,14,1)", "padding":"6px", "border-width":"1px","border-style":"solid","border-color":"rgba(255,255,255,1)", "border-radius":"5px", "box-shadow":"5px 5px 5px rgba(0,0,0,0.3)"});
	txt[15] = sym.getSymbol("canalMc0").$("txt15").css({"pointer-events":"none"});
	txt[16] = sym.getSymbol("canalMc0").$("txt16").css({"pointer-events":"none"});
	txt[17] = sym.getSymbol("canalMc0").$("txt17").css({"pointer-events":"none", "background-color":"rgba(255,193,14,1)", "padding":"6px", "border-width":"1px","border-style":"solid","border-color":"rgba(255,255,255,1)", "border-radius":"5px", "box-shadow":"5px 5px 5px rgba(0,0,0,0.3)"});
	txt[18] = sym.getSymbol("canalMc0").$("txt18").css({"pointer-events":"none"});
	txt[19] = sym.getSymbol("canalMc0").$("txt19").css({"pointer-events":"none"});
	txt[20] = sym.getSymbol("canalMc0").$("txt20").css({"pointer-events":"none"});
	txt[21] = sym.getSymbol("canalMc0").$("txt21").css({"pointer-events":"none"});
	txt[22] = sym.getSymbol("canalMc0").$("txt22").css({"pointer-events":"none"});
	txt[23] = sym.getSymbol("canalMc0").$("txt23").css({"pointer-events":"none"});
	txt[24] = sym.getSymbol("canalMc1").$("txt24").css({"pointer-events":"none", "background-color":"rgba(255,193,14,1)", "padding":"6px", "border-width":"1px","border-style":"solid","border-color":"rgba(255,255,255,1)", "border-radius":"5px", "box-shadow":"5px 5px 5px rgba(0,0,0,0.3)"});
	txt[25] = sym.getSymbol("canalMc1").$("txt25").css({"pointer-events":"none"});
	txt[26] = sym.getSymbol("canalMc1").$("txt26").css({"pointer-events":"none"});
	txt[27] = sym.getSymbol("canalMc1").$("txt27").css({"pointer-events":"none"});
	txt[28] = sym.getSymbol("canalMc1").$("txt28").css({"pointer-events":"none"});
	txt[29] = sym.getSymbol("canalMc1").$("txt29").css({"pointer-events":"none"});
	txt[30] = sym.getSymbol("canalMc1").$("txt30").css({"pointer-events":"none"});
	txt[31] = sym.getSymbol("canalMc1").$("txt31").css({"pointer-events":"none"});
	txt[32] = sym.getSymbol("canalMc1").$("txt32").css({"pointer-events":"none"});
	txt[33] = sym.getSymbol("canalMc1").$("txt33").css({"pointer-events":"none"});
	txt[34] = sym.getSymbol("canalMc1").$("txt34").css({"pointer-events":"none"});
	txt[35] = sym.getSymbol("canalMc1").$("txt35").css({"pointer-events":"none"});
	txt[36] = sym.getSymbol("canalMc2").$("txt36").css({"pointer-events":"none", "background-color":"rgba(255,193,14,1)", "padding":"6px", "border-width":"1px","border-style":"solid","border-color":"rgba(255,255,255,1)", "border-radius":"5px", "box-shadow":"5px 5px 5px rgba(0,0,0,0.3)"});
	txt[37] = sym.getSymbol("canalMc2").$("txt37").css({"pointer-events":"none"});
	txt[38] = sym.getSymbol("canalMc2").$("txt38").css({"pointer-events":"none"});
	txt[39] = sym.getSymbol("canalMc2").$("txt39").css({"pointer-events":"none"});
	txt[40] = sym.getSymbol("canalMc2").$("txt40").css({"pointer-events":"none"});
	txt[41] = sym.getSymbol("canalMc2").$("txt41").css({"pointer-events":"none"});
	txt[42] = sym.getSymbol("canalMc2").$("txt42").css({"pointer-events":"none"});
	txt[43] = sym.getSymbol("canalMc2").$("txt43").css({"pointer-events":"none"});
	txt[44] = sym.getSymbol("canalMc2").$("txt44").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: "GN32138.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<45; i++){
			txtArr[i]=$(xml).find('txt'+i).text();
			txt[i].html(txtArr[i]);
			}
	
			sym.getSymbol("graphMc").$("txt2").animate({left:673 - sym.getSymbol("graphMc").$("txt2").width()/2}, 0);
			sym.getSymbol("canalMc0").$("txt17").animate({left:615 - sym.getSymbol("canalMc0").$("txt17").width()+0}, 0);
			sym.getSymbol("canalMc0").$("txt22").animate({top:439 - sym.getSymbol("canalMc0").$("txt22").height()+10}, 0);
	
		}
	}); // END XML
	
	// AUX BUTTONS --------------------------------------------	
	auxArray = []; //the array that will hold references to the buttons.
	
	for (var a = 0; a < 3; a++){
		var auxBtnSymbols = sym.getSymbol("auxBtnsMc").getSymbol("auxBtn" +a); // Create an instance element of a symbol as a child of the given parent element
		auxBtnSymbols.setVariable("auxId", a); //set the value of a Symbol variable
		auxArray.push(auxBtnSymbols); //push it into the array
	}
	
	$.each(auxArray, function( count, auxInTheArray ){ //a 'for each' loop through the newly populated array
		var auxBtnItem = $(auxInTheArray); //create jQuery reference to the item
		var auxBtnElement = auxInTheArray.getSymbolElement(); //create a jQuery reference to the DIV element inside the symbol
		auxBtnElement.bind ("click", {auxId:count}, auxBtnClick);
		auxBtnElement.bind ("touchstart", {auxId:count}, auxBtnClick);
		auxBtnElement.bind ("mouseover", {auxId:count}, auxBtnShow);
		auxBtnElement.bind ("mouseout", {auxId:count}, auxBtnHide);
	})
	
	function resetAux(){
		for (var a=0; a<auxArray.length; a++){
        	auxArray[a].$("btnClick").fadeOut(0);
       	auxArray[a].$("btnOver").fadeOut(0);
       	auxArray[a].$("btnPlus").fadeIn(0);
		}
		for (var b=0;b<3; b++){
			sym.$("canalMc" + b).stop().animate ({opacity:0}, 300);
		}
	}
	resetAux();

	var clicked = 3;

	function auxBtnClick (e){
		sym.$("graphMc").fadeOut(200);
		resetAux(); //set them all back to normal state
		var auxAux_id = (e.data.auxId); //get the id of the clicked item
		sym.getSymbol("auxBtnsMc").getSymbol("auxBtn" + auxAux_id).$("btnClick").fadeIn(0);
		sym.getSymbol("auxBtnsMc").getSymbol("auxBtn" + auxAux_id).$("btnPlus").fadeOut(0);
		btnNo = auxAux_id;
		sym.$("canalMc" + btnNo).stop().animate ({opacity:1}, 300);

		if (clicked == btnNo){
			resetAux();
			sym.$("graphMc").stop().fadeIn(400);
			clicked = 3;
		}else{

		if (auxAux_id==0) {
		clicked = 0;
		}
		if (auxAux_id==1) {
		clicked = 1;
		}
		if (auxAux_id==2) {
		clicked = 2;
		}
		}
	}

	function auxBtnShow (e){
		var auxAux_id = (e.data.auxId); //get the id of the over button
		sym.getSymbol("auxBtnsMc").getSymbol("auxBtn" + auxAux_id).$("btnOver").fadeIn(0);
	}
	function auxBtnHide (e){
		var auxAux_id = (e.data.auxId); //get the id of the out button
		sym.getSymbol("auxBtnsMc").getSymbol("auxBtn" + auxAux_id).$("btnOver").fadeOut(0);
	}

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

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

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

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

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

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

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