title: Strange behavior of marker events in OpenLayer
body: <p>I have markers layer on my map.</p>
  <p>Every time I add a new marker I register it to a mouse-click event:</p>
  <pre><code>var lonlat = new OpenLayers.LonLat(lon,lat);
  var marker = new OpenLayers.Marker(lonlat,icon);
  marker.id = callId;
  
  marker.events.register(&quot;mousedown&quot;, marker, function() {AddPopup(marker.id);});
  
  callMarkers.addMarker(marker);
  </code></pre>
  <p>Sometimes I want to disable/enable the event. so I use these functions:</p>
  <pre><code>function EnableAllMarkers()
  { 
      for (var i in callMarkers.markers)
      {
          callMarkers.markers[i].events.remove(&quot;mousedown&quot;);               
  
          callMarkers.markers[i].events.register(&quot;mousedown&quot;, callMarkers.markers[i],   
  
          function() { AddPopup(callMarkers.markers[i].id); });
      }  
  }
  
  
  function DisableAllMarkers()
  { 
      for (var i in callMarkers.markers)
      {
          callMarkers.markers[i].events.remove(&quot;mousedown&quot;);
      }  
  }
  </code></pre>
  <p>When I use this code I get strange behavior - sometimes a popup opens for the wrong marker.</p>
  <p>I click on marker X and popup Y opens.</p>
  <p>Can someone help me, please?</p>
  <p>Note:<br />
  The reason <code>EnableAllmMarkers</code> first removes the event is because we don't know if <code>DisableAllmMarkers</code> was ever called since a new marker was added. if it was called indeed, remove function will do nothing.</p>