﻿/*********************************************************************
* 内容      ：Cookie内容を削除
* 引数      ：なし
* 戻り値    ：false
*********************************************************************/
function DelWishList() {
	// WishList内容を取得
	var wishList = getWishList();

	// 画面のホテルコードを取得
	var Gv_List = document.getElementById("ctl00_ContentPlaceHolder1_OkiniiriHotelArea_Gv_List");
	var selFlg = false;
	var delRow = "";
	var MaxList = 20;

	if (Gv_List != null) {

		var itemIdx = 0;
		var n = 2;

		while (n < MaxList + 2) {
			var elementId = "";
			if (n < 10) {
				elementId = "ctl00_ContentPlaceHolder1_OkiniiriHotelArea_Gv_List_ctl0" + n.toString() + "_";
			}
			else {
				elementId = "ctl00_ContentPlaceHolder1_OkiniiriHotelArea_Gv_List_ctl" + n.toString() + "_";
			}

			var radio = document.getElementById(elementId + "Cbx_HotelCode");
			if (radio != null && radio.checked) {
				selFlg = true;
				var hotelCd = document.getElementById(elementId + "HOTEL_CD").value;
				for (var j = 0; j < wishList.length; j++) {

					if (wishList[j] == hotelCd) {
						wishList.splice(j, 1);
						delRow = delRow + itemIdx.toString() + ",";
						break;
					}
				}
			}
			if (radio != null) {
				itemIdx++;
			}
			n++;
		}

		// 選択行を削除
		var delList = delRow.split(",");
		if (delList.length > 1) {
			for (var i = delList.length - 2; i >= 0; i--) {
				Gv_List.deleteRow(delList[i] * 3);
				Gv_List.deleteRow(delList[i] * 3);
				Gv_List.deleteRow(delList[i] * 3);
			}
		}

		// お気に入りリストがない場合は削除ボタンを非表示とする
		if (Gv_List.rows.length == 0) {
			var Ibt_Checkdel = document.getElementById("ctl00_ContentPlaceHolder1_OkiniiriHotelArea_Ibt_Checkdel");
			Ibt_Checkdel.style.display = "none";
			Gv_List.style.display = "none";
		}
	}

	// 選択が０行の場合
	if (selFlg == false) {
		ShowMessage("1", "E-F10100-021");
		return false;
	}

	var expire = new Date();
	expire.setTime(expire.getTime() + 1000 * 60 * 60 * 24 * 30);
	var setValue;
	setValue = "WishList" + "=" + escape(wishList.join(",")) + ";";
	setValue += " expires=" + expire.toGMTString() + ";";
	setValue += " path=" + "/;";
	document.cookie = setValue;

	return false;
}

/*********************************************************************
* 内容      ：WishList内容を取得
* 引数      ：なし
* 戻り値    ：Array
*********************************************************************/
function getWishList() {

    var wishListStr = getCookie("WishList");
    if (wishListStr) {
        return wishListStr.split(",");
    } else {
        return new Array();
    }
}

/*********************************************************************
* 内容      ：Cookie内容を取得
* 引数      ：なし
* 戻り値    ：Array
*********************************************************************/
function getCookie(key) {

	theData = "";
	theKey = key + "=";
	theCookie = document.cookie + ";";
	start = theCookie.indexOf(theKey);

	if (start != -1) {
		end = theCookie.indexOf(";", start);
		theData = unescape(theCookie.substring(start + theKey.length, end));
		return theData;
	}
    return ("");
}
resizeImage(".Hotel_Fav_Img", 50, 35);
