Pdf/BaladeNature/Js/balade_nature.js
changeset 94 d8344a68c91f
parent 74 58e48a5c5ca2
child 124 f0f5895259d9
--- a/Pdf/BaladeNature/Js/balade_nature.js	mar. avril 16 12:31:08 2013 +0200
+++ b/Pdf/BaladeNature/Js/balade_nature.js	mar. avril 23 08:31:19 2013 +0200
@@ -10,27 +10,28 @@
 window.addEvent('domready', function(){
     // Hotspots
     (function initialize() {
-        var scenario;
-        var content;
         $$(".pdocHotspot").each(function(hotspot) {
-            scenario = hotspot.getElement("span");
-            content = $(hotspot.get('id').replace("x", "z"))
-            if (scenario && content) {
-                
+            var spot = $(hotspot.get('id') + "s")
+            var scenario = hotspot.getElement("span");
+            if (spot && scenario) {
                 hotspot.addEvent("click", function() {
-                    var content = $(this.get('id').replace("x", "z"));
-                    content.setStyles({"opacity": 0, "display": "block"});
+                    var spot = $(this.get('id') + "s");
+                    if (spot.getChildren("img")) {
+                        spot.setStyles({"opacity": 1, "display": "block"});
+                    } else {
+                        spot.setStyles({"opacity": 0, "display": "block"});
+                        spot.tween("opacity", 1);
+                    }
                     this.setStyle("display", "none");
-                    content.tween("opacity", 1);
                     (function() {
-                        content.setStyle("display", "none");
+                        spot.setStyle("display", "none");
                         hotspot.setStyle("display", "block");
                     }).delay(12000);
                 });
 
-                content.addEvent("click", function() {
+                spot.addEvent("click", function() {
                     this.setStyle("display", "none");
-                    $(this.get('id').replace("z", "x"))
+                    $(this.get('id').substring(0, this.get('id').length-1))
                         .setStyle("display", "block");
                 });
             }