/***********************
* Acciones de composición de Adobe Edge Animate
*
* Editar este archivo con precaución, teniendo cuidado de conservar 
* las firmas de función y los comentarios que comienzan con "Edge" para mantener la 
* capacidad de interactuar con estas acciones en Adobe Edge Animate
*
***********************/
(function($, Edge, compId){
var Composition = Edge.Composition, Symbol = Edge.Symbol; // los alias más comunes para las clases de Edge

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

      

      

      

      

      

      

      

      

      

      

      

      

      

      

      

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

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_boton_iniciar}", "click", function(sym, e) {
         // introducir aquí código para clic de ratón
         // Reproducir la línea de tiempo en un momento o etiqueta específicos. Por ejemplo:
         // sym.play(500); o sym.play("myLabel");
         sym.play("A");

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 4920, function(sym, e) {
         sym.stop();
         
         clock = $('#Stage_RELOJ').FlipClock({
         	clockFace: 'MinuteCounter',
         	autoStart: true
         });
         
         $(".flip-clock-label").css({"color":"white","font-size":"18px"});

      });
      //Edge binding end

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

      });
      //Edge binding end

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

      });
      //Edge binding end

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

      });
      //Edge binding end

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

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_boton_A_2}", "click", function(sym, e) {
         sym.$("pop_error").show("slow");
         

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_boton_A_3}", "click", function(sym, e) {
         sym.$("pop_error").show("slow");

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_boton_B_2}", "click", function(sym, e) {
         sym.$("pop_error").show("slow");

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_boton_B_1}", "click", function(sym, e) {
         sym.$("pop_error").show("slow");

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_boton_C_3}", "click", function(sym, e) {
         sym.$("pop_error").show("slow");

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_boton_C_1}", "click", function(sym, e) {
         sym.$("pop_error").show("slow");

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_boton_C_2}", "click", function(sym, e) {
         sym.$("pop_bien").show("slow");
         
         
         clock = $('#Stage_RELOJ').FlipClock({
         	clockFace: 'MinuteCounter',
         	autoStart: false
         });
         
         $('#Stage_RELOJ').hide();
         
         var minutosTotal;
         var segundosRestantes;
         
         if(segundosTotal >=60){
         	minutosTotal = Math.floor(segundosTotal/60);
         	segundosRestantes = segundosTotal%60;
         	$('.relojFinal').append("<br><div style='text-align:center;font-family:Trebuchet MS;font-size:46px;color:white;'>Tardaste "+minutosTotal+" minuto(s) y "+segundosRestantes+" segundo(s)</div>");
         }
         else{
         	$('.relojFinal').append("<br><div style='text-align:center;font-family:Trebuchet MS;font-size:46px;color:white;'>Tardaste "+segundosTotal+" segundos</div>");
         }
         
         
         

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "document", "compositionReady", function(sym, e) {
         
         //$("head").append("<script type='text/javascript' src='js/flipclock.js'></script>");
         $("head").append("<link href='css/flipclock.css' rel='stylesheet' type='text/css'>");
         sym.$("pop_bien").hide();
         
         /*
         clock = $('.Stage_RELOJ_id').FlipClock({
         	clockFace: 'MinuteCounter',
         	running: false
         });
         */

      });
      //Edge binding end

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

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

   //=========================================================
   
   //Edge symbol: 'flecha_bt'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 0, function(sym, e) {
         // introducir código aquí
         sym.stop();

      });
      //Edge binding end

      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 250, function(sym, e) {
         // introducir código aquí
         sym.stop();

      });
      //Edge binding end

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

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

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

   //=========================================================
   
   //Edge symbol: 'bt_audio'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 0, function(sym, e) {
         // introducir código aquí
         sym.stop();

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_ht_spot}", "click", function(sym, e) {
         var soundId = sym.getSymbolElement().attr( "title" );
         var currentAudio=sym.getComposition().getStage().$(soundId)[0].currentTime;
         var duracion= sym.getComposition().getStage().$(soundId).duration;
         console.log("soundId="+soundId);
         if (duracion== currentAudio){
         sym.stop("up");
         }
         
         sym.getComposition().getStage().$(soundId).on('ended', function() {
         sym.stop("up");
            // enable button/link
         });
         
         console.log("currentAudio="+currentAudio);
         console.log("duracion="+duracion);
         // Definir un conmutador para reproducir o pausar una pista de audio 
         if (sym.getComposition().getStage().$(soundId)[0].paused) {
         	sym.getComposition().getStage().$(soundId)[0].play();
         	sym.getComposition().getStage().$(soundId)[0].volume=0.7;
         	sym.stop("down");
         
         } else {
         //activar para pausar en vez de reiniciar
         	sym.getComposition().getStage().$(soundId)[0].pause();
         	sym.stop("up");
         }

      });
      //Edge binding end

      

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

      });
      //Edge binding end

      

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

   //=========================================================
   
   //Edge symbol: 'btn_empezar'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 1167, function(sym, e) {
         sym.play("inicio");

      });
      //Edge binding end

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

   //=========================================================
   
   //Edge symbol: 'reloj_icono'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 870, function(sym, e) {
         sym.play("salto");

      });
      //Edge binding end

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

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

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

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

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

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

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

      });
      //Edge binding end

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

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

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

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

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

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

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

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

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

   //=========================================================
   
   //Edge symbol: 'pop_error'
   (function(symbolName) {   
   
      Symbol.bindElementAction(compId, symbolName, "${_btn_reiniciar}", "click", function(sym, e) {
         sym.getComposition().getStage().play("intro");
         
         clock = $('#Stage_RELOJ').FlipClock({
         	clockFace: 'MinuteCounter',
         	callbacks: {		
         		reset: true
         	}
         });
         
         segundosTotal = 0;

      });
      //Edge binding end

      Symbol.bindSymbolAction(compId, symbolName, "creationComplete", function(sym, e) {
         $('#Stage_RELOJ').hide();

      });
      //Edge binding end

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

   //=========================================================
   
   //Edge symbol: 'btn_reiniciar'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 839, function(sym, e) {
         sym.play("reiniciar");

      });
      //Edge binding end

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

   //=========================================================
   
   //Edge symbol: 'pop_error_1'
   (function(symbolName) {   
      //Edge binding end

      Symbol.bindSymbolAction(compId, symbolName, "creationComplete", function(sym, e) {
         // insert code to be run when the symbol is created here
         
         /*
         clock = $('.relojFinal').FlipClock({
         	clockFace: 'MinuteCounter',
         	start: false
         });
         */
         
         /*
         var data  = [
         				date.getHours(),
         				date.getMinutes(),
         				date.getSeconds()			
         			];
         
         			*/ 
         
         
         

      });
      //Edge binding end

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

})(jQuery, AdobeEdge, "EDGE-94063035");