﻿<!--
// ==============================================================================================================
// 	AJAX 物件
// ==============================================================================================================

function AjaxRequest()
{
	var xmlRequest = false;

	if (window.XMLHttpRequest)
	{
		xmlRequest = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		try {

			xmlRequest = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try {

				xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) { }
		}
	}

	return xmlRequest;
}

// ==============================================================================================================
// 	亂數
// ==============================================================================================================

function Rnd()
{
	var theDate = new Date();

	return theDate.getMinutes() + "" + theDate.getSeconds() + "" + theDate.getMilliseconds() + "" + Math.floor(Math.random()*10000000000000000);
}

// ==============================================================================================================
// 	廣告模組
// ==============================================================================================================

function RequestAdvertise(thsElement)
{
	var httpRequest = AjaxRequest();
	var objElement = ParentNodeTagName(thsElement, "TD");

	if (httpRequest && objElement)
	{
		var Request = new aspRequest(document.URL);
		var UserBlog = new getUserBlog(Request);

		httpRequest.onreadystatechange = function() {

			if (httpRequest.readyState == 4 && httpRequest.status == 200)
			{
				var oJSON = eval("(" + httpRequest.responseText + ")");
				var strId, strUrl, strText;
				var strHTML = "<table width='100%' border='0' cellpadding='0' cellspacing='0'><tr>";

				for (var i=1; i<oJSON.ADVERTISE.length; i++)
				{
					strId = oJSON.ADVERTISE[i].ID;
					strUrl = oJSON.ADVERTISE[i].URL;
					strText = oJSON.ADVERTISE[i].TEXT;

					strHTML += "<td align='center' nowrap><a href='http://ad.cnyes.com/cnYESAD/adredir.asp?ciid=" + strId + "&url=" + strUrl + "' target='_blank' class='LinkTop'>" + strText + "</a></td>";
				}

				strHTML += "</tr></table>";

				objElement.innerHTML = strHTML;
			}
		}

		var url = "../../Xml/AdvertiseJS.aspx?AD_TAG=CNYESBLOG_5,CNYESBLOG_6,CNYESBLOG_7&rnd=" + Rnd();

		httpRequest.open("GET", url, true);
		httpRequest.send(null);
	}
}

// ==============================================================================================================
// 	模組展開
// ==============================================================================================================

function DocumentModelLoad()
{
	var aryElement = new Array();
	var objElement = document.getElementsByName("Model");

	for (var i=0; i<objElement.length; i++)
		aryElement[i] = objElement[i];

	for (var i=0; i<aryElement.length; i++)
		aryElement[i].onclick();
}

// ==============================================================================================================
// 	取得 XML 元素的內容
// ==============================================================================================================

function getNodeValue(oNode)
{
	if (oNode && oNode.firstChild)
		return oNode.firstChild.data;
	else
		return "";
}

// ==============================================================================================================
// 	套用 css
// ==============================================================================================================

function hrefClassName(strApply)
{
	setCookie("Apply", strApply);

	document.getElementById("cssApply").href = "css/" + strApply + "/default.css";
}

function initClassName()
{
	var strApply = getCookie("Apply");

	if (strApply == "")
		hrefClassName("yellow");
	else
		hrefClassName(strApply);
}

// ==============================================================================================================
// 	登出
// ==============================================================================================================

function LogoutUrl()
{
	var Request = new aspRequest(document.URL);

	strUrl = Request.QueryString("");

	if (strUrl != "")
		strUrl = "?" + strUrl;

	strUrl = Request.path + Request.file + strUrl;

	location.href = "../../Logout.aspx?RefUrl=" + escape(strUrl);
}

// ==============================================================================================================
// 	取得節點於畫面所在位置 x, y
// ==============================================================================================================

function PositionLeft(objElement)
{
	var p = objElement.offsetLeft;

	while (objElement=objElement.offsetParent)
		p += objElement.offsetLeft;

	return p;
}

function PositionTop(objElement)
{
	var p = objElement.offsetTop;

	while (objElement=objElement.offsetParent)
		p += objElement.offsetTop;

	return p;
}

// ==============================================================================================================
// 	是否為正確的 Email 格式
// ==============================================================================================================

function isNEmail(strEmail)
{
	var strChar = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_@.";
	var i;

	for (i=0; i<strEmail.length; i++)
	{
		if (strChar.indexOf(strEmail.charAt(i)) < 0)
			return true;
	}

	i = strEmail.indexOf("@");

	if (i > 0)
	{
		var j = strEmail.indexOf(".", i);

		i += 1;

		if (j > i && strEmail.charAt((strEmail.length-1)) != ".")
			return false;
	}

	return true;
}

// ==============================================================================================================
// 	複製到剪貼簿
// ==============================================================================================================

function copy_to_clipborad(thsElement)
{
	if (document.all)
	{
		if (prompt("複製網址到剪貼簿", thsElement.value))
		{
			window.clipboardData.setData("Text", thsElement.value);

			alert("已複製到剪貼簿");
		}
	}
	else
	{
		alert("請按 Ctrl-C 複製網址到剪貼簿");

		thsElement.select();
	}
}

// ==============================================================================================================
// 	設為首頁
// ==============================================================================================================

function MyHomePage()
{
	if (document.all)
	{
		document.body.style.behavior = "url(#default#homepage)";
		document.body.setHomePage("http://blog.cnyes.com");
	}
}

// ==============================================================================================================
// 	加入我的最愛
// ==============================================================================================================

function MyFavorite()
{
	if (document.all)
		window.external.AddFavorite(document.URL, document.title);
}

// ==============================================================================================================
// 	XML  的屬性
// ==============================================================================================================

function AttributeEncode(strValue)
{
	strValue = Replace(strValue, "&", "&#x26;");

	while (strValue.indexOf("'")  >= 0)
		strValue = strValue.replace("'",  "&#x27;");

	while (strValue.indexOf("<")  >= 0)
		strValue = strValue.replace("<",  "&#x3c;");

	while (strValue.indexOf(">")  >= 0)
		strValue = strValue.replace(">",  "&#x3e;");

	while (strValue.indexOf("\"") >= 0)
		strValue = strValue.replace("\"", "&#x22;");

	return strValue;
}

function AttributeDecode(strValue)
{
	while (strValue.indexOf("&#x27;")  >= 0)
		strValue = strValue.replace("&#x27;",  "'");

	while (strValue.indexOf("&#x3c;")  >= 0)
		strValue = strValue.replace("&#x3c;",  "<");

	while (strValue.indexOf("&#x3e;")  >= 0)
		strValue = strValue.replace("&#x3e;",  ">");

	while (strValue.indexOf("&#x22;") >= 0)
		strValue = strValue.replace("&#x22;", "\"");

	while (strValue.indexOf("&#x26;") >= 0)
		strValue = strValue.replace("&#x26;", "&");

	return strValue;
}

// ==============================================================================================================
// 	FROM 的 input 組成
// ==============================================================================================================

function FormParam(objForm)
{
	var aryParam = new Array();

	for (var i=0; i<objForm.elements.length; i++)
	{
		if (objForm.elements[i].name != "")
		{
			if (aryParam[objForm.elements[i].name])
			{
				if ( (objForm.elements[i].type != "checkbox" && objForm.elements[i].type != "radio")
				||   (objForm.elements[i].type == "checkbox" && objForm.elements[i].checked)
				||   (objForm.elements[i].type == "radio"    && objForm.elements[i].checked) )
					aryParam[objForm.elements[i].name] += "," + objForm.elements[i].value;
			}
			else
			{
				if ( (objForm.elements[i].type != "checkbox" && objForm.elements[i].type != "radio")
				||   (objForm.elements[i].type == "checkbox" && objForm.elements[i].checked)
				||   (objForm.elements[i].type == "radio"    && objForm.elements[i].checked) )
					aryParam[objForm.elements[i].name] = objForm.elements[i].value;
			}
		}

		objForm.elements[i].disabled = true;
	}

	return aryParam;
}

// ==============================================================================================================
// 	FROM 的 input 組成 XML
// ==============================================================================================================

function FormXML(objForm)
{
	var aryParam = FormParam(objForm);
	var strXML = "<form><input ";

	for (var i in aryParam)
		strXML += i + "='" + AttributeEncode(InnerEncode(aryParam[i])) + "' ";

	strXML += "/></form>";

	return strXML;
}

// ==============================================================================================================
// 	Cookie 的操作
// ==============================================================================================================

function setCookie(theName, theValue)
{
	var theDate = new Date("2020/1/1 18:56:35");

	document.cookie = theName + "=" + escape(theValue) + ";expires=" + theDate.toUTCString();
}

function delCookie(theName)
{
	setCookie(theName, "");

	var theDate = new Date("1970/1/1 00:00:01");

	document.cookie = theName + "=;expires=" + theDate.toUTCString();
}

function getCookie(theName)
{
	theName += "=";

	var theCookie = document.cookie + ";";
	var s = theCookie.indexOf(theName);

	if (s < 0)
		return "";
	else
		return unescape(theCookie.substring((s + theName.length), theCookie.indexOf(";", s)));
}

// ==============================================================================================================
// 	回傳此元素為 tagName 的父節點
// ==============================================================================================================

function ParentNodeTagName(objElement, ElementTagName)
{
	ElementTagName = ElementTagName.toUpperCase();

	do
	{
		objElement = objElement.parentNode;
	}
	while (objElement.tagName != ElementTagName)

	return objElement;
}

// ==============================================================================================================
// 	點選 INPUT 元件 checked
// ==============================================================================================================

function BoxChecked(objElement, CheckedValue)
{
	if (objElement.length)
	{
		for (var i=0; i<objElement.length; i++)
		{
			if (objElement[i].value == CheckedValue)
			{
				objElement[i].click();
				break;
			}
		}
	}
	else
	{
		if (objElement.value == CheckedValue)
			objElement[i].click();
	}
}

// ==============================================================================================================
// 	選取 INPUT 元件 selected
// ==============================================================================================================

function ListSelected(objElement, SelectedValue)
{
	for (var i=0; i<objElement.length; i++)
	{
		if ((objElement.options[i].value + "") == (SelectedValue + ""))
		{
			objElement.options[i].selected = true;
			break;
		}
	}
}

// ==============================================================================================================
//
// ==============================================================================================================

function NodeDecode(strString)
{
	while (strString.indexOf("]]&gt;") >= 0)
		strString = strString.replace("]]&gt;", "]]>");

	return strString;
}

function InnerEncode(strString)
{
	strString = HTMLEncode(strString);

	while (strString.indexOf("\n") >= 0)
		strString = strString.replace("\n", "<br>");

	return strString;
}

function InnerDecode(strString)
{
	var objElement = document.createElement("DIV");

	objElement.innerHTML = strString;

	return objElement.innerHTML;
}

// ==============================================================================================================
// 	數字的排序
// ==============================================================================================================

function ArrayFirstSort(arySort, len)
{
	var strFirst, i;
	var strSpace = "";

	for (i=0; i<=len; i++)
		strSpace += "0";

	for (i=0; i<arySort.length; i++)
	{
		strFirst = strSpace + arySort[i][0];

		arySort[i][0] = strFirst.substr(strFirst.length-len, len);
	}

	arySort.sort();

	for (i=0; i<arySort.length; i++)
	{
		if (!isNaN(arySort[i][0]))
			arySort[i][0] = "" + Number(arySort[i][0]);
	}

	return arySort;
}

// ==============================================================================================================
// 	計數器
// ==============================================================================================================

function BrowserCounter()
{
	var Request = new aspRequest(document.URL);
	var strPath = Request.path;
	var strFile = Request.file;

	if (strFile.toLowerCase() == "default.aspx")
		strFile = "";

	var strScriptName = strPath + strFile;

	if (strScriptName != "")
		document.writeln("<iframe src='Browser.aspx?SCRIPT_NAME=" + strScriptName + "' marginwidth='0' marginheight='0' scrolling='no' border='0' frameborder='0' width='0' height='0'></iframe>")
}

// ==============================================================================================================
// 	實作 SQL 的 LTrim 方法
// ==============================================================================================================

function LTrim(strString)
{
	var strChar = " ";
	var i = 0;

	while (i < strString.length && strChar == " ")
	{
		strChar = strString.charAt(i);

		i++;
	}

	return strString.substring((--i), strString.length);
}

// ==============================================================================================================
// 	實作 SQL 的 RTrim 方法
// ==============================================================================================================

function RTrim(strString)
{
	var strChar = " ";
	var i = strString.length - 1;

	while (i >= 0 && strChar == " ")
	{
		strChar = strString.charAt(i);

		i--;
	}

	return strString.substring(0, (i+2));
}

// ==============================================================================================================
// 	實作 ASP 的 FormatDateTime() 方法
// ==============================================================================================================

function FormatDateTime(strDateTime, strFormat)
{
	var iHour = 0;

	strDateTime = strDateTime.toLowerCase();

	while (strDateTime.indexOf("&nbsp;") >= 0)
		strDateTime = strDateTime.replace("&nbsp;", " ");

	strDateTime = strDateTime.replace("-", "/");
	strDateTime = strDateTime.replace("-", "/");
	strDateTime = strDateTime.replace("上午", "");
	strDateTime = strDateTime.replace("am", "");

	if (strDateTime.indexOf("下午") >= 0)
	{
		strDateTime = strDateTime.replace("下午", "");
		iHour = 12;
	}

	if (strDateTime.indexOf("pm") >= 0)
	{
		strDateTime = strDateTime.replace("pm", "");
		iHour = 12;
	}

	strDateTime = new Date(strDateTime);

	if (strDateTime.getTime())
	{
		var strYear, strMonth, strDay, strHour, strMinute, strSecond, strMilliSecond;

		strYear = strDateTime.getFullYear();
		strMonth = "00" + (strDateTime.getMonth() + 1);
		strDay = "00" + strDateTime.getDate();
		strHour = "00" + (strDateTime.getHours() + iHour);
		strMinute = "00" + strDateTime.getMinutes();
		strSecond = "00" + strDateTime.getSeconds();
		strMilliSecond = strDateTime.getMilliseconds() + "000";

		strMonth = strMonth.substr(strMonth.length-2, 2);
		strDay = strDay.substr(strDay.length-2, 2);
		strHour = strHour.substr(strHour.length-2, 2);
		strMinute = strMinute.substr(strMinute.length-2, 2);
		strSecond = strSecond.substr(strSecond.length-2, 2);
		strMilliSecond = strMilliSecond.substr(0, 3);

		if (strHour == "12")
			strHour = "00";
		else if (strHour == "24")
			strHour = "12";

		strFormat = strFormat.replace("yyyy", strYear);
		strFormat = strFormat.replace("yy", strYear);
		strFormat = strFormat.replace("ms", strMilliSecond);
		strFormat = strFormat.replace("m", strMonth);
		strFormat = strFormat.replace("d", strDay);
		strFormat = strFormat.replace("h", strHour);
		strFormat = strFormat.replace("n", strMinute);
		strFormat = strFormat.replace("s", strSecond);

		return strFormat;
	}
	else
	{
		return "";
	}
}

// ==============================================================================================================
// 	實作 ASP 的 Replace() 方法
// ==============================================================================================================

function Replace(strString, strSub, strRep)
{
	var i = strString.indexOf(strSub);
	var strSubLen = strSub.length;
	var strRepLen = strRep.length;

	while (i >= 0)
	{
		strString = strString.substring(0, i) + strRep + strString.substring((i + strSubLen), strString.length);

		i = strString.indexOf(strSub, (i+strRepLen));
	}

	return strString;
}

// ==============================================================================================================
// 	實作 ASP 的 HTMLEncode 方法
// ==============================================================================================================

function HTMLEncode(strString)
{
	if (typeof(strString) == "undefined")
		strString = "";

	strString = Replace(strString, "&", "&amp;");

	while (strString.indexOf("<") >= 0)
		strString = strString.replace("<", "&lt;");

	while (strString.indexOf(">") >= 0)
		strString = strString.replace(">", "&gt;");

	while (strString.indexOf("\"") >= 0)
		strString = strString.replace("\"", "&quot;");

	return strString;
}

// ==============================================================================================================
// 	實作 ASP.NET 的 HTMLDecode 方法
// ==============================================================================================================

function HTMLDecode(strString)
{
	while (strString.indexOf("&lt;") >= 0)
		strString = strString.replace("&lt;", "<");

	while (strString.indexOf("&gt;") >= 0)
		strString = strString.replace("&gt;", ">");

	while (strString.indexOf("&quot;") >= 0)
		strString = strString.replace("&quot;", "\"");

	while (strString.indexOf("&amp;") >= 0)
		strString = strString.replace("&amp;", "&");

	return strString;
}

// ==============================================================================================================
// 	實作 ASP 的 Request.QueryString 物件
// ==============================================================================================================

function aspRequest(url)
{
	if (url)
	{
	}
	else
	{
		url = document.URL;
	}

	var urlpath, urlhash, urlary, varname, varval;
	var urlfile = (url + "?").split("?")[0];
	var urlquerystring = url.replace(urlfile, "");
	var s = urlfile.indexOf(":");
	var e = urlfile.lastIndexOf("/") + 1;

	s += 3;
	s = urlfile.indexOf("/", s);

	this.host = urlfile.substring(0, s);

	urlpath = urlfile.substring(s, e);
	urlfile = urlfile.substring(e, urlfile.length);
	urlquerystring = urlquerystring.replace("?", "");

	s = urlquerystring.lastIndexOf("#");

	if (s >= 0)
	{
		urlhash = urlquerystring.substring((s+1), urlquerystring.length);
		urlquerystring = urlquerystring.substring(0, s);
	}
	else
	{
		urlhash = "";
	}

	urlary = ("&" + urlquerystring).split("&");

	this.path = urlpath;
	this.file = urlfile;
	this.hash = urlhash;
	this.aryQueryString = new Array();

	for (var i=1; i<urlary.length; i++)
	{
		varname = (urlary[i] + "=").split("=")[0];
		varval = urlary[i].replace(varname + "=", "");
		varname = varname.toLowerCase();

		if (this.aryQueryString[varname])
			this.aryQueryString[varname] += "," + varval;
		else
			this.aryQueryString[varname] = varval;
	}

	this.QueryString = function (strQuery) {

		if (strQuery && strQuery != "")
		{
			strQuery = strQuery.toLowerCase();

			if (this.aryQueryString[strQuery])
				return this.aryQueryString[strQuery];
			else
				return "";
		}
		else
		{
			return urlquerystring;
		}
	}
}

// ==============================================================================================================
// 	Combo BOX
// ==============================================================================================================

function ComboBox(thsElement)
{
	var thsClass = this;

	this.TextKeyIn = function (pntElement) {

	}

	this.ListVisible = function (pntElement) 	{

		switch (pntElement.options.length)
		{
			case 0:
			case 1:
			case 2:

				pntElement.size = 2;
				break;


			case 3:
			case 4:

				pntElement.size = pntElement.options.length;

				break;

			default:

				pntElement.size = 5;

				break;

		}

		pntElement.style.visibility = "visible";
	}

	this.ListSelected = function (pntElement, SelectedValue)	{

		pntElement.selectedIndex = -1;

		SelectedValue += "";
		SelectedValue = SelectedValue.toLowerCase();

		var OptionValue;

		for (var i=0; i<pntElement.options.length; i++)
		{
			OptionValue = pntElement.options[i].text;

			if (OptionValue.toLowerCase() == SelectedValue)
			{
				pntElement.selectedIndex = i;
				break;
			}
		}
	}

	this.ParentNodeTagName = function (pntElement, ElementTagName)	{

		ElementTagName = ElementTagName.toUpperCase();

		do
		{
			pntElement = pntElement.parentNode;
		}
		while (pntElement.tagName != ElementTagName)

		return pntElement;
	}

	this.TextSelected = function (pntElement)	{

		var ElementValue = pntElement.value;

		pntElement = thsClass.ParentNodeTagName(pntElement, "TABLE");
		pntElement = pntElement.getElementsByTagName("SELECT")[0];

		thsClass.ListSelected(pntElement, ElementValue);
	}

	thsElement.innerHTML = "<table border='0' cellspacing='0' cellpadding='0'><tr><td><input type='text'></td></tr><tr><td><select size='2' style='position: absolute; visibility: hidden;'></select></td></tr></table>";

	var objElement = thsElement.getElementsByTagName("TABLE")[0];

	objElement.onmouseover = function () {

		var pntElement = this.getElementsByTagName("SELECT")[0];

		thsClass.ListVisible(pntElement);
	}

	objElement.onmouseout = function () {

		var pntElement = this.getElementsByTagName("SELECT")[0];

		pntElement.style.visibility = "hidden";
	}

	objElement = thsElement.getElementsByTagName("INPUT")[0];

	this.TextBox = objElement;

	objElement.onchange = function () 	{

		thsClass.TextSelected(this);
	}

	objElement.onkeyup = function (keyEvent) 	{

		if (!keyEvent)
			keyEvent = event;

		var pntElement = ParentNodeTagName(this, "TABLE");

		pntElement = pntElement.getElementsByTagName("SELECT")[0];

		thsClass.ListVisible(pntElement);

		switch (keyEvent.keyCode)
		{
			case 40:

				if (pntElement.selectedIndex < 0)
					pntElement.selectedIndex = 0;

				pntElement.focus();

				break;

			case 9:
			case 16:
			case 17:
			case 18:
			case 20:
			case 33:
			case 34:
			case 35:
			case 36:
			case 37:
			case 38:
			case 39:

				break;

			default:

				thsClass.TextKeyIn(this);
				thsClass.ListSelected(pntElement, this.value);

				break;
		}
	}

	objElement.onmouseover = function () 	{

		thsClass.TextSelected(this);
	}

	objElement = thsElement.getElementsByTagName("SELECT")[0];

	this.ListBox = objElement;

	objElement.onclick = function () {

		if (this.selectedIndex >= 0)
		{
			var pntElement = thsClass.ParentNodeTagName(this, "TABLE");

			pntElement = pntElement.getElementsByTagName("INPUT")[0];
			pntElement.value = this.options[this.selectedIndex].text;

			this.style.visibility = "hidden";
			this.blur();
		}
	}

	objElement.onkeypress = function (keyEvent) {

		if (!keyEvent)
			keyEvent = event;

		switch (keyEvent.keyCode)
		{
			case 13:

				this.onclick();
				break;
		}
	}

	objElement.onkeydown = function (keyEvent) {

		if (!keyEvent)
			keyEvent = event;

		switch (keyEvent.keyCode)
		{
			case 38:

				if (this.selectedIndex == 0)
				{
					var pntElement = thsClass.ParentNodeTagName(this, "TABLE");

					pntElement = pntElement.getElementsByTagName("INPUT")[0];
					pntElement.focus();
				}

				break;
		}
	}
}

// ==============================================================================================================
// 	顯示分頁數字
// ==============================================================================================================

function PageLine(Request, PageIndex, PageSize, RecordCount)
{
	var urlquery = "";
	var urlparam = "?";
	var PageCount = Math.ceil(RecordCount / PageSize);

	if ( (!isNaN(PageIndex)) && Number(PageIndex) > 0)
		PageIndex = Number(PageIndex);
	else
		PageIndex = 1;

	for (var varname in Request.aryQueryString)
	{
		if (varname != "pageindex" && varname != "")
		{
			urlquery += urlparam + varname + "=" + Request.aryQueryString[varname];
			urlparam = "&";
		}
	}

	i = PageIndex;

	if ((i + 4) > PageCount)
		i = PageCount - 4;

	if (i <= 4)
		i = 1;
	else
		i -= 4;

	var PageEnd = i + 9;
	var strHTML = "<table border='0' width='100%' cellspacing='3' cellpadding='0'><tr><td align='left'>" + ((PageIndex >= PageCount) ? RecordCount : (PageIndex * PageSize)) + " / " + RecordCount + " 筆</td><td align='center' class='Document-Title'>";

	if (PageIndex <= 1)
	{
		strHTML += "&lt;&lt;&nbsp;&nbsp;&lt;&nbsp; ";
	}
	else
	{
		strHTML += "<a href='" + Request.path + Request.file + urlquery + "'>&lt;&lt;</a>&nbsp;&nbsp;";

		var nxtPageIndex = PageIndex - 1;

		if (nxtPageIndex == 1)
			strHTML += "<a href='" + Request.path + Request.file + urlquery + "'>&lt;</a>";
		else
			strHTML += "<a href='" + Request.path + Request.file + urlquery + urlparam + "PageIndex=" + nxtPageIndex + "'>&lt;</a>";
	}

	if (RecordCount > 0)
	{
		for (; i<PageEnd && i<=PageCount; i++)
		{
			if (i == PageIndex)
			{
				strHTML += " <font color='#FF0000'>" + i + "</font> ";
			}
			else
			{
				if (i == 1)
					strHTML += " <a href='" + Request.path + Request.file + urlquery + "'>" + i + "</a> ";
				else
					strHTML += " <a href='" + Request.path + Request.file + urlquery + urlparam + "PageIndex=" + i + "'>" + i + "</a> ";
			}
		}
	}
	else
	{
		strHTML += " 1 ";
	}

	if (PageIndex >= PageCount)
		strHTML += "&gt;&nbsp;&nbsp;&gt;&gt;";
	else
		strHTML += "<a href='" + Request.path + Request.file + urlquery + urlparam + "PageIndex=" + (PageIndex+1) + "'>&gt;</a>&nbsp;&nbsp;<a href='" + Request.path + Request.file + urlquery + urlparam + "PageIndex=" + PageCount + "'>&gt;&gt;</a>";

	strHTML += "</td><td align='right'>" + PageIndex + " / " + PageCount + " 頁</td></tr></table>";

	return strHTML;
}

// ==============================================================================================================
// 	擷取文字行列數
// ==============================================================================================================

function stringMoreBig5()
{
	this.Replace = function (strString, strSub, strRep)	{

		var i = strString.indexOf(strSub);
		var strSubLen = strSub.length;
		var strRepLen = strRep.length;

		while (i >= 0)
		{
			strString = strString.substring(0, i) + strRep + strString.substring((i + strSubLen), strString.length);

			i = strString.indexOf(strSub, (i+strRepLen));
		}

		return strString;
	}

	this.InnerEncode = function (strString)	{

		strString = this.Replace(strString, "&", "&amp;");

		while (strString.indexOf("<") >= 0)
			strString = strString.replace("<", "&lt;");

		while (strString.indexOf(">") >= 0)
			strString = strString.replace(">", "&gt;");

		while (strString.indexOf("\"") >= 0)
			strString = strString.replace("\"", "&quot;");

		while (strString.indexOf(" ") >= 0)
			strString = strString.replace(" ", "&nbsp;");

		while (strString.indexOf("\n") >= 0)
			strString = strString.replace("\n", "<br>");

		return strString;
	}

	this.InnerDecode = function (strString)	{

		var divElement = document.createElement("DIV");

		divElement.innerHTML = strString;
		strString = divElement.innerHTML;

		while (strString.indexOf("&lt;") >= 0)
			strString = strString.replace("&lt;", "<");

		while (strString.indexOf("&gt;") >= 0)
			strString = strString.replace("&gt;", ">");

		while (strString.indexOf("&quot;") >= 0)
			strString = strString.replace("&quot;", "\"");

		while (strString.indexOf("&nbsp;") >= 0)
			strString = strString.replace("&nbsp;", " ");

		while (strString.indexOf("&amp;") >= 0)
			strString = strString.replace("&amp;", "&");

		while (strString.indexOf("<br>") >= 0)
			strString = strString.replace("<br>", "\n");

		while (strString.indexOf("<BR>") >= 0)
			strString = strString.replace("<BR>", "\n");

		return strString;
	}

	this.StringMore = function (strString, maxLen, maxLin)		{

		var strChar, intChar, i;
		var strHTML = "";
		var strLen = 0;
		var strLin = 0;

		strString = this.InnerDecode(strString);

		for (i=0; i<strString.length && ((maxLin <= 0) || (maxLin > 0 && strLin < maxLin)); i++)
		{
			strChar = strString.charAt(i);

			if (strChar == "\n")
			{
				strLen = 0;
				strLin++;
			}
			else
			{
				if (escape(strChar).length > 3)
					intChar = 2;
				else
					intChar = 1;

				strLen += intChar;

				if (strLen > maxLen)
				{
					strLen = intChar;

					if ((i + 1) != strString.indexOf("\n", i))
						strHTML += "\n";

					strLin++;
				}
			}

			strHTML += strChar;
		}

		if (maxLin > 0 && (i < strString.length || strLin >= maxLin))
		{
			strLen = 2;
			strHTML = strHTML.substring(0, strHTML.lastIndexOf("\n"));
			strString = strHTML.substring(strHTML.lastIndexOf("\n")+1, strHTML.length);
			strHTML = strHTML.substring(0, strHTML.lastIndexOf("\n")+1)

			for (i=0; i<strString.length && strLen < maxLen; i++)
			{
				strChar = strString.charAt(i);

				if (escape(strChar).length > 3)
					intChar = 2;
				else
					intChar = 1;

				strLen += intChar;
				strHTML += strChar;
			}

			if (strLen > maxLen)
				strHTML = strHTML.substring(0, strHTML.length-1);

			strHTML += "…";
		}

		return this.InnerEncode(strHTML);
	}
}

// ==============================================================================================================
// 	部落格的帳號
// ==============================================================================================================

function getUserBlog(Request)
{
	var strBlog = "";
	var aryPath = "//" + Request.path;

	aryPath = aryPath.split("/");

	switch (aryPath[aryPath.length-3].toUpperCase())
	{
		case "MY":

			strBlog = aryPath[aryPath.length-2];
			break;

		case "GROUP":

			strBlog = aryPath[aryPath.length-2];
			break;

		case "EDIT":

			strBlog = Request.QueryString("CN");
			break;

		default:

			strBlog = aryPath[aryPath.length-2];
			break;
	}

	this.Blog = strBlog;
}
//-->