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(35.223572, 136.173835);
	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(35.064364,136.130937);
	html = '<p class="gMapCom"><a href="http://www.murachi.com/" target="_blank">村地綜合木材（株）</a></p><p class="gMapAdd">蒲生郡竜王町綾戸３２８-３</p><p class="gMapTel">0748（57）0615</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.09789,136.127009);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/act/" target="_blank">（株）アクト建設</a></p><p class="gMapAdd">近江八幡市馬淵町４４６-２</p><p class="gMapTel">0748（37）8533</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.108689,136.15432);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/shigaoota/" target="_blank">（有）シガオータランバー</a></p><p class="gMapAdd">近江八幡市末広町１３番地</p><p class="gMapTel">0748（38）4147</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.995599,136.024029);
	html = '<p class="gMapCom"><a href="http://www.kurodajyuken.jp/" target="_blank">（株）黒田住建</a></p><p class="gMapAdd">栗東市御園２０２７-２</p><p class="gMapTel">077（558）0037</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.987933,136.014431);
	html = '<p class="gMapCom">（株）中西製材所</p><p class="gMapAdd">栗東市荒張９８４</p><p class="gMapTel">077（558）2741</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.917034,136.170368);
	html = '<p class="gMapCom"><a href="http://www.yumesakinoie.com/" target="_blank">（株）マツヤ</a></p><p class="gMapAdd">甲賀市甲南町竜法師７９２</p><p class="gMapTel">0748（86）3143</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.983679,136.189268);
	html = '<p class="gMapCom"><a href="http://www.fujisawacons.jp" target="_blank">（株）フジサワ建設</a></p><p class="gMapAdd">甲賀市水口町水口１５９０-１</p><p class="gMapTel">0748（62）3100</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.300484,136.00185);
	html = '<p class="gMapCom"><a href="http://www.sakae-club.co.jp/" target="_blank">（株）栄</a></p><p class="gMapAdd">高島市音羽４５０番地１</p><p class="gMapTel">0740（36）1326</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.033844,136.06102);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/e-plus/" target="_blank">（有）イー・プラス</a></p><p class="gMapAdd">湖南市菩提寺１５８８番地</p><p class="gMapTel">0748（74）8511</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.028483,135.95901);
	html = '<p class="gMapCom"><a href="http://www.ayaha.co.jp/arnet/" target="_blank">アヤハ不動産（株）</a></p><p class="gMapAdd">草津市野村1-26-8 A.S野村ビル2F</p><p class="gMapTel">077（567）2232</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.28514,136.26155);
	html = '<p class="gMapCom">上田康允デザインコラボ</p><p class="gMapAdd">彦根市松原町3651-127</p><p class="gMapTel">0749(20)1584</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.982084,136.166253);
	html = '<p class="gMapCom"><a href="http://www.biwakohome.com/" target="_blank">びわこテックコーポレーション（株）</a></p><p class="gMapAdd">甲賀市水口町名坂1033-7</p><p class="gMapTel">0748（63）8050</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.058392,136.105418);
	html = '<p class="gMapCom"><a href="http://www5d.biglobe.ne.jp/~sun-en/" target="_blank">（株）スンエン 関西支店</a></p><p class="gMapAdd">蒲生郡竜王町小口1284-1</p><p class="gMapTel">0748（58）3456</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.968442,136.161837);
	html = '<p class="gMapCom"><a href="http://nishimura-c.co.jp/jyutaku/" target="_blank">西村建設（株）</a></p><p class="gMapAdd">甲賀市水口町的場96</p><p class="gMapTel">0748（65）0600</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.36124,136.039822);
	html = '<p class="gMapCom"><a href="http://www.dih.jp/" target="_blank">（有）大地工務店</a></p><p class="gMapAdd">高島市新旭町旭１２５２</p><p class="gMapTel">074（025）7485</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.009386,135.991293);
	html = '<p class="gMapCom"><a href="http://www.hondakoumuten.com/" target="_blank">（株）本田工務店</a></p><p class="gMapAdd">栗東市下戸山１２７５番地</p><p class="gMapTel">077（553）9155</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.390136,136.289157);
	html = '<p class="gMapCom">たちばな建設（株）</p><p class="gMapAdd">長浜市山階町３５３-８</p><p class="gMapTel">0749(63)7277</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.33791,136.293668);
	html = '<p class="gMapCom">（株）北村</p><p class="gMapAdd">米原市宇賀野１１-７</p><p class="gMapTel">0749(52)2110</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);
				}
			}
		);
	}
}

