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(31.602224, 130.564785);
	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(28.394249,129.495276);
	html = '<p class="gMapCom"><a href="http://www.miracle3.co.jp/tie_up/company_data/kyushu/kawaguchi/index.html" target="_blank">川口建設（株）</a></p><p class="gMapAdd">奄美市名瀬長浜町１４-１５</p><p class="gMapTel">0997（52）7595</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(31.786631,130.319269);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/shuken/" target="_blank">（有）集建</a></p><p class="gMapAdd">薩摩川内市勝目町５３３５-２５</p><p class="gMapTel">0996（20）3500</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(31.82237,130.300326);
	html = '<p class="gMapCom">束田建材（株）</p><p class="gMapAdd">薩摩川内市大王町8-18</p><p class="gMapTel">0996（22）7271</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(31.824577,130.301167);
	html = '<p class="gMapCom">リビングハウス風の家</p><p class="gMapAdd">薩摩川内市大小路町２７-２０</p><p class="gMapTel">0996（22）5425</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(31.823637,130.302454);
	html = '<p class="gMapCom"><a href="http://www.synapse.ne.jp/kaname/" target="_blank">（株）宇都組</a></p><p class="gMapAdd">薩摩川内市大小路町８０-８</p><p class="gMapTel">0996（23）4668</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(31.227303,130.644602);
	html = '<p class="gMapCom"><a href="http://www2.synapse.ne.jp/kyoushin/" target="_blank">（有）協進建設</a></p><p class="gMapAdd">鹿児島県指宿市十二町3352番1</p><p class="gMapTel">0993（22）1180</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(31.53997,130.539841);
	html = '<p class="gMapCom"><a href="http://www.canada-place.co.jp/" target="_blank">（株）カナダプレイス</a></p><p class="gMapAdd">鹿児島市宇宿２丁目２１-１</p><p class="gMapTel">099（206）0711</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(31.551828,130.548815);
	html = '<p class="gMapCom"><a href="http://www.imabeppu.co.jp/" target="_blank">今別府産業（株）</a></p><p class="gMapAdd">鹿児島市新栄町１５-７</p><p class="gMapTel">099（256）4111</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(31.583443,130.508237);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/muse/" target="_blank">ミューズ建築工房（有）</a></p><p class="gMapAdd">鹿児島市西陵５-２０-９</p><p class="gMapTel">099（283）7088</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(31.418009,130.323974);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/smile-gen/" target="_blank">住まいる玄</a></p><p class="gMapAdd">南さつま市加世田東本町18-9</p><p class="gMapTel">099-262-1188</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(31.533782,130.535261);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/maruhira/" target="_blank">（株）マルヒラ</a></p><p class="gMapAdd">鹿児島市東開町４番地</p><p class="gMapTel">099（268）3171</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(31.525619,130.53422);
	html = '<p class="gMapCom">アイ・ビー建販（株）</p><p class="gMapAdd">鹿児島市東開町８-３</p><p class="gMapTel">099（268）7095</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(27.726923,129.017088);
	html = '<p class="gMapCom">（有）木之下建設</p><p class="gMapAdd">大島郡徳之島町亀津３１０２番地</p><p class="gMapTel">0997（83）1123</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(31.39513,130.384789);
	html = '<p class="gMapCom">（有）北薗建設</p><p class="gMapAdd">南九州市川辺町田部田3739-2</p><p class="gMapTel">0993（56）5051</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(31.380934,130.442392);
	html = '<p class="gMapCom">（有）田中工務店</p><p class="gMapAdd">南九州市知覧町郡１４０２１</p><p class="gMapTel">0993（83）2945</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(31.301391,130.281816);
	html = '<p class="gMapCom"><a href="http://masudazaimoku.com/" target="_blank">（株）増田材木店</a></p><p class="gMapAdd">枕崎市東鹿篭７１１６</p><p class="gMapTel">0993（72）3225</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(31.71162,130.766634);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/meta/" target="_blank">（株）米田</a></p><p class="gMapAdd">霧島市国分広瀬４-７-６</p><p class="gMapTel">0995（45）1123</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(31.690741,130.839777);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/yanagimoto/" target="_blank">（有）柳元建築</a></p><p class="gMapAdd">霧島市国分上之段３３６-１</p><p class="gMapTel">0995（48）2527</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(31.778981,130.76474);
	html = '<p class="gMapCom"><a href="http://www.mct.ne.jp/users/tsudawa/" target="_blank">（株）津田和建設</a></p><p class="gMapAdd">霧島市隼人町松永３２８２-４</p><p class="gMapTel">0995（42）1238</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(31.571325,130.524527);
	html = '<p class="gMapCom"><a href="http://kamizuru-kensetsu.com/" target="_blank">上鶴建設</a></p><p class="gMapAdd">鹿児島市田上台２丁目２７番３号</p><p class="gMapTel">099(251)6070</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);
				}
			}
		);
	}
}

