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(34.150055, 131.551416);
	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.972137,131.22542);
	html = '<p class="gMapCom"><a href="http://www.ubemokuzai.co.jp/" target="_blank">（株）ウベモク</a></p><p class="gMapAdd">宇部市西平原３－２－２２</p><p class="gMapTel">0836（39）2415</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.993333,130.942675);
	html = '<p class="gMapCom"><a href="http://www.kenwa-jutaku.co.jp/" target="_blank">建和住宅（株）</a></p><p class="gMapAdd">下関市熊野西町６番６号</p><p class="gMapTel">0832（53）2323</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.036436,132.218601);
	html = '<p class="gMapCom"><a href="http://www7.ocn.ne.jp/~kouchi/" target="_blank">（有）河内</a></p><p class="gMapAdd">岩国市由宇町南沖２-５-１</p><p class="gMapTel">0827（63）2111</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.956933,132.048031);
	html = '<p class="gMapCom"><a href="http://www.shisan.info/" target="_blank">（有）田布施不動産</a></p><p class="gMapAdd">熊毛郡田布施町波野３６２-４</p><p class="gMapTel">0820（53）1744</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.924989,132.048478);
	html = '<p class="gMapCom"><a href="http://www8.plala.or.jp/itoukoumuten/" target="_blank">伊東工務店</a></p><p class="gMapAdd">熊毛郡田布施町麻郷３４０５-７</p><p class="gMapTel">0820（55）6206</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.919587,132.058672);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/fujii-zaimoku/" target="_blank">藤井材木店</a></p><p class="gMapAdd">熊毛郡平生町大字曽根３０８</p><p class="gMapTel">0820（56）2131</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.970986,131.917206);
	html = '<p class="gMapCom"><a href="http://www.naka-bayashi.co.jp/" target="_blank">中林建設（株）</a></p><p class="gMapAdd">光市虹ヶ浜２-１５-１０</p><p class="gMapTel">0833（71）1672</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.098652,131.397443);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/choshu/" target="_blank">（株）長州興業</a></p><p class="gMapAdd">山口市小郡下郷１２１２-４</p><p class="gMapTel">083（972）2521</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.104207,131.395152);
	html = '<p class="gMapCom"><a href="http://www.sanwa-co.jp/" target="_blank">（株）三和</a></p><p class="gMapAdd">山口市小郡下郷７９６-５</p><p class="gMapTel">083（973）2829</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.061587,131.797048);
	html = '<p class="gMapCom"><a href="http://www.shunan.co.jp" target="_blank">周南システム産業（株）</a></p><p class="gMapAdd">周南市江口１丁目１番１号</p><p class="gMapTel">0834（21）1785</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.056,131.811591);
	html = '<p class="gMapCom"><a href="http://www.nikkogumi.com/" target="_blank">（株）日光組</a></p><p class="gMapAdd">周南市三番町２-１６</p><p class="gMapTel">0834（31）1500</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.063331,131.782563);
	html = '<p class="gMapCom"><a href="http://www.m-style80.com/" target="_blank">（株）みうら</a></p><p class="gMapAdd">周南市野村３-２４-１</p><p class="gMapTel">0834（63）8811</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.40961,131.415237);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/hatano-juuken/" target="_blank">（有）波多野住建</a></p><p class="gMapAdd">萩市椿東１０６８-３</p><p class="gMapTel">0838（25）2525</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.151513,132.176568);
	html = '<p class="gMapCom">（有）栄和建設</p><p class="gMapAdd">岩国市川西４丁目９番３４号</p><p class="gMapTel">0827（41）1563</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.128637,132.141226);
	html = '<p class="gMapCom">（株）白石木材店</p><p class="gMapAdd">岩国市柱野１６６７番３</p><p class="gMapTel">0827（46）0700</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.984956,130.927274);
	html = '<p class="gMapCom"><a href="http://www.life-rich-style.com/" targer="_blank">日環特殊（株）</a></p><p class="gMapAdd">下関市山の田東町7-1</p><p class="gMapTel">083(253)7797</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);
				}
			}
		);
	}
}

