function DiscoverMap(){
	if (GBrowserIsCompatible()) {
		G_HYBRID_MAP.getName=function($short){
			if($short){
				return 'Sat';
			} else {
				return 'Satellite';
			}
		};
		G_PHYSICAL_MAP.getName=function($short){
			if($short){
				return 'Phy';
			} else {
				return '地形';
			}
		};
		G_NORMAL_MAP.getName=function($short){
			if($short){
				return 'Nor';
			} else {
				return '地図';
			}
		};
		//	var _mLastResult = "Reset map position and zoom level"; 
		this.map=new GMap2(document.getElementById('map'), {mapTypes:[G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP, G_PHYSICAL_MAP ]});
		this.map.setCenter(new GLatLng(0, 0), 0, G_NORMAL_MAP);
		
		this.map.addControl(new GHierarchicalMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 7)));
		this.map.addControl(new GLargeMapControl(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7)));
		
		this.clusterer=new ClusterMarker(this.map);
		var $map=this.map, $clusterer=this.clusterer;	//	req'd for function closure
		
		GEvent.addListener($clusterer, 'refreshed', function($status){
			for (var i=$status.length-1; i>=0; i--){
				if($map._activeMarkerIndex===i){ $status[i]+=' active'; }
				document.getElementById('anchor'+i).className=$status[i];
			}
		});
		
		GEvent.addListener($clusterer, 'clustermouseover', function($markers) {
			var i, $id;
			for(i=$markers.length-1; i>=0; i--){
				$id='anchor'+$markers[i].index;
				document.getElementById($id).style.backgroundColor='#8bec4b';	//	use multiple classes instead of individual properties
			}
		});
		GEvent.addListener($clusterer, 'clustermouseout', function($markers) {
			var i, $id;
			for(i=$markers.length-1; i>=0; i--){
				$id='anchor'+$markers[i].index;
				document.getElementById($id).style.backgroundColor='';
			}
		});
		
		GEvent.addListener(this.map, 'infowindowopen', function(){
			var $li=document.getElementById('anchor'+$map._activeMarkerIndex);
			$li.className=$li.className+' active';
		});
		
		GEvent.addListener(this.map, 'infowindowclose', function(){
			var $li=document.getElementById('anchor'+$map._activeMarkerIndex);
			$class=$li.className;
			$class=$class.replace(/\sactive/,'');
			$li.className=$class;
			$map._activeMarkerIndex=false;
		});
		
		GEvent.addListener(this.map, 'moveend', function() { $map._lastCenter=$map.getCenter(); });
		GEvent.addListener(this.map, 'resize', function() { $map.setCenter($map._lastCenter); });
	}
}





DiscoverMap.prototype.getMarkers=function(){
	function createMarker($point,$name,$address,$pin,$type,$args,$icon,$photo,$tel,$holiday,$hour,$uid,$coupon,$model,$job) {

		// STEVE START NEW
		var $newname = $name;
		var $marker=new GMarker($point, {title:$name, icon:customIcons[$type], draggable:false});
		//var $marker=new GMarker($point, iconBlue);
		//	var $marker=new GMarker($args.location, {title:$args.name, icon:$icon});
		// ** POPUP WINDOW INFORMATION ON MARKER - GOES HERE **
		var $html='<div class="infowindow"><h4><a href="/users.php?mode=profile&uid='+$uid+'" target="oya">'+$newname+'</a></h4><table class="ta"><tr>'+$photo+'<td><div class="info"><table>'+$tel+$holiday+$hour+$address+'</table></div></td></tr></table><p>クーポン：<b>'+$coupon+'</b>件　モデル：<b>'+$model+'</b>件　求人：<b>'+$job+'</b>件</p></div>';
		// $marker.index=$args.index;
		$marker.index=$args;
		GEvent.addListener($marker, 'click', function(){
			if($map._activeMarkerIndex!==$marker.index){
				$map.openInfoWindowHtml($marker.getLatLng(), $html, {maxWidth:388});
				$map._activeMarkerIndex=$marker.index;
			} else {
				$map.closeInfoWindow();
			}
		});
		GEvent.addListener($marker, 'dragend', function() { document.getElementById('title').innerHTML=$marker.getLatLng(); });
		
		return $marker;
	}

	var $icon=new GIcon(), $this=this, $map=this.map;
	$icon.image='http://googlemapsapi.martinpearman.co.uk/maps/westnorfolkpoi/images/marker_icons/mm_20_red.png';
	$icon.iconSize=new GSize(12, 20);
	$icon.iconAnchor=new GPoint(6, 17);

	// ****
	var iconBlue = new GIcon(); 
    iconBlue.image = 'http://www.salon-cafe.com/gmap/coco_b2.gif';
    iconBlue.shadow = 'http://www.salon-cafe.com/gmap/shadow.png';
    iconBlue.iconSize = new GSize(35, 53);
    iconBlue.shadowSize = new GSize(45, 53);
    iconBlue.iconAnchor = new GPoint(17, 53);
    iconBlue.infoWindowAnchor = new GPoint(17, 1);
    
	var iconPurple = new GIcon(); 
    iconPurple.image = 'http://www.salon-cafe.com/gmap/coco_pu2.gif';
    iconPurple.shadow = 'http://www.salon-cafe.com/gmap/shadow.png';
    iconPurple.iconSize = new GSize(35, 53);
    iconPurple.shadowSize = new GSize(90, 60);
    iconPurple.iconAnchor = new GPoint(17, 53);
    iconPurple.infoWindowAnchor = new GPoint(17, 1);
    
    var iconPink = new GIcon(); 
    iconPink.image = 'http://www.salon-cafe.com/gmap/coco_p2.gif';
    iconPink.shadow = 'http://www.salon-cafe.com/gmap/shadow.png';
    iconPink.iconSize = new GSize(35, 53);
    iconPink.shadowSize = new GSize(45, 53);
    iconPink.iconAnchor = new GPoint(17, 53);
    iconPink.infoWindowAnchor = new GPoint(17, 1);

    var iconRed = new GIcon(); 
    iconRed.image = 'http://www.salon-cafe.com/gmap/coco_o.gif';
    iconRed.shadow = 'http://www.salon-cafe.com/gmap/shadow.png';
    iconRed.iconSize = new GSize(12, 20);
    iconRed.shadowSize = new GSize(22, 20);
    iconRed.iconAnchor = new GPoint(6, 20);
    iconRed.infoWindowAnchor = new GPoint(5, 1);

    
    var iconGreen = new GIcon(); 
    iconGreen.image = 'http://www.salon-cafe.com/gmap/coco_g.gif';
    iconGreen.shadow = 'http://www.salon-cafe.com/gmap/shadow.png';
    iconGreen.iconSize = new GSize(12, 20);
    iconGreen.shadowSize = new GSize(22, 20);
    iconGreen.iconAnchor = new GPoint(6, 20);
    iconGreen.infoWindowAnchor = new GPoint(5, 1);

    var customIcons = [];
    customIcons["[ヘ]"] = iconBlue;
    customIcons["[ネ]"] = iconPurple;
    customIcons["[エ]"] = iconPink;

	
	GDownloadUrl("phpsqlajax_genxml.php", function(doc) {
		var xmlDoc = GXml.parse(doc);
        var $markers = xmlDoc.documentElement.getElementsByTagName("marker");
			var $json=[];
			//eval($file);
			var i, j=$markers.length, $row, $linksHtml='<ul id="salon_list" class="icon_set">';
			var $markers_next=[];
			for(i=0; i<j; i++) {
				//$row=$markers[i];
				/* $row.index=i; */
				var $row = i;
				var $lat = parseFloat($markers[i].getAttribute("lat"));
          		var $lng = parseFloat($markers[i].getAttribute("lng"));
          		var $point = new GLatLng($lat,$lng);
          		var $name = $markers[i].getAttribute("name");
          		var $address = $markers[i].getAttribute("address");
          		var $pin = $markers[i].getAttribute("pin");
          		var $type = $markers[i].getAttribute("type");
          		var $photo = $markers[i].getAttribute("photo");
          		var $tel = $markers[i].getAttribute("tel");
          		var $holiday = $markers[i].getAttribute("holiday");
          		var $hour = $markers[i].getAttribute("hour");
          		var $uid = $markers[i].getAttribute("uid");
          		var $coupon = $markers[i].getAttribute("coupon");
          		var $model = $markers[i].getAttribute("model");
          		var $job = $markers[i].getAttribute("job");
				$markers_next.push(createMarker($point, $name, $address, $pin,$type, $row, $icon,$photo,$tel,$holiday,$hour,$uid,$coupon,$model,$job));
				
				$linksHtml+='<li id="anchor'+i+'" onclick="map.menuSelect('+i+')"><span class="'+$pin+'">'+$name+'</span></li>';
				// alert($linksHtml);
			}
			$linksHtml+='</ul>';
		
			document.getElementById('menu').innerHTML=$linksHtml;
			// alert($markers);
			$this.clusterer.addMarkers($markers_next);
			$this.clusterer.fitMapToMarkers();
			$this.map.savePosition();
		
	});
};

DiscoverMap.prototype.menuSelect=function($id){
	if(this.map._activeMarkerIndex!==$id){
		this.clusterer.triggerClick($id);
	} else {
		this.map.closeInfoWindow();
	}
};

