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(36.275279, 138.144836);
	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(36.065654,138.068929);
	html = '<p class="gMapCom"><a href="http://www.e-shin.info/" target="_blank">（有）エーシン</a></p><p class="gMapAdd">岡谷市長地権現町１-６-２０</p><p class="gMapTel">0266（28）0111</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.530539,137.88342);
	html = '<p class="gMapCom"><a href="http://www.hikarimokuzai.com/" target="_blank">ひかり木材（株）</a></p><p class="gMapAdd">下伊那郡豊丘村神稲９２８９-１</p><p class="gMapTel">0265（35）8661</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.866966,138.407151);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/mizuho-mokuzai/" target="_blank">瑞穂木材（株）</a></p><p class="gMapAdd">下高井郡木島平村大字穂高３２２８-１</p><p class="gMapTel">0269（82）3118</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.975662,138.176737);
	html = '<p class="gMapCom"><a href="http://www.wellness-net.co.jp/" target="_blank">（有）池田工務店</a></p><p class="gMapAdd">茅野市宮川７２９６-９１</p><p class="gMapTel">0266（73）2242</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.739541,137.937123);
	html = '<p class="gMapCom"><a href="http://www.marutaki.jp/" target="_blank">（株）丸滝</a></p><p class="gMapAdd">駒ヶ根市北町１０-６</p><p class="gMapTel">0265（82）3111</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.272669,138.47813);
	html = '<p class="gMapCom"><a href="http://www.miyamori-g.co.jp/" target="_blank">ミヤモリ（株）</a></p><p class="gMapAdd">佐久市岩村田７５１</p><p class="gMapTel">0267（68）0001</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.299507,138.467053);
	html = '<p class="gMapCom"><a href="http://www.cozyhome-ie.com/" target="_blank">コージーホーム（株）</a></p><p class="gMapAdd">小諸市御影新田２２９９-２</p><p class="gMapTel">0267（41）0120</p>';
	map.addOverlay(createMarker(point, html, icon));


	point = new GLatLng(36.225648,137.958794);
	html = '<p class="gMapCom"><a href="http://www.rinyuwood.co.jp/" target="_blank">（株）林友</a></p><p class="gMapAdd">松本市渚４-１-１</p><p class="gMapTel">0263（28）7700</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.220643,137.973232);
	html = '<p class="gMapCom"><a href="http://www.sinken21.co.jp/" target="_blank">（株）シンケン</a></p><p class="gMapAdd">松本市庄内３-４-３９</p><p class="gMapTel">0263（26）2705</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.22026,137.975673);
	html = '<p class="gMapCom"><a href="http://www.k2-homes.com/hp/s-homes/" target="_blank">（株）シャーロックホームズ</a></p><p class="gMapAdd">松本市筑摩１-１６-２３</p><p class="gMapTel">0263（27）4658</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.639537,138.279514);
	html = '<p class="gMapCom"><a href="http://www.yama2.co.jp/" target="_blank">（株）山二</a></p><p class="gMapAdd">須坂市大字井上１７００-１７</p><p class="gMapTel">026（242）5100</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.637021,138.29141);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/iwasaki-mokuzai/" target="_blank">岩崎木材（株）</a></p><p class="gMapAdd">須坂市幸高２１６</p><p class="gMapTel">026（245）0002</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.642676,138.291652);
	html = '<p class="gMapCom"><a href="http://www.kohki-e.co.jp/" target="_blank">（株）コーキ</a></p><p class="gMapAdd">須坂市米持２５１-１</p><p class="gMapTel">026（245）3743</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.548378,138.128551);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/minemura-zaimokuten/" target="_blank">（株）峯村材木店</a></p><p class="gMapAdd">千曲市大字粟佐７６０-１</p><p class="gMapTel">026（272）1182</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.521665,138.124785);
	html = '<p class="gMapCom"><a href="http://az.s-net21.ne.jp/~n.takizawa/" target="_blank">山の瀧澤建設</a></p><p class="gMapAdd">千曲市鋳物師屋２１９-３</p><p class="gMapTel">026（274）2703</p>';
	map.addOverlay(createMarker(point, html, icon));

		point = new GLatLng(36.51228,137.847094);
	html = '<p class="gMapCom"><a href="http://www.bluejay-jp.com/" target="_blank">（株）大八木建設</a></p><p class="gMapAdd">大町市大町５３９５-１</p><p class="gMapTel">0261（22）1809</p>';
	map.addOverlay(createMarker(point, html, icon));
		
	point = new GLatLng(36.658755,138.223592);
	html = '<p class="gMapCom"><a href="http://www.maru-oka.jp/" target="_blank">（株）マルオカ</a></p><p class="gMapAdd">長野市吉田５-２５-７</p><p class="gMapTel">026（221）6352</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.644223,138.208039);
	html = '<p class="gMapCom"><a href="http://ito-kenchikujyo.com/" target="_blank">（有）川端伊藤建築所</a></p><p class="gMapAdd">長野市高田７８８-２</p><p class="gMapTel">026（226）6206</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.570308,138.181736);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/sakai-kenchiku/" target="_blank">酒井建築</a></p><p class="gMapAdd">長野市篠ノ井東福寺２２４６-１</p><p class="gMapTel">026（293）6471</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.58215,138.146678);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/kizaki-home/" target="_blank">（有）キザキホーム</a></p><p class="gMapAdd">長野市篠ノ井布施高田４６５-１</p><p class="gMapTel">026（299）9093</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.581189,138.201366);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/kanaiyama-kenzai/" target="_blank">金井山建材工業（株）</a></p><p class="gMapAdd">長野市松代町東寺尾３１３５</p><p class="gMapTel">026（278）2551</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.637661,138.224431);
       html = '<p class="gMapCom"><a href="http://www.tamai-k.com/" target="_blank">玉井建設（株）</a></p><p class="gMapAdd">長野市大字風間１４７８</p><p class="gMapTel">026（221）5531</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.653686,138.226912);
	html = '<p class="gMapCom"><a href="http://www.fukoku-net.co.jp/" target="_blank">富国物産（株）</a></p><p class="gMapAdd">長野市東和田８０６</p><p class="gMapTel">026（405）8157</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.647149,138.238449);
	html = '<p class="gMapCom">（株）木商</p><p class="gMapAdd">長野市北長池１８６２</p><p class="gMapTel">026（243）0433</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.32119,138.589754);
	html = '<p class="gMapCom"><a href="http://www.e-fuji.org/" target="_blank">（株）フジコーポレーション</a></p><p class="gMapAdd">北佐久郡軽井沢町発地２５９１-５７</p><p class="gMapTel">0267（45）2988</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.290612,138.299545);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/urano-kensetsu/" target="_blank">浦野建設（株）</a></p><p class="gMapAdd">北佐久郡立科町大字牛鹿２３３０</p><p class="gMapTel">0267（56）2445</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.26507,138.491079);
	html = '<p class="gMapCom"><a href="http://www.nakajima-sc.com/" target="_blank">中島木材（株）</a></p><p class="gMapAdd">佐久市新子田１８５４</p><p class="gMapTel">0267（67）4038</p>';
	map.addOverlay(createMarker(point, html, icon));


	point = new GLatLng(36.674772,138.244785);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/kouya/" target="_blank">広野建設（株）</a></p><p class="gMapAdd">長野市大字金箱７１１－２９</p><p class="gMapTel">026（296）2504</p>';
	map.addOverlay(createMarker(point, html, icon));


	point = new GLatLng(36.641569,138.244242);
	html = '<p class="gMapCom"><a href="http://www.tokiwa-home.jp/" target="_blank">（株）トキワ</a></p><p class="gMapAdd">長野市北長池２３８－１</p><p class="gMapTel">026（221）8221</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.007793,138.122996);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/chuo-j/" target="_blank">中央住材（株）</a></p><p class="gMapAdd">諏訪市湖南112-1</p><p class="gMapTel">0266（56）1677</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.57382,138.132086);
	html = '<p class="gMapCom"><a href="http://www.nakamurajyuken.com/" target="_blank">建設業中村住建（有）</a></p><p class="gMapAdd">長野市篠ノ井二ツ柳1935-6</p><p class="gMapTel">026（292）4548</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.18181797298241,137.95684039592743);
	html = '<p class="gMapCom"><a href="http://www.a-p-h.co.jp/" target="_blank">（株）アルプスピアホーム</a></p><p class="gMapAdd">松本市芳川小屋1125-5</p><p class="gMapTel">0263（85）2525</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.675346,138.222462);
	html = '<p class="gMapCom"><a href="http://www.g-home.co.jp/index.php" target="_blank">ミツヤジーホーム（株）</a></p><p class="gMapAdd">長野市稲田二丁目１１番６号</p><p class="gMapTel">026（263）0263</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.3466209312,137.9347259371);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/ishii-koumuten/" target="_blank">石井工務店</a></p><p class="gMapAdd">安曇野市明科中川手東５７９-１</p><p class="gMapTel">0263（62）3302</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.215244,137.960039);
	html = '<p class="gMapCom"><a href="http://www.ksoken.com/" target="_blank">小林創建</a></p><p class="gMapAdd">松本市高宮北５-８</p><p class="gMapTel">0263（26）6260</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(35.943823,138.242643);
	html = '<p class="gMapCom"><a href="http://www.lcv.ne.jp/~marugen/" target="_blank">（株）宮坂建設</a></p><p class="gMapAdd">諏訪郡原村１２６７０番地１</p><p class="gMapTel">0266（79）2536</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(36.354671,137.932114);
	html = '<p class="gMapCom">小林建築</p><p class="gMapAdd">安曇野市明科中川手４０５９-４</p><p class="gMapTel">0263（62）4607</p>';
	map.addOverlay(createMarker(point, html, icon));


	point = new GLatLng(36.066326,138.053756);
	html = '<p class="gMapCom"><a href="http://www.h-repair.com/">ハウスリペア</a></p><p class="gMapAdd">岡谷市銀座２-１-２</p><p class="gMapTel">0266(22)5120</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);
				}
			}
		);
	}
}

