// IE高速化 ====================================================================
/*@cc_on
eval((function(props) {
	var code = [];
	for (var i = 0, l = props.length; i < l; i++) {
		var prop = props[i];
		window['_' + prop] = window[prop];
		code.push(prop + ' = _' + prop);
	}
	return 'var ' + code.join(',');
})('document self top parent alert setInterval clearInterval setTimeout clearTimeout'.split(' ')));
@*/

// namespace ===================================================================
/******************
 * アコーディオン *
 ******************/
mapionGlobals.accordion = {

	menues: null,

	/**************************
	 * アコーディオン（init） *
	 **************************/
	init: function() {

		var self = this;

		// 全てのメニューdiv
		var tmp = [
			document.getElementById("cmjKeyword"),
			document.getElementById("cmjOften"),
			document.getElementById("cmjSlider"),
			document.getElementById("cmjBookmark"),
			document.getElementById("cmjRecommend"),
			document.getElementById("cmjResultList")
		];
		this.menues = tmp;
		
		// スタイル設定
		var a = accordionByBytefx(tmp);
		for(var  i = 0; i < tmp.length; i++) {
			tmp[i].style.display = "none";
			a = tmp[i].parentNode.childNodes[0];
			if(!a.innerHTML)
				a = tmp[i].parentNode.childNodes[1];
			//bytefx.$event(a, "onmouseover", function(){
			//	this.style.background = "#FFCC33";
			//	this.style.color = "#000";
			//});
			//bytefx.$event(a, "onmouseout", function(){
			//	this.style.background = "#2569AE";
			//	this.style.color = "#fff";
			//});
		};
		
		// 初期オープン
		var firstOpenElm = tmp[0];
		firstOpenElm.begin(function() {self.setHeaderStyle(firstOpenElm.id)});
	
		// スライダー初期化
		mapionGlobals.slider.init();
	},
	
	/**************************************************
	 * アコーディオン（メニューヘッダのスタイル設定） *
	 **************************************************/
	setHeaderStyle: function(id) {
	
		for (var i = 0; i < this.menues.length; i++) {
		
			var menu = this.menues[i];
			var menuId = menu.id;
			var headId = menuId + "Head";
			var headElm = document.getElementById(headId);
			if (id == menuId) {
				headElm.style.background = "#FFCC33";
				headElm.style.color = "#000";
				headElm.onmouseover = null;
				headElm.onmouseout = null;
			} else {
				headElm.style.background = "#2569AE";
				headElm.style.color = "#FFF";
				headElm.onmouseover = function(e) {
					this.style.background = "#FFCC33";
					this.style.color = "#000";
				};
				headElm.onmouseout = function(e) {
					this.style.background = "#2569AE";
					this.style.color = "#FFF";
				};
			}
		}
	},
	
	/******************************
	 * アコーディオン（速さ取得） *
	 ******************************/
	getSpeed: function() {
		if (mapionFuncs.net.browser.firefox || mapionFuncs.net.browser.safari) {
			return 9;
		} else {
			return 10;
		}
	},
	
	/******************************
	 * アコーディオン（オープン） *
	 ******************************/
	open: function(id) {

		this.setHeaderStyle(id);
		
		var elm = document.getElementById(id);
		
		switch (id) {
		case 'cmjSlider':
			if (mapionFuncs.net.browser.firefox) {
				if (document.getElementById("cmjInnerResultList")) {
					document.getElementById("cmjInnerResultList").style.overflow = "hidden";
				}
			}
			elm.begin(function() {
				bytefx.size(elm, {width: 280, height: document.getElementById("cmjDiv" + mapionGlobals.slider.currentDivNo).scrollHeight}, mapionGlobals.accordion.getSpeed(), function() {});
			});
			break;
		case 'cmjKeyword':
			if (mapionFuncs.net.browser.firefox) {
				if (document.getElementById("cmjInnerResultList")) {
					document.getElementById("cmjInnerResultList").style.overflow = "hidden";
				}
			}
			elm.begin(function() {document.getElementById("cmjKeywordInput").focus();});
			break;
		case 'cmjResultList':
			elm.begin(function() {
				if (document.getElementById("cmjResultList")) {
					if (document.getElementById("cmjInnerResultList")) {
						var resultListHeight = document.getElementById("cmjResultList").style.height;
						var minus = 25;
						document.getElementById("cmjInnerResultList").style.height = parseInt(resultListHeight) - minus + "px";
						if (mapionFuncs.net.browser.firefox) {
							document.getElementById("cmjInnerResultList").style.overflow = "auto";
						}
					} else {
						document.getElementById("cmjResultList").style.overflow = "auto";
					}
				}
			});
			break;
		case 'cmjOften':
			if (mapionFuncs.net.browser.firefox) {
				if (document.getElementById("cmjInnerResultList")) {
					document.getElementById("cmjInnerResultList").style.overflow = "hidden";
				}
			}
			elm.begin(function() {
				document.getElementById("cmjOften").style.overflow = "auto";
			});
			break;
		default:
			if (mapionFuncs.net.browser.firefox) {
				if (document.getElementById("cmjInnerResultList")) {
					document.getElementById("cmjInnerResultList").style.overflow = "hidden";
				}
			}
			elm.begin(function() {});
		}
	}

};

/************
 * 検索結果 *
 ************/
mapionGlobals.resultList = {

	// 検索結果のマップ
	poiInfo: {},
	
	focusId: "",

	/*****************************************
	 * 検索結果（prev/nextリンククリック時） *
	 *****************************************/
	move: function(count) {
	
		var map = mapionGlobals.map;
		
		// 全て消す
		map.clearOverlays();
		map.closeInfoWindow();
	
		var type = mapionGlobals.searchType;
		//console.log(mapionGlobals.currentGenre);
		if (type == "searchGenre") {
			type = mapionGlobals.currentGenre.split("/")[2];
		}
		var ph = mapionGlobals[type].ph;
		var start = ph.get("start");
		ph.replace("start", parseInt(start) + count);
		mapionGlobals[type].doRequest();

	},
	
	/********************************
	 * 検索結果（アイコンクリック） *
	 ********************************/
	click: function(poiId) {

		
		

		var name = mapionGlobals.resultList.poiInfo[poiId].name;

		var poi = mapionGlobals.resultList.poiInfo[poiId];
		
		var html = mapionGlobals.generateHtml(poi);
		
		var marker = this.poiInfo[poiId].marker;
		marker.openInfoWindowHtml(html);

		mapionGlobals.recommend.nameMelters = [];
		mapionGlobals.recommend.nameMelters.push("cmjMelterName" + poiId);
		mapionGlobals.doMelter();
	},
	
	/******************************************
	 * 検索結果（検索結果リスト詳細オープン） *
	 ******************************************/
	open: function(poiId, fromMarker) {

		if (!document.getElementById("cmjInnerResultList")) {
			return;
		}

		if (this.focusId == poiId) {
			return;
		}
	
		this.focusId = poiId;
		
		var poi = this.poiInfo[poiId];

		if (poi.thumbnail) {
			// 画像を拡大
			document.getElementById("cmjThumb" + poiId).style.width = "90px";
		}
		
		// キャッチフレーズ ---
		if (poi.catch_phrase) {
			document.getElementById("cmjCatchphrase" + poiId).innerHTML = poi.catch_phrase;
			document.getElementById("cmjCatchphrase" + poiId).style.display = "block";
		}
		// end ---
		
		var detailsHtml = "";
		
		// 電話番号 ---
		//var telShigai = !isNaN(parseInt(poi.tel_shigai)) ? poi.tel_shigai : "";
		//var telShinai = !isNaN(parseInt(poi.tel_shinai)) ? poi.tel_shinai : "";
		//var tel = !isNaN(parseInt(poi.tel)) ? poi.tel : "";
		//var telAll = telShigai + (telShinai != "" ? "-" + telShinai : "") + (tel != "" ? "-" + tel : "");
		//var telAll = poi.phone_number;
		// end ---
		
		// 電略 ---
		//var denryakuImg = mapionGlobals.getMakedDenryaku([poi.phone_type]);
		// end ---

		// 郵便番号と住所
		var address = "〒" + poi.zip + ' ' + poi.address;
		
		//detailsHtml += denryakuImg + telAll;
		
		/*
		if (poi.CooperateList) {
			for (var i = 0; i < poi.CooperateList.Cooperate.length; i++) {
				var cooperate = poi.CooperateList.Cooperate[i];
				if (cooperate.code == "10") {
					detailsHtml += '<a target="_blank" href="' + cooperate.url + '">';
					detailsHtml += '<img src="' + mapionGlobals.constant.WEBCALLING_IMG() + '"/>';
					detailsHtml += '</a>';
				}
			}
		}
		*/
		
		detailsHtml += "<br/>" + address;
		
		// 電話番号とかその他 ---
		document.getElementById("cmjDetails" + poiId).style.display = "block";
		document.getElementById("cmjDetails" + poiId).style.color = "#000";
		document.getElementById("cmjDetails" + poiId).innerHTML = detailsHtml;
		// end ---
	
		// ジャンル ---
		/*
		var categoryNames = [];
		var categoryAllLevelList = poi.CategoryAllLevelList instanceof Array ? poi.CategoryAllLevelList : [poi.CategoryAllLevelList];
		for (var j = 0; j < categoryAllLevelList.length; j++) {
			var cCategoryAllLevelList= categoryAllLevelList[j];
			
			// <CategoryAllLevelList/>がある場合の対処
			if (!cCategoryAllLevelList.hasOwnProperty("CategoryAllLevel")) {
				continue;
			}
			
			var categoryAllLevelListList = cCategoryAllLevelList.CategoryAllLevel instanceof Array ? cCategoryAllLevelList.CategoryAllLevel : [cCategoryAllLevelList.CategoryAllLevel];
			//for (var k = 0; k < categoryAllLevelListList.length; k++) {
			//	var cCategoryAllLevelListList = categoryAllLevelListList[k];
			//	categoryNames.push(cCategoryAllLevelListList.name);
			//}
			// 一番上だけでよい
			var cateLink = '<a href="javascript:mapionGlobals.genreClick(\'' + categoryAllLevelListList[0].id + '\', \'' + categoryAllLevelListList[0].name + '\');">';
			cateLink += categoryAllLevelListList[0].name;
			cateLink += '</a>';
			categoryNames.push(cateLink);
		}
		var categoryName = categoryNames.join(" / ");
		document.getElementById("cmjGenre" + poiId).innerHTML = '<font class="cmjSmall">' + categoryName + '</font>';
		document.getElementById("cmjGenre" + poiId).style.display = "block";
		*/
		// end ---
		
		document.getElementById("cmj" + poiId).style.backgroundColor = "#FFEE88";

		var map = mapionGlobals.map;

		var marker = this.poiInfo[poiId].marker;
		
		var isExistsMarker = marker ? true : false;
		
		if (fromMarker) {

			// 検索結果のスクロールを動かして対象を見やすくする
			var scrollHeight = 0;
			for (var i = 1; i < poi.number; i++) {
				var cTr = document.getElementById("cmjResultListTr" + i).scrollHeight;
				scrollHeight += parseInt(cTr);
			}
			var plus = -13;
			if (mapionFuncs.net.browser.IE) {
				plus += 10;
			} else {
				plus += 14;
			}
			document.getElementById("cmjInnerResultList").scrollTop = scrollHeight + plus;
		
			
		} else {
		
			// 注目アイコン ---
			if (isExistsMarker) {
				var attentionIcon = new MIcon();
				attentionIcon.getHTML = function() {
					var html = '<div align="center" id="cmjAttentionInfoWindow" valign="middle" style="background:none;">';
					html += '<img width="73" height="72" src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/mark.gif"/>';
					html += '</div>';
					return html;
				};
				attentionIcon.iconAnchor = new MPoint(73 / 2, 72 / 2);
				var attentionMarker = new MMarker(new MPoint(marker.lon, marker.lat), attentionIcon, false);
				map.addOverlay(attentionMarker);
				mapionGlobals.deleteMarkersId.push(attentionMarker.id);
			}
			// end ---
		}

	},
	
	/******************************************
	 * 検索結果（検索結果リスト詳細クローズ） *
	 ******************************************/
	close: function(poiId) {

		if (!document.getElementById("cmjInnerResultList")) {
			return;
		}

		this.focusId = "";
		
		var poi = this.poiInfo[poiId];

		if (poi.thumbnail) {
			// 画像
			document.getElementById("cmjThumb" + poiId).style.width = "50px";
		}
		
		// キャッチフレーズ（max）
		document.getElementById("cmjCatchphrase" + poiId).style.display = "none";
		
		// 電話番号とかをキャッチフレーズ（min）にする ---
		if (!poi.catch_phrase) {
			document.getElementById("cmjDetails" + poiId).style.display = "none";
		}
		document.getElementById("cmjDetails" + poiId).innerHTML = poi.catch_phrase ? (poi.catch_phrase.length > 15 ? (poi.catch_phrase.substring(0, 15) + '…')  : poi.catch_phrase) : "";
		document.getElementById("cmjDetails" + poiId).style.color = "rgb(255, 114, 0)";
		// end ---
		
		// ジャンル
		document.getElementById("cmjGenre" + poiId).style.display = "none";
		
		document.getElementById("cmj" + poiId).style.backgroundColor = "#fff";

		var map = mapionGlobals.map;
	
		var infoWindow;
		if (infoWindow = document.getElementById("cmjSmallInfoWindow")) {
			infoWindow.parentNode.removeChild(infoWindow);
		}
		
		var attentionWindow;
		if (attentionWindow = document.getElementById("cmjAttentionInfoWindow")) {
			attentionWindow.parentNode.removeChild(attentionWindow);
		}
		
		var newMarkerArray = {};
		for (var p in map.markerArray) {
			if (!map.markerArray.hasOwnProperty(p)) {
				continue;
			}
			if (!mapionGlobals.deleteMarkersId.inArray(p)) {
				newMarkerArray[p] = map.markerArray[p];
			}
		}
		map.markerArray = newMarkerArray;
		mapionGlobals.deleteMarkersId = [];

	},
	
	/************************
	 * 検索結果（html作成） *
	 ************************/
	make: function(response) {

		var map = mapionGlobals.map;
		
		// 全て消す
		map.clearOverlays();
		
		//mapionGlobals.recommend.nameMelters = [];
		//mapionGlobals.recommend.telMelters = [];
		
		
		if (document.getElementById("cmjPoiName")) {
			document.getElementById("cmjPoiName").style.visibility = "hidden";
		}
		if (document.getElementById("cmjTellAllMelter")) {
			document.getElementById("cmjTellAllMelter").style.visibility = "hidden";
		}
	
		if (!response.ResultList.Item) {
			this.hideSearchImage();
			alert("表示している地図上にはありません。");
			document.getElementById("cmjResultList").innerHTML = "";
			return;
		}
	
		// 入力ボックスからfocusを外す
		document.getElementById("cmjKeywordInput").blur();

		var poiList = response.ResultList.Item instanceof Array ? response.ResultList.Item : [response.ResultList.Item];
	
		// 結果html作成 ---
		var html = '<table style="width:280px;height:23px;" cellspacing="0" cellpadding="0"><tr>';
	
		if (mapionGlobals.currentGenre.split("/")[2] != "often") {
			html += '<td><input type="button" value="業種選択" onclick="mapionGlobals.selectGenre.click();"/></td>';
		}
	
		if (1 < response.System.start) {
			html += '<td style="width:60px;"><a href="javascript:mapionGlobals.resultList.move(-1);"><img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/botan_pre.gif" width="60" height="19"></a></td>';
		} else {
			html += '<td style="width:60px;"></td>';
		}
		
		html += '<td align="center">' + response.System.start_index + '-' + response.System.end_index + '/' + response.System.hit + '</td>';
		
		if (parseInt(response.System.end_index) < parseInt(response.System.hit)) {
			html += '<td align="right" style="width:60px;"><a href="javascript:mapionGlobals.resultList.move(1);"><img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/botan_next.gif" width="60" height="19"></a></td>';
		} else {
			html += '<td align="right" style="width:60px;"></td>';
		}
		
		html += '</tr></table>';
		
		html += '<div id="cmjInnerResultList" style="overflow:auto;height:242px;"><table border="0" style="width:262px;" cellspacing="0" cellpadding="0">';
		
		var switchObjIds = [];
		this.poiInfo = {};
		for (var i = 0; i < poiList.length; i++) {
	
			var poi = poiList[i];
			
			// 検索結果をグローバルに保存しておく
			this.poiInfo[poi.id] = poi;
			poi.number = i + 1;
			
			var poiLink;
			if (poi.ad_url_pc) {
				poiLink = "http://nttbj.itp.ne.jp" + poi.ad_url_pc + "index.html";
			} else {
				poiLink = "http://itp.ne.jp/servlet/jp.ne.itp.sear.SGSSVWebDspCtrl?Gyoumu_cate=3&Media_cate=populer&cont_id=a00&svc=1901&index_dsp=2&navi=search,r1&index_sta=0&proc_id=k1&clk=181&kid=" + poi.id;
			}

			// リンク ---
			//var telShigai = !isNaN(parseInt(poi.tel_shigai)) ? poi.tel_shigai : "";
			//var telShinai = !isNaN(parseInt(poi.tel_shinai)) ? poi.tel_shinai : "";
			//var tel = !isNaN(parseInt(poi.tel)) ? poi.tel : "";
			//var telAll = telShigai + telShinai + tel;
			var telAll = poi.phone_number;
			// end ---
			
			// 電略 ---
			var denryakuImg = mapionGlobals.getMakedDenryaku([poi.phone_type]);
			// end ---

			
			var webcalling = '';
			if (poi.CooperateList) {
/*
				for (var j = 0; j < poi.CooperateList.Cooperate.length; j++) {
					var cooperate = poi.CooperateList.Cooperate[j];
					if (cooperate.code == "10") {
						webcalling += '<a target="_blank" href="' + cooperate.url + '">';
						webcalling += '<img src="' + mapionGlobals.constant.WEBCALLING_IMG() + '"/>';
						webcalling += '</a>';
					}
				}
*/
			}
			

			//if (poi.ad == 0 || poi.ad == null) {
			//	poiLink = "http://itp.ne.jp/servlet/jp.ne.itp.sear.SGSSVWebDspCtrl?Gyoumu_cate=3&Media_cate=populer&cont_id=a00&svc=1901&index_dsp=2&navi=search,r1&index_sta=0&proc_id=k1&clk=181&kid=" + poi.id;
			//} else {
			//	poiLink = "http://nttbj.itp.ne.jp" + (poi.ad_url_web ? poi.ad_url_web : "/");
			//} 			
			//var poiLink = mapionGlobals.getPoiLink(poi);
			
			//var kuchikomi  = "http://kuchikomi.itp.ne.jp/user?ACTION_ID=STORETOP&grid=" + poi.kuchikomi_id;
			
			// キャッチフレーズ ---
			var catchphrase = poi.catch_phrase ? (poi.catch_phrase.length > 15 ? (poi.catch_phrase.substring(0, 15) + '…')  : poi.catch_phrase) : "";
			// end ---
			
			html += '<tr id="cmjResultListTr' + (i + 1) + '">';
			html += '	<td style="border-bottom: 1px solid rgb(221, 221, 221);">';
			html += '		<table id="cmj' + poi.id + '" style="width:262px" cellspacing="0" cellpadding="0" border="0" onmouseover="mapionGlobals.resultList.open(\'' + poi.id + '\');" onmouseout="mapionGlobals.resultList.close(\'' + poi.id + '\');">';
			html += '			<tr>';
			html += '				<td>';
			html += '					<span id="span1">';
			if (3000 <= poi.coordinates_level) {
				html += '						<img align="absmiddle" style="margin-right: 3px;" width="17" height="13" src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/' + (i + 1) + '.gif"/>';
			}
			html += '					</span>';
			html += '					<a href="#cmj' + poi.id + '"/>';
			html += '					<a href="' + poiLink + '" target="_blank">';
			html += '						<span style="font-weight: bold;">' + poi.name + '</span>';
			html += '					</a>';
			html += '<br/>';
			html += denryakuImg + telAll + webcalling;
			html += '				</td>';
			html += '			</tr>';
			html += '			<tr>';
			html += '				<td>';
			html += '					<span id="cmjCatchphrase' + poi.id + '" style="display: none; color: rgb(255, 114, 0);"/>';
			html += '				</td>';
			html += '			</tr>';
			html += '			<tr>';
			html += '				<td>';
			html += '					<table style="width:262px" cellspacing="0" cellpadding="0" border="0">';
			html += '						<tr>';
			if (poi.thumbnail) {
				html += '							<td align="left">';
				html += '								<a href="' + poiLink + '" target="_blank">';
				html += '									<img id="cmjThumb' + poi.id + '" width="50" border="0" align="left" src="http://nttbj.itp.ne.jp' + poi.ad_url_pc + poi.thumbnail + '" style="margin-right: 3px;" onerror="this.style.display=\'none\'"/>';
				html += '								</a>';
				html += '							</td>';
			} else {
				html += '<td><br/></td>';
			}
			html += '							<td align="left">';
			if (catchphrase) {
				html += '							<div id="cmjDetails' + poi.id + '" style="display:block;color: rgb(255, 114, 0); margin-bottom: 4px; width: 100%;">' + catchphrase + '</div>';
			} else {
				html += '							<div id="cmjDetails' + poi.id + '" style="display:none;color: rgb(255, 114, 0); margin-bottom: 4px; width: 100%;"></div>';
			}
			html += '								<div>';
			if (poi.coupon_flag == "1" || poi.coupon_flag == "3") {
				html += '								<a href="http://nttbj.itp.ne.jp' + poi.ad_url_pc + 'coupon.html" target="_blank">';
				html += '									<img width="53" height="14" border="0" src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/img_coupon01.gif" alt="マル得クーポン" style="margin-right: 3px;"/>';
				html += '								</a>';
			}
			
			html += '<br/>';
			
			var moviecm = "";
			if (poi.CooperateList) {
				for (var j = 0; j < poi.CooperateList.Cooperate.length; j++) {
					var cooperate = poi.CooperateList.Cooperate[j];
					if (cooperate.code == "09") { // 09 => 動画リンク
						moviecm += '<span style="margin-left:2px;margin-right:2px">';
						moviecm += '<a target="_blank" href="' + cooperate.url + '">';
						moviecm += '<img src="' + mapionGlobals.constant.MOVIECM_IMG() + '"/>';
						moviecm += '</a>';
						moviecm += '</span>';
					}
				}
			}
			
			html += moviecm;
			
			if (poi.CooperateList) {
				for (var j = 0; j < poi.CooperateList.Cooperate.length; j++) {
					var cooperate = poi.CooperateList.Cooperate[j];
					if (cooperate.code == "01" || cooperate.code == "02") { // 01 => 楽天市場, 02 => 楽天トラベル		
						html += '<span style="margin-left:5px;"><a target="_blank" href="' + cooperate.url + '"><img src="' + mapionGlobals.constant.HYPER_SERVER + cooperate.icon + '"/></a></span>';
					}
				}
			}
			
			var hpType;
			if (poi.flag02 == "1") {
				hpType = "tsume";
			} else {
				if (poi.ad_flag == "1" && (!poi.url_link || poi.url_link == "0")) {
					hpType = "tsume";
				} else {
					if (poi.url) {
						hpType = "visible";
					} else {
						hpType = "gray";
					}
				}
			}
			switch (hpType) {
			case 'visible':
				html += '<a target="_blank" href="' + poi.url + '">HP</a>&nbsp;';
				break;
			case 'gray':
				html += '<font style="color:gray;">HP</font>&nbsp;';
				break;
			default:
			}
			
			
			html += '&nbsp;';
			
			if (poi.flag01 == "1") {
				html += '<a href="javascript:topicButtonCallBack(\'' + poi.id + '\', ' + poi.latitude + ', ' + poi.longitude + ', \'' + poi.category_code + '\', \'' + poi.pref_code + poi.city_code + '\');">トピック</a>';
				html += '&nbsp;';
			}

			if (poi.kuchi_status == "1" && poi.kuchi_icon == "1") {
				html += '<a target="_blank" href="http://kuchikomi.itp.ne.jp/user?ACTION_ID=STORETOP&grid=' + poi.kuchi_id + '">くちコミ</a>';
			}
			
			
			html += '								</div>';
			html += '							</td>';
			html += '						</tr>';
			html += '						<tr>';
			html += '							<td colspan="2">';
			html += '								<span id="cmjGenre' + poi.id + '" style="display: none;"/>';
			html += '							</td>';
			html += '						</tr>';
			html += '					</table>';
			html += '				</td>';
			html += '			</tr>';
			html += '		</table>';
			html += '	</td>';
			html += '</tr>';
			
		}
		
		html += '</table>';
		if (mapionFuncs.net.browser.IE) {
			html += '<br/><br/><br/><br/>';
		}

		if (poiList.length == 0) {
			html += '表示している地図上にはありません';
		}
		
		if (response.Parameter.bt1) {
			eval(response.Parameter.bt1 + "()");
		} else {
			document.getElementById("cmjResultList").innerHTML = html;
		}
		// end ---
		
		// 地図にplot ---
		var poiCrowdList = response.CrowdList.Item instanceof Array ? response.CrowdList.Item : [response.CrowdList.Item];
		var marker = null;
		for (var i = 0; i < poiCrowdList.length; i++) {
	
			var poiCrowd = poiCrowdList[i];
		
			var id = poiCrowd.ids;
			var ids = id.split(",");

			// disp_levelが3000未満のものは削除 ---
			var newIds = [];
			for (var j = 0; j < ids.length; j++) {
				var cId = ids[j];
				if (3000 <= this.poiInfo[cId].coordinates_level) {
					newIds.push(cId);
				}
			}
			ids = newIds;
			// end ---
			
			if (ids.length == 0) {
				continue;
			}
			
			// 左マーカー ---
			var leftIcon = new MIcon();
			leftIcon.image = mapionGlobals.constant.BLOCK_SERVER + "/itp2/img/num_l.gif";
			leftIcon.width = 6;
			leftIcon.height = 19;
			leftIcon.iconAnchor = new MPoint(0, 19);
			marker = new MMarker(new MPoint(poiCrowd.longitude, poiCrowd.latitude), leftIcon);
			map.addOverlay(marker);
			// end ---
	
			for (var j = 0; j < ids.length; j++) {
				var cId = ids[j];
			
				// 中間マーカー
				if (0 < j && j < ids.length) { // 最初と最後以外は中間アイコン
				
					var middleIcon = new MIcon();
					middleIcon.image = mapionGlobals.constant.BLOCK_SERVER + "/itp2/img/num_m.gif";
					middleIcon.width = 6;
					middleIcon.height = 19;
					var middleIconX = -(6 + 17 * j + 6 * (j - 1));
					middleIcon.iconAnchor = new MPoint(middleIconX, 19);
					marker = new MMarker(new MPoint(poiCrowd.longitude, poiCrowd.latitude), middleIcon);         
					map.addOverlay(marker);
				}
			
				// poiマーカー ---
				var poiIcon = new MIcon();
				poiIcon.image = mapionGlobals.constant.BLOCK_SERVER + "/itp2/img/list_" + this.poiInfo[cId].number + ".gif";
				poiIcon.width = 17;
				poiIcon.height = 19;
				var poiIconX = -(6 + 17 * j + 6 * j);
				poiIcon.iconAnchor = new MPoint(poiIconX, 19);
				marker = new MMarker(new MPoint(poiCrowd.longitude, poiCrowd.latitude), poiIcon);         
				map.addOverlay(marker);
				marker.poiId = cId;
				marker.lon = poiCrowd.longitude;
				marker.lat = poiCrowd.latitude;
				//mapionGlobals.resultList.poiInfo[cId].makerId = marker.id;
				this.poiInfo[cId].marker = marker;
				
				// イベント登録
				MEvent.addListener(marker, "click", function(arg1, arg2, arg3) {
				
					mapionGlobals.resultList.click(arg1.poiId);
				});
				
				MEvent.addListener(marker, "mouseover", function(arg1, arg2, arg3) {
					arg1.div.style.cursor = "pointer";
					mapionGlobals.resultList.open(arg1.poiId, true);
				});
				
				MEvent.addListener(marker, "mouseout", function(arg1, arg2, arg3) {
		
					mapionGlobals.resultList.close(arg1.poiId);
				});
			}
			
			// 右マーカー ---
			var leftIcon = new MIcon();
			leftIcon.image = mapionGlobals.constant.BLOCK_SERVER + "/itp2/img/num_r.gif";
			leftIcon.width = 6;
			leftIcon.height = 19;
			var leftIconX = -(6 + 17 * ids.length + 6 * (ids.length - 1));
			leftIcon.iconAnchor = new MPoint(leftIconX, 19);
			marker = new MMarker(new MPoint(poiCrowd.longitude, poiCrowd.latitude), leftIcon);         
			map.addOverlay(marker);
			// end ---
			
		}
		// ---
		
	
		// switcher ---
		//var switcher = mapionGlobals.switcher = new mapionFuncs.html.TabSwitcher();
		//for (var i = 0; i < switchObjIds.length; i++) {
		//	var switchObjId = switchObjIds[i];
		//	switcher.push(document.getElementById(switchObjId));
		//}
		// end ---
		
		// 検索結果表示
		mapionGlobals.accordion.open("cmjResultList");
		
		// 検索中画像消す
		this.hideSearchImage();

	},
	
	/********************************
	 * 検索結果（検索中画像の表示）	*
	 ********************************/
	dispSearchImage: function() {
	
		var map = mapionGlobals.map;
	
		if (document.getElementById("cmjSearchImg")) {
			return;
		}
	
		var imgW = parseInt(115 / 2);
		var imgH = parseInt(50 / 2);
	
		var w = parseInt(parseInt(document.getElementById("cmjMmap").style.width) / 2 - imgW);
		var h = parseInt(parseInt(document.getElementById("cmjMmap").style.height) / 2 - imgH);
		
		var elm = document.createElement("div");
		if (mapionFuncs.net.browser.IE) {
			var attrId = document.createAttribute("id");
			attrId.value = "cmjSearchDiv";
			elm.setAttributeNode(attrId);

			var attrLeft = document.createAttribute("left");
			attrLeft.value = w;
			elm.setAttributeNode(attrLeft);
			
			var attrTop = document.createAttribute("top");
			attrTop.value = h;
			elm.setAttributeNode(attrTop);
			
			var attrStyle = document.createAttribute("style");
			//attrStyle.value = "position:absolute;z-index:100000;top:" + h + "px; left:" + w + "px;";
			//attrStyle.value = "position:absolute";
			elm.setAttributeNode(attrStyle);
			4
			var attrAlign = document.createAttribute("align");
			attrAlign.value = "center";
			elm.setAttributeNode(attrAlign);
			
			var attrValign = document.createAttribute("valign");
			attrValign.value = "center";
			elm.setAttributeNode(attrValign);
			
			
			
		} else {
			
			elm.setAttribute("id", "cmjSearchDiv");
			elm.setAttribute("left", w);
			elm.setAttribute("top", h);
			elm.setAttribute("style", "position:absolute;z-index:100000;top:" + h + "px; left:" + w + "px;");
			elm.setAttribute("align", "center");
			elm.setAttribute("valign", "center");
		}
		elm.innerHTML = '<img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/searching.gif" id="cmjSearchImg" width="115" height="50">';
	
		document.getElementById("cmjMmap").appendChild(elm);
		
		if (mapionFuncs.net.browser.IE) {
			document.getElementById("cmjSearchDiv").style.position = "absolute";
			document.getElementById("cmjSearchDiv").style.zIndex = "100000";
			document.getElementById("cmjSearchDiv").style.top = h + "px";
			document.getElementById("cmjSearchDiv").style.left = w + "px";
		}
		
	},
	
	/**********************************
	 * 検索結果（検索中画像の非表示） *
	 **********************************/
	hideSearchImage: function() {
	
		var map = mapionGlobals.map;
	
		if (document.getElementById("cmjSearchDiv")) {
			try {
				document.getElementById("cmjMmap").removeChild(document.getElementById("cmjSearchDiv"));
			} catch (e) {
				return;
			}
		} else {
			return;
		}
	}
	
};

/**************
 * スライダー *
 **************/
mapionGlobals.slider = {

	// スライダー用ParamHash
	ph: null,
	
	// スライダーのジャンル一覧用ParamHash（階層毎に用意）
	genrePh1: null,
	genrePh2: null,
	genrePh3: null,
	genrePh4: null,
	genrePh5: null,
	
	// スライダーでカレントのdiv番号
	currentDivNo: 1,
	
	// メニューに対するindex
	IndexOnMenu: 0,

	/**********************
	 * スライダー（init） *
	 **********************/
	init: function() {

		// メニューに対するindexを求める
		for (var i = 0; i < mapionGlobals.accordion.menues.length; i++) {
			var menu = mapionGlobals.accordion.menues[i];
			if (menu.id == "cmjSlider") {
				this.IndexOnMenu = i;
			}
		}

		var ph1 = this.genrePh1 = new mapionGlobals.api.GenreDrillDown();
		ph1.replace("grp", mapionGlobals.constant.GRP);
		ph1.replace("kd", "1");
		ph1.replace("pm", "10");
		ph1.replace("start", "1");
		ph1.replace("vo", "mbml");
		ph1.replace("json", "1");
		ph1.replace("callback", "mapionGlobals.slider._request");
		
		var ph2 = this.genrePh2 = new mapionGlobals.api.GenreDrillDown2();
		ph2.replace("grp", mapionGlobals.constant.GRP);
		ph2.replace("kd", "1");
		ph2.replace("pm", "10");
		ph2.replace("start", "1");
		ph2.replace("vo", "mbml");
		ph2.replace("json", "1");
		ph2.replace("callback", "mapionGlobals.slider._request2");
		
		var ph3 = this.genrePh3 = new mapionGlobals.api.GenreDrillDown2();
		ph3.replace("grp", mapionGlobals.constant.GRP);
		ph3.replace("kd", "1");
		ph3.replace("pm", "10");
		ph3.replace("start", "1");
		ph3.replace("vo", "mbml");
		ph3.replace("json", "1");
		ph3.replace("callback", "mapionGlobals.slider._request2");
		
		var ph4 = this.genrePh4 = new mapionGlobals.api.GenreDrillDown2();
		ph4.replace("grp", mapionGlobals.constant.GRP);
		ph4.replace("kd", "1");
		ph4.replace("pm", "10");
		ph4.replace("start", "1");
		ph4.replace("vo", "mbml");
		ph4.replace("json", "1");
		ph4.replace("callback", "mapionGlobals.slider._request2");
		
		var ph5 = this.genrePh5 = new mapionGlobals.api.GenreDrillDown2();
		ph5.replace("grp", mapionGlobals.constant.GRP);
		ph5.replace("kd", "1");
		ph5.replace("pm", "10");
		ph5.replace("start", "1");
		ph5.replace("vo", "mbml");
		ph5.replace("json", "1");
		ph5.replace("callback", "mapionGlobals.slider._request2");

		var url = ph1.getRequestURI();

		new mapionFuncs.net.Jsonp(url).make().request().remove();
	},
	
	/******************************
	 * スライダー（コールバック） *
	 ******************************/
	_request: function(response) {
	
		var genreList = response.mbml.GenreList.Genre instanceof Array ? response.mbml.GenreList.Genre : [response.mbml.GenreList.Genre];
	
		var divNo = (6 - (response.mbml.Parameter.lvl ? response.mbml.Parameter.lvl : 5));
		var divName = "cmjDiv" + divNo;
	
		var html = "";
		
		if (response.mbml.Parameter.lvl && response.mbml.Parameter.lvl < 5) {
			html += '<div align="right">';
			html += '<img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/top_b.gif' + '" width="67" height="19" style="cursor:pointer;" onclick="mapionGlobals.slider.upToTop(\'' + response.mbml.Parameter.lvl + '\')"/>';
			html += '<img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/back_b.gif' + '" width="78" height="19" style="cursor:pointer;" onclick="mapionGlobals.slider.up(\'' + response.mbml.Parameter.lvl + '\')"/>';
			html += '</div>';
		}
		
		if (1 < response.mbml.Parameter.start) {
			html += '<a href="javascript:mapionGlobals.slider.move(-1, ' + divNo + ');">↑</a><br/>';
		}
		
		for (var i = 0; i < genreList.length; i++) {
			var genre = genreList[i];
			if (genre.genre_level == "1") {
				html += '<a href="javascript:mapionGlobals.slider.request(\'' + genre.id + '\', \'' + genre.name + '\');">' + genre.name + '</a>';
			} else {
				html += '<a href="javascript:mapionGlobals.slider.down(\'' + genre.genre_level + '\', \'' + genre.id + '\')">' + genre.name + '</a>';
				html += '<img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/yajirusi_rs.gif" width="10" height="10"/>';
			}
			html += '<br/>';
		}
		
		if (parseInt(response.mbml.Property["end-index"]) < parseInt(response.mbml.Property.hit)) {
			html += '<a href="javascript:mapionGlobals.slider.move(1, ' + divNo + ');">↓</a>';
		}
		
		var elm = document.getElementById(divName);
		elm.innerHTML = html;
		
		if (elm.scrollHeight != 0) {
			bytefx.size(document.getElementById("cmjSlider"),{width: 280, height: elm.scrollHeight}, mapionGlobals.accordion.getSpeed(), function() {});
		}
	
	},
	
	/*******************************************
	 * スライダー（prev/nextリンククリック時） *
	 *******************************************/
	move: function(count, divNo) {
	
		var ph = this["genrePh" + divNo];
		var start = ph.get("start");
		ph.replace("start", parseInt(start) + count);
		
		var url = ph.getRequestURI();

		new mapionFuncs.net.Jsonp(url).make().request().remove();
	},
	
	/*******************************************
	 * スライダー（コールバック）（2回目以降） *
	 *******************************************/
	_request2: function(response) {
	
		this._request(response);
		
		// 高さ調整
		var level = response.mbml.Parameter.lvl;
		var divNo = 6 - level;
		var height = document.getElementById("cmjDiv" + divNo).scrollHeight;
		bytefx.size(document.getElementById("cmjSlider"), {width: 280, height: height}, mapionGlobals.accordion.getSpeed(), function() {});
		
		// 高さ保存
		accordionByBytefx.heights.cmjSlider = height;
	},
	
	/**********************************
	 * スライダー（最下層クリック時） *
	 **********************************/
	request: function(id, name) {
	
		var map = mapionGlobals.map;
		
		if (map.getZoomLevel() < mapionGlobals.constant.RESEARCH_LEVEL_BORDER) {
			alert("縮尺が21000以下でないと検索できません。");
			return;
		}
		
		// 全て消す
		map.clearOverlays();
		map.closeInfoWindow();

		mapionGlobals.recommend.openPoiId = null;
	
		mapionGlobals.searchType = "slider";
		
		mapionGlobals.currentGenre = id + "/" + name + "/slider";
		document.getElementById("cmjCurrentGenre").innerHTML = '「<b><font style="color:rgb(255, 114, 0);">' + name + '</font></b>」で検索中';;
	
		var ph = this.ph = new mapionGlobals.api.Local();
		
		ph.replace("lmt", mapionGlobals.constant.PAGE_MAX);
		ph.replace("start", "1");
		ph.replace("cate", id);
		ph.replace("cpix", mapionGlobals.constant.CPIX);
		ph.replace("fmt", "json");
		ph.replace("cb", "mapionGlobals.resultList.make");
		
		this.movedRequest();
	},
	
	/******************************
	 * スライダー（movedRequest） *
	 ******************************/
	movedRequest: function() {
	
		var map = mapionGlobals.map;
		
		// 緯度経度
		var centerLatLng = map.getCenterLatLng();
		
		// 縮尺
		var scl = map.getZoomLevel();
		
		// 四隅
		var boundsLatLng = map.getBoundsLatLng();
		
		var ph = this.ph;
		
		ph.replace("nl", new String(centerLatLng.y));
		ph.replace("el", new String(centerLatLng.x));
		ph.replace("minnl", new String(boundsLatLng.minY));
		ph.replace("minel", new String(boundsLatLng.minX));
		ph.replace("maxnl", new String(boundsLatLng.maxY));
		ph.replace("maxel", new String(boundsLatLng.maxX));
		ph.replace("scl", scl);
		
		this.doRequest();
	},
	
	/***************************
	 * スライダー（doRequest） *
	 ***************************/
	doRequest: function() {
	
		// 検索中画像
		mapionGlobals.resultList.dispSearchImage();
	
		var ph = this.ph;
	
		mapionGlobals.lastAPI = ph;
	
		var url = ph.getRequestURI();

		new mapionFuncs.net.Jsonp(url).make().request().remove();
	},

	/**************************************
	 * スライダー（結果リンククリック時） *
	 **************************************/
	down: function(level, parent) {
	
		var divNo = 6 - level;

		var ph = this["genrePh" + (divNo + 1)];
		ph.replace("start", "1");
		ph.replace("lvl", level - 1);
		ph.replace("parent", parent);

		var url = mapionGlobals.constant.GENRE_DRILL_DOWN_API() + "?" + ph.toString();

		new mapionFuncs.net.Jsonp(url).make().request().remove();
	
		
		if (mapionFuncs.net.browser.firefox) {
			document.getElementById("cmjDiv" + divNo).style.display = "none";
		}

		var y = (this.IndexOnMenu + 1) * (mapionGlobals.constant.MENU_HEADER_HEIGHT + 1) + 5;

		var x = -280 * divNo;
		bytefx.moveFromParent(document.getElementById("cmjWrapper"), {x: x, y: y}, mapionGlobals.accordion.getSpeed(), function() {
		});
		
		// カレントのdivNoグローバルに保存
		this.currentDivNo = divNo + 1;
	},
	
	/**********************************************
	 * スライダー（一つ前に戻るリンククリック時） *
	 **********************************************/
	up: function(level) {

		var divNo = 6 - level - 1;
		
		if (mapionFuncs.net.browser.firefox) {
			document.getElementById("cmjDiv" + divNo).style.display = "block";
		}
		
		var y = (this.IndexOnMenu + 1) * (mapionGlobals.constant.MENU_HEADER_HEIGHT + 1) + 5;
		
		var x = -280 * (divNo - 1);
		bytefx.moveFromParent(document.getElementById("cmjWrapper"), {x: x, y: y}, mapionGlobals.accordion.getSpeed(), function() {
		});
		
		// 高さ調整
		var height = document.getElementById("cmjDiv" + divNo).scrollHeight;
		bytefx.size(document.getElementById("cmjSlider"), {width: 280, height: height}, mapionGlobals.accordion.getSpeed(), function() {});
		
		// 高さ保存
		//accordionByBytefx.heights.cmjSlider = height;
		
		// カレントのdivNoグローバルに保存
		this.currentDivNo = divNo;
		
	},
	
	/**********************************************
	 * スライダー（トップに戻るリンククリック時） *
	 **********************************************/
	upToTop: function(level) {
	
		var divNo = 6 - level - 1;
		
		if (mapionFuncs.net.browser.firefox) {
			for (var i = 1; i <= divNo; i++) {
				document.getElementById("cmjDiv" + i).style.display = "block";
			}
		}
		
		var y = (this.IndexOnMenu + 1) * (mapionGlobals.constant.MENU_HEADER_HEIGHT + 1) + 5;
	
		bytefx.moveFromParent(document.getElementById("cmjWrapper"), {x: 0, y: y}, mapionGlobals.accordion.getSpeed(), function() {
		});
		
		// 高さ調整
		var height = document.getElementById("cmjDiv1").scrollHeight;
		bytefx.size(document.getElementById("cmjSlider"), {width: 280, height: height}, mapionGlobals.accordion.getSpeed(), function() {});
		
		// 高さ保存
		accordionByBytefx.heights.cmjSlider = height;
		
		// カレントのdivNoグローバルに保存
		this.currentDivNo = 1;
		
	}

};

/******************
 * デフォルト検索 *
 ******************/
mapionGlobals.recommend = {

	// poiとマーカーIDの対応表
	poiToMarker: {},
	
	// マーカーが持ってるpoiのマップ
	markerToId: {},
	
	// poiの詳細情報マップ
	poiDetail: {},
	
	buffPoi: null,
	
	// インフォウィンドウで開いているpoi
	openedPoiList: [],
	
	// コールバック完了フラグ
	isDone: false,
	
	// デフォルト用ParamHash
	ph: null,
	
	// PInfo用ph
	pInfoPh: null,
	
	// 開いてるインフォウィンドウのpoiマップ
	currentPoi: {},
	
	// melterさせたいidリスト
	nameMelters: [],
	//telMelters: [],
	
	// 口コミを格納するマップ
	kuchikomiMap: {},
	
	// 最初に開かせるpoiid
	openPoiId: null,
	
	count: 0,
	
	currentPoiId: null,

	/**************************
	 * デフォルト検索（init） *
	 **************************/
	init: function(number, categories) {

		this.count = 0;

		var ph = this.ph = new mapionGlobals.api.ItpPoiWithin();
		ph.replace("grp", mapionGlobals.constant.GRP);
		ph.replace("start", "1");
		ph.replace("kd", "0");
		ph.replace("lvl", "3000");
		ph.replace("crd", "1");
		ph.replace("vo", "mbml");
		ph.replace("json", "1");
		ph.replace("callback", "mapionGlobals.recommend.callback");
		this.request(number, categories);
	},

	/************************************
	 * デフォルト検索（リクエスト実行） *
	 ************************************/
	request: function(number, categories, overrideSearchType) {

		mapionGlobals.searchType = "recommend";
		if (overrideSearchType) {
			mapionGlobals.searchType = overrideSearchType;
		}
	
		var map = mapionGlobals.map;
		
		// 検索結果htmlクリア
		document.getElementById("cmjResultList").innerHTML = "";
		
		// 現在検索中htmlクリア
		document.getElementById("cmjCurrentGenre").innerHTML = "";
		
		
		if (categories == "no") {
			// 全て消す
			map.clearOverlays();
			map.closeInfoWindow();
			return;
		}
		
		var ph = this.ph;
		if (number) {
			ph.replace("pm", number);
		}
		if (categories) {
			categories = categories.replace(/\|\|/g, ",");
			ph.replace("kc", categories);
		}

		this.movedRequest();
	},
	
	/**********************************
	 * デフォルト検索（movedRequest） *
	 **********************************/
	movedRequest: function() {
	
		var map = mapionGlobals.map;
		
		// 再度のチェックですが、moveendの時必要なので
		if ((mapionGlobals.getCookie())["cmj.recommend.categories"] == "no") {
			// 全て消す
			map.clearOverlays();
			map.closeInfoWindow();
			return;
		}

		// 緯度経度
		var centerLatLng = map.getCenterLatLng();
		var nl = centerLatLng.y;
		var el = centerLatLng.x;
		
		// 縮尺
		var scl = map.getZoomLevel();

		// 四隅
		var boundsLatLng = map.getBoundsLatLng();
		var minnl = boundsLatLng.minY;
		var maxnl = boundsLatLng.maxY;
		var minel = boundsLatLng.minX;
		var maxel = boundsLatLng.maxX;
		
		var ph = this.ph;
		
		ph.replace("nl", new String(nl));
		ph.replace("el", new String(el));
		ph.replace("minnl", new String(minnl));
		ph.replace("minel", new String(minel));
		ph.replace("maxnl", new String(maxnl));
		ph.replace("maxel", new String(maxel));
		ph.replace("scl", scl);
		
		this.doRequest();
	},
	
	/**********************************
	 * デフォルト検索（doRequest） *
	 **********************************/
	doRequest: function() {
	
		var ph = this.ph;
		
		mapionGlobals.lastAPI = ph;
		
		var url = ph.getRequestURI();
		//javascript:void(prompt("", url));
		new mapionFuncs.net.Jsonp(url).make().request().remove();
	},

	/**********************************
	 * デフォルト検索（コールバック） *
	 **********************************/
	callback: function(response) {

		// 初期化 ---
		this.poiToMarker = {};
		this.markerToId = {};
		var newPoiDetail = {};
		for (var p in this.poiDetail) { // インフォウィンドウで開いているpoiは残しておく
			if (!this.poiDetail.hasOwnProperty(p)) {
				continue;
			}
			if (this.openedPoiList.inArray(p)) {
				newPoiDetail[p] = this.poiDetail[p];
			}
		}
		this.poiDetail = newPoiDetail;
		// end ---
	
		var map = mapionGlobals.map;
		
		// 全て消す
		map.clearOverlays();

		if (!response.mbml.PoiList.Poi) {
			this.isDone = true;
			return;
		}
	
		var poiList = response.mbml.PoiList.Poi instanceof Array ? response.mbml.PoiList.Poi : [response.mbml.PoiList.Poi];

		// poiの詳細情報マップを作る ---
		for (var i = 0; i < poiList.length; i++) {
			var cPoi = poiList[i];
			if (!this.poiDetail[cPoi.id]) { // 既にあれば入れない
				this.poiDetail[cPoi.id] = cPoi;
			}
		}
		// end ---

		var poiCrowdList = response.mbml.PoiCrowdList.PoiCrowd instanceof Array ? response.mbml.PoiCrowdList.PoiCrowd : [response.mbml.PoiCrowdList.PoiCrowd];
		var marker = null;
		for (var i = 0; i < poiCrowdList.length; i++) {
		
			var poiCrowd = poiCrowdList[i];
		
			var id = poiCrowd.id;
			var ids = id.split(",");
			
			// マーカー ---
			var iconInfo = this.getIconInfo(poiCrowd.favorite_genre);
			var customMarkerObj = new MIcon();
			customMarkerObj.image = iconInfo.image;
			customMarkerObj.width = iconInfo.width;
			customMarkerObj.height = iconInfo.height;
			customMarkerObj.iconAnchor = new MPoint(0, iconInfo.height);
			marker = new MMarker(new MPoint(poiCrowd.longitude, poiCrowd.latitude), customMarkerObj);         
			map.addOverlay(marker);
			// end ---
			
			// poiとマーカーIDの対応表を作る---
			for (var j = 0; j < ids.length; j++) {

				var cId = ids[j];	
				this.poiToMarker[cId] = marker.id;
			}
			// end ---
			
			// マーカーが持ってるpoiのマップを作る
			this.markerToId[marker.id] = id;
			
			// イベント登録
			MEvent.addListener(marker, "click", function(marker){		
				mapionGlobals.recommend.markerInit(marker);
			});
			MEvent.addListener(marker, "mouseover", function(arg1, arg2, arg3) {
				arg1.div.style.cursor = "pointer";
			});
		}
		
		this.isDone = true;
	},
	
	/************************************************
	 * デフォルト検索（マーカーに必要な情報を作る） *
	 ************************************************/
	markerInit: function(obj, _poiId) {

		this.kuchikomiMap = {};
		
		this.currentPoiId = _poiId;

		var markerId = obj instanceof MMarker ? obj.id : obj;

		var crowdPoi;
		if (_poiId) {
			this.openPoiId = _poiId;
			var map = mapionGlobals.map;
			var marker = map.markerArray[this.poiToMarker[this.openPoiId]];
			if (!marker) { // 端っこのアイコンの吹き出し開く => zoomIn（地図から出る） => zoomOut => 最初なくて再検索で引っかかるのでそれを待つ
				if (5 < this.count) { // 5回繰り返してもmarker取れない場合（対象のアイコンが乗らない状態）はインフォウィンドウ消して終わり
					this.count = 0;
					//mapionGlobals.map.hiddenInfoWindow();
					mapionGlobals.map.closeInfoWindow();
					return;
				}
				this.count++;
				window.setTimeout(function() {mapionGlobals.recommend.markerInit(obj, _poiId);}, 500);
				return;
			}
			crowdPoi = this.markerToId[marker.id].split(",");
		} else {
			if (this.markerToId[markerId]) {
				crowdPoi = this.markerToId[markerId].split(",");
				this.openPoiId = crowdPoi[0];
			} else {
				return;
			}
		}

		/*
		// 口コミ有りのpoiのリストを作る
		var kuchikomiPoi = [];
		for (var i = 0; i < crowdPoi.length; i++) {
			var cCrowdPoi = crowdPoi[i];
			if (this.poiDetail[cCrowdPoi].kuchikomi_id) {
				kuchikomiPoi.push(cCrowdPoi);
			}
		}

		if (kuchikomiPoi.length == 0) { // 混雑含めて口コミがない
			mapionGlobals.recommend.markerOpen(this.openPoiId);
		} else { // 口コミ有り

			// プロパティを作っておく
			for (var i = 0; i < kuchikomiPoi.length; i++) {
				this.kuchikomiMap[kuchikomiPoi[i]] = null;
			}

			// 口コミ取得⇒markerOpen実行
			for (var i = 0; i < kuchikomiPoi.length; i++) {
				this.getKuchikomi(kuchikomiPoi[i]);
			}
		}
		*/

		// クリックしたアイコンのpoiのidを取得する
		var currentPoi = null;
		for (var i = 0; i < crowdPoi.length; i++) {
			var cPoi = crowdPoi[i];
			if (this.poiDetail[cPoi]) {
				currentPoi = cPoi;
				break;
			}
		}
		//console.log(currentPoi);
		this.buffPoi == currentPoi ? this.markerOpen(buffPoi) : this.getMarkerInfo(this.markerToId[markerId]);
		this.buffPoi == currentPoi;
	},
	
	/**********************************************************
	 * デフォルト検索（クリックしたアイコンの情報を取得する） *
	 **********************************************************/
	getMarkerInfo: function(ids) {
		//console.log("getmarkerinfo");
		var ph = this.pInfoPh = new mapionGlobals.api.PInfo();
		ph.replace("fmt", "json");
		ph.replace("cb", "mapionGlobals.recommend._getMarkerInfo");
		ph.replace("id", ids);
		var url = ph.getRequestURI();
		//javascript:void(prompt("", url));
		new mapionFuncs.net.Jsonp(url).make().request().remove();
	
	},
	
	/**************************************************************************
	 * デフォルト検索（クリックしたアイコンの情報を取得する（コールバック）） *
	 **************************************************************************/
	_getMarkerInfo: function(response) {

		for (var i = 0; i < response.ResultList.Item.length; i++) {
			var item = response.ResultList.Item[i];
			this.poiDetail[item.id] = item;
		}

		this.markerOpen(this.currentPoiId ? this.currentPoiId : response.Parameter.id.split(",")[0]);

	},
	
	/************************************************
	 * デフォルト検索（インフォウィンドウオープン） *
	 ************************************************/
	markerOpen: function(poiId) {

		var map = mapionGlobals.map;
		var marker = map.markerArray[this.poiToMarker[poiId]];

		if (!marker) {
			map.closeInfoWindow();
			return;
		}
		
		var crowdPoi = this.markerToId[marker.id].split(",");

		// this.poiDetailから対象のpoi情報だけ抜き出す
		this.currentPoi = {}; // 初期化
		for (var i = 0; i < crowdPoi.length; i++) {
			var cCrowdPoi = crowdPoi[i];
			this.currentPoi[cCrowdPoi] = this.poiDetail[cCrowdPoi];
		}
		

		// 引数のpoiIdのindexを求める
		var index = 0;
		for (var i = 0; i < crowdPoi.length; i++) {
			var cCrowdPoi = crowdPoi[i];
			if (cCrowdPoi == poiId) {
				index = i;
				break;
			}
		}

		this.nameMelters = [];
		//this.telMelters = [];

		var html = '';
		html += '<div id="cmjInfoSoto" style="position:relative;width:240px;overflow:hidden;background:none;z-index:8000;">';
		html += '<div id="cmjInfoWrapper" style="z-index:8000;">';

		var firstCurrentPoi = null;
		var offset = 0;

		for (var p in this.currentPoi) {
			if (!this.currentPoi.hasOwnProperty(p)) {
				continue;
			}
			
			var cCurrentPoi = this.currentPoi[p];
			
			var poiDetail = this.poiDetail[cCurrentPoi.id];
			
			var crowdPoi = this.markerToId[marker.id].split(",");
			// グローバルに格納しておく
			this.openedPoiList = crowdPoi;

			if (offset == index) {
				firstCurrentPoi = cCurrentPoi;
			}

			var leftPx = (offset - index) * 240;
	
			html += '<div id="cmjOnePoi' + p + '" style="z-index:8000;width:240px;position:absolute;left:' + leftPx + 'px;">';
			
			html += mapionGlobals.generateHtml(poiDetail);

			html += '<table cellspacing="0" cellpadding="0" style="width:238px;">';
			html += '<tr>';
			if (0 < offset) {
				html += '<td align="left"><a href="javascript:mapionGlobals.recommend.prev(\'' + p + '\', ' + index + ')"><img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/pre.gif" width="39" height="17"/></a></td>';
			}
			if (1 < crowdPoi.length && offset < crowdPoi.length - 1) {
				html += '<td align="right"><a href="javascript:mapionGlobals.recommend.next(\'' + p + '\', ' + index + ')"><img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/next.gif" width="39" height="17"/></a></td>';
			}
			html += '</tr>';
			html += '</table>';
			html += '</div>';
			
			
			cCurrentPoi.index = offset;
	
			offset++;
		}
		html += '</div>';
		html += '</div>';

		marker.openInfoWindowHtml(html);
		
		mapionGlobals.doMelter();
		
		// 高さ調整
		var onePoiHeight = parseInt(document.getElementById("cmjOnePoi" + firstCurrentPoi.id).scrollHeight) + 5;
		//if (320 < onePoiHeight) {
		//	onePoiHeight = 320;
		//}
		map.infowindow.divArea.style.height = onePoiHeight + "px";
		//console.log(onePoiHeight);

		//document.getElementById("cmjCategoryDiv" + firstCurrentPoi.id).style.overflow = "auto";
		//if (document.getElementById("cmjKuchikomiDiv" + firstCurrentPoi.id)) {
		//	document.getElementById("cmjKuchikomiDiv" + firstCurrentPoi.id).style.overflow = "auto";
		//}

		var cmjInfoSotoHeight = document.getElementById("cmjInfoSoto").scrollHeight;
		//alert(cmjInfoSotoHeight);
		//if (320 < cmjInfoSotoHeight) {
		//	cmjInfoSotoHeight = 320;
		//}
		
		// 長い店舗名の場合、melterで動いた後高さ足りなくなるので
		//var heightPlus = 0;
		//if (mapionFuncs.net.browser.IE) heightPlus += 10;
		//if (mapionFuncs.net.browser.firefox) heightPlus += 13;
		//document.getElementById("cmjInfoSoto").style.height = cmjInfoSotoHeight + heightPlus + "px";
		
		//alert(cmjInfoSotoHeight);
		//document.getElementById("cmjInfoSoto").style.height = cmjInfoSotoHeight + "px";
		//document.getElementById("divareaSingleInfowindow0").style.height = cmjInfoSotoHeight + "px";
		document.getElementById("cmjInfoSoto").style.height = onePoiHeight + "px";
		document.getElementById("divareaSingleInfowindow0").style.height = onePoiHeight + "px";
	},
	
	/*******************************
	 * デフォルト検索（前のPOIへ） *
	 *******************************/
	prev: function(id, _index) {
		
		if (!mapionFuncs.net.browser.IE) {
			mapionGlobals.doMelter();
		}
		
		// overflowをhiddenにする
		//document.getElementById("cmjCategoryDiv" + id).style.overflow = "hidden";
		//if (document.getElementById("cmjKuchikomiDiv" + id)) {
		//	document.getElementById("cmjKuchikomiDiv" + id).style.overflow = "hidden";
		//}
		
		// prev先のpoiidを得る
		var currentPoi = this.currentPoi;
		var index = currentPoi[id].index - 1;
		var prevPoiId;
		for (var p in currentPoi) {
			if (!currentPoi.hasOwnProperty(p)) {
				continue;
			}
			var cCurrentPoi = currentPoi[p];
			if (cCurrentPoi.index == index) {
				prevPoiId = p;
				break;
			}
		}
		this.openPoiId = prevPoiId;
		
		// 高さ調整
		var height = parseInt(document.getElementById("cmjOnePoi" + prevPoiId).scrollHeight) + 5;
		if (320 < height) {
			height = 320;
		}
		var map = mapionGlobals.map;
		map.infowindow.divArea.style.height = height + "px";
		map.infowindow.move = true;
		map.infowindow.drawing();

		var moving = -(this.currentPoi[id].index + 1) * 240 + 240 * 2 + 240 * _index;
		bytefx.moveFromParent(document.getElementById("cmjInfoWrapper"), {x: moving, y: 0}, mapionGlobals.accordion.getSpeed(), function() {
			// overflowをautoにする
			//document.getElementById("cmjCategoryDiv" + prevPoiId).style.overflow = "auto";
			//if (document.getElementById("cmjKuchikomiDiv" + prevPoiId)) {
			//	document.getElementById("cmjKuchikomiDiv" + prevPoiId).style.overflow = "auto";
			//}
			
			//if (mapionFuncs.net.browser.IE) { // ieは混雑poi中一番大きい高さより小さくならないので
				var tmp = map.infowindow.divArea.innerHTML;
				map.infowindow.divArea.removeChild(map.infowindow.divArea.firstChild);
				//map.infowindow.divArea.innerHTML = "";
				map.infowindow.divArea.style.width = null;
				map.infowindow.divArea.style.height = height + "px";
				map.infowindow.move = true;
				map.infowindow.drawing();
				map.infowindow.divArea.innerHTML = tmp;
				document.getElementById("cmjInfoSoto").style.height = height + "px";
				
				mapionGlobals.doMelter();
			//}
		});
	},
	
	/*******************************
	 * デフォルト検索（次のPOIへ） *
	 *******************************/
	next: function(id, _index) {

		if (!mapionFuncs.net.browser.IE) {
			mapionGlobals.doMelter();
		}

		// overflowをhiddenにする
		//document.getElementById("cmjCategoryDiv" + id).style.overflow = "hidden";
		//if (document.getElementById("cmjKuchikomiDiv" + id)) {
		//	document.getElementById("cmjKuchikomiDiv" + id).style.overflow = "hidden";
		//}
		
		// next先のpoiidを得る
		var currentPoi = this.currentPoi;
		var index = currentPoi[id].index + 1;
		var nextPoiId;
		for (var p in currentPoi) {
			if (!currentPoi.hasOwnProperty(p)) {
				continue;
			}
			var cCurrentPoi = currentPoi[p];
			if (cCurrentPoi.index == index) {
				nextPoiId = p;
				break;
			}
		}
		this.openPoiId = nextPoiId;
		
		// 高さ調整
		var height = parseInt(document.getElementById("cmjOnePoi" + nextPoiId).scrollHeight) + 5;
		if (320 < height) {
			height = 320;
		}
		var map = mapionGlobals.map;
		map.infowindow.divArea.style.height = height + "px";
		map.infowindow.move = true;
		map.infowindow.drawing();
	
		var moving = -(this.currentPoi[id].index + 1) * 240 + 240 * _index;
		bytefx.moveFromParent(document.getElementById("cmjInfoWrapper"), {x: moving, y: 0}, mapionGlobals.accordion.getSpeed(), function() {

			// overflowをautoにする
			//document.getElementById("cmjCategoryDiv" + nextPoiId).style.overflow = "auto";
			//if (document.getElementById("cmjKuchikomiDiv" + nextPoiId)) {
			//	document.getElementById("cmjKuchikomiDiv" + nextPoiId).style.overflow = "auto";
			//}
			
			//if (mapionFuncs.net.browser.IE) { // ieは混雑poi中一番大きい高さより小さくならないので

				var tmp = map.infowindow.divArea.innerHTML;
				map.infowindow.divArea.removeChild(map.infowindow.divArea.firstChild);
				//map.infowindow.divArea.innerHTML = "";
				//return;
				map.infowindow.divArea.style.width = null;
				map.infowindow.divArea.style.height = height + "px";
				map.infowindow.move = true;
				map.infowindow.drawing();
				map.infowindow.divArea.innerHTML = tmp;				
				document.getElementById("cmjInfoSoto").style.height = height + "px";
				
				mapionGlobals.doMelter();
			//}

		});
	},
	
	/**********************************************
	 * デフォルト検索（マーカーアイコン情報取得） *
	 **********************************************/
	getIconInfo: function(type) {
	
		var image;
		var width;
		var height;
			switch (type) {
			case "G001":
				image = mapionGlobals.constant.G001_ICON();
				width = mapionGlobals.constant.G001_WIDTH;
				height = mapionGlobals.constant.G001_HEIGHT;
				break;
			case "G002":
				image = mapionGlobals.constant.G002_ICON();
				width = mapionGlobals.constant.G002_WIDTH;
				height = mapionGlobals.constant.G002_HEIGHT;
				break;
			case "G003":
				image = mapionGlobals.constant.G003_ICON();
				width = mapionGlobals.constant.G003_WIDTH;
				height = mapionGlobals.constant.G003_HEIGHT;
				break;
			case "G004":
				image = mapionGlobals.constant.G004_ICON();
				width = mapionGlobals.constant.G004_WIDTH;
				height = mapionGlobals.constant.G004_HEIGHT;
				break;
			case "OTHER":
				image = mapionGlobals.constant.OTHER_ICON();
				width = mapionGlobals.constant.OTHER_WIDTH;
				height = mapionGlobals.constant.OTHER_HEIGHT;
				break;
			case "CROWD":
				image = mapionGlobals.constant.CROWD_ICON();
				width = mapionGlobals.constant.CROWD_WIDTH;
				height = mapionGlobals.constant.CROWD_HEIGHT;
				break;
			default:
			}
			
			return {
				image: image,
				width: width,
				height: height
			};
	}

};

/********************
 * ループス提供関数 *
 ********************/
mapionGlobals.loops = {

	/**************************************
	 * ループス提供関数（吹き出しを出す） *
	 **************************************/
	openInfoWindow: function(poiId) {

		var interval = window.setInterval(function() {
			if (mapionGlobals.recommend.isDone) {

				if (mapionGlobals.recommend.poiToMarker[poiId]) {
					mapionGlobals.recommend.markerInit(mapionGlobals.recommend.poiToMarker[poiId], poiId);
				} else {

					mapionGlobals.onlyOne.init(mapionGlobals.params.shop_id);
				}

				window.clearInterval(interval);
			} else {
			}
			
		}, 10);
	}
	
};

/************
 * そこどこ *
 ************/
mapionGlobals.sokodoko = {

	// そこどこ
	areaName: '',
	
	// そこどこ用ParamHash
	ph: null,

	/********************
	 * そこどこ（init） *
	 ********************/
	init: function() {

		var ph = this.ph = new mapionGlobals.api.Where();
		ph.replace("grp", mapionGlobals.constant.GRP);
		ph.replace("vo", "mbml");
		ph.replace("json", "1");
		ph.replace("callback", "mapionGlobals.sokodoko.callback");
	
		this.request();
	},
	
	/**************************
	 * そこどこ（リクエスト） *
	 **************************/
	request: function() {
	
		var map = mapionGlobals.map;
		
		var centerLatLng = map.getCenterLatLng();
		nl = centerLatLng.y;
		el = centerLatLng.x;
		
		var ph = this.ph;
		ph.replace("nl", nl);
		ph.replace("el", el);
		
		var url = ph.getRequestURI();
		//console.log(url);
		new mapionFuncs.net.Jsonp(url).make().request().remove();
	},

	/****************************
	 * そこどこ（コールバック） *
	 ****************************/
	callback: function(response) {
	
		var poi = response.mbml.PoiList.Poi;
		
		var all = "";
		
		if (poi) {
	
			var ken = poi.adna2 instanceof Object ? "" : poi.adna2;
			
			var adna3 = poi.adna3 instanceof Object ? "" : poi.adna3;
			var adna4 = poi.adna4 instanceof Object ? "" : poi.adna4;
			var adna5 = poi.adna5 instanceof Object ? "" : poi.adna5;
			
			all = ken + adna3 + adna4 + adna5;
		}
	
		document.getElementById("cmjSokodoko").innerHTML = "「<b>" + all + "</b>」周辺";
		
		// 地名をグローバルに保存しておく
		this.areaName = all;
	}


};

/************
 * クッキー *
 ************/
mapionGlobals.cookie = {

	/********************************
	 * クッキー（おすすめ設定件数） *
	 ********************************/
	recommendNumber: function(selectElm) {
		
		var map = mapionGlobals.map;
		
		// インフォウィンドウを閉じる
		map.closeInfoWindow();

		if (map.getZoomLevel() < mapionGlobals.constant.RESEARCH_LEVEL_BORDER) {
			
			// 検索結果htmlクリア
			document.getElementById("cmjResultList").innerHTML = "";
			
			for (var i = 0; i < selectElm.options.length; i++) {
				var option = selectElm.options[i];
				if (option.selected) {
					mapionFuncs.net.setCookie("cmj.recommend.number", option.value, mapionGlobals.constant.EXPIRES);
					return;
				}
			}
			
		} else {
	
			for (var i = 0; i < selectElm.options.length; i++) {
				var option = selectElm.options[i];
				if (option.selected) {
					mapionFuncs.net.setCookie("cmj.recommend.number", option.value, mapionGlobals.constant.EXPIRES);
					mapionGlobals.recommend.request(option.value, mapionFuncs.net.getCookie("cmj.recommend.categories"));
					return;
				}
			}
		}
	},
	
	/************************************
	 * クッキー（おすすめ設定カテゴリ） *
	 ************************************/
	recommendCategories: function() {
		
		var map = mapionGlobals.map;
		
		map.clearOverlays();
		
		// インフォウィンドウを閉じる
		map.closeInfoWindow();
		
		var recommendCategoriesChckebox = document.getElementsByName("recommendCategoriesChckebox");
		var categories = [];
		for (var i = 0; i < recommendCategoriesChckebox.length; i++) {
			var input = recommendCategoriesChckebox[i];
			if (input.checked) {
				categories.push(input.value);
			}
		}
		var categoriesStr = (categories.length == 0) ? "no" : categories.join("||");
		mapionFuncs.net.setCookie("cmj.recommend.categories", categoriesStr, mapionGlobals.constant.EXPIRES);
		
		if (map.getZoomLevel() < mapionGlobals.constant.RESEARCH_LEVEL_BORDER) {
			
			// 検索結果htmlクリア
			document.getElementById("cmjResultList").innerHTML = "";
			
		} else {
		
			mapionGlobals.recommend.request(mapionFuncs.net.getCookie("cmj.recommend.number"), categoriesStr);
		}
	}

};



/******************
 * お気に入り設定 *
 ******************/
mapionGlobals.bookmark = {

	/**************************
	 * お気に入り設定（init） *
	 **************************/
	init: function() {

		var html = '';
	
		// エリア
		html += '<table width="100%" cellpadding="0" cellspacing="0">';
		html += '	<tr>';
		if(mapionFuncs.net.browser.IE){
			html += '		<td width="9" style="padding-top:0px;background-image: url(' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/bggray4.gif);background-repeat: repeat-x;height: 24px;"><img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/info_title_l.gif"/></td>';
		} else {
			html += '		<td width="9" style="padding-top:6px;background-image: url(' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/bggray4.gif);background-repeat: repeat-x;height: 24px;"><img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/info_title_l.gif"/></td>';
		}
		html += '		<td valign="center" nowrap="nowrap" style="padding-top:2px;background-image: url(' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/bggray4.gif);	background-repeat: repeat-x;height: 24px;">';
		html += '			<table align="center" width="100%" cellspacing="0" cellpadding="0">';
		html += '				<tr>';
		html += '					<td height="19" nowrap="nowrap" style="background-repeat: repeat-x;background-image: url(' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/info_title_m.gif);">';
		html += '						<img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/book.gif" style="margin-left:2px;margin-right:4px;"/>';
		html += '					</td>';
		html += '					<td width="100%" height="19" nowrap="nowrap" style="background-repeat: repeat-x;background-image: url(' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/info_title_m.gif);padding-left:6px;font-weight: bold;color: #000000;text-align: left;font-size:13px;">';
		html += '						エリアお気に入り一覧';
		html += '					</td>';
		html += '					<td width="80" height="19" nowrap="nowrap" style="background-repeat: repeat-x;background-image: url(' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/info_title_m.gif);padding-top:2px;text-align: left;font-size:13px;">';
		html += '						<img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/button_add.gif" style="height:11px;cursor : pointer;margin-top:2px;margin-right:15px;" onclick="mapionGlobals.bookmark.addArea();"/>';
		html += '					</td>';
		html += '				</tr>';
		html += '			</table>';
		html += '		</td>';
		if(mapionFuncs.net.browser.IE){
			html += '		<td width="9" style="padding-top:0px;background-image: url(' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/bggray4.gif);background-repeat: repeat-x;height: 24px;"><img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/info_title_r.gif"/></td>';
		} else {
			html += '		<td width="9" style="padding-top:6px;background-image: url(' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/bggray4.gif);background-repeat: repeat-x;height: 24px;"><img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/info_title_r.gif"/></td>';
		}
		html += '	</tr>';
		html += '	<tr>';
		html += '		<td colspan="3" valign="top" style="height:90px;">';
		html += '			<div id="cmjAreaName" style="overflow:hidden;"></div>';
		html += '		</td>';
		html += '	</tr>';
		html += '</table>';
		
		
		// 業種
		html += '<table width="100%" cellpadding="0" cellspacing="0">';
		html += '	<tr>';
		if(mapionFuncs.net.browser.IE){
			html += '		<td width="9" style="padding-top:0px;background-image: url(' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/bggray4.gif);background-repeat: repeat-x;height: 24px;"><img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/info_title_l.gif"/></td>';
		} else {
			html += '		<td width="9" style="padding-top:6px;background-image: url(' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/bggray4.gif);background-repeat: repeat-x;height: 24px;"><img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/info_title_l.gif"/></td>';
		}
		html += '		<td valign="center" nowrap="nowrap" style="padding-top:2px;background-image: url(' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/bggray4.gif);	background-repeat: repeat-x;height: 24px;">';
		html += '			<table align="center" width="100%" cellspacing="0" cellpadding="0">';
		html += '				<tr>';
		html += '					<td height="19" nowrap="nowrap" style="background-repeat: repeat-x;background-image: url(' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/info_title_m.gif);">';
		html += '						<img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/book.gif" style="margin-left:2px;margin-right:4px;"/>';
		html += '					</td>';
		html += '					<td width="100%" height="19" nowrap="nowrap" style="background-repeat: repeat-x;background-image: url(' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/info_title_m.gif);padding-left:6px;font-weight: bold;color: #000000;text-align: left;font-size:13px;">';
		html += '						業種お気に入り一覧';
		html += '					</td>';
		html += '					<td width="80" height="19" nowrap="nowrap" style="background-repeat: repeat-x;background-image: url(' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/info_title_m.gif);padding-top:2px;text-align: left;font-size:13px;">';
		html += '						<img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/button_add.gif" style="height:11px;cursor : pointer;margin-top:2px;margin-right:15px;" onclick="mapionGlobals.bookmark.addGenre();"/>';
		html += '					</td>';
		html += '				</tr>';
		html += '			</table>';
		html += '		</td>';
		if(mapionFuncs.net.browser.IE){
			html += '		<td width="9" style="padding-top:0px;background-image: url(' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/bggray4.gif);background-repeat: repeat-x;height: 24px;"><img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/info_title_r.gif"/></td>';
		} else {
			html += '		<td width="9" style="padding-top:6px;background-image: url(' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/bggray4.gif);background-repeat: repeat-x;height: 24px;"><img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/info_title_r.gif"/></td>';
		}
		html += '	</tr>';
		html += '	<tr>';
		html += '		<td colspan="3" valign="top" style="height:90px;">';
		html += '			<div id="cmjGenre" style="overflow:hidden;"></div>';
		html += '		</td>';
		html += '	</tr>';
		html += '</table>';
		
		document.getElementById("cmjBookmark").innerHTML = html;
		
		this.writeArea(mapionFuncs.net.getCookie("cmj.bookmark.area"));
		this.writeGenre(mapionFuncs.net.getCookie("cmj.bookmark.genre"));
	},
	
	/********************************
	 * お気に入り設定（エリア登録） *
	 ********************************/
	addArea: function() {
	
		var areaName = mapionGlobals.sokodoko.areaName;
		
		if (!areaName) {
			alert("場所が特定できません。");
			return;
		}
	
		var map = mapionGlobals.map;
		
		// 緯度経度
		var centerLatLng = map.getCenterLatLng();
		
		// 縮尺
		var scl = map.getZoomLevel();
		
		var cookie = mapionFuncs.net.getCookie("cmj.bookmark.area");
		
		var cookieValue = "";
		if (cookie) { // 既にクッキーあれば
		
			cookieValue += centerLatLng.x + "/" + centerLatLng.y + "/" + scl + "/" + areaName;
			addCookieArray = [];
			cookieSplit = cookie.split("||");
			for (var i = 0; i < cookieSplit.length; i++) {
				var cCookie = cookieSplit[i];
				var cCookieSplit = cCookie.split("/");
				var cookieX = cCookieSplit[0];
				var cookieY = cCookieSplit[1];
				var cookieScl = cCookieSplit[2];
				var cookieAreaName = cCookieSplit[3];
				
				if (centerLatLng.x == cookieX && centerLatLng.y == cookieY && scl == cookieScl) {
					alert("既に登録されています。");
					return;
				}
				
				addCookieArray.push(cookieX + "/" + cookieY + "/" + cookieScl + "/" + cookieAreaName);
				
				if (i == 3) {
					break;
				}
			}
			cookieValue += "||" + addCookieArray.join("||");
			
		} else { // クッキーなければ
			cookieValue += centerLatLng.x + "/" + centerLatLng.y + "/" + scl + "/" + areaName;
		}

		mapionFuncs.net.setCookie("cmj.bookmark.area", cookieValue, mapionGlobals.constant.EXPIRES);
		
		this.writeArea(mapionFuncs.net.getCookie("cmj.bookmark.area"));
	},

	/********************************
	 * お気に入り設定（業種登録） *
	 ********************************/
	addGenre: function() {
	
		var currentGenre = mapionGlobals.currentGenre;
		var currentGenreSplit = currentGenre.split("/");
		
		if (currentGenre == "") {
			alert("業種で検索が実行されていません。");
			return;
		}
	
		var cookie = mapionFuncs.net.getCookie("cmj.bookmark.genre");

		var cookieStr = currentGenre;
		if (cookie) { // 既にクッキーあれば
		
			addCookieArray = [];
			cookieSplit = cookie.split("||");
			for (var i = 0; i < cookieSplit.length; i++) {
				var cCookie = cookieSplit[i];
				var cCookieSplit = cCookie.split("/");
				var cookieId = cCookieSplit[0];
				var cookieValue = cCookieSplit[1];
				var cookieType = cCookieSplit[2];
	
				if (currentGenreSplit[0] == cookieId && currentGenreSplit[1] == cookieValue && currentGenreSplit[2] == cookieType) {
					alert("既に登録されています。");
					return;
				}
	
				addCookieArray.push(cookieId + "/" + cookieValue + "/" + cookieType);
				
				if (i == 3) {
					break;
				}
			}
			cookieStr += "||" + addCookieArray.join("||");
			
		}

		mapionFuncs.net.setCookie("cmj.bookmark.genre", cookieStr, mapionGlobals.constant.EXPIRES);
		
		this.writeGenre(mapionFuncs.net.getCookie("cmj.bookmark.genre"));
	},

	/*****************************************
	 * お気に入り設定（クッキー反映/エリア） *
	 *****************************************/
	writeArea: function(cookie) {
	
		if (!cookie) {
			document.getElementById("cmjAreaName").innerHTML = "";
			return;
		}

		var html = '';
		cookieSplit = cookie.split("||");
		for (var i = 0; i < cookieSplit.length; i++) {
			var cCookie = cookieSplit[i];
			var cCookieSplit = cCookie.split("/");
			var x = cCookieSplit[0];
			var y = cCookieSplit[1];
			var scl = cCookieSplit[2];
			var areaName = cCookieSplit[3];
			html += '<table cellspacing="0" cellpadding="0" style="width:100%;">';
			html += '<tr>';
			html += '<td>';
			html += '<a href="javascript:mapionGlobals.bookmark.goArea(' + x + ',' + y + ',' + scl + ');">';
			html += areaName;
			html += '</a>';
			html += '</td>';
			html += '<td align="right">';
			html += '<img width="35" height="11" style="cursor:pointer;" src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/remove.gif" onclick="mapionGlobals.bookmark.removeCookie(' + i + ', \'area\');">';
			html += '</td>';
			html += '</tr>';
			html += '</table>';
		}
		
		document.getElementById("cmjAreaName").innerHTML = html;
	},
	
	/***************************************
	 * お気に入り設定（クッキー反映/業種） *
	 ***************************************/
	writeGenre: function(cookie) {

		if (!cookie) {
			document.getElementById("cmjGenre").innerHTML = "";
			return;
		}
		var html = '';
		cookieSplit = cookie.split("||");
		for (var i = 0; i < cookieSplit.length; i++) {
			var cCookie = cookieSplit[i];
			var cCookieSplit = cCookie.split("/");
			var id = cCookieSplit[0];
			var value = cCookieSplit[1];
			var type = cCookieSplit[2];
			var keywordType = cCookieSplit[3] || "";
			html += '<table cellspacing="0" cellpadding="0" style="width:100%;">';
			html += '<tr>';
			html += '<td>';
			html += '<a href="javascript:mapionGlobals.bookmark.goGenre(\'' + id + '\',\'' + value + '\',\'' + type + '\',\'' + keywordType + '\');">';
			html += value;
			html += '</a>';
			html += '</td>';
			html += '<td align="right">';
			html += '<img width="35" height="11" style="cursor:pointer;" src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/remove.gif" onclick="mapionGlobals.bookmark.removeCookie(' + i + ', \'genre\');">';
			html += '</td>';
			html += '</tr>';
			html += '</table>';
		}
		
		document.getElementById("cmjGenre").innerHTML = html;
	},
	
	/**********************************
	 * お気に入り設定（クッキー削除） *
	 **********************************/
	removeCookie: function(index, type) {
	
		var cookieName;
		var func;
		switch (type) {
		case 'area':
			cookieName = "cmj.bookmark.area";
			func = mapionGlobals.bookmark.writeArea;
			break;
		case 'genre':
			cookieName = "cmj.bookmark.genre";
			func = mapionGlobals.bookmark.writeGenre;
			break;
		default:
		}
		
		var cookie = mapionFuncs.net.getCookie(cookieName);
		var cookieSplit = cookie.split("||");
		var newCookie = [];
		for (var i = 0; i < cookieSplit.length; i++) {
			if (i != index) {
				newCookie.push(cookieSplit[i]);
			}
		}
		mapionFuncs.net.setCookie(cookieName, newCookie.join("||"));
		func(mapionFuncs.net.getCookie(cookieName));
	},
	
	/************************************
	 * お気に入り設定（エリアチェンジ） *
	 ************************************/
	goArea: function(x, y, scl) {
	
		var map = mapionGlobals.map;
		map.centerAndZoom(new MPoint(x, y), scl);
		mapionGlobals.moveEnd();
	},
	
	/************************************
	 * お気に入り設定（業種チェンジ） *
	 ************************************/
	goGenre: function(id, value, type, keywordType) {
		switch (type) {
		case 'keyword':
			mapionGlobals.keyword.request(value, keywordType);
			break;
		case 'slider':
			mapionGlobals.slider.request(id, value);
			break;
		case 'often':
			mapionGlobals.often.click(id, value);
			break;
		case 'selectGenre':
			mapionGlobals.selectGenre.request(id);
			break;
		default:
		}
	}
};

/**************************
 * よく検索されている業種 *
 **************************/
mapionGlobals.often = {
	
	// よく検索されている業種用ParamHash
	ph: null,

	/**********************************
	 * よく検索されている業種（init） *
	 **********************************/
	init: function() {
		
		var ph = new mapionGlobals.api.General();
		ph.replace("grp", mapionGlobals.constant.GRP);
		ph.replace("pm", "100");
		ph.replace("start", "1");
		ph.replace("tno", "2");
		ph.replace("vo", "mbml");
		ph.replace("json", "1");
		ph.replace("callback", "mapionGlobals.often._init");
			
		var url = ph.getRequestURI();
		//console.log(url);
		new mapionFuncs.net.Jsonp(url).make().request().remove();
		
	},
	
	/**********************************************
	 * よく検索されている業種（initコールバック） *
	 **********************************************/
	_init: function(response) {	
		
		var generalList = response.mbml.GeneralList.General instanceof Array ? response.mbml.GeneralList.General : [response.mbml.GeneralList.General];
		var g001Html = "";
		var g002Html = "";
		var g003Html = "";
		var g004Html = "";
		
		for (var i = 0; i < generalList.length; i++) {
	
			var general = generalList[i];
			switch (general.kg_genre) {
			case 'G001':
				g001Html += '<dd style="margin-left:20px;">';
				g001Html += '<a href="javascript:mapionGlobals.often.click(\'' + general.id + '\', \'' + general.kg_name + '\');">';
				g001Html += general.kg_name;
				g001Html += '</a></dd>';
				break;
			case 'G002':
				g002Html += '<dd style="margin-left:20px;">';
				g002Html += '<a href="javascript:mapionGlobals.often.click(\'' + general.id + '\', \'' + general.kg_name + '\');">';
				g002Html += general.kg_name;
				g002Html += '</a></dd>';
				break;
			case 'G003':
				g003Html += '<dd style="margin-left:20px;">';
				g003Html += '<a href="javascript:mapionGlobals.often.click(\'' + general.id + '\', \'' + general.kg_name + '\');">';
				g003Html += general.kg_name;
				g003Html += '</a></dd>';
				break;
			case 'G004':
				g004Html += '<dd style="margin-left:20px;">';
				g004Html += '<a href="javascript:mapionGlobals.often.click(\'' + general.id + '\', \'' + general.kg_name + '\');">';
				g004Html += general.kg_name;
				g004Html += '</a></dd>';
				break;
			default:
			}
			
		}
		
		var allHtml = '<dl style="margin-top:0px;">';
		allHtml += '<dt><img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/yajirusi_d2.gif" width="15" height="15">美容・エステ</dt>';
		allHtml += g004Html;
		allHtml += '<dt><img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/yajirusi_d2.gif" width="15" height="15">グルメ</dt>';
		allHtml += g001Html;
		allHtml += '<dt><img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/yajirusi_d2.gif" width="15" height="15">宿泊施設</dt>';
		allHtml += g002Html;
		allHtml += '<dt><img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/yajirusi_d2.gif" width="15" height="15">病院・歯科</dt>';
		allHtml += g003Html;
		allHtml += '</dl>';
		
		document.getElementById("cmjOften").innerHTML = allHtml;
	},

	/**********************************************
	 * よく検索されている業種（リンククリック時） *
	 **********************************************/
	click: function(id, name) {
	
		var map = mapionGlobals.map;
	
		map.closeInfoWindow();
		
		if (map.getZoomLevel() < mapionGlobals.constant.RESEARCH_LEVEL_BORDER) {
			alert("縮尺が1/21000以下でないと検索できません。");
			return;
		}
		
		mapionGlobals.currentGenre = id + "/" + name + "/often";
		document.getElementById("cmjCurrentGenre").innerHTML = '「<b><font style="color:rgb(255, 114, 0);">' + name + '</font></b>」で検索中';
	
		var ph = this.ph = new mapionGlobals.api.Local2();

		ph.replace("lmt", mapionGlobals.constant.PAGE_MAX);
		ph.replace("lgc", "1");
		ph.replace("fmt", "json");
		ph.replace("cb", "mapionGlobals.resultList.make");
		ph.replace("cate2", id);
		ph.replace("cpix", mapionGlobals.constant.CPIX);
		ph.replace("start", "1");

		this.movedRequest();
	
	},
	
	/******************************************
	 * よく検索されている業種（movedRequest） *
	 ******************************************/
	movedRequest: function() {

		var map = mapionGlobals.map;
		
		// 全て消す
		map.clearOverlays();

		mapionGlobals.recommend.openPoiId = null;
	
		mapionGlobals.searchType = "often";
	
		// 緯度経度
		var centerLatLng = map.getCenterLatLng();
		
		// 縮尺
		var scl = map.getZoomLevel();
		
		// 四隅
		var boundsLatLng = map.getBoundsLatLng();
		
		var ph = this.ph;
		ph.replace("nl", new String(centerLatLng.y));
		ph.replace("el", new String(centerLatLng.x));
		ph.replace("minnl", new String(boundsLatLng.minY));
		ph.replace("maxnl", new String(boundsLatLng.maxY));
		ph.replace("minel", new String(boundsLatLng.minX));
		ph.replace("maxel", new String(boundsLatLng.maxX));
		ph.replace("scl", scl);

		this.doRequest();
	},
	
	/***************************************
	 * よく検索されている業種（doRequest） *
	 ***************************************/
	doRequest: function() {
	
		// 検索中画像
		mapionGlobals.resultList.dispSearchImage();
	
		var ph = this.ph;
		
		mapionGlobals.lastAPI = ph;
		
		var url = ph.getRequestURI();
		//javascript:void(prompt("", url));
		new mapionFuncs.net.Jsonp(url).make().request().remove();
	}

};

/*************************
 * shop_idパラメータ有り *
 *************************/
mapionGlobals.onlyOne = {

	// ParamHash
	ph: null,
	
	data: null,
	
	// 検索結果のマップ
	poiInfo: {},
	
	focusId: "",
	
	/*********************************
	 * shop_idパラメータ有り（init） *
	 *********************************/
	init: function(shop_id) {

		var ph = this.ph = new mapionGlobals.api.PInfo();
		ph.replace("fmt", "json");
		ph.replace("cb", "mapionGlobals.onlyOne.callback");
		ph.replace("id", shop_id);
		
		var url = ph.getRequestURI();
		new mapionFuncs.net.Jsonp(url).make().request().remove();

	},
	
	/*****************************************
	 * shop_idパラメータ有り（コールバック） *
	 *****************************************/
	callback: function(response) {
	
		var map = mapionGlobals.map;
		
		var id = response.Parameter.id;

		// マーカー ---
		var iconInfo = mapionGlobals.recommend.getIconInfo("OTHER");
		var customMarkerObj = new MIcon();
		customMarkerObj.image = iconInfo.image;
		customMarkerObj.width = iconInfo.width;
		customMarkerObj.height = iconInfo.height;
		customMarkerObj.iconAnchor = new MPoint(0, iconInfo.height);
		marker = new MMarker(new MPoint(response.ResultList.Item[0].longitude, response.ResultList.Item[0].latitude), customMarkerObj);         
		map.addOverlay(marker);
		// end ---
		
		// poiとマーカーIDの対応表を作る---
		//for (var j = 0; j < ids.length; j++) {
		//	var cId = ids[j];	
		//	this.poiToMarker[cId] = marker.id;
		//}
		// end ---
		
		mapionGlobals.recommend.poiToMarker[id] = marker.id;
		
		// マーカーが持ってるpoiのマップを作る
		mapionGlobals.recommend.markerToId[marker.id] = id;
		
		mapionGlobals.recommend.poiDetail[id] = response.ResultList.Item[0];
		
		// イベント登録
		MEvent.addListener(marker, "click", function(marker){		
			mapionGlobals.recommend.markerInit(marker);
		});
		MEvent.addListener(marker, "mouseover", function(arg1, arg2, arg3) {
			arg1.div.style.cursor = "pointer";
		});

		mapionGlobals.recommend.markerOpen(id);		
	}
};

/******************
 * キーワード検索 *
 ******************/
mapionGlobals.keyword = {

	ph: null,
	
	/**************************
	 * キーワード検索（init） *
	 **************************/
	init: function(value, checkboxes) {
	
		var checkedbox;
		for (var i = 0; i < checkboxes.length; i++) {
			var checkbox = checkboxes[i];
			if (checkbox.checked) {
				checkedbox = checkbox;
				break;
			}
		}
		
		var lgc = checkedbox.value;
		
		this.request(value, lgc);
		
		return false;
	},
	
	/********************************
	 * キーワード検索（リクエスト） *
	 ********************************/
	request: function(value, lgc) {
	
		var map = mapionGlobals.map;
	
		map.closeInfoWindow();
	
		if (map.getZoomLevel() < mapionGlobals.constant.RESEARCH_LEVEL_BORDER) {
			alert("縮尺が1/21000以下でないと検索できません。");
			return;
		}
	
		var ph = this.ph = new mapionGlobals.api.Local();
		ph.replace("lmt", mapionGlobals.constant.PAGE_MAX);
		ph.replace("start", "1");
		ph.replace("lgc", lgc);
		ph.replace("fmt", "json");
		ph.replace("cb", "mapionGlobals.resultList.make");
		ph.replace("cpix", mapionGlobals.constant.CPIX);
		ph.replace("q", value);
		
		mapionGlobals.searchType = "keyword";

		if (value == "") {
			return;
		}

		if (value) {
			var valueStr = (20 < value.length) ? value.substr(0, 20) + "..." : value;
			mapionGlobals.currentGenre = "/" + value + "/keyword/" + lgc;
			document.getElementById("cmjCurrentGenre").innerHTML = '「<b><font style="color:#2569AE;">' + valueStr + '</font></b>」で検索中';
		}
		
		this.movedRequest();
	},
	
	/**********************************
	 * キーワード検索（movedRequest） *
	 **********************************/
	movedRequest: function(afterFunc) {

		var map = mapionGlobals.map;
		
		// 緯度経度
		var centerLatLng = map.getCenterLatLng();
		
		// 縮尺
		var scl = map.getZoomLevel();
		
		// 四隅
		var boundsLatLng = map.getBoundsLatLng();
	
		var ph = this.ph;
		
		ph.replace("scl", scl);
		ph.replace("nl", new String(centerLatLng.y));
		ph.replace("el", new String(centerLatLng.x));
		ph.replace("minnl", new String(boundsLatLng.minY));
		ph.replace("minel", new String(boundsLatLng.minX));
		ph.replace("maxnl", new String(boundsLatLng.maxY));
		ph.replace("maxel", new String(boundsLatLng.maxX));
		
		if (afterFunc) {
			ph.replace("bt1", afterFunc);
		}
		
		this.doRequest();

	},
	
	/*******************************
	 * キーワード検索（doRequest） *
	 *******************************/
	doRequest: function() {
	
		// 検索中画像
		mapionGlobals.resultList.dispSearchImage();
	
		var ph = this.ph;
		
		mapionGlobals.lastAPI = ph;
		
		//var url = mapionGlobals.constant.LOCAL_API() + "?" + ph.toString();
		var url = ph.getRequestURI();
		new mapionFuncs.net.Jsonp(url).make().request().remove();
	},
	
	/******************************
	 * キーワード検索（入力確定） *
	 ******************************/
	inputClick: function() {
	

		var form = document.getElementById("cmjKeywordForm");
		var value = form.cmjKeywordInput.value;
		var radio = form.cmjKeyword;
		if (value != "") {
			mapionGlobals.keyword.init(value, radio);
		}
	}

};

/************
 * 業種選択 *
 ************/
mapionGlobals.selectGenre = {

	cateMap: {},
	
	ph: null,

	/****************************************
	 * 業種選択（業種選択ボタンクリック時） *
	 ****************************************/
	click: function() {
	
		cateMap = {};
		
		var map = mapionGlobals.map;

		var currentGenreSplit = mapionGlobals.currentGenre.split("/");

		var centerLatLng = map.getCenterLatLng();
		var nl = centerLatLng.y;
		var el = centerLatLng.x;
		
		// 四隅
		var boundsLatLng = map.getBoundsLatLng();
		var minnl = boundsLatLng.minY;
		var maxnl = boundsLatLng.maxY;
		var minel = boundsLatLng.minX;
		var maxel = boundsLatLng.maxX;

		var ph;
		if (currentGenreSplit[0]) {
			ph = new mapionGlobals.api.LocalCate2();
			ph.replace("lmt", mapionGlobals.constant.GENRE_PAGE_MAX);
			ph.replace("fmt", "json");
			ph.replace("cb", "mapionGlobals.selectGenre.callback");
			ph.replace("nl", new String(nl));
			ph.replace("el", new String(el));
			ph.replace("minnl", new String(minnl));
			ph.replace("maxnl", new String(maxnl));
			ph.replace("minel", new String(minel));
			ph.replace("maxel", new String(maxel));
			ph.replace("cate", currentGenreSplit[0]);
		} else {
			ph = new mapionGlobals.api.LocalCate();
			ph.replace("lmt", mapionGlobals.constant.GENRE_PAGE_MAX);
			ph.replace("fmt", "json");
			ph.replace("cb", "mapionGlobals.selectGenre.callback");
			ph.replace("nl", new String(nl));
			ph.replace("el", new String(el));
			ph.replace("minnl", new String(minnl));
			ph.replace("maxnl", new String(maxnl));
			ph.replace("minel", new String(minel));
			ph.replace("maxel", new String(maxel));
			ph.replace("q", currentGenreSplit[1]);
		}
		
		var url = ph.getRequestURI();
		//javascript:void(prompt("", url));
		new mapionFuncs.net.Jsonp(url).make().request().remove();
	
	},
	
	/*****************************************************
	 * 業種選択（業種選択ボタンクリック時/コールバック） *
	 *****************************************************/
	callback: function(response) {

		//if (mapionGlobals.searchType.indexOf("/") != -1) {
		//	mapionGlobals.searchType = "selectGenre/" + mapionGlobals.searchType.split("/")[1];
		//} else {
		//	mapionGlobals.searchType = "selectGenre/keyword";
		//}
		//mapionGlobals.searchType = "selectGenre/" + (mapionGlobals.searchType.split("/")[1] || "keyword");
		mapionGlobals.searchType = "selectGenre";
	
		//console.log(response);
		
		var html = '';
		html += '1つだけ選択のときはテキストをクリック。複数選択するとき→はチェックボックスを選択。（最大5個まで）<br/>';
		
		html += '<form onsubmit="return mapionGlobals.selectGenre.next(this.cmjCheckGenre);">';
		
		html += '<div><input type="submit" value="検索を続ける"/><br/></div>';
		
		var items = response.ResultList.Item;
		for (var i = 0; i < items.length; i++) {

			var item = items[i];
			
			// cateMapに入れる ---
			this.cateMap[item.id] = item.name;
			// end ---
			
			var id = "cmjCheckGenre" + item.id;
			
			html += '<input type="checkbox" name="cmjCheckGenre" id="' + id + '" value="' + item.id + '"/>';
			html += '<label style="cursor:pointer;" for="' + id + '">';
			html += item.name;
			html += '（' + item.num + '）';
			html += '</label>';
			html += '<br/>';
		}
		html += '<div><input type="submit" value="検索を続ける"/><br/></div>';
		html += '</form><br/>';
		
		document.getElementById("cmjResultList").innerHTML = html;
		document.getElementById("cmjResultList").style.overflow = "auto";
	},
	
	/************************************
	 * 業種選択（検索を続けるクリック） *
	 ************************************/
	next: function(checkboxes) {

		var cateArr = [];
		for (var i = 0; i < checkboxes.length; i++) {
			var checkbox = checkboxes[i];
			if (checkbox.checked) {
				cateArr.push(checkbox.value);
			}
		}
		
		if (cateArr.length == 0) {
			alert("チェックを入れてください。");
			return false;
		}
		
		if (5 < cateArr.length) {
			alert("チェックは最大5個までです。");
			return false;
		}
		
		this.request(cateArr.join(","));
		
		return false;
	},
	
	/**************************
	 * 業種選択（リクエスト） *
	 **************************/
	request: function(cate) {
	
		var map = mapionGlobals.map;
		
		mapionGlobals.searchType = "searchGenre";
		
		map.closeInfoWindow();
		
		var cateSplit = cate.split(",");
		var valueArr = [];
		for (var i = 0; i < cateSplit.length; i++) {
			valueArr.push(this.cateMap[cateSplit[i]]);
		}
		var value = valueArr.join(",");
		
		

		//console.log(mapionGlobals.currentGenre);
		
		var currentGenreSplit = mapionGlobals.currentGenre.split("/");
		
		var fromKeyword = false;
		if (currentGenreSplit[2] == "keyword") {
			value = currentGenreSplit[1] + "," + value;
			fromKeyword = true;
		}
		
		var valueStr = (20 < value.length) ? value.substr(0, 20) + "..." : value;
		
		if (fromKeyword) {
			var valueStrSplit = valueStr.split(",");
			var valueStrSplitShift = valueStrSplit.shift();
			
			document.getElementById("cmjCurrentGenre").innerHTML = '「<b><font style="color:#2569AE;">' + valueStrSplitShift + '</font><font style="color:rgb(255, 114, 0);">,' + valueStrSplit.join(",") + '</font></b>」で検索中';
		} else {
			document.getElementById("cmjCurrentGenre").innerHTML = '「<b><font style="color:rgb(255, 114, 0);">' + valueStr + '</font></b>」で検索中';
		}

		var beforeSearchType = mapionGlobals.currentGenre.split("/")[2];
		var ph = this.ph = mapionGlobals[beforeSearchType].ph;

		ph.replace("cate", cate);
		ph.replace("start", "1");

		this.movedRequest();
		
	},
	
	/**************************
	 * 業種選択（movedRequest） *
	 **************************/
	movedRequest: function(afterFunc) {
	
		var map = mapionGlobals.map;
	
		// 緯度経度
		var centerLatLng = map.getCenterLatLng();

		// 縮尺
		var scl = map.getZoomLevel();

		// 四隅
		var boundsLatLng = map.getBoundsLatLng();
		
		var ph = this.ph;
		ph.replace("nl", new String(centerLatLng.y));
		ph.replace("el", new String(centerLatLng.x));
		ph.replace("minnl", new String(boundsLatLng.minY));
		ph.replace("maxnl", new String(boundsLatLng.maxY));
		ph.replace("minel", new String(boundsLatLng.minX));
		ph.replace("maxel", new String(boundsLatLng.maxX));
		ph.replace("scl", scl);
		
		if (afterFunc) {
			ph.replace("bt1", afterFunc);
		}
		
		this.doRequest(afterFunc);
	},
	
	/**************************
	 * 業種選択（doRequest） *
	 **************************/
	doRequest: function() {

		// 検索中画像
		mapionGlobals.resultList.dispSearchImage();
	
		var ph = this.ph;

		mapionGlobals.lastAPI = ph;

		var url = ph.getRequestURI();

		//javascript:void(prompt("", url));
		new mapionFuncs.net.Jsonp(url).make().request().remove();
	}
};

// function ====================================================================
/********************
 * ジャンルクリック	*
 ********************/
mapionGlobals.generateHtml = function(poi) {

	var poiLink;
	if (poi.ad_url_pc) {
		poiLink = "http://nttbj.itp.ne.jp" + poi.ad_url_pc + "index.html";
	} else {
		poiLink = "http://itp.ne.jp/servlet/jp.ne.itp.sear.SGSSVWebDspCtrl?Gyoumu_cate=3&Media_cate=populer&cont_id=a00&svc=1901&index_dsp=2&navi=search,r1&index_sta=0&proc_id=k1&clk=181&kid=" + poi.id;
	}


	
	//var topicUrl = "http://staging.nttbj.looops.in/topics/trial?shop_id=" + poi.id + "&area=" + poi.pref_code + poi.city_code + "&nl=" + poi.latitude + "&el=" + poi.longitude + "&cate=" + poi.genre;
	//var kuchikomiUrl = "http://kuchikomi.itp.ne.jp/user?ACTION_ID=STORETOP&grid=" + poi.kuchikomi_id;
	
	var catchphrase = poi.catch_phrase ? poi.catch_phrase : "";

	// 電略 ---
	var denryakuImg = mapionGlobals.getMakedDenryaku([poi.phone_type]);
	
	// melters
	mapionGlobals.recommend.nameMelters.push("cmjMelterName" + poi.id);
	//mapionGlobals.recommend.telMelters.push("cmjMelterTellAll" + poiId);

	var html = '<div style="width:238px;height:100%;z-index:8000;">';
	html += '	<table border="0" cellspacing="0" cellpadding="0">';
	html += '		<tr>';
	html += '			<td colspan="2">';
	html += '				<div id="cmjMelterName' + poi.id + '" style="width:238px;">';
	html += '					<a target="_blank" href="' + poiLink + '">' + poi.name + '</a>';
	html += '				</div>';
	html += '			</td>';
	html += '		</tr>';
	html += '		<tr>';
	html += '			<td colspan="2">';
	html += '				<div style="width:238px;">';
	html += 					catchphrase;
	html += '				</div>';
	html += '			</td>';
	html += '		</tr>';
	html += '		<tr>';
	html += '			<td style="width:167px;" valign="top">';
	html += '				<table border="0" cellspacing="0" cellpadding="0" style="100%">';
	html += '					<tr>';
	html += '						<td>';
	html += 							denryakuImg;
	html += '								<a target="_blank" href="' + poiLink + '">' + poi.phone_number + '</a>';
	html += '						</td>';
	html += '					</tr>';
	html += '					<tr>';
	html += '						<td>';

/*
	if (poi.CooperateList) {
		for (var i = 0; i < poi.CooperateList.Cooperate.length; i++) {
			var cooperate = poi.CooperateList.Cooperate[i];
			if (cooperate.code == "10") {
				html += '<a target="_blank" href="' + cooperate.url + '">';
				html += '<img src="' + mapionGlobals.constant.WEBCALLING_IMG() + '"/>';
				html += '</a>';
			}
		}
		html += '<br/>';
	}
*/

	/*
	if (!poi.flag02 && poi.flag02 != "1") {
		if (poi.url != "" && poi.url_link == "1") {
			html += '<a target="_blank" href="' + poi.url + '">HP</a>';
		} else {
			html += '<font style="color:gray;">HP</font>';
		}
		html += '&nbsp;';
	}
	*/
	var hpType;
	if (poi.flag02 == "1") {
		hpType = "tsume";
	} else {
		if (poi.ad_flag == "1" && (!poi.url_link || poi.url_link == "0")) {
			hpType = "tsume";
		} else {
			if (poi.url) {
				hpType = "visible";
			} else {
				hpType = "gray";
			}
		}
	}
	switch (hpType) {
	case 'visible':
		html += '<a target="_blank" href="' + poi.url + '">HP</a>&nbsp;';
		break;
	case 'gray':
		html += '<font style="color:gray;">HP</font>&nbsp;';
		break;
	default:
	}
	
	
	
	if (poi.flag01 == "1") {
		html += '<a href="javascript:topicButtonCallBack(\'' + poi.id + '\', ' + poi.latitude + ', ' + poi.longitude + ', \'' + poi.category_code + '\', \'' + poi.pref_code + poi.city_code + '\');">トピック</a>';
		html += '&nbsp;';
	}

	if (poi.kuchi_status == "1" && poi.kuchi_icon == "1") {
		html += '<a target="_blank" href="http://kuchikomi.itp.ne.jp/user?ACTION_ID=STORETOP&grid=' + poi.kuchi_id + '">くちコミ</a>';
	}
	
	if (poi.coupon_flag == "1" || poi.coupon_flag == "3") {
		html += '								<br/><a href="http://nttbj.itp.ne.jp' + poi.ad_url_pc + 'coupon.html" target="_blank">';
		html += '									<img width="53" height="14" border="0" src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/img_coupon01.gif" alt="マル得クーポン" style="margin-right: 3px;"/>';
		html += '								</a>';
	}
	
	html += '<br/>';
	
	if (poi.CooperateList) {
		for (var i = 0; i < poi.CooperateList.Cooperate.length; i++) {
			var cooperate = poi.CooperateList.Cooperate[i];
			if (cooperate.code == "01" || cooperate.code == "02") { // 01 => 楽天市場, 02 => 楽天トラベル
				html += '<a target="_blank" href="' + cooperate.url + '"><img src="' + mapionGlobals.constant.HYPER_SERVER + cooperate.icon + '"/></a>';
			}
		}
	}

	html += '						</td>';
	html += '					</tr>';
	html += '				</table>';
	html += '			</td>';
	if (poi.thumbnail) {

		html += '		<td style="width:113px;">';
		html += '			<div style="width:113px;height:86px;">';
		html += '				<img src="http://nttbj.itp.ne.jp' + poi.ad_url_pc  + poi.thumbnail + '"/>';
		html += '			</div>';
		html += '		</td>';
	} else {
		html += '		<td style="width:113px;">';
		html += '			<br/>';
		html += '		</td>';
	}
	html += '		</tr>';
	html += '	</table>';
	html += '</div>';
	
	return html;
};

mapionGlobals.genreClick = function(key, value) {

	var map = mapionGlobals.map;

	var infowindowIsClose = (mapionGlobals.searchType == "recommend") ? false : true;
	
	// デフォルトの吹き出しからここに来た場合必要
	if (document.getElementById("cmjPoiName")) {
		document.getElementById("cmjPoiName").style.visibility = "hidden";
	}
	if (document.getElementById("cmjTellAllMelter")) {
		document.getElementById("cmjTellAllMelter").style.visibility = "hidden";
	}
};

/********************************
 * 再検索ON/OFFボタンクリック時 *
 ********************************/
mapionGlobals.researchButtonClick = function() {

	var autoSearchButton = document.getElementById("cmjAutoSearchButton");

	if (mapionGlobals.doResearch) {
		autoSearchButton.style.backgroundImage = 'url(' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/search_off.gif)';
		mapionGlobals.doResearch = false;
	} else {
		autoSearchButton.style.backgroundImage = 'url(' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/search_on.gif)';
		mapionGlobals.doResearch = true;
		mapionGlobals.moveEnd();
	}
};

/**************
 * melter実行 *
 **************/
mapionGlobals.doMelter = function() {

	for (var i = 0; i < mapionGlobals.recommend.nameMelters.length; i++) {
		var nameElm = document.getElementById(mapionGlobals.recommend.nameMelters[i]);
		if (nameElm) {
			new bt_melter(nameElm, 1);
		}
	}
	//for (var i = 0; i < mapionGlobals.recommend.telMelters.length; i++) {
	//	var telElm = document.getElementById(mapionGlobals.recommend.telMelters[i]);
	//	if (telElm) {
	//		new bt_melter(telElm, 0);
	//	}
	//}
};

/******************
 * 電略画像を返す *
 ******************/
mapionGlobals.getMakedDenryaku = function(denryakuList) {

	var ret = '';
	for (var i = 0; i < denryakuList.length; i++) {
		var denryaku = parseInt(denryakuList[i]);
		if (denryaku == 6 || denryaku == 12 || denryaku == 22 || denryaku == 24 || denryaku == 27) {
			ret += '<img src="' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/telmark_' + denryaku + '.gif' + '"/>';
		}
	}

	return ret;
};

/********************
 * cookieを取得する *
 ********************/
mapionGlobals.getCookie = function() {
	var recommendNumber = mapionFuncs.net.getCookie("cmj.recommend.number");
	if (!recommendNumber) {
		recommendNumber = "60";
		mapionFuncs.net.setCookie("cmj.recommend.number", recommendNumber, mapionGlobals.constant.EXPIRES);
	}
	
	var recommendCategories = mapionFuncs.net.getCookie("cmj.recommend.categories");
	if (!recommendCategories) {
		recommendCategories = "OTHER,G004,G001,G002,G003";
		mapionFuncs.net.setCookie("cmj.recommend.categories", recommendCategories, mapionGlobals.constant.EXPIRES);
	}
	
	return {
		"cmj.recommend.number": recommendNumber,
		"cmj.recommend.categories": recommendCategories
	}
};

/******************
 * htmlを挿入する *
 ******************/
mapionGlobals.insertHtml = function(number, categories) {

	var html = ''
		+ '<div id="cmjMap">'
		+ '	<table id="cmjTable1" cellspacing="0" cellpadding="0">'
		+ '		<tr>'
		+ '			<td id="cmjSokodokoTd">'
		+ '				<table cellspacing="0" cellpadding="0" style="width:100%;">'
		+ '					<tr>'
		+ '						</td>'
		+ '						<td style="width:5px;">'
		+ '						</td>'
		+ '						<td>'
		+ '							<div id="cmjSokodoko"></div>'
		+ '						</td>'
		+ '						<td align="right">'
		+ '							<div id="cmjCurrentGenre"></div>'
		+ '						</td>'
		+ '						</td>'
		+ '						<td align="right">'
		+ '							自動検索：'
		+ '						</td>'
		+ '						<td align="right" style="width:50px;">'
		+ '							<div id="cmjAutoSearchButton" onclick="mapionGlobals.researchButtonClick();" style="width:50px;height:21px;background-image:url(' + mapionGlobals.constant.BLOCK_SERVER + '/itp2/img/search_on.gif);cursor:pointer;">'
		+ '							</div>'
		+ '						</td>'
		+ '						<td style="width:5px;">'
		+ '						</td>'
		+ '					</tr>'
		+ '				</table>'
		+ '			</td>'
		+ '		</tr>'
		+ '		<tr>'
		+ '			<td>'
		+ '				<div id="cmjMmap" style="position:absolute;"></div>'
		+ '			</td>'
		+ '		</tr>'
		+ '	</table>'
		+ '</div>'
	// accordion ---
		+ '<div id="cmjMenu">'
		+ '	<div class="cmjBlock">'
		+ '		<div class="cmjHeader" id="cmjKeywordHead" onclick="mapionGlobals.accordion.open(\'cmjKeyword\');">'
		+ '			<table cellspacing="0" cellpadding="0" style="height:100%;">'
		+ '				<tr>'
		+ '					<td valign="middle">'
		+ '						キーワードで検索'
		+ '					</td>'
		+ '				</tr>'
		+ '			</table>'
		+ '		</div>'
		+ '		<div id="cmjKeyword" class="cmjContent" style="height:100px;">'
		+ '			キーワードを入力してください。<br/>'
		+ '			（スペースで区切って複数指定可能です。例）病院　歯）<br/>'
		+ '			<form id="cmjKeywordForm" onsubmit="return mapionGlobals.keyword.init(this.cmjKeywordInput.value, this.cmjKeyword);">'
		+ '				<input type="text" id="cmjKeywordInput" name="cmjKeywordInput" style="width:200px;"/>'
		+ '				<br/>'
		+ '				<input type="radio" onclick="mapionGlobals.keyword.inputClick();" id="cmjKeywordRadioKeyword" name="cmjKeyword" value="1" checked="checked"/><label for="cmjKeywordRadioKeyword" style="cursor:pointer;">キーワード検索</label>'
		+ '				<br/>'
		+ '				<input type="radio" onclick="mapionGlobals.keyword.inputClick();" id="cmjKeywordRadioCorpname" name="cmjKeyword" value="2"/><label for="cmjKeywordRadioCorpname" style="cursor:pointer;">店舗・企業名検索</label>'
		+ '			</form>'
		+ '		</div>'
		+ '	</div>'
		+ '	<div class="cmjBlock">'
		+ '		<div class="cmjHeader" id="cmjOftenHead" onclick="mapionGlobals.accordion.open(\'cmjOften\');">'
		+ '			<table cellspacing="0" cellpadding="0" style="height:100%;">'
		+ '				<tr>'
		+ '					<td valign="middle">'
		+ '						よく検索されている業種'
		+ '					</td>'
		+ '				</tr>'
		+ '			</table>'
		+ '		</div>'
		+ '		<div id="cmjOften" class="cmjContent">'
		+ '			お待ちください。'
		+ '		</div>'
		+ '	</div>'
		+ '	<div class="cmjBlock">'
		+ '		<div class="cmjHeader" id="cmjSliderHead" onclick="mapionGlobals.accordion.open(\'cmjSlider\');">'
		+ '			<table cellspacing="0" cellpadding="0" style="height:100%;">'
		+ '				<tr>'
		+ '					<td valign="middle">'
		+ '						業種で検索（業種INDEX）'
		+ '					</td>'
		+ '				</tr>'
		+ '			</table>'
		+ '		</div>'
		+ '		<div id="cmjSlider" class="cmjContent">'
		+ '			<div id="cmjWrapper">'
		+ '				<div id="cmjDiv1">'
		+ '					お待ちください。'
		+ '				</div>'
		+ '				<div id="cmjDiv2">'
		+ '					お待ちください。'
		+ '				</div>'
		+ '				<div id="cmjDiv3">'
		+ '					お待ちください。'
		+ '				</div>'
		+ '				<div id="cmjDiv4">'
		+ '					お待ちください。'
		+ '				</div>'
		+ '				<div id="cmjDiv5">'
		+ '					お待ちください。'
		+ '				</div>'
		+ '			</div>'
		+ '		</div>'
		+ '	</div>'
		+ '	<div class="cmjBlock">'
		+ '		<div class="cmjHeader" id="cmjBookmarkHead" onclick="mapionGlobals.accordion.open(\'cmjBookmark\');">'
		+ '			<table cellspacing="0" cellpadding="0" style="height:100%;">'
		+ '				<tr>'
		+ '					<td valign="middle">'
		+ '						お気に入り設定'
		+ '					</td>'
		+ '				</tr>'
		+ '			</table>'
		+ '		</div>'
		+ '		<div id="cmjBookmark" class="cmjContent">'
		+ '		</div>'
		+ '	</div>'
		+ '	<div class="cmjBlock">'
		+ '		<div class="cmjHeader" id="cmjRecommendHead" onclick="mapionGlobals.accordion.open(\'cmjRecommend\');">'
		+ '			<table cellspacing="0" cellpadding="0" style="height:100%;">'
		+ '				<tr>'
		+ '					<td valign="middle">'
		+ '						おすすめ設定'
		+ '					</td>'
		+ '				</tr>'
		+ '			</table>'
		+ '		</div>'
		+ '		<div id="cmjRecommend" class="cmjContent">'
		+ '			<select id="recommendNumberSelect" onchange="mapionGlobals.cookie.recommendNumber(this);">'
		+ '				<option value="40">40</option>'
		+ '				<option value="60">60</option>'
		+ '				<option value="80">80</option>'
		+ '				<option value="100">100</option>'
		+ '				<option value="120">120</option>'
		+ '			</select>'
		+ '			件表示'
		+ '			<br/>'
		+ '			<img src="' + mapionGlobals.constant.OTHER_ICON() + '" width="' + mapionGlobals.constant.OTHER_WIDTH + '" height="' + mapionGlobals.constant.OTHER_HEIGHT + '"/>'
		+ '			<input type="checkbox" name="recommendCategoriesChckebox" value="OTHER" onclick="mapionGlobals.cookie.recommendCategories();"/>'
		+ '			おすすめ情報<br/>'
		+ '			<img src="' + mapionGlobals.constant.G004_ICON() + '" width="' + mapionGlobals.constant.G004_WIDTH + '" height="' + mapionGlobals.constant.G004_HEIGHT + '"/>'
		+ '			<input type="checkbox" name="recommendCategoriesChckebox" value="G004" onclick="mapionGlobals.cookie.recommendCategories();"/>'
		+ '			美容・エステ<br/>'
		+ '			<img src="' + mapionGlobals.constant.G001_ICON() + '" width="' + mapionGlobals.constant.G001_WIDTH + '" height="' + mapionGlobals.constant.G001_HEIGHT + '"/>'
		+ '			<input type="checkbox" name="recommendCategoriesChckebox" value="G001" onclick="mapionGlobals.cookie.recommendCategories();"/>'
		+ '			グルメ<br/>'
		+ '			<img src="' + mapionGlobals.constant.G002_ICON() + '" width="' + mapionGlobals.constant.G002_WIDTH + '" height="' + mapionGlobals.constant.G002_HEIGHT + '"/>'
		+ '			<input type="checkbox" name="recommendCategoriesChckebox" value="G002" onclick="mapionGlobals.cookie.recommendCategories();"/>'
		+ '			宿泊施設<br/>'
		+ '			<img src="' + mapionGlobals.constant.G003_ICON() + '" width="' + mapionGlobals.constant.G003_WIDTH + '" height="' + mapionGlobals.constant.G003_HEIGHT + '"/>'
		+ '			<input type="checkbox" name="recommendCategoriesChckebox" value="G003" onclick="mapionGlobals.cookie.recommendCategories();"/>'
		+ '			病院・歯科<br/>'
		+ '			※アイコンが重なる場合は<img src="' + mapionGlobals.constant.CROWD_ICON() + '" width="' + mapionGlobals.constant.CROWD_WIDTH + '" height="' + mapionGlobals.constant.CROWD_HEIGHT + '"/>' + 'が表示されます'
		+ '		</div>'
		+ '	</div>'
		+ '	<div class="cmjBlock">'
		+ '		<div class="cmjHeader" id="cmjResultListHead" onclick="mapionGlobals.accordion.open(\'cmjResultList\');">'
		+ '			<table cellspacing="0" cellpadding="0" style="height:100%;">'
		+ '				<tr>'
		+ '					<td valign="middle">'
		+ '						検索結果'
		+ '					</td>'
		+ '				</tr>'
		+ '			</table>'
		+ '		</div>'
		+ '		<div id="cmjResultList" class="cmjContent">'
		+ '		</div>'
		+ '	</div>'
		+ '</div>';
	// accordion end ---
	

	document.getElementById("cmjDiv").innerHTML = html;

	// クッキー反映 ---
	var recommendNumberSelect = document.getElementById("recommendNumberSelect");
	for (var i = 0; i < recommendNumberSelect.options.length; i++) {
		var option = recommendNumberSelect.options[i];
		if (number == option.value) {
			option.selected = true;
			break;
		}
	}

	var recommendCategoriesChckebox = document.getElementsByName("recommendCategoriesChckebox");
	for (var i = 0; i < recommendCategoriesChckebox.length; i++) {
		var input = recommendCategoriesChckebox[i];
		if (categories.split(",").inArray(input.value)) {
			input.checked = true;
		}
	}
	// end ---
	
	
	// サイズを決める
	mapionGlobals.setSize();
};

/********************
 * サイズを設定する *
 ********************/
mapionGlobals.setSize = function() {

	var safariPlus = 0;
	if (mapionFuncs.net.browser.safari) {
		safariPlus = 1;
	}
	var mapionDivWidth = mapionGlobals.mapionDivWidth;
	var mapionDivHeight = mapionGlobals.mapionDivHeight;
	
	// widthは%でも指定可能にする
	if (mapionDivWidth <= 100) {
		var clientWidth = document.body.clientWidth;
		mapionDivWidth = Math.floor(mapionDivWidth / 100 * clientWidth);
	}
	
	var mapionMapWidth = mapionDivWidth - 280 - mapionGlobals.constant.MENU_LENGTH;
	
	document.getElementById("cmjMap").style.width = mapionMapWidth + "px";
	document.getElementById("cmjTable1").style.width = mapionMapWidth + "px";
	document.getElementById("cmjMmap").style.width = mapionMapWidth + "px";

	
	
	var mapionMenuLeft = mapionDivWidth - 280;
	document.getElementById("cmjMenu").style.left = mapionMenuLeft + "px";

	document.getElementById("cmjMap").style.height = mapionDivHeight + safariPlus + "px";
	document.getElementById("cmjTable1").style.height = mapionDivHeight + "px";
	document.getElementById("cmjMenu").style.height = (mapionFuncs.net.browser.IE ? mapionDivHeight + 1 : mapionDivHeight) + safariPlus + "px";
	document.getElementById("cmjMmap").style.height = mapionDivHeight - 30 + "px";

};


/******************
 * 地図を表示する *
 ******************/
mapionGlobals.showMap = function() {

	var nl = mapionGlobals.params.nl;
	var el = mapionGlobals.params.el;
	var scl = mapionGlobals.params.scl;

	// 地図表示
	var map = mapionGlobals.map = new MMap(document.getElementById("cmjMmap"));
		
	map.autoScroll = true;
	
	//中心のセンターマーク(＋)を消す
	map.centerMarkHide();
	
	// コントローラー表示
	var cnt = new MSliderControlEX(true, false);
	map.addControl(cnt);
	
	// 縮尺リスト全部入れておく
	cnt.setScaleList([5000, 10000, 25000, 70000, 250000, 500000, 1000000, 3000000, 5000000, 26000000]);

	// 初期地点＆ズームレベルの設定
	map.centerAndZoom(new MPoint(el, nl), scl);
	
	// 縮尺リスト更新
	cnt.setScaleListEX();
	
	// コピーライトの位置変更
	map.setCopyrightPosition(M_ANCHOR_BOTTOM_RIGHT);

	// イベント登録（click）
	MEvent.addListener(map, "click", function(arg1, arg2, arg3) {
		map.closeInfoWindow();
		//map.recenterOrPanToLatLng(arg2);
		//cnt.setScaleListEX();
	});
	
	// イベント登録（moveend）
	MEvent.addListener(map, "moveend", function(arg1, arg2, arg3) {
		
		mapionGlobals.moveEnd();
		mapionGlobals.callOutFunc();
	});
	
	MEvent.addListener(map, "zoom", function(arg1, arg2, arg3) {

		mapionGlobals.moveEnd();
		mapionGlobals.callOutFunc();

		// 吹き出しがちっちゃくなって中身なくなるので再度作る
		if (mapionGlobals.recommend.openPoiId) {

			var poiDetail = mapionGlobals.recommend.poiDetail[mapionGlobals.recommend.openPoiId];
			var nl = poiDetail.latitude;
			var el = poiDetail.longitude;
			if (mapionGlobals.map.isIn(el, nl)) { // 表示している地図上にアイコンある場合
				var id = mapionGlobals.recommend.openPoiId;
					mapionGlobals.recommend.markerInit(mapionGlobals.recommend.poiToMarker[id], id);
			} else { // 表示している地図上にアイコンない場合
				mapionGlobals.map.closeInfoWindow();
			}
		}
	});
	
	MEvent.addListener(map, "infowindowclose", function(arg1, arg2, arg3) {
		mapionGlobals.recommend.openedPoiList = [];
		mapionGlobals.recommend.currentPoi = {};
		mapionGlobals.recommend.kuchikomiMap = {};
		//mapionGlobals.recommend.nameMelters = [];
		//mapionGlobals.recommend.telMelters = [];
	});
};

/****************
 * 外の関数呼ぶ *
 ****************/
mapionGlobals.callOutFunc = function() {

	var map = mapionGlobals.map;
	
	// 緯度経度
	var centerLatLng = map.getCenterLatLng();
	
	// 縮尺
	var scl = map.getZoomLevel();
	
	// 四隅
	var boundsLatLng = map.getBoundsLatLng();
	
	if ((typeof receive_ui_event) != 'undefined') {
		receive_ui_event(centerLatLng.y, centerLatLng.x, boundsLatLng.minY, boundsLatLng.minX, boundsLatLng.maxY, boundsLatLng.maxX, scl);
	}
};

/**************************
 * 地図が変化した時の動作 *
 **************************/
mapionGlobals.moveEnd = function() {

	var map = mapionGlobals.map;
	
	mapionGlobals.recommend.isDone = false;
	
	var ctr = null;
	for (var p in map.controls) {
		if (!map.controls.hasOwnProperty(p)) {
			continue;
		}
		ctr = map.controls[p];
	}
	ctr.setScaleListEX();

	// そこどこ
	mapionGlobals.sokodoko.request();

	// 自動検索offの場合
	if (!mapionGlobals.doResearch) {
		return;
	}

	// 検索しない縮尺の場合
	if (map.getZoomLevel() < mapionGlobals.constant.RESEARCH_LEVEL_BORDER) {

		// 全て消す
		map.clearOverlays();
		map.closeInfoWindow();
		
		// 検索結果htmlクリア
		document.getElementById("cmjResultList").innerHTML = "";
		
		return;
	}

	var type = mapionGlobals.searchType;
	//console.log(type);
	if (type == "onlyOne") {
	
		mapionGlobals.recommend.request(null, null, "onlyOne");
		// 店舗IDパラメータがあったら吹き出しを出す
		if (!mapionGlobals.params.shop_id == ""||!mapionGlobals.params.shop_id == null) {
			mapionGlobals.loops.openInfoWindow(mapionGlobals.params.shop_id);
		}
	} else if (type == "selectGenre") {
		//console.log(mapionGlobals.currentGenre);
		//var secondType = type.split("/")[1];
		
		var currentGenreSplit = mapionGlobals.currentGenre.split("/");

		if (currentGenreSplit[0] == "") {
			// 前のアクションがキーワード検索だった場合
			mapionGlobals.keyword.movedRequest("mapionGlobals.selectGenre.click");
		//} else if (secondType == "searchGenre") {
		} else {
			var ph = mapionGlobals.selectGenre.ph;
			ph.replace("start", "1");
			mapionGlobals.selectGenre.movedRequest("mapionGlobals.selectGenre.click");
		}
	
	} else if (type == "searchGenre") {
		var ph = mapionGlobals.selectGenre.ph;
		ph.replace("start", "1");
		mapionGlobals.selectGenre.movedRequest();
	} else {
	
		var ph = mapionGlobals[type].ph;
		ph.replace("start", "1");
		mapionGlobals[type].movedRequest();
	
	}

};

/***************************************************
 * 直前にリクエストしたurlを得る（ループス提供用） *
 ***************************************************/
mapionGlobals.getLastRequest = function() {

	return mapionGlobals.lastAPI.getRequestURI();
};


// init ========================================================================
// mapオブジェクト
mapionGlobals.map = null;

// パラメータ取得
mapionGlobals.params = mapionFuncs.net.getQuery();

if (!mapionGlobals.params.nl) {
	mapionGlobals.params.nl = mapionGlobals.constant.NL;
}
if (!mapionGlobals.params.el) {
	mapionGlobals.params.el = mapionGlobals.constant.EL;
}
if (!mapionGlobals.params.scl) {
	mapionGlobals.params.scl = mapionGlobals.constant.SCL;
}

// 地図+検索メニューの幅
mapionGlobals.mapionDivWidth = 0;

// 地図+検索メニューの高さ
mapionGlobals.mapionDivHeight = 0;

// 検索タイプ
mapionGlobals.searchType = "recommend";

// 再検索フラグ
mapionGlobals.doResearch = true;

// 検索中の業種情報
mapionGlobals.currentGenre = "";

// mapionGlobals.resultList.closeDetailで消したいマーカー一覧
mapionGlobals.deleteMarkersId = [];

// 直前に地図上にPOIを載せるAPIを格納しておく
mapionGlobals.lastAPI = null;

// domready ====================================================================
Event.domReady.add(function() {

	// divの幅と高さ取得
	mapionGlobals.mapionDivWidth = parseInt(document.getElementById("cmjDiv").style.width);
	mapionGlobals.mapionDivHeight = parseInt(document.getElementById("cmjDiv").style.height);

	// shop_idがあったら問答無用で全てのカテゴリにチェックを入れた状態にする	
	if (!mapionGlobals.params.shop_id == ""||!mapionGlobals.params.shop_id == null) {
	
		mapionFuncs.net.setCookie("cmj.recommend.categories", "OTHER,G004,G001,G002,G003", mapionGlobals.constant.EXPIRES);
	}
	
	// クッキー取得
	var cookies = mapionGlobals.getCookie();

	// htmlを挿入する
	mapionGlobals.insertHtml(cookies["cmj.recommend.number"], cookies["cmj.recommend.categories"].replace(/\|\|/g, ","));
	
	// 地図を表示する
	mapionGlobals.showMap();

	if (mapionGlobals.constant.RESEARCH_LEVEL_BORDER <= mapionGlobals.params.scl) {
		// デフォルト検索
		mapionGlobals.recommend.init(cookies["cmj.recommend.number"], cookies["cmj.recommend.categories"]);
	}
	
	// アコーディオンメニュー
	mapionGlobals.accordion.init();
	
	// よく検索されている業種
	mapionGlobals.often.init();
	
	// そこどこ
	mapionGlobals.sokodoko.init();
	
	// お気に入り設定
	mapionGlobals.bookmark.init();
	
	// 検索結果の高さ
	var plus = 12;
	if (mapionFuncs.net.browser.IE) {
		plus -= 2;
	}
	accordionByBytefx.heights.cmjResultList = 
		mapionGlobals.mapionDivHeight - (mapionGlobals.constant.MENU_HEADER_HEIGHT * mapionGlobals.constant.MENU_LENGTH + (mapionGlobals.constant.MENU_LENGTH - 1)) - plus;
	
	// 店舗IDパラメータがあったら吹き出しを出す
	if (mapionGlobals.constant.RESEARCH_LEVEL_BORDER <= mapionGlobals.params.scl) {
		if (!mapionGlobals.params.shop_id == "" || !mapionGlobals.params.shop_id == null) {
			mapionGlobals.loops.openInfoWindow(mapionGlobals.params.shop_id);
		}
	}

	// windowリサイズ時のイベント登録
	mapionFuncs.event.addEvent(window, "resize", function() {
	
		var map = mapionGlobals.map;
		mapionGlobals.setSize();
		map.setMapBox();
		map.refreshMapAll();
		
		// 吹き出しがちっちゃくなって中身なくなるので再度作る
		if (mapionGlobals.recommend.openPoiId) {
			var id = mapionGlobals.recommend.openPoiId;
			mapionGlobals.recommend.markerInit(mapionGlobals.recommend.poiToMarker[id], id);
		}
	});
	
});

