﻿<!--
function LogCommandLine()
{
	if (strCN == "")
		document.getElementById("CommandLine").innerHTML = "<a href='../../Interface.htm'><img src='images/index_07.gif' border='0' alt='' /></a>";
	else
		document.getElementById("CommandLine").innerHTML = "<a href='../../Logout.aspx'><img src='images/index_07_out.gif' border='0' alt='' /></a>";
}

function AdminLogin(url)
{
	var Request = new aspRequest(document.URL);
	var UserBlog = new getUserBlog(Request);

	location.href = url + "?Group=" + UserBlog.Blog;
}

// ==============================================================================================================
// 	社團模組
// ==============================================================================================================

// 廣告

function RequestGroupAdvertise(thsElement)
{
	var httpRequest = AjaxRequest();
	var objElement = ParentNodeTagName(thsElement, "TD");

	if (httpRequest && objElement)
	{
		var Request = new aspRequest(document.URL);
		var UserBlog = new getUserBlog(Request);
		var url = "../../Xml/GroupAdvertiseHorizontal.aspx?Group=" + UserBlog.Blog + "&rnd=" + Rnd();

		httpRequest.onreadystatechange = function() {

			if (httpRequest.readyState == 4 && httpRequest.status == 200)
			{
				var strHTML;
				var aryRows = eval(httpRequest.responseText);

				if (aryRows.length > 0)
				{
					var strText, strLink;

					strHTML = "<table width='100%' border='0' cellpadding='0' cellspacing='0'><tr>";

					for (var i=0; i<aryRows.length; i++)
					{
						strText = HTMLEncode(aryRows[i][0]);
						strLink = aryRows[i][1];

						if (strLink != "")
							strText = "<a href='" + strLink + "' target='_blank'>" + strText + "</a>";

						strHTML += "<td align='center' nowrap>" + strText + "</td>";
					}

					strHTML += "</tr></table>";
				}
				else
				{
					strHTML = "&nbsp;";
				}

				objElement.innerHTML = strHTML;
			}
		}

		httpRequest.open("GET", url, true);
		httpRequest.send(null);
	}
}

// 行事曆模組

function DateDay(theYear, theMonth)
{
	var MonthAry = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

	if (((theYear % 4 == 0) && (theYear % 100 != 0)) || (theYear % 400 == 0))
		MonthAry[1]++;

	return MonthAry[theMonth];
}

function CalendarEvent(theDate, aryDay, sFile)
{
	theDate.setDate(1);

	var EndDay, SumDay, AddDay, eDate, nxtLink;
	var nowDate = new Date(nowDateTime.toDateString());
	var theYear  = theDate.getFullYear();
	var theMonth = theDate.getMonth();
	var theWeek = theDate.getDay();
	var theDay = DateDay(theYear, theMonth);

	theMonth += 1;

	nowDate.setDate(1);

	if (theDate < nowDate)
	{
		theDate.setMonth((theDate.getMonth()+1));

		nxtLink = " href='Search." + sFile + "?sDate=" + theDate.getFullYear() + "/" + (theDate.getMonth()+1) + "'";

		theDate.setMonth((theDate.getMonth()-2));
	}
	else
	{
		nxtLink = "";

		theDate.setMonth((theDate.getMonth()-1));
	}

	var strHTML = "<div align='center'>";

	strHTML += "<table width='100%' border='0' cellpadding='3' cellspacing='0' class='Calendar'>";
	strHTML += "<tr>";
	strHTML += "<td height='30' align='center'>";
	strHTML += "<a href='Search." + sFile + "?sDate=" + theDate.getFullYear() + "/" + (theDate.getMonth()+1) + "'>&lt;&lt;</a>";
	strHTML += "&nbsp;<a href='Search." + sFile + "?sDate=" + theYear + "/" + theMonth + "'>";

	switch (theMonth)
	{
		case 1:
			strHTML += "January";
			break;
		case 2:
			strHTML += "February";
			break;
		case 3:
			strHTML += "March";
			break;
		case 4:
			strHTML += "April";
			break;
		case 5:
			strHTML += "May";
			break;
		case 6:
			strHTML += "June";
			break;
		case 7:
			strHTML += "July";
			break;
		case 8:
			strHTML += "August";
			break;
		case 9:
			strHTML += "September";
			break;
		case 10:
			strHTML += "October";
			break;
		case 11:
			strHTML += "November";
			break;
		case 12:
			strHTML += "December";
			break;
		default:
			break;
	}

	strHTML += "&nbsp;" + theYear + "</a>&nbsp;<a" + nxtLink + ">&gt;&gt;</a>";
	strHTML += "</td>";
	strHTML += "</tr>";
	strHTML += "<tr>";
	strHTML += "<td>";
	strHTML += "<table width='100%' border='0' cellpadding='2' cellspacing='1'>";
	strHTML += "<tr>";
	strHTML += "<td align='center'><div>日</div></td>";
	strHTML += "<td align='center'><div>一</div></td>";
	strHTML += "<td align='center'><div>二</div></td>";
	strHTML += "<td align='center'><div>三</div></td>";
	strHTML += "<td align='center'><div>四</div></td>";
	strHTML += "<td align='center'><div>五</div></td>";
	strHTML += "<td align='center'><div>六</div></td>";
	strHTML += "</tr>";
	strHTML += "<tr>";

	EndDay = theDay + theWeek;
	AddDay = EndDay % 7;
			
	if (AddDay == 0)
		AddDay = 0;
	else
		AddDay = 7 - AddDay;
			
	SumDay = EndDay + AddDay;
		
	for (var i=1; i<=SumDay; i++)
	{
		if (i <= theWeek || i > EndDay)
		{
			strHTML += "<td align='center'>&nbsp;</td>";
		}
		else
		{
			eDate = i - theWeek;

			if (aryDay[eDate])
				strHTML += "<td align='center'><a href='Search." + sFile + "?sDate=" + theYear + "/" + theMonth + "&eDate=" + eDate + "'>" + eDate + "</a></td>";
			else
				strHTML += "<td align='center'>" + eDate + "</td>";
		}
		
		if ((i+7) % 7 == 0)
			strHTML += "</tr><tr>";
	}

	strHTML += "</tr>";
	strHTML += "</table>";
	strHTML += "</td>";
	strHTML += "</tr>";
	strHTML += "</table>";
	strHTML += "</div>";

	return strHTML;
}

function TheCalendar(strDate, UserBlog, objElement)
{
	var aryDate = (strDate + "/").split("/");
	var theYear  = aryDate[0];
	var theMonth = aryDate[1];
	var theDate = new Date();

	if ((!isNaN(theYear)) && (!isNaN(theMonth)))
	{
		theYear  = Number(theYear);
		theMonth = Number(theMonth) - 1;

		theDate.setYear(theYear);
		theDate.setMonth(theMonth);
	}

	var httpRequest = AjaxRequest();

	if (httpRequest && strBlog != "")
	{
		httpRequest.onreadystatechange = function() {

			if (httpRequest.readyState == 4 && httpRequest.status == 200)
			{
				var xmldoc = httpRequest.responseXML;
				var aryDay = new Array();

				if (xmldoc)
				{
					rowsElement = xmldoc.getElementsByTagName("rows");

					for (i=0; i<rowsElement.length; i++)
						aryDay[rowsElement[i].childNodes[0].firstChild.data] = "Y";
				}

				objElement.innerHTML = CalendarEvent(theDate, aryDay, "aspx");
			}
		}

		var strBlog = UserBlog.Blog;
		var sDate = theDate.getFullYear() + "/" + (theDate.getMonth() + 1);
		var url = "../../Xml/CalendarGroup.aspx?GROUP=" + strBlog + "&sDate=" + sDate + "&rnd=" + Rnd();

		httpRequest.open("GET", url, true);
		httpRequest.send(null);
	}
}

function RequestCalendar(thsElement)
{
	var objElement = ParentNodeTagName(thsElement, "TD");
	var httpRequest = AjaxRequest();
	var Request = new aspRequest(document.URL);
	var UserBlog = new getUserBlog(Request);
	var strBlog = UserBlog.Blog;

	if (objElement && httpRequest && strBlog != "")
	{
		objElement.title = "";

		var sDate = Request.QueryString("sDate") + "/1";

		if (sDate != "" && (!isNaN(new Date(sDate))))
		{
			TheCalendar(sDate, UserBlog, objElement);
		}
		else
		{
			httpRequest.onreadystatechange = function() {

				if (httpRequest.readyState == 4 && httpRequest.status == 200)
				{
					var xmldoc = httpRequest.responseXML;

					if (xmldoc)
					{
						var rowsElement = xmldoc.getElementsByTagName("rows");

						if (rowsElement.length > 0 && rowsElement[0].firstChild)
						{
							sDate = rowsElement[0].firstChild.data;

							TheCalendar(sDate, UserBlog, objElement);
						}
						else
						{
							sDate = new Date(nowDateTime);

							objElement.innerHTML = CalendarEvent(sDate, (new Array()), "aspx");
						}
					}
				}
			}

			var url = "../../Xml/LastCalendarGroup.aspx?GROUP=" + strBlog + "&rnd=" + Rnd();

			httpRequest.open("GET", url, true);
			httpRequest.send(null);
		}
	}
}

// 熱門新聞

function RequestGroupNews(thsElement)
{
	var objElement = ParentNodeTagName(thsElement, "TD");
	var httpRequest = AjaxRequest();
	var Request = new aspRequest(document.URL);
	var UserBlog = new getUserBlog(Request);
	var strBlog = UserBlog.Blog;

	if (httpRequest && strBlog != "")
	{
		var url = "../../Xml/GroupNews.aspx?GROUP=" + strBlog + "&rnd=" + Rnd();

		httpRequest.onreadystatechange = function() {

			if (httpRequest.readyState == 4 && httpRequest.status == 200)
			{
				var aryRows = eval(httpRequest.responseText);
				var strDocumentId, strTitle, strMy;
				var strHTML = "<table width='100%' border='0' cellspacing='0' cellpadding='2'>";

				for (var i=0; i<aryRows.length; i++)
				{
					strDocumentId = aryRows[i][0];
					strTitle = aryRows[i][1];
					strMy = aryRows[i][2];

					strHTML += "<tr align='left'>";
					strHTML += "<td nowrap><span><img src='../../images/blank.gif'></span></td>";
					strHTML += "<td width='100%'><a href='../../My/" + encodeURIComponent(strMy) + "/Content.htm?DocumentId=" + strDocumentId + "' target='_blank'>" + HTMLEncode(strTitle) + "</a></td>";
					strHTML += "</tr>";
				}

				strHTML += "</table>";

				objElement.innerHTML = strHTML;
			}
		}

		httpRequest.open("GET", url, true);
		httpRequest.send(null);
	}
}

// 序

function RequestGroupIntroduction(thsElement)
{
	var objElement = ParentNodeTagName(thsElement, "TD");
	var httpRequest = AjaxRequest();
	var Request = new aspRequest(document.URL);
	var UserBlog = new getUserBlog(Request);
	var strBlog = UserBlog.Blog;

	if (httpRequest && strBlog != "")
	{
		var url = "../../Xml/GroupIntroduction.aspx?GROUP=" + strBlog + "&rnd=" + Rnd();

		httpRequest.onreadystatechange = function() {

			if (httpRequest.readyState == 4 && httpRequest.status == 200)
			{
				var strIntroduction = httpRequest.responseText;

				objElement.innerHTML = "<span><img src='../../images/blank.gif'></span>" + InnerEncode(strIntroduction);
			}
		}

		httpRequest.open("GET", url, true);
		httpRequest.send(null);
	}
}

// 群俠行

function RequestGroupMember(thsElement)
{
	var objElement = ParentNodeTagName(thsElement, "TD");
	var httpRequest = AjaxRequest();
	var Request = new aspRequest(document.URL);
	var UserBlog = new getUserBlog(Request);
	var strBlog = UserBlog.Blog;

	if (httpRequest && objElement && strBlog != "")
	{
		var url = "../../Xml/GroupBlogMember.aspx?GROUP=" + strBlog + "&rnd=" + Rnd();

		httpRequest.onreadystatechange = function() {

			if (httpRequest.readyState == 4 && httpRequest.status == 200)
			{
				var strClassId, strMember, strMemberName, strNickName, j;
				var aryRows = eval(httpRequest.responseText);
				var strHTML = "<table width='100%' border='0' cellpadding='2' cellspacing='0'>";

				for (var i in aryRows)
				{
					strClassName = HTMLEncode(aryRows[i][0]);
					strCount = Number(aryRows[i][1]);
					strHit = Number(aryRows[i][2]);

					strHTML += "<tr>";
					strHTML += "<td>";
					strHTML += "<table width='100%' border='0' cellpadding='0' cellspacing='1' class='Group-Member'>";
					strHTML += "<tr>";
					strHTML += "<td>";
					strHTML += "<table width='100%' border='0' cellpadding='0' cellspacing='0'>";
					strHTML += "<tr><td><div>" + InnerEncode(strClassName) + "</div></td></tr>";
					strHTML += "</table>";
					strHTML += "</td>";
					strHTML += "</tr>";
					strHTML += "<tr>";
					strHTML += "<td align='left'>";
					strHTML += "<div>";
					strHTML += "<table width='100%' border='0' cellpadding='3' cellspacing='0'>";

					for (j=0; j<aryRows[i][3].length; j++)
					{
						strMemberName = HTMLEncode(aryRows[i][3][j][0]);
						strMember = aryRows[i][3][j][1];
						strNickName = HTMLEncode(aryRows[i][3][j][2]);

						strHTML += "<tr>";
						strHTML += "<td>";
						strHTML += "<table width='100%' border='0' cellpadding='0' cellspacing='0'>";
						strHTML += "<tr>";
						strHTML += "<td nowrap>" + strMemberName + "：</td>";
						strHTML += "<td width='100%'><a href='../../My/" + encodeURIComponent(strMember) + "/'>" + strNickName + "</a></td>";
						strHTML += "</tr>";
						strHTML += "</table>";
						strHTML += "</td>";
						strHTML += "</tr>";
					}

					strHTML += "</table>";
					strHTML += "</div>";
					strHTML += "</td>";
					strHTML += "</tr>";
					strHTML += "<tr>";
					strHTML += "<td>";
					strHTML += "<span>";
					strHTML += "<table width='100%' border='0' cellpadding='0' cellspacing='1'>";
					strHTML += "<tr>";
					strHTML += "<td>";
					strHTML += "<table border='0' cellpadding='0' cellspacing='0'>";
					strHTML += "<tr><td>總文章數：<b>" + strCount + "</b><br>累積人氣：<b>" + strHit + "</b></td></tr>";
					strHTML += "</table>";
					strHTML += "</td>";
					strHTML += "</tr>";
					strHTML += "</table>";
					strHTML += "</span>";
					strHTML += "</td>";
					strHTML += "</tr>";
					strHTML += "</table>";
					strHTML += "</td>";
					strHTML += "</tr>";
				}

				strHTML += "</table>";

				objElement.innerHTML = strHTML;
			}
		}

		httpRequest.open("GET", url, true);
		httpRequest.send(null);
	}
}

// 成員最新發表

function RequestGroupMemberDocument(thsElement)
{
	var objElement = ParentNodeTagName(thsElement, "TD");
	var httpRequest = AjaxRequest();
	var Request = new aspRequest(document.URL);
	var UserBlog = new getUserBlog(Request);
	var strBlog = UserBlog.Blog;

	if (httpRequest && strBlog != "")
	{
		var url = "../../Xml/GroupMemberDocument.aspx?GROUP=" + strBlog + "&rnd=" + Rnd();

		httpRequest.onreadystatechange = function() {

			if (httpRequest.readyState == 4 && httpRequest.status == 200)
			{
				var aryRows = eval(httpRequest.responseText);

				var theDate = new Date(nowDateTime);

				theDate.setDate(theDate.getDate()-1);

				var strMy, strNickName, strPhotoUrl, strDocument, strPostDateTime, strDocumentId, strUserKindId, strUserKindName, strTitle, aryDocument;
				var strSpacer = "";
				var strHTML = "<table width='100%' border='0' cellpadding='0' cellspacing='2'>";

				for (var i=0; i<aryRows.length; i++)
				{
					strMy = aryRows[i][0];
					strNickName = aryRows[i][1];
					strPhotoUrl = aryRows[i][2];
					strDocument = aryRows[i][3];

					if (strDocument == "")
					{
						break;
					}
					else
					{
						aryDocument = strDocument.split(">");

						strPostDateTime = aryDocument[0];
						strDocumentId = aryDocument[1];
						strUserKindId = aryDocument[2];
						strUserKindName = aryDocument[3];
						strTitle = aryDocument[4];

						strPostDateTime = strPostDateTime.substring(0, strPostDateTime.lastIndexOf(":"));
						strPostDateTime = FormatDateTime(strPostDateTime, "yyyy/m/d h:n");

						if (strPhotoUrl == "")
							strPhotoUrl = "<img src='../../images/120x90.jpg'>";
						else
							strPhotoUrl = "<a href='../../UpImage/PhotoLarge/" + strPhotoUrl + "' target='_blank'><img src='../../UpImage/Photo/" + strPhotoUrl + "' border='0'></a>";

						strMy = encodeURIComponent(strMy);

						strHTML += strSpacer;
						strHTML += "<tr>";
						strHTML += "<td align='center' width='125'>" + strPhotoUrl + "</td>";
						strHTML += "<td align='left'>";
						strHTML += "<table width='100%' border='0' cellpadding='3' cellspacing='0'>";
						strHTML += "<tr><td>時間：" + strPostDateTime + "</td></tr>";
						strHTML += "<tr><td>分類：<a href='../../My/" + strMy + "/Search.htm?UserKindId=" + strUserKindId + "&KindName=" + encodeURIComponent(strUserKindName) + "'>" + HTMLEncode(strUserKindName) + "</a></td></tr>";
						strHTML += "<tr>";
						strHTML += "<td>";
						strHTML += "<div>";
						strHTML += "<a href='../../My/" + strMy + "/Content.htm?DocumentId=" + strDocumentId + "'>" + strTitle + "</a>";

						if ((new Date(strPostDateTime)) >= theDate)
							strHTML += "<img src='../../images/new.gif'>";

						strHTML += "</div>";
						strHTML += "</td>";
						strHTML += "</tr>";
						strHTML += "<tr><td><a href='../../My/" + strMy + "'>" + HTMLEncode(strNickName) + "</a>&nbsp;發表</td></tr>";
						strHTML += "</table>";
						strHTML += "</td>";
						strHTML += "</tr>";

						strSpacer = "<tr><td colspan='2'><div><table width='100%' border='0' cellpadding='0' cellspacing='0'><tr><td>&nbsp;</td></tr></table></div></td></tr>";
					}
				}

				if (strSpacer != "")
				{
					strHTML += "<tr>";
					strHTML += "<td colspan='2'>";
					strHTML += "<div>";
					strHTML += "<table width='100%' border='0' cellpadding='0' cellspacing='0'>";
					strHTML += "<tr><td align='right'><div><a href='Search.aspx'>more</a>&nbsp;&nbsp;</div></td></tr>";
					strHTML += "</table>";
					strHTML += "</div>";
					strHTML += "</td>"
					strHTML += "</tr>";
				}

				strHTML += "</table>";

				objElement.innerHTML = strHTML;
			}
		}

		httpRequest.open("GET", url, true);
		httpRequest.send(null);
	}
}

// 社團最新發表

function RequestGroupNewDocument(thsElement)
{
	var objElement = ParentNodeTagName(thsElement, "TD");
	var httpRequest = AjaxRequest();
	var Request = new aspRequest(document.URL);
	var UserBlog = new getUserBlog(Request);
	var strBlog = UserBlog.Blog;

	if (httpRequest && strBlog != "")
	{
		var url = "../../Xml/GroupNewDocument.aspx?GROUP=" + strBlog + "&rnd=" + Rnd();

		httpRequest.onreadystatechange = function() {

			if (httpRequest.readyState == 4 && httpRequest.status == 200)
			{
				var aryRows = eval(httpRequest.responseText);
				var strDocumentId, strTitle, strMy;
				var strHTML = "<table width='100%' border='0' cellspacing='0' cellpadding='2'>";

				for (var i=0; i<aryRows.length; i++)
				{
					strDocumentId = aryRows[i][0];
					strTitle = aryRows[i][1];
					strMy = aryRows[i][2];

					strHTML += "<tr>";
					strHTML += "<td align='center'>" + (i+1) + "</td>";
					strHTML += "<td width='100%'><a href='../../My/" + encodeURIComponent(strMy) + "/Content.htm?DocumentId=" + strDocumentId + "' target='_blank'>" + HTMLEncode(strTitle) + "</a></td>";
					strHTML += "</tr>";
				}

				strHTML += "</table>";

				objElement.innerHTML = strHTML;
			}
		}

		httpRequest.open("GET", url, true);
		httpRequest.send(null);
	}
}

// 熱門俠客

function RequestGroupHotMember(thsElement)
{
	var objElement = ParentNodeTagName(thsElement, "TD");
	var httpRequest = AjaxRequest();
	var Request = new aspRequest(document.URL);
	var UserBlog = new getUserBlog(Request);
	var strBlog = UserBlog.Blog;

	if (httpRequest && strBlog != "")
	{
		var url = "../../Xml/GroupHotMember.aspx?GROUP=" + strBlog + "&rnd=" + Rnd();

		httpRequest.onreadystatechange = function() {

			if (httpRequest.readyState == 4 && httpRequest.status == 200)
			{
				var aryRows = eval(httpRequest.responseText);
				var aryPhotoNo = new Array("<img src='../../images/main_champ.gif'>", "2.", "3.", "4.", "5.");
				var aryPhotoUrl = new Array("", "", "", "", "");
				var strMy, strNickName;
				var strHTML = "<table width='100%' border='0' cellpadding='2' cellspacing='0'>";

				if (aryRows.length > 0)
				{
					strHTML += "<tr>";
					strHTML += "<td align='center' valign='top'>";
					strHTML += "<div>";
					strHTML += "<table width='95%' border='0' cellpadding='1' cellspacing='1'>";

					for (var i=0; i<aryRows.length; i++)
					{
						strMy = aryRows[i][0];
						strNickName = aryRows[i][1];
						aryPhotoUrl[i] = aryRows[i][2];

						strHTML += "<tr align='left'>";
						strHTML += "<td align='center'>" + aryPhotoNo[i] + "</td>";
						strHTML += "<td><a href='../../My/" + encodeURIComponent(strMy) + "' target='_blank'>" + InnerEncode(strNickName) + "</a></td>";
						strHTML += "</tr>";
					}

					if (aryPhotoUrl[0] == "")
						aryPhotoUrl[0] = "images/120x90.jpg";
					else
						aryPhotoUrl[0] = "UpImage/Photo/" + aryPhotoUrl[0];

					strHTML += "</table>";
					strHTML += "</div>";
					strHTML += "</td>";
					strHTML += "<td align='center'><img src='../../" + aryPhotoUrl[0] + "'></td>";
					strHTML += "</tr>"
				}

				strHTML += "</table>";

				objElement.innerHTML = strHTML;
			}
		}

		httpRequest.open("GET", url, true);
		httpRequest.send(null);
	}
}

// 熱門文章

function RequestGroupHotDocument(thsElement)
{
	var objElement = ParentNodeTagName(thsElement, "TD");
	var httpRequest = AjaxRequest();
	var Request = new aspRequest(document.URL);
	var UserBlog = new getUserBlog(Request);
	var strBlog = UserBlog.Blog;

	if (httpRequest && strBlog != "")
	{
		var url = "../../Xml/GroupHotDocument.aspx?GROUP=" + strBlog + "&rnd=" + Rnd();

		httpRequest.onreadystatechange = function() {

			if (httpRequest.readyState == 4 && httpRequest.status == 200)
			{
				var aryRows = eval(httpRequest.responseText);
				var aryPhotoNo = new Array("<img src='../../images/main_champ.gif'>", "2.", "3.", "4.", "5.");
				var strHTML = "<table width='100%' border='0' cellpadding='1' cellspacing='1'>";
				var strDocumentId, strTitle, strMy;

				for (var i=0; i<aryRows.length; i++)
				{
					strDocumentId = aryRows[i][0];
					strTitle = aryRows[i][1];
					strMy = aryRows[i][2];

					strHTML += "<tr>";
					strHTML += "<td align='center'>" + aryPhotoNo[i] + "</td>";
					strHTML += "<td align='left'><a href='../../My/" + encodeURIComponent(strMy) + "/Content.htm?DocumentId=" + strDocumentId + "'>" + HTMLEncode(strTitle) + "</a></td>";
					strHTML += "</tr>";
				}

				strHTML += "</table>";

				objElement.innerHTML = strHTML;
			}
		}

		httpRequest.open("GET", url, true);
		httpRequest.send(null);
	}
}

// 最新留言

function RequestGroupNewQuestion(thsElement)
{
	var objElement = ParentNodeTagName(thsElement, "TD");
	var httpRequest = AjaxRequest();
	var Request = new aspRequest(document.URL);
	var UserBlog = new getUserBlog(Request);
	var strBlog = UserBlog.Blog;

	if (httpRequest)
	{
		var url = "../../Xml/GroupNewQuestion.aspx?GROUP=" + strBlog + "&rnd=" + Rnd();

		httpRequest.onreadystatechange = function() {

			if (httpRequest.readyState == 4 && httpRequest.status == 200)
			{
				var strDocumentId, strTitle, strMy, strResponsedId, strDateTime, strQuestionCN, strQuestionName, strCreate;
				var aryRows = eval(httpRequest.responseText);
				var strHTML = "<table width='100%' border='0' cellspacing='0' cellpadding='2'>";

				for (var i=0; i<aryRows.length; i++)
				{
					strDocumentId = aryRows[i][0];
					strTitle = aryRows[i][1];
					strMy = aryRows[i][2];
					strResponsedId = aryRows[i][3];
					strDateTime = aryRows[i][4];
					strQuestionCN = aryRows[i][5];
					strQuestionName = aryRows[i][6];

					if (strQuestionCN != "" && strQuestionName != "")
					{
						strCreate = strQuestionName.charAt(0);

			                        strQuestionName = strQuestionName.substring(1, strQuestionName.length);
						strQuestionName = HTMLEncode(strQuestionName);

						if (strCreate == "Y")
							strQuestionName = "<a href='../../My/" + encodeURIComponent(strQuestionCN) + "'>" + strQuestionName + "</a>";
					}

					strHTML += "<tr>";
					strHTML += "<td>";
					strHTML += "<table width='100%' border='0' cellpadding='3' cellspacing='0'>";
					strHTML += "<tr valign='top'>";
					strHTML += "<td rowspan='2' align='center'><div><span>" + (i+1) + "</span></div></td>";
					strHTML += "<td colspan='2' width='100%'><a href='../../My/" + encodeURIComponent(strMy) + "/Content.htm?DocumentId=" + strDocumentId + "#" + strResponsedId + "'>" + HTMLEncode(strTitle) + "</a></td>";
					strHTML += "</tr>";
					strHTML += "<tr>";
					strHTML += "<td>" + strQuestionName + "</td>";
					strHTML += "<td align='right'>於&nbsp;" + FormatDateTime(strDateTime, "m/d") + "&nbsp;留言</td>";
					strHTML += "</tr>";
					strHTML += "</table>";
					strHTML += "</td>";
					strHTML += "</tr>";
				}

				strHTML += "</table>";

				objElement.innerHTML = strHTML;
			}
		}

		httpRequest.open("GET", url, true);
		httpRequest.send(null);
	}
}

// 專欄

function RequestGroupWriter(thsElement, strMy)
{
	var objElement = ParentNodeTagName(thsElement, "TD");
	var httpRequest = AjaxRequest();

	if (httpRequest)
	{
		var url = "../../Xml/GroupWriter.aspx?CN=" + strMy + "&rnd=" + Rnd();

		httpRequest.onreadystatechange = function() {

			if (httpRequest.readyState == 4 && httpRequest.status == 200)
			{
				var strTitle;
				var aryRows = eval(httpRequest.responseText);
				var strHTML = "<table width='100%' border='0' cellspacing='0' cellpadding='2'>";

				for (var i=0; i<aryRows.length; i++)
				{
					strTitle = HTMLEncode(aryRows[i][1]);

					strHTML += "<tr>";
					strHTML += "<td width='100%'><div style='position: absolute; text-overflow: ellipsis; overflow: hidden; width: 180px; white-space: nowrap;'><a href='../../My/" + encodeURIComponent(strMy) + "/Content.htm?DocumentId=" + aryRows[i][0] + "' title=\"" + strTitle + "\">" + strTitle + "</a></div>&nbsp;</td>";
					strHTML += "<td nowrap>" + FormatDateTime(aryRows[i][2], "m/d")  + "</td>";
					strHTML += "</tr>";
				}

				strHTML += "</table>";

				objElement.innerHTML = strHTML;
			}
		}

		httpRequest.open("GET", url, true);
		httpRequest.send(null);
	}
}

// 搜尋

function RequestGroupSearch(thsElement)
{
	var objElement = ParentNodeTagName(thsElement, "TD");
	var httpRequest = AjaxRequest();
	var Request = new aspRequest(document.URL);
	var UserBlog = new getUserBlog(Request);
	var strBlog = UserBlog.Blog;

	if (httpRequest && strBlog != "")
	{
		var url = "";
		var strWord = "";
		var sDate = Request.QueryString("sDate");
		var theDate = new Date(sDate + "/1");

		if (sDate != "" && (!isNaN(theDate)))
		{
			var eDate = Request.QueryString("eDate");
			var sYear, sMonth;

			if ((!isNaN(eDate)) && Number(eDate) > 0)
			{
				theDate.setDate(Number(eDate));

				sYear = theDate.getFullYear();
				sMonth = theDate.getMonth() + 1;
				eDate = theDate.getDate();

				strWord = sYear + "年" + sMonth + "月" + eDate + "日";

				url = "GroupDate.aspx?sDate=" + sYear + "/" + sMonth + "&eDate=" + eDate;
			}
			else
			{
				sYear = theDate.getFullYear();
				sMonth = theDate.getMonth() + 1;

				strWord = sYear + "年" + sMonth + "月";

				url = "GroupMonth.aspx?sDate=" + sDate;
			}
		}
		else
		{
			strWord = Request.QueryString("word");

			while (strWord.indexOf("+") >= 0)
				strWord = strWord.replace("+", " ");

			while (strWord.indexOf("  ") >= 0)
				strWord = strWord.replace("  ", " ");

			url = "GroupSearch.aspx?word="

			if (strWord == "")
			{
				strWord = "最新文章";
			}
			else
			{
				url += strWord;

				strWord = "關鍵字：" + HTMLEncode(decodeURIComponent(strWord));
			}
		}

		var pagesize = 20;
		var pageindex = Request.QueryString("PageIndex");

		if ((!isNaN(pageindex)) && Number(pageindex) > 0)
			pageindex = Number(pageindex);
		else
			pageindex = "1";

		url = "../../Xml/" + url + "&GROUP=" + strBlog + "&PageSize=" + pagesize + "&PageIndex=" + pageindex + "&rnd=" + Rnd();

		httpRequest.onreadystatechange = function() {

			if (httpRequest.readyState == 4 && httpRequest.status == 200)
			{
				var theDate = new Date(nowDateTime);

				theDate.setDate(theDate.getDate()-1);

				var aryRows = eval(httpRequest.responseText);
				var recordcount = Number(aryRows.pop());
				var pagecount = Math.ceil(recordcount / pagesize);
				var strDocumentId, strTitle, strPostDateTime, strMy, strNickName, strSysKindId, strSysKindName, strUserKindId, strUserKindName;

				if (pageindex > pagecount)
					pageindex = 1;

				var strHTML = "<table width='100%' border='0' cellpadding='0' cellspacing='0'>";

				strHTML += "<tr>";
				strHTML += "<td colspan='3'>";
				strHTML += "<div>";
				strHTML += "<table width='100%' border='0' cellpadding='0' cellspacing='0'>";
				strHTML += "<tr>";
				strHTML += "<td>&nbsp;&nbsp;" + strWord + "</td><td align='right'>共&nbsp;" + recordcount + "&nbsp;篇文章&nbsp;&nbsp;</td>";
				strHTML += "</tr>";
				strHTML += "</table>";
				strHTML += "</div>";
				strHTML += "</td>";
				strHTML += "</tr>";

				for (var i=0; i<aryRows.length; i++)
				{
					strDocumentId = aryRows[i][0];
					strTitle = aryRows[i][1];
					strPostDateTime = FormatDateTime(aryRows[i][2], "yyyy/m/d h:n");
					strMy = aryRows[i][3];
					strNickName = aryRows[i][4];
					strSysKindId = aryRows[i][5];
					strSysKindName = aryRows[i][6];
					strUserKindId = aryRows[i][7];
					strUserKindName = aryRows[i][8];
					strMy = encodeURIComponent(strMy);

					strHTML += "<tr><td height='5'></td></tr>";
					strHTML += "<tr>";
					strHTML += "<td colspan='3'>";
					strHTML += "<div>";
					strHTML += "<a href='../../My/" + strMy + "/Content.htm?DocumentId=" + strDocumentId + "'>" + HTMLEncode(strTitle) + "</a>";

					if ((new Date(strPostDateTime)) >= theDate)
						strHTML += "<img src='../../images/new.gif'>";

					strHTML += "</div>";
					strHTML += "</td>";
					strHTML += "</tr>";
					strHTML += "<tr>";
					strHTML += "<td width='150'>文章分類：<a href='../../My/" + strMy + "/Search.htm?SysKindId=" + strSysKindId + "&KindName=" + encodeURIComponent(strSysKindName) + "'>" + HTMLEncode(strSysKindName) + "</a></td>";
					strHTML += "<td>自訂分類：<a href='../../My/" + strMy + "/Search.htm?UserKindId=" + strUserKindId + "&KindName=" + encodeURIComponent(strUserKindName) + "'>" + HTMLEncode(strUserKindName) + "</a></td>";
					strHTML += "<td align='right'><a href='../../My/" + strMy + "'>" + HTMLEncode(strNickName) + "</a>&nbsp;於&nbsp;" + strPostDateTime + "&nbsp;發表</td>";
					strHTML += "</tr>";
				}

				strHTML += "<tr>";
				strHTML += "<td colspan='3'>" + PageLine(Request, pageindex, pagesize, recordcount) + "</td>";
				strHTML += "</tr>";
				strHTML += "</table>";

				objElement.innerHTML = strHTML;
			}
		}

		httpRequest.open("GET", url, true);
		httpRequest.send(null);
	}
}

// 留言

function RequestGroupReply(thsElement)
{
	var objElement = ParentNodeTagName(thsElement, "TD");
	var httpRequest = AjaxRequest();
	var Request = new aspRequest(document.URL);
	var UserBlog = new getUserBlog(Request);
	var strBlog = UserBlog.Blog;

	if (httpRequest && strBlog != "")
	{
		var pagesize = 20;
		var pageindex = Request.QueryString("PageIndex");

		if ((!isNaN(pageindex)) && Number(pageindex) > 0)
			pageindex = Number(pageindex);
		else
			pageindex = "1";

		httpRequest.onreadystatechange = function() {

			if (httpRequest.readyState == 4 && httpRequest.status == 200)
			{
				var oJSON = eval("(" + httpRequest.responseText + ")");
				var recordcount = Number(oJSON.RECORDCOUNT);
				var pagecount = Math.ceil(recordcount / pagesize);
				var strDocumentId, strTitle, strMy, strNickName, strResponsedId, strAnswerDateTime, strQuestionDateTime, strQuestionCN, QuestionName;

				var strHTML = "<table width='100%' border='0' cellpadding='0' cellspacing='0'>";

				strHTML += "<tr>";
				strHTML += "<td colspan='2'>";
				strHTML += "<div>";
				strHTML += "<table width='100%' border='0' cellpadding='0' cellspacing='0'>";
				strHTML += "<tr>";
				strHTML += "<td>&nbsp;&nbsp;最新留言</td><td align='right'>共&nbsp;" + recordcount + "&nbsp;篇留言&nbsp;&nbsp;</td>";
				strHTML += "</tr>";
				strHTML += "</table>";
				strHTML += "</div>";
				strHTML += "</td>";
				strHTML += "</tr>";

				for (var i=1; i<oJSON.GROUP.length; i++)
				{
					strDocumentId = oJSON.GROUP[i].DOCUMENTID;
					strTitle = oJSON.GROUP[i].TITLE;
					strNickName = oJSON.GROUP[i].NICKNAME;
					strAnswerDateTime = oJSON.GROUP[i].ANSWERDATETIME;
					strResponsedId = oJSON.GROUP[i].RESPONSEDID;
					strQuestionDateTime = oJSON.GROUP[i].QUESTIONDATETIME;
					strQuestionCN = oJSON.GROUP[i].QUESTIONCN;
					strQuestionName = oJSON.GROUP[i].QUESTIONNAME;
					strMy = oJSON.GROUP[i].CN;
					strMy = encodeURIComponent(strMy);

					if (strQuestionCN != "" && strQuestionName != "")
					{
						strCreate = strQuestionName.charAt(0);

			                        strQuestionName = strQuestionName.substring(1, strQuestionName.length);
						strQuestionName = HTMLEncode(strQuestionName);

						if (strCreate == "Y")
							strQuestionName = "<a href='../../My/" + encodeURIComponent(strQuestionCN) + "'>" + strQuestionName + "</a>";
					}

					strHTML += "<tr><td height='5'></td></tr>";
					strHTML += "<tr><td colspan='2'><div><a href='../../My/" + strMy + "/Content.htm?DocumentId=" + strDocumentId + "#" + strResponsedId + "'>" + HTMLEncode(strTitle) + "</a></div></td></tr>";
					strHTML += "<tr>";
					strHTML += "<td>發表&nbsp;<a href='../../My/" + strMy + "'>" + HTMLEncode(strNickName) + "</a>";

					if (strAnswerDateTime != "")
						strHTML += "&nbsp;回覆&nbsp;" + FormatDateTime(strAnswerDateTime, "yyyy/m/d h:n");

					strHTML += "</td>";
					strHTML += "<td align='right'>&nbsp;" + strQuestionName + "&nbsp;於&nbsp;" + FormatDateTime(strQuestionDateTime, "yyyy/m/d h:n") + "&nbsp;留言</td>";
					strHTML += "</tr>";
				}

				strHTML += "<tr>";
				strHTML += "<td colspan='2'>" + PageLine(Request, pageindex, pagesize, recordcount) + "</td>";
				strHTML += "</tr>";
				strHTML += "</table>";

				objElement.innerHTML = strHTML;
			}
		}

		var url = "../../Xml/GroupReply.aspx?GROUP=" + strBlog + "&PageSize=" + pagesize + "&PageIndex=" + pageindex + "&rnd=" + Rnd();

		httpRequest.open("GET", url, true);
		httpRequest.send(null);
	}
}

// 

function RequestSecretary(thsElement, strBlog)
{
	var objElement = ParentNodeTagName(thsElement, "TD");
	var httpRequest = AjaxRequest();
	var Request = new aspRequest(document.URL);

	if (httpRequest && strBlog != "")
	{
		httpRequest.onreadystatechange = function() {

			if (httpRequest.readyState == 4 && httpRequest.status == 200)
			{
				var xmldoc = httpRequest.responseXML;

				if (xmldoc)
				{
					var strDocumentId, strTitle, strPhotoUrl;
					var rowsElement = xmldoc.getElementsByTagName("rows");

					var strDocumentId = "";
					var strTitle = "";
					var strPhotoUrl = "";

					if (rowsElement.length > 0)
					{
						strDocumentId = rowsElement[0].childNodes[0].firstChild.data;
						strTitle = HTMLEncode(NodeDecode(rowsElement[0].childNodes[1].firstChild.data));
						strPhotoUrl = rowsElement[0].childNodes[2].firstChild.data;
					}

					if (strPhotoUrl == "")
						strPhotoUrl = "<img src='../../images/120x90.jpg' width='50'>";
					else
						strPhotoUrl = "<a target='_blank' href='../../UpImage/PhotoLarge/" + strPhotoUrl + "'><img src='../../UpImage/PhotoSmall/" + strPhotoUrl + "' border='0'></a>";

					var strHTML = "<table width='100%' border='0' cellpadding='0' cellspacing='3'>";

					strHTML += "<tr valign='top'>";
					strHTML += "<td width='60' align='center' valign='top'>";
					strHTML += "<table width='55' border='0' cellpadding='3' cellspacing='1' bgcolor='#CCCCCC'>";
					strHTML += "<tr><td bgcolor='#FFFFFF' align='center'>" + strPhotoUrl + "</td></tr>";
					strHTML += "</table>";
					strHTML += "</td>";
					strHTML += "<td>";
					strHTML += "<div><a href='../../My/" + strBlog + "/Content.htm?DocumentId=" + strDocumentId + "'>" + strTitle + "</a></div>";
					strHTML += "<div align='right'><span><a href='../../My/" + strBlog + "/'>more</a></span></div>";
					strHTML += "</td>";
					strHTML += "</tr>";
					strHTML += "</table>";

					objElement.innerHTML = strHTML;
				}
			}
		}

		var url = "../../Xml/Secretary.aspx?CN=" + strBlog + "&rnd=" + Rnd();

		httpRequest.open("GET", url, true);
		httpRequest.send(null);
	}
}

// * 個人最新文章模組

function RequestGroupDocument(thsElement, strBlog)
{
	var objElement = ParentNodeTagName(thsElement, "TD");
	var httpRequest = AjaxRequest();

	if (httpRequest && objElement && strBlog != "")
	{
		objElement.title = "";

		httpRequest.onreadystatechange = function() {

			if (httpRequest.readyState == 4 && httpRequest.status == 200)
			{
				var aryRows = eval(httpRequest.responseText);
				var strHTML = "<table width='100%' border='0' cellspacing='0' cellpadding='2'>";
				var strMy = encodeURIComponent(strBlog);
				var strDocumentId, strTitle;

				for (var i=0; i<aryRows.length; i++)
				{
					strDocumentId = aryRows[i][0];
					strTitle = aryRows[i][1];

					strHTML += "<tr align='left'>";
					strHTML += "<td nowrap><span><img src='../../images/blank.gif'></span></td>";
					strHTML += "<td width='100%'><a href='../../My/" + strMy + "/Content.htm?DocumentId=" + strDocumentId + "' target='_blank'>" + HTMLEncode(strTitle) + "</a></td>";
					strHTML += "</tr>";
				}

				strHTML += "</table>";

				objElement.innerHTML = strHTML;
			}
		}

		var url = "../../Xml/GroupDocument.aspx?CN=" + strBlog + "&rnd=" + Rnd();

		httpRequest.open("GET", url, true);
		httpRequest.send(null);
	}
}
//-->