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(38.320178, 140.885754);
	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(38.436053,141.427582);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/houbu/" target="_blank">（有）報武工務店</a></p><p class="gMapAdd">牡鹿郡女川町浦宿浜字蓬田１３-１</p><p class="gMapTel">0225（53）3182</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(38.576564,140.85892);
	html = '<p class="gMapCom"><a href="http://www.tostem-fc.jp/blog.php?post_cmd=index&post_blogdir=5000269&sjd=93ee73136468d9ca8443c3b7ab4fca2b" target="_blank">（株）あいトーヨー住器</a></p><p class="gMapAdd">加美郡加美町矢越２６７-１</p><p class="gMapTel">0229（63）3374</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(38.507519,140.866822);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/kurosawa-koumuten/" target="_blank">（有）黒澤工務店</a></p><p class="gMapAdd">加美郡色麻町大字上本町７２</p><p class="gMapTel">0229（65）2575</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(37.98129,140.775602);
	html = '<p class="gMapCom"><a href="http://www.wakaki-group.co.jp" target="_blank">（株）ワカキ</a></p><p class="gMapAdd">角田市角田字幸町３</p><p class="gMapTel">0224（62）3217</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(38.387393,140.866019);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/home-universe/" target="_blank">（株）ホームユニバース</a></p><p class="gMapAdd">黒川郡大和町杜の丘３-７-５</p><p class="gMapTel">022（358）9628</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(38.383382,140.949687);
	html = '<p class="gMapCom"><a href="http://www.daitojyutaku.co.jp/" target="_blank">大東住宅（株）</a></p><p class="gMapAdd">黒川郡大和町鶴巣太田字壱町田２４-５</p><p class="gMapTel">022（343）2021</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(38.455481,140.917622);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/kurokawa-forest/" target="_blank">黒川森林組合</a></p><p class="gMapAdd">黒川郡大和町落合松坂字直南沢３９-２３</p><p class="gMapTel">022（345）2203</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(38.442422,141.329189);
	html = '<p class="gMapCom">（株）丸中材木店</p><p class="gMapAdd">石巻市大瓜字井内６</p><p class="gMapTel">0225（22）2644</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(38.271275,140.927824);
	html = '<p class="gMapCom"><a href="http://www.kunenkansou.co.jp/" target="_blank">（株）ホーム建材店</a></p><p class="gMapAdd">仙台市宮城野区苦竹２丁目７番５号</p><p class="gMapTel">022（284）7867</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(38.262251,140.934969);
	html = '<p class="gMapCom">（株）菊地製材所</p><p class="gMapAdd">仙台市宮城野区日の出町３-８-３</p><p class="gMapTel">022（231）4318</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(38.259234,140.923595);
	html = '<p class="gMapCom">（株）ＬＩＸＩＬ新日軽住建販売</p><p class="gMapAdd">仙台市若林区卸町３-５-８</p><p class="gMapTel">022（283）4504</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(38.575364,140.968768);
	html = '<p class="gMapCom"><a href="http://www.takakaz.com/" target="_blank">（株）髙勝の家</a></p><p class="gMapAdd">大崎市古川幸町１-４-３１</p><p class="gMapTel">0229（23）8008</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(38.591284,140.95396);
	html = '<p class="gMapCom">（株）仙北製材所</p><p class="gMapAdd">大崎市古川若葉町２丁目１１番４６号</p><p class="gMapTel">0229（24）0222</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(37.988124,140.615787);
	html = '<p class="gMapCom"><a href="http://ww5.et.tiki.ne.jp/~kabusakuma/" target="_blank">（株）佐久間工務店</a></p><p class="gMapAdd">白石市大平森合字清水田２８</p><p class="gMapTel">0224（26）3212</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(37.989254,140.86631);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/sennan-beniya/" target="_blank">仙南ベニヤ（株）</a></p><p class="gMapAdd">亘理郡山元町大平字畑中９-２</p><p class="gMapTel">0223（37）4011</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(38.070398,140.863671);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/takahashi-kenzai/" target="_blank">たかはし建材（株）</a></p><p class="gMapAdd">亘理郡亘理町逢隈田沢字神明１７４</p><p class="gMapTel">0223（34）6363</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(37.956051,140.828192);
	html = '<p class="gMapCom"><a href="http://hhhome.jp/" target="_blank">（有）星不動産</a></p><p class="gMapAdd">角田市尾山字大門１－１</p><p class="gMapTel">0224（62）1041</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(38.572151,140.971697);
	html = '<p class="gMapCom"><a href="http://chibamin-sukoyaka.web.officelive.com/default.aspx" target="_blank">（株）チバミン</a></p><p class="gMapAdd">大崎市古川駅東１丁目５-１１</p><p class="gMapTel">0229（22）0291</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);
				}
			}
		);
	}
}

