﻿//設定初始顯示圖片
function SetDefTab(strImgPath){ 
	//店資訊
	if(document.getElementById("hidTabStoreMenuID")!=null){
		if(document.getElementById("hidTabStoreMenuID").value=="")
		{
			onClickTabDef("Menu_StorePos","hidTabStoreMenuID",strImgPath);
		}
		else{
			onClickTabDef(document.getElementById("hidTabStoreMenuID").value,"hidTabStoreMenuID",strImgPath);
		}
	}
	
	//搜尋			
	if(document.getElementById("hidTabSrhID")!=null){
		if(document.getElementById("hidTabSrhID").value=="")
		{
			onClickTabDef("Bu_Search04","hidTabSrhID",strImgPath);
		}
		else{
			onClickTabDef(document.getElementById("hidTabSrhID").value,"hidTabSrhID",strImgPath);
		}
	}
	
	//大樓導覽
	if(document.getElementById("hidTabCommMenuID")!=null){
		if(document.getElementById("hidTabCommMenuID").value=="")
		{
			onClickTabDef("Menu_Comm","hidTabCommMenuID",strImgPath);
		}
		else{
			onClickTabDef(document.getElementById("hidTabCommMenuID").value,"hidTabCommMenuID",strImgPath);
		}
	}
	
	//生活圈資訊 & 最新消息
	if(document.getElementById("hidTabLivingMenuID")!=null){
		if(document.getElementById("hidTabLivingMenuID").value=="")
		{
			onClickTabDef("Menu_Living","hidTabLivingMenuID",strImgPath);
		}
		else{
			onClickTabDef(document.getElementById("hidTabLivingMenuID").value,"hidTabLivingMenuID",strImgPath);
		}
	}
}

//設定滑鼠點選事件
function onClickTabDef(strTabButtonID,strHidTabDefID,strImgPath)
{
	var arrImgName;
	var arrTabName;
	var strDivH = "";
	var strDivClassName = "";
	var strPlace = "";
	var strImgPath = strImgPath;
	if(strImgPath==''){strImgPath = 'Images'}
	
	//將所有Tab設為初始狀態-----------------------------------------------------
	//搜尋
	if(strHidTabDefID=="hidTabSrhID")
	{
		arrImgName = "Bu_Search01,Bu_Search02,Bu_Search03,Bu_Search04".split(",");
		arrTabName = "Bu_Search01,Bu_Search02,Bu_Search03,Bu_Search04".split(",");
		
		if(document.location.pathname.toLowerCase().indexOf('ugcs_object.asp') >= 0){
			strDivH = "24";
			if(strTabButtonID=='Bu_Search02'){strDivH = "47";}
			//if(strTabButtonID=='Bu_Search04'){strDivH = "45";}
		}
		else{
			strDivH = "24";
			if(strTabButtonID=='Bu_Search02'){strDivH = "95";}
			if(strTabButtonID=='Bu_Search04'){strDivH = "45";}
		}
		strDivClassName = "";
	}

	//位置圖 & 專業團隊 & 聯賣服務
	if(strHidTabDefID=="hidTabStoreMenuID")
	{
		arrImgName = "Menu_StorePos,Menu_StoreEmp,Menu_StoreUnion".split(",");
		arrTabName = "Menu_StorePos,Menu_StoreEmp,Menu_StoreUnion".split(",");
		strDivH = "165";
		strDivClassName = "tab_store_border";
	}

	//大樓導覽 & 影音物件
	if(strHidTabDefID=="hidTabCommMenuID")
	{
		arrImgName = "Menu_Comm,Menu_ObjVedio,Menu_ObjVedio2".split(",");
		arrTabName = "Menu_Comm,Menu_ObjVedio,Menu_ObjVedio2".split(",");
		strDivH = "173";
		strDivClassName = "tab_store_border";
	}

	//生活圈資訊 & 最新消息
	if(strHidTabDefID=="hidTabLivingMenuID")
	{
		arrImgName = "Menu_Living,Menu_News,Menu_News2".split(",");
		arrTabName = "Menu_Living,Menu_News,Menu_News2".split(",");
		strDivH = "145";
		strDivClassName = "tab_store_border";
	}

	//將所有Tab設為預設狀態-----------------------------------------------------
	for(i=0;i<=arrTabName.length-1;i++)
	{
		if(document.getElementById("tab_"+arrTabName[i])!=null){
			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)
	{
		if(document.getElementById("tab_" + arrTabName[0])!=null){
			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
	{
		if(document.getElementById("tab_" + strTabButtonID)!=null){
			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;
		}
	}
	
	if(strTabButtonID=='Menu_ObjVedio2'){
		document.getElementById("tab_Menu_ObjVedio").style.display = "";
		document.getElementById("tab_Menu_ObjVedio").style.visibility = "visible";
		document.getElementById("tab_Menu_ObjVedio").style.height = strDivH + "px";
	}
	if(strTabButtonID=='Menu_News2'){
		document.getElementById("tab_Menu_News").style.display = "";
		document.getElementById("tab_Menu_News").style.visibility = "visible";
		document.getElementById("tab_Menu_News").style.height = strDivH + "px";
	}

	//設定滑鼠點選時,圖片&hidden的狀態-------------------------------------------
	for(i=0;i<=arrImgName.length-1;i++)
	{
		if(document.getElementById(arrImgName[i])!=null){
			document.getElementById(arrImgName[i]).src = strImgPath + "/" + arrImgName[i] + ".gif";
		}	
	}	
	
	document.getElementById(strHidTabDefID).value = strTabButtonID;
	document.getElementById(strTabButtonID).src=strImgPath + "/" + strTabButtonID +"_c.gif";		
}

//設定滑鼠滑出後事件
function onMouseOutTabDef(strTabButtonID,strHidTabDefID,strImgPath)
{
	var strImgPath = strImgPath;
	if(strImgPath==''){strImgPath = 'Images'}
	
	if(document.getElementById(strHidTabDefID).value!=strTabButtonID)
	{
		document.getElementById(strTabButtonID).src = strImgPath + "/" + strTabButtonID + ".gif";
		//MM_swapImgRestore()
	}

	if(document.getElementById(strHidTabDefID).value==strTabButtonID)
	{
		document.getElementById(strTabButtonID).src = strImgPath + "/" + strTabButtonID + "_c.gif";
		//MM_swapImgRestore()
	}
}

//首頁三物件
function getObjectData(dataType,dataArea){
	var tmpPara = '';
	var tmpBefPara = '';
	
	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);
		}
	});
}