var map = null;
var geocoder = null;
var marker2 = null;

function createMarker(point, html, icon){
	var marker = new GMarker(point, icon);
	GEvent.addListener(marker, "mouseover", function() {
		marker.openInfoWindowHtml(html);
		});
	return marker;
	}

function load() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());
		map.addControl(new GScaleControl());
		map.addControl(new GMapTypeControl());
		map.enableContinuousZoom();
		map.enableDoubleClickZoom();

	// GClientGeocoderを初期化
	geocoder = new GClientGeocoder();

var center = new GLatLng(36.065197, 136.251068);
map.setCenter(center, 10);

	icon = new GIcon();
	icon.image = '../img/marker.gif';
	icon.iconSize = new GSize( 25, 33 );	// 画像の大きさ
	icon.shadow = '../img/marker_shadow.png';
	icon.shadowSize = new GSize( 45, 29 );	// 影画像の大きさ
	icon.iconAnchor = new GPoint( 12, 32 );	// 画像の「基準点」
	icon.infoWindowAnchor = new GPoint( 12, 32 );	// 情報ウィンドウの基準点	
var html; 
var point;

	point = new GLatLng(35.910917,136.162219);
	html = '<p class="gMapCom">丸福木材（株）</p><p class="gMapAdd">越前市平出２丁目１番２３号</p><p class="gMapTel">0778（24）5888</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.08561,136.238184);
	html = '<p class="gMapCom"><a href="http://www.aroc.co.jp/" target="_blank">アロック・サンワ（株）</a></p><p class="gMapAdd">福井市開発５-３１５</p><p class="gMapTel">0776（54）2640</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.899321,136.153462);
	html = '<p class="gMapCom"><a href="http://www.crasis.co.jp/" target="_blank">クラシス（株）</a></p><p class="gMapAdd">越前市日野美2-18</p><p class="gMapTel">0778（22）2260</p>';
	map.addOverlay(createMarker(point, html, icon));





	}
}


function showAddress(address) {
	if (geocoder) {
		geocoder.getLatLng(
		address,
			function(point) {
				if (!point) {
				alert(address + " not found");
				} else {
					if(marker2 != null){
					map.removeOverlay(marker2);
					}
				var icon = new GIcon();
				icon.image = "../img/aicon_map.gif";  //アイコン画
				icon.shadow = "../img/aicon_map.gif"; //影の画
				icon.iconSize = new GSize(36, 36);    //アイコンサイズ
				icon.shadowSize = new GSize(36, 36); //影のサイズ
				icon.iconAnchor = new GPoint(18, 36);
				icon.infoWindowAnchor = new GPoint(18, 0);
				var markeropts = new Object();
				markeropts.icon = icon;
				map.setCenter(point, 13);
				marker2 = new GMarker(point, icon);
				map.addOverlay(marker2);
				marker2.openInfoWindowHtml(address);
				}
			}
		);
	}
}

