﻿//設定初始顯示圖片
function SetDefTab(){ 
	//最新消息
	/*if(document.getElementById("hidTabNewsID")!=null){
		if(document.getElementById("hidTabNewsID").value=="")
		{
			onClickTabDef("DefMenu_News","hidTabNewsID");
		}
		else{
			onClickTabDef(document.getElementById("hidTabNewsID").value,"hidTabNewsID");
		}
	}*/
	
	//投資精選
	/*091118 -------
	if(document.getElementById("hidTabHotID")!=null){
		if(document.getElementById("hidTabHotID").value=="")
		{
			onClickTabDef("DefMenu_Carefully","hidTabHotID");
		}
	}
	
	if(document.getElementById("hidTabHotAreaID")!=null){
		//北台灣
		if(document.getElementById("hidTabHotAreaID").value=="")
		{
			onClickTabDef("Bu_Place_north","hidTabHotAreaID");
		}
	}091118 -------*/
	
	//搜尋			
	if(document.getElementById("hidTabSrhID")!=null){
		if(document.getElementById("hidTabSrhID").value=="")
		{
			onClickTabDef("Bu_Search02","hidTabSrhID");
		}
		else{
			onClickTabDef(document.getElementById("hidTabSrhID").value,"hidTabSrhID");
		}
	}
}

/*
1. 投資精選
2. 店長推薦
3. 租屋精選
*/
var intAreaType = 1;

/*
1. 北部
2. 中部
3. 南部
4. 東部
*/
var intArea = 1;

//設定滑鼠點選事件
function onClickTabDef(strTabButtonID,strHidTabDefID)
{
	var arrImgName;
	var arrTabName;
	var strDivH = "";
	var strDivClassName = "";
	var strPlace = "";
	
	//將所有Tab設為初始狀態-----------------------------------------------------
	//搜尋
	if(strHidTabDefID=="hidTabSrhID")
	{
		arrImgName = "Bu_Search01,Bu_Search02,Bu_Search03,Bu_Search04,Bu_Search05,Bu_Search06".split(",");
		arrTabName = "Bu_Search01,Bu_Search02,Bu_Search03,Bu_Search04,Bu_Search05,Bu_Search06".split(",");
		strDivH = "80";
		strDivClassName = "";
	}

	//最新消息 & 房地產知 & 服務據點
	if(strHidTabDefID=="hidTabNewsID")
	{
		arrImgName = "DefMenu_News,DefMenu_Knowledge,DefMenu_Store".split(",");
		arrTabName = "DefMenu_News,DefMenu_Knowledge,DefMenu_Store".split(",");
		strDivH = "165";
		strDivClassName = "tab_news_border";
	}
	
	//投資精選 & 店長推薦 & 租屋精選
	if(strHidTabDefID=="hidTabHotID")
	{
		arrImgName = "DefMenu_Carefully,DefMenu_Recommend,DefMenu_Rent".split(",");
		arrTabName = "DefMenu_Carefully".split(",");
		strDivH = "165";
		strDivClassName = "tab_hot_border";
	}
	
	//北.中.南.東台灣
	if(strHidTabDefID=="hidTabHotAreaID")
	{
		arrImgName = "Bu_Place_north,Bu_Place_middle,Bu_Place_southern,Bu_Place_east".split(",");
	}
	else
	{
		//將所有Tab設為預設狀態-----------------------------------------------------
		for(i=0;i<=arrTabName.length-1;i++)
		{
			document.getElementById("tab_"+arrTabName[i]).style.display='none';
			document.getElementById("tab_"+arrTabName[i]).style.visibility='hidden';
			document.getElementById("tab_"+arrTabName[i]).style.height='0px';
			document.getElementById("tab_"+arrTabName[i]).className = "ClearFloat";
		}
		
		if(arrTabName.length==1)
		{
			document.getElementById("tab_" + arrTabName[0]).style.display = "";
			document.getElementById("tab_" + arrTabName[0]).style.visibility = "visible";
			document.getElementById("tab_" + arrTabName[0]).style.height = strDivH + "px";
			document.getElementById("tab_" + arrTabName[0]).className = strDivClassName;
		}
		else
		{
			document.getElementById("tab_" + strTabButtonID).style.display = "";
			document.getElementById("tab_" + strTabButtonID).style.visibility = "visible";
			document.getElementById("tab_" + strTabButtonID).style.height = strDivH + "px";
			document.getElementById("tab_" + strTabButtonID).className = strDivClassName;
		}
	}
	
	//設定滑鼠點選時,圖片&hidden的狀態-------------------------------------------
	for(i=0;i<=arrImgName.length-1;i++)
	{
		document.getElementById(arrImgName[i]).src = "Images/" + arrImgName[i] + ".gif";
	}	
	
	document.getElementById(strHidTabDefID).value = strTabButtonID;
	document.getElementById(strTabButtonID).src="Images/" + strTabButtonID +"_c.gif";		
	
	//"投資精選 & 店長推薦 & 租屋精":重新抓取房屋資料------------------------------
	//北.中.南.東台灣
	if(strHidTabDefID=="hidTabHotAreaID" || strHidTabDefID=="hidTabHotID")
	{
		//重新Loading區域內資料
		switch(document.getElementById("hidTabHotID").value)
		{
			case "DefMenu_Carefully":
				intAreaType = 1;
			break;
			
			case "DefMenu_Recommend":
				intAreaType = 2;
			break;
			
			case "DefMenu_Rent":
				intAreaType = 3;
			break;
		}

		switch(document.getElementById("hidTabHotAreaID").value)
		{
			case "Bu_Place_north":
				intArea = 1;
			break;
			
			case "Bu_Place_middle":
				intArea = 2;
			break;
			
			case "Bu_Place_southern":
				intArea = 3;
			break;
			
			case "Bu_Place_east":
				intArea = 4;
			break;
		}
		getObjectData(intAreaType,intArea);
	}
}

//設定滑鼠滑出後事件
function onMouseOutTabDef(strTabButtonID,strHidTabDefID)
{
	if(document.getElementById(strHidTabDefID).value!=strTabButtonID)
	{
		document.getElementById(strTabButtonID).src = "Images/" + strTabButtonID + ".gif";
		//MM_swapImgRestore()
	}

	if(document.getElementById(strHidTabDefID).value==strTabButtonID)
	{
		document.getElementById(strTabButtonID).src = "Images/" + strTabButtonID + "_c.gif";
		//MM_swapImgRestore()
	}
}

//首頁三物件
function getObjectData(dataType,dataArea){
	var tmpPara = '';
	var tmpBefPara = '';
	
	if(document.getElementById("hidKW")!=null){
		if(document.getElementById("hidKW").value !=''){
			tmpPara = tmpPara + '&hidKW=' + escape(document.getElementById("hidKW").value);
		}
	}

	if(document.getElementById("hidColumn")!=null){
		if(document.getElementById("hidColumn").value !=''){
			tmpPara = tmpPara + '&hidColumn=' + document.getElementById("hidColumn").value;
			tmpBefPara = tmpBefPara + '?hidColumn=' + document.getElementById("hidColumn").value;
		}
	}

	if(document.getElementById("hidTotalNum")!=null){
		if(document.getElementById("hidTotalNum").value !=''){
			tmpPara = tmpPara + '&hidTotalNum=' + document.getElementById("hidTotalNum").value;
		}
	}
	
	/*$.ajax({
		type:"get",
		url:"ugC_incBefLoadObject.asp" + tmpBefPara,
		error:function(){$("#tab_Bu_Place_north").html("");},
		success:function(Eval_Data){
			$("#tab_Bu_Place_north").html(Eval_Data);
		}
	});*/
	
	$.ajax({
		type:"get",
		url:"ugC_incDefObject.asp",
		data:"area=" + dataArea + "&type=" + dataType + tmpPara,
		error:function(){$("#tab_Bu_Place_north").html("資料讀取失敗");},
		success:function(Eval_Data){
			$("#tab_Bu_Place_north").html(Eval_Data);
		}
	});
}