<%
   dim WINNT_CHINESE 
   function strLength(str)
       ON ERROR RESUME NEXT
       dim WINNT_CHINESE
       WINNT_CHINESE    = (len("???")=3)
       if WINNT_CHINESE then
          dim l,t,c
          dim i
          l=len(str)
          t=l
          for i=1 to l
             c=asc(mid(str,i,1))
             if c<0 then c=c+65536
             if c>255 then
                t=t+1
             end if
          next
          strLength=t
       else 
          strLength=len(str)
       end if
       if err.number<>0 then err.clear
   end function 

function Strcheck(str)
	if isnull(str) then
		Strcheck = ""
		exit function 
	end if
	Strcheck=replace(str,"'","''")
	Strcheck=Trim(Strcheck)
	Strcheck = "'" & Strcheck & "'"
end function
   function isInteger(para)
       dim str
       dim l,i
       if isNUll(para) then 
          isInteger=false
          exit function
       end if
       str=cstr(para)
       if trim(str)="" then
          isInteger=false
          exit function
       end if
       l=len(str)
       for i=1 to l
           if mid(str,i,1)>"9" or mid(str,i,1)<"0" then
              isInteger=false 
              exit function
           end if
       next
       isInteger=true
       if err.number<>0 then err.clear
   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 then
		cutStr=left(str,i)&"..."
		exit for
		else
		cutStr=str
		end if
		next
	end function
Function Checkstr(str)
	str=replace(str,"'","''")
	Checkstr=str
End Function
Function PrintTrueText(tempString)

	If tempString<>"" Then
		'PrintTrueText=Replace(Replace(htmlEncode(tempString),chr(13),"<br>" & VbCrLf),"  "," &nbsp;")
		PrintTrueText=Replace(Replace(Replace(Replace(Replace(htmlEncode(tempString),VbCrLf & " ","<br>" & "&nbsp;"),VbCrLf,"<br>" & VbCrLf),"   ","&nbsp; &nbsp;"),"  ","&nbsp; "),chr(9)," &nbsp; &nbsp; &nbsp;")

		If Left(PrintTrueText,1) = chr(32) Then
			PrintTrueText = "&nbsp;" & Mid(PrintTrueText,2)
			'PrintTrueText = Replace(PrintTrueText," ","&nbsp;",1,1)
		End If
	Else
		PrintTrueText=""
	End If

End Function

Function PrintTrueTextNoHTML(tempString)

	If tempString<>"" Then
		PrintTrueTextNoHTML=Replace(Replace(tempString,chr(13),"<br>" & VbCrLf),"  "," &nbsp;")
		PrintTrueTextNoHTML=Replace(Replace(Replace(tempString,chr(13),"<br>" & VbCrLf),"  "," &nbsp;"),chr(9)," &nbsp; &nbsp; &nbsp;")
	Else
		PrintTrueTextNoHTML=""
	End If

End Function
Function htmlEncode(str)

	If len(str)>0 Then
		'htmlEncode=Replace(Replace(Replace(Replace(str,"&","&amp;"),">","&gt;"),"<","&lt;"),"""","&quot;")
		htmlEncode=Replace(Replace(Replace(str,">","&gt;"),"<","&lt;"),"""","&quot;")
	Else
		htmlEncode=str
	End If

End Function
function IsValidEmail(email)

dim names, name, i, c

'Check for valid syntax in an email address.

IsValidEmail = true
names = Split(email, "@")
if UBound(names) <> 1 then
   IsValidEmail = false
   exit function
end if
for each name in names
   if Len(name) <= 0 then
     IsValidEmail = false
     exit function
   end if
   for i = 1 to Len(name)
     c = Lcase(Mid(name, i, 1))
     if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
          IsValidEmail = false
       exit function
     end if
   next
   if Left(name, 1) = "." or Right(name, 1) = "." then
      IsValidEmail = false
      exit function
   end if
next
if InStr(names(1), ".") <= 0 then
   IsValidEmail = false
   exit function
end if
i = Len(names(1)) - InStrRev(names(1), ".")
if i <> 2 and i <> 3 then
   IsValidEmail = false
   exit function
end if
if InStr(email, "..") > 0 then
   IsValidEmail = false
end if

end function
'系统自动发信设置
sub sendmail()
			mailbody=mailbody&chr(13)&chr(10)&space(20)&"--------"
			mailbody=mailbody&chr(13)&chr(10)&space(10)&sendname

		if EmailFlag=0 then
	       Response.write "系统暂时不支持发送邮件。"
			exit sub
		else
			call jmail_msg()
		End if

if SendMailStatus="OK" then
	    Response.write "系统开启邮件功能... ..."
else
	   Response.write "系统自动投递信件失败... ..."
end if


end sub
Rem 返回时间数字，比如YYYYMMDDHHmmSS
Function GetTimeValue(DateString)

	Dim Temp,TempStr
	If isNull(DateString) Then Exit Function
	Temp = csTr(Year(DateString))
	If len(temp)<3 Then
		Temp = left(year(date),2) & temp
	End If
	TempStr = Temp
	
	Temp = csTr(month(DateString))
	If len(temp)<2 Then
		Temp = "0" & temp
	End If
	TempStr = TempStr & Temp

	Temp = csTr(day(DateString))
	If len(temp)<2 Then
		Temp = "0" & temp
	End If
	TempStr = TempStr & Temp

	Temp = csTr(Hour(DateString))
	If len(temp)<2 Then
		Temp = "0" & temp
	End If
	TempStr = TempStr & Temp

	Temp = csTr(Minute(DateString))
	If len(temp)<2 Then
		Temp = "0" & temp
	End If
	TempStr = TempStr & Temp

	Temp = csTr(Second(DateString))
	If len(temp)<2 Then
		Temp = "0" & temp
	End If
	TempStr = TempStr & Temp

	GetTimeValue = cCur(TempStr)

End Function
Function UrlEncode(str)

	If str & "" <> "" Then
		urlencode = Server.UrlEncode(str)
	Else
		UrlEncode = str
	End If

End Function

Function RestoreTime(DateString)

	If isNull(DateString) Then Exit Function
	DateString = cstr(DateString)
	If len(DateString)<8 then
		RestoreTime=DateString
	Else
		If len(DateString)<14 then
			RestoreTime = Mid(DateString,1,4) & "-" & Mid(DateString,5,2) & "-" & Mid(DateString,7,2)
		Else
			RestoreTime = Mid(DateString,1,4) & "-" & Mid(DateString,5,2) & "-" & Mid(DateString,7,2) & " " & Mid(DateString,9,2) & ":" & Mid(DateString,11,2) & ":" & Mid(DateString,13,2)
		End If
	End If

End Function
%>