/***********************
* 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.bindSymbolAction(compId, symbolName, "creationComplete", function(sym, e) {
         sym.$('.center-wrapper').css("overflow","hidden");

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "document", "compositionReady", function(sym, e) {
         $(".animales").css("pointer-events","none");
         
         var soundId = "Audio_1";
         
         contadorJuego = 1;
         
         $(".animales").click(function(){
         	var idAnimal = $(this).prop("id").slice(16);
         
         	if(idAnimal == 1 && contadorJuego == 1){
         		$("#Stage_slide_1_b_"+idAnimal).fadeIn();
            	sym.getComposition().getStage().$(soundId)[0].muted = false;
            	sym.getComposition().getStage().$(soundId)[0].currentTime = 0;
         		sym.getComposition().getStage().$(soundId)[0].volume=0.7;
            	sym.getComposition().getStage().$(soundId)[0].play();
            	setTimeout(function(){
           			sym.getComposition().getStage().$(soundId)[0].pause();
           			sym.getComposition().getStage().$(soundId)[0].currentTime = 0;			
         		}, 1600);
         		contadorJuego++;
            }
            else if(idAnimal == 6 && contadorJuego == 2){
            	$("#Stage_slide_1_b_"+idAnimal).fadeIn();
            	sym.getComposition().getStage().$(soundId)[0].muted = false;
            	sym.getComposition().getStage().$(soundId)[0].currentTime = 2;
         		sym.getComposition().getStage().$(soundId)[0].volume=0.7;
            	sym.getComposition().getStage().$(soundId)[0].play();
            	setTimeout(function(){
           			sym.getComposition().getStage().$(soundId)[0].pause();
           			sym.getComposition().getStage().$(soundId)[0].currentTime = 0;				
         		}, 1600);
         		contadorJuego++;
            }
            else if(idAnimal == 4 && contadorJuego == 3){
            	$("#Stage_slide_1_b_"+idAnimal).fadeIn();
            	sym.getComposition().getStage().$(soundId)[0].muted = false;
            	sym.getComposition().getStage().$(soundId)[0].currentTime = 4;
         		sym.getComposition().getStage().$(soundId)[0].volume=0.7;
            	sym.getComposition().getStage().$(soundId)[0].play();
            	setTimeout(function(){
           			sym.getComposition().getStage().$(soundId)[0].pause();
           			sym.getComposition().getStage().$(soundId)[0].currentTime = 0;				
         		}, 1400);
         		contadorJuego++;
            }
            else if(idAnimal == 2 && contadorJuego == 4){
            	$("#Stage_slide_1_b_"+idAnimal).fadeIn();
            	sym.getComposition().getStage().$(soundId)[0].muted = false;
            	sym.getComposition().getStage().$(soundId)[0].currentTime = 5.5;
         		sym.getComposition().getStage().$(soundId)[0].volume=0.7;
            	sym.getComposition().getStage().$(soundId)[0].play();
            	setTimeout(function(){
           			sym.getComposition().getStage().$(soundId)[0].pause();
           			sym.getComposition().getStage().$(soundId)[0].currentTime = 0;				
         		}, 1600);
         		contadorJuego++;
            }
            else if(idAnimal == 5 && contadorJuego == 5){
            	$("#Stage_slide_1_b_"+idAnimal).fadeIn();
            	sym.getComposition().getStage().$(soundId)[0].muted = false;
            	sym.getComposition().getStage().$(soundId)[0].currentTime = 7;
         		sym.getComposition().getStage().$(soundId)[0].volume=0.7;
            	sym.getComposition().getStage().$(soundId)[0].play();
            	setTimeout(function(){
           			sym.getComposition().getStage().$(soundId)[0].pause();	
           			sym.getComposition().getStage().$(soundId)[0].currentTime = 0;			
         		}, 2800);
         		contadorJuego++;
            }
            else if(idAnimal == 3 && contadorJuego == 6){
            	$("#Stage_slide_1_b_"+idAnimal).fadeIn();
            	sym.getComposition().getStage().$(soundId)[0].muted = false;
            	sym.getComposition().getStage().$(soundId)[0].currentTime = 10;
         		sym.getComposition().getStage().$(soundId)[0].volume=0.7;
            	sym.getComposition().getStage().$(soundId)[0].play();
            	setTimeout(function(){
           			sym.getComposition().getStage().$(soundId)[0].pause();	
           			sym.getComposition().getStage().$(soundId)[0].currentTime = 0;			
         		}, 1800);
         		sym.$("resp_correcta").show();
         		setTimeout('$("#Stage_resp_correcta").fadeOut("slow");', 2500);
            }
            else{   	
            	$(".animales").css("pointer-events","none");
            	$('[id^="Stage_slide_1_b_"]').fadeOut();
            	contadorJuego = 1;
         		sym.$("resp_incorrecta").show();		
         		setTimeout('$("#Stage_resp_incorrecta").fadeOut("slow");', 1800);
            }
         
         
         });

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_bt_reiniciar}", "click", function(sym, e) {
         var soundId = "Audio_1";
         
         $(".animales").css("pointer-events","none");
         $('[id^="Stage_slide_1_b_"]').fadeOut();
         contadorJuego = 1;
         sym.getComposition().getStage().$(soundId)[0].pause();
         sym.getComposition().getStage().$(soundId)[0].currentTime = 0;	
         /*
         var BtAudio = sym.getComposition().getStage().getSymbol("slide_1").$("bt_audio");
         sym.$(BtAudio).stop("up");
         console.log(BtAudio);
         */

      });
      //Edge binding end

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

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

   //=========================================================
   
   //Edge symbol: 'slide_5'
   (function(symbolName) {   
   
      Symbol.bindTriggerAction(compId, symbolName, "Default Timeline", 0, function(sym, e) {
         //CAMBIAR ESTA OPCIÓN A PLAY SI SE DESEA INICIAR LA ANIMACIÓN O SI ES IMAGEN FIJA PONERLA EN STOP 
         sym.play();

      });
      //Edge binding end

      

      

      

      

      

      

      

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

      });
      //Edge binding end

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

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

      });
      //Edge binding end

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

      });
      //Edge binding end

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

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

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

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

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

   //=========================================================
   
   //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");
         $(".animales").css("pointer-events","auto");
         });
         //console.log("currentAudio="+currentAudio);
         //console.log("duracion="+duracion); 
         
         $("audio").prop("muted", true);
         
         	if (sym.getComposition().getStage().$(soundId)[0].paused) {
         	//elimina el mute del audio
         	sym.getComposition().getStage().$(soundId)[0].muted = false;
         	sym.getComposition().getStage().$(soundId)[0].volume=0.7;
         	sym.getComposition().getStage().$(soundId)[0].play();
         	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: 'bt_reiniciar'
   (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

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

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