﻿	//<![CDATA[

	var vpoint_num = 2;
	var vpoint = new Array(vpoint_num);
	vpoint[0] = new Array(140.73607,  40.821894, "たかはし歯科クリニック","〒030-0862 青森市古川3-15-1<br>TEL：017-775-0077");
	vpoint[1] = new Array(140.786249, 40.816201, "高橋ひでき歯科クリニック","〒030-0964 青森市南佃2-8-17<br>TEL：017-741-9595");

	var markers = new Array(vpoint_num);
	var map;
	var vpoint_index = -1;
	var vpoint_index_opened = -1;

	function onLoad(index) {
		map = new GMap(document.getElementById("map"));
		map.addControl(new GLargeMapControl());
		map.centerAndZoom(new GPoint(vpoint[index][0], vpoint[index][1]), 3);

		GEvent.addListener(map, "movestart", function() {
			if(vpoint_index >= 0) {
			}
		});
		GEvent.addListener(map, "moveend", function() {
			if(vpoint_index >= 0) {
				mapMarkerInfo(vpoint_index);
			}
		});
		GEvent.addListener(map, "infowindowopen", function() {
			if(vpoint_index >= 0) {
				vpoint_index_opened = vpoint_index;
				vpoint_index = -1;
			}
		});
		GEvent.addListener(map, "infowindowclose", function() {
			vpoint_index_opened = -1;
		});
		
		var baseIcon = new GIcon();
		baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
		baseIcon.iconSize = new GSize(20, 34);
		baseIcon.shadowSize = new GSize(37, 34);
		baseIcon.iconAnchor = new GPoint(9, 34);
		baseIcon.infoWindowAnchor = new GPoint(9, 2);
		baseIcon.infoShadowAnchor = new GPoint(18, 25);

		function createMarker(point, index) {
			var letter = String.fromCharCode("A".charCodeAt(0) + index);
			var icon = new GIcon(baseIcon);
			icon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
			var marker = new GMarker(point, icon);
			GEvent.addListener(marker, "click", function() {
				mapMarkerInfo(index);
			});
			return marker;
		}

		var lp;
		for(lp = 0; lp < vpoint_num; lp++) {
			var point = new GPoint(vpoint[lp][0],vpoint[lp][1]);
			var marker = createMarker(point, lp);
			map.addOverlay(marker);
			markers[lp] = marker;
		}
		mapMarkerInfo(index);


	}

	function mapPoint(index) {
		vpoint_index = index;
		var center = map.getCenterLatLng();
		if(vpoint_index_opened >= 0) {
			map.closeInfoWindow();
			vpoint_index_opened = -1;
		}
		if(center.x == vpoint[index][0] && center.y == vpoint[index][1]) {
			mapMarkerInfo(index);
		}
		else {
			var point = new GPoint(vpoint[index][0], vpoint[index][1]);
			map.recenterOrPanToLatLng(point);
		}
	}

	function mapMarkerInfo(index) {
		var html = "<div class=MRKname>" + vpoint[index][2] + "</div>";
		if(vpoint[index][3] != "") {
			html += "<div class=MRKcmt>" + vpoint[index][3] + "</div>";
		}
		var point = new GPoint(vpoint[index][0], vpoint[index][1]);
		markers[index].openInfoWindowHtml(html);
	}

	function mapTextAncher() {
		var lp;
		for(lp = 0; lp < vpoint_num; lp++) {
			document.write( String.fromCharCode("Ａ".charCodeAt(0) + lp) +  "： <a href=\"JavaScript:mapPoint(" + lp + ");\">" + vpoint[lp][2] + "</a>&nbsp;&nbsp;&nbsp;&nbsp;\n");
		}
	}

	//]]>

