/***********************
* 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) {        
                //Colocar la cantidad de puntos a obtener
                sym.setVariable("Elementos", 9);				         
                sym.setVariable("lef01", sym.$("Drag_1").css("left"));
                sym.setVariable("top01", sym.$("Drag_1").css("top"));
                sym.setVariable("lef02", sym.$("Drag_2").css("left"));
                sym.setVariable("top02", sym.$("Drag_2").css("top"));
                sym.setVariable("lef03", sym.$("Drag_3").css("left"));
                sym.setVariable("top03", sym.$("Drag_3").css("top"));
                sym.setVariable("lef04", sym.$("Drag_4").css("left"));
                sym.setVariable("top04", sym.$("Drag_4").css("top"));
                sym.setVariable("lef05", sym.$("Drag_5").css("left"));
                sym.setVariable("top05", sym.$("Drag_5").css("top"));
                sym.setVariable("lef06", sym.$("Drag_6").css("left"));
                sym.setVariable("top06", sym.$("Drag_6").css("top"));
                sym.setVariable("lef07", sym.$("Drag_7").css("left"));
                sym.setVariable("top07", sym.$("Drag_7").css("top"));
                sym.setVariable("lef08", sym.$("Drag_8").css("left"));
                sym.setVariable("top08", sym.$("Drag_8").css("top"));
                sym.setVariable("lef09", sym.$("Drag_9").css("left"));
                sym.setVariable("top09", sym.$("Drag_9").css("top"));
                
                //establecer el valor de un símbolo de variable
                sym.setVariable("DragVar1", 0);
                sym.setVariable("DragVar2", 0);
                sym.setVariable("DragVar3", 0);
                sym.setVariable("DragVar4", 0);
                sym.setVariable("DragVar5", 0);
                sym.setVariable("DragVar6", 0);
                sym.setVariable("DragVar7", 0);
                sym.setVariable("DragVar8", 0);
                sym.setVariable("DragVar9", 0);
                
                sym.setVariable("DropVar1", 0);
                sym.setVariable("DropVar2", 0);
                sym.setVariable("DropVar3", 0);
                sym.setVariable("DropVar4", 0);
                sym.setVariable("DropVar5", 0);
                sym.setVariable("DropVar6", 0);
                sym.setVariable("DropVar7", 0);
                sym.setVariable("DropVar8", 0);
                sym.setVariable("DropVar9", 0);
                
                // Define the Variables
                var Drag_1 = sym.$('Drag_1');
                var Drag_2 = sym.$('Drag_2');
                var Drag_3 = sym.$('Drag_3');
                var Drag_4 = sym.$('Drag_4');
                var Drag_5 = sym.$('Drag_5');
                var Drag_6 = sym.$('Drag_6');
                var Drag_7 = sym.$('Drag_7');
                var Drag_8 = sym.$('Drag_8');
                var Drag_9 = sym.$('Drag_9');
                
                var Drop_1 = sym.$('Drop_1');
                var Drop_2 = sym.$('Drop_2');
                var Drop_3 = sym.$('Drop_3');
                var Drop_4 = sym.$('Drop_4');
                var Drop_5 = sym.$('Drop_5');
                var Drop_6 = sym.$('Drop_6');
                var Drop_7 = sym.$('Drop_7');
                var Drop_8 = sym.$('Drop_8');
                var Drop_9 = sym.$('Drop_9');
                
                // Mostrar un elemento.    
                
          // Mostrar un elemento.    
          
          sym.$('[id^="Stage_Drag_"]').draggable({
         start: function(event, ui) {
         ui.draggable.css('-ms-touch-action', 'none' );
         },
         	containment: '#Stage_container', 
         	opacity: 0.4,
         	zIndex: 100,
         	cursor:'pointer',		
         	refreshPositions: true,
         	snap:true,
         	snapMode: "inner",
         	helper: "clone",
         	//revert: "invalid",
         	//revertDuration: 200,
         	iframeFix: true
         });
         sym.$('[id^="Stage_Drop_"]').droppable({
                	greedy: true, 
                	tolerance: "intersect",
                	//eventos
         drop: function(event, ui){
         	ui.draggable.css('-ms-touch-action', 'none' );
             ui.draggable.position( { of: $(this), my: 'center', at: 'middle' } );
         }, 
         });
         
         // Make variables draggable
               // Make variables draggable
                Drag_1.draggable({
                start: function(event, ui) {
                if (ui.helper.attr('id')=="Stage_Drag_1") {
                			sym.setVariable("DragVar1", 0);	}	
                	}
         
                });
         
                Drag_2.draggable ({
                start: function(event, ui) {
                	if (ui.helper.attr('id')=="Stage_Drag_2") {
                			sym.setVariable("DragVar2", 0);	}	
                	}
         
                });
         
                Drag_3.draggable ({
                	start: function(event, ui) {
                	if (ui.helper.attr('id')=="Stage_Drag_3") {
                			sym.setVariable("DragVar3", 0);	}	
                	}
         
                });
         
                Drag_4.draggable ({
                	start: function(event, ui) {
                	if (ui.helper.attr('id')=="Stage_Drag_4") {
                			sym.setVariable("DragVar4", 0);	}	
                	}
         
                });
         
                Drag_5.draggable ({
                	start: function(event, ui) {
                	if (ui.helper.attr('id')=="Stage_Drag_5") {
                			sym.setVariable("DragVar5", 0);	}	
                	}
         
                });
         
                Drag_6.draggable ({
                		start: function(event, ui) {
                	if (ui.helper.attr('id')=="Stage_Drag_6") {
                				sym.setVariable("DragVar6", 0);	}	
                	}
         
                });
         
                Drag_7.draggable ({
                		start: function(event, ui) {
                	if (ui.helper.attr('id')=="Stage_Drag_7") {
                				sym.setVariable("DragVar7", 0);	}	
                	}
         
                });
         
                Drag_8.draggable ({
                		start: function(event, ui) {
                	if (ui.helper.attr('id')=="Stage_Drag_8") {
                				sym.setVariable("DragVar8", 0);	}	
                	}
         
                });
         
                Drag_9.draggable ({
                		start: function(event, ui) {
                	if (ui.helper.attr('id')=="Stage_Drag_9") {
                				sym.setVariable("DragVar9", 0);		}
                	}
                });
         
         
         
                Drop_1.droppable({
         
                	  drop: function( event, ui ){  
         
                			sym.setVariable("DropVar1", 0);
                			if (ui.draggable.attr('id')=="Stage_Drag_1") {
                				sym.setVariable("DragVar1", 1);
                				sym.setVariable("DropVar1", 1);
                			}
         
                			coordenadas("Drop_1", ui.draggable.attr('id').slice(6));	}
                });	
         
         
                Drop_2.droppable({
                		drop: function( event, ui ){  
         
                		sym.setVariable("DropVar2", 0);
                			if (ui.draggable.attr('id')=="Stage_Drag_2") {
                				sym.setVariable("DragVar2", 1);
                				sym.setVariable("DropVar2", 1);	
                			}
         
                			coordenadas("Drop_2", ui.draggable.attr('id').slice(6));	}
                });	
         
         
                Drop_3.droppable({
                		drop: function( event, ui ){  
         
                		sym.setVariable("DropVar3", 0);
                			if (ui.draggable.attr('id')=="Stage_Drag_3") {
                				sym.setVariable("DragVar3", 1);
                				sym.setVariable("DropVar3", 1);
                			}
                			coordenadas("Drop_3", ui.draggable.attr('id').slice(6));	}
                });	
         
         
                Drop_4.droppable({
                		drop: function( event, ui ){  
         
                		sym.setVariable("DropVar4", 0);
                			if (ui.draggable.attr('id')=="Stage_Drag_4") {
                				sym.setVariable("DragVar4", 1);
                				sym.setVariable("DropVar4", 1);
                			}
         
                			coordenadas("Drop_4", ui.draggable.attr('id').slice(6));	}
                });	
         
         
                Drop_5.droppable({
                		drop: function( event, ui ){  
         
                		sym.setVariable("DropVar5", 0);
                			if (ui.draggable.attr('id')=="Stage_Drag_5") {
                				sym.setVariable("DragVar5", 1);
                				sym.setVariable("DropVar5", 1);
                			}
         
                			coordenadas("Drop_5", ui.draggable.attr('id').slice(6));	}
                });	
         
         
                Drop_6.droppable({
                		drop: function( event, ui ){  
         
                		sym.setVariable("DropVar6", 0);
                			if (ui.draggable.attr('id')=="Stage_Drag_6") {
                				sym.setVariable("DragVar6", 1);
                				sym.setVariable("DropVar6", 1);
                			}
         
                			coordenadas("Drop_6", ui.draggable.attr('id').slice(6));	}
                });	
         
         
                Drop_7.droppable({
                		drop: function( event, ui ){  
         
                		sym.setVariable("DropVar7", 0);
                			if (ui.draggable.attr('id')=="Stage_Drag_7") {
                				sym.setVariable("DragVar7", 1);
                				sym.setVariable("DropVar7", 1);
                			}
                			coordenadas("Drop_7", ui.draggable.attr('id').slice(6));	}
                });	
         
         
                Drop_8.droppable({
                		drop: function( event, ui ){  
         
                		sym.setVariable("DropVar8", 0);
                			if (ui.draggable.attr('id')=="Stage_Drag_8") {
                				sym.setVariable("DragVar8", 1);
                				sym.setVariable("DropVar8", 1);
                			}
                			coordenadas("Drop_8", ui.draggable.attr('id').slice(6));	}
                });	
         
         
                Drop_9.droppable({
                		drop: function( event, ui ){  
         
                		sym.setVariable("DropVar9", 0);
                			if (ui.draggable.attr('id')=="Stage_Drag_9") {
                				sym.setVariable("DragVar9", 1);
                				sym.setVariable("DropVar9", 1);
                			}
         
                			coordenadas("Drop_9", ui.draggable.attr('id').slice(6));	}
                });	
         
         
         
             function coordenadas (Drop, simbolo) {
                varxdrop = sym.$(Drop).css("left");
                varydrop = sym.$(Drop).css("top");
                varxdropanch = sym.$(Drop).css("width");
                varydropalto = sym.$(Drop).css("height");
                varxdropcentro = parseInt(varxdrop) + parseInt(varxdropanch)/2;
                varydropcentro = parseInt(varydrop) + parseInt(varydropalto)/2;
                varxdraganch = sym.$(simbolo).css("width");
                varydragalto = sym.$(simbolo).css("height");
                varxdragcentro = parseInt(varxdraganch)/2;
                varydragcentro = parseInt(varydragalto)/2;
                sym.$(simbolo).css({top: varydropcentro-varydragcentro});
                sym.$(simbolo).css({left: varxdropcentro-varxdragcentro});
                };

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "document", "compositionReady", function(sym, e) {
         //botones
         sym.getSymbol("bt_validar").stop("normal");
         sym.getSymbol("bt_solucion").stop("down");
         sym.getSymbol("bt_reiniciar").stop("down");
         sym.getSymbol("bt_ayuda").stop("normal");
         sym.$("hotspot_validar").show();
         sym.$("hotspot_solucion").hide();
         sym.$("hotspot_reiniciar").hide();
         sym.$("hotspot_ayuda").show();

      });
      //Edge binding end



      Symbol.bindElementAction(compId, symbolName, "${_hotspot_validar}", "click", function(sym, e) {
         //Definición de variables
         var DragVar1 = sym.getVariable("DragVar1");
         var DragVar2 = sym.getVariable("DragVar2");
         var DragVar3 = sym.getVariable("DragVar3");
         var DragVar4 = sym.getVariable("DragVar4");
         var DragVar5 = sym.getVariable("DragVar5");
         var DragVar6 = sym.getVariable("DragVar6");
         var DragVar7 = sym.getVariable("DragVar7");
         var DragVar8 = sym.getVariable("DragVar8");
         var DragVar9 = sym.getVariable("DragVar9");
         
         var DropVar1 = sym.getVariable("DropVar1");
         var DropVar2 = sym.getVariable("DropVar2");
         var DropVar3 = sym.getVariable("DropVar3");
         var DropVar4 = sym.getVariable("DropVar4");
         var DropVar5 = sym.getVariable("DropVar5");
         var DropVar6 = sym.getVariable("DropVar6");
         var DropVar7 = sym.getVariable("DropVar7");
         var DropVar8 = sym.getVariable("DropVar8");
         var DropVar9 = sym.getVariable("DropVar9");
         
         
         var tipoactividad = sym.getVariable("tipoactividad");
         
         var colorok = sym.getVariable("colorok");
         var colorbad = sym.getVariable("colorbad");
         
         Total = DragVar1 + DragVar2 + DragVar3 + DragVar4 + DragVar5 + DragVar6 + DragVar7 + DragVar8 + DragVar9;
         
         //get the value of a Symbol variable
         
         var TotalElementos = sym.getVariable("Elementos");
         
         //Muestra las leyendas
         
         if(Total==TotalElementos){
         	sym.$("resp_correcta").show();
         	//audio correcto
         	sym.$("success")[0].play();
         	//botones
         	sym.getSymbol("bt_validar").stop("down");
         	sym.getSymbol("bt_solucion").stop("down");
         	sym.getSymbol("bt_reiniciar").stop("normal");
         	sym.$("hotspot_validar").hide();
         	sym.$("hotspot_solucion").hide();
         	sym.$("hotspot_reiniciar").show();
         
         }  else {
         	//mensaje respuesta incorrecta
         	sym.$("resp_incorrecta").show();
         	//audio incorrecto
         	sym.$("error")[0].play();
         	//botones
         	sym.$("hotspot_validar").hide();
         	sym.$("hotspot_solucion").show();
         	sym.$("hotspot_reiniciar").show();
         	sym.getSymbol("bt_validar").stop("down");
         	sym.getSymbol("bt_solucion").stop("normal");
         	sym.getSymbol("bt_reiniciar").stop("normal");
         	//sym.$("txt_Respuesta").html (Total + "/" + Punteo);
         
         }

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_hotspot_solucion}", "click", function(sym, e) {
         //botones
         sym.getSymbol("bt_validar").stop("down");
         sym.getSymbol("bt_solucion").stop("down");
         sym.getSymbol("bt_reiniciar").stop("normal");
         sym.$("hotspot_validar").hide();
         sym.$("hotspot_solucion").hide();
         sym.$("hotspot_reiniciar").show();
         
         //Oculta las leyendas
         sym.$("resp_correcta").hide();
         sym.$("resp_incorrecta").hide();
         
         var colorok = sym.getVariable("colorok");
         var fondook = sym.getVariable("fondook");
         
         var tipoactividad = sym.getVariable("tipoactividad");
         
         //Muestra las respuestas correctas
         coordenadas("Drop_1", "Drag_1");
         sym.$("Drop_1").css({color: colorok ,background: fondook})
         coordenadas("Drop_2", "Drag_2");
         sym.$("Drop_2").css({color: colorok ,background: fondook})
         coordenadas("Drop_3", "Drag_3");
         sym.$("Drop_3").css({color: colorok ,background: fondook})
         coordenadas("Drop_4", "Drag_4");
         sym.$("Drop_4").css({color: colorok ,background: fondook})
         coordenadas("Drop_5", "Drag_5");
         sym.$("Drop_5").css({color: colorok ,background: fondook})
         coordenadas("Drop_6", "Drag_6");
         sym.$("Drop_6").css({color: colorok ,background: fondook})
         coordenadas("Drop_7", "Drag_7");
         sym.$("Drop_7").css({color: colorok ,background: fondook})
         coordenadas("Drop_8", "Drag_8");
         sym.$("Drop_8").css({color: colorok ,background: fondook})
         coordenadas("Drop_9", "Drag_9");
         sym.$("Drop_9").css({color: colorok ,background: fondook})
         
         
         function coordenadas (Drop, simbolo) {
         	varxdrop = sym.$(Drop).css("left");
         	varydrop = sym.$(Drop).css("top");
         	varxdropanch = sym.$(Drop).css("width");
         	varydropalto = sym.$(Drop).css("height");
         	varxdropcentro = parseInt(varxdrop) + parseInt(varxdropanch)/2;
         	varydropcentro = parseInt(varydrop) + parseInt(varydropalto)/2;
         	varxdraganch = sym.$(simbolo).css("width");
         	varydragalto = sym.$(simbolo).css("height");
         	varxdragcentro = parseInt(varxdraganch)/2;
         	varydragcentro = parseInt(varydragalto)/2;
         	sym.$(simbolo).css({top: varydropcentro-varydragcentro});
         	sym.$(simbolo).css({left: varxdropcentro-varxdragcentro});
         };

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_hotspot_reiniciar}", "click", function(sym, e) {
         //botones
         	sym.getSymbol("bt_validar").stop("normal");
         	sym.getSymbol("bt_solucion").stop("down");
         	sym.getSymbol("bt_reiniciar").stop("down");
         	sym.$("hotspot_validar").show();
         	sym.$("hotspot_reiniciar").hide();
         	sym.$("hotspot_solucion").hide();  
         //Oculta las leyendas
         sym.$("resp_correcta").hide();
         sym.$("resp_incorrecta").hide();
         
         var colorini = sym.getVariable("colorini");
         var fondoini = sym.getVariable("fondo");
         var tipoactividad = sym.getVariable("tipoactividad");
         
         
         //Reinicia los valores
         sym.$("Drag_1").draggable ({
         	disabled: false,
         });
         sym.$("Drag_2").draggable ({
         	disabled: false,
         });
         sym.$("Drag_3").draggable ({
         	disabled: false,
         });
         sym.$("Drag_4").draggable ({
         	disabled: false,
         });
         sym.$("Drag_5").draggable ({
         	disabled: false,
         });
         sym.$("Drag_6").draggable ({
         	disabled: false,
         });
         sym.$("Drag_7").draggable ({
         	disabled: false,
         });
         sym.$("Drag_8").draggable ({
         	disabled: false,
         });
         sym.$("Drag_9").draggable ({
         	disabled: false,
         });
         
         var lef01 = sym.getVariable("lef01");
         var top01 = sym.getVariable("top01");
         var lef02 = sym.getVariable("lef02");
         var top02 = sym.getVariable("top02");
         var lef03 = sym.getVariable("lef03");
         var top03 = sym.getVariable("top03");
         var lef04 = sym.getVariable("lef04");
         var top04 = sym.getVariable("top04");
         var lef05 = sym.getVariable("lef05");
         var top05 = sym.getVariable("top05");
         var lef06 = sym.getVariable("lef06");
         var top06 = sym.getVariable("top06");
         var lef07 = sym.getVariable("lef07");
         var top07 = sym.getVariable("top07");
         var lef08 = sym.getVariable("lef08");
         var top08 = sym.getVariable("top08");
         var lef09 = sym.getVariable("lef09");
         var top09 = sym.getVariable("top09");
         
         
         
         sym.$("Drop_1").css({color: colorini ,background: fondoini});
         sym.$("Drop_2").css({color: colorini ,background: fondoini});
         sym.$("Drop_3").css({color: colorini ,background: fondoini});
         sym.$("Drop_4").css({color: colorini ,background: fondoini});
         sym.$("Drop_5").css({color: colorini ,background: fondoini});
         sym.$("Drop_6").css({color: colorini ,background: fondoini});
         sym.$("Drop_7").css({color: colorini ,background: fondoini});
         sym.$("Drop_8").css({color: colorini ,background: fondoini});
         sym.$("Drop_9").css({color: colorini ,background: fondoini});
         
         
         sym.$("Drag_1").css({top: top01, left: lef01});
         sym.$("Drag_2").css({top: top02, left: lef02});
         sym.$("Drag_3").css({top: top03, left: lef03});
         sym.$("Drag_4").css({top: top04, left: lef04});
         sym.$("Drag_5").css({top: top05, left: lef05});
         sym.$("Drag_6").css({top: top06, left: lef06});
         sym.$("Drag_7").css({top: top07, left: lef07});
         sym.$("Drag_8").css({top: top08, left: lef08});
         sym.$("Drag_9").css({top: top09, left: lef09});
         
         sym.setVariable("DragVar1", 0);
         sym.setVariable("DragVar2", 0);
         sym.setVariable("DragVar3", 0);
         sym.setVariable("DragVar4", 0);
         sym.setVariable("DragVar5", 0);
         sym.setVariable("DragVar6", 0);
         sym.setVariable("DragVar7", 0);
         sym.setVariable("DragVar8", 0);
         sym.setVariable("DragVar9", 0);
         
         sym.setVariable("DropVar1", 0);
         sym.setVariable("DropVar2", 0);
         sym.setVariable("DropVar3", 0);
         sym.setVariable("DropVar4", 0);
         sym.setVariable("DropVar5", 0);
         sym.setVariable("DropVar6", 0);
         sym.setVariable("DropVar7", 0);
         sym.setVariable("DropVar8", 0);
         sym.setVariable("DropVar9", 0);

      });
      //Edge binding end

      Symbol.bindElementAction(compId, symbolName, "${_hotspot_ayuda}", "click", function(sym, e) {
         // Definir un conmutador para ocultar o mostrar un elemento 
         if (sym.$("help").is(":visible")) {
         	sym.$("help").hide();
         	sym.getSymbol("bt_ayuda").stop("normal");
         } else {
         	sym.$("help").show();
         	sym.getSymbol("bt_ayuda").stop("down");
         }

      });
      //Edge binding end

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

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

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

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

   //=========================================================
   
   //Edge symbol: 'bt_validar'
   (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_validar");
   //Edge symbol end:'bt_validar'

   //=========================================================
   
   //Edge symbol: 'bt_solucion'
   (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_solucion");
   //Edge symbol end:'bt_solucion'

   //=========================================================
   
   //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'

   //=========================================================
   
   //Edge symbol: 'bt_ayuda'
   (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_ayuda");
   //Edge symbol end:'bt_ayuda'

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