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.841904, 132.750549);
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(33.216083,132.570623);
	html = '<p class="gMapCom"><a href="http://www.yokoyama-kenkou.com/" target="_bank">横山建工（有）</a></p><p class="gMapAdd">宇和島市愛宕町２-２-２０</p><p class="gMapTel">0895（22）7276</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.206239,132.554688);
	html = '<p class="gMapCom">（有）森川建設</p><p class="gMapAdd">宇和島市中沢町２-４-３１</p><p class="gMapTel">0895（25）2828</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.218538,132.55851);
	html = '<p class="gMapCom">宇和島建材（株）</p><p class="gMapAdd">宇和島市明倫町４-２-１３</p><p class="gMapTel">0895（22）4770</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.816148,132.745572);
	html = '<p class="gMapCom"><a href="http://home.e-catv.ne.jp/sanwashi/" target="_blank">（株）三和新建材</a></p><p class="gMapAdd">松山市保免中２-４-１２</p><p class="gMapTel">089（972）2572</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.837354,132.708722);
	html = '<p class="gMapCom">（株）三浦商店</p><p class="gMapAdd">松山市北吉田町１２０７-１</p><p class="gMapTel">089（972）0070</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.964078,133.278132);
	html = '<p class="gMapCom"><a href="http://www.e-jikan.co.jp/" target="_blank">宮崎木材（株）</a></p><p class="gMapAdd">新居浜市徳常町６-８</p><p class="gMapTel">0897（37）2541</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.253719,132.691861);
	html = '<p class="gMapCom">善家工務店</p><p class="gMapAdd">北宇和郡鬼北町出目１９８４</p><p class="gMapTel">0895（45）3623</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.806832,132.827708);
	html = '<p class="gMapCom"><a href="http://www.sensible.e-arc.jp/" target="_blank">（株）SENSIBLE</a></p><p class="gMapAdd">松山市平井町甲２７５７－１</p><p class="gMapTel">089（989）3885</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.821268,132.766281);
	html = '<p class="gMapCom">（有）山田木材</p><p class="gMapAdd">松山市朝生田町６丁目３-２９</p><p class="gMapTel">089（933）2188</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.810978,132.8237);
	html = '<p class="gMapCom"><a href="http://www.athousing-az.com/" target="_blank">（株）アットハウジング・ＡＺ</a></p><p class="gMapAdd">松山市平井町甲２３８２</p><p class="gMapTel">089（976）7255</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.20918,132.5464);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/jyuhyo/" target="_blank">住建ヒョウドウ（株）</a></p><p class="gMapAdd">宇和島市別当６丁目７-１３</p><p class="gMapTel">0895（25）7636</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.264129,132.512376);
	html = '<p class="gMapCom">（株）竹田工務店</p><p class="gMapAdd">宇和島市吉田町南君１５６１-１</p><p class="gMapTel">0895（54）0245</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.064939,132.934922);
	html = '<p class="gMapCom"><a href="http://www.toryukoumuten.jp/" target="_blank">（有）鳥生工務店</a></p><p class="gMapAdd">今治市大西町紺原甲728-3</p><p class="gMapTel">0898（53）4535</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(33.219603,132.551457);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/hyodo-komuten/" target="_blank">兵頭工務店（有）</a></p><p class="gMapAdd">宇和島市坂下津甲４０７-１４９</p><p class="gMapTel">0895（24）5850</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);
				}
			}
		);
	}
}

