var map, marker, html, m_i, KoM, ad_p;
window.onload = function(){
if(typeof map_id != "undefined"){
	if(GBrowserIsCompatible()){
		
		//地図初期設定
			map = new GMap2(document.getElementById(map_id));
			if(typeof kind_of_map != "undefined"){
				if(kind_of_map == "map"){
					KoM = G_NORMAL_MAP;
				} else if(kind_of_map == "satellite"){
					KoM = G_SATELLITE_MAP;
				} else if(kind_of_map == "hybrid"){
					KoM = G_HYBRID_MAP;
				}
			} else {
				KoM = G_NORMAL_MAP;
			}
			if(typeof hyoji == "undefined"){
				hyoji = 0;
			}
			if(typeof center_lat == "undefined"){
				center_lat = 0;
			}
			if(typeof center_lng == "undefined"){
				center_lng = 0;
			}
			map_dp = new GLatLng(center_lat,center_lng) 
			map.setCenter(map_dp,hyoji,KoM);

		//マーカーアイコン生成
			if(typeof marker_icon != "undefined"){
				if(marker_icon != null){
					m_i = new GIcon();
					m_i.image = marker_icon;
					m_i.iconSize = new GSize(icon_width, icon_height);
					m_i.iconAnchor = new GPoint(icon_x, icon_y);
				}
			}
		//マーカーアイコン影
			if(typeof marker_shadow != "undefined"){
				if(marker_shadow != null){
					m_i.shadow = marker_shadow;
					m_i.shadowSize = new GSize(shadow_width, shadow_height);
				}
			}

		//マーカー生成
			if(typeof marker_lat != "undefined" && typeof marker_lng != "undefined"){
				ad_p = new GLatLng(marker_lat,marker_lng);
				if(m_i == "undefined"){
					marker = new GMarker(ad_p);
					map.addOverlay(marker);
				} else {
					marker = new GMarker(ad_p, m_i);
					map.addOverlay(marker);
				}
			}

		//マーカーhtml位置調整
			if(typeof fukidashi_x != "undefined" && typeof fukidashi_y != "undefined"){
				m_i.infoWindowAnchor = new GPoint(fukidashi_x, fukidashi_y);
			}

		//マーカーをクリックでhtml表示
			if(typeof fukidashi_tab == "undefined" || fukidashi_tab < 1){
				fukidashi_tab = 1;
			}
			if(fukidashi_tab == 1){
				if(typeof fukidashi != "undefined" || fukidashi != null){
					html = document.getElementById(fukidashi);
					GEvent.addListener(marker, "click", function(){
						marker.openInfoWindowHtml(html);
					});
				}
			} else if(fukidashi_tab == 2){
				if(typeof fukidashi != "undefined" || typeof fukidashi2 != "undefined" || fukidashi != null || fukidashi2 != null){
					var t_l = [
						new GInfoWindowTab(tab_title1, document.getElementById(fukidashi)),
						new GInfoWindowTab(tab_title2, document.getElementById(fukidashi2))
					];
					GEvent.addListener(marker, "click", function (){
						marker.openInfoWindowTabs(t_l);
					});
				}
			}
		
		//マップコントロールの付加
			if(typeof control != "undefined"){
				if(control == "L"){
					map.addControl(new GLargeMapControl());
				} else if(control == "M"){
					map.addControl(new GSmallMapControl());
				} else if(control == "S"){
					map.addControl(new GSmallZoomControl());
				}
			}
		
		//スケールの付加
			if(typeof scale != "undefined"){
				if(scale){
					map.addControl(new GScaleControl());
				}
			}
		
		//地図タイプ変更ボタン付加
			if(typeof map_switch != "undefined"){
				if(map_switch){
					map.addControl(new GMapTypeControl());
				}
			}

		//地図をドラッグで動かすかどうか
			if(typeof map_drag != "undefined"){
				if(!map_drag){
					map.disableDragging();
				}
			}		
		}
		window.onunload = function (){
			GUnload();
		}
	}
}