<!--
//最近チェックした物件取得
function GetChkCookie(){

	//変数宣言
	var tmp = "";

	//クッキー値取得
	tmp = GetCookieValue('homemate_check');

	return tmp;
}

//最近チェックした物件保存
function SetChkCookie(bn,imgpath){

	//変数宣言
	var tmp = "";
	var intChk;
	var cke = "";
	var cnt = 0;
	var imgcnt = 0;

	//クッキー値取得
	tmp = GetChkCookie();

	//クッキー値編集
	bn = encodeURI(escape(bn));

	intChk = tmp.indexOf(bn);
	if(intChk != -1){
		//登録済み→最後尾へ移動
		cke = tmp.split("**");
		tmp = '';
		for(var i=0; i<cke.length; i++){
			intChk = cke[i].indexOf(bn);
			if(intChk == -1){
				if(tmp != ''){
					tmp = tmp + '**';
				}
				tmp = tmp + cke[i];
			}
		}
		if(tmp != ""){
			bn = tmp + '**' + bn;
		}

		//画像パスの追加
		if(imgpath != ''){
			bn = bn + '@@' + imgpath;
		}
	}else if(tmp != ";"){
		//未登録→最後尾へ追加
		cke = tmp.split("**");
		cnt = cke.length;
		//20件数以上か否か
		if(20<=cnt){
			tmp = '';
			for(var i=1; i<cnt; i++){
				if(i != 1){
					tmp = tmp + '**';
				}
				tmp = tmp + cke[i];
			}
		}
		if(tmp != ''){
			bn = tmp + '**' + bn;
		}

		//画像パスの追加
		if(imgpath != ''){
			bn = bn + '@@' + imgpath;
		}
	}

	//古い画像パスの削除
	imgcnt = 2;
	cke = bn.split("@@");
	cnt = cke.length - 1;
	if(cnt > 2){
		cke = bn.split("**");
		for(var i=0; i<cke.length; i++){
			intChk = cke[i].indexOf('@@');
			if(intChk != -1 && cnt > imgcnt){
				bn = bn.replace(cke[i] , cke[i].substring(0,intChk));
				imgcnt = imgcnt + 1;
			}
			if(cnt <= imgcnt){
				break;
			}
		}
	}

	//クッキー書き込み
	return SetCookieValue("homemate_check", bn, 90);
}

//最近チェックした物件表示
function GetDispChk(kbn){

	//変数宣言
	var tmp = "";
	var cke = "";
	var pos = 0;
	var strhtml = "";
	var cnt = 0;
	var img1 = "";
	var img2 = "";
	var bn1 = "";
	var bn2 = "";

	//クッキー値取得
	tmp = GetChkCookie()

	//ビジター
	if(tmp == '' && kbn == '1')
	{
		document.getElementById('fav_check').innerHTML = '（0件）';
		document.getElementById('dd_chk_bukken').innerHTML = 'チェックした物件はありません。';
		return;
	}

	//件数取得
	if(tmp != ';' && tmp != ''){
		cke = tmp.split("**");
		cnt = cke.length;
	}

	//画像パス取得
	for(i=0;i<cnt;i++){
		pos = cke[i].indexOf("@@");
		if(pos != -1){
			//1つ目の画像
			if(img1 == ""){
				//bn1 = cke[i].substring(0,pos);
				//img1 = cke[i].replace(cke[i].substring(0,pos+2), "");
				bn1 = escape(unescape(decodeURI(cke[i].substring(0,pos))));
				img1 = unescape(decodeURI(cke[i].replace(cke[i].substring(0,pos+2), "")));
			//2つ目の画像
			}else if(img2 == ""){
				//bn2 = cke[i].substring(0,pos);
				//img2 = cke[i].replace(cke[i].substring(0,pos+2), "");
				bn2 = escape(unescape(decodeURI(cke[i].substring(0,pos))));
				img2 = unescape(decodeURI(cke[i].replace(cke[i].substring(0,pos+2), "")));
			}
		}
	}

	//HTML出力
	//TOPページ
	if(kbn == '1')
	{
		if(cnt != 0){
			//件数部
			document.getElementById('fav_check').innerHTML = '（<a href="/rent/recentsrch.asp">' + cnt + '件</a>）';

			if(navigator.userAgent.toLowerCase().indexOf("safari") != -1)
			{
				//Safariの場合
				if(img1 != ''){
					strhtml  = '<div class="def">';
					strhtml += '<p class="bukken_photo"><a href="/rent/dtl.asp?bn='+unescape(bn1)+'"><img src="'+img1+'?w=80&h=60" alt="外観写真" id="pct1" onError="DispDefImg(this);" /></a></p>'
					strhtml += '</div>';
				}
				if(img2 != ''){
					strhtml += '<div class="def">';
					strhtml += '<p class="bukken_photo"><a href="/rent/dtl.asp?bn='+unescape(bn2)+'"><img src="'+img2+'?w=80&h=60" alt="外観写真" id="pct2" onError="DispDefImg(this);" /></a></p>'
					strhtml += '</div>';
				}
			}
			else
			{
				if(img1 != ''){
					strhtml  = '<div class="def">';
					strhtml += '<p class="bukken_photo"><a href="/rent/dtl.asp?bn='+bn1+'"><img src="'+img1+'?w=80&h=60" alt="外観写真" id="pct1" onError="DispDefImg(this);" /></a></p>'
					strhtml += '</div>';
				}
				if(img2 != ''){
					strhtml += '<div class="def">';
					strhtml += '<p class="bukken_photo"><a href="/rent/dtl.asp?bn='+bn2+'"><img src="'+img2+'?w=80&h=60" alt="外観写真" id="pct2" onError="DispDefImg(this);" /></a></p>'
					strhtml += '</div>';
				}
			}

			document.getElementById('dd_chk_bukken').innerHTML = strhtml;
		}
	}
	//お気に入り一覧
	else if(kbn == '2')
	{
		if(cnt != 0){
			//タイトル部
			document.getElementById('fav_check').innerHTML = '<a href="/rent/recentsrch.asp">最近チェックした物件</a>';

			if(navigator.userAgent.toLowerCase().indexOf("safari") != -1)
			{
				//Safariの場合
				strhtml  = '<ul>';
				if(img1 != ''){
					strhtml += '<li><a href="/rent/dtl.asp?bn='+unescape(bn1)+'"><img src="'+img1+'?w=73&h=54" alt="最近チェックした物件1" onError="DispDefImg(this);" /></a></li>'
				}
				if(img2 != ''){
					strhtml += '<li class="checklist_right"><a href="/rent/dtl.asp?bn='+unescape(bn2)+'"><img src="'+img2+'?w=73&h=54" alt="最近チェックした物件2" onError="DispDefImg(this);" /></a></li>'
				}
				strhtml += '</ul>'
				strhtml += '<p><span class="check_lately"><a href="/rent/recentsrch.asp">最近の'+cnt+'件</a></span></p>'
			}
			else
			{
				strhtml  = '<ul>';
				if(img1 != ''){
					strhtml += '<li><a href="/rent/dtl.asp?bn='+bn1+'"><img src="'+img1+'?w=73&h=54" alt="最近チェックした物件1" onError="DispDefImg(this);" /></a></li>'
				}
				if(img2 != ''){
					strhtml += '<li class="checklist_right"><a href="/rent/dtl.asp?bn='+bn2+'"><img src="'+img2+'?w=73&h=54" alt="最近チェックした物件2" onError="DispDefImg(this);" /></a></li>'
				}
				strhtml += '</ul>'
				strhtml += '<p><span class="check_lately"><a href="/rent/recentsrch.asp">最近の'+cnt+'件</a></span></p>'
			}
			document.getElementById('dd_chk_bukken').innerHTML = strhtml;
		}
	}
}

//最近チェックした物件デフォルト画像表示
function DispDefImg(obj){

	//obj.src='/rent/image/top_img_checknot.jpg?w=73&h=54';
	obj.src='/rent/image/top_img_checknot.jpg?w=80&h=60';

}

//**************************************************
//物件詳細
//**************************************************
//最近ﾁｪｯｸした物件取得
function GetRecentBkn() {

	var tmp = "";
	var cke = "";
	var cnt = "";
	var bn = "";
	var pos = "";
	var link = "";

	//クッキー値取得
	tmp = GetChkCookie()

	//件数取得
	if(tmp != ';' && tmp != ''){
		cke = tmp.split("**");
		cnt = cke.length;
	}

	//物件NO取得
	for(i=0; i<cnt; i++){
		if(cnt-i <= 3)
		{
			if(bn != "")
			{
				bn = bn + ",";
			}

			pos = cke[i].indexOf("@@");
			if(pos != -1){
				bn = bn + cke[i].substring(0,pos);
			}
			else
			{
				bn = bn + cke[i];
			}
		}
	}

	//最近チェックした物件数リンク
	link = '<img src="/rent/image/top_mrk_linkarrow.gif" width="7" height="7" alt="最近チェックした物件はこちら" />'
	link = link + '<a href="/rent/recentsrch.asp">最近の' + cnt + '件</a>'

	var param = 'bn=' + bn;

	//Ajaxで表示用物件データ取得
	var ajx = new Ajax.Request(
		'/rent/ajax/getRecentBkn.asp',
		{
			method: 'post',
			parameters: param,
			onComplete: function (orgReq){
				var list = orgReq.responseText;
				document.getElementById("recent_bkn").innerHTML = decodeURI(list);
				document.getElementById("recent_kensu").innerHTML = link;
			}
		}
	);

}

//-->
