/*****************************************************************/
/* Importing story data and managin it                           */

console.log(story.A001.title);
console.log(story.A001.description);
for ( var conseq in story.A001.conseq_ref)
console.log(conseq.ref);


window.ref = "A001"; //Init first step

function story_manager(){
    var interfaceBlock = document.getElementById('interfaceBlock');
    interfaceBlock.style.display = "block";
    //Display story in interface

    description.innerHTML = story[window.ref].description;
    title.innerHTML = story[window.ref].title;
    
    document.getElementById('conseq_ref').innerHTML = ""; // Erase the content before adding
    for ( var conseq in story[window.ref].conseq_ref){
    	/* Create a li element to host a choice */
    	var li = document.createElement('li');
    	document.getElementById('conseq_ref').appendChild(li);
    	var button = document.createElement('button');
    	button.setAttribute('onclick', "function update(){ window.ref = \"" + story[window.ref].conseq_ref[conseq][0] + "\"; story_manager();} update()"); 
    	button.setAttribute('data-conseq_ref',story[window.ref].conseq_ref[conseq][0]); 
    	button.setAttribute('data-location',story[window.ref].conseq_ref[conseq][2]); 
    	li.appendChild(button);

    	/* Bind a choice to the li element */
    	var choice = document.createTextNode(story[window.ref].conseq_ref[conseq][1]);
    	button.appendChild(choice);

        /** Bind choice to marker type **/
        if(story[window.ref].conseq_ref[conseq][2] === "musees"){  // !! Check if correct !!
                   museesLayer.on('click', function(){
                    window.ref = story[window.ref].conseq_ref[conseq][0];
                    story_manager();
                }); 
        }
        else if(story[window.ref].conseq_ref[conseq][2] === "commissariat"){
                   commissariatsLayer.on('click', function(){
                    window.ref = story[window.ref].conseq_ref[conseq][0];
                    story_manager();
                }); 
        }
        else if(story[window.ref].conseq_ref[conseq][2] === "hopitaux"){
                   hopitauxLayer.on('click', function(){
                    window.ref = story[window.ref].conseq_ref[conseq][0];
                    story_manager();
                }); 
        }
        else{
            
        }

    }
}


@@ -134,146 +134,8 @@
 */%0A%0A
-console.log(story.A001.title);%0Aconsole.log(story.A001.description);%0Afor ( var conseq in story.A001.conseq_ref)%0Aconsole.log(conseq.ref);%0A%0A%0A
 wind
@@ -1471,26 +1471,94 @@
     
-       museesLayer
+for (var i = 0; i %3C musees.features.length; i++) %7B%0A                    markerMusees%5Bi%5D
 .on(
@@ -1700,32 +1700,46 @@
              %7D);
+%0A            %7D
  %0A        %7D%0A    
@@ -1827,33 +1827,108 @@
     
-       commissariatsLayer
+for (var i = 0; i %3C commissariats.features.length; i++) %7B%0A                    markerCommissariats%5Bi%5D
 .on(
@@ -2070,32 +2070,46 @@
              %7D);
+%0A            %7D
  %0A        %7D%0A    
@@ -2193,28 +2193,534 @@
     
-       hopitauxLayer
+for (var i = 0; i %3C hopitaux.features.length; i++) %7B%0A                    markerHopitaux%5Bi%5D.on('click', function()%7B%0A                    window.ref = story%5Bwindow.ref%5D.conseq_ref%5Bconseq%5D%5B0%5D;%0A                    story_manager();%0A                %7D); %0A            %7D%0A        %7D%0A        else if(story%5Bwindow.ref%5D.conseq_ref%5Bconseq%5D%5B2%5D === %22bar%22)%7B%0A            for (var i = 0; i %3C pub.elements.length; i++) %7B %0A                if(pub.elements%5Bi%5D.lat && pub.elements%5Bi%5D.lon)%7B //Protect if data corrumpted%0A%0A                    markerPub%5Bi%5D
 .on(
@@ -2859,36 +2859,123 @@
                 
-%7D); 
+    //console.log('Pub click');%0A                    %7D); %0A                %7D   %0A            %7D
 %0A        %7D%0A     

Update marker events with new implementation