// GOOGLE MAPS - GOOGLE MAPS - GOOGLE MAPS - GOOGLE MAPS - GOOGLE MAPS - GOOGLE MAPS //
// GOOGLE MAPS - GOOGLE MAPS - GOOGLE MAPS - GOOGLE MAPS - GOOGLE MAPS - GOOGLE MAPS //
// GOOGLE MAPS - GOOGLE MAPS - GOOGLE MAPS - GOOGLE MAPS - GOOGLE MAPS - GOOGLE MAPS //

var TW_DOCBASEURL;
var TW_DEFAULTMAPICON;

function initmap(mapdivid)
	{
	if (GBrowserIsCompatible()) 
		{
		var map = new GMap2(document.getElementById(mapdivid));
		map.setCenter(new GLatLng(38.341656192795924,137.2412109375), 4);
		//map.addControl(new GMapTypeControl());
        //map.addControl(new GOverviewMapControl());
		map.addControl(new GSmallMapControl());
		map.enableScrollWheelZoom();

		// Create a base icon for all of markers that specifies the
		// shadow, icon dimensions, etc.
		TW_DEFAULTMAPICON = new GIcon(G_DEFAULT_ICON);
		// override default icon
		TW_DEFAULTMAPICON.image = "http://www.japantravelplan.com/tway_0/html/public/gmap-icons/blue-house.png";
		TW_DEFAULTMAPICON.iconSize = new GSize(32, 32); //<----
		//TW_DEFAULTMAPICON.shadow = "";
		TW_DEFAULTMAPICON.shadow = "http://www.japantravelplan.com/tway_0/html/public/gmap-icons/blue-house-shadow.png";
		//TW_DEFAULTMAPICON.shadowSize = new GSize(32, 50);
		TW_DEFAULTMAPICON.iconAnchor = new GPoint(16, 32);
		TW_DEFAULTMAPICON.infoWindowAnchor = new GPoint(16, 32);
		var clusterer = new Clusterer( map );
		//return map;
		
		//set Clusterer icon
		
		myCluster = new GIcon();
		myCluster.image = 'http://www.japantravelplan.com/tway_0/html/public/gmap-icons/blue-house-group.png';
		myCluster.shadow = 'http://www.japantravelplan.com/tway_0/html/public/gmap-icons/blue-house-group-shadow.png';
		myCluster.iconSize = new GSize( 32, 32 );
		//myCluster.shadowSize = new GSize( 32, 50 );
		myCluster.iconAnchor = new GPoint(16, 32);
		myCluster.infoWindowAnchor = new GPoint(28, 18);
		myCluster.infoShadowAnchor = new GPoint(28, 18);
		
		clusterer.SetIcon(myCluster);
		clusterer.SetMaxVisibleMarkers(2);
		clusterer.SetMinMarkersPerCluster(4);
		return clusterer;
		}
	}

function createmapmarker(gmap,lat,lng,zmm,infodivid,title)
	{
	var point = new GLatLng(lat,lng);
	var twicon = new GIcon(TW_DEFAULTMAPICON);
	//twicon.image = TW_DOCBASEURL + "images/elements/mapmarker" + type + ".png";

	// Set up GMarkerOptions object
	markerOptions = { icon:twicon };
	var marker = new GMarker(point, markerOptions);
	//build bubble
	var bubble = new EBubble(gmap.map, "http://www.japantravelplan.com/tway_0/html/public/gmap-icons/popupbox.png",new GSize(350,200), new GSize(320,135), new GPoint(16,16), new GPoint(108,197));    
	
	GEvent.addListener(marker, "click", function() 
		{
		var infohtml=$('#mapinfo-' + infodivid).html()
		//var infowinoptions= {maxWidth:100, noCloseOnClick:false};
  		//marker.openInfoWindowHtml(infohtml,infowinoptions);
		bubble.openOnMarker(marker,infohtml);
		});

	//gmap.addOverlay(marker);
	gmap.AddMarker( marker, title )
	return marker;
	}

function centermap(gmap,lat,lng,zmm)
	{
	if (!zmm) {zmm=13;} //13: street, 1: world
	var point = new GLatLng(lat,lng);
	gmap.setCenter(point, zmm);
	}
