
	var MyGoogleMap = Class.create();
	
	MyGoogleMap.prototype =
	{
		initialize : function ( key )
		{
			this.map = null;
			this.geocoder = null;
			if( key != null && key != "" && typeof(key) != "undefined"){
				this.initGoogleMap( key );
			}
			
			this.lng = 139.782272;
			this.lat = 35.707812;
		},
		
		initGoogleMap : function ( key )
		{
			document.write('<script src="http://maps.google.co.jp/maps?file=api&v=2.x&key=' + key + '" type="text/javascript"></script>');
		},
		
		
		
	  	loadMap : function ( map_div,lng,lat,change_marker )
		{
			if(lng == null || lng == "" || typeof(lng) == "undefined"){
				lng = 139.782272;
			}
			if(lat == null || lat == "" || typeof(lat) == "undefined"){
				lat = 35.707812;
			}
			this.lat = lat;
			this.lng = lng;
				
	
			if (GBrowserIsCompatible()) {
	
				// Create our "tiny" marker icon
				gSmallIcon = new GIcon();
				gSmallIcon.image = "http://labs.google.com/ridefinder/images/mm_20_yellow.png";
				gSmallIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
				gSmallIcon.iconSize = new GSize(12, 20);
				gSmallIcon.shadowSize = new GSize(22, 20);
				gSmallIcon.iconAnchor = new GPoint(6, 20);
				gSmallIcon.infoWindowAnchor = new GPoint(5, 1);
	
				this.map = new GMap2(map_div);
				this.map.addControl(new GLargeMapControl());
				this.map.addControl(new GScaleControl());
				//this.map.addControl(new GOverviewMapControl());
				//this.map.addControl(new GMapTypeControl());
				this.map.setCenter(new GLatLng(lat, lng), 13);
	
				var marker = new GMarker(new GLatLng(lat, lng),gSmallIcon);
				this.map.addOverlay(marker);
	
				this.geocoder = new GClientGeocoder();
			}
	
	
			if(change_marker == true){
				GEvent.addListener(this.map, 'click', this._changeMarker.bind(this));
			}
		},
		
	  	searchFromAddress : function ( address )
		{
			this.address = address;
			if (this.geocoder) {
				this.geocoder.getLatLng(
					address,
					this._searchFromAddress.bind(this)
				);
			}
		},
		
		_searchFromAddress :function (point)
		{
			if (!point) {
				alert(this.address + " が見つかりません");
			} else {
				this.map.clearOverlays();
				this.map.setCenter(point, 13);
				var marker = new GMarker(point,gSmallIcon);
				this.map.addOverlay(marker);
				//marker.openInfoWindowHtml(address);
				
				this.lat = point.y;
				this.lng = point.x;
			}
		},
		
		
		_changeMarker :function(overlay, point){
			//alert(point);
			//クリックしたポイントにマーカー移動
			//document.form1.xxx.value = parseFloat(point.x);
			//document.form1.yyy.value = parseFloat(point.y);
			//obj = document.getElementById("lat");
			//obj.value = parseFloat(point.y);
				
			//obj = document.getElementById("lng");
			//obj.value = parseFloat(point.x);

			if(typeof(point) != "undefined"){
				this.map.clearOverlays();
				this.map.panTo(new GLatLng(point.y, point.x));
				//gMap.setCenter(new GLatLng(point.y, point.x), 13);
				var marker = new GMarker(new GLatLng(point.y, point.x),gSmallIcon);
				this.map.addOverlay(marker);
			
				this.lat = point.y;
				this.lng = point.x;
			}
		}
		
		
	}
	
