var map;
var mgr;
var marker_list=[];
var txt_list=[];

function load() {
	if (GBrowserIsCompatible()) {

	//地図を作成
	map = new GMap2(document.getElementById("map"));
	map.setCenter(new GLatLng(40.446947 , 140.888672), 6);
	
	//マップコントローラを付ける
	map.addControl(new GLargeMapControl());
	//マップタイプコントローラを追加する
	map.addControl(new GMapTypeControl());

	//マーカーを追加
	var txt="郡山長者店";
	txt_list.push(txt);
	addMarker(new GLatLng(37.399632, 140.366842),txt);
	
	//マーカーを追加
	txt="仙台長町店";
	txt_list.push(txt);
	addMarker(new GLatLng(38.225578, 140.868352),txt);
	
	
	//マーカーを追加）
	txt="古川店";
	txt_list.push(txt);
	addMarker(new GLatLng(38.576033, 140.967859),txt);
	
	//マーカーを追加）
	txt="札幌新道東店";
	txt_list.push(txt);
	addMarker(new GLatLng(43.103548347923294 , 141.3768258690834),txt);
	
	
	//マーカーを追加）
	txt="札幌旭ヶ丘店";
	txt_list.push(txt);
	addMarker(new GLatLng(43.039512611244085 , 141.32828056812286),txt);
	
	
	//マーカーを追加）
	txt="会津若松店";
	txt_list.push(txt);
	addMarker(new GLatLng(37.487293, 139.940812),txt);
	
	//マーカーを追加）
	txt="札幌八軒店";
	txt_list.push(txt);
	addMarker(new GLatLng(43.09259, 141.305979),txt);
	
	//マーカーを追加）
	txt="菊水元町店";
	txt_list.push(txt);
	addMarker(new GLatLng(43.068538, 141.408994),txt);
	
	//マーカーを追加）
	txt="札幌西岡店";
	txt_list.push(txt);
	addMarker(new GLatLng(43.001156, 141.383747),txt);
	
	//マーカーを追加）
	txt="仙台岩切店";
	txt_list.push(txt);
	addMarker(new GLatLng(38.291736, 140.937175),txt);
	
	//マーカーを追加）
	txt="いわき平店";
	txt_list.push(txt);
	addMarker(new GLatLng(37.04702, 140.893348),txt);

	}
}
function addMarker(latlng,txt){
	//マーカーを作成
	var marker = new GMarker(latlng);

	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(txt);
	});

	//マーカーのコンストラクタを配列に記憶
	marker_list.push(marker);

	//マーカーを地図上に配置
	map.addOverlay(marker);



var pos0 = new GLatLng(37.399632, 140.366842);
var pos1 = new GLatLng(38.225578, 140.868352);
var pos2 = new GLatLng(38.576033, 140.967859);
var pos3 = new GLatLng(43.103548347923294 , 141.3768258690834);
var pos4 = new GLatLng(43.039512611244085 , 141.32828056812286);
var pos5 = new GLatLng(37.487293, 139.940812);
var pos6 = new GLatLng(43.09259, 141.305979);
var pos7 = new GLatLng(43.068538, 141.408994);
var pos8 = new GLatLng(43.001156, 141.383747);
var pos9 = new GLatLng(38.291736, 140.937175);
var pos10 = new GLatLng(37.04702, 140.893348);
//マーカーマネージャーを作成する
mgr = new GMarkerManager(map);
//ズームレベル15以上のとき、photoAを表示
var photo0_marker = createMarker(pos0, {
	image : "../common/img/mugilogo_l.png"
	,iconAnchor: new GPoint(60, 60)
});
var photo1_marker = createMarker(pos1, {
	image : "../common/img/mugilogo_l.png"
	,iconAnchor: new GPoint(60, 60)
});
var photo2_marker = createMarker(pos2, {
	image : "../common/img/mugilogo_l.png"
	,iconAnchor: new GPoint(60, 60)
});
var photo3_marker = createMarker(pos3, {
	image : "../common/img/mugilogo_l.png"
	,iconAnchor: new GPoint(60, 60)
});
var photo4_marker = createMarker(pos4, {
	image : "../common/img/mugilogo_l.png"
	,iconAnchor: new GPoint(60, 60)
});
var photo5_marker = createMarker(pos5, {
	image : "../common/img/mugilogo_l.png"
	,iconAnchor: new GPoint(60, 60)
});
var photo6_marker = createMarker(pos6, {
	image : "../common/img/mugilogo_l.png"
	,iconAnchor: new GPoint(60, 60)
});
var photo7_marker = createMarker(pos7, {
	image : "../common/img/mugilogo_l.png"
	,iconAnchor: new GPoint(60, 60)
});
var photo8_marker = createMarker(pos8, {
	image : "../common/img/mugilogo_l.png"
	,iconAnchor: new GPoint(60, 60)
});
var photo9_marker = createMarker(pos9, {
	image : "../common/img/mugilogo_l.png"
	,iconAnchor: new GPoint(60, 60)
});
var photo10_marker = createMarker(pos10, {
	image : "../common/img/mugilogo_l.png"
	,iconAnchor: new GPoint(60, 60)
});
/*
mgr.addMarker( photo0_marker, 17 );
mgr.addMarker( photo1_marker, 17 );
mgr.addMarker( photo2_marker, 17 );
mgr.addMarker( photo3_marker, 17 );
mgr.addMarker( photo4_marker, 17 );
mgr.addMarker( photo5_marker, 17 );
mgr.addMarker( photo6_marker, 17 );
mgr.addMarker( photo7_marker, 17 );
mgr.addMarker( photo8_marker, 17 );
mgr.addMarker( photo9_marker, 17 );
mgr.addMarker( photo10_marker, 17 );

//マーカーマネージャーを稼動させる
mgr.refresh();*/

}
function createMarker(markerPos, photoInfo){
            //オリジナルマーカーの画像を作成
            var myIcon = new GIcon(photoInfo);
            
            //画像として表示させるため、クリック・オートパンの禁止
            var markerOpt = {
                                icon: myIcon
                               ,clickable: false
                               ,autoPan: false
                            };
            var marker = new GMarker(markerPos, markerOpt);
            return marker;
        }
	function clickMarker(index){
	//吹き出しを表示する
	marker_list[index].openInfoWindowHtml(txt_list[index]);
}
