/***********************
* 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 for compositionReady event here
         sym.$("mainDiv").delay (4000).animate({opacity:1},1000);
         sym.$("introMc").delay (4000).animate({opacity:0},1000);
         var menu_arr = ["bornTxt", "captionTxt", "table03Txt", "table04Txt", "table05Txt", "table06Txt", "table07Txt", "table08Txt", "table09Txt", "table10Txt"];
         $.each(menu_arr, function(index, value) {
         sym.$(value).css('line-height', '120%');
         });
         
         var headline;
         var headlinetxt = sym.$("headlineTxt");
         headlinetxt.css('font-weight', '900');
         
         
         
         var order;
         var athlete;
         var nation;
         var born;
         var caption;
         var sources;
         var pictures;
         var tablesubhead01
         var table01;
         var table02;
         var table03;
         var table04;
         var table05;
         
         
         //AJAX retrieves data from xml source specified in url, maps xml variable to DOM object variable
         
         $.ajax({	
         	type: "GET",
         	url: "GN29786.xml",
         	dataType: "xml",
         	success: function(xml) {
         
         		headline = $(xml).find('headline').text();
         		sym.$("headlineTxt").html(headline);
         
         		order = $(xml).find('order1').text();
         		sym.$("orderTxt").html(order);
         
         		athlete = $(xml).find('athlete1').text();
         		sym.$("athleteTxt").html(athlete);
         
         		nation = $(xml).find('nation1').text();
         		sym.$("nationTxt").html(nation);
         
         		born = $(xml).find('born1').text();
         		sym.$("bornTxt").html(born);
         
         		caption = $(xml).find('caption1').text();
         		sym.$("captionTxt").html(caption);
         
         		sources = $(xml).find('sources').text();
         		sym.$("sourcesTxt").html(sources);
         
         		pictures = $(xml).find('pictures').text();
         		sym.$("picturesTxt").html(pictures);
         
         		tablesubhead01 = $(xml).find('tablesubhead01').text();
         		sym.$("tablesubhead01Txt").html(tablesubhead01);
         
         		table01 = $(xml).find('table01').text();
         		sym.$("table01Txt").html(table01);
         
         		table02 = $(xml).find('table02').text();
         		sym.$("table02Txt").html(table02);
         
         		table03 = $(xml).find('table03').text();
         		sym.$("table03Txt").html(table03);
         
         		table04 = $(xml).find('table04').text();
         		sym.$("table04Txt").html(table04);
         
         		table05 = $(xml).find('table05').text();
         		sym.$("table05Txt").html(table05);
         
         		tablesubhead02 = $(xml).find('tablesubhead02').text();
         		sym.$("tablesubhead02Txt").html(tablesubhead02);
         
         		table06 = $(xml).find('table06').text();
         		sym.$("table06Txt").html(table06);
         
         		table07 = $(xml).find('table07').text();
         		sym.$("table07Txt").html(table07);
         
         		table08 = $(xml).find('table08').text();
         		sym.$("table08Txt").html(table08);
         
         		table09 = $(xml).find('table09').text();
         		sym.$("table09Txt").html(table09);
         
         		table10 = $(xml).find('table10').text();
         		sym.$("table10Txt").html(table10);
         
         
         	// cap1 = $(xml).find('cap1').text();
         	// sym.getSymbol("panels").getSymbol("panel1").$("cap1Txt").html(cap1);
         
         
         		}
         	});
         
         
         //set the value of a Symbol variable
         sym.setVariable("number", 1);
         
         
         
         
         

      });
      //Edge binding end

      

      

      

      

      

      

      Symbol.bindElementAction(compId, symbolName, "${_forward_butt}", "click", function(sym, e) {
         var id = sym.getVariable("number");
         var next;
         if(id==23){
         next = 1
         }else{
         next = id+1;
         }
         sym.setVariable("number", next);
         
         var mainPic = sym.$("main_pic");
         var athlete;
         var nation;
         var born;
         var caption;
         var order;
         var img_arr=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23];
         for (var i=0; i<23; i++){
         if (img_arr[i]==next){
         mainPic.attr("src","images/pic_"+next+".jpg");
         sym.$(this.lookupSelector("pic_"+img_arr[i]+"_lite")).show();
         }else{
         sym.$(this.lookupSelector("pic_"+img_arr[i]+"_lite")).hide();
         }
         }
         
         $.ajax({    
             type: "GET",
             url: "GN29786.xml",
             dataType: "xml",
             success: function(xml) {    
                 athlete = $(xml).find('athlete'+next).text();
                 sym.$("athleteTxt").html(athlete);
                 nation = $(xml).find('nation'+next).text();
                 sym.$("nationTxt").html(nation);
                 born = $(xml).find('born'+next).text();
                 sym.$("bornTxt").html(born);
                 caption = $(xml).find('caption'+next).text();
                 sym.$("captionTxt").html(caption);
                 order = $(xml).find('order'+next).text();
                 sym.$("orderTxt").html(order);
                         }
             });

      });
      //Edge binding end

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      Symbol.bindElementAction(compId, symbolName, "${_back_butt}", "click", function(sym, e) {
var id = sym.getVariable("number");
var previous;
if(id==1){
previous = 23
}else{
previous = id-1;
}
sym.setVariable("number", previous);

var mainPic = sym.$("main_pic");
var athlete;
var nation;
var born;
var caption;
var order;
var img_arr=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23];
for (var i=0; i<23; i++){
if (img_arr[i]==previous){
mainPic.attr("src","images/pic_"+previous+".jpg");
sym.$(this.lookupSelector("pic_"+img_arr[i]+"_lite")).show();
}else{
sym.$(this.lookupSelector("pic_"+img_arr[i]+"_lite")).hide();
}
}

$.ajax({    
    type: "GET",
    url: "GN29786.xml",
    dataType: "xml",
    success: function(xml) {    
        athlete = $(xml).find('athlete'+previous).text();
        sym.$("athleteTxt").html(athlete);
        nation = $(xml).find('nation'+previous).text();
        sym.$("nationTxt").html(nation);
        born = $(xml).find('born'+previous).text();
        sym.$("bornTxt").html(born);
        caption = $(xml).find('caption'+previous).text();
        sym.$("captionTxt").html(caption);
        order = $(xml).find('order'+previous).text();
        sym.$("orderTxt").html(order);
                }
    });

      });
      //Edge binding end

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

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

//Edge symbol: 'tab'
(function(symbolName) {
Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 0, function(sym, e) {
// insert code here
sym.stop();
});
//Edge binding end

Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 1000, function(sym, e) {
// insert code here
sym.stop();
});
//Edge binding end












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

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

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 1000, function(sym, e) {
         // insert code here
         sym.stop();

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_forward_butt}", "click", function(sym, e) {
         // insert code for mouse click here
         sym.play("p1");

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_forward_butt}", "touchstart", function(sym, e) {
         // insert code to be run when a user touches the object (for touch devices only)
         sym.play("p1");

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_back_butt}", "click", function(sym, e) {
         // insert code for mouse click here
         sym.playReverse();

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_back_butt}", "touchstart", function(sym, e) {
         // insert code to be run when a user touches the object (for touch devices only)
         sym.playReverse();

      });
      //Edge binding end

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

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

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

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

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

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

//Edge symbol: 'backBtn'
(function(symbolName) {
Symbol.bindElementAction(compId, symbolName, "${_Rectangle}", "mouseover", function(sym, e) {
// insert code for mouse enter here
// stop the timeline at the given position (ms or label)
sym.stop("over");
});
//Edge binding end

Symbol.bindElementAction(compId, symbolName, "${_Rectangle}", "mouseout", function(sym, e) {
// insert code for mouse leave here
// stop the timeline at the given position (ms or label)
sym.stop("off");
});
//Edge binding end






Symbol.bindElementAction(compId, symbolName, "${_Rectangle}", "click", function(sym, e) {
// insert code for mouse clicks here
sym.stop("over");
});
//Edge binding end







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

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

//Edge symbol: 'forwardBtn'
(function(symbolName) {
Symbol.bindElementAction(compId, symbolName, "${_Rectangle}", "mouseover", function(sym, e) {
// insert code for mouse enter here
// stop the timeline at the given position (ms or label)
sym.stop("over");
});
//Edge binding end

Symbol.bindElementAction(compId, symbolName, "${_Rectangle}", "mouseout", function(sym, e) {
// insert code for mouse leave here
// stop the timeline at the given position (ms or label)
sym.stop("off");
});
//Edge binding end






Symbol.bindElementAction(compId, symbolName, "${_Rectangle}", "click", function(sym, e) {
// insert code for mouse clicks here
sym.stop("over");
});
//Edge binding end







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

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

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

//=========================================================
   (function(symbolName) {

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 4000, function(sym, e) {
         // insert code here// play the timeline from the given position (ms or label)
         sym.play("glow");

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_vid_icon}", "click", function(sym, e) {
         // play the timeline from the given position (ms or label)
         sym.play("start");
         // insert code for mouse click here

      });
      //Edge binding end

      

      Symbol.bindElementAction(compId, symbolName, "${_vid_back}", "click", function(sym, e) {
         // play the timeline from the given position (ms or label)
         sym.play("back");

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 6000, function(sym, e) {
         // insert code here
         // stop the timeline at the given position (ms or label)
         sym.stop("off");

      });
      //Edge binding end

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

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

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