//<![CDATA[

var markerlist = new Object();

function showAddresses() {
  for (i=0; i < addresses.length; i++) {
// added by Zero Computing: icon
      showAddress(addresses[i][0], addresses[i][1], addresses[i][2], addresses[i][3]);
  }
}

// added by Zero Computing: icon
function showAddress(address, htmlInfo, moveToPoint, icon) {
 if (geocoder) {
   geocoder.getLatLng(
     address,
     function(point) {
       if (!point) {        
         document.getElementById("maperror").value = "1";
       } else {              
         if (moveToPoint) {           
           map.setCenter(point, _gmzf);
         }             
         
         if(_gmhm)   
         {
           var marker;
           if(icon != null)
             marker = new GMarker(point,icon);
           else
             marker = new GMarker(point);
           map.addOverlay(marker);
           if (htmlInfo != "") {
             GEvent.addListener(marker, "click", function() {
                marker.openInfoWindowHtml(htmlInfo);
             });              
           }
         }             
       }
     }
   );
  }
}

function showGeopoints() {
  for (i=0; i < geopoints.length; i++) {
// added by Zero Computing: icon
 	  	showGeopoint(geopoints[i][0], geopoints[i][1], geopoints[i][2], geopoints[i][3], geopoints[i][4]);
  }	
}

// added by Zero Computing: icon and markerlist
function showGeopoint(longitude, latitude, htmlInfo, moveToPoint, icon) {
  if (moveToPoint) {
    map.setCenter(new GLatLng(longitude, latitude), _gmzf);
  }
  var marker;
  if(icon != null)
    marker = new GMarker(new GLatLng(longitude, latitude),icon);
  else
    marker = new GMarker(new GLatLng(longitude, latitude));
  map.addOverlay(marker);
  if (htmlInfo != "") {
    GEvent.addListener(marker, "click", function() {
      marker.openInfoWindowHtml(htmlInfo);
    });
     }
    markerlist['G'+i] = marker;
}

function moveToGeopoint(index) {
	map.panTo(new GLatLng(geopoints[index][0], geopoints[index][1]));
}

function moveToAddress(index) {
  moveToAddressEx(addresses[index][0]); 
}

function moveToAddressEx(addressString) {
  if (geocoder) { 
   geocoder.getLatLng(
     addressString,
     function(point) {       
       if (!point) {
         alert("Location not found:" + addressString);
       } else {                                    
          center = point;
          map.panTo(point);           
       }
     });    
  }
}

function moveToAddressDMarker(addressString) {
  if (geocoder) { 
   geocoder.getLatLng(
     addressString,
     function(point) {       
       if (!point) {
         alert("Location not found:" + addressString);
       } else {                                    
          center = point;
          setZoomFactor(14);
          map.panTo(point);  
          addDragableMarker();         
       }
     });    
  }
}

function setZoomFactor(factor) {
	  map.setZoom(factor);
}

function addDragableMarker() {
  if (!marker) {
    marker = new GMarker(center, {draggable: true});
    map.addOverlay(marker);    
       
    GEvent.addListener(marker, "dragend", function() {      
      var tpoint =  marker.getPoint();      
      document.getElementById(updateX).value = tpoint.lat();
      document.getElementById(updateY).value = tpoint.lng();              
  });

  } else {
  	marker.setPoint(center);  	 
  }
  
  var tpoint =  marker.getPoint();      
  document.getElementById(updateX).value = tpoint.lat();
  document.getElementById(updateY).value = tpoint.lng();              
}

// added by Zero Computing
function openGeopointInfo(id)
{
  if(id >= 0 && id < geopoints.length && geopoints[id][2] != "" && markerlist['G'+id] != null)
      markerlist['G'+id].openInfoWindowHtml(geopoints[id][2]);
}

function setGeopointImage(id,url)
{
  if(id >= 0 && id < geopoints.length && markerlist['G'+id] != null)
      markerlist['G'+id].setImage(url);
}

//]]>

