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(33.3064814, 130.197165);
	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.276206,129.875803);
	html = '<p class="gMapCom"><a href="http://kameei.co.jp/" target="_blank">亀栄建材（株）</a></p><p class="gMapAdd">伊万里市伊万里町乙１８６</p><p class="gMapTel">0955（22）7800</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.279245,129.87775);
	html = '<p class="gMapCom"><a href="http://www.kurokinet.co.jp/" target="_blank">黒木建設（株）</a></p><p class="gMapAdd">伊万里市松島町１００-１</p><p class="gMapTel">0955（22）7111</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.315483,130.3036);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/sakamoto-kensetsu/" target="_blank">（株）坂本建設　マイハウス</a></p><p class="gMapAdd">佐賀市金立町金立１９４１</p><p class="gMapTel">0952（98）2048</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.257568,130.273032);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/yumex/" target="_blank">（株）ミサワホーム佐賀</a></p><p class="gMapAdd">佐賀市鍋島町大字八戸１３９４-１</p><p class="gMapTel">0952（23）7141</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.098166,130.075388);
	html = '<p class="gMapCom"><a href="http://www1.megax.ne.jp/yumekikou/" target="_blank">（有）夢木香</a></p><p class="gMapAdd">鹿島市三河内甲２８４７</p><p class="gMapTel">0954（69）8333</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.285339,130.208853);
	html = '<p class="gMapCom"><a href="http://www.kogamokuzai.co.jp/" target="_blank">（株）古賀木材センター</a></p><p class="gMapAdd">小城市三日月町久米１３５０</p><p class="gMapTel">0952（73）4114</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.212844,129.849592);
	html = '<p class="gMapCom"><a href="http://ww7.tiki.ne.jp/~iwachu/" target="_blank">岩忠建設（株）</a></p><p class="gMapAdd">西松浦郡有田町立部乙２２３８-１</p><p class="gMapTel">0955（46）2426</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.492544,129.925324);
	html = '<p class="gMapCom"><a href="http://www.flex-k.co.jp/" target="_blank">（株）フレックス唐津</a></p><p class="gMapAdd">唐津市浦６４１０</p><p class="gMapTel">0955（74）5500</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.444691,129.962534);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/narimura/" target="_blank">成村建設（株）</a></p><p class="gMapAdd">唐津市熊原町３０８２-３</p><p class="gMapTel">0955（73）5421</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.395711,129.978536);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/shinto-mokuzai/" target="_blank">（株）進藤木材店</a></p><p class="gMapAdd">唐津市山本１５５４-１２</p><p class="gMapTel">0955（78）1110</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.350852,129.999024);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/kurihara/" target="_blank">栗原工業（株）</a></p><p class="gMapAdd">唐津市相知町相知２６３５-３０</p><p class="gMapTel">0955（62）2401</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.53262,129.918964);
	html = '<p class="gMapCom"><a href="http://www.fujita-house.com/" target="_blank">（株）藤田工務店</a></p><p class="gMapAdd">唐津市鎮西町赤木３９６３</p><p class="gMapTel">0955（82）4394</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.516829,129.902256);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/sakamoto-koumuten/" target="_blank">坂本工務店</a></p><p class="gMapAdd">唐津市鎮西町打上３３０１</p><p class="gMapTel">0955（51）1102</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.547498,129.854975);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/yamashita/" target="_blank">山下建築</a></p><p class="gMapAdd">唐津市鎮西町波戸１９６番地</p><p class="gMapTel">0955（82）4076</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.44941,129.988532);
	html = '<p class="gMapCom"><a href="http://create-home.net/" target="_blank">クリエイトホーム（株）</a></p><p class="gMapAdd">唐津市東唐津４丁目７番１２-２号</p><p class="gMapTel">0955（74）3055</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.52659,129.948154);
	html = '<p class="gMapCom"><a href="http://nakamura-kenchiku.jp/" target="_blank">（株）中村建築</a></p><p class="gMapAdd">唐津市湊町８９５-１</p><p class="gMapTel">0955（79）0638</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.433809,129.98783);
	html = '<p class="gMapCom"><a href="http://www.fukui-mk.com/" target="_blank">福井木材（株）</a></p><p class="gMapAdd">唐津市和多田南先石１-２９</p><p class="gMapTel">0955（73）2111</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.22479,130.029521);
	html = '<p class="gMapCom"><a href="http://www.matsuo-kk.co.jp/" target="_blank">松尾建設（株）</a></p><p class="gMapAdd">武雄市朝日町大字中野１０４０５</p><p class="gMapTel">0954（23）2155</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.418531,129.997629);
	html = '<p class="gMapCom">（株）栗原木材店</p><p class="gMapAdd">唐津市原1360-1</p><p class="gMapTel">0955（77）0221</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.199974,129.87061);
	html = '<p class="gMapCom">（株）梶原建設</p><p class="gMapAdd">西松浦郡有田町黒牟田丙３７８１</p><p class="gMapTel">0955（29）8031</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);
				}
			}
		);
	}
}

