var Valuesid = '2156863';
var Valuepid = '874958766';
// infoWindow中のdiv幅
var infoWindowWidth = '530';
// SPOT画像ファイルの幅
var spotImageWidth = '170';
// Hot Pepper のリンク内テキスト
var hpLinkText = 'お店の詳細とお得なクーポン';
// SPOT のリンク内テキスト
var spotLinkText = 'この情報の詳細ページへ進む';
// 右リストの内容
var list_category_flag = true;
var list_name_flag = true;
var list_address_flag = true;
var list_hours_flag = true;
var list_holiday_flag = true;
//var list_info_flag = true;
var list_excerption_flag = false;

var checkStation_flag = false;
var checkStationArray = new Array();

var getZoom, getTxt;

// HotPepper API ver 1.1 対応
function moveMapHP3(place_category,place_name,place_zoom,place_address,place_address3,place_lat,place_lon,place_access,place_hours,place_holiday,place_description,place_url,place_img,imgwidth,imgheight) {
	var txt = createHPInfoWindowHtmlTxt(place_category,place_name,place_address,place_access,place_hours,place_holiday,place_description,place_url,place_img,imgwidth,imgheight);
	var lat = place_lat;
	var lon = place_lon;
	var zoom = place_zoom;
	var point = new GLatLng(lat,lon);
	map.closeInfoWindow();
	map.setZoom(zoom);
	//map.panTo(point);
	map.openInfoWindowHtml(point,txt);
}
// HotPepper API ver 1.1 対応
function moveMapSPOT(place_id,place_name,place_address,place_lat,place_lon,place_genre,place_catch,place_description,place_url,place_img,imgwidth,imgheight,place_open,place_close) {
	var txt = createSPOTInfoWindowHtmlTxt(place_name,place_address,place_genre,place_catch,place_description,place_url,place_img,imgwidth,imgheight,place_open,place_close);
	var lat = place_lat;
	var lon = place_lon;
	var zoom = zoomDef;
	var point = new GLatLng(lat,lon);
	map.closeInfoWindow();
	map.setZoom(zoom);
	//map.panTo(point);
	map.openInfoWindowHtml(point,txt);
	//１秒後に実行するには？
	//timerID = setTimeout("map.openInfoWindowHtml(point,txt)",1000);
}

function createMarkerSpot(place_id,place_name,place_address,place_lat,place_lon,place_genre,place_catch,place_description,place_url,place_img,imgwidth,imgheight,place_open,place_close) {
	var txt = createSPOTInfoWindowHtmlTxt(place_name,place_address,place_genre,place_catch,place_description,place_url,place_img,imgwidth,imgheight,place_open,place_close);
	var point = new GLatLng(place_lat,place_lon);
	var iconR = new GIcon();
	iconR.image = "/gmap_img/osusumeIcon.png";
	iconR.shadow = "/gmap_img/osusumeIconShadow.png";
	iconR.iconSize = new GSize(67,37);
	iconR.shadowSize = new GSize(67,37);
	iconR.iconAnchor = new GPoint(27,37);
	iconR.infoWindowAnchor = new GPoint(27,37);
	iconR.transparent = "/gmap_img/osusumeIcon.png";
	var marker = new GMarker(point, iconR);
	map.addOverlay(marker);
	GEvent.addListener(marker, "click", function() {
		//alert(txt);
		//document.getElementById("test").innerHTML = '<blockquote><p>'+txt+'</p></blockquote>';
		marker.openInfoWindowHtml(txt);
	});
}

function createSPOTInfoWindowHtmlTxt(place_name,place_address,place_genre,place_catch,place_description,place_url,place_img,imgwidth,imgheight,place_open,place_close) {
	var txt = '<div style="margin: 0px; padding: 0px; width:' +infoWindowWidth+ 'px; line-height: 140%;">';
	//alert('imgwidth = '+imgwidth+'/imgheight = '+imgheight);
	//画像サイズ計算。画像の幅サイズがvar spotImageWidthより大の場合に、画像の高さをもとめる
	if(imgwidth > spotImageWidth) {
		var ratio = spotImageWidth / imgwidth;
		var thisImgHeight = parseInt(ratio * imgheight);
		var thisImgWidth = parseInt(spotImageWidth);
		var divHeight = thisImgHeight + 5;
		var divWidth = thisImgWidth + 5;
	} else {
		var thisImgHeight = parseInt(imgheight);
		var thisImgWidth = parseInt(spotImageWidth);
		var divHeight = thisImgHeight + 5;
		var divWidth = thisImgWidth + 5;
	}
	//alert('divWidth = '+divWidth+'/divHeight = '+divHeight);
	txt += '<div style="float: left; width:' +divWidth+ 'px; height:' +divHeight+ 'px; margin: 0px 0px 0px 0px; padding: 0px;"><img src="' +place_img+ '" width="'+thisImgWidth+'" height="'+thisImgHeight+'" style = "border: solid 1px #888; margin-bottom: 3px;" alt="' +place_name+ '" /></div>';
	txt += '<div style="float: right; width:330px; margin: 5px 0px 0px 0px; padding: 0px;">';
	txt += '<div style="margin: 0px 0px 5px 0px;"><span style="font-size:x-small;">' + place_genre + '</span>&nbsp;&nbsp;<strong>' + place_name +'</strong></div><p class="tensen2"></p>';
	txt += '<div style="margin: 5px 0px 0px 0px; font-size:small; font-weight: bold; color:#000;">' + place_catch + '</div><p class="tensen2"></p>';
	txt += '<div style="margin: 5px 0px 0px 0px;  font-size:x-small; color:#000;">' + place_description + '</div><p class="tensen2"></p>';
	if(place_open != "null") {
		txt += '<div style="margin: 5px 0px 0px 0px;  font-size:x-small; color:#000;">営業時間: ' + place_open + '</div><p class="tensen2"></p>';
	}
	if(place_close != "null") {
		txt += '<div style="margin: 5px 0px 0px 0px;  font-size:x-small; color:#000;">休業日: ' + place_close + '</div><p class="tensen2"></p>';
	}
	txt += '<div style="margin: 5px 0px 0px 0px; 0px; padding: 0px; font-size:x-small; color:#333; font-weight: bold; line-height: 130%;">→ <a href="' + place_url + '" target="_self" onMouseover="ss(\'' + place_url + '\'); return true;" onFocus="ss(\'' + place_url + '\'); return true;" onMouseout="cs(); return true;">' + spotLinkText +'</a></div></div></div>';
	return txt;
}

function createHPMarker2(place_category,place_name,place_zoom,place_address,place_address2,place_lat,place_lon,place_access,place_hours,place_holiday,place_description,place_url,place_img,imgwidth,imgheight) {
	var txt = createHPInfoWindowHtmlTxt2(place_category,place_name,place_address,place_access,place_hours,place_holiday,place_description,place_url,place_img,imgwidth,imgheight);
	var point = new GLatLng(place_lat,place_lon);
	var iconH = new GIcon();
	iconH.image = "/img/hotIcon.png";
	iconH.shadow = "/img/hotIconShadow.png";
	iconH.iconSize = new GSize(45,38);
	iconH.shadowSize = new GSize(45,38);
	iconH.iconAnchor = new GPoint(14,37);
	iconH.infoWindowAnchor = new GPoint(10,10);
	iconH.transparent = "/img/hotIcon.png";
	var marker = new GMarker(point, iconH);
	map.addOverlay(marker);
	GEvent.addListener(marker, "click", function() {
		//alert(txt);
		//document.getElementById("test").innerHTML = '<blockquote><p>'+txt+'</p></blockquote>';
		marker.openInfoWindowHtml(txt);
	});
}
function createHPInfoWindowHtmlTxt2(place_category,place_name,place_address,place_access,place_hours,place_holiday,place_description,place_url,place_img,imgwidth,imgheight) {
	//アフィリエイトURL作成
	//:→%3a　/→%2f　.→%2e　?→%3F　&→%26　=→%3D　に変換する
	place_urlSTRING2 = place_url.replace(":", "%3a");
	place_urlSTRING3 = place_urlSTRING2.replace("/", "%2f");
	place_urlSTRING4 = place_urlSTRING3.replace(".", "%2e");
	place_urlSTRING5 = place_urlSTRING4.replace("?", "%3F");
	place_urlSTRING6 = place_urlSTRING5.replace("&", "%26");
	place_urlSTRING7 = place_urlSTRING6.replace("=", "%3D");

	var txt = '<div style="margin: 0px; padding: 0px; width:' +infoWindowWidth+ 'px; line-height: 140%;">';
	var divWidth = parseInt(imgwidth) + 5;
	var divHeight = parseInt(imgheight) + 20;
	//alert('divWidth = '+divWidth+'/divHeight = '+divHeight);
	txt += '<div style="float: left; width:' +divWidth+ 'px; height:' +divHeight+ 'px; margin: 0px 0px 0px 0px; padding: 0px;"><img style = "border: solid 1px #888;" alt="' +place_name+ '" src="' +place_img+ '" width="' +imgwidth+ '" height="' +imgheight+ '" style="margin-bottom: 3px;" /><div style="width: 170px; margin-top: 5px; font-size: x-small; line-height: 150%;">写真提供：ホットペッパー.jp</div></div>';
	txt += '<div style="float: right; width:290px; margin: 5px 0px 0px 0px; padding: 0px;">';
	txt += '<div style="margin: 0px 0px 5px 0px;"><span style="font-size:x-small;">【ジャンル：' + place_category + '】</span>&nbsp;&nbsp;<strong><a Href="http://ck.jp.ap.valuecommerce.com/servlet/referral?sid='+Valuesid+'&pid='+Valuepid+'&vc_url=' + place_urlSTRING7 + '" target="_blank" onMouseover="ss(\'' + place_url + '\'); return true;" onFocus="ss(\'' + place_url + '\'); return true;" onMouseout="cs(); return true;"><img Src="http://ad.jp.ap.valuecommerce.com/servlet/gifbanner?sid='+Valuesid+'&pid='+Valuepid+'" height="1" width="1" Border="0">' + place_name +'</a></strong></div><p class="tensen2"></p>';
	txt += '<div style="margin: 5px 0px 0px 0px; font-size:small; font-weight: bold; color:#000;">' + place_description + '</div><p class="tensen2"></p>';
	txt += '<div style="margin: 5px 0px 0px 0px;  font-size:x-small; color:#000;">所在地: ' + place_address + '</div><p class="tensen2"></p>';
	txt += '<div style="margin: 5px 0px 0px 0px;  font-size:x-small; color:#000;">アクセス: ' + place_access + '</div><p class="tensen2"></p>';
	txt += '<div style="margin: 5px 0px 0px 0px;  font-size:x-small; color:#000;">営業時間: ' + place_hours + '</div><p class="tensen2"></p>';
	txt += '<div style="margin: 5px 0px 0px 0px;  font-size:x-small; color:#000;">休業日: ' + place_holiday + '</div><p class="tensen2"></p>';
	txt += '<div style="margin: 5px 0px 0px 0px; 0px; padding: 0px; font-size:x-small; color:#333; font-weight: bold; line-height: 130%;">→ <a Href="http://ck.jp.ap.valuecommerce.com/servlet/referral?sid='+Valuesid+'&pid='+Valuepid+'&vc_url=' + place_urlSTRING7 + '" target="_blank" onMouseover="ss(\'' + place_url + '\'); return true;" onFocus="ss(\'' + place_url + '\'); return true;" onMouseout="cs(); return true;"><img Src="http://ad.jp.ap.valuecommerce.com/servlet/gifbanner?sid='+Valuesid+'&pid='+Valuepid+'" height="1" width="1" Border="0">' + hpLinkText +'</a></div></div></div>';
	return txt;
}

function createHPMarker(HotelID,HotelName,HotelAddress,HotelType,HotelDetailURL,HotelCatchCopy,HotelCaption,PictureURL,imgwidth,imgheight,PictureCaption,LastUpdate) {
	var txt = createHPInfoWindowHtmlTxt(HotelID,HotelName,HotelAddress,HotelType,HotelDetailURL,HotelCatchCopy,HotelCaption,PictureURL,imgwidth,imgheight,PictureCaption,LastUpdate);
	var geocoder = new GClientGeocoder();
	geocoder.getLatLng(HotelAddress, function(point) {
		if (point) {
			var iconH = new GIcon();
			iconH.image = "/img/hotelIcon.png";
			iconH.shadow = "/img/hotIconShadow.png";
			iconH.iconSize = new GSize(45,38);
			iconH.shadowSize = new GSize(45,38);
			iconH.iconAnchor = new GPoint(14,37);
			iconH.infoWindowAnchor = new GPoint(10,10);
			iconH.transparent = "/img/hotelIcon.png";
			var marker = new GMarker(point, iconH);
			map.addOverlay(marker);
			GEvent.addListener(marker, "click", function() {
				marker.openInfoWindowHtml(txt);
			});
		}
	});
}

function createHPInfoWindowHtmlTxt(place_category,place_name,place_address,place_access,place_hours,place_holiday,place_description,place_url,place_img,imgwidth,imgheight) {
	//アフィリエイトURL作成
	//:→%3a　/→%2f　.→%2e　?→%3F　&→%26　=→%3D　に変換する
	place_urlSTRING2 = place_url.replace(":", "%3a");
	place_urlSTRING3 = place_urlSTRING2.replace("/", "%2f");
	place_urlSTRING4 = place_urlSTRING3.replace(".", "%2e");
	place_urlSTRING5 = place_urlSTRING4.replace("?", "%3F");
	place_urlSTRING6 = place_urlSTRING5.replace("&", "%26");
	place_urlSTRING7 = place_urlSTRING6.replace("=", "%3D");

	var txt = '<div style="margin: 0px; padding: 0px; width:' +infoWindowWidth+ 'px; line-height: 140%;">';
	var divWidth = parseInt(imgwidth) + 5;
	var divHeight = parseInt(imgheight) + 20;
	//alert('divWidth = '+divWidth+'/divHeight = '+divHeight);
	txt += '<div style="float: left; width:' +divWidth+ 'px; height:' +divHeight+ 'px; margin: 0px 0px 0px 0px; padding: 0px;"><img style = "border: solid 1px #888;" alt="' +place_name+ '" src="' +place_img+ '" width="' +imgwidth+ '" height="' +imgheight+ '" style="margin-bottom: 3px;" /><div style="width: 170px; margin-top: 5px; font-size: x-small; line-height: 150%;">写真提供：ホットペッパー.jp</div></div>';
	txt += '<div style="float: right; width:340px; margin: 5px 0px 0px 0px; padding: 0px;">';
	txt += '<div style="margin: 0px 0px 5px 0px;"><span style="font-size:x-small;">【ジャンル：' + place_category + '】</span>&nbsp;&nbsp;<strong><a Href="http://ck.jp.ap.valuecommerce.com/servlet/referral?sid='+Valuesid+'&pid='+Valuepid+'&vc_url=' + place_urlSTRING7 + '" target="_blank" onMouseover="ss(\'' + place_url + '\'); return true;" onFocus="ss(\'' + place_url + '\'); return true;" onMouseout="cs(); return true;"><img Src="http://ad.jp.ap.valuecommerce.com/servlet/gifbanner?sid='+Valuesid+'&pid='+Valuepid+'" height="1" width="1" Border="0">' + place_name +'</a></strong></div><p class="tensen2"></p>';
	txt += '<div style="margin: 5px 0px 0px 0px; font-size:small; font-weight: bold; color:#000;">' + place_description + '</div><p class="tensen2"></p>';
	txt += '<div style="margin: 5px 0px 0px 0px;  font-size:x-small; color:#000;">所在地: ' + place_address + '</div><p class="tensen2"></p>';
	txt += '<div style="margin: 5px 0px 0px 0px;  font-size:x-small; color:#000;">アクセス: ' + place_access + '</div><p class="tensen2"></p>';
	txt += '<div style="margin: 5px 0px 0px 0px;  font-size:x-small; color:#000;">営業時間: ' + place_hours + '</div><p class="tensen2"></p>';
	txt += '<div style="margin: 5px 0px 0px 0px;  font-size:x-small; color:#000;">休業日: ' + place_holiday + '</div><p class="tensen2"></p>';
	txt += '<div style="margin: 5px 0px 0px 0px; 0px; padding: 0px; font-size:x-small; color:#333; font-weight: bold; line-height: 130%;">→ <a Href="http://ck.jp.ap.valuecommerce.com/servlet/referral?sid='+Valuesid+'&pid='+Valuepid+'&vc_url=' + place_urlSTRING7 + '" target="_blank" onMouseover="ss(\'' + place_url + '\'); return true;" onFocus="ss(\'' + place_url + '\'); return true;" onMouseout="cs(); return true;"><img Src="http://ad.jp.ap.valuecommerce.com/servlet/gifbanner?sid='+Valuesid+'&pid='+Valuepid+'" height="1" width="1" Border="0">' + hpLinkText +'</a></div></div></div>';
	return txt;
}

//ステータスバー関連の処理
var ignoreWord = 'valuecommerce';
function ss(w) {
	window.status = w;
	return true;
}
function cs(){
	window.status = '';
}
function changeAnchorText(){
	var anchor = document.getElementsByTagName('a');
	var anchorLen = anchor.length;
	for(var i=0;i<anchorLen;i++){
		var temp = anchor[i].href;
		//含まれていなければ
		if (temp.indexOf(ignoreWord, 0) != -1){
			//alert(temp);
			var anchors = temp.split('vc_url=');
			place_urlSTRING = anchors[1];
			//:→%3a　/→%2f　.→%2e　?→%3F　&→%26　=→%3D　を逆に変換する
			place_urlSTRING2 = place_urlSTRING.replace(/%3a/g, ":");
			place_urlSTRING3 = place_urlSTRING2.replace(/%2f/g, "/");
			place_urlSTRING4 = place_urlSTRING3.replace(/%2e/g, ".");
			place_urlSTRING5 = place_urlSTRING4.replace(/%3F/g, "?");
			place_urlSTRING6 = place_urlSTRING5.replace(/%26/g, "&");
			place_urlSTRING7 = place_urlSTRING6.replace(/%3D/g, "=");
			var focusFunc = "ss('" + place_urlSTRING7 + "'); return true;";
			var overFunc = "return ss('" + place_urlSTRING7 + "'); return true;";
			var outFunc = "cs(); return true;";
			if (document.all){
				anchor[i].setAttribute('onfocus', new Function(focusFunc));
				anchor[i].setAttribute('onmouseover', new Function(overFunc));
				anchor[i].setAttribute('onmouseout', new Function(outFunc));
			} else {
				anchor[i].setAttribute('onfocus', focusFunc);
				anchor[i].setAttribute('onmouseover', overFunc);
				anchor[i].setAttribute('onmouseout', outFunc);
			}
		}
	}
}