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.954365, 129.970243);
	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(33.786793,129.758846);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/nagafuji/" target="_blank">（有）永藤建設</a></p><p class="gMapAdd">壱岐市芦辺町諸吉二亦触８２</p><p class="gMapTel">0920（45）2272</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.826694,129.743352);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/matsushima/" target="_blank">（有）松島建設</a></p><p class="gMapAdd">壱岐市芦辺町箱崎釘ノ尾触４４９-１</p><p class="gMapTel">0920（45）0430</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.751961,129.708939);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/nagabun/" target="_blank">（株）長文建設</a></p><p class="gMapAdd">壱岐市郷ノ浦町志原西触２０６-１</p><p class="gMapTel">0920（47）4494</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.734957,129.698388);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/kuramotogumi/" target="_blank">（株）倉本組</a></p><p class="gMapAdd">壱岐市郷ノ浦町片原触１１６３</p><p class="gMapTel">0920（47）3813</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.835837,129.842866);
	html = '<p class="gMapCom"><a href="http://www.amwood.co.jp/" target="_blank">長建木材供給（株）</a></p><p class="gMapAdd">西彼杵郡時津町左底郷１-４</p><p class="gMapTel">095（882）0304</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.960412,129.942777);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/iwanaga-juutaku/" target="_blank">岩永住宅</a></p><p class="gMapAdd">大村市沖田町４３８-１</p><p class="gMapTel">0957（55）7859</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.914389,129.950197);
	html = '<p class="gMapCom"><a href="http://www.ai-deal.com/" target="_blank">（株）アイディアル</a></p><p class="gMapAdd">大村市杭出津１-５４３</p><p class="gMapTel">0957（54）1551</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.912581,129.951331);
	html = '<p class="gMapCom"><a href="http://www.tomiken.gr.jp/" target="_blank">（株）富建</a></p><p class="gMapAdd">大村市杭出津２丁目７９４-２</p><p class="gMapTel">0957（53）2145</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.912314,129.975581);
	html = '<p class="gMapCom"><a href="http://www.asahikoubou.co.jp/" target="_blank">（株）朝日工房</a></p><p class="gMapAdd">大村市赤佐古町４５０-１</p><p class="gMapTel">0957（54）6335</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.881493,129.966644);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/isshin/" target="_blank">（有）一心住建</a></p><p class="gMapAdd">大村市西部町1692-1</p><p class="gMapTel">0957（50）0260</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.963637,129.953918);
	html = '<p class="gMapCom"><a href="http://www.tominagakoumuten.com" target="_blank">（株）富永工務店</a></p><p class="gMapAdd">大村市福重町９２-２</p><p class="gMapTel">0957（55）8273</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.72832,129.830276);
	html = '<p class="gMapCom"><a href="http://www.nao.co.jp/" target="_blank">（有）ナオ建築</a></p><p class="gMapAdd">長崎市小瀬戸町８０９-９</p><p class="gMapTel">095（865）4917</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.792392,129.860947);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/grand-house/" target="_blank">（株）グランドハウス</a></p><p class="gMapAdd">長崎市住吉町１３－４</p><p class="gMapTel">095（845）5229</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.71841,129.866488);
	html = '<p class="gMapCom"><a href="http://www17.ocn.ne.jp/~yushin/" target="_blank">（有）勇進建設</a></p><p class="gMapAdd">長崎市上戸町１-３-１２</p><p class="gMapTel">095（879）0485</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.684254,129.830291);
	html = '<p class="gMapCom">小宮工務店</p><p class="gMapAdd">長崎市深堀町１-１６１-１０１</p><p class="gMapTel">095（871）5722</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.1156,129.868052);
	html = '<p class="gMapCom"><a href="http://www.matsusita.co.jp/" target="_blank">（株）松下建設</a></p><p class="gMapAdd">東彼杵郡波佐見町長野郷５６３-２</p><p class="gMapTel">0956（85）2330</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.867055,130.033512);
	html = '<p class="gMapCom"><a href="http://www.kuroda-co.com/" target="_blank">（株）クロダ</a></p><p class="gMapAdd">諫早市栄田町２０-３１</p><p class="gMapTel">0957（26）5114</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.834002,130.003132);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/yuno-koumuten/" target="_blank">（有）祐野工務店</a></p><p class="gMapAdd">諫早市久山町１７７７</p><p class="gMapTel">0957（26）0278</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.831295, 130.055451);
	html = '<p class="gMapCom"><a href="http://tierrahome.com/" target="_blank">（株）池田建設</a></p><p class="gMapAdd">諌早市小川町９０－１</p><p class="gMapTel">0957（22）0030</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.84331,130.061358);
	html = '<p class="gMapCom"><a href="http://www.murayama-co.jp/" target="_blank">（株）ムラヤマ</a></p><p class="gMapAdd">諫早市仲沖町２１-１</p><p class="gMapTel">0957（24）3183</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.976034,129.784645);
	html = '<p class="gMapCom"><a href="http://kawamotohome.lar.jp/" target="_blank">川本建設</a></p><p class="gMapAdd">西海市西彼町上岳郷１７１７</p><p class="gMapTel">0959（27）1846</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.820672, 129.868818);
	html = '<p class="gMapCom"><a href="http://shikikoubou.com/" target="_blank">（有）四季工房</a></p><p class="gMapAdd">西彼杵郡長与町高田郷３７３７－１</p><p class="gMapTel">095（887）5855</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.944473,129.933591);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/dohome/" target="_blank">（株）DoHome</a></p><p class="gMapAdd">大村市富の原2-653-3</p><p class="gMapTel">0957（56）9660</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.9454,129.950682);
	html = '<p class="gMapCom"><a href="http://seokoumuten.com/" target="_blank">（株）瀬尾工務店</a></p><p class="gMapAdd">大村市鬼橋町169-3</p><p class="gMapTel">0957（55）4829</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.83468,130.114663);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/tatara/" target="_blank">（有）多々良工務店</a></p><p class="gMapAdd">諫早市森山町下井牟田2429-2</p><p class="gMapTel">0957（35）2191</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.812409,130.346964);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/taisei/" target="_blank">（株）大誠</a></p><p class="gMapAdd">島原市下宮町甲1750</p><p class="gMapTel">0957（63）5112</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.83118,129.986545);
	html = '<p class="gMapCom"><a href="http://www.kikitsuhome.jp/" target="_blank">（有）喜々津ホーム</a></p><p class="gMapAdd">諫早市多良見町化屋７４１-１２</p><p class="gMapTel">0957（43）7750</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.884606,130.000742);
	html = '<p class="gMapCom">森本住建</p><p class="gMapAdd">大村市中里町1215</p><p class="gMapTel">0957（53）8872</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.142695,129.905122);
	html = '<p class="gMapCom">（株）山口住建工業</p><p class="gMapAdd">東彼杵郡波佐見町折敷瀬郷1445-1</p><p class="gMapTel">0956（85）2066</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(32.863369,130.046087);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/taiyo-kobo/" target="_blank">太陽工房（株）</a></p><p class="gMapAdd">諫早市天満町１７２３-３</p><p class="gMapTel">0957(35)6100</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);
				}
			}
		);
	}
}

