/***********************
* 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) {
         sym.$("captionTxt").css('line-height', '120%');
         var headline;
         var headlinetxt = sym.$("headlineTxt");
         var order;
         var caption;
         var captionb;
         var sources;
         var pictures;
         var keya;
         var keyb;
         var mauritania;
         var algeria;
         var niger;
         var burkina;
         var ghana;
         var guinea;
         var mali;
         var sahara;
         var scalekm;
         var scalemile;
         var taoudenni;
         var timbuktu;
         var kidal;
         var gao;
         var lere;
         var diabaly;
         var douentza;
         var mopti;
         var konna;
         var segou;
         var bamako;
         var logi;
         var ecowas;
         var nos;
         var mainPic = sym.$("main_pic");
         
         //AJAX retrieves data from xml source specified in url, maps xml variable to DOM object variable
         function resetCaps(){
         $.ajax({	
         	type: "GET",
         	url: "GN30196.xml",
         	dataType: "xml",
         	success: function(xml) {
         
         		headline = $(xml).find('headline').text();
         		sym.$("headlineTxt").html(headline);
         
         		order = $(xml).find('order0').text();
         		sym.$("orderTxt").html(order);
         
         		caption = $(xml).find('caption0').text();
         		sym.$("captionTxt").html(caption);
         
         		captionb = $(xml).find('captionb0').text();
         		sym.$("captionbTxt").html(captionb);
         
         		sources = $(xml).find('sources').text();
         		sym.$("sourcesTxt").html(sources);
         
         		pictures = $(xml).find('pictures').text();
         		sym.$("picturesTxt").html(pictures);
         
         		keya = $(xml).find('keya0').text();
         		sym.$("keyaTxt").html(keya);
         
         		keyb = $(xml).find('keyb0').text();
         		sym.$("keybTxt").html(keyb);
         
         		mauritania = $(xml).find('mauritania0').text();
         		sym.$("mauritaniaTxt").html(mauritania);
         
         		algeria = $(xml).find('algeria0').text();
         		sym.$("algeriaTxt").html(algeria);
         
         		niger = $(xml).find('niger0').text();
         		sym.$("nigerTxt").html(niger);
         
         		burkina = $(xml).find('burkina0').text();
         		sym.$("burkinaTxt").html(burkina);
         
         		ghana = $(xml).find('ghana0').text();
         		sym.$("ghanaTxt").html(ghana);
         
         		guinea = $(xml).find('guinea0').text();
         		sym.$("guineaTxt").html(guinea);
         
         		mali = $(xml).find('mali0').text();
         		sym.$("maliTxt").html(mali);
         
         		sahara = $(xml).find('sahara0').text();
         		sym.$("saharaTxt").html(sahara);
         
         		scalekm = $(xml).find('scalekm0').text();
         		sym.$("scalekmTxt").html(scalekm);
         
         		scalemile = $(xml).find('scalemile0').text();
         		sym.$("scalemileTxt").html(scalemile);
         
         		taoudenni = $(xml).find('taoudenni0').text();
         		sym.$("taoudenniTxt").html(taoudenni);
         
         		timbuktu = $(xml).find('timbuktu0').text();
         		sym.$("timbuktuTxt").html(timbuktu);
         
         		kidal = $(xml).find('kidal0').text();
         		sym.$("kidalTxt").html(kidal);
         
         		gao = $(xml).find('gao0').text();
         		sym.$("gaoTxt").html(gao);
         
         		lere = $(xml).find('lere0').text();
         		sym.$("lereTxt").html(lere);
         
         		diabaly = $(xml).find('diabaly0').text();
         		sym.$("diabalyTxt").html(diabaly);
         
         		douentza = $(xml).find('douentza0').text();
         		sym.$("douentzaTxt").html(douentza);
         
         		mopti = $(xml).find('mopti0').text();
         		sym.$("moptiTxt").html(mopti);
         
         		konna = $(xml).find('konna0').text();
         		sym.$("konnaTxt").html(konna);
         
         		segou = $(xml).find('segou0').text();
         		sym.$("segouTxt").html(segou);
         
         		bamako = $(xml).find('bamako0').text();
         		sym.$("bamakoTxt").html(bamako);
         
         		logi = $(xml).find('logi0').text();
         		sym.$("logiTxt").html(logi);
         
         		ecowas = $(xml).find('ecowas0').text();
         		sym.$("ecowasTxt").html(ecowas);
         
         		nos = $(xml).find('nos0').text();
         		sym.$("nosTxt").html(nos);
         
         
         		}
         	});
         }
         resetCaps();
         
         
         //CHANGE THE FOLLOWING	
         var thumbWidth=83; //distance between origin of thumbnail images
         var n=6; //number of images
         var thumbs = 9; //number of thumbnails
         var space = 30; //pixels offset at beginning of buttonstrip
         var ttime= 500; //transition time in milliseconds
         //END CHANGES
         
         //set variables for image gallery
         sym.setVariable("number", 0);
         sym.setVariable("strip", 0);
         
         //CREATE MAIN FORWARD-BACK BUTTONS
         var mainbtnArray = ["mainBtn0","mainBtn1"]; // back and forward buttons
         		for (var m=0; m<mainbtnArray.length; m++){
         		sym.$("mainBtn"+m).bind('click', mainbtnClick);
         		//sym.$("mainBtn"+i).bind('mouseover', btnShow);
         		//sym.$("mainBtn"+i).bind('mouseout', btnHide);
         		}
         function mainbtnClick() {
         			var selected_id = $(this).attr("id");
         			$.ajax({    
             		type: "GET",
             		url: "GN30196.xml",
             		dataType: "xml",
             		success: function(xml) { 
          			var id = sym.getVariable("number");
         			var next;
          			if(selected_id == "Stage_mainBtn0"){ //back button
         			next = id-1;
          				if(next<1){
         				sym.$("mainBtn0").hide();
         				sym.$("stripBtn0").hide();
         				}
         				if(next<n-thumbs){
         				sym.$("stripBtn1").show();
         				}
         				if(next>n-thumbs){
         				sym.$("stripBtn1").hide();
         				}
         				if(next<n-1){
         				sym.$("mainBtn1").show();
         				}
         				if (id>n-thumbs){
         				sym.getSymbol("slider").$("buttonstrip").animate ({left: ((n-thumbs)*-(thumbWidth))+space}, 0);
         				}else{
         				sym.getSymbol("slider").$("buttonstrip").animate ({left: (next*-(thumbWidth))+space}, ttime);
         				}
         			}else{  
         			//forward button
         			next = id+1;
         				if(next>0){
         				sym.$("mainBtn0").show();
         				sym.$("stripBtn0").show();
         				}
         				if(next<n-thumbs-1){
         				sym.$("stripBtn1").show();
         				}
         				if(next>n-thumbs-1){
         				sym.$("stripBtn1").hide();
         				}
         				if(next>n-2){
         				sym.$("mainBtn1").hide();
         				}
         				if (id<n-thumbs){
         				sym.getSymbol("slider").$("buttonstrip").animate ({left: (next*-(thumbWidth))+space}, ttime);
         				}
         			}
         			   keya = $(xml).find('keya'+next).text();
                 		sym.$("keyaTxt").html(keya);
         			   keyb = $(xml).find('keyb'+next).text();
                 		sym.$("keybTxt").html(keyb);
         			   mauritania = $(xml).find('mauritania'+next).text();
                 		sym.$("mauritaniaTxt").html(mauritania);
         			   algeria = $(xml).find('algeria'+next).text();
                 		sym.$("algeriaTxt").html(algeria);
         			   niger = $(xml).find('niger'+next).text();
                 		sym.$("nigerTxt").html(niger);
         			   burkina = $(xml).find('burkina'+next).text();
                 		sym.$("burkinaTxt").html(burkina);
          			   ghana = $(xml).find('ghana'+next).text();
                 		sym.$("ghanaTxt").html(ghana);
         			   guinea = $(xml).find('guinea'+next).text();
                 		sym.$("guineaTxt").html(guinea);
         			   mali = $(xml).find('mali'+next).text();
                 		sym.$("maliTxt").html(mali);
         			   sahara = $(xml).find('sahara'+next).text();
                 		sym.$("saharaTxt").html(sahara);
         			   scalekm = $(xml).find('scalekm'+next).text();
                 		sym.$("scalekmTxt").html(scalekm);
         			   scalemile = $(xml).find('scalemile'+next).text();
                 		sym.$("scalemileTxt").html(scalemile);
         			   taoudenni = $(xml).find('taoudenni'+next).text();
                 		sym.$("taoudenniTxt").html(taoudenni);
         			   timbuktu = $(xml).find('timbuktu'+next).text();
                 		sym.$("timbuktuTxt").html(timbuktu);
         			   kidal = $(xml).find('kidal'+next).text();
                 		sym.$("kidalTxt").html(kidal);
         			   gao = $(xml).find('gao'+next).text();
                 		sym.$("gaoTxt").html(gao);
         			   lere = $(xml).find('lere'+next).text();
                 		sym.$("lereTxt").html(lere);
         			   diabaly = $(xml).find('diabaly'+next).text();
                 		sym.$("diabalyTxt").html(diabaly);
         			   douentza = $(xml).find('douentza'+next).text();
                 		sym.$("douentzaTxt").html(douentza);
         			   mopti = $(xml).find('mopti'+next).text();
                 		sym.$("moptiTxt").html(mopti);
         			   konna = $(xml).find('konna'+next).text();
                 		sym.$("konnaTxt").html(konna);
         			   segou = $(xml).find('segou'+next).text();
                 		sym.$("segouTxt").html(segou);
         			   bamako = $(xml).find('bamako'+next).text();
                 		sym.$("bamakoTxt").html(bamako);
                		caption = $(xml).find('caption'+next).text();
                 		sym.$("captionTxt").html(caption);
                		captionb = $(xml).find('captionb'+next).text();
                 		sym.$("captionbTxt").html(captionb);
                 		logi = $(xml).find('logi'+next).text();
                 		sym.$("logiTxt").html(logi);
                 		ecowas = $(xml).find('ecowas'+next).text();
                 		sym.$("ecowasTxt").html(ecowas);
                 		nos = $(xml).find('nos'+next).text();
                 		sym.$("nosTxt").html(nos);
                 		order = $(xml).find('order'+next).text();
                 		sym.$("orderTxt").html(order);
         
         			for (var i=0; i<n; i++){
         				if (i==next){
         				mainPic.attr("src","images/pic_"+next+".jpg");
         				sym.getSymbol("slider").getSymbol("buttonstrip").$("btn"+next).css({"border-width":"3px","border-style":"solid","border-color":"rgba(100,100,100,0.75)"});
         				}else{
         				sym.getSymbol("slider").getSymbol("buttonstrip").$("btn"+i).css({"border-width":"3px","border-style":"solid","border-color":"rgba(100,100,100,0)"});
         				}
         			}
         				sym.setVariable("number", next);
         				//sym.getSymbol("slider").$("buttonstrip").animate ({left: (thumbs*s*-(thumbWidth))+space}, ttime);		
                        }
             		});
         			e.preventDefault()
         }
         
         
         
         //CREATE BACK AND FORWARD BUTTONS on BUTTONSTRIP
         var btnArray = ["stripBtn0","stripBtn1"]; // back and forward buttons
         		for (var b=0; b<btnArray.length; b++){
         		sym.$("stripBtn"+b).bind('click', stripbtnClick);
         		//sym.$("stripBtn"+i).bind('mouseover', btnShow);
         		//sym.$("stripBtn"+i).bind('mouseout', btnHide);
         		}
         
         function stripbtnClick() {
         			var selected_id = $(this).attr("id");
         			var s = sym.getVariable("strip");
         		if(selected_id == "Stage_stripBtn0"){ //back button
         			if (s>0){ if (s<=i){ sym.$("stripBtn0").hide(); }else{ sym.$("stripBtn0").show(); } s=s-1;
         			}else{ s=0; 	sym.$("stripBtn0").hide(); }
         			sym.getSymbol("slider").$("buttonstrip").animate ({left: (thumbs*s*-(thumbWidth))+space}, ttime);
         			sym.$("stripBtn1").show(); 
         		}else{  //forward button
         			if (s>(n/thumbs)-2){ s= Math.floor(n/thumbs); 
         			sym.getSymbol("slider").$("buttonstrip").animate ({left: ((n-thumbs)*-(thumbWidth))+space}, ttime);
         			sym.$("stripBtn1").hide();
         			}else{ s=s+1; sym.getSymbol("slider").$("buttonstrip").animate ({left: (thumbs*s*-(thumbWidth))+space}, ttime); sym.$("stripBtn1").show();
         			}
         			sym.$("stripBtn0").show(); 
         
         		}
         		sym.setVariable("strip", s);
         		e.preventDefault()
         		}
         
         //CREATE THUMBNAIL IMAGE BUTTONS
         for (var j=0; j<n; j++){
         		sym.getSymbol("slider").getSymbol("buttonstrip").$("btn"+j).bind('click', thClick);
         		sym.getSymbol("slider").getSymbol("buttonstrip").$("btn"+j).css({"border-width":"3px","border-style":"solid","border-color":"rgba(100,100,100,0)"});
         		}
         
         function thClick() {
         			var selected_id = $(this).attr("id");
         			$.ajax({    
             				type: "GET",
             				url: "GN30196.xml",
             				dataType: "xml",
             				success: function(xml) {
         					for (var i=0; i<n; i++){
         						if(selected_id == "Stage_slider_buttonstrip_btn" + i){
         						keya = $(xml).find('keya' + i).text();
                 				sym.$("keyaTxt").html(keya);    
         						keyb = $(xml).find('keyb' + i).text();
                 				sym.$("keybTxt").html(keyb);    
         						mauritania = $(xml).find('mauritania' + i).text();
                 				sym.$("mauritaniaTxt").html(mauritania);    
          						algeria = $(xml).find('algeria' + i).text();
                 				sym.$("algeriaTxt").html(algeria);    
         						niger = $(xml).find('niger' + i).text();
                 				sym.$("nigerTxt").html(niger);    
         						burkina = $(xml).find('burkina' + i).text();
                 				sym.$("burkinaTxt").html(burkina);    
         						ghana = $(xml).find('ghana' + i).text();
                 				sym.$("ghanaTxt").html(ghana);    
         						guinea = $(xml).find('guinea' + i).text();
                 				sym.$("guineaTxt").html(guinea);    
         						mali = $(xml).find('mali' + i).text();
                 				sym.$("maliTxt").html(mali);    
         						sahara = $(xml).find('sahara' + i).text();
                 				sym.$("saharaTxt").html(sahara);    
         						scalekm = $(xml).find('scalekm' + i).text();
                 				sym.$("scalekmTxt").html(scalekm);    
         						scalemile = $(xml).find('scalemile' + i).text();
                 				sym.$("scalemileTxt").html(scalemile);    
         						taoudenni = $(xml).find('taoudenni' + i).text();
                 				sym.$("taoudenniTxt").html(taoudenni);    
         						timbuktu = $(xml).find('timbuktu' + i).text();
                 				sym.$("timbuktuTxt").html(timbuktu);    
         						kidal = $(xml).find('kidal' + i).text();
                 				sym.$("kidalTxt").html(kidal);    
         						gao = $(xml).find('gao' + i).text();
                 				sym.$("gaoTxt").html(gao);    
         						lere = $(xml).find('lere' + i).text();
                 				sym.$("lereTxt").html(lere);    
         						diabaly = $(xml).find('diabaly' + i).text();
                 				sym.$("diabalyTxt").html(diabaly);    
         						douentza = $(xml).find('douentza' + i).text();
                 				sym.$("douentzaTxt").html(douentza);    
         						mopti = $(xml).find('mopti' + i).text();
                 				sym.$("moptiTxt").html(mopti);    
         						konna = $(xml).find('konna' + i).text();
                 				sym.$("konnaTxt").html(konna);    
         						segou = $(xml).find('segou' + i).text();
                 				sym.$("segouTxt").html(segou);    
         						bamako = $(xml).find('bamako' + i).text();
                 				sym.$("bamakoTxt").html(bamako);    
                				caption = $(xml).find('caption' + i).text();
                 				sym.$("captionTxt").html(caption);
                				captionb = $(xml).find('captionb' + i).text();
                 				sym.$("captionbTxt").html(captionb);
                 				logi = $(xml).find('logi' + i).text();
                 				sym.$("logiTxt").html(logi);
                 				ecowas = $(xml).find('ecowas' + i).text();
                 				sym.$("ecowasTxt").html(ecowas);
                 				nos = $(xml).find('nos' + i).text();
                 				sym.$("nosTxt").html(nos);
                 				order = $(xml).find('order' + i).text();
                 				sym.$("orderTxt").html(order);
         						sym.getSymbol("slider").getSymbol("buttonstrip").$("btn"+i).css({"border-width":"3px","border-style":"solid","border-color":"rgba(100,100,100,0.75)"});
         						mainPic.attr("src","images/pic_"+i+".jpg");
         							if(i>0){ sym.$("mainBtn0").show(); sym.$("stripBtn0").show(); }//show back button once selected image is past the first
         							if(i<1){ sym.$("mainBtn0").hide(); sym.$("stripBtn0").hide(); }//hide back button if first image is selected
         							if(i<n-thumbs-1){ sym.$("stripBtn1").show(); }	//hide forward button if last image is selected
         							if(i>n-thumbs-1){ sym.$("stripBtn1").hide(); }	//hide forward button if last image is selected	
         							if(i>n-2){ sym.$("mainBtn1").hide(); }	//hide forward button if last image is selected	
         							if(i<n-1){ sym.$("mainBtn1").show(); }	//show forward button if selected image is before the last
         							//move strip horizontally
         							if (i<n-thumbs+1){ sym.getSymbol("slider").$("buttonstrip").animate ({left: (i*-(thumbWidth))+space}, ttime); 
         							}else{ sym.getSymbol("slider").$("buttonstrip").animate ({left: ((n-thumbs)*-(thumbWidth))+space}, ttime);	}
         						sym.setVariable("strip", Math.floor(i/thumbs));
         						sym.setVariable("number", i);
         						}else{				
         					sym.getSymbol("slider").getSymbol("buttonstrip").$("btn"+i).css({"border-width":"3px","border-style":"solid","border-color":"rgba(100,100,100,0)"});
         					}
         			}
                         }
             			});
         		e.preventDefault()
         		}
         
         sym.$("mainBtn0").hide();
         sym.$("stripBtn0").hide();

      });
      //Edge binding end

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      

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

//=========================================================

//Edge symbol: 'backBtn'
(function(symbolName) {

















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

//=========================================================

//Edge symbol: 'forwardBtn'
(function(symbolName) {

















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

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

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

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

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