﻿/********************************************************/
// 不動産一覧用JavaScript
//
//
//
//
/********************************************************/
var fgOldRow = 99;

//詳細ウィンドウの名前
var fgSubWinName = "fudousantbl"
var fgDataNew="";
var fgDataCnt="";
//2009/08/27 変更 ST koi
var fgDataList="";
//2009/08/27 変更 ED koi
/********************************************************/
// ONLOADイベント
//
//
//
/********************************************************/
window.onload=function(){
var sWhere = "";
var sSql = "";
var sType = "";

	for (i=1;i<=47;i++){

//		document.getElementById("KEN" + i + "_1").onclick = function(evt){OpenDetail(this);};
//		document.getElementById("KEN" + i + "_2").onclick = function(evt){OpenDetail(this);};
//		document.getElementById("KEN" + i + "_NAME").onclick = function(evt){OpenDetail(this);};
		document.getElementById("KEN" + i + "_KENSU").innerHTML = "0";
		document.getElementById("KEN" + i + "_ZOOM").href = "javascript:ListOpen(" + i + ");"
	}

//2009/09/03-2
//var sParam = "({UI_KAISYAMEI:     {pclass:'FUDOUSAN_LIST1',pcolspan:'1',prowspan:'1',pcollf:'0',ptype:'S',palign:'left',pimgsrc:'',purl:'javascript:OpenUserUrlNew(this,[row],0);',pjs:''}"
var sParam = "({UI_KAISYAMEI:     {pclass:'FUDOUSAN_LIST1',pcolspan:'1',prowspan:'1',pcollf:'0',ptype:'AS',palign:'left',pimgsrc:'',purl:'javascript:OpenUserUrlNew(this,[row],0);',pjs:'',pinqurl:'UI_URL'}"
//2009/09/03-2
                +  ",UI_TEL:      {pclass:'FUDOUSAN_LIST2',pcolspan:'1',prowspan:'1',pcollf:'0',ptype:'S',palign:'left',pimgsrc:'',purl:'',pjs:''}"
                +  ",UI_USERIDIMG:{pclass:'FUDOUSAN_LIST3',pcolspan:'1',prowspan:'1',pcollf:'0',ptype:'S',palign:'left',pimgsrc:'../images/btn/fudousan_dtl.gif',purl:'',pjs:'OpenDetailNew(this);'}"
                +  ",UI_USERID:   {pclass:'FUDOUSAN_LIST_H',pcolspan:'1',prowspan:'1',pcollf:'0',ptype:'S',palign:'left',pimgsrc:'',purl:'',pjs:''}"
                +  ",UI_ZYUSYO:   {pclass:'FUDOUSAN_LIST4',pcolspan:'4',prowspan:'1',pcollf:'1',ptype:'S',palign:'left',pimgsrc:'',purl:'',pjs:''}"
                +  ",UI_URL:   {pclass:'FUDOUSAN_LIST_H',pcolspan:'1',prowspan:'1',pcollf:'0',ptype:'S',palign:'left',pimgsrc:'',purl:'',pjs:''}"				+ "})";

	sParam = eval(sParam);

	sType = "ONS_FDNEW";
	comGetServerData(fgsUrl, sType, sWhere, sSql);
	fgDataNew = fgData;
	//新着リスト
	if (fgDataNew!=""){
		comDataAdd(document.getElementById('TBL_0'),fgDataNew,sParam);
	}

	//件数表示
	sType = "ONS_FDCNT";
	comGetServerData(fgsUrl, sType, sWhere, sSql);
	fgDataCnt = fgData; 

	var CNT = eval("(" + fgDataCnt + ");");

	for (var sKey in CNT){
		var sCntRow = CNT[sKey];
		document.getElementById("KEN" + sCntRow['UI_CHIIKI'] + "_KENSU").innerHTML = sCntRow['CNT'];
	}

//2009/08/31 変更 ST koi
	document.getElementById("btn_sendmail").onclick = function(evt){CallMailSend();};
//2009/08/31 変更 ED koi

//	setContents_l("75%");

//ページカウンター処理
	comSetCounterPage(comGetFileName());

	sType = "ONS_FDLIST";
	comGetServerData(fgsUrl, sType, sWhere, sSql);
//2009/08/27 変更 ST koi
	fgDataList = fgData; 
	SetSponsor(document.getElementById("div_sponsor_l"),"",3,"L");
	SetSponsor(document.getElementById("div_sponsor_r"),"",3,"R");
//2009/08/27 変更 ED koi
//2009/09/16 変更 ST koi
		comSetSrvUserCnt(fgsSetUserCntUrl,"P");
//2009/09/16 変更 ED koi

}

/********************************************************/
// 不動産情報の詳細を表示する(新着不動産TABLE用)
//
//
//
/********************************************************/
function OpenDetailNew(pObj){

	//クリックした画像のあるRowIndex -> pObj.parentElement.parentElement.parentElement.rowIndex

	//対象USERID
//	var sUserId = document.getElementById("TBL_0").rows[pObj.parentElement.parentElement.parentElement.rowIndex].cells[3].innerHTML;

//2009/09/03 不具合 ST koi
//	var sUserId = document.getElementById("TBL_0").rows[pObj.parentNode.parentNode.rowIndex].cells[3].innerHTML;
	var sUserId = document.getElementById("TBL_0").rows[pObj.parentNode.parentNode.parentNode.rowIndex].cells[3].innerHTML;
//2009/09/03 不具合 ED koi




	if(sUserId == null || sUserId == undefined){
		return;
	}

	//ユーザ詳細カウンタアップ
//2009/09/01 変更 ST koi
//	comSetCounterUserDetail(sUserId);
	comSetCounterUserDetail(sUserId,"5");
//2009/09/01 変更 ED koi

	window.open("srh_detail_c.html" + "?userid=" + sUserId,fgSubWinName);

}


/********************************************************/
// 不動産情報の詳細を表示する(地域別TABLE用)
//
//
//
/********************************************************/
function OpenDetail(pObj){
	if(fgOldRow==99){
		return
	}
	//クリックした画像のあるRowIndex -> pObj.parentNode.parentNode.parentNode.rowIndex

	//対象USERID
//2009/09/03 不具合 ST koi
//	var sUserId = document.getElementById("TBL_" + fgOldRow).rows[pObj.parentNode.parentNode.rowIndex].cells[4].innerHTML;
	var sUserId = document.getElementById("TBL_" + fgOldRow).rows[pObj.parentNode.parentNode.parentNode.rowIndex].cells[4].innerHTML;
//2009/09/03 不具合 ED koi


	if(sUserId == null || sUserId == undefined){
		return;
	}

	//ユーザ詳細カウンタアップ
//2009/09/01 変更 ST koi
//	comSetCounterUserDetail(sUserId);
	comSetCounterUserDetail(sUserId,"6");
//2009/09/01 変更 ED koi

	window.open("srh_detail_c.html" + "?userid=" + sUserId,fgSubWinName);

}

/********************************************************/
// 県別の一覧を表示／非表示する
//
//
//
/********************************************************/
	function ListOpen(pIndex){
		if(fgOldRow!=99){
			//前回表示した行の削除
			comRowAllClear(document.getElementById('TBL_' + fgOldRow));
			//フォルダアイコン変更
			document.getElementById('OP_' + fgOldRow).src="../icon/fl_cl.gif";

			if(pIndex==fgOldRow){
				//開いている行を閉じるだけなので、地域コードを初期化して終了
				fgOldRow = 99;
				return;
			}

		}

	var sParam = "({UI_NEWIMG:{pclass:'FUDOUSAN_LIST5',pcolspan:'1',prowspan:'1',pcollf:'0',ptype:'I',palign:'left',pimgsrc:'UI_NEWIMG',purl:'',pjs:''}"
//2009/09/03-2
//				+ ",UI_KAISYAMEI:{pclass:'FUDOUSAN_LIST1',pcolspan:'1',prowspan:'1',pcollf:'0',ptype:'S',palign:'left',pimgsrc:'',purl:'javascript:OpenUserUrl(this,[row]," + (pIndex) + ");',pjs:''}"
				+ ",UI_KAISYAMEI:{pclass:'FUDOUSAN_LIST1',pcolspan:'1',prowspan:'1',pcollf:'0',ptype:'AS',palign:'left',pimgsrc:'',purl:'javascript:OpenUserUrl(this,[row]," + (pIndex) + ");',pjs:'',pinqurl:'UI_URL'}"
//2009/09/03-2
				+ ",UI_TEL:      {pclass:'FUDOUSAN_LIST2',pcolspan:'1',prowspan:'1',pcollf:'0',ptype:'S',palign:'left',pimgsrc:'',purl:'',pjs:''}"
				+ ",UI_USERIDIMG:{pclass:'FUDOUSAN_LIST3',pcolspan:'1',prowspan:'1',pcollf:'0',ptype:'S',palign:'left',pimgsrc:'../images/btn/fudousan_dtl.gif',purl:'',pjs:'OpenDetail(this);'}"
				+ ",UI_USERID:   {pclass:'FUDOUSAN_LIST_H',pcolspan:'1',prowspan:'1',pcollf:'0',ptype:'S',palign:'left',pimgsrc:'',purl:'',pjs:''}"
				+ ",UI_ZYUSYO:   {pclass:'FUDOUSAN_LIST4',pcolspan:'5',prowspan:'1',pcollf:'1',ptype:'S',palign:'left',pimgsrc:'',purl:'',pjs:''}"
                +  ",UI_URL:   {pclass:'FUDOUSAN_LIST_H',pcolspan:'1',prowspan:'1',pcollf:'0',ptype:'S',palign:'left',pimgsrc:'',purl:'',pjs:''}"								+ "})";

		sParam = eval(sParam);

		//選択した地域のデータのみ表示
//2009/08/27 変更 ST koi
//		comDataAddFD(document.getElementById('TBL_' + pIndex),fgData,sParam,pIndex);
		comDataAddFD(document.getElementById('TBL_' + pIndex),fgDataList,sParam,pIndex);
//2009/08/27 変更 ED koi
		//フォルダアイコン変更
		document.getElementById('OP_' + pIndex).src="../icon/fl_op.gif";
		//表示した地域コードの保持
		fgOldRow = pIndex;

		location.href="#ken" + pIndex;
	}


/****************************************************/
//  TBODYにDB内データ（複数行）追加[不動産一覧用]
//  comDataAddの改変
/****************************************************/
function comDataAddFD(poTbl,psData,psParam,psAreaCode){
var sStr="";

	var sAllData = eval("(" + psData + ");");

	//1行ごとに出力
	for (var sKey in sAllData){
		var sRowData = sAllData[sKey];		

//共通の改変 ST
		////行追加
		//comRowAdd(poTbl,sRowData,psParam);

		if(sRowData["UI_CHIIKI"]==psAreaCode){
			//行追加
			comRowAdd(poTbl,sRowData,psParam);
		}
//共通の改変 ED

	}

}

/******************************************/
/* 不動産会社ホームページ表示(新着)       */
/******************************************/
function OpenUserUrlNew(pObj,piRowIndex,piTblNo) {
	//対象データの取得
var iIndex = piRowIndex - 1;
var i = 0;
var iUseridIdx = 0;
var iUserUrlIdx = 0;

//1行目
	for (i = 0; i <= document.getElementById("TBL_"+piTblNo).rows[iIndex].cells.length - 1; i++) {
		if (document.getElementById("TBL_"+piTblNo).rows[iIndex].cells[i].id == "TD4") {
			iUseridIdx = i;
		}
	}

//2行目
	for (i = 0; i <= document.getElementById("TBL_"+piTblNo).rows[iIndex+1].cells.length - 1; i++) {
		if (document.getElementById("TBL_"+piTblNo).rows[iIndex+1].cells[i].id == "TD6") {
			iUserUrlIdx = i;
		}
	}

	var sUserId = document.getElementById("TBL_"+piTblNo).rows[iIndex].cells[iUseridIdx].innerHTML;
	var sUserUrl = document.getElementById("TBL_"+piTblNo).rows[iIndex+1].cells[iUserUrlIdx].innerHTML;
	if (sUserId == null || sUserId == undefined) {
		return;
	}
//	if (sUserUrl == null || sUserUrl == undefined) {
	if (sUserUrl == null || sUserUrl == undefined || sUserUrl == "") {
		return;
	}

	//ユーザ詳細カウンタアップ
//2009/09/01 変更 ST koi
//	comSetCounterUserHP(sUserId);
	comSetCounterUserHP(sUserId,"0");
//2009/09/01 変更 ED koi


	//ユーザHP画面表示
	window.open(sUserUrl);
}

/******************************************/
/* 不動産会社ホームページ表示(通常)       */
/******************************************/
function OpenUserUrl(pObj,piRowIndex,piTblNo) {
	//対象データの取得
var iIndex = piRowIndex - 1;
var i = 0;
var iUseridIdx = 0;
var iUserUrlIdx = 0;

//1行目
	for (i = 0; i <= document.getElementById("TBL_"+piTblNo).rows[iIndex].cells.length - 1; i++) {
		if (document.getElementById("TBL_"+piTblNo).rows[iIndex].cells[i].id == "TD5") {
			iUseridIdx = i;
		}
	}

//2行目
	for (i = 0; i <= document.getElementById("TBL_"+piTblNo).rows[iIndex+1].cells.length - 1; i++) {
		if (document.getElementById("TBL_"+piTblNo).rows[iIndex+1].cells[i].id == "TD7") {
			iUserUrlIdx = i;
		}
	}

	var sUserId = document.getElementById("TBL_"+piTblNo).rows[iIndex].cells[iUseridIdx].innerHTML;
	var sUserUrl = document.getElementById("TBL_"+piTblNo).rows[iIndex+1].cells[iUserUrlIdx].innerHTML;

	if (sUserId == null || sUserId == undefined) {
		return;
	}
//	if (sUserUrl == null || sUserUrl == undefined) {
	if (sUserUrl == null || sUserUrl == undefined || sUserUrl == "") {
		return;
	}

	//ユーザ詳細カウンタアップ
//2009/09/01 変更 ST koi
//	comSetCounterUserHP(sUserId);
	comSetCounterUserHP(sUserId,"1");
//2009/09/01 変更 ED koi

	//ユーザHP画面表示
	window.open(sUserUrl);
}

//2009/08/31 変更 ST koi
function CallMailSend(){
var sUrl;

	sUrl=location.href;
	location.href="../../inq/html/inq_sendmail.html?type=3&retUrl=" + sUrl;

}
//2009/08/31 変更 ED koi
