<%
'判断是否为空
Function ChkIsNull(Str,Msg)
	IF Str="" Then
		Response.Write "<script type='text/javascript'>"
		Response.Write "alert('" & Msg & "');"
		Response.Write "window.history.back(-1);"
		Response.Write "</script>"
		Response.End()
	End IF
End Function

'判断是否为数值
Function ChkIsNumber(Str,Msg)
	IF Not Isnumeric(Str) Then
		Response.Write "<script type='text/javascript'>"
		Response.Write "alert('" & Msg & "');"
		Response.Write "window.history.back(-1);"
		Response.Write "</script>"
		Response.End()
	End IF
End Function

'判断是否为数值
Function ChkNumber(Str,Msg)
	IF Not Isnumeric(Str) Then
		Response.Write Msg
		Response.End()
	End IF
End Function

Sub Success(Msg,Url)
	Response.Write "<script type='text/javascript'>"
	Response.Write "alert('" & Msg & "');"
	Response.Write "window.location.href='" & Url & "';"
	Response.Write "</script>"
	Response.End()
End Sub

Sub IsError(Msg)
	Response.Write "<script type='text/javascript'>"
	Response.Write "alert('" & Msg & "');"
	Response.Write "window.history.back(-1);"
	Response.Write "</script>"
	Response.End()
End Sub

Sub ChkLogin(Login)
	IF Login="" OR Login=NULL Then
		Response.Write "<script type='text/javascript'>"
		Response.Write "alert('请返回到登陆页重新登陆!');"
		Response.Write "window.location.href='/WebAdmins/index.asp';"
		Response.Write "</script>"
		Response.End()
	End IF 
End Sub
'SQL过滤
Function Checkstr(Str) 
	if isnull(Str) then
	   checkStr = ""
	   exit Function
	else
	   Str=replace(Str,"'","")
	   Str=replace(Str,";","")
	   Str=replace(Str,"--","")
	   checkStr=Str
	end if
End Function

'后台各页面的分页函数
Function showpage(CurrentPage,TotalRecs,RecsPerPage,PagesCount,queryChar)
	IF TotalRecs>CurrentPage Then 	
	  Response.Write "[页次:<font class='Red'>"&RecsPerPage&"</font>/"&PagesCount&"[共"& TotalRecs &"条&nbsp;<font class='Red'>"& CurrentPage &"</font>条/页]&nbsp;&nbsp;" 	
	  IF RecsPerPage < 2 Then
	  	 Response.Write "首页&nbsp;&nbsp;"
		 Response.Write "上一页&nbsp;&nbsp;"
	  Else
	  	 Response.Write "<a href='?page=1"&queryChar&"'>首页</a>&nbsp;&nbsp;"
		 Response.Write "<a href='?page="&(RecsPerPage-1)& queryChar &"'>上一页</a>&nbsp;&nbsp;"
	  End IF 
	  
	  IF PagesCount - RecsPerPage < 1 Then
		 Response.Write "下一页&nbsp;&nbsp;"
		 Response.Write "尾页&nbsp;&nbsp;"
	  Else
		 Response.Write "<a href='?page="&(RecsPerPage+1)& queryChar &"'>下一页</a>&nbsp;&nbsp;"
		 Response.Write "<a href='?page="& PagesCount & queryChar &"'>尾页</a>&nbsp;&nbsp;"
	  End IF	  
	  
	  Response.Write "<input name='GoPage' id='GoPage' type='text' class='txt page' onkeyup=""value=value.replace(/[^\d]/g,'')"" onbeforepaste=""clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))""/>"
	%>
      <img src="../images/Go.gif" width="40" height="14" align="middle" onclick="window.location.href='?page=' + $('#GoPage').val() + '<%=queryChar%>'" />
    <%	  
	End IF	
End Function

'子分类递归
Function SubCategory(ParentID,Sapce)
	StrSql="SELECT * FROM T_Class WHERE ParentID=" & ParentID & " ORDER BY SortID DESC,ID ASC"
	SetRs Rs1,StrSql,conn,1,1
	IF Not Rs1.EOF Then
	Do While Not Rs1.EOF
	iCount = iCount + 1
	ClassName = Sapce & Rs1("ClassName")
	ClassID = Rs1("ID")
	%>	
	<option value="<%=ClassID%>" <%IF Cstr(ClassID)=Cstr(CID) Then Response.Write "Selected"%>><%=ClassName%></option>
	<%
		TempClassName = TempClassName & ClassName & ","
		TempClassID = TempClassID & ClassID & ","
		Sapce = Sapce + "&nbsp;&nbsp;&nbsp;&nbsp;"
		Call SubCategory(Rs1("ID"),Sapce)
	Rs1.movenext
	Loop
	End IF
	IF Len(Sapce)>24 Then
		Sapce = Left(Sapce,Len(Sapce)-24)
	Else
		Sapce = "&nbsp;&nbsp;&nbsp;&nbsp;"
	End IF
	DisRs Rs1
End Function

'==== 字串输出为指定的长度 ====
Function LeftStr(Str, Lennum)
  dim p_num
  dim i,x
  if strlen(str)<=lennum then
    LeftStr=str
  else
    p_num=0
    x=0
    do while not p_num > lennum-2
      x=x+1
      if asc(mid(str,x,1))<0 then
        p_num=int(p_num) + 2
      else
        p_num=int(p_num) + 1
      end if
      LeftStr=left(trim(str),x)&"..."
    loop
  end if
  response.write LeftStr
End Function

Function CutStr(Str,StrLen)
	Dim L,T,C
	l=len(Str)
	t=0
	For i=1 to l
	c=Abs(Asc(Mid(Str,i,1)))
	if c>255 then
	t=t+2
	else
	t=t+1
	end if
	if t>=StrLen - 1 then
	CutStr=left(Str,i)&"..."
	exit for
	else
	CutStr=Str
	end if
	next
	CutStr=replace(CutStr,chr(10),"")
End Function

Function StrLen(Str)
  dim p_len, xx
  p_len=0
  strlen=0
  if trim(str)<>"" then
    p_len=len(trim(str))
    for xx=1 to p_len
    if asc(mid(str,xx,1))<0 then
      strlen=int(strlen) + 2
    else
      strlen=int(strlen) + 1
    end if
    next
  end if
End Function
'===========================================
%>