//--------------------------------------------------------------------------------------------------
// 汎用 Google Maps API スクリプト“ KsGMap ” Ver1.10.1
// http://www.ksgmap.jp/
// Copyright(c) 2005-2007 Ksc
//--------------------------------------------------------------------------------------------------

var ksgmap_start_date , ksgmap_import_flag , ksgmap_import_count , ksgmap_focus_category , ksgmap_import_current_file , ksgmap_apiversion;
var ksgmap_category = {};  var ksgmap_item = {};
var ksgmap_narrowCondition = {};  var ksgmap_marker = {};  var ksgmap_current_marker = {};  var ksgmap_template = {};
var ksgmap__version		= 1.10;
var ksgmap__ua			= {};
var ksgmap__title		= "";
var ksgmap_poweredByKsGMap_time = 10;
var ksgmap_import_file			= "";
var ksgmap_import_path			= "";
var ksgmap_import_cache			= 1;
var ksgmap_import_maxItems		= Infinity;
var ksgmap_import_maxCategorys	= Infinity;
var ksgmap_image_path		= "./image/";

var ksgmap_debug_mode 		= 0;
var ksgmap_default_lng  	= 0;
var ksgmap_default_lat  	= 0;
var ksgmap_default_zoom 	= 12;
var ksgmap_default_type		= "map";
var ksgmap_default_category	= "";
var ksgmap_default_item		= "";
var ksgmap_default_sort		= "";
var ksgmap_zmarking				= 1;
var ksgmap_zmarking_separate	= "<hr style=\"width:200px;\" />";
var ksgmap_control_zoom					= 1;
var ksgmap_control_type					= 1;
var ksgmap_control_scale				= 1;
var ksgmap_control_overviewMap			= 0;
var ksgmap_control_overviewMap_width	= 125;
var ksgmap_control_overviewMap_height	= 125;
var ksgmap_item_name		= "アイテム";
var ksgmap_itemNavi_page_items		= 0;
var ksgmap_itemNavi_countColumn		= 1;
var ksgmap_itemNavi_rowStrips		= 0;
var ksgmap_itemNavi_thirdRow		= "";
var ksgmap_category_name			= "カテゴリ";
var ksgmap_category_autoCentering	= 2;
var ksgmap_category_all				= 1;
var ksgmap_category_all_label		= "スポーツクラブ全てを表示";
var ksgmap_category_map				= 0;
var ksgmap_category_map_label		= "マップ内の%item_name%を表示";
var ksgmap_infoWindow_tab					= "";
var ksgmap_infoWindow_tab_defaultVisible	= 1;
var ksgmap_infoWindow_func_moveCenter		= 0;
var ksgmap_infoWindow_func_zoomDetail		= 0;
var ksgmap_html_categoryNavi					= "";
var ksgmap_html_itemNavi						= "";
var ksgmap_html_itemNavi_autoZoom				= "";
var ksgmap_html_googleLocal						= "";
var ksgmap_html_search_itemName_textField		= "";
var ksgmap_html_search_message					= "";
var ksgmap_html_mapInfo_url						= "";
var ksgmap_html_mapInfo_point					= "";
var ksgmap_html_googleMap						= "map";
var ksgmap_html_debug							= "";
var ksgmap_link_type	= 1;
var ksgmap_marker_key				= "";
var ksgmap_marker_center_adjust_x	= 0;
var ksgmap_marker_center_adjust_y	= 0;
var ksgmap_mapInfo_point_format					= "%lat% ／ %lng%";
var ksgmap_mapInfo_point_base					= 60;
var ksgmap_mapInfo_point_base10_decimalDigit	= 5;
var ksgmap_mapInfo_point_base60_decimalDigit	= 2;
var ksgmap_mapInfo_point_base60_language		= "jp";
var ksgmap_mapInfo_point_enableType				= "category,item,location";
var ksgmap_search_dic_synonym			= "";
var ksgmap_search_narrow_message		= 1;
var ksgmap_search_geocoding				= 1;
var ksgmap_search_geocoding_joinPrefix	= "";
var ksgmap_design_mapLiquidWidth	=    0;
var ksgmap_design_mapLiquidHeight	=    0;
var ksgmap_limit_dragging			=    0;
var ksgmap_limit_zoomByMouseWheel	=    0;
var ksgmap_limit_operateByKeyboard	=    0;
var ksgmap_limit_zoom_max			=   99;
var ksgmap_limit_zoom_min			=    0;
var ksgmap_limit_lng_max			=  180;
var ksgmap_limit_lng_min			= -180;
var ksgmap_limit_lat_max			=   90;
var ksgmap_limit_lat_min			=  -90;
var ksgmap_limit_urlArgument		=    0;
var ksgmap_limit_userMessage		=    0;
var _zMarker = "";
KsGMapDefine();
function KsGMapDefine(){
	var ua = navigator.userAgent;
	if( ua.match( /Opera[\/\s]([0-9]\.[0-9]+)/ )				){ ksgmap__ua.Opera		= parseFloat( RegExp.$1 ); } else { ksgmap__ua.Opera	= 0; }
	if( ua.match( /MSIE ([0-9]\.[0-9]+)/ ) && !ksgmap__ua.Opera ){ ksgmap__ua.MSIE		= parseFloat( RegExp.$1 ); } else { ksgmap__ua.MSIE		= 0; }
	if( ua.match( /Firefox[\/\s]([0-9]\.[0-9]+)/ )				){ ksgmap__ua.Firefox	= parseFloat( RegExp.$1 ); } else { ksgmap__ua.Firefox	= 0; }
	if( ua.match( /Netscape[0-9]?[\/\s]([0-9]\.[0-9]+)/ )		){ ksgmap__ua.Netscape	= parseFloat( RegExp.$1 ); } else { ksgmap__ua.Netscape	= 0; }
	if( ua.match( /Safari/ )									){ ksgmap__ua.Safari	= 1;					   } else { ksgmap__ua.Safari	= 0; }
	ksgmap__ua.Gecko = ( ua.match( /Netscape|Firefox/ ) ? true : false );
	window.onload   = KsGMapInit;
}
function KsGMapInit(){
	if( ksgmap_debug_mode ){ ksgmap_start_date = new Date(); }
	ksgmap_apiversion = ( typeof( G_NORMAL_MAP ) == "object" ? 2 : 1 );
	if( ksgmap_apiversion == 1 ){ return KsGMapCommon.Error.trigger( "本バージョンの KsGMap は Google Maps API Ver2 でのみ動作します。\nGoogle の APIキーを入力する所の v=1 を v=2 にして下さい。" , 0 , 3 ); }
	if( !ksgmap_import_flag && !KsGMapInit_html() ){ return; }
	if( location.search ){ KsGMapInit_procUrlArgument(); }
	if( ( ksgmap_import_file || ksgmap_import_current_file ) && !ksgmap_import_flag ){
		if( !ksgmap_import_current_file ){ ksgmap_import_current_file = ksgmap_import_file; }
		KsGMapCommon.XML.include( ksgmap_import_path + ksgmap_import_current_file , KsGMapInit_import );  return;
	}
	KsGMapDataCategory( "_all" , "-" );
	KsGMapDataCategory( "_map" , "-" );
	KsGMapEX.callback( this , arguments );
	if(      ksgmap_default_category && ksgmap_category[ ksgmap_default_category ] ){ ksgmap_focus_category = ksgmap_default_category; }
	else if( ksgmap_default_item     && ksgmap_item[     ksgmap_default_item     ] ){ ksgmap_focus_category = ksgmap_item[ ksgmap_default_item ].category; }
	else																			{ ksgmap_focus_category = KsGMapCommon.Array.keys( ksgmap_category )[ 2 ]; }
	var KsGMapMapInitResult = KsGMapMap.init();
	KsGMapCategoryNavi.init();
	KsGMapItemNavi.init();
	KsGMapSearch.init();
	KsGMapSort.init();
	if( !ksgmap_marker[ "_default" ] ){ KsGMapDataMarker( "_default" , "http://www.google.com/mapfiles/marker%count%.png" , "http://www.google.com/mapfiles/shadow50.png" , ",[A-Z]" ,   20 , 34   ,   37 , 34   ,    9 , 34   ,   9 , 2 ); }
	if( ksgmap_marker[ "_center" ] ){ ksgmap_marker[ "_center" ].marking(); }

	if( ksgmap_poweredByKsGMap_time ){
		KsGMapCommon.HTML.setDisplay( "ksgmap--map-poweredByKsGMap" , 1 );
		setTimeout( "KsGMapCommon.HTML.setDisplay( \"ksgmap--map-poweredByKsGMap\" , 0 );" , ( ksgmap_poweredByKsGMap_time * 1000 ) - 500 );
	}

	if( ksgmap_html_mapInfo_point ){ KsGMapInfo.dispPoint( KsGMapMapInitResult.defaultPoint.x , KsGMapMapInitResult.defaultPoint.y ); }
	if( ksgmap_category_all ){ ksgmap_category[ "_all" ].name = ksgmap_category_all_label; }
	if( ksgmap_category_map ){ ksgmap_category[ "_map" ].name = ksgmap_category_map_label.replace( "%item_name%" , ksgmap_item_name ); }
	if( !ksgmap_focus_category ){ ksgmap_focus_category = KsGMapInit_getDefaultCategory(); }
	if( ksgmap_focus_category ){ ksgmap_category[ ksgmap_focus_category ].change( "MOVE:off INIT" ); }
	KsGMapCategoryNavi.create();
	var temp_message = KsGMapCommon.Variable.getTempValue( "urlArgumentUserMessage" );
	if( temp_message ){
		var layoutSize = KsGMapCommon.HTML.getLayoutSize( temp_message );
		KsGMapMap.gmap.openInfoWindowHtml( KsGMapMapInitResult.defaultPoint , "<div class=\"ksgmsp--infoWindow-userMessage\" style=\"width: " + layoutSize.width + "px;  height: " + layoutSize.height + "px;\">" + temp_message + "</div>" );
	}
	KsGMapInit_finish();
}
function KsGMapInit_finish(){
	KsGMapEX.callback( this , arguments );	
	if( ksgmap_default_item ){ ksgmap_item[ ksgmap_default_item ].openInfoWindowByItemNavi(); }
	if( ksgmap_debug_mode ){ KsGMapInit_debug_timer(); }
}
function KsGMapInit_procUrlArgument(){
	if( ksgmap_limit_urlArgument ){ return ; }
	var urlArgumentFlag = 0;
	if( location.search.match( /(?=.*[&\?]lng=([0-9\.-]+))(?=.*[&\?]lat=([0-9\.-]+))/ ) ){
		ksgmap_default_lng  = parseFloat( RegExp.$1 );
		ksgmap_default_lat	= parseFloat( RegExp.$2 );
		ksgmap_default_category = "";  ksgmap_default_item  = "";
		urlArgumentFlag = 1;
	}
	if( location.search.match( /[&\?]category=([a-zA-Z0-9_-]+)/ ) ){
		ksgmap_default_category = RegExp.$1;
		ksgmap_default_item   = "";
		urlArgumentFlag = 1;
	}
	if( location.search.match( /[&\?]item=([a-zA-Z0-9_\.-]+)/ ) ){
		ksgmap_default_item   = RegExp.$1;
		ksgmap_default_category = ( ksgmap_item[ ksgmap_default_item ] ? ksgmap_item[ ksgmap_default_item ].category : "" );
		urlArgumentFlag = 1;
	}
	if( location.search.match( /[&\?]zoom=([0-9]{1,2})/ ) ){
		ksgmap_default_zoom    = parseInt( RegExp.$1 );
		urlArgumentFlag = 1;
	}
	if( location.search.match( /[&\?]type=(map|satellite|hybrid)/ ) ){
		ksgmap_default_type = RegExp.$1;
		urlArgumentFlag = 1;
	}
	if( location.search.match( /[&\?]import=([0-9a-zA-Z!$%&()+,;=@\[\]^_=`{}~\.-]+)/ ) ){
		ksgmap_import_current_file = RegExp.$1;
		urlArgumentFlag = 1;
	}
	if( location.search.match( /[&\?]message=([^&\?]+)/ ) && !ksgmap_limit_userMessage ){
		KsGMapInfo.userMessageEditor.message = RegExp.$1;
		var temp_userMessage = decodeURIComponent( RegExp.$1 );
		temp_userMessage = KsGMapCommon.HTML.encode( temp_userMessage );
		temp_userMessage = temp_userMessage.replace( "|" , "<br />" );
		KsGMapCommon.Variable.setTempValue( temp_userMessage , "urlArgumentUserMessage" );
	}
	if( ksgmap_default_lng < ksgmap_limit_lng_min || ksgmap_default_lng > ksgmap_limit_lng_max || ksgmap_default_lat < ksgmap_limit_lat_min || ksgmap_default_lat > ksgmap_limit_lat_max ){
		ksgmap_default_lng = ( ( [ ksgmap_default_lng , ksgmap_limit_lng_min , ksgmap_limit_lng_max ] ).sort() )[ 1 ];
		ksgmap_default_lat = ( ( [ ksgmap_default_lat , ksgmap_limit_lat_min , ksgmap_limit_lat_max ] ).sort() )[ 1 ];
	}
	if( ksgmap_default_zoom < ksgmap_limit_zoom_min ){ ksgmap_default_zoom = ksgmap_limit_zoom_min; }
	if( ksgmap_default_zoom > ksgmap_limit_zoom_max ){ ksgmap_default_zoom = ksgmap_limit_zoom_max; }
	if( urlArgumentFlag ){ KsGMapInfo.setURL( "location" ); }
}
function KsGMapInit_import( xmlDoc ){
	KsGMapDataImportXML( xmlDoc );
	ksgmap_import_flag = 1;
	KsGMapInit();
}
function KsGMapInit_html(){
	var temp_gmap	= document.getElementById( ksgmap_html_googleMap );
	var insertTag	= "";
	var style_displayNone = ( !ksgmap__ua.Opera ? "display: none;" : "visibility: hidden;" );
	if( ksgmap_design_mapLiquidWidth || ksgmap_design_mapLiquidHeight ){
		var windowSize = KsGMapCommon.HTML.getWindowSize();
		if( ksgmap_design_mapLiquidWidth  ){ temp_gmap.style.width  = String( windowSize.width  + ksgmap_design_mapLiquidWidth )  + "px"; }
		if( ksgmap_design_mapLiquidHeight ){ temp_gmap.style.height = String( windowSize.height + ksgmap_design_mapLiquidHeight ) + "px"; }
	}
	if( ksgmap_marker[ "_center" ] && temp_gmap.offsetWidth  % 2 == 1 ){ temp_gmap.style.width  = String( temp_gmap.offsetWidth  - 1 ) + "px"; }
	if( ksgmap_marker[ "_center" ] && temp_gmap.offsetHeight % 2 == 1 ){ temp_gmap.style.height = String( temp_gmap.offsetHeight - 1 ) + "px"; }

	if(      typeof( GBrowserIsCompatible ) == "undefined"	){ var mapMessage = "マップをご利用になるには、インターネットに接続されている必要があります。";  var r_value = false; }
	else if( !GBrowserIsCompatible()						){ var mapMessage = "ご利用のブラウザ、環境ではマップをご利用になることはできません。";  var r_value = false; }
	else													 { var mapMessage = "読み込み中...";  var r_value = true; }
	KsGMapCommon.HTML.write( "ksgmap--map-message" , mapMessage );
	if( ksgmap_marker[ "_center" ] ){
		var centerMarkert_style_icon   = "position: absolute;  z-index: 101;  width: " + ksgmap_marker[ "_center" ].width  + "px;  height: " + ksgmap_marker[ "_center" ].height  + "px;  " + style_displayNone + "  ";
		var centerMarkert_style_shadow = "position: absolute;  z-index: 100;  width: " + ksgmap_marker[ "_center" ].swidth + "px;  height: " + ksgmap_marker[ "_center" ].sheight + "px;  " + style_displayNone + "  ";
		if( ksgmap__ua.MSIE && ksgmap__ua.MSIE < 7.0 ){
			centerMarkert_style_icon   += "  filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + ksgmap_marker[ "_center" ].iconfile     + "',sizingmethod=image);"
			centerMarkert_style_shadow += "  filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + ksgmap_marker[ "_center" ].gicon.shadow + "',sizingmethod=image);"
			insertTag = "<div id=\"ksgmap--icon-center-outer-icon\" style=\"" + centerMarkert_style_icon + "\"></div>\n";
			if( ksgmap_marker[ "_center" ].gicon.shadow ){ insertTag += "<div id=\"ksgmap--icon-center-outer-shadow\" style=\"" + centerMarkert_style_shadow + "\"></div>\n"; }
		} else {
			insertTag = "<img id=\"ksgmap--icon-center-outer-icon\" src=\"" + ksgmap_marker[ "_center" ].iconfile + "\" width=\"" + ksgmap_marker[ "_center" ].width + "\" height=\"" + ksgmap_marker[ "_center" ].height + "\" alt=\"\"  style=\"" + centerMarkert_style_icon + "\" />\n";
			if( ksgmap_marker[ "_center" ].gicon.shadow ){ insertTag += "<img id=\"ksgmap--icon-center-outer-shadow\" src=\"" + ksgmap_marker[ "_center" ].gicon.shadow + "\" width=\"" + ksgmap_marker[ "_center" ].swidth + "\" height=\"" + ksgmap_marker[ "_center" ].sheight + "\" alt=\"\"  style=\"" + centerMarkert_style_shadow + "\" />\n"; }
		}
	}
	var temp_css = "left: " + ( temp_gmap.offsetLeft + 10 ) + "px;  top: " + ( temp_gmap.offsetHeight - 70 ) + "px;  " + style_displayNone;
	insertTag += KsGMapMap.infoBar.html.replace( "%css%" , temp_css );
	if( ksgmap_poweredByKsGMap_time ){
		insertTag += "<div id=\"ksgmap--map-poweredByKsGMap\" style=\"position: absolute;  left: 70px;  top: " + ( temp_gmap.offsetHeight - 24 ) + "px;  z-index: 100;  font-size: 14px;  " + style_displayNone + "  " + ( ksgmap__ua.MSIE ? "filter: Alpha(opacity=70);" : "-moz-opacity: 0.7;" ) + "\">and　<a href=\"http://www.ksgmap.jp/index.html\" target=\"_blank\" style=\"color: #000000;  font-size: 15px;  font-weight: bold;  text-decoration: none;  background-color: #dddddd;\">KsGMap</a></div>\n";
	}
	insertTag += "<div id=\"ksgmap--common-getlayoutsize\" style=\"position: absolute;  left: -10000px;  top: -10000px;  visibility:hidden;\"></div>\n";
	if( ksgmap_debug_mode ){
		KsGMapCommon.HTML.write( ksgmap_html_debug , "<div id=\"ksgmap--debug-point\">&nbsp;</div><div id=\"ksgmap--debug-timer\">&nbsp;</div>" );
		KsGMapCommon.HTML.setDisplay( ksgmap_html_debug , 1 );
	}

	if( ksgmap__ua.MSIE ){ temp_gmap.parentElement.innerHTML = temp_gmap.parentElement.innerHTML + insertTag; }
	else				 { temp_gmap.parentNode.innerHTML    = temp_gmap.parentNode.innerHTML    + insertTag; }

	var insertTag = "";
	insertTag += "<div id=\"ksgmap--common-popupShadow\" style=\"position: absolute;  display: none;\"></div>\n";

	document.getElementsByTagName( "body" )[ 0 ].innerHTML = document.getElementsByTagName( "body" )[ 0 ].innerHTML + insertTag;

	return r_value;
}
function KsGMapInit_checkHybridEnable(){
	var mapTypes = KsGMapMap.gmap.getMapTypes();
	var result = 0;
	for( var i = 0 ; i < mapTypes.length ; i++ ){ if( mapTypes[ i ] == _HYBRID_TYPE ){ result = 1 ;  break; } }
	if( result ){ return true; } else { ksgmap_default_type = "satellite";  return false; }
}
function KsGMapInit_getDefaultCategory(){
	var result_array = KsGMapCommon.Map.getNearData( ksgmap_category , "all" , 1 );
	if( result_array ){ var result = result_array[ 0 ]; }
	return result;
}
function KsGMapInit_debug_timer(){
	if( ksgmap__ua.Firefox ){
		for ( i = 0; i < document.images.length; i++ ){
			if( !document.images[ i ].complete ){ setTimeout( "KsGMapInit_debug_timer()" , 100 );  return ; }
		}
	}
	var ksgmap_end_date = new Date();
	KsGMapCommon.HTML.write( "ksgmap--debug-timer" , ( ( ksgmap_end_date.getTime() - ksgmap_start_date.getTime() ) / 1000 ) + " 秒" );
}
var KsGMapMap = new function(){
	this.id								= "";
	this.gmap							= {};
    this.geocoder						= null;   
	this.inited							= 0;
	this.dummyMarker					= null;
	this.event							= {};
	this.event.moveCompletionID			= "";
	this.event.moveStart				= KsGMapMap_event_moveStart;
	this.event.moveEnd					= KsGMapMap_event_moveEnd;
	this.event.moveCompletion			= KsGMapMap_event_moveCompletion;
	this.event.resize					= KsGMapMap_event_resize;
	this.event.zoomEnd					= KsGMapMap_event_zoomEnd;
	this.event.infoWindowOpen			= KsGMapMap_event_infoWindowOpen;
	this.event.infoWindowClose			= KsGMapMap_event_infoWindowClose;
	this.event.mouseWheel				= KsGMapMap_event_mouseWheel;
	this.event.keyDown					= KsGMapMap_event_keyDown;
	this.infoBar						= {};
	this.infoBar.clear					= KsGMapMap_infoBar_clear;
	this.infoBar.display				= KsGMapMap_infoBar_display;
	this.infoBar.opacity				= 0.7;
	this.infoBar.html					= "<div id=\"ksgmap--map-infobar\" style=\"%css%  position: absolute;  z-index: 100;  overflow: hidden;  border: 2px solid #ffffff;  padding: 4px 6px 3px 6px;  background-color: #000000;  font-size: 14px;  color: #ffffff;  letter-spacing: 1px;  " + ( ksgmap__ua.MSIE ? "filter: Alpha(opacity=70);" : "-moz-opacity: 0.7;" ) + "  opacity: 0.7;\"></div>\n";
	this.infoBar.message				= {};
	this.infoBar.message.limitPoint		= "表示範囲を超えました。これ以上、移動することはできません。";
	this.infoBar.message.limitZoomMin	= "表示範囲を超えました。これ以上、広域にズームすることはできません。";
	this.infoBar.message.limitZoomMax	= "表示範囲を超えました。これ以上、詳細にズームすることはできません。";
	this.infoBar.message.waitMarking	= "しばらくお待ち下さい。";
	this.infoBar.message.waitLoading	= "しばらくお待ち下さい。";
	this.infoWindow						= {};
	this.infoWindow.tabPage				= 1;
	this.infoWindow.tabLabel			= [];
	this.infoWindow.currentItemID		= "";
	this.infoWindow.currentMarker		= "";
	this.infoWindow.enabled				= true;
	this.infoWindow.iconMoveCenterFile	= "ksgmap_infowindow_movecenter.png";
	this.infoWindow.iconZoomDetailFile	= "ksgmap_infowindow_zoomdetail.png";
	this.infoWindow.open				= KsGMapMap_infoWindow_open;
	this.infoWindow.close				= KsGMapMap_infoWindow_close;
	this.infoWindow.moveCenter			= KsGMapMap_infoWindow_moveCenter;
	this.infoWindow.zoomDetail			= KsGMapMap_infoWindow_zoomDetail;
	this.userControl					= {};
	this.userControl.marker				= new KsGMapMap_userControl_marker;
	this.userControl.marker.type		= "marker";
	this.userControl.centerMarker 		= new KsGMapMap_userControl_marker;
	this.userControl.centerMarker.type	= "centerMarker";
	this.userControl.mouseWheel			= {};
	this.userControl.mouseWheel.status	= 1;
	this.userControl.mouseWheel.reverse	= 0;
	this.zMarking						= {};
	this.zMarking.dformerDigit			= [ -1 , -2 , -1 , -1 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 2 , 2 , 2 , 3 , 3 , 4 , 4 , 5 , 5 ];
	this.init							= KsGMapMap_init;
}
function KsGMapMap_init(){
	var gmapInitResult = KsGMapMap_init_gmap();
	KsGMapMap_init_event();
	KsGMapMap.inited = 1;
	if( !ksgmap_zmarking ){ this.zMarking.dformerDigit = [ 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 ]; }
	return gmapInitResult;
}
function KsGMapMap_init_gmap(){
	KsGMapMap.gmap = new GMap2( document.getElementById( ksgmap_html_googleMap ) );

	if( ksgmap_control_zoom == 1 	){ KsGMapMap.gmap.addControl( new GLargeMapControl() );  }
	if( ksgmap_control_zoom == 2 	){ KsGMapMap.gmap.addControl( new GSmallMapControl() );  }
	if( ksgmap_control_zoom == 3 	){ KsGMapMap.gmap.addControl( new GSmallZoomControl() ); }
	if( ksgmap_control_type			){ KsGMapMap.gmap.addControl( new GMapTypeControl()  );  }
	if( ksgmap_control_scale		){ setTimeout( "KsGMapMap.gmap.addControl( new GScaleControl() );" , ( ksgmap_poweredByKsGMap_time * 1000 ) ); }
	if( ksgmap_control_overviewMap	){ KsGMapMap.gmap.addControl( new GOverviewMapControl( new GSize( ksgmap_control_overviewMap_width , ksgmap_control_overviewMap_height ) ) ); }
	if(      ksgmap_default_item						){ var defaultPoint = new GLatLng( ksgmap_item[ ksgmap_default_item ].lat			, ksgmap_item[ ksgmap_default_item ].lng		); }
	else if( ksgmap_default_lng && ksgmap_default_lat	){ var defaultPoint = new GLatLng( ksgmap_default_lat								, ksgmap_default_lng							); }
	else if( ksgmap_focus_category						){ var defaultPoint = new GLatLng( ksgmap_category[ ksgmap_focus_category ].lat		, ksgmap_category[ ksgmap_focus_category ].lng	); }
	else												 { var defaultPoint = new GLatLng( 35.68402											, 139.77448										); }
	KsGMapMap.gmap.setCenter( defaultPoint , ksgmap_default_zoom );
	if( ksgmap_default_type == "hybrid" && KsGMapInit_checkHybridEnable()	){ KsGMapMap.gmap.setMapType( G_HYBRID_MAP );    }
	if( ksgmap_default_type == "satellite"									){ KsGMapMap.gmap.setMapType( G_SATELLITE_MAP ); }
	if( ksgmap_limit_dragging ){ KsGMapMap.gmap.disableDragging(); }
/*
	if( ksgmap_infoWindow_tab ){
		KsGMapMap.infoWindow.tabLabel = ksgmap_infoWindow_tab.split( "," );
		var update_tabs = function( attr , tabPage ){
			if( attr != "page" ){ return; }
			tabPage = parseInt( tabPage );
			KsGMapMap.infoWindow.tabPage = tabPage;
			KsGMapMap.infoWindow.open( "tab" , KsGMapMap.infoWindow.currentItemID , KsGMapMap.infoWindow.currentMarker );
		}
		var infoWindow = KsGMapMap.gmap.getInfoWindow();
		infoWindow.addContext( "iwstate"    , update_tabs );
		infoWindow.addContext( "iwnavigate" , update_tabs );
	}
*/
	KsGMapMap.geocoder = new GClientGeocoder();
	window.onunload = GUnload;
	var gmapInitResult = {};
	gmapInitResult.defaultPoint = defaultPoint;
	return gmapInitResult;
}
function KsGMapMap_init_event(){
	var obj_gmap = document.getElementById( ksgmap_html_googleMap );
	GEvent.addListener( KsGMapMap.gmap , "movestart"		, KsGMapMap.event.moveStart	);
	GEvent.addListener( KsGMapMap.gmap , "moveend"			, KsGMapMap.event.moveEnd	);
	GEvent.addListener( KsGMapMap.gmap , "zoomend"			, KsGMapMap.event.zoomEnd		);
	GEvent.addListener( KsGMapMap.gmap , "infowindowopen" 	, KsGMapMap.event.infoWindowOpen  );
	GEvent.addListener( KsGMapMap.gmap , "infowindowclose"	, KsGMapMap.event.infoWindowClose );
	if(      ksgmap__ua.MSIE   ){ window.attachEvent( "onresize" , KsGMapMap.event.resize );			}
	else if( ksgmap__ua.Safari ){ window.onresize = KsGMapMap.event.resize;								}
	else						{ window.addEventListener( "resize" , KsGMapMap.event.resize , false ); }
	if(      ksgmap__ua.MSIE   ){ obj_gmap.attachEvent( "onclick" , function(){ obj_gmap.focus(); } ); }
	if(      ksgmap__ua.MSIE   ){ obj_gmap.attachEvent( "onmousewheel" , KsGMapMap.event.mouseWheel ); }
	else if( ksgmap__ua.Safari ){ obj_gmap.onmousewheel = KsGMapMap.event.mouseWheel; }
	else						{ obj_gmap.addEventListener( "DOMMouseScroll" , KsGMapMap.event.mouseWheel , false ); }
}
function KsGMapMap_event_moveStart(){
	var center = KsGMapMap.gmap.getCenter();
	KsGMapEX.callback( this , arguments , center.x , center.y );
	if( ksgmap_marker[ "_center" ] ){ ksgmap_marker[ "_center" ].movestart(); } 
	if( KsGMapMap.event.moveCompletionID ){
		clearTimeout( KsGMapMap.event.moveCompletionID );  
		KsGMapMap.event.moveCompletionID = "";
	}
}
function KsGMapMap_event_moveEnd(){
	var center = KsGMapMap.gmap.getCenter();
	KsGMapEX.callback( this , arguments , center.x , center.y );
	if( center.x < ksgmap_limit_lng_min || center.x > ksgmap_limit_lng_max || center.y < ksgmap_limit_lat_min || center.y > ksgmap_limit_lat_max ){
		var lng = ( ( [ center.x , ksgmap_limit_lng_min , ksgmap_limit_lng_max ] ).sort() )[ 1 ];
		var lat = ( ( [ center.y , ksgmap_limit_lat_min , ksgmap_limit_lat_max ] ).sort() )[ 1 ];
		KsGMapMap.gmap.panTo( new GLatLng( lat , lng ) );
		KsGMapMap.infoBar.display( KsGMapMap.infoBar.message.limitPoint , 5000 );
		return ;
	}
	if( ksgmap_marker[ "_center" ] ){ ksgmap_marker[ "_center" ].marking(); }
	if( KsGMapMap.event.moveCompletionID ){ clearTimeout( KsGMapMap.event.moveCompletionID ); }
	KsGMapMap.event.moveCompletionID = setTimeout( "KsGMapMap.event.moveCompletion( " + center.x + " , " + center.y + " )" , 750 );
}
function KsGMapMap_event_moveCompletion( lng , lat ){
	KsGMapEX.callback( this , arguments , lng , lat );
	var temp = String( lng ).split( "." );  var str_lng = temp[ 0 ] + "." + temp[ 1 ].substring( 0 , 5 );
	var temp = String( lat ).split( "." );  var str_lat = temp[ 0 ] + "." + temp[ 1 ].substring( 0 , 5 );
	KsGMapInfo.setURL( "point" , str_lng , str_lat );
	if( ksgmap_html_mapInfo_point ){ KsGMapInfo.dispPoint( lng , lat ); }
	if( ( KsGMapSort.distance && KsGMapInfo.urlPriorityType != "item" ) || ksgmap_focus_category == "_map" ){
		ksgmap_category[ ksgmap_focus_category ].marking();
	}
	if( ksgmap_html_itemNavi_autoZoom ){ KsGMapItemNavi.checkAutoZoom(); }
	if( ksgmap_debug_mode ){ KsGMapCommon.HTML.write( "ksgmap--debug-point" , ( str_lng + " , " + str_lat + "　　　　　　lng=\"" + str_lng + "\" lat=\"" + str_lat + "\"" + "　　　　　　z=" + KsGMapMap.gmap.getZoom() ) ); }
	if( ksgmap_html_googleLocal ){ document.getElementById( ksgmap_html_googleLocal ).value = String( lat ) + "," + String( lng ); }
	KsGMapMap.event.moveCompletionID = "";
}
function KsGMapMap_event_resize(){
	var windowSize = KsGMapCommon.HTML.getWindowSize();
	KsGMapEX.callback( this , arguments , windowSize.width , windowSize.height );
	var map_width  = parseInt( document.getElementById( ksgmap_html_googleMap ).offsetWidth  );
	var map_height = parseInt( document.getElementById( ksgmap_html_googleMap ).offsetHeight );
	if( ksgmap_design_mapLiquidWidth  ){ map_width  = windowSize.width  + ksgmap_design_mapLiquidWidth;  }
	if( ksgmap_design_mapLiquidHeight ){ map_height = windowSize.height + ksgmap_design_mapLiquidHeight; }

	if( ksgmap_marker[ "_center" ]  && map_width  % 2 == 1 ){ map_width--; }
	if( ksgmap_marker[ "_center" ]  && map_height % 2 == 1 ){ map_height--; }
	if( ksgmap_design_mapLiquidWidth  ){ document.getElementById( ksgmap_html_googleMap ).style.width  = String( map_width  ) + "px"; }
	if( ksgmap_design_mapLiquidHeight ){ document.getElementById( ksgmap_html_googleMap ).style.height = String( map_height ) + "px"; }
	if( ksgmap_marker[ "_center" ] ){ ksgmap_marker[ "_center" ].movestart(); }
	KsGMapMap.gmap.checkResize();
}
function KsGMapMap_event_zoomEnd( oldZoomLevel, newZoomLevel ){
	KsGMapEX.callback( this , arguments , oldZoomLevel, newZoomLevel );
	if( newZoomLevel < ksgmap_limit_zoom_min ){ KsGMapMap.gmap.setZoom( ksgmap_limit_zoom_min );  KsGMapMap.infoBar.display( KsGMapMap.infoBar.message.limitZoomMin , 5000 );  return ; }
	if( newZoomLevel > ksgmap_limit_zoom_max ){ KsGMapMap.gmap.setZoom( ksgmap_limit_zoom_max );  KsGMapMap.infoBar.display( KsGMapMap.infoBar.message.limitZoomMax , 5000 );  return ; }
	if( KsGMapMap.zMarking.dformerDigit[ oldZoomLevel ] != KsGMapMap.zMarking.dformerDigit[ newZoomLevel ] ){
		ksgmap_category[ ksgmap_focus_category ].marking( "" , "TYPE:zoom" );
	}
}
function KsGMapMap_event_infoWindowOpen(){
	var temp_id = KsGMapMap.infoWindow.currentItemID;
	if( !temp_id ){ KsGMapMap.infoWindow.currentItemID = "_unknown"; }
	KsGMapEX.callback( this , arguments , temp_id );
	KsGMapInfo.setURL( "item" , temp_id );
	if( ksgmap_marker[ "_center" ] ){ ksgmap_marker[ "_center" ].remove();	}
}
function KsGMapMap_event_infoWindowClose(){
	var temp_id = KsGMapMap.infoWindow.currentItemID;
	KsGMapEX.callback( this , arguments , temp_id );
	KsGMapMap.infoWindow.currentItemID	= "";
	KsGMapInfo.urlPriorityType			= "";
	if( ksgmap_marker[ "_center" ] ){ ksgmap_marker[ "_center" ].marking(); }
}
function KsGMapMap_event_mouseWheel( event ){
	if( ksgmap_limit_zoomByMouseWheel ){ return ; }
	KsGMapEX.callback( this , arguments );
	if( KsGMapInfo.urlPriorityType == "item" ){ return ; }
	if( !KsGMapMap.userControl.mouseWheel.status ){ return ; }
	if(      ksgmap__ua.MSIE   ){ var delta = event.wheelDelta;   event.returnValue = false; }
	else if( ksgmap__ua.Safari ){ var delta = event.wheelDelta;   event.returnValue = false; }
	else						{ var delta = event.detail * -1;  event.preventDefault();    }
	if( KsGMapMap.userControl.mouseWheel.reverse ){ delta *= -1; }
	KsGMapMap.gmap.setZoom( KsGMapMap.gmap.getZoom() + ( delta < 0 ? -1 : 1 ) );
}
function KsGMapMap_event_keyDown( event ){
	if( ksgmap_limit_operateByKeyboard ){ return ; }
	if(  ksgmap__ua.MSIE ){ var keyCode = event.keyCode; }
	else 				  { var keyCode = event.witch;   }
	KsGMapEX.callback( this , arguments , event , keyCode );
	if( KsGMapCommon.Variable.getTempValue( "temp_operatebykeyboard" , false ) == 1 ){ return KsGMapCommon.Event.cancel( event ); }
	if( KsGMapMap.infoWindow.currentItemID ){
		if( keyCode == 9 ){ KsGMapMap.gmap.closeInfoWindow(); }
		return true;
	}
	var lng = 0;  var lat = 0;  var wait = 0;
	var bounds = KsGMapMap.gmap.getBounds();
	var tempSW = bounds.getSouthWest();  var tempNE = bounds.getNorthEast();
	var center = KsGMapMap.gmap.getCenter();
	switch( keyCode ){
		case 107 : KsGMapMap.gmap.setZoom( KsGMapMap.gmap.getZoom() + 1 );  break;
		case 109 : KsGMapMap.gmap.setZoom( KsGMapMap.gmap.getZoom() - 1 );  break;
		case  33 : lat = tempNE.y + ( ( tempNE.y - tempSW.y ) / 3 );  wait = 1000; break;
		case  35 : lng = tempNE.x + ( ( tempNE.x - tempSW.x ) / 3 );  wait = 1000; break;
		case  34 : lat = tempSW.y - ( ( tempNE.y - tempSW.y ) / 3 );  wait = 1000; break;
		case  36 : lng = tempSW.x - ( ( tempNE.x - tempSW.x ) / 3 );  wait = 1000; break;
		case  38 : lat = tempNE.y + ( ( tempNE.y - tempSW.y ) / 10 );    wait =  500; break;
		case  39 : lng = tempNE.x + ( ( tempNE.x - tempSW.x ) / 10 );    wait =  500; break;
		case  40 : lat = tempSW.y - ( ( tempNE.y - tempSW.y ) / 10 );    wait =  500; break;
		case  37 : lng = tempSW.x - ( ( tempNE.x - tempSW.x ) / 10 );    wait =  500; break;
		case 9   : if( KsGMapItemNavi.firstID ){ document.getElementById( KsGMapItemNavi.firstID ).focus(); }	break;
		case 27  : KsGMapMap.gmap.closeInfoWindow();						  									break;
	}
	if( lng || lat ){
		KsGMapMap.gmap.panTo( new GLatLng( ( lat ? lat : center.y ) , ( lng ? lng : center.x ) ) );
		KsGMapCommon.Variable.setTempValue( 1 , "temp_operatebykeyboard" );
		setTimeout( "KsGMapCommon.Variable.clearTempValue( \"temp_operatebykeyboard\" );" , wait );
	}
	KsGMapCommon.Event.cancel( event );
}
function KsGMapMap_infoBar_clear(){
	KsGMapEX.callback( this , arguments );
	if( !ksgmap__ua.Opera ){
		var obj = document.getElementById( "ksgmap--map-infobar" );
		KsGMapMap.infoBar.opacity = ( KsGMapMap.infoBar.opacity >= 0.1 ? KsGMapMap.infoBar.opacity - 0.1 : 0.7 );
		if( ksgmap__ua.MSIE		){ obj.style.filter		= "Alpha(opacity=" + String( KsGMapMap.infoBar.opacity * 100 ) + ")"; }
		if( ksgmap__ua.Gecko	){ obj.style.MozOpacity	= KsGMapMap.infoBar.opacity; }
		if( ksgmap__ua.Safari	){ obj.style.opacity	= KsGMapMap.infoBar.opacity; }
		if( KsGMapMap.infoBar.opacity != 0.7 ){
			setTimeout( "KsGMapMap.infoBar.clear();" , 75 );
			return;
		}
	}
	KsGMapCommon.HTML.setDisplay( "ksgmap--map-infobar" , 0 );
}
function KsGMapMap_infoBar_display( value , msec ){
	KsGMapEX.callback( this , arguments );
	var obj_infoBar = document.getElementById( 'ksgmap--map-infobar' );
	obj_infoBar.style.width = String( document.getElementById( ksgmap_html_googleMap ).offsetWidth - 40 ) + "px";
	KsGMapCommon.HTML.setDisplay( "ksgmap--map-infobar" , 1 );
	obj_infoBar.innerHTML = value;
	if( msec ){ setTimeout( "KsGMapMap.infoBar.clear();" , msec ); }
}
function KsGMapMap_infoWindow_open( type , item_id , marker ){
	if( !KsGMapMap.infoWindow.enabled ){ return; }
	if( KsGMapMap.infoWindow.currentItemID ){ KsGMapMap.gmap.closeInfoWindow(); }
	KsGMapMap.infoWindow.currentItemID = item_id;
	KsGMapMap.infoWindow.currentMarker = marker;
	var callback_result = KsGMapEX.callback( this , arguments, type , item_id , marker );
	if( callback_result.cancelParentProcess ){ return ;	}
	if( !ksgmap_infoWindow_tab ){
		var temp_html = ksgmap_item[ item_id ].getInfoWindowHTML();
		temp_html = temp_addFunc( temp_html );
		marker.openInfoWindowHtml( temp_html );
	} else { 
		var tabData = [];  var tabLabel = ksgmap_infoWindow_tab.split( "," );
		for( var i = 1 ; i <= 2 ; i++ ){
			KsGMapMap.infoWindow.tabPage = i;
			var temp_html = ksgmap_item[ item_id ].getInfoWindowHTML();
			if( !temp_html ){ continue; }
			if( i == 1 ){ temp_html = temp_addFunc( temp_html ); }
			tabData.push( new GInfoWindowTab( tabLabel[ i - 1 ] , temp_html ) );
		}
		marker.openInfoWindowTabsHtml( tabData );
	}

	function temp_addFunc( html ){
		var func_html = "";  var func_css_left = 0;
		if( ksgmap_infoWindow_func_moveCenter ){ func_html += KsGMapCommon.HTML.makePngTag( ksgmap_image_path + KsGMapMap.infoWindow.iconMoveCenterFile , 40 , 13 , { onclick : "KsGMapMap.infoWindow.moveCenter( event );" , style : "position: absolute;  left: " + func_css_left + "px;  cursor: pointer;" } , "image" );  func_css_left += 42; }
		if( ksgmap_infoWindow_func_zoomDetail ){ func_html += KsGMapCommon.HTML.makePngTag( ksgmap_image_path + KsGMapMap.infoWindow.iconZoomDetailFile , 40 , 13 , { onclick : "KsGMapMap.infoWindow.zoomDetail( event );" , style : "position: absolute;  left: " + func_css_left + "px;  cursor: pointer;" } , "image" );  func_css_left += 42; }
		if( func_html ){ html = "<div style=\"position:relative;  left: -3px;  top: -5px;  width: " + func_css_left + "px;  height: 15px;\">" + func_html + "</div>" + html; }
		return html;
	}
}
function KsGMapMap_infoWindow_close(){
}
function KsGMapMap_infoWindow_moveCenter( event ){
	var temp = ksgmap_item[ KsGMapMap.infoWindow.currentItemID ];
	var lng = ( temp.zCurrentPoint.lng ? temp.zCurrentPoint.lng : temp.lng ) + ( Math.random() / 100000 );
	var lat = ( temp.zCurrentPoint.lat ? temp.zCurrentPoint.lat : temp.lat ) + ( Math.random() / 100000 );
	KsGMapMap.gmap.closeInfoWindow();
	KsGMapMap.gmap.panTo( new GLatLng( lat , lng ) );
}
function KsGMapMap_infoWindow_zoomDetail( event ){
	var temp = ksgmap_item[ KsGMapMap.infoWindow.currentItemID ].zBrother;
	var map_point = new KsGMapPoint();
	for( var i = 0 ; i < temp.length ; i++ ){ map_point.addPoint( ksgmap_item[ temp[ i ] ].lng , ksgmap_item[ temp[ i ] ].lat ); }
	KsGMapMap.gmap.closeInfoWindow();
	map_point.moveCenterAndZoom();
}
function KsGMapMap_userControl_marker(){
	this.type		= "";
	this.visibility = 1;
	this.changeVisibility	= KsGMapMap_userControl_marker_changeVisibility;
}
function KsGMapMap_userControl_marker_changeVisibility( status ){
	this.visibility = status;
	KsGMapEX.callback( this , arguments  , status );
	switch( this.type ){
		case "marker"		: ksgmap_category[ ksgmap_focus_category ].marking();	break;
		case "centerMarker"	: ksgmap_marker[ "_center" ].marking();					break;
	}
}
function KsGMapCategory( category_id , name , lng , lat , group ){
	this.id						= category_id;
	this.name					= name;
	this.lng					= parseFloat( lng );
	this.lat					= parseFloat( lat );
	this.group					= ( group != undefined ? group : "" );
	this.defaultItems			= [];
	this.searchResultItems		= [];
	this.sortCacheItems			= [];
	this.markerCount			= 0;
	this.bounds					= { minLng : 180 , maxLng : -180 , minLat : 90 , maxLat : -90 };
	if( category_id == "_map" ){
		this.cacheItems			= "";
	}
}
KsGMapCategory.prototype = new function(){
	this.setItem				= KsGMapCategory_setItem;
	this.addSearchResultItems	= KsGMapCategory_addSearchResultItems;
	this.change					= KsGMapCategory_change;
	this.clearSearchResultItems	= KsGMapCategory_clearSearchResultItems;
	this.clearSortCacheItems	= KsGMapCategory_clearSortCacheItems;
	this.getTargetItems			= KsGMapCategory_getTargetItems;
	this.getZMarker				= KsGMapCategory_getZMarker;
	this.marking				= KsGMapCategory_marking;
	this.sort					= KsGMapCategory_sort;
}
var KsGMapCategory_callback = new KsGMapCategory( "" , "" , 0 , 0 , "" );
function KsGMapCategory_setItem( item_id , lng , lat ){
	this.defaultItems[ this.defaultItems.length ] = item_id;
	if( this.bounds.minLng > lng ){ this.bounds.minLng = lng; } 
	if( this.bounds.maxLng < lng ){ this.bounds.maxLng = lng; }
	if( this.bounds.minLat > lat ){ this.bounds.minLat = lat; }
	if( this.bounds.maxLat < lat ){ this.bounds.maxLat = lat; }
}
function KsGMapCategory_addSearchResultItems( item_id ){
	this.searchResultItems[ this.searchResultItems.length ] = item_id;
}
function KsGMapCategory_change( option , tid ){
	if( option == undefined ){ option = ""; }
	if( this.id == "-" ){ return ; }
	KsGMapItemNavi.page.num = 1;
	if( !tid ){ KsGMapEX.callback( this , arguments ); }
	if( KsGMapMap.dummyMarker ){ KsGMapMap.gmap.removeOverlay( KsGMapMap.dummyMarker ); }
	if( !option.match( /INIT/ ) ){ KsGMapMap.gmap.closeInfoWindow(); }
	if( !tid ){
		var map_point = new KsGMapPoint();
	} else {
		var temp = KsGMapCommon.Variable.getTempValue( tid , false );
		var map_point = temp.map_point;  option = temp.option;
	}
	if( KsGMapSort.distance ){
		var center = KsGMapMap.gmap.getCenter();
		if( this.lng != center.x || this.lat != center.y ){ option += " MARKING:off ITEMNAVI:off"; }
	}
	var result = this.marking( map_point , option , tid );
	ksgmap_focus_category = this.id;
	if( !result ){ return; }

	if( !option.match( /MOVE:off/ ) ){
		var temp_autoCentering = ksgmap_category_autoCentering;
		if( option.match( /AUTOCENTERING:([0-9])/ ) ){ temp_autoCentering = parseInt( RegExp.$1 ); }
		if( map_point && temp_autoCentering ){
			switch( temp_autoCentering ){
				case 1: map_point.moveCenter();  		break;
				case 2: map_point.moveCenterAndZoom();	break;
			}
		} else if( this.lng && this.lat ){
			KsGMapMap.gmap.panTo( new GLatLng( this.lat , this.lng ) );
		}
		map_point = {};
	}
	KsGMapInfo.setURL( "category" , this.id );
	if( ksgmap__ua.MSIE ){ document.getElementById( ksgmap_html_googleMap ).focus(); }
}
function KsGMapCategory_clearSearchResultItems(){
	this.searchResultItems = [];
}
function KsGMapCategory_clearSortCacheItems(){
	this.sortCacheItems = [];
}
function KsGMapCategory_getTargetItems(){
	var targetItems = [];
	var callback_result = KsGMapEX.callback( this , arguments );
	if( callback_result.cancelParentProcess ){
		return callback_result.returnValue.targetItems;
	}
	if( this.id == "_all" ){ 
		for( var category_id in ksgmap_category ){/*●_●*/
			if( category_id == "clear" || category_id.match( /^_/ ) ){ continue; }
			targetItems = targetItems.concat( ( !KsGMapSearch.status ? ksgmap_category[ category_id ].defaultItems : ksgmap_category[ category_id ].searchResultItems ) );
		}
	} else if( this.id == "_map" ){
		var bounds = KsGMapMap.gmap.getBounds();
		var tempSW = bounds.getSouthWest();  var tempNE = bounds.getNorthEast();
		var bound_w = ( tempNE.x - tempSW.x ) / 2;		  var bound_h = ( tempNE.y - tempSW.y ) / 2;
		for( var category_id in ksgmap_category ){/*●_●*/
			if( category_id == "clear" || category_id.match( /^_/ ) ){ continue; }
			var c_bounds = ksgmap_category[ category_id ].bounds;
			if( ( c_bounds.maxLng < tempSW.x - bound_w ) || ( tempNE.x + bound_w < c_bounds.minLng ) || ( c_bounds.maxLat < tempSW.y - bound_h ) || ( tempNE.y + bound_h < c_bounds.minLat ) ){ continue; }
			var temp_targetItems = ( !KsGMapSearch.status ? ksgmap_category[ category_id ].defaultItems : ksgmap_category[ category_id ].searchResultItems );
			for( var i = 0 ; i < temp_targetItems.length ; i++ ){
				if( ( ksgmap_item[ temp_targetItems[ i ] ].lng < tempSW.x - bound_w ) || ( tempNE.x + bound_w < ksgmap_item[ temp_targetItems[ i ] ].lng ) || ( ksgmap_item[ temp_targetItems[ i ] ].lat < tempSW.y - bound_h ) || ( tempNE.y + bound_h < ksgmap_item[ temp_targetItems[ i ] ].lat ) ){ continue; }
				targetItems[ targetItems.length ] = temp_targetItems[ i ];
			}
		}
	} else {
		targetItems = ( !KsGMapSearch.status ? this.defaultItems : this.searchResultItems );
	}
	if( KsGMapSort.status || KsGMapSort.distance ){ targetItems = this.sort( targetItems ); }
	if( KsGMapItemNavi.page.items ){
		var page_num			= KsGMapItemNavi.page.num;
		var page_items			= KsGMapItemNavi.page.items;
		KsGMapItemNavi.page.qty = Math.ceil( targetItems.length / page_items );
		targetItems				= targetItems.slice( ( page_num  - 1 ) * page_items , page_num * page_items );
	}
	return targetItems;
}
function KsGMapCategory_marking( map_point , option , tid ){
	if( option == undefined ){ option = ""; }
	if( !tid ){
		var targetItems = this.getTargetItems();
		var zMarker = this.getZMarker( targetItems , map_point );
		if( KsGMapCommon.Array.count( zMarker.zpoint ) >= 20 && KsGMapMap.userControl.marker.visibility && !option.match( /MARKING:off/ ) ){
			var temp = {};
			temp.targetItems = targetItems;  temp.zMarker = zMarker;  temp.map_point = map_point;  temp.option = option;
			var tid = KsGMapCommon.Variable.setTempValue( temp );
			KsGMapMap.infoBar.display( KsGMapMap.infoBar.message.waitMarking , 0 );
			KsGMapItemNavi.clear();
			if( map_point ){ setTimeout( "ksgmap_category[ '" + this.id + "' ].change( '" + option + "' , '" + tid + "' );" , 100 ); }
			else           { setTimeout( "ksgmap_category[ '" + this.id + "' ].marking( 0 , '" + option + "' , '" + tid + "' );" , 100 ); }
			return false;
		}
	} else {
		var temp = KsGMapCommon.Variable.getTempValue( tid );
		var targetItems = temp.targetItems;  var zMarker = temp.zMarker;
		KsGMapMap.infoBar.clear();
	}
	if( this.id == "_map" && zMarker.cacheItems == this.cacheItems ){ return ; } else if( this.id == "_map" ){ this.cacheItems = zMarker.cacheItems; }
	if( !tid && this.id != "_map" && option.match( /TYPE:zoom/ ) && this.markerCount == KsGMapCommon.Array.count( zMarker.zpoint ) && ksgmap_category_autoCentering != 2 ){ return ; }

	for( var i = 0 ; i < ksgmap_current_marker.length ; i++ ){ KsGMapMap.gmap.removeOverlay( ksgmap_current_marker[ i ] ); }
	ksgmap_current_marker = [];

	if( map_point && ( ksgmap_category_autoCentering == 2 || option.match( /AUTOCENTERING:2/ ) ) && !option.match( /INIT/ ) ){
		map_point.setCenterAndZoom();
		if( KsGMapMap.zMarking.dformerDigit[ map_point.newZoom ] != KsGMapMap.zMarking.dformerDigit[ KsGMapMap.gmap.getZoom() ] ){ return true; }
	}
	if( !option.match( /MARKING:off/ ) ){
		for( var zpoint in zMarker.zpoint ){
			if( zpoint == "clear" ){ continue; }
			ksgmap_item[ zMarker.zpoint[ zpoint ].item_id ].addMarker( zMarker.zpoint[ zpoint ].count , ( zMarker.zpoint[ zpoint ].sumLng / zMarker.zpoint[ zpoint ].qty ) , ( zMarker.zpoint[ zpoint ].sumLat / zMarker.zpoint[ zpoint ].qty ) , zMarker.zpoint[ zpoint ].marker , zMarker.zpoint[ zpoint ].items.length );
		}
		this.markerCount = KsGMapCommon.Array.count( zMarker.zpoint );
	}
	if( !option.match( /ITEMNAVI:off/ ) ){
		for( var i = 0 ; i < targetItems.length ; i++ ){
			var item_id = targetItems[ i ];
			var zpoint  = zMarker.item2point[ item_id ];
			if( this.id == "_map" && !zMarker.zpoint[ zpoint ].flagInMap ){ continue; }
			KsGMapItemNavi.add( item_id , zMarker.zpoint[ zpoint ].count , zMarker.zpoint[ zpoint ].marker );
			ksgmap_item[ item_id ].zBrother = zMarker.zpoint[ zpoint ].items;
			ksgmap_item[ item_id ].zCurrentPoint = { lng : ( zMarker.zpoint[ zpoint ].sumLng / zMarker.zpoint[ zpoint ].qty ) , lat : ( zMarker.zpoint[ zpoint ].sumLat / zMarker.zpoint[ zpoint ].qty ) };
		}
		KsGMapItemNavi.make();
	}
	return true;
}
function KsGMapCategory_getZMarker( targetItems , map_point ){
	var bounds = KsGMapMap.gmap.getBounds();
	var count = 1;
	var zMarker			= {};
	zMarker.zpoint		= {};
	zMarker.item2point	= {};
	zMarker.cacheItems	= "";	//
	for( var i = 0 ; i < targetItems.length ; i++ ){
		var item_id = targetItems[ i ];
		var zpoint = ksgmap_item[ item_id ].getZPoint();
		var marker = ( ksgmap_marker_key ? ksgmap_item[ item_id ].data[ ksgmap_marker_key ] : "" );
		if( zMarker.zpoint[ zpoint ] == null  ){
			var tempSW = bounds.getSouthWest();  var tempNE = bounds.getNorthEast();
			zMarker.zpoint[ zpoint ] = {};
			zMarker.zpoint[ zpoint ].item_id	= item_id;
			zMarker.zpoint[ zpoint ].marker		= "";
			zMarker.zpoint[ zpoint ].qty		= 0;
			zMarker.zpoint[ zpoint ].sumLng		= 0;
			zMarker.zpoint[ zpoint ].sumLat		= 0;
			zMarker.zpoint[ zpoint ].items		= [];
			zMarker.zpoint[ zpoint ].flagInMap = ( ( ksgmap_item[ item_id ].lng < tempSW.x ) || ( tempNE.x < ksgmap_item[ item_id ].lng ) || ( ksgmap_item[ item_id ].lat < tempSW.y ) || ( tempNE.y < ksgmap_item[ item_id ].lat ) ? 0 : 1 );
			if( this.id != "_map" || zMarker.zpoint[ zpoint ].flagInMap ){
				zMarker.zpoint[ zpoint ].count	= count;
				count++;
			} else {
				zMarker.zpoint[ zpoint ].count	= 0;
			}
		}
		zMarker.zpoint[ zpoint ].qty++;
		zMarker.zpoint[ zpoint ].sumLng += ksgmap_item[ item_id ].lng;
		zMarker.zpoint[ zpoint ].sumLat += ksgmap_item[ item_id ].lat
		zMarker.zpoint[ zpoint ].items[ zMarker.zpoint[ zpoint ].items.length ] = item_id;
		if( ksgmap_marker[ marker ] ){
			if( 	 !zMarker.zpoint[ zpoint ].marker																){ zMarker.zpoint[ zpoint ].marker = marker;		}
			else if( ksgmap_marker[ marker ].priority == ksgmap_marker[ zMarker.zpoint[ zpoint ].marker ].priority	){  }
			else if( ksgmap_marker[ "_composite" ]																	){ zMarker.zpoint[ zpoint ].marker = "_composite";	}
			else if( ksgmap_marker[ marker ].priority < ksgmap_marker[ zMarker.zpoint[ zpoint ].marker ].priority	){ zMarker.zpoint[ zpoint ].marker = marker; }
		}
		zMarker.cacheItems += item_id + "-" + zMarker.zpoint[ zpoint ].count + " ";
		zMarker.item2point[ item_id ] = zpoint;
		if( map_point ){ map_point.addPoint( ksgmap_item[ item_id ].lng , ksgmap_item[ item_id ].lat ); }
	}
	return zMarker;
}
function KsGMapCategory_sort( targetItems ){
	if( !KsGMapSort.distance && this.id != "_map" && ksgmap_category[ this.id ].sortCacheItems.length ){
		return ksgmap_category[ this.id ].sortCacheItems;
	}
	if( KsGMapSort.distance ){
		var center = KsGMapMap.gmap.getCenter();
		var lng = center.x;  var lat = center.y;
	}
	var search_array = {};
	for( var i = 0 ; i < targetItems.length ; i++ ){
		if( KsGMapSort.distance ){
			search_array[ targetItems[ i ] ] = ksgmap_item[ targetItems[ i ] ].getDistance( lng , lat );
		} else {
			var temp =  ksgmap_item[ targetItems[ i ] ].data[ KsGMapSort.key ];
			search_array[ targetItems[ i ] ] = ( KsGMapSort.type == "number" ? parseFloat( temp ) : temp );
		}
	}
	search_array = KsGMapCommon.Array.sort( search_array , "" , ( !KsGMapSort.distance && KsGMapSort.desc ? "desc" : "" ) );
	var result_array = KsGMapCommon.Array.keys( search_array );
	this.sortCacheItems = result_array;
	return result_array;
}
function KsGMapItem( item_id , category_id , name , lng , lat , argJS , argXML ){
	this.id				= item_id;
	this.category		= category_id;
	this.lng			= parseFloat( lng );
	this.lat			= parseFloat( lat );
	this.name			= name;
	this.distance		= 0;
	this.zBrother		= [];
	this.zCurrentPoint	= {};
	var gData = [];
	if( argJS  ){ for( var i= 0 ; i < ksgmap_item_argName.length ; i++ ){ gData[ ksgmap_item_argName[ i ] ] = ( argJS[ i ] ? argJS[ i ] : "" ); } }
	if( argXML ){ gData = argXML; }
	this.data			= gData;
	this.distance		= 0;
	ksgmap_category[ category_id ].setItem( item_id , this.lng , this.lat );
}
KsGMapItem.prototype = new function(){
	this.addMarker					= KsGMapItem_addMarker;
	this.getDistance				= KsGMapItem_getDistance;
	this.getInfoWindowHTML			= KsGMapItem_getInfoWindowHTML;
	this.getZPoint					= KsGMapItem_getZPoint;
	this.makeHTML					= KsGMapItem_makeHTML;
	this.moveCenter					= KsGMapItem_moveCenter;
	this.openInfoWindowByItemNavi	= KsGMapItem_openInfoWindowByItemNavi;
}
function KsGMapItem_addMarker( count , zLng , zLat , marker_id , zBrothers ){
	if( !KsGMapMap.userControl.marker.visibility ){ return ; }
	var lng = ( zLng ? zLng : this.lng );  var lat = ( zLat ? zLat : this.lat );
	if( !marker_id || !ksgmap_marker[ marker_id ] ){ marker_id = "_default"; }
	ksgmap_marker[ marker_id ].gicon.image = ksgmap_marker[ marker_id ].iconfile.replace( "%count%" , ( ksgmap_marker[ marker_id ].filesuffix[ count ] ? ksgmap_marker[ marker_id ].filesuffix[ count ] : ksgmap_marker[ marker_id ].filesuffix[ 0 ] ) );
	var m = ksgmap_current_marker.length;
	var markerOption = {
		icon : ksgmap_marker[ marker_id ].gicon ,
		title : this.name + ( zBrothers >= 2 ? "　他" : ""  )
	}
	ksgmap_current_marker[ m ] = new GMarker( new GLatLng( lat , lng ) , markerOption );
    KsGMapMap.gmap.addOverlay( ksgmap_current_marker[ m ] );
	var temp_id = this.id;
	GEvent.addListener( ksgmap_current_marker[ m ] , "click" , function() {
		if( KsGMapMap.infoWindow.currentItemID == temp_id ){ KsGMapMap.gmap.closeInfoWindow();  return; }
		KsGMapMap.infoWindow.open( "marker" , temp_id , ksgmap_current_marker[ m ] );
	} );
}
function KsGMapItem_getDistance( lng , lat ){
	var distance = KsGMapCommon.Map.convPointsToDistance( this.lng , this.lat , lng , lat );
	this.distance = distance;
	return distance;
}
function KsGMapItem_getInfoWindowHTML(){
	var html = "";  var tab = [ "-" , true , false ];
	var myZPoint	= this.getZPoint();
	var temp_html	= this.makeHTML();
	html = ( typeof( temp_html ) == "object" ? temp_html.html : temp_html );
	var targetItems = this.zBrother;
	for( var i = 0 ; i < targetItems.length ; i++ ){
		var item_id = targetItems[ i ];
		if( item_id == this.id ){ continue; }
		temp_html = ksgmap_item[ item_id ].makeHTML();
		if( !temp_html ){ continue; }
		html += ksgmap_zmarking_separate + ( typeof( temp_html ) == "object" ? temp_html.html : temp_html );
	}
	if( !html ){ return ""; }
	var temp_gmap = document.getElementById( ksgmap_html_googleMap );
	var layoutSize = KsGMapCommon.HTML.getLayoutSize( html );
	if( layoutSize.width >= ( temp_gmap.offsetWidth / 1.25 ) || layoutSize.height >= ( temp_gmap.offsetHeight / 2 ) ){
		if( layoutSize.height >= ( temp_gmap.offsetHeight / 2 ) ){ layoutSize.width += 20; }
		var css_w = ( layoutSize.width  >= ( temp_gmap.offsetWidth / 1.25 ) ? 1 : 0 );
		var css_h = ( layoutSize.height >= ( temp_gmap.offsetHeight / 2   ) ? 1 : 0 );
		html = "<div class=\"active\" style=\"position:relative;  left: 5px;  width:" + ( !css_w ? layoutSize.width : ( temp_gmap.offsetWidth / 1.25 ) ) + "px;  height: " + ( !css_h ? layoutSize.height : ( temp_gmap.offsetHeight / 2 ) ) + "px;  overflow: auto;  margin-top: 11px;\">" + html + "</div>";
	} else {
		html = "<div class=\"active\" id=\"ksgmsp--infoWindow\" style=\"width:" + layoutSize.width + "px;  height:" + layoutSize.height + "px;\">" + html + "</div>";
	}
	return html;
}
function KsGMapItem_getZPoint(){
	var z = KsGMapMap.gmap.getZoom();
	var lng = Math.round( this.lng * Math.pow( 10 , KsGMapMap.zMarking.dformerDigit[ z ] ) ) / Math.pow( 10 , KsGMapMap.zMarking.dformerDigit[ z ] );
	var lat = Math.round( this.lat * Math.pow( 10 , KsGMapMap.zMarking.dformerDigit[ z ] ) ) / Math.pow( 10 , KsGMapMap.zMarking.dformerDigit[ z ] );
	var zpoint = String( lng ) + "," + String( lat );
	return zpoint;
}
function KsGMapItem_makeHTML(){
	var gData = this.data;
	var iData = [];
	for( var i in gData ){ iData[ i ] = gData[ i ]; }
	if( typeof( user_KsGMapItem_makeHTML ) == "function" ){
		var html = user_KsGMapItem_makeHTML( iData );
	} else if( ksgmap_template[ "undefined" ] ){
		var html = KsGMapCommon.Data.convTemplate( iData );
	} else {
		if( typeof( iData[ "value" ] ) == "undefined" ){ iData[ "value" ] = ""; }
		if( typeof( iData[ "_html" ] ) == "undefined" ){ iData[ "_html" ]  = ""; }
		var html = "<div><strong>" + iData[ "name" ] + "</strong><br>" + iData[ "value" ] + iData[ "_html" ] + "</div>";
	}
	return html;
}
function KsGMapItem_moveCenter(){
	KsGMapMap.gmap.closeInfoWindow();
	KsGMapMap.gmap.panTo( new GLatLng( this.lat , this.lng ) );
}
function KsGMapItem_openInfoWindowByItemNavi( count , option ){
	if( option == undefined ){ option = ""; }
	var lng = ( this.zCurrentPoint.lng ? this.zCurrentPoint.lng : this.lng );
	var lat = ( this.zCurrentPoint.lat ? this.zCurrentPoint.lat : this.lat );
	if( KsGMapMap.dummyMarker ){ KsGMapMap.gmap.removeOverlay( KsGMapMap.dummyMarker ); }
	var marker = ( ksgmap_marker_key ? ksgmap_item[ this.id ].data[ ksgmap_marker_key ] : "" );
	if( !marker || !ksgmap_marker[ marker ] ){ marker = "_default"; }
	ksgmap_marker[ marker ].gicon.image = ksgmap_marker[ marker ].iconfile.replace( "%count%" , ( ksgmap_marker[ marker ].filesuffix[ count ] ? ksgmap_marker[ marker ].filesuffix[ count ] : ksgmap_marker[ marker ].filesuffix[ 0 ] ) );
	KsGMapMap.dummyMarker = new GMarker( new GLatLng( lat , lng ) , ksgmap_marker[ marker ].gicon );
	KsGMapMap.gmap.addOverlay( KsGMapMap.dummyMarker );
	var temp_id = this.id;
	KsGMapMap.infoWindow.open( "itemNavi" , temp_id , KsGMapMap.dummyMarker );
	GEvent.addListener( KsGMapMap.dummyMarker , 'infowindowclose' , function(){
		if( !KsGMapMap.userControl.marker.visibility || option.match( /ADDMARKER/ ) ){ KsGMapMap.gmap.removeOverlay( KsGMapMap.dummyMarker ); }
	} );
}

function KsGMapPoint(){
	this.count  = 0;  this.minLng = 0;  this.maxLng = 0;  this.minLat = 0;  this.maxLat = 0;
	this.newPoint = 0;  this.newLng = 0;  this.newLat = 0;  this.newZoom = 0;
	this.addPoint			= KsGMapPoint_addPoint;
	this.moveCenter			= KsGMapPoint_moveCenter;
	this.moveCenterAndZoom	= KsGMapPoint_moveCenterAndZoom;
	this.setCenterAndZoom	= KsGMapPoint_setCenterAndZoom;
}
function KsGMapPoint_addPoint( lng , lat ){
	if( !lng || !lat ){ return ; }
	this.count++
	if( !this.minLng || this.minLng > lng ){ this.minLng = lng; }
	if( !this.maxLng || this.maxLng < lng ){ this.maxLng = lng; }
	if( !this.minLat || this.minLat > lat ){ this.minLat = lat; }
	if( !this.maxLat || this.maxLat < lat ){ this.maxLat = lat; }
}
function KsGMapPoint_moveCenter(){
	KsGMapMap.gmap.panTo( new GLatLng( ( this.minLat + this.maxLat ) / 2 ) , ( this.minLng + this.maxLng ) / 2 );
}
function KsGMapPoint_moveCenterAndZoom(){
	if( !this.newPoint ){ this.setCenterAndZoom(); }
	KsGMapMap.gmap.setCenter( new GLatLng( this.newLat , this.newLng ) , this.newZoom );
}
function KsGMapPoint_setCenterAndZoom(){
	if( !this.count ){ return ; }
	var bounds = KsGMapMap.gmap.getBounds();
	var tempSW = bounds.getSouthWest();  var tempNE = bounds.getNorthEast();
	var bound_w = tempNE.x - tempSW.x;			var bound_h = tempNE.y - tempSW.y;
	var new_lng = ( this.minLng + this.maxLng ) / 2;	var new_lat = ( this.minLat + this.maxLat ) / 2;
	var mapTypeList = { "map" : G_NORMAL_MAP , "satellite" : G_SATELLITE_MAP , "hybrid" : G_HYBRID_MAP };
	var mapType = mapTypeList[ KsGMapInfo.getType() ];
	var minZoom = mapType.getMinimumResolution()
	var maxZoom = mapType.getMaximumResolution()

	if( this.count <= 1 ){
		var n = maxZoom;
	} else if( new_lng - ( bound_w / 2 ) > this.minLng || new_lng + ( bound_w / 2 ) < this.maxLng || new_lat - ( bound_h / 2 ) > this.minLat || new_lat + ( bound_h / 2 ) < this.maxLat ){
		var n_x  = Math.ceil( Math.log( Math.max( this.maxLng - new_lng , new_lng - this.minLng ) / ( bound_w / 2 ) ) / Math.log( 2 ) )
		var n_y  = Math.ceil( Math.log( Math.max( this.maxLat - new_lat , new_lat - this.minLat ) / ( bound_h / 2 ) ) / Math.log( 2 ) )
		var n    = KsGMapMap.gmap.getZoom() - Math.min( n_x , n_y );
		if( n < minZoom ){ n = minZoom; }
	} else {
		var n_x  = Math.floor( Math.log( ( bound_w / 2 ) / Math.max( this.maxLng - new_lng , new_lng - this.minLng ) ) / Math.log( 2 ) )
		var n_y  = Math.floor( Math.log( ( bound_h / 2 ) / Math.max( this.maxLat - new_lat , new_lat - this.minLat ) ) / Math.log( 2 ) )
		var n    = KsGMapMap.gmap.getZoom() + Math.max( n_x , n_y );
		if( n > maxZoom ){ n = maxZoom; }
	}
	this.newPoint = 1;  this.newLng = new_lng;  this.newLat = new_lat;  this.newZoom = n;
}
function KsGMapMarker( type ){
	this.gicon		= "";
	this.iconfile	= "";
	this.filesuffix = [];
	this.naviprefix = [];
	if( type == "_center" ){
		this.marker		= "";
		this.width		= 0;
		this.height		= 0;
		this.marking	= KsGMapMarker_marking;
		this.remove		= KsGMapMarker_remove;
		this.movestart	= KsGMapMarker_movestart;
	}
}
function KsGMapMarker_marking(){
	if( KsGMapInfo.urlPriorityType == "item" ){ return ; }
	KsGMapCommon.HTML.setDisplay( "ksgmap--icon-center-outer-icon"   , 0 );
	KsGMapCommon.HTML.setDisplay( "ksgmap--icon-center-outer-shadow" , 0 );
	if( this.marker ){ KsGMapMap.gmap.removeOverlay( this.marker ); }
	if( !KsGMapMap.userControl.centerMarker.visibility ){ return; }
	this.marker = new GMarker( KsGMapMap.gmap.getCenter() , this.gicon );
    KsGMapMap.gmap.addOverlay( this.marker );
	if( ksgmap_apiversion < 2 ){ this.marker.iconImage.style.cursor = "default"; }
}
function KsGMapMarker_remove(){
	KsGMapMap.gmap.removeOverlay( this.marker );
	KsGMapCommon.HTML.setDisplay( "ksgmap--icon-center-outer-icon"   , 0 );
	KsGMapCommon.HTML.setDisplay( "ksgmap--icon-center-outer-shadow" , 0 );
	this.marker = "";
}
function KsGMapMarker_movestart(){
	if( !KsGMapMap.userControl.centerMarker.visibility ){ return; }
	if( KsGMapInfo.urlPriorityType == "item" ){ return ; }
	this.remove();
	var ksgmap_obj  = document.getElementById( ksgmap_html_googleMap );
	var x = String( ksgmap_obj.offsetLeft + ( ( ksgmap_obj.offsetWidth  - this.width  + 1 ) / 2 ) + ksgmap_marker_center_adjust_x ) + "px";
	var y = String( ksgmap_obj.offsetTop  + ( ( ksgmap_obj.offsetHeight - this.height + 1 ) / 2 ) + ksgmap_marker_center_adjust_y ) + "px";
	document.getElementById( "ksgmap--icon-center-outer-icon" ).style.left = x;  document.getElementById( "ksgmap--icon-center-outer-icon" ).style.top = y;
	if( ksgmap_marker[ "_center" ].gicon.shadow ){ document.getElementById( "ksgmap--icon-center-outer-shadow" ).style.left = x;  document.getElementById( "ksgmap--icon-center-outer-shadow" ).style.top = y; }
	KsGMapCommon.HTML.setDisplay( "ksgmap--icon-center-outer-icon"   , 1 );
	KsGMapCommon.HTML.setDisplay( "ksgmap--icon-center-outer-shadow" , 1 );
}
var KsGMapSearch = new function(){
	this.status				= 0;
	this.count				= 0;
	this.dictionarySynonym	= [];
	this.init				= KsGMapSearch_init;
	this.clear				= KsGMapSearch_clear;
	this.dispMessage		= KsGMapSearch_dispMessage;
	this.search				= KsGMapSearch_search;
	this.geocoding			= KsGMapSearch_geocoding;
	this.itemName			= {};
	this.itemName.name		= [];
	this.itemName.clear		= KsGMapSearch_itemName_clear;
	this.itemName.set		= KsGMapSearch_itemName_set;
	this.narrow				= {};
	this.narrow.keys		= [];
	this.narrow.change		= KsGMapSearch_narrow_change;
	this.geocodingSearch				= {};
	this.geocodingSearch.value			= "";
	this.geocodingSearch.prevCategory	= "";
	this.geocodingSearch.result			= "";
	this.geocodingSearch.trimPrefix		= "（日本）|日本";
	this.geocodingSearch.template		= {};
	this.geocodingSearch.template.unmatch	= "<div class=\"ksgmap--message-negative\">見付かりませんでした。<br />キーワードを変えて再検索を行ってください。</div>";
	this.geocodingSearch.template.outer		= "<table>%html%</table>";
	this.geocodingSearch.template.row		= "<tr class=\"%row_class%\">%col%</tr>";
	this.geocodingSearch.template.col		= "<td onclick=\"%script%\" style=\"cursor: pointer;  color: #000000;  text-decoration: none;\">%address%</td>";
}
function KsGMapSearch_init(){
	var dic  = ksgmap_search_dic_synonym;
	if( dic ){
		dic = dic.replace( /\t/g , " " );  dic = dic.replace( /\s{2,}/g , " " );
		var temp_dic = dic.split( " " );
		for( var i = 0 ; i < temp_dic.length; i++ ){ this.dictionarySynonym[ this.dictionarySynonym.length ] = "(?:" + temp_dic[ i ].replace( /,/ , "|" ) + ")"; }
	}
}
function KsGMapSearch_itemName_clear(){
	if( ksgmap_focus_category == "_geocoding" ){
		ksgmap_focus_category = KsGMapSearch.geocodingSearch.prevCategory;
		KsGMapSearch.geocodingSearch.prevCategory = "";
	}
	this.name = [];
	KsGMapSearch.geocodingSearch.value	= "";
	KsGMapSearch.geocodingSearch.result = "";
}
function KsGMapSearch_itemName_set( value ){
	KsGMapSearch.geocodingSearch.value = value;
	for( var i = 0 ; i < KsGMapSearch.dictionarySynonym.length ; i++ ){
		var reg = new RegExp( KsGMapSearch.dictionarySynonym[ i ] , "i" );
		value = value.replace( reg , KsGMapSearch.dictionarySynonym[ i ] );
	}
	this.name = value.split( " " );
}
function KsGMapSearch_narrow_change( key , num ){
	num = parseInt( num );
	var tempNarrowSearchKeys = [];
	var flag_match = 0;
	for( var i = 0 ; i < this.keys.length ; i++ ){
		var reg = new RegExp( "^" + key + ":" );
		if( this.keys[ i ].match( reg ) &&  num ){ this.keys[ i ] = key + ":" + num;  flag_match = 1; }
		if( this.keys[ i ].match( reg ) && !num ){ flag_match = 1;  continue; }
		tempNarrowSearchKeys[ tempNarrowSearchKeys.length ] = this.keys[ i ];
	}
	if( !flag_match && num ){ tempNarrowSearchKeys[ tempNarrowSearchKeys.length ] = key + ":" + num; }
	this.keys = tempNarrowSearchKeys;
}
function KsGMapSearch_clear(){
	this.status		= 0;
	if( ksgmap_focus_category == "_geocoding" ){
		ksgmap_focus_category = KsGMapSearch.geocodingSearch.prevCategory;
		KsGMapSearch.geocodingSearch.prevCategory = "";
	}
	if( ksgmap_focus_category ){ ksgmap_category[ ksgmap_focus_category ].marking(); }
	KsGMapCategoryNavi.create();
	KsGMapCommon.HTML.write( ksgmap_html_search_message , "" );
}
function KsGMapSearch_dispMessage(){
	if( this.count ){
		var resultMessage = "<div class=\"ksgmap--message-positive\">" + this.count + "件の" + ksgmap_item_name + "が見つかりました。</div>";
	} else {
		var resultMessage = "<div class=\"ksgmap--message-negative\">1件も見つかりませんでした。</div>";
	}
	KsGMapCommon.HTML.write( ksgmap_html_search_message , resultMessage );
}
function KsGMapSearch_search(){
	KsGMapEX.callback( this , arguments );
	if( ksgmap_focus_category == "_geocoding" ){
		KsGMapSearch.geocoding();
		return; 
	}
	this.count = 0;
	for( var category_id in ksgmap_category ){
		if( category_id == "clear" ){ continue; }
		ksgmap_category[ category_id ].clearSearchResultItems();
		ksgmap_category[ category_id ].clearSortCacheItems();
	}
	var reg_searchName = [];
	if( this.itemName.name.length ){
		for( i = 0 ; i < this.itemName.name.length ; i++ ){
			if( !this.itemName.name[ i ] ){ continue; }
			reg_searchName[ reg_searchName.length ] = new RegExp( this.itemName.name[ i ] , "i" );
		}
	}
	if( !this.itemName.name.length && !this.narrow.keys.length ){ this.clear();  return; }

	LABEL_for01:
	for( var item_id in ksgmap_item ){
		if( item_id == "clear" ){ continue; }
		for( var i = 0 ; i < reg_searchName.length ; i++ ){ if( !ksgmap_item[ item_id ].name.match( reg_searchName[ i ] ) ){ continue LABEL_for01; } }
		for( var i = 0 ; i < this.narrow.keys.length ; i++ ){
			if( !ksgmap_narrowCondition[ this.narrow.keys[ i ] ] || ksgmap_narrowCondition[ this.narrow.keys[ i ] ].match( /;/ ) ){ continue; }
			if( !eval( ksgmap_narrowCondition[ this.narrow.keys[ i ] ].replace( /%([a-zA-Z][a-zA-Z0-9_]+)%/g , "ksgmap_item[ \"" + item_id + "\" ].data[ \"$1\" ]" ) ) ){ continue LABEL_for01; }
		}
		ksgmap_category[ ksgmap_item[ item_id ].category ].addSearchResultItems( item_id );
		this.count++;
	}
	if( this.count || ksgmap_search_geocoding ){ this.status = 1; }
	KsGMapItemNavi.page.num = 1;
	if( ksgmap_focus_category ){ ksgmap_category[ ksgmap_focus_category ].marking(); }
	KsGMapCategoryNavi.create();
	if( !ksgmap_search_narrow_message && !this.itemName.name.length ){ return ; }
	this.dispMessage();
}
function KsGMapSearch_geocoding( option ){
	if( !option ){ option = {}; }
	if( ksgmap_focus_category != "_geocoding" ){
		KsGMapSearch.geocodingSearch.prevCategory = ksgmap_focus_category;
		ksgmap_focus_category = "_geocoding";
	}
	var keyword = KsGMapSearch.geocodingSearch.value;
	if( ksgmap_search_geocoding_joinPrefix ){
		keyword = keyword.replace( new RegExp( "^" + ksgmap_search_geocoding_joinPrefix.replace( /\s/g , "|" ) , "g" ) , "" );
		keyword = ksgmap_search_geocoding_joinPrefix.replace( /\s/g , "" ) + keyword;
	}
	var isLandmark = ( option.landmark ? true : false );
	KsGMapMap.geocoder.getLocations(
		keyword ,
		function( response ) {
			if( !response || response.Status.code != 200 ){
				KsGMapSearch.geocodingSearch.result = KsGMapSearch.geocodingSearch.template.unmatch;
			} else {
				var html = "";
				for( var i = 0 ; i < response.Placemark.length ; i++ ){
					var replace_list = {};
					var placemark = response.Placemark[ i ];
					var lng = placemark.Point.coordinates[ 0 ];  var lat = placemark.Point.coordinates[ 1 ];
					var replace_list = { 
						address	: placemark.address.replace( new RegExp( "^" + KsGMapSearch.geocodingSearch.trimPrefix ) , "" ) , 
						script	: "return KsGMapFunc.move.toLatLng( event , " + lat + " , " + lng + " );"
					};
					var replace_list = { 
						col 		: KsGMapCommon.String.convTemplate( KsGMapSearch.geocodingSearch.template.col , replace_list ) , 
						row_class	: ( ksgmap_itemNavi_rowStrips && i % 2 != 1 ? "ksgmap--itemNavi-row-strips" : "" ) 
					};
					html += KsGMapCommon.String.convTemplate( KsGMapSearch.geocodingSearch.template.row , replace_list );
				}
				KsGMapSearch.geocodingSearch.result = KsGMapCommon.String.convTemplate( KsGMapSearch.geocodingSearch.template.outer , { html : html } );
			}
			KsGMapItemNavi.make();
		}
	);
}
var KsGMapSort = new function(){
	this.status			= 0;
	this.key			= "";
	this.desc			= 0;
	this.type			= "string";
	this.distance		= 0;
	this.init					= KsGMapSort_init;
	this.clear					= KsGMapSort_clear;
	this.setSortVar				= KsGMapSort_setSortVar;
}
function KsGMapSort_init(){
	if( ksgmap_default_sort ){ this.setSortVar( ksgmap_default_sort ); }
}
function KsGMapSort_clear(){
	this.status = 0;  this.key = "";  this.desc = 0;  this.itemNaviFormat	 = "";
	KsGMapItemNavi.page.num = 1;
	for( var category_id in ksgmap_category ){
		if( category_id == "clear" ){ continue; }
		ksgmap_category[ category_id ].clearSortCacheItems();
	}
}
function KsGMapSort_setSortVar( sortKey ){
	this.status	= 1;
	KsGMapItemNavi.page.num = 1;
	sortKey.match( /^([a-zA-Z0-9_-]+)(\s.+)?$/i );
	var option = RegExp.$2;
	if( RegExp.$1 == "_distance" ){
		this.distance = 1;
	} else {
		this.distance = 0;
		this.key = RegExp.$1;
		this.desc = ( option.match( /desc/ ) ? 1 : 0 );
		this.type = ( option.match( /num/  ) ? "number" : "string" );
	}
	this.itemNaviFormat = ( option.match( /navi:(.+)/ ) ? RegExp.$1 : "" );
}
var KsGMapCategoryNavi = new function(){
	this.id			= "";
	this.html		= "";
	this.group		= {};
	this.template		= {};
	this.template.outer	= "<select id=\"ksgmsp--categoryNavi-select\" onclick=\"KsGMapCategoryNavi.click( this );\">%html%</select>";
	this.template.group	= "　<optgroup label=\"%group_name%\">%html%</optgroup>";
	this.template.inner	= "<option id=\"ksgmsp--categoryNavi-listItem-%html_id%\" value=\"%category_id%\"%selected%>%name%</option>";
	this.innerUndefined		= "<option id=\"ksgmsp--categoryNavi-listItem--undefined\" value=\"-\" selected>%ksgmap_category_name%を選択して下さい。</option>";
	this.innerSearchUnmatch	= "<option id=\"ksgmsp--categoryNavi-listItem--undefined\" value=\"%category_id%\" selected>%ksgmap_category_name%を選択して下さい。</option>";
	this.init	= KsGMapCategoryNavi_init;
	this.add	= KsGMapCategoryNavi_add;
	this.change	= KsGMapCategoryNavi_change;
	this.make	= KsGMapCategoryNavi_make;
	this.clear	= KsGMapCategoryNavi_clear;
	this.create	= KsGMapCategoryNavi_create;
	this.click	= KsGMapCategoryNavi_click;
}
function KsGMapCategoryNavi_init(){
	this.id = ksgmap_html_categoryNavi;
	var replace_list = {};
	replace_list[ "ksgmap_category_name" ] = ksgmap_category_name;
	this.innerUndefined		= KsGMapCommon.String.convTemplate( this.innerUndefined , replace_list );
	this.innerSearchUnmatch	= KsGMapCommon.String.convTemplate( this.innerSearchUnmatch , replace_list );
}
function KsGMapCategoryNavi_add( category_id ){
	if( !this.id || category_id == "clear" ){ return ; }
	if( category_id == "_all" && ksgmap_category_all == 0 && ksgmap_focus_category != "_all" ){ return ;}
	if( category_id == "_map" && ksgmap_category_map == 0 && ksgmap_focus_category != "_map" ){ return ;}
	var replace_list = {};
	replace_list[ "category_id" ] = category_id;  replace_list[ "name" ] = ( category_id != "_geocodingSearch" ? ksgmap_category[ category_id ].name : "住所検索結果" );  replace_list[ "selected" ] = ( category_id == ksgmap_focus_category ? " selected=\"selected\"" : "" );  replace_list[ "html_id" ] = category_id.replace( /^_/ , "-" );
	var html = KsGMapCommon.String.convTemplate( this.template.inner , replace_list );
	if( ksgmap_category[ category_id ] && ksgmap_category[ category_id ].group ){
		if( !this.group[ ksgmap_category[ category_id ].group ] ){ this.group[ ksgmap_category[ category_id ].group ] = ""; }
		this.group[ ksgmap_category[ category_id ].group ] += html;
	} else {
		this.html += html;
	}
}
function KsGMapCategoryNavi_change( category_id ){
	document.getElementById( "ksgmsp--categoryNavi-select" ).value = category_id;
}
function KsGMapCategoryNavi_clear(){
	if( this.id ){ document.getElementById( !this.id ).innerHTML = ""; }
}
function KsGMapCategoryNavi_create(){
	if( !ksgmap_focus_category ){ this.html = this.innerUndefined + this.html; }
	for( var category_id in ksgmap_category ){
		if( category_id == "clear" ){ continue; }
		if( KsGMapSearch.status && category_id != "_all" && !ksgmap_category[ category_id ].searchResultItems.length ){
			if( ksgmap_focus_category == category_id ){
				var replace_list = {};
				replace_list[ "category_id" ] = category_id;  replace_list[ "name" ] = ksgmap_category[ category_id ].name;
				this.html = KsGMapCommon.String.convTemplate( this.innerSearchUnmatch , replace_list ) + this.html;
			}
			continue;
		}
		this.add( category_id );
	}
	if( KsGMapSearch.status && ksgmap_search_geocoding ){ KsGMapCategoryNavi.add( "_geocodingSearch" ); }
	this.make();
}
function KsGMapCategoryNavi_make(){
	if( !this.id ){ return; }
	var html = this.html;
	for( var group_name in this.group ){
		var replace_list = {};
		replace_list[ "group_name" ] =  group_name;  replace_list[ "html" ] = this.group[ group_name ];
		html += KsGMapCommon.String.convTemplate( this.template.group , replace_list );
	}
	var replace_list = {};
	replace_list[ "html" ] = html;
	document.getElementById( this.id ).innerHTML = KsGMapCommon.String.convTemplate( this.template.outer , replace_list );
	this.html = "";  this.group = {};
}
function KsGMapCategoryNavi_click( form ){
	if( form.value == "_geocodingSearch" ){ KsGMapSearch.geocoding();  return; }
	if( ksgmap_focus_category == form.value ){ return ; }
	ksgmap_category[ form.value ].change();
}
var KsGMapItemNavi = new function(){
	this.id			= "";
	this.html		= "";
	this.firstID	= "";
	this.tempCount	= 0;
	this.page		= {};
	this.page.num	= 1;
	this.page.items	= 0;
	this.page.qty	= 1;
	this.template				= {};
	this.template.outer			= "<table>%html%</table>";
	this.template.inner			= {};
	this.template.inner.row		= "<tr class=\"%row_class%\">%col1%%col2%%col3%</tr>";
	this.template.inner.col1	= "<td style=\"width: 25px;  text-align: center;\"><a href=\"\" id=\"ksgmap--itemNavi-countLabel-%item_id%\" accesskey=\"%countLabel%\" onclick=\"%function_openInfoWindow%\" onfocus=\"%function_openInfoWindow%\" onkeydown=\"KsGMapItemNavi.changeFocus( event );\" style=\"cursor: pointer;  color: #000000;  text-decoration: none;\">%countInnerHTML%</a></td>";
	this.template.inner.col2	= "<td colspan=\"%main_colspan%\"><span unselectable=\"on\" onclick=\"%function_openInfoWindow%\" style=\"cursor: pointer;  color: #000000;  text-decoration: none;\">%name%</span></td>";
	this.template.inner.col3	= "<td style=\"width: 70px;  text-align: right;  color: #666666;\">%thirdRow%</td>";
	this.template.pageNavi		= "<div style=\"text-align: center;\"><a style=\"color: #333333;\" href=\"\"%prev_attr%>前のページ</a>&nbsp;&nbsp;( %pageInfo% )&nbsp;&nbsp;<a style=\"color: #333333;\" href=\"\"%next_attr%>次のページ</a></div>";
	this.innerEmpty			= "<div class=\"ksgmap--message-negative\">%ksgmap_category_name%には%ksgmap_item_name%は存在しません。</div>";
	this.innerSearchUnmatch = "<div class=\"ksgmap--message-negative\">%ksgmap_category_name%には検索結果にマッチする%ksgmap_item_name%は存在しません。<br /><br /><span onclick=\"KsGMapCategoryNavi.change( '_all' );  ksgmap_category[ '_all' ].change( 'AUTOCENTERING:2' );\" style=\"cursor: pointer;  text-decoration: underline;\">マップ上にすべて表示する場合はクリック</span></div>";
	this.innerSearchAddress = "<div class=\"ksgmap--message-negative\"><span onclick=\"KsGMapCategoryNavi.change( '_geocodingSearch' );  KsGMapSearch.geocoding();\" style=\"cursor: pointer;  text-decoration: underline;\">住所検索を行う場合はクリック</span></div>";
	this.init			= KsGMapItemNavi_init;
	this.add			= KsGMapItemNavi_add;
	this.makeThirdRow	= KsGMapItemNavi_makeThirdRow;
	this.changeFocus	= KsGMapItemNavi_changeFocus;
	this.clear			= KsGMapItemNavi_clear;
	this.make			= KsGMapItemNavi_make;
	this.openInfoWindow = KsGMapItemNavi_openInfoWindow;
	this.changePage		= KsGMapItemNavi_changePage;
	this.checkAutoZoom	= KsGMapItemNavi_checkAutoZoom;
}
function KsGMapItemNavi_init(){
	this.id = ksgmap_html_itemNavi;
	this.page.items = ksgmap_itemNavi_page_items;
	if( this.id ){
		var obj = document.getElementById( this.id );
		if(      ksgmap__ua.MSIE  ){ obj.style.overflowY = "auto";  obj.style.overflowX = "hidden"; }
		else if( ksgmap__ua.Gecko ){ obj.style.overflow  = "-moz-scrollbars-vertical"; }
		else					   { obj.style.overflow  = "auto"; }
	}
	if( ksgmap_html_itemNavi_autoZoom ){ KsGMapItemNavi.checkAutoZoom(); }
}
function KsGMapItemNavi_add( item_id , count , marker_id ){
	if( !this.id ){ return; }
	if( !this.html ){ this.firstID = "ksgmap--itemNavi-countLabel-" + item_id; }
	this.tempCount++;
	var replace_list = {};
	replace_list[ "item_id" ] = item_id;  replace_list[ "count" ] = count;  replace_list[ "name" ] = ksgmap_item[ item_id ].name;
	if( !marker_id || !ksgmap_marker[ marker_id ] ){ marker_id = "_default"; }
	replace_list[ "countLabel" ] = ( ksgmap_marker[ marker_id ].naviprefix[ count ] ? ksgmap_marker[ marker_id ].naviprefix[ count ] : ksgmap_marker[ marker_id ].naviprefix[ 0 ] );
	replace_list[ "countInnerHTML" ] = replace_list[ "countLabel" ];
	if( ksgmap_marker[ "itemnavi:" + marker_id ] != undefined ){
		var countMarkerFilename = ksgmap_marker[ "itemnavi:" + marker_id ].iconfile.replace( "%count%" , ( ksgmap_marker[ "itemnavi:" + marker_id ].filesuffix[ count ] ? ksgmap_marker[ "itemnavi:" + marker_id ].filesuffix[ count ] : ksgmap_marker[ "itemnavi:" + marker_id ].filesuffix[ 0 ] ) );
		if( ksgmap_focus_category == "_map" && ksgmap__ua.MSIE <= 6 && navigator.userAgent.match( /SV1/ ) ){
			replace_list[ "countInnerHTML" ] = "<img src=\"" + countMarkerFilename + "\" width=\"" + ksgmap_marker[ "itemnavi:" + marker_id ].width + "\" height=\"" + ksgmap_marker[ "itemnavi:" + marker_id ].height + "\" alt=\"" + replace_list[ "countLabel" ] + "\" style=\"border: 0;\" />";
		} else {
			replace_list[ "countInnerHTML" ] = KsGMapCommon.HTML.makePngTag( countMarkerFilename , ksgmap_marker[ "itemnavi:" + marker_id ].width , ksgmap_marker[ "itemnavi:" + marker_id ].height , { style : "border: 0;" , title : replace_list[ "countLabel" ] , alt : replace_list[ "countLabel" ] } );
		}
	}
	replace_list[ "thirdRow" ] = this.makeThirdRow( item_id );
	replace_list[ "main_colspan" ] = ( replace_list[ "thirdRow" ] ? 1 : 2 );

	replace_list[ "function_openInfoWindow" ] = "KsGMapItemNavi.openInfoWindow( event , this , '" + item_id + "' , " + count + " );";

	replace_list[ "row_class" ] = ( ksgmap_itemNavi_rowStrips && this.tempCount % 2 != 1 ? "ksgmap--itemNavi-row-strips" : "" );
	replace_list[ "col1" ] = ( ksgmap_itemNavi_countColumn ? KsGMapCommon.String.convTemplate( this.template.inner.col1 , replace_list ) : "" );
	replace_list[ "col2" ] = KsGMapCommon.String.convTemplate( this.template.inner.col2 , replace_list );
	replace_list[ "col3" ] = ( replace_list[ "thirdRow" ] ? KsGMapCommon.String.convTemplate( this.template.inner.col3 , replace_list ) : "" );
	this.html += KsGMapCommon.String.convTemplate( this.template.inner.row , replace_list );
}
function KsGMapItemNavi_makeThirdRow( item_id ){
	var value = "";  var format = "";
	if( KsGMapSort.itemNaviFormat && KsGMapSort.distance ){
		format = KsGMapSort.itemNaviFormat;
		value = ksgmap_item[ item_id ].distance;
	} else if( KsGMapSort.itemNaviFormat && KsGMapSort.status && KsGMapSort.itemNaviFormat ){
		format = KsGMapSort.itemNaviFormat;
		value = ksgmap_item[ item_id ].data[ KsGMapSort.key ];
	} else if( ksgmap_itemNavi_thirdRow ){
		var temp = ksgmap_itemNavi_thirdRow.split( " " );
		format = ( temp[ 1 ] ? temp[ 1 ] : "" );
		value = ksgmap_item[ item_id ].data[ temp[ 0 ] ];
	}
	var callback = KsGMapEX.callback( this , arguments , item_id , value , format );
	if( callback.cancelParentProcess ){ return callback.returnValue.result;   }
	if( callback.returnValue && callback.returnValue.format  ){ format = callback.returnValue.format; }
	if( callback.returnValue && callback.returnValue.value   ){ value  = callback.returnValue.value;  }
	if( value && format ){ value = KsGMapCommon.String.sprintf( format , value ); }
	return value;
}
function KsGMapItemNavi_changeFocus( event ){
	if( !ksgmap__ua.MSIE ){ return ; }
	if( event.shiftKey || event.keyCode == 9 ){ return ; }
	KsGMapMap.gmap.closeInfoWindow();
	document.getElementById( ksgmap_html_googleMap ).focus();
}
function KsGMapItemNavi_clear(){
	if( !this.id ){ return; }
	document.getElementById( ksgmap_html_itemNavi ).innerHTML = "";
}
function KsGMapItemNavi_make(){
	if( !this.id ){ return; }
	if( this.html ){
		var replace_list = {};
		replace_list[ "html" ] = this.html;
		this.html = KsGMapCommon.String.convTemplate( this.template.outer , replace_list );
		if( KsGMapItemNavi.page.items && this.page.qty >= 2 ){
			var replace_list = {};
			replace_list[ "prev_attr" ] = " onclick=\"KsGMapItemNavi.changePage( event , " + ( this.page.num - 1 ) + " )\"" + ( this.page.num == 1 ? " disabled=\"disabled\"" : "" );
			replace_list[ "next_attr" ] = " onclick=\"KsGMapItemNavi.changePage( event , " + ( this.page.num + 1 ) + " )\"" + ( this.page.num == this.page.qty ? " disabled=\"disabled\"" : "" );
			replace_list[ "pageInfo" ]  = this.page.num + " / " + this.page.qty;
			var pageNavi = KsGMapCommon.String.convTemplate( this.template.pageNavi , replace_list );
			this.html = pageNavi + this.html + pageNavi;
		}
	} else {
		var replace_list = {};
		replace_list[ "ksgmap_category_name" ] = ( ksgmap_focus_category != "_map" ? "この" + ksgmap_category_name : "マップ内" );
		replace_list[ "ksgmap_item_name" ] = ksgmap_item_name;
		if(  KsGMapSearch.status ){
			if( !KsGMapSearch.geocodingSearch.result ){
				if( KsGMapSearch.count		){ this.html  = KsGMapCommon.String.convTemplate( this.innerSearchUnmatch , replace_list ); }
				if( ksgmap_search_geocoding ){ this.html += KsGMapCommon.String.convTemplate( this.innerSearchAddress , replace_list ); }
			} else {
				this.html = KsGMapSearch.geocodingSearch.result;
			}
		} else if( !KsGMapSearch.status ){
			this.html = KsGMapCommon.String.convTemplate( this.innerEmpty , replace_list );
		}
	}
	document.getElementById( ksgmap_html_itemNavi ).innerHTML = this.html;
	this.html = "";
	this.tempCount = 0;
}
function KsGMapItemNavi_openInfoWindow( event , obj , item_id , count ){
	if( event.shiftKey && obj.tagName != "A" ){
		ksgmap_item[ item_id ].moveCenter();
	} else {
		ksgmap_item[ item_id ].openInfoWindowByItemNavi( count );
	}
	return 	KsGMapCommon.Event.cancel( event );
}
function KsGMapItemNavi_changePage( event , pageNo ){
	if( 1 <= pageNo && pageNo <= this.page.qty ){
		this.page.num = pageNo;
		ksgmap_category[ ksgmap_focus_category ].marking();
	}
	return 	KsGMapCommon.Event.cancel( event );
}
function KsGMapItemNavi_checkAutoZoom(){
	if( ksgmap_focus_category == "_geocoding" ){ return false; }
	var map_boudns = bounds = KsGMapMap.gmap.getBounds();
	var tempSW = map_boudns.getSouthWest();  var tempNE = map_boudns.getNorthEast();
	var category_bounds	= ksgmap_category[ ksgmap_focus_category ].bounds;
	var obj = document.getElementById( ksgmap_html_itemNavi_autoZoom );
	if( tempSW.x < category_bounds.minLng && category_bounds.maxLng < tempNE.x && tempSW.y < category_bounds.minLat && category_bounds.maxLat < tempNE.y ){
		obj.disabled = true;   obj.style.cursor = "default";
	} else {
		obj.disabled = false;  obj.style.cursor = "auto";
	}
}
var KsGMapInfo = new function(){
	this.urlPriorityType 	= "";
	this.active 			= ( ( ksgmap_html_mapInfo_url || ksgmap_html_mapInfo_point ) ? 1 : 0 );
	this.url				= "";
	this.xmlInfo			= {};
	this.dispURL_extraArg	= "";
	this.dispURL				= KsGMapInfo_dispURL;
	this.dispPoint				= KsGMapInfo_dispPoint;
	this.getType				= KsGMapInfo_getType;
	this.getURL					= KsGMapInfo_getURL;
	this.setURL					= KsGMapInfo_setURL;
	this.userMessageEditor			= {};
	this.userMessageEditor.message	= "";
	this.userMessageEditor.html		= "<textarea id=\"ksgmsp--mapInfo-userMessageEditor-textarea\" onblur=\"KsGMapInfo.userMessageEditor.onblur( this );\" style=\"width: 200px;  height: 60px;\">%message%</textarea><br /><input type=\"button\" onclick=\"KsGMapInfo.userMessageEditor.submit();\" value=\"決定\" style=\"width: 100px;  letter-spacing: 1em;\"> <input type=\"button\" onclick=\"KsGMapMap.gmap.closeInfoWindow();\" value=\"キャンセル\" style=\"width: 100px;\">";
	this.userMessageEditor.open		= KsGMapInfo_userMessageEditor_open;
	this.userMessageEditor.submit	= KsGMapInfo_userMessageEditor_submit;
	this.userMessageEditor.onblur	= KsGMapInfo_userMessageEditor_onblur;
}
function KsGMapInfo_dispURL(){
	var tempObj = document.getElementById( ksgmap_html_mapInfo_url );
	if( tempObj.tagName != "INPUT" ){ tempObj.innerHTML = this.url; } else { tempObj.value = this.url; }
}
function KsGMapInfo_dispPoint( lng , lat ){
	var result = "";
	if( ksgmap_mapInfo_point_base == 60 ){
		switch( ksgmap_mapInfo_point_base60_language ){
			case "jp"	: var lang = [ "東経" , "西経" , "北緯" , "南緯" , "度" , "分" , "秒" ];  break;
			case "sign"	: var lang = [ "E" , "W" , "N" , "S" , "°" , "′" , "″" ];  break;
		}
		var decimalDigit = ksgmap_mapInfo_point_base60_decimalDigit;
		var base60_lng = KsGMapCommon.Map.convBase10ToBase60( lng );
		base60_lng.match( /^(.)([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?$/ );
		var result_lng = ( RegExp.$1 == "+" ? lang[ 0 ] : lang[ 1 ] ) + RegExp.$2 + lang[ 4 ] + RegExp.$3  + lang[ 5 ] + RegExp.$4 + lang[ 6 ] + ( decimalDigit ? RegExp.$5.substring( 1 , ( decimalDigit + 1 ) ) : "" );
		var base60_lat = KsGMapCommon.Map.convBase10ToBase60( lat );
		base60_lat.match( /^(.)([0-9]+)\.([0-9]+)\.([0-9]+)(\.([0-9]+))?$/ );
		var result_lat = ( RegExp.$1 == "+" ? lang[ 2 ] : lang[ 3 ] ) + RegExp.$2 + lang[ 4 ] + RegExp.$3  + lang[ 5 ] + RegExp.$4 + lang[ 6 ] + ( decimalDigit ? RegExp.$5.substring( 1 , ( decimalDigit + 1 ) ) : "" );
	} else {
		var decimalDigit = ksgmap_mapInfo_point_base10_decimalDigit;
		var temp = String( lng ).split( "." );  var result_lng = temp[ 0 ] + "." + temp[ 1 ].substring( 0 , decimalDigit );
		var temp = String( lat ).split( "." );  var result_lat = temp[ 0 ] + "." + temp[ 1 ].substring( 0 , decimalDigit );
	}
	var result = ksgmap_mapInfo_point_format;
	result = result.replace( "%lng%" , result_lng );
	result = result.replace( "%lat%" , result_lat );
	document.getElementById( ksgmap_html_mapInfo_point ).innerHTML = result;
}
function KsGMapInfo_getType(){
	var temp_type = KsGMapMap.gmap.getCurrentMapType();
	if(      temp_type == G_SATELLITE_MAP ){ var type = "satellite"; }
	else if( typeof( G_HYBRID_MAP ) != "undefined" && temp_type == G_HYBRID_MAP ){ var type = "hybrid"; }
	else { var type = "map"; }
	return type;
}
function KsGMapInfo_getURL(){
	return this.url;
}
function KsGMapInfo_setURL( type ){
	var arg = arguments;
	if( this.urlPriorityType ){
		if( this.urlPriorityType == "location" ){ this.urlPriorityType = "";  return ; }
		else { return ; }
	}
	if( type != "point" && ( !ksgmap_mapInfo_point_enableType || !type.match( new RegExp( ksgmap_mapInfo_point_enableType.replace( /,|\t|\s/g , "|" ) , "i" ) ) ) ){
		if( type == "location" ){ return; } else { type = "point"; }
	}
	if( type == "item" || type == "location" ){ this.urlPriorityType = type; }
	if( type == "item" && !arg[ 1 ] ){ return ; }
	if( type == "point" && ( !arg[ 1 ] || !arg[ 2 ] ) ){
		var center = KsGMapMap.gmap.getCenter();
		var temp = String( center.x ).split( "." );  arg[ 1 ] = temp[ 0 ] + "." + temp[ 1 ].substring( 0 , 5 );
		var temp = String( center.y ).split( "." );  arg[ 2 ] = temp[ 0 ] + "." + temp[ 1 ].substring( 0 , 5 );
	}
	var urlArg = "http://" + location.host + location.pathname + "?" + this.dispURL_extraArg;
	switch( type ){
		case "category"	: urlArg += "category=" + arg[ 1 ];  break;
		case "item"		: urlArg += "item=" + arg[ 1 ];  break;
		case "point"	: urlArg += "lng=" + arg[ 1 ] + "&lat=" + arg[ 2 ] + ( ksgmap_focus_category != undefined ? "&category=" + ksgmap_focus_category : "" );  break;
		case "location" : urlArg += location.search.replace( /^\?/ , "" );  break;
	}
	if( type != "location" ){	
		var temp_type = this.getType();  var temp_zoom = KsGMapMap.gmap.getZoom();
		urlArg += ( temp_zoom != ksgmap_default_zoom	? "&zoom=" + temp_zoom : "" );
		urlArg += ( temp_type != ksgmap_default_type	? "&type=" + temp_type : "" );
		urlArg += ( ksgmap_import_current_file && ksgmap_import_current_file != ksgmap_import_file ? "&import="	+ ksgmap_import_current_file : "" );
	}
	if( this.userMessageEditor.message && type != "item" ){
		urlArg += "&message=" + this.userMessageEditor.message;
	}
	this.url = urlArg;
	if( ksgmap_html_mapInfo_url ){ this.dispURL(); }
}
function KsGMapInfo_userMessageEditor_open(){
	var html 		= this.html;
	var message		= decodeURIComponent( this.message );
	message = KsGMapCommon.HTML.encode( message );
	message = message.replace( "|" , "\n" );
	html = KsGMapCommon.String.convTemplate( html , { message : message } );
	var center		= KsGMapMap.gmap.getCenter();
	var layoutSize	= KsGMapCommon.HTML.getLayoutSize( html );
	KsGMapMap.gmap.openInfoWindowHtml( new GLatLng( center.y , center.x ) , "<div class=\"ksgmsp--infoWindow-userMessage\" style=\"width: " + ( layoutSize.width + 20 ) + "px;  height: " + layoutSize.height + "px;\">" + html + "</div>" );
}
function KsGMapInfo_userMessageEditor_submit(){
	var message = document.getElementById( "ksgmsp--mapInfo-userMessageEditor-textarea" ).value;
	message = message.replace( "\n" , "|" );
	message = encodeURIComponent( message );
	this.message = message;
	KsGMapMap.gmap.closeInfoWindow();
	KsGMapInfo.setURL( "point" );
}
function KsGMapInfo_userMessageEditor_onblur( obj ){
	if( KsGMapMap.infoWindow.currentItemID ){ obj.focus(); }
}
var KsGMapEX = new function(){
	this.callbackList	= [];
	this.addCallback	= KsGMapEX_addCallback;
	this.callback		= KsGMapEX_callback;
	this.plugInList		= [];
	this.addPlugIn		= KsGMapEX_addPlugIn;
	this.isPlugInExist	= KsGMapEX_isPlugInExist;
}
function KsGMapEX_addCallback( callFunc , procFunc ){
	if( this.callbackList[ callFunc ] == undefined ){ this.callbackList[ callFunc ] = []; }
	this.callbackList[ callFunc ][ this.callbackList[ callFunc ].length ] = procFunc;
}
function KsGMapEX_callback( ref , arg ){
	var callFunc = arg.callee;
	if( this.callbackList[ callFunc ] == undefined ){ return false; }
	ref.arg = arg;
	var result = { cancelParentProcess : false , returnValue : null }
	var arg = [];
	for( var i = 2 ; i < arguments.length ; i++ ){ arg[ i - 2 ] = arguments[ i ]; }
	for( var i = 0 ; i < this.callbackList[ callFunc ].length ; i++ ){
		var func = this.callbackList[ callFunc ][ i ];
		if( !func ){ continue; }
		var temp_ret = func.apply( ref , arg );
		if( temp_ret ){
			if( temp_ret.cancelParentProcess	){ result.cancelParentProcess	= temp_ret.cancelParentProcess; }
			if( temp_ret.returnValue			){ result.returnValue			= temp_ret.returnValue; }
		}
	}
	return result;
}
function KsGMapEX_addPlugIn( plugInName , version , compatibilityVersion ){
	if( compatibilityVersion != undefined && ksgmap__version < compatibilityVersion ){ KsGMapCommon.Error.trigger( "設定エラー：プラグイン（ " + plugInName + " ）は、この KsGMap本体のバージョンでは動作しません。" , "i003" );  return; }
	this.plugInList[ this.plugInList.length ] = plugInName;
}
function KsGMapEX_isPlugInExist( plugInName ){
	for( var i = 0 ; i < this.plugInList.length ; i++ ){ if( this.plugInList[ i ] == plugInName ){ return true; } }
	return false;
}
function KsGMapDataCategory( category_id , name , lng , lat , group ){
	ksgmap_category[ category_id ] = new KsGMapCategory( category_id , name , lng , lat , group );
}
function KsGMapDataItem( item_id , category_id , name , lng , lat ){
	if( !ksgmap_category[ category_id ] ){ KsGMapCommon.Error.trigger( "データインポートエラー：" + name + "（" + item_id + " ）のカテゴリ（ " + category_id + " ）が定義されていません。" , "i002" , 0 );        }
	ksgmap_item[ item_id ] = new KsGMapItem( item_id , category_id , name , lng , lat , arguments , "" );
}
function KsGMapDataImportXML( xmlDoc ){
	KsGMapEX.callback( this , arguments , xmlDoc );
	ksgmap__title = KsGMapCommon.XML.getValueByUniqueTag( xmlDoc , "title" );
	KsGMapInfo.xmlInfo = {};
	var ksgmapinfo = [ "title" , "link" , "author" , "generator" , "createdate" , "lastupdate" ];
	for( var i = 0 ; i < ksgmapinfo.length ; i++ ){ KsGMapInfo.xmlInfo[ ksgmapinfo[ i ] ] = KsGMapCommon.XML.getValueByUniqueTag( xmlDoc , ksgmapinfo[ i ] ); }
	KsGMapDataImportXML_xml2data( xmlDoc , "category" );
	KsGMapDataImportXML_xml2data( xmlDoc , "item"     );
	KsGMapDataImportXML_xml2data( xmlDoc , "template" );
}
function KsGMapDataImportXML_xml2data( xmlDoc , type ){
	var count_max	= Infinity;
	switch( type ){
		case "category" : count_max = ksgmap_import_maxCategorys;	break;
		case "item"     : count_max = ksgmap_import_maxItems;		break;
	}
	var temp_xmlData = xmlDoc.documentElement.getElementsByTagName( type );
	for( var i = 0 ; i < temp_xmlData.length ; i++ ){
		var iData = KsGMapCommon.XML.convAttributesToArray( temp_xmlData[ i ] );
		iData[ "flagXML" ]  = 1;
		iData[ "_html" ]    = GXml.value( temp_xmlData[ i ] );
		switch( type ){
			case "category" :
				ksgmap_category[ iData[ "id" ] ] = new KsGMapCategory( iData[ "id" ] , iData[ "name" ] , iData[ "lng" ] , iData[ "lat" ] , iData[ "group" ] );
				break;
			case "item" :
				if( !ksgmap_category[ iData[ "category" ] ] ){ KsGMapCommon.Error.trigger( "データインポートエラー：" + iData[ "name" ] + "（ " + iData[ "id" ] + " ）のカテゴリ（ " + iData[ "category" ] + " ）が定義されていません。" , "i002" , 0 );  break; }
				ksgmap_item[     iData[ "id" ] ] = new KsGMapItem( iData[ "id" ] , iData[ "category" ] , iData[ "name" ] , iData[ "lng" ] , iData[ "lat" ] , "" , iData );
				break;
			case "template" :
				if( iData[ "id" ] == undefined ){ iData[ "id" ] = "undefined"; }
				ksgmap_template[ iData[ "id" ] ] = { html : iData[ "_html" ] , attribute : iData };
				break;
		}
		if( i >= ( count_max - 1 ) ){ break; }
	}
}
function KsGMapDataMarker( key_value , image , shadow , image_suffix , iconSize_w , iconSize_h , shadowSize_w , shadowSize_h , iconAnchor_x , iconAnchor_y , infoWindowAnchor_x , infoWindowAnchor_y ){
	if( image_suffix.match( /(\[([A-Z])-([A-Z])\])/ ) && RegExp.$2.charCodeAt( 0 ) <= RegExp.$3.charCodeAt( 0 ) ){
		var temp = [];
		for( var i = RegExp.$2.charCodeAt( 0 ) ; i <= RegExp.$3.charCodeAt( 0 ) ; i++ ){ temp[ temp.length ] = String.fromCharCode( i ); }
		image_suffix = image_suffix.replace( RegExp.$1  , temp.join( "," ) );
	}
	ksgmap_marker[ key_value ] = new KsGMapMarker( key_value );
	ksgmap_marker[ key_value ].iconfile		= image;
	ksgmap_marker[ key_value ].filesuffix	= image_suffix.split( "," );
	ksgmap_marker[ key_value ].naviprefix	= ksgmap_marker[ key_value ].filesuffix;
	ksgmap_marker[ key_value ].filesuffix	= image_suffix.split( "," );
	ksgmap_marker[ key_value ].priority		= KsGMapCommon.Array.count( ksgmap_marker );
	ksgmap_marker[ key_value ].width		= iconSize_w;		ksgmap_marker[ key_value ].height		= iconSize_h;
	ksgmap_marker[ key_value ].swidth		= shadowSize_w;		ksgmap_marker[ key_value ].sheight		= shadowSize_h;
	if( key_value.match( /^itemnavi/ ) ){ return ; }
	if( iconAnchor_x == undefined       ){ iconAnchor_x = Math.floor( iconSize_w / 2 );			}
	if( iconAnchor_y == undefined       ){ iconAnchor_y = iconSize_h;							}
	if( infoWindowAnchor_x == undefined ){ infoWindowAnchor_x = Math.floor( iconSize_w / 2 );	}  
	if( infoWindowAnchor_y == undefined ){ infoWindowAnchor_y = 2;  							}
	ksgmap_marker[ key_value ].gicon = new GIcon();
	ksgmap_marker[ key_value ].gicon.image = image;
	ksgmap_marker[ key_value ].gicon.iconSize			= new GSize(  iconSize_w		 , iconSize_h         );
	if( shadow						 ){ ksgmap_marker[ key_value ].gicon.shadow	    = shadow;	}
	if( shadowSize_w && shadowSize_h ){ ksgmap_marker[ key_value ].gicon.shadowSize = new GSize( shadowSize_w , shadowSize_h ); }
	ksgmap_marker[ key_value ].gicon.iconAnchor			= new GLatLng( iconAnchor_y       , iconAnchor_x	   );
	ksgmap_marker[ key_value ].gicon.infoWindowAnchor	= new GLatLng( infoWindowAnchor_y , infoWindowAnchor_x );
}
function KsGMapDataNarrowCondition( key , condition ){
	if( !key.match( /:\d+$/ ) ){ key += ":1"; }
	ksgmap_narrowCondition[ key ] = condition;
}
/* 【諸事情で、ここから先は改造／単独利用はご遠慮下さい。KsGMap での利用では問題ありません】 */
var KsGMapCommon = new function(){
	this.Array								= {};
	this.Array.count						= KsGMapCommon_Array_count;
	this.Array.keys							= KsGMapCommon_Array_keys;
	this.Array.merge						= KsGMapCommon_Array_merge;
	this.Array.sort							= KsGMapCommon_Array_sort;
	this.Data								= {};
	this.Data.conv3digitcomma				= KsGMapCommon_Data_conv3digitcomma;
	this.Data.convTemplate					= KsGMapCommon_Data_convTemplate;
	this.Data.makeAnchorTag					= KsGMapCommon_Data_makeAnchorTag;
	this.Data.makeImageTag					= KsGMapCommon_Data_makeImageTag;
	this.Data.sprintf						= KsGMapCommon_String_sprintf;
	this.Error								= {};
	this.Error.trigger						= KsGMapCommon_Error_trigger;
	this.Event								= {};
	this.Event.cancel						= KsGMapCommon_Event_cancel;
	this.HTML								= {};
	this.HTML.encode						= KsGMapCommon_HTML_encode;
	this.HTML.makePngTag					= KsGMapCommon_HTML_makePngTag;
	this.HTML.getLayoutSize					= KsGMapCommon_HTML_getLayoutSize;
	this.HTML.getWindowSize					= KsGMapCommon_HTML_getWindowSize;
	this.HTML.openPopup						= KsGMapCommon_HTML_openPopup;
	this.HTML.closePopup					= KsGMapCommon_HTML_closePopup;
	this.HTML.setDisplay					= KsGMapCommon_HTML_setDisplay;
	this.HTML.write							= KsGMapCommon_HTML_write;
	this.Map								= {};
	this.Map.convBase10ToBase60				= KsGMapCommon_Map_convBase10ToBase60;
	this.Map.convCoordinateGTokyoToWGS84	= KsGMapCommon_Map_convCoordinateGTokyoToWGS84;
	this.Map.convCoordinateWGS84ToGTokyo	= KsGMapCommon_Map_convCoordinateWGS84ToGTokyo;
	this.Map.convPointsToDistance			= KsGMapCommon_Map_convPointsToDistance;
	this.Map.getNearData					= KsGMapCommon_Map_getNearData;
	this.String								= {};
	this.String.convTemplate				= KsGMapCommon_String_convTemplate;
	this.String.repeat						= KsGMapCommon_String_repeat;
	this.String.sprintf						= KsGMapCommon_String_sprintf;
	this.Variable							= {};
	this.Variable.tempValue					= [];
	this.Variable.convInputValue			= KsGMapCommon_Variable_convInputValue;
	this.Variable.clearTempValue			= KsGMapCommon_Variable_clearTempValue;
	this.Variable.getTempValue				= KsGMapCommon_Variable_getTempValue;
	this.Variable.setTempValue				= KsGMapCommon_Variable_setTempValue;
	this.XML								= {};
	this.XML.convAttributesToArray			= KsGMapCommon_XML_convAttributesToArray;
	this.XML.include						= KsGMapCommon_XML_include;
	this.XML.getValueByUniqueTag			= KsGMapCommon_XML_getValueByUniqueTag;
}
function KsGMapCommon_Array_count( array ){
	if( !array ){ return 0; } 
	var result = 0;
	if( array.length   ){ result = array.length; }
	else				{ for( var i in array ){ if( i != "clear" ){ result++; } } }
	return result;
}
function KsGMapCommon_Array_keys( array ){
	var result_array = [];
	for( var key in array ){ if( key != "clear" ){ result_array[ result_array.length ] = key; } }
	return result_array;
}
function KsGMapCommon_Array_merge(){
	var result = [];
	for( var i = 0 ; i < arguments.length ; i++ ){
		for( var temp in arguments[ i ] ){
			if( temp == "clear" ){ continue; }
			result[ temp ] = arguments[ i ][ temp ];
		}
	}
	return result;
}
/*
function KsGMapCommon_Array_sort( base_array , sort_key , option ){
	var sort_str = 0;
	var sort_desc = ( option == "desc" ? 1 : 0 );
	var sort_array = new Array();
	for( var key in base_array ){
		if( key == "clear" ){ continue; }
		var l = sort_array.length;
		sort_array[ l ] = new Array();
		sort_array[ l ][ "key"   ] = key;
		sort_array[ l ][ "value" ] = base_array[ key ];
		if( isNaN( ( sort_key ? base_array[ key ][ sort_key ] : base_array[ key ] ) ) ){ sort_str = 1; }
	}
	for( var j = sort_array.length ; j >= 0 ; j-- ){ 
		for( var i = 0 ; i < ( j - 1 ) ; i++ ){
			var comp_1 = ( sort_key ? sort_array[ i     ][ "value" ][ sort_key ] : sort_array[ i     ][ "value" ] );
			var comp_2 = ( sort_key ? sort_array[ i + 1 ][ "value" ][ sort_key ] : sort_array[ i + 1 ][ "value" ] );
			var result = ( ( !sort_str ? Number( comp_1 ) : String( comp_1 ) ) > ( !sort_str ? Number( comp_2 ) : String( comp_2 ) ) ? 1 : 0 );
			if( sort_desc ){ result = Math.abs( result - 1 ); }
			if( result ){
				var temp = sort_array[ i + 1 ]; 
				sort_array[ i + 1 ] = sort_array[ i ]; 
				sort_array[ i ] = temp;
			}
		} 
	}
	var result_array = new Array();
	for( var i = 0 ; i < sort_array.length ; i++ ){
		result_array[ sort_array[ i ][ "key" ] ] = sort_array[ i ][ "value" ];
	}
	return result_array;
}
*/
function KsGMapCommon_Array_sort( base_array , sort_key , option ){
	var sort_str = 0;
	var sort_desc = ( option == "desc" ? 1 : 0 );
	var sort_array = [];  var n = 0;
	for( var key in base_array ){
		var l = sort_array.length;
		sort_array[ l ] = [];
		sort_array[ l ][ "key"   ] = key;
		sort_array[ l ][ "value" ] = base_array[ key ];
		if( isNaN( ( sort_key ? base_array[ key ][ sort_key ] : base_array[ key ] ) ) ){ sort_str = 1; }
		n++;
	}
	if( !n ){ return base_array; }
	var tempChangeType = ( sort_str ? function( v ){ return String( v ); } : function( v ){ return Number( v ); } );
	if( sort_key   ){ tempSortObjectRoutine(   sort_array , 0 , sort_array.length - 1 ); }
	else			{ tempSortStandardRoutine( sort_array , 0 , sort_array.length - 1 ); }
	var result_array = {};
	if( !sort_desc ){ for( var i = 0 ; i < sort_array.length ; i++      ){ result_array[ sort_array[ i ][ "key" ] ] = sort_array[ i ][ "value" ]; } }
	else			{ for( var i = sort_array.length - 1 ; i >= 0 ; i-- ){ result_array[ sort_array[ i ][ "key" ] ] = sort_array[ i ][ "value" ]; } }
	return result_array;

	function tempSortStandardRoutine( sort_array , first , last ){
		var x = tempChangeType( sort_array[ Math.floor( ( first + last ) / 2 ) ].value );  var i = first;  var j = last;
		while( true ){
			while( tempChangeType( sort_array[ i ].value ) < x ){ i++; }
			while( x < tempChangeType( sort_array[ j ].value ) ){ j--; }
			if ( i >= j ){ break; }
			var t = sort_array[ i ];  sort_array[ i ] = sort_array[ j ];  sort_array[ j ] = t;  i++;  j--; 
		}
		if( first < i - 1 ){ tempSortStandardRoutine( sort_array , first , i - 1 ); }
		if( j + 1 < last  ){ tempSortStandardRoutine( sort_array , j + 1 , last  ); }
	}
	function tempSortObjectRoutine( sort_array , first , last ){
		var x = tempChangeType( sort_array[ Math.floor( ( first + last ) / 2 ) ].value[ sort_key ] );  var i = first;  var j = last;
		while( true ){
			while( tempChangeType( sort_array[ i ].value[ sort_key ] ) < x ){ i++; }
			while( x < tempChangeType( sort_array[ j ].value[ sort_key ] ) ){ j--; }
			if ( i >= j ){ break; }
			var t = sort_array[ i ];  sort_array[ i ] = sort_array[ j ];  sort_array[ j ] = t;  i++;  j--; 
		}
		if( first < i - 1 ){ tempSortObjectRoutine( sort_array , first , i - 1 ); }
		if( j + 1 < last  ){ tempSortObjectRoutine( sort_array , j + 1 , last  ); }
	}
}
function KsGMapCommon_Data_conv3digitcomma( num , failed ){
	if( isFinite( num ) ){ 
		num = String( num );
		while( num != ( num = num.replace( /^(-?\d+)(\d{3})(\.?\d*)/ , "$1,$2$3" ) ) ){}
		var result = num;
	} else {
		var result = ( typeof( failed ) != "undefined" ? failed : num );
	}
	return result;
}
function KsGMapCommon_Data_convTemplate( replace_list , template_id ){
	if( template_id == undefined ){ template_id = "undefined"; }
	if( !ksgmap_template[ template_id ] ){ return "Template Not Fount!"; }
	var result = KsGMapCommon.String.convTemplate( ksgmap_template[ template_id ].html , replace_list );
	return result;
}
function KsGMapCommon_Data__makeTag( tagName , endtag , attribute , innerHTML ){
	var result = "<" + tagName;
	for( var key in attribute ){
		if( key != "clear" && !key.match( /^_/ ) ){ result += " " + key + "=\"" + attribute[ key ] + "\""; }
	}
	result += ( endtag ? ">" + innerHTML + "</" + tagName + ">" : " />" );
	return result;
}
function KsGMapCommon_Data_makeAnchorTag( url , innerHTML , attribute , failed ){
	var reg = new RegExp( "^https?:\/\/[\x23-\x2f0-9a-zA-Z_!:;=?\@~]+$|^[\x23-\x2f0-9a-zA-Z_!;=?\@~]+$" );
	if( url.match( reg ) ){
		if( !attribute ){ attribute = {}; }
		attribute.href		= url;
		if( !attribute.target && ksgmap_link_type == 2 ){ attribute.target = "_blank"; }
		var result = KsGMapCommon_Data__makeTag( "a" , true , attribute , innerHTML );
	} else {
		var result = ( typeof( failed ) != "undefined" ? failed : url );
	}
	return result;
}
function KsGMapCommon_Data_makeImageTag( src , width , height , attribute, failed ){
	var img = new Image()
	img.src = src;
	if( ksgmap__ua.MSIE ){ var isImg = ( img.mimeType ? 1 : 0 ); }
	else				 { var isImg = ( img.width    ? 1 : 0 ); }
	if( isImg ){
		if( !attribute ){ attribute = {}; }
		if( attribute._PreserveAspectRatio || attribute._PAR ){
			var resize = KsGMapCommon_Data_makeImageTag_getSizePreserveAspectRatio( img.width , img.height , width , height )
			width = resize.width;  height = resize.height;
			attribute.style = ( attribute.style ? attribute.style + " " : "" ) + "margin: " + resize.marginY + "px " + resize.marginX + "px " + resize.marginY + "px " + resize.marginX + "px;";
		}
		attribute.src		= src;
		attribute.width		= ( width  ? width  : img.width  );
		attribute.height	= ( height ? height : img.height ); 
		attribute.alt		= ( attribute.alt ? attribute.alt : "" );
		var result = KsGMapCommon_Data__makeTag( "img" , false , attribute );
	} else {
		var result = ( typeof( failed ) != "undefined" ? failed : src );
	}
	return result;
}
function KsGMapCommon_Data_makeImageTag_getSizePreserveAspectRatio( base_width , base_height , resize_width , resize_height ){
	var result = {};
	if( ( resize_width / base_width ) < ( resize_height / base_height ) ){
		result.width = resize_width;  result.height = Math.round( base_height * ( resize_width / base_width ) );
		result.marginX = 0;  result.marginY = ( resize_height - result.height ) / 2;
	} else if( ( resize_width / base_width ) > ( resize_height / base_height ) ){
		result.width = Math.round( base_width * ( resize_height / base_height ) );  result.height = resize_height;
		result.marginX = ( resize_width  - result.width ) / 2;  result.marginY = 0;
	} else {
		result.width = resize_width ;  result.height = resize_height;
		result.marginX = 0;  result.marginY = 0;
	}
	return result;
}
function KsGMapCommon_Error_trigger( message , errNo , errLevel ){	
	if( errLevel == undefined ){ errLevel = 0; }
	if( errLevel == 0 && !ksgmap_debug_mode ){ return true; }
	alert( message );
	return false;
}
function KsGMapCommon_Event_cancel( event ){
	if( ksgmap__ua.MSIE ){
		event.returnValue = false;
	} else {
		event.preventDefault();
	}
	return false;
}
function KsGMapCommon_HTML_encode( value ){
	var convList = [ "&:&amp;" , "<:&lt;" , ">:&gt;" , "\":&quot;" , "':&apos;" ];
	for( var i = 0 ; i < convList.length ; i++ ){
		var temp = convList[ i ].split( ":" );
		value = value.replace( new RegExp( temp[ 0 ] , "g" ) , temp[ 1 ] );
	}
	return value;
}
function KsGMapCommon_HTML_makePngTag( filename , width , height , attributes , sizingmethod ){
	if( !sizingmethod ){ sizingmethod = "scale"; }
	var temp_attributes = "";  var style = "";
	if( attributes ){
		for( var name in attributes ){ if( name != "style" ){ temp_attributes += " " + name + "=\"" + attributes[ name ] + "\""; } }
		if( attributes.style ){ style = attributes.style; }
	}
	if( ksgmap__ua.MSIE && ksgmap__ua.MSIE < 7.0 && filename.match( /\.png$/ ) ){
		var result = "<div style=\"filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + filename + "',sizingmethod=" + sizingmethod + ");  width: " + width + "px;  height: " + height + "px;  overflow: hidden;  " + style + "\"" + temp_attributes + "></div>";
	} else {
		var result = "<img src=\"" + filename + "\" width=\"" + width + "\"  height=\"" + height + "\"  alt=\"\" style=\"" + style + "\"" + temp_attributes + " />";
	}
	return result;
}
function KsGMapCommon_HTML_getLayoutSize( html ){
	var temp_obj = document.getElementById( "ksgmap--common-getlayoutsize" );
	temp_obj.innerHTML = "<div>" + html + "</div>";
	var result = { width : temp_obj.firstChild.offsetWidth , height : temp_obj.firstChild.offsetHeight };
	return result;
}
function KsGMapCommon_HTML_getWindowSize(){
	var result = {};
	var mode_standard = ( document.compatMode == "CSS1Compat" ? 1 : 0 );
	if( ksgmap__ua.MSIE && mode_standard ){
		result.width  = document.body.offsetWidth;  result.height = document.documentElement.offsetHeight;
	} else if( ( ksgmap__ua.MSIE && !mode_standard ) ){
		result.width  = document.body.clientWidth;  result.height = document.body.clientHeight;
	} else if( ksgmap__ua.Gecko || ksgmap__ua.Safari ){
		result.width = document.body.offsetWidth;  result.height = window.innerHeight;
	} else if( ksgmap__ua.Opera ){
		result.width = document.body.offsetWidth - 20;  result.height = window.innerHeight;
	}
	return result;
}
function KsGMapCommon_HTML_openPopup( id , option ){
	if( option == undefined ){ option = ""; }
	var obj_box = document.getElementById( id );
	if( !obj_box ){ KsGMapCommon.Error.trigger( "設定エラー：指定されたID（ " + id + " ）のHTMLタグが存在しません。" , "i004" , 0 );  return false; }
	obj_box.style.display = "block";
	var temp = [ "width" , "height" , "left" , "top" , "right" , "bottom" ];
	for( var i = 0 ; i < temp.length ; i++ ){
		if( option.match( new RegExp( temp[ i ] + "\\s?[=:]\\s?([0-9]+)(px|%)?" , "i" ) ) ){ obj_box.style[ temp[ i ] ] = RegExp.$1 + ( RegExp.$2 ? RegExp.$2 : "px" ); }
	}
	if( option.match( /left\s?[=:]\s?center/i ) ){ obj_box.style.left = String( ( obj_box.parentNode.offsetWidth  - obj_box.offsetWidth  ) / 2 ) + "px"; }
	if( option.match( /top\s?[=:]\s?center/i  ) ){ obj_box.style.top  = String( ( obj_box.parentNode.offsetHeight - obj_box.offsetHeight ) / 2 ) + "px"; }
	obj_box.style.zIndex = 301;
	
	if( !option.match( /shadow\s?[=:]\s?(?:0|off|false)/ ) ){
		var obj_shadow	= document.getElementById( "ksgmap--common-popupShadow" );
		obj_shadow.style.display = "block";
		var shadow_width		= obj_box.offsetWidth + 28;  			var shadow_height		= obj_box.offsetHeight + 28;
		obj_shadow.style.left	= String( obj_box.offsetLeft ) + "px";	obj_shadow.style.top    = String( obj_box.offsetTop ) + "px";  
		obj_shadow.style.width	= String( shadow_width ) + "px";		obj_shadow.style.height = String( shadow_height ) + "px";  
		obj_shadow.style.zIndex = 300;
		var insertTag = "";
		insertTag += KsGMapCommon.HTML.makePngTag( ksgmap_image_path + "ksgmap_popup_shadow_bl.png" , 28					, 28						, { style : "position: absolute;  left:  0px;  top: " + String( obj_box.offsetHeight ) + "px;" } );
		insertTag += KsGMapCommon.HTML.makePngTag( ksgmap_image_path + "ksgmap_popup_shadow_br.png" , 28					, 28						, { style : "position: absolute;  left: " + String( obj_box.offsetWidth ) + "px;  top: " + String( obj_box.offsetHeight ) + "px;" } );
		insertTag += KsGMapCommon.HTML.makePngTag( ksgmap_image_path + "ksgmap_popup_shadow_tr.png" , 28					, 28						, { style : "position: absolute;  left: " + String( obj_box.offsetWidth ) + "px;  top: 0px;" } );
		insertTag += KsGMapCommon.HTML.makePngTag( ksgmap_image_path + "ksgmap_popup_shadow_bc.png" , ( shadow_width - 56 ) , 28						, { style : "position: absolute;  left: 28px;  top: " + String( obj_box.offsetHeight ) + "px;" } );
		insertTag += KsGMapCommon.HTML.makePngTag( ksgmap_image_path + "ksgmap_popup_shadow_cr.png" , 28					, ( shadow_height - 56 )	, { style : "position: absolute;  left: " + String( obj_box.offsetWidth ) + "px;  top: 28px;" } );
		obj_shadow.innerHTML = insertTag;
	}
	if( !option.match( /close\s?[=:]\s?(?:0|off|false)/ ) && !document.getElementById( "ksgmap--common-popupClose-" + id ) ){
		obj_box.innerHTML = obj_box.innerHTML + "<img id=\"ksgmap--common-popupClose-" + id + "\" src=\"" + ksgmap_image_path + "ksgmap_popup_close.png\" width=\"14\" height=\"13\" alt=\"閉じる\" onclick=\"KsGMapCommon.HTML.closePopup( '" + id + "' )\" style=\"position: absolute;  right: 10px;  top: 10px;  cursor: pointer;\">";
	}
	if( ksgmap__ua.MSIE && !option.match( /select\s?[=:]\s?(?:1|on|true)/ ) ){
		var obj_select = document.getElementsByTagName( "select" );
		for( var i = 0 ; i < obj_select.length ; i++ ){ obj_select[ i ].style.visibility = "hidden"; }
	}
	if( !option.match( /maplimit\s?[=:]\s?(?:0|off|false)/ ) ){
		if( !ksgmap_limit_dragging ){ KsGMapMap.gmap.disableDragging(); }
		KsGMapMap.infoWindow.enabled = false;
	}
}
function KsGMapCommon_HTML_closePopup( id ){
	var obj_box		= document.getElementById( id );
	var obj_shadow	= document.getElementById( "ksgmap--common-popupShadow" );
	var obj_select = document.getElementsByTagName( "select" );
	if( !obj_box ){ KsGMapCommon.Error.trigger( "設定エラー：指定されたID（ " + id + " ）のHTMLタグが存在しません。" , "i004" , 0 );  return false; }
	if( document.getElementById( "ksgmap--common-popupClose-" + id ) ){ obj_box.removeChild( document.getElementById( "ksgmap--common-popupClose-" + id ) ); }
	obj_box.style.display		= "none";
	obj_shadow.style.display	= "none";
	if( ksgmap__ua.MSIE ){ for( var i = 0 ; i < obj_select.length ; i++ ){ obj_select[ i ].style.visibility = "visible"; } }
	if( !ksgmap_limit_dragging ){ KsGMapMap.gmap.enableDragging(); }
	KsGMapMap.infoWindow.enabled = true;
}
function KsGMapCommon_HTML_setDisplay( id , type ){
	var obj = document.getElementById( id );
	if( !obj ){ return false; }
	if( !ksgmap__ua.Opera ){ obj.style.display		= ( type ? "block"   : "none"   ); }
	else				   { obj.style.visibility	= ( type ? "visible" : "hidden" ); }
	return true;
}
function KsGMapCommon_HTML_write( id , html ){
	if( !id || !document.getElementById( id ) ){ return false; }
	document.getElementById( id ).innerHTML = html;
	return true;
}
function KsGMapCommon_Map_convBase10ToBase60( base10 ){
	base10 = parseFloat( base10 );
	var minus = 0;
	if( base10 < 0 ){ base10 *= -1 ;  minus = 1; }
	var base60_1 = Math.floor( base10 );
	base10 = ( base10 - base60_1 ) * 60;
	var base60_2 = Math.floor( base10 );
	base10 = ( base10 - base60_2 ) * 60;
	var base60_3 = base10;
	var result =
		( !minus ? "+" : "-" ) +
		String( base60_1 ) + "." + 
		( base60_2 < 10 ? "0" : "" ) + String( base60_2 ) + "." + 
		( base60_3 < 10 ? "0" : "" ) + String( base60_3 );
	if( arguments[ 1 ] ){
		var result_obj = {};
		result_obj.lng = result;  result_obj.lat = KsGMapCommon_Map_convBase10ToBase60( arguments[ 1 ] );
		return result_obj;
	} else {
		return result;
	}
}
function KsGMapCommon_Map_convCoordinateGTokyoToWGS84(){
	var result = {};
	if( typeof( arguments[ 0 ] ) == "object" ){ result.lng = arguments[ 0 ].x;  result.lat = arguments[ 0 ].y; }
	else									  { result.lng = arguments[ 0 ];    result.lat = arguments[ 1 ];   }
	if( ( 115 < result.lng && result.lng < 152 ) && ( 30 < result.lat && result.lat < 50 ) ){
		result.lng -= 0.0032027777777777775;
		result.lat += 0.003236111111111111;
	}
	return result;
}
function KsGMapCommon_Map_convCoordinateWGS84ToGTokyo(){
	var result = {};
	if( typeof( arguments[ 0 ] ) == "object" ){ result.lng = arguments[ 0 ].x;  result.lat = arguments[ 0 ].y; }
	else									  { result.lng = arguments[ 0 ];    result.lat = arguments[ 1 ];   }
	if( ( 115 < result.lng && result.lng < 152 ) && ( 30 < result.lat && result.lat < 50 ) ){
		result.lng += 0.0032027777777777775;
		result.lat -= 0.003236111111111111;
	}
	return result;
}
function KsGMapCommon_Map_convPointsToDistance( lng1 , lat1 , lng2 , lat2 ){
	var lng1 = ( lng1 * Math.PI ) / 180;
	var lat1 = ( lat1 * Math.PI ) / 180;
	var lng2 = ( lng2 * Math.PI ) / 180;
	var lat2 = ( lat2 * Math.PI ) / 180;
	var t = Math.sin( lat1 ) * Math.sin( lat2 ) + Math.cos( lat1 ) * Math.cos( lat2 ) * Math.cos( lng1 - lng2 );
	var d = 20000 * Math.acos( t ) / Math.PI;
	return d;
}
function KsGMapCommon_Map_getNearData( data , type , limit ){
	if( !type  ){ type  = "all"; }
	if( !limit ){ limit = Infinity; }
	var conditionType = 0;
	var center = KsGMapMap.gmap.getCenter();
	if( type.match( /^(.+):(.+)$/ ) ){ type = RegExp.$1;  var ref = RegExp.$2.split( "," ); }
	switch( type ){
		case "map" :  var conditionType = 1;
			var bounds = KsGMapMap.gmap.getBounds();
			var tempSW = bounds.getSouthWest();  var tempNE = bounds.getNorthEast();
			var minLng = tempSW.x;  var maxLng = tempNE.x;  var minLat = tempSW.y;  var maxLat = tempNE.x;
			break;
		case "dist":  var conditionType = 1;
			ref[ 0 ] = parseFloat( ref[ 0 ] );
			var minLng = center.x - ref[ 0 ];  var maxLng = center.x + ref[ 0 ];  var minLat = center.y - ref[ 0 ];  var maxLat = center.y + ref[ 0 ];
			break;
	}
	var sort_array = [];
	for( var id in data ){
		if( key == "clear" || !data[ id ].lng || !data[ id ].lat ){ continue; }
		if( conditionType == 1 && ( data[ id ].lng < minLng || maxLng < data[ id ].lng || data[ id ].lat < minLat || maxLat < data[ id ].lat ) ){ continue; }
		sort_array[ id ] = KsGMapCommon.Map.convPointsToDistance( data[ id ].lng , data[ id ].lat , center.x , center.y );
	}
	var result_array = [];  var c = 1;
	if( sort_array ){
		sort_array = KsGMapCommon.Array.sort( sort_array );
		for( var key in sort_array ){
			if( key == "clear" ){ continue; }
			result_array[ result_array.length ] = key;
			if( c >= limit ){ break; } else { c++; }
		}
	}
	return result_array;
}
function KsGMapCommon_String_convTemplate( value , replace_list ){
	for( var key in replace_list ){ if( key != "clear" ){ value = value.replace( new RegExp( "%" + key + "%" , "g" ) , replace_list[ key ] ); } }
	return value;
}
function KsGMapCommon_String_repeat( str , count ){
	var result = "";
	for( var i = 0 ; i < parseInt( count ) ; i++ ){ result += str; }
	return result;
}
function KsGMapCommon_String_sprintf( format ){
	var count = 1;
	while( format.match( /(%([0-9\.+-]*?)([dfs]))/ ) ){
		var value = arguments[ count ];
		if( value == undefined ){ continue; }
		var replace = RegExp.$1;  var parameter = RegExp.$2;  var type = RegExp.$3;
		format = format.replace( replace , KsGMapCommon_String_sprintf_replace( replace , parameter , type , value ) );
		count++;
	}
	return format;
}
function KsGMapCommon_String_sprintf_replace( format , parameter , type , value ){
	switch( type ){
		case "d" : value = parseInt( value );	 	break;
		case "f" : value = parseFloat( value );		break;
		case "s" : value = String( value ); 		break;
	}
	var base_value = value;
	if( type == "f" && parameter.match( /\.([1-9]+)$/ ) ){
		value = String( parseInt( base_value ) ) + "." + String( Math.floor( ( base_value - parseInt( base_value ) ) * Math.pow( 10 , parseInt( RegExp.$1 ) ) ) );
	}

	if( type == "s" && parameter.match( /\.([1-9]+)$/ ) ){
		value = value.substring( 0 , parseInt( RegExp.$1 ) );
	}
	if( ( type == "d" || type == "f" ) && parameter.match( /^\+/ ) && base_value > 0 ){
		value = "+" + String( value );
	}
	if( parameter.match( /^\+?-([1-9][0-9]*)/ ) ){
		value = String( value ) + KsGMapCommon.String.repeat( "&nbsp;" , parseInt( RegExp.$1 ) - String( value ).length );
	}
	if( parameter.match( /^\+?(0)?([1-9][0-9]*)/ ) ){
		var temp1 = RegExp.$1;  var temp2 = RegExp.$2;  var temp3 = ( String( value ).match( /^(\+|-)/ ) ? RegExp.$1 : 0 );
		value = ( temp3 ? temp3 : "" ) + KsGMapCommon.String.repeat( ( temp1 != "" ? temp1 : "&nbsp;" ) , parseInt( temp2 ) - String( value ).length ) + String( value ).substring( ( temp3 ? 1 : 0 ) );
	}
	return value;
}
function KsGMapCommon_Variable_convInputValue( tempArg , option ){
	if( typeof( tempArg ) == "object" && option && option.match( /ISCHECKED/i ) ){ var result = tempArg.checked; }
	else if( typeof( tempArg ) == "object" ){ var result = tempArg.value; }
	else { var result = tempArg; }
	return result;
}
function KsGMapCommon_Variable_clearTempValue( id  ){
	KsGMapCommon.Variable.tempValue[ id ] = "";
}
function KsGMapCommon_Variable_getTempValue( id , isClear ){
	var result = KsGMapCommon.Variable.tempValue[ id ];
	if( isClear != false ){ KsGMapCommon.Variable.tempValue[ id ] = ""; }
	return result;
}
function KsGMapCommon_Variable_setTempValue( value , id ){
	if( typeof( id ) == "undefined" ){ id = "TV" + String( new Date().getTime() ) + String( Math.ceil( Math.random() * 10000 ) ); }
	KsGMapCommon.Variable.tempValue[ id ] = value;
	return id;
}
function KsGMapCommon_XML_convAttributesToArray( xmlData ){
	var result = [];
	for( var i = 0 ; i < xmlData.attributes.length ; i++ ){
		var temp = xmlData.attributes.item( i ).nodeValue;
		temp = temp.replace( /&#39;/g , "'" );
		result[ xmlData.attributes.item( i ).nodeName ] = temp;
	}
	return result;
}
function KsGMapCommon_XML_include( filename , func , option ){
	if( option == undefined ){ option = "" };
	if( ksgmap_debug_mode || !ksgmap_import_cache || option.match( /CACHE:(?:0|OFF)/i ) ){ filename += ( !filename.match( /\?/ ) ? "?" : "&" ) + "rand=" + String( Math.random() ).substring( 2 , 8 ); }
	var ksgmap_request = GXmlHttp.create();
	var method = ( option.match( /METHOD:POST/i ) ? "POST" : "GET" );
	ksgmap_request.open( method , filename , true );
	ksgmap_request.onreadystatechange = function(){
		if( ksgmap_request.readyState != 4 ){ return; }
		var xmlDoc = ksgmap_request.responseXML;
		if( !xmlDoc.documentElement ){ KsGMapCommon.Error.trigger( "データインポートエラー：ファイルが存在しないか、XMLファイルではありません。" , "i001" , 3 );  return false; }
		func.apply( null , [ xmlDoc ] );
	}
	ksgmap_request.send( null );
}
function KsGMapCommon_XML_getValueByUniqueTag( xmlDoc , tagName ){
	var temp_xmlData = xmlDoc.documentElement.getElementsByTagName( tagName );
	var result = GXml.value( temp_xmlData[ 0 ] );
	return result;
}
var KsGMapFunc = new function(){
	this.category					= {};
	this.category.change			= KsGMapFunc_category_change;
	this.html						= {};
	this.html.popupOpen				= KsGMapFunc_html_popupOpen;
	this.item						= {};
	this.item.openInfoWindow		= KsGMapFunc_item_openInfoWindow;
	this.itemNavi					= {};
	this.itemNavi.autoZoom			= KsGMapFunc_itemNavi_autoZoom;
	this.itemNavi.changeThirdRow	= KsGMapFunc_itemNavi_changeThirdRow;
	this.link						= {};
	this.link.select				= KsGMapFunc_link_select;
	this.link.ksgmap				= KsGMapFunc_link_ksgmap;
	this.map						= {};
	this.map.changeType				= KsGMapFunc_map_changeType;
	this.map.changeZoom				= KsGMapFunc_map_changeZoom;
	this.mapInfo							= {};
	this.mapInfo.select						= KsGMapFunc_mapInfo_select;
	this.mapInfo.urlAddFavorite				= KsGMapFunc_mapInfo_urlAddFavorite;
	this.mapInfo.urlCopyToClipboard			= KsGMapFunc_mapInfo_urlCopyToClipboard;
	this.mapInfo.urlLink					= KsGMapFunc_mapInfo_urlLink;
	this.mapInfo.urlSendMail				= KsGMapFunc_mapInfo_urlSendMail;
	this.mapInfo.urlOpenUserMessageEditor	= KsGMapFunc_mapInfo_urlOpenUserMessageEditor;
	this.mapInfo.pointChangeBase			= KsGMapFunc_mapInfo_pointChangeBase;
	this.move						= {};
	this.move.toLatLng				= KsGMapFunc_move_toLatLng;
	this.move.toLngLat				= KsGMapFunc_move_toLngLat;
	this.move.select				= KsGMapFunc_move_select;
	this.move.toNeighbor			= KsGMapFunc_move_toNeighbor;
	this.search						= {};
	this.search.itemName			= {};
	this.search.itemName.submit		= KsGMapFunc_search_itemName_submit;
	this.search.itemName.keydown	= KsGMapFunc_search_itemName_keydown;
	this.search.itemName.clear		= KsGMapFunc_search_itemName_clear;
	this.search.narrow				= {};
	this.search.narrow.change		= KsGMapFunc_search_narrow_change;
	this.sort						= {};
	this.sort.change				= KsGMapFunc_sort_change;
	this.userControl								= {};
	this.userControl.marker							= {};
	this.userControl.marker.changeVisibility		= KsGMapFunc_userControl_marker_changeVisibility;
	this.userControl.marker.hidden					= KsGMapFunc_userControl_marker_hidden;
	this.userControl.marker.visible					= KsGMapFunc_userControl_marker_visible;
	this.userControl.centerMarker					= {};
	this.userControl.centerMarker.changeVisibility	= KsGMapFunc_userControl_centerMarker_changeVisibility;
	this.userControl.centerMarker.hidden			= KsGMapFunc_userControl_centerMarker_hidden;
	this.userControl.centerMarker.visible			= KsGMapFunc_userControl_centerMarker_visible;
	this.userControl.mouseWheel						= {};
	this.userControl.mouseWheel.changeStatus		= KsGMapFunc_userControl_mouseWheel_changeStatus;
	this.userControl.mouseWheel.changeDirection		= KsGMapFunc_userControl_mouseWheel_changeDirection;
}
function KsGMapFunc_category_change( event , category_id ){
	if( ksgmap_category[ category_id ] ){
		if( ksgmap_html_categoryNavi ){ KsGMapCategoryNavi.change( category_id ); }
		ksgmap_category[ category_id ].change();
	}
	return KsGMapCommon.Event.cancel( event );
}
function KsGMapFunc_html_popupOpen( event , target_id , option ){
	KsGMapCommon.HTML.openPopup( target_id , option );
	return KsGMapCommon.Event.cancel( event );
}
function KsGMapFunc_item_openInfoWindow( event , item_id ){
	if( ksgmap_item[ item_id ] ){
		var option = ( ksgmap_item[ item_id ].category != ksgmap_focus_category ? "ADDMARKER" : "" );
		ksgmap_item[ item_id ].moveCenter();
		ksgmap_item[ item_id ].openInfoWindowByItemNavi( 0 , option );
	}
	return KsGMapCommon.Event.cancel( event );
}
function KsGMapFunc_itemNavi_autoZoom( event ){
	if( !ksgmap_html_itemNavi_autoZoom || document.getElementById( ksgmap_html_itemNavi_autoZoom ).disabled == false ){
		ksgmap_category[ ksgmap_focus_category ].change( 'AUTOCENTERING:2' );
	}
	return KsGMapCommon.Event.cancel( event );
}
function KsGMapFunc_itemNavi_changeThirdRow( event , tempValue ){
	ksgmap_itemNavi_thirdRow = KsGMapCommon.Variable.convInputValue( tempValue );
	ksgmap_category[ ksgmap_focus_category ].marking();
	return KsGMapCommon.Event.cancel( event );
}
function KsGMapFunc_link__commonLink( event , url ){
	switch( ksgmap_link_type ){
		case 1 : location.href = url;  break;
		case 2 : window.open( url , "_blank" );  break;
	}
	KsGMapCommon.Event.cancel( event );
}
function KsGMapFunc_link__getEvent( temp_event ){
	if( typeof( temp_event ) == "string" ){
		var event = KsGMapCommon_Variable_getTempValue( temp_event );
	} else {
		var event = temp_event;
	}
	return event;
}
function KsGMapFunc_link_select( event , form ){
	var site = form.value;
	if( site == "-" ){ return ; }
	if( site.match( /^ksgmap,(.+)$/ ) ){
		KsGMapFunc.link.ksgmap( event , RegExp.$1 );
	} else if( site.match( /^KsGMapPlugIn/ ) ){
		var eid = KsGMapCommon.Variable.setTempValue( event );
		eval( site + "( '" + eid + "' );" );
	} else if( KsGMapEX.isPlugInExist( "mapLink" ) ) {
		var eid = KsGMapCommon.Variable.setTempValue( event );
		eval( "KsGMapPlugIn_mapLink_" + site + "( '" + eid + "' );" );
	}
	form.selectedIndex = 0;
}
function KsGMapFunc_link_ksgmap( temp_event , url ){		/* この関数は改造禁止です */
	var event = KsGMapFunc_link__getEvent( temp_event );
	var center = KsGMapMap.gmap.getCenter();
	url += "?lng="		+ center.x;
	url += "&lat="		+ center.y;
	url += "&zoom="		+ KsGMapMap.gmap.getZoom();
	url += "&referer="	+ escape( location.href );
	KsGMapFunc_link__commonLink( event , url );
	return false;
}
function KsGMapFunc_map_changeType( event , tempValue ){
	var type = KsGMapCommon.Variable.convInputValue( tempValue );
	if( type == "map"										){ KsGMapMap.gmap.setMapType( G_NORMAL_MAP );		}
	if( type == "satellite"									){ KsGMapMap.gmap.setMapType( G_SATELLITE_MAP );	}
	if( type == "hybrid" && KsGMapInit_checkHybridEnable()	){ KsGMapMap.gmap.setMapType( G_HYBRID_MAP );		}
	return KsGMapCommon.Event.cancel( event );
}
function KsGMapFunc_map_changeZoom( event , tempValue ){
	var level = KsGMapCommon.Variable.convInputValue( tempValue );
	level = ( String( level ).match( /^[+-][0-9]+$/ ) ? KsGMapMap.gmap.getZoom() + parseInt( level ) : parseInt( level ) ); 
	if( level < 0 ){ level = 0; } else if( level > 17 ){ level = 17; }
	KsGMapMap.gmap.setZoom( level );
	return KsGMapCommon.Event.cancel( event );
}
function KsGMapFunc_mapInfo_select( event , form ){
	switch( form.value ){
		case "urlAddFavorite"			: KsGMapFunc.mapInfo.urlAddFavorite( event );  break;
		case "urlCopyToClipboard"		: KsGMapFunc.mapInfo.urlCopyToClipboard( event );  break;
		case "urlLink"					: KsGMapFunc.mapInfo.urlLink( event );  break;
		case "urlSendMail"				: KsGMapFunc.mapInfo.urlSendMail( event );  break;
		case "urlOpenUserMessageEditor" : KsGMapFunc.mapInfo.urlOpenUserMessageEditor( event );  break;
	}
	form.selectedIndex = 0;
	return KsGMapCommon.Event.cancel( event );
}
function KsGMapFunc_mapInfo_urlAddFavorite( event ){
	var url = KsGMapInfo.getURL();
	window.external.AddFavorite( url , document.title );
	return KsGMapCommon.Event.cancel( event );
}
function KsGMapFunc_mapInfo_urlCopyToClipboard( event ){
	var url = KsGMapInfo.getURL();
	clipboardData.setData( "Text" , url );
	return KsGMapCommon.Event.cancel( event );
}
function KsGMapFunc_mapInfo_urlLink( event ){
	var url = KsGMapInfo.getURL();
	location.href = url;
	return KsGMapCommon.Event.cancel( event );
}
function KsGMapFunc_mapInfo_urlSendMail( event ){
	var url = KsGMapInfo.getURL();
	location.href = "mailto:?body=" + escape( url );
	return KsGMapCommon.Event.cancel( event );
}
function KsGMapFunc_mapInfo_urlOpenUserMessageEditor( event ){
	KsGMapInfo.userMessageEditor.open();
	return KsGMapCommon.Event.cancel( event );
}
function KsGMapFunc_mapInfo_pointChangeBase( event , base ){
	if( !base ){ base = ( ksgmap_mapInfo_point_base == 60 ? 10 : 60 ); }
	ksgmap_mapInfo_point_base = base;
	var center = KsGMapMap.gmap.getCenter();
	KsGMapInfo.dispPoint( center.x , center.y );
	return KsGMapCommon.Event.cancel( event );
}
function KsGMapFunc_move_toLatLng( event , lat , lng ){
	KsGMapMap.gmap.closeInfoWindow();
	lng = parseFloat( lng );  lat = parseFloat( lat );
	KsGMapMap.gmap.panTo( new GLatLng( lat , lng ) );
	return ( event ? KsGMapCommon.Event.cancel( event ) : true );
}
function KsGMapFunc_move_toLngLat( event , lng , lat ){
	return KsGMapFunc.move.toLatLng( event , lat , lng );
}
function KsGMapFunc_move_select( event , form ){
	if( form.value == "-" ){ return ; }
	KsGMapMap.gmap.closeInfoWindow();
	var point = form.value.split( /[,\s\t]/ );
	lng = parseFloat( point[ 1 ] );  lat = parseFloat( point[ 0 ] );
	KsGMapMap.gmap.panTo( new GLatLng( lat , lng ) );
}
function KsGMapFunc_move_toNeighbor( event , tempValue ){
	KsGMapMap.gmap.closeInfoWindow();
	var direction = KsGMapCommon.Variable.convInputValue( tempValue );
	var bounds = KsGMapMap.gmap.getBounds();
	var tempSW = bounds.getSouthWest();  var tempNE = bounds.getNorthEast();
	var center = KsGMapMap.gmap.getCenter();
	var lng = center.x;  var lat = center.y;
	switch( direction.toLowerCase() ){
		case "north" : lat = tempNE.y + ( ( tempNE.y - tempSW.y ) / 3 );  break;
		case "east"  : lng = tempNE.x + ( ( tempNE.x - tempSW.x ) / 3 );  break;
		case "south" : lat = tempSW.y - ( ( tempNE.y - tempSW.y ) / 3 );  break;
		case "west"  : lng = tempSW.x - ( ( tempNE.x - tempSW.x ) / 3 );  break;
	}
	KsGMapMap.gmap.panTo( new GLatLng( lat , lng ) );
	return KsGMapCommon.Event.cancel( event );
}
function KsGMapFunc_search_itemName_submit( event , form ){
	var searchName = document.getElementById( ksgmap_html_search_itemName_textField ).value;
	KsGMapSearch.itemName.set( searchName );
	KsGMapSearch.search();
}
function KsGMapFunc_search_itemName_keydown( event , form ){
	if( event.keyCode == 13 ){ KsGMapFunc.search.itemName.submit( event , form ); }
}
function KsGMapFunc_search_itemName_clear( event , form ){
	document.getElementById( ksgmap_html_search_itemName_textField ).value = "";
	KsGMapSearch.itemName.clear();
	KsGMapSearch.search();
}
function KsGMapFunc_search_narrow_change( event , form ){
	var key   = form.name;
	if( form.type == "checkbox" ){
		var value = ( form.value.match( /!(\d+)/ ) ? RegExp.$1 :  form.value );
		var checked = ( form.checked ? 1 : 0 );
		if( form.value.match( /!/ ) ){ checked = Math.abs( checked - 1 ); }
		value = ( checked ? value : 0 );
	} else {
		var value = form.value;
	}
	KsGMapSearch.narrow.change( key , value );
	KsGMapSearch.search();
}
function KsGMapFunc_sort_change( event , tempValue ){
	var sortKey = KsGMapCommon.Variable.convInputValue( tempValue );
	KsGMapSort.clear();
	if( sortKey || sortKey != "-" ){ KsGMapSort.setSortVar( sortKey ); }
	ksgmap_category[ ksgmap_focus_category ].marking();
	return KsGMapCommon.Event.cancel( event );
}
function KsGMapFunc_userControl_marker_changeVisibility( event , form ){ KsGMapMap.userControl.marker.changeVisibility( ( form.checked ? 1 : 0 ) ); }
function KsGMapFunc_userControl_marker_hidden( event , form           ){ KsGMapMap.userControl.marker.changeVisibility( 0 ); }
function KsGMapFunc_userControl_marker_visible( event , form          ){ KsGMapMap.userControl.marker.changeVisibility( 1 ); }
function KsGMapFunc_userControl_centerMarker_changeVisibility( event , form ){ KsGMapMap.userControl.centerMarker.changeVisibility( ( form.checked ? 1 : 0 ) ); }
function KsGMapFunc_userControl_centerMarker_hidden( event , form           ){ KsGMapMap.userControl.centerMarker.changeVisibility( 0 ); }
function KsGMapFunc_userControl_centerMarker_visible( event , form          ){ KsGMapMap.userControl.centerMarker.changeVisibility( 1 ); }
function KsGMapFunc_userControl_mouseWheel_changeStatus( event , tempValue ){
	var value = KsGMapCommon.Variable.convInputValue( tempValue , "isChecked" );
	KsGMapMap.userControl.mouseWheel.status = value;
}
function KsGMapFunc_userControl_mouseWheel_changeDirection( event , tempValue ){
	var value = KsGMapCommon.Variable.convInputValue( tempValue , "isChecked" );
	KsGMapMap.userControl.mouseWheel.reverse = tempValue;
}

