// Stateless function to create the marker and set up the event window
function addMarkerParty(
    point, 
    Icon,
    gmarkersTmp,
    index,
    mapTmp,
    boundsTmp,
    height, 
    summaryUrl,
    fullUrl) {
  var marker = new GMarker(point, Icon);
  GEvent.addListener(marker, "click", function() {
    var maxContentDiv = document.createElement('div');
    maxContentDiv.innerHTML = 'Loading...'
    
    //first show a loading message // - this width and height are the value of the "loading" screen that stays very shortly
    marker.openInfoWindowHtml('<div style="width:200px;height:' + height + '">Loading...</div>');
    GDownloadUrl(summaryUrl, 
      function(data) {
        marker.openInfoWindowHtml(data,
        {maxContent: maxContentDiv, 
         maxTitle: ''});
      }); 
    
    var iw = map.getInfoWindow();
    GEvent.addListener(iw, "maximizeclick", function() {
        GDownloadUrl(fullUrl, 
        function(data) {
          maxContentDiv.innerHTML = data;
        });
      });      
  });
  
  mapTmp.addOverlay(marker);
  // ==== Each time a point is found, extent the bounds to include it =====
  boundsTmp.extend(point);
  
  // save the info we need to use later for the side_bar
  gmarkersTmp[index] = marker;
  return gmarkersTmp;
}

//This function picks up the click and opens the corresponding info window
function myPartyClick(gmarkersTmp, i) {
  GEvent.trigger(gmarkersTmp[i], "click");
}

function myPartyHighlight(gmarkers, i) {
  gmarkers[i].setImage('/images/yellow.png');
}

function myPartyUnHighlight(gmarkers, i) {
  gmarkers[i].setImage('/images/red.png'); 
}

//function myPartyZoomIn(map, gmarkers, i) {
//  var p = gmarkers[i].getPoint();
//  map.setCenter(p);
//  map.setZoom(16);
//  GEvent.trigger(gmarkers[i], "click");//to move the map to see the infowindow
//}
//
//function myPartyZoomOut(map, gmarkers, i) {
//  map.setCenter(savedCenter);
//  map.setZoom(savedZoom);
//  GEvent.trigger(gmarkers[i], "click");//to move the map to see the infowindow
//}