// Loginなしポップアップ呼び出し
function explainWindowOpen(section) {

	var url = '/info/mystyle.php';
	var url2 = '';
	var strTmpVal = '';
	var InfoPath = 'login';

	if (section == 1){ 

		window.open(url,null,'width=700,height=850,directories=0,location=0 menubar=0,toolbar=0,resizable=1,scrollbars=1,left=0,top=0');

	}else{

		url2 = url + '?param=' + InfoPath;
	    window.open(url2,null,'width=700,height=850,directories=0,location=0,scrollbars=1,menubar=0,toolbar=0,resizable=1,left=0,top=0');
	}
}


// 物件比較へ送る
function search_compare() {

	var cnt=0;
	var InfoPath = '';

	for (i=0;i < document.getElementsByName('PropChk').length; i++) {
		if (document.getElementsByName('PropChk')[i].checked) {
			cnt++;
		}
	}

	if (cnt == 0) {
		alert("物件を選択してください");
		return ;
	}

	InfoPath += get_BuyPropertyID();

	document.compare.action = document.compare.action + InfoPath;
	document.compare.submit();

}

// 条件を保存
function search_kantan(section) {

	var strTmpVal = '';
	var InfoPath = '';
	var cnt = 0;
	var url = '/buy/M1120032/return';
	var url2 = '';
	var exp = new Date();

	InfoPath += get_Param(section);

	exp.setTime(exp.getTime()+1000*60*60*24*1);
        document.cookie = "kantan=1; path=/; expires=" + exp.toGMTString();


	url2 = url + InfoPath;
	window.open(url2,null,'width=700,height=500,directories=0,location=0,scrollbars=1,menubar=0,toolbar=0,resizable=1,left=0,top=0');
}

// 条件を保存
function kantan_register(section, intNo) {

	var strTmpVal = '';
	var InfoPath = '';
	var cnt = 0;

	InfoPath += '/target/' + intNo;
	InfoPath += get_Param(section);
	document.kantan.action = document.kantan.action + InfoPath;
	document.kantan.submit();

}
// お問い合わせ
function search_inquire() {
	var InfoPath = '';
	var cnt = 0;

	for (i=0;i < document.getElementsByName('PropChk').length; i++) {
		if (document.getElementsByName('PropChk')[i].checked) {
			cnt++;
		}
	}

	if (cnt == 0) {
		alert("物件を選択してください");
		return ;
	}

	InfoPath += get_Param(1);
	InfoPath += get_RentGroupID();
	document.inquire.action = document.inquire.action + InfoPath;
	document.inquire.submit();
}

// 物件詳細
function search_detail() {
	var InfoPath = '';
	var cnt = 0;

	for (i=0;i < document.getElementsByName('PropChk').length; i++) {
		if (document.getElementsByName('PropChk')[i].checked) {
			cnt++;
		}
	}

	if (cnt == 0) {
		alert("物件を選択してください");
		return ;
	}
	InfoPath += get_Param(1);
	InfoPath += get_RentGroupID();
	document.detail.action = document.detail.action + InfoPath;
	document.detail.submit();
}


// お気に入り追加
function search_favorite() {

	var strTmpVal = '';
	var InfoPath = '';
	var cnt = 0;
	var url = '/buy/M1120031/return';
	var url2 = '';
	var exp = new Date();

	for (i=0;i < document.getElementsByName('PropChk').length; i++) {
		if (document.getElementsByName('PropChk')[i].checked) {
			cnt++;
		}
	}

	if (cnt == 0) {
		alert("物件を選択してください");
		return ;
	}

	for (i=0;i < document.getElementsByName('PropChk').length; i++) {
		if (document.getElementsByName('PropChk')[i].checked) {
			strTmpVal += document.getElementsByName('PropId')[i].value + ','; 
		}
	}
	
	InfoPath += '/' + 'PropId/' + strTmpVal.substring(0, strTmpVal.length - 1);
	url2 = url + InfoPath;

	exp.setTime(exp.getTime()+1000*60*60*24*1);
	document.cookie = "favorite=1; path=/; expires=" + exp.toGMTString();

	window.open(url2,null,'width=700,height=500,directories=0,location=0,menubar=0,toolbar=0,resizable=1,left=0,top=0');
}

//チェックボックスのグループIDを取得
function get_BuyPropertyID() {
	var strTmpVal = '';

	for (i=0;i < document.getElementsByName('PropChk').length; i++) {
		if (document.getElementsByName('PropChk')[i].checked) {
			strTmpVal += document.getElementsByName('PropChk')[i].value + ','; 
		}
	}
	return '/' + 'PropId/' + strTmpVal.substring(0, strTmpVal.length - 1);
}

//チェックボックスのグループIDを取得
function get_RentGroupID() {
	var strTmpVal = '';

	for (i=0;i < document.getElementsByName('PropChk').length; i++) {
		if (document.getElementsByName('PropChk')[i].checked) {
			strTmpVal += document.getElementsByName('PropChk')[i].value + ','; 
		}
	}
//2008/10/19 upd by h-takahashi
	return '/' + 'PropId/' + strTmpVal.substring(0, strTmpVal.length - 1);
}

//検索パラメータ取得
function get_Param(section) {
	var strTmpVal = '';

	for (i=0;i < document.getElementsByName('Param').length; i++) {
		strTmpVal += document.getElementsByName('Param')[i].value + ','; 
	}

	if (strTmpVal.length > 0) {
		if ( section != 1 ) { 
			return strTmpVal.substring(0, strTmpVal.length - 1) + '/section/' + section;
		} else {
			return strTmpVal.substring(0, strTmpVal.length - 1);
		}
	} else {
		return '';
	}
}


