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(32.790738, 130.687866);
	map.setCenter(center, 9);

	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(32.783813,130.7077);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/tanaka_zaimokuten/" target="_blank">（株）田中材木店</a></p><p class="gMapAdd">熊本市琴平２-４-１０</p><p class="gMapTel">096（362）1261</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.893529,130.755534);
	html = '<p class="gMapCom"><a href="http://nozawaKK.com/" target="_blank">野沢工芸建築（株）</a></p><p class="gMapAdd">合志市御代志８５４</p><p class="gMapTel">096（242）1021</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.878119,130.783452);
	html = '<p class="gMapCom"><a href="http://www.daisyou.co.jp/" target="_blank">（株）大商木材</a></p><p class="gMapAdd">合志市福原３１２２-６</p><p class="gMapTel">096（248）7500</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.1071,130.695142);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/takeguma/" target="_blank">（有）竹熊建設</a></p><p class="gMapAdd">山鹿市鹿北町四丁１４７２-１</p><p class="gMapTel">0968（32）2894</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.548535,130.147007);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/smilehome/" target="_blank">（株）高田建材</a></p><p class="gMapAdd">天草市五和町二江７４１-２</p><p class="gMapTel">0969（33）1116</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.500387,130.581156);
	html = '<p class="gMapCom">（株）マルヤマ</p><p class="gMapAdd">八代市中北町３６１９</p><p class="gMapTel">0965（34）2724</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.933279,130.551618);
	html = '<p class="gMapCom"><a href="http://www.kazuya.co.jp/" target="_blank">（株）かずやハウジング</a></p><p class="gMapAdd">玉名市立願寺１３５-１</p><p class="gMapTel">0968（73）4668</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.076142,130.692451);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/inaba/" target="_blank">（有） 稲葉工務店</a></p><p class="gMapAdd">山鹿市鹿北町芋生４１０５－１</p><p class="gMapTel">0968（32）2148</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.994544,130.473278);
	html = '<p class="gMapCom"><a href="http://www.kazuya.co.jp/" target="_blank">（株）若久工務店</a></p><p class="gMapAdd">荒尾市本井手１２４８－１</p><p class="gMapTel">0968（66）3737</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.776705,130.677764);
	html = '<p class="gMapCom"><a href="http://www.shinwajuutaku.com/" target="_blank">（株）伸和住拓</a></p><p class="gMapAdd">熊本市野中２－１１－４５</p><p class="gMapTel">096（353）5788</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.969353,130.767651);
	html = '<p class="gMapCom">（株）工藤商店</p><p class="gMapAdd">菊池市七城町砂田１４３２</p><p class="gMapTel">0968（25）0181</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.798615,130.761277);
	html = '<p class="gMapCom">（株） 冨治商会 熊本営業所</p><p class="gMapAdd">熊本市尾ノ上４－１１－２５５</p><p class="gMapTel">096（367）0123</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.989715,130.806314);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/yamamoto-k/" target="_blank">（有）山本建築</a></p><p class="gMapAdd">菊池市玉祥寺３１７-８</p><p class="gMapTel">0968（24）5333</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.905369,130.735296);
	html = '<p class="gMapCom">（有）大智</p><p class="gMapAdd">合志市野々島5081-2</p><p class="gMapTel">096（348）5055</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.782829,130.666595);
	html = '<p class="gMapCom">（株）すまいプロデュース</p><p class="gMapAdd">熊本市上代3-15-30</p><p class="gMapTel">096（356）6446</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.674789,130.728836);
	html = '<p class="gMapCom"><a href="http://www.taikai-kensetsu.co.jp/" target="_blank">大海建設（株）</a></p><p class="gMapAdd">下益城郡城南町藤山３２９７-８</p><p class="gMapTel">0964（28）0095</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.93538,130.445017);
	html = '<p class="gMapCom">前田建設（有）</p><p class="gMapAdd">玉名郡長洲町長洲５００番地１</p><p class="gMapTel">0968（78）1749</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.869455,130.697933);
	html = '<p class="gMapCom"><a href="http://www.k2-homes.com/hp/mura-ken/" target="_blank">（株）村建</a></p><p class="gMapAdd">熊本市硯川町７４９</p><p class="gMapTel">096（245）0230</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);
				}
			}
		);
	}
}

