<!--#include file="cls_askmain.asp"-->
<!--#include file="customtag.asp"-->
<%
Dim TextMemory,Immediate
If IsURLRewrite Then
	Immediate = False
Else
	Immediate = True
End If

Set NewAsp = New AskingMain_Cls
NewAsp.GetAsked_Setting
NewAsp.CheckUserLogin

Sub TextEcho(strEcho)
	If Immediate Then
		Response.Write (strEcho)
	Else
		TextMemory = TextMemory & strEcho
	End If
End Sub

Sub TextFlush()
	If IsURLRewrite Then
		HTML_URLRewrite
	End If
	Response.Write (TextMemory)
	TextMemory = Null
End Sub

Sub HTML_URLRewrite()
	Dim re
	Set re = new RegExp
	re.IgnoreCase = True
	re.Global = True
	re.Pattern = "\{\$InstallDir\}"
	TextMemory = re.Replace(TextMemory,NewAsp.InstallDir)
	re.Pattern = "<a(.[^>]*)showlist\.asp\?classid=(\d+)(&|&amp;)topicmode=(\d+)(&|&amp;)page=(\d+)"
	TextMemory = re.Replace(TextMemory,"<a$1showlist-$2-$4-$6")
	re.Pattern = "<a(.[^>]*)showlist\.asp\?classid=(\d+)(&|&amp;)page=(\d+)"
	TextMemory = re.Replace(TextMemory,"<a$1showlistlist-$2-$4-1")
	re.Pattern = "<a(.[^>]*)showlist\.asp\?classid=(\d+)"
	TextMemory = re.Replace(TextMemory,"<a$1showlist-$2-0-1")
	re.Pattern = "<a(.[^>]*)question\.asp\?topicid=(\d+)(&|&amp;)page=(\d+)"
	TextMemory = re.Replace(TextMemory,"<a$1question-$2-$4")
	re.Pattern = "<a(.[^>]*)question\.asp\?topicid=(\d+)"
	TextMemory = re.Replace(TextMemory,"<a$1question-$2-1")
	re.Pattern = "<a(.[^>]*)share\.asp\?topicid=(\d+)(&|&amp;)page=(\d+)"
	TextMemory = re.Replace(TextMemory,"<a$1share-$2-$4")
	re.Pattern = "<a(.[^>]*)share\.asp\?topicid=(\d+)"
	TextMemory = re.Replace(TextMemory,"<a$1share-$2-1")
	re.Pattern = "<a(.[^>]*)topasking\.asp\?mode=(\d+)(&|&amp;)page=(\d+)"
	TextMemory = re.Replace(TextMemory,"<a$1topasking-$2-$4")
	re.Pattern = "<a(.[^>]*)topasking\.asp\?mode=(\d+)"
	TextMemory = re.Replace(TextMemory,"<a$1topasking-$2-1")
	re.Pattern = "<a(.[^>]*)topasking\.asp"
	TextMemory = re.Replace(TextMemory,"<a$1topasking-0-1")

	re.Pattern = "<a(.[^>]*)topshare\.asp\?mode=(\d+)(&|&amp;)page=(\d+)"
	TextMemory = re.Replace(TextMemory,"<a$1topshare-$2-$4")
	re.Pattern = "<a(.[^>]*)topshare\.asp\?mode=(\d+)"
	TextMemory = re.Replace(TextMemory,"<a$1topshare-$2-1")
	re.Pattern = "<a(.[^>]*)topshare\.asp"
	TextMemory = re.Replace(TextMemory,"<a$1topshare-0-1")

	re.Pattern = "<a(.[^>]*)usertopic\.asp\?userid=(\d+)(&|&amp;)topicmode=(\d+)(&|&amp;)page=(\d+)"
	TextMemory = re.Replace(TextMemory,"<a$1usertopic-$2-$4-$6")
	re.Pattern = "<a(.[^>]*)usertopic\.asp\?userid=(\d+)(&|&amp;)topicmode=(\d+)"
	TextMemory = re.Replace(TextMemory,"<a$1usertopic-$2-$4-1")
	re.Pattern = "<a(.[^>]*)usertopic\.asp\?userid=(\d+)"
	TextMemory = re.Replace(TextMemory,"<a$1usertopic-$2-0-1")
	Set re=Nothing
End Sub

Function showlistpage(page, Pcount, strLink)
	Dim strTemp,i,n,m
	If strLink = "" Then strLink = "?"
	m = 8
	If page = 0 Then page = 1
	If page > 996 Then m = 6
	If page = 1 Then
		strTemp = "<kbd class=""disable""><a href=""" & strLink & "page=1"">上一页</a></kbd>"
		strTemp = strTemp & "<code>"
		strTemp = strTemp & "<a href=""" & strLink & "page=1"" class=""active"">1</a> "
	Else
		strTemp = "<kbd><a href=""" & strLink & "page=" & page-1 & """>上一页</a></kbd>"
		strTemp = strTemp & "<code>"
		strTemp = strTemp & "<a href=""" & strLink & "page=1"">1</a> "
	End If

	If Pcount > m And page > (m\2) Then
		If Pcount-page <= (m\2) Then
			n = Pcount-(m+1)
		Else
			n = Page-(m\2)
		End If
	Else
		n = 2
	End If

	If n > 2 And Pcount > 10 Then
		strTemp = strTemp & "<i>...</i> "
	End If

	If Pcount > 9 Then
		For i = n To n + m
			If i => Pcount Then Exit For
			If i > 1 Then
				If i = page Then
					strTemp = strTemp & "<a href=""" & strLink & "page=" & i & """ class=""active"">" & i & "</a> "
				Else
					strTemp = strTemp & "<a href=""" & strLink & "page=" & i & """>" & i & "</a> "
				End If
			End If
		Next
	Else
		For i = 2 To 10
			If i > Pcount Then
				strTemp = strTemp & "<a href=""#"">" & i & "</a> "
			Else
				If i = page Then
					strTemp = strTemp & "<a href=""" & strLink & "page=" & i & """ class=""active"">" & i & "</a> "
				Else
					strTemp = strTemp & "<a href=""" & strLink & "page=" & i & """>" & i & "</a> "
				End If
			End If
		Next
	End If
	If Pcount > i Then
		strTemp = strTemp & "<i>...</i> "
	End If

	If page => Pcount Then
		If Pcount > 9 Then strTemp = strTemp & "<a href=""" & strLink & "page=" & Pcount & """ class=""active"">" & Pcount & "</a> "
		strTemp = strTemp & "</code>"
		strTemp = strTemp & "<dfn class=""disable""><a href=""" & strLink & "page=" & Pcount & """>下一页</a></dfn>"
	Else
		If Pcount > 9 Then strTemp = strTemp & "<a href=""" & strLink & "page=" & Pcount & """>" & Pcount & "</a> "
		strTemp = strTemp & "</code>"
		strTemp = strTemp & "<dfn><a href=""" & strLink & "page=" & page+1 & """>下一页</a></dfn>"
	End If
	showlistpage = strTemp
End Function

Sub UpdateUserData(userid)

End Sub

%>
<script language="javascript" type="text/javascript" runat="server">
function EncodeURIComponent(str){
	return encodeURIComponent(str);
}
function DecodeURIComponent(str){
	return decodeURIComponent(str);
}
function EncodeUtf8(s1){
	var s = escape(s1);
	var sa = s.split("%");
	var retV ="";
	if(sa[0] != "")
	{
	 retV = sa[0];
	}
	for(var i = 1; i < sa.length; i ++)
	{
	   if(sa[i].substring(0,1) == "u")
	   {
		   retV += Hex2Utf8(Str2Hex(sa[i].substring(1,5))) + sa[i].substring(5,sa[i].length);

	   }
	   else retV += "%" + sa[i];
	}

	return retV;
}
function Str2Hex(s){
	var c = "";
	var n;
	var ss = "0123456789ABCDEF";
	var digS = "";
	for(var i = 0; i < s.length; i ++)
	{
	 c = s.charAt(i);
	 n = ss.indexOf(c);
	 digS += Dec2Dig(eval(n));

	}
	//return value;
	return digS;
}
function Dec2Dig(n1){
	var s = "";
	var n2 = 0;
	for(var i = 0; i < 4; i++)
	{
	 n2 = Math.pow(2,3 - i);
	 if(n1 >= n2)
	 {
		s += '1';
		n1 = n1 - n2;
	  }
	 else
	  s += '0';

	}
	return s;

}
function Dig2Dec(s){
	var retV = 0;
	if(s.length == 4)
	{
	  for(var i = 0; i < 4; i ++)
	  {
		  retV += eval(s.charAt(i)) * Math.pow(2, 3 - i);
	  }
	  return retV;
	}
	return -1;
}
function Hex2Utf8(s){
	var retS = "";
	var tempS = "";
	var ss = "";
	if(s.length == 16)
	{
	 tempS = "1110" + s.substring(0, 4);
	 tempS += "10" +  s.substring(4, 10);
	 tempS += "10" + s.substring(10,16);
	 var sss = "0123456789ABCDEF";
	 for(var i = 0; i < 3; i ++)
	 {
		retS += "%";
		ss = tempS.substring(i * 8, (eval(i)+1)*8);



		retS += sss.charAt(Dig2Dec(ss.substring(0,4)));
		retS += sss.charAt(Dig2Dec(ss.substring(4,8)));
	 }
	 return retS;
	}
	return "";
}
</script>
