	var gLocalSearch;
	var gMap;
	var gSelectedResults = [];
	var gCurrentResults = [];

	var gSmallIcon = new GIcon();
	gSmallIcon.image = "/js/pointer.png";
	gSmallIcon.shadow = "/js/shadow.png";
	gSmallIcon.iconSize = new GSize(53, 49);
	gSmallIcon.shadowSize = new GSize(90, 60);
	gSmallIcon.iconAnchor = new GPoint(40, 48);
	gSmallIcon.infoWindowAnchor = new GPoint(40, 0);

	function gmapStart(element, addr) {
		if (GBrowserIsCompatible()) { 

			gMap = new GMap(document.getElementById(element));
			gMap.addControl(new GLargeMapControl());
			gMap.addControl(new GMapTypeControl(true));
			gMap.setCenter(new GLatLng(0,0), 15);
			gMap.enableDoubleClickZoom();
			gMap.enableContinuousZoom();
			gLocalSearch = new GlocalSearch();
			gLocalSearch.setCenterPoint(gMap);
			gLocalSearch.setSearchCompleteCallback(null, OnLocalSearch);
			gLocalSearch.execute(addr);
		}
	}

	function OnLocalSearch() {
		if (!gLocalSearch.results) return;
		for (var i = 0; i < gCurrentResults.length; i++) {
			if (!gCurrentResults[i].selected()) {
				gMap.removeOverlay(gCurrentResults[i].marker());
			}
		}
		gCurrentResults = [];
		for (var i = 0; i < gLocalSearch.results.length; i++) {
			gCurrentResults.push(new LocalResult(gLocalSearch.results[i]));
		}
		var first = gLocalSearch.results[0];
		gMap.recenterOrPanToLatLng(new GLatLng(parseFloat(first.lat), parseFloat(first.lng)));
	}

	function LocalResult(result) {
		this.result_ = result;
		this.resultNode_ = this.unselectedHtml();
		gMap.addOverlay(this.marker(gSmallIcon));
	}

	LocalResult.prototype.marker = function(opt_icon) {
		if (this.marker_) return this.marker_;
		var marker = new GMarker(new GLatLng(parseFloat(this.result_.lat),parseFloat(this.result_.lng)),opt_icon);
		GEvent.bind(marker, "click", this, function() {
			var textnode = '<b>なつクリニック皮膚科・形成外科</b><br />〒663-8204 西宮市高松町3-3 ジオタワー1F<br />（西宮北口 南側歩行者デッキより駅直結のマンション1階、<br />兵庫県立芸術文化ホール前）<br/><a href="http://maps.google.co.jp/maps?q=%E8%A5%BF%E5%AE%AE%E5%B8%82%E9%AB%98%E6%9D%BE%E7%94%BA3-3" target="_blank">新しいページで地図を見る</a>';
			marker.openInfoWindowHtml(textnode);
//			marker.openInfoWindow(this.selected() ? this.selectedHtml() :this.unselectedHtml());
		});
		this.marker_ = marker;
		return marker;
	}

	LocalResult.prototype.select = function() {
		if (!this.selected()) {
			this.selected_ = true;
			gMap.removeOverlay(this.marker());
			this.marker_ = null;
			gMap.addOverlay(this.marker(G_DEFAULT_ICON));
		}
	}

	LocalResult.prototype.unselectedHtml = function() {
		var container = document.createElement("div");
		container.className = "unselected";
		container.appendChild(this.result_.html.cloneNode(true));

		var saveDiv = document.createElement("div");
		saveDiv.className = "select";
		GEvent.bindDom(saveDiv, "click", this, function() {
			gMap.closeInfoWindow();
			this.select();
			gSelectedResults.push(this);
		});
		container.appendChild(saveDiv);
		return container;
	}

	LocalResult.prototype.selectedHtml = function() {
		return this.result_.html.cloneNode(true);
	}
	
	LocalResult.prototype.selected = function() {
		return this.selected_;
	}