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.280784, 135.753593);
	map.setCenter(center, 8);

	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(34.912517,135.761965);
	html = '<p class="gMapCom"><a href="http://www.nagatani.biz/" target="_blank">（株）永谷木材</a></p><p class="gMapAdd">宇治市槙島町一丁田８番地</p><p class="gMapTel">0774（23）8150</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.89682,135.798959);
	html = '<p class="gMapCom">（株）中徳木材</p><p class="gMapAdd">宇治市槇島町薗場２７</p><p class="gMapTel">0774（22）4500</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.881322,135.734399);
	html = '<p class="gMapCom"><a href="http://minamiyama.main.jp/" target="_blank">（株）南山建設</a></p><p class="gMapAdd">久世郡久御山町田井向野４４-２</p><p class="gMapTel">0774（45）1848</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.759433,135.177645);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/hanamitsu/" target="_blank">（有）花満建設</a></p><p class="gMapAdd">京丹後市丹後町中浜６７０</p><p class="gMapTel">0772（76）0612</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.683988,135.026652);
	html = '<p class="gMapCom"><a href="http://www.marufukusanshou.com/" target="_blank">まるふく産商（株）</a></p><p class="gMapAdd">京丹後市網野町網野７４７</p><p class="gMapTel">0772（72）0570</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.012824,135.697386);
	html = '<p class="gMapCom"><a href="http://shinwahomes.com/" target="_blank">眞和ハウス（株）</a></p><p class="gMapAdd">京都市右京区嵯峨野秋街道町１１-５０</p><p class="gMapTel">075（864）1138</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.930938,135.749433);
	html = '<p class="gMapCom"><a href="http://www.gouhan.com" target="_blank">早川合板（株）</a></p><p class="gMapAdd">京都市伏見区横大路下三栖辻堂町８７</p><p class="gMapTel">075（601）7271</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.828533,135.800011);
	html = '<p class="gMapCom"><a href="http://www.landhome.biz" target="_blank">（株）ランドホーム</a></p><p class="gMapAdd">城陽市市辺五島１０１番地の１</p><p class="gMapTel">0774（53）8811</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.829366,135.800147);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/horimoku/" target="_blank">ホリモク（株）</a></p><p class="gMapAdd">城陽市市辺五島８４-２</p><p class="gMapTel">0774（52）0032</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.873031,135.727405);
	html = '<p class="gMapCom"><a href="http://www.katsura-lmb.com/" target="_blank">（株）かつら木材センター</a></p><p class="gMapAdd">八幡市下奈良北浦１-３</p><p class="gMapTel">075（982）0866</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.459832,135.38114);
	html = '<p class="gMapCom"><a href="http://www.sakane.co.jp/" target="_blank">（株）坂根工務店</a></p><p class="gMapAdd">舞鶴市字森１８４-３</p><p class="gMapTel">0773（63）2315</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.008008, 135.716462);
	html = '<p class="gMapCom"><a href="http://www.l-housing.co.jp/" target="_blank">（株）嵯峨野不動産</a></p><p class="gMapAdd">京都市右京区山ノ内荒木町7-58</p><p class="gMapTel">075（881）1211</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.031262,135.779084);
	html = '<p class="gMapCom"><a href="http://www.kirin-g.jp/" target="_blank">野口建設（株）</a></p><p class="gMapAdd">京都市左京区田中大堰町214</p><p class="gMapTel">075（781）9131</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);
				}
			}
		);
	}
}

