var gmaps = new function(){
	this.map = null;
	this.geo = null;
	this.marker = null;
	this._init = function(id){
		this.map = new GMap2($(id));
		this.map.addControl(new GSmallMapControl());
		GEvent.addListener(this.map, "click", this.onClick);
	}
	this.load = function(id){
		if(!this.map) this._init(id);
//		this.map.setCenter(new GLatLng(35.685326404244, 139.75296020), 16);
	}
	this.onClick = function(overlay, point){
//		$("debug").innerHTML = point.y + "/" + point.x;
	}
	this.geosearch = function(addr,lat,lon){
		if(!this.map) this._init(id);

		if (lat == ""|| lat == 0 || lon == "" || lon == 0){
			if(!this.geo) this.geo = new GClientGeocoder();
			this.geo.getLatLng(addr, gmaps.moveMap);
		}else{
			latlng = new GLatLng(lat, lon);
			gmaps.map.setCenter(latlng, 17);
			if(!gmaps.marker) delete gmaps.marker;
			gmaps.marker = new GMarker(latlng);
			gmaps.map.addOverlay(gmaps.marker);
		}

	}
	this.moveMap = function(latlng){
		if(!latlng) return;
		gmaps.map.clearOverlays();
//		gmaps.map.panTo(latlng);
		gmaps.map.setCenter(latlng, 16);
		if(!gmaps.marker) delete gmaps.marker;
		gmaps.marker = new GMarker(latlng);
		gmaps.map.addOverlay(gmaps.marker);
	}
}




