var cm_mapMarkers = [];
	var cm_baseIcon = new GIcon();
	//cm_baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
	cm_baseIcon.iconSize = new GSize(34, 34);
	cm_baseIcon.shadowSize = new GSize(37, 34);
	cm_baseIcon.iconAnchor = new GPoint(9, 34);
	cm_baseIcon.infoWindowAnchor = new GPoint(9, 2);
	cm_baseIcon.infoShadowAnchor = new GPoint(18, 25);
 
    var map = null;
    var geocoder = null;
	var ai=0;
 
    function initialize() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
		map.setMapType(G_NORMAL_MAP);
		//map.setUIToDefault();
		map.setCenter(new GLatLng(25.091075,121.5598345),11);
        geocoder = new GClientGeocoder();
      }
    }

function cm_setp(aid,title,html){
		geocoder.getLatLng(
          title,
          function(point) {
            if (!point) {
              $("a#"+aid).click(function(){alert("電子地圖無法定位");});
            } else {
			  var marker = cm_createMarker(point,title,html);
			  map.addOverlay(marker);
			  cm_mapMarkers.push(marker);
			  //alert(ai);
              $("a#"+aid).attr("href","javascript:cm_markerClicked("+ai+",'"+html+"');");//click(function(){cm_markerClicked(0,html);});
			  ai++;
			}
		  });
}

	
	
function cm_createMarker(point, title, html) {
  var markerOpts = {};
  var nIcon = new GIcon(cm_baseIcon);
	  nIcon.image = "images/home.png";
	  markerOpts.icon = nIcon;
	  markerOpts.title = title;
	  
  var marker = new GMarker(point, markerOpts);
	
  GEvent.addListener(marker, "click", function() {
	top.location.href=html;
    //marker.openInfoWindowHtml(html);
  });
  return marker;
}
function cm_markerClicked(markerNum,txt) {
  cm_mapMarkers[markerNum].openInfoWindowHtml(txt);
}
 
    function showAddress(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              //alert("電子地圖無法定位: " + address);
            } else {
              map.setCenter(point);
            }
          });
      }
    }