<%
If Not InStr(Dvbbs.ScriptName,"loadcache")>0 Then
	Dim hasVipPlus, VipFieldName, DefaultAvatarBoy, DefaultAvatarGirl
	Dim PhotoListCount
	Dim DvbbsRS, DvbbsSQL, AvatarRs, AvatarSQL, TempRs, LoopVar
	Dim v_ErrCodes, SucMsg, v_FoundErr, NeedShowMsg
	Dim AvatarXMLDOM
	
	hasVipPlus = 0                    ' 是否安装了VIP插件，0-否，1-是
	VipFieldName = "UserVip"          ' VIP插件在Dv_User表中字段名
	DefaultAvatarBoy = "||||||14.7|13.8|12.9||11.11||10.13|9.14||||8.18|||||||"
	                                  ' 默认男性形象
	DefaultAvatarGirl = "||||||7.7|6.8|5.9||4.11||3.13|2.14||||1.18|||||||"
	                                  ' 默认女性形象
	PhotoListCount = 5
	
	NeedShowMsg = False
	
	Dim v_MySex, v_MyVip, v_MyFace, v_MyAvatar, v_MyWidth, v_MyHeight, v_MyMoney, v_MyClass, v_MyUserIsAva, v_CurSex, v_ToolByUser
	
	v_MyVip = 0
	v_MyFace = "Images/UserFace/Image1.gif"
	v_MyWidth = Dvbbs.Forum_Setting(38)
	v_MyHeight = Dvbbs.Forum_Setting(39)
	v_MyMoney = 0
	v_MyClass = "游客"
	v_MyUserIsAva = 1
	v_ToolByUser = ""
	If Not IsNull(Request("mysex")) And Request("mysex") <> "" Then
		If Request("mysex") = 0 Then
			v_CurSex = 0
			v_MyAvatar = DefaultAvatarGirl
		Else
			v_CurSex = 1
			v_MyAvatar = DefaultAvatarBoy
		End If
	Else
		v_CurSex = 2
		v_MyAvatar = DefaultAvatarBoy
	End If
	If Not Dvbbs.Forum_Setting(82) <> "0" Then
		If Not IsObject(Application(Dvbbs.CacheName & "_Avatar")) Then
			Call MakeAvatarXML
		End If
		Set AvatarXMLDOM = Application(Dvbbs.CacheName & "_Avatar").CloneNode(True)
		If Dvbbs.UserID > 0 Then
			If hasVipPlus = 1 Then
				DvbbsSQL = "Select Top 1 " & VipFieldName & ",UserAvaSetting,UserIsAva,UserGroupID From Dv_User Where UserID=" & Dvbbs.UserID
			Else
				DvbbsSQL = "Select Top 1 0 As NoUse,UserAvaSetting,UserIsAva,UserGroupID From Dv_User Where UserID=" & Dvbbs.UserID
			End If
			Set DvbbsRS = Dvbbs.Execute(DvbbsSQL)
			If Not DvbbsRS.Eof Then
				v_MySex = Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@usersex").text
				If hasVipPlus = 1 Then
					v_MyVip = DvbbsRS(0)
					If IsNull(v_MyVip) Or Not IsInteger(v_MyVip) Then
						v_MyVip = 0
					End If
				Else
					If Dvbbs.Master Or Dvbbs.SuperBoardMaster Or Dvbbs.BoardMaster Or Dvbbs.VIPUser Then
						v_MyVip = 1
					ElseIf Not Dvbbs.Execute("Select Top 1 ParentGID From Dv_UserGroups Where UserGroupID=" & DvbbsRs(3) & " And ParentGID=5").Eof Then
						v_MyVip = 1
					Else
						v_MyVip = 0
					End If
				End If
				v_MyFace = Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userface").text
				v_MyWidth = Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwidth").text
				v_MyHeight = Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userheight").text
				v_MyMoney = CLng(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwealth").text)
				If DvbbsRs(3) < 4 Then
					v_MyClass = Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userclass").text
				Else
					v_MyClass = "注册用户"
				End If
				v_MyAvatar = DvbbsRS(1)
				If InStr(v_MyAvatar, ",") > 0 Then
					v_ToolByUser = Trim(Split(v_MyAvatar, ",")(1))
					v_MyAvatar = Trim(Split(v_MyAvatar, ",")(0))
				Else
					v_ToolByUser = ""
					v_MyUserIsAva = DvbbsRS(2)
				End If
				If v_ToolByUser <> "" Then
					v_MyUserIsAva = 1
				Else
					If IsNull(v_MyUserIsAva) Then
						v_MyUserIsAva = 0
					End If
				End If
				If IsNull(v_MyAvatar) Or v_MyAvatar = "" Then
					If v_MySex = 1 Then
						v_MyAvatar = DefaultAvatarBoy
					Else
						v_MyAvatar = DefaultAvatarGirl
					End If
				End If
			End If
			DvbbsRS.Close
			Set DvbbsRS = Nothing
			Call CheckMyAvatar()
		Else
			If v_CurSex = 2 Then
				v_MySex = 1
				v_CurSex = 1
			Else
				v_MySex = v_CurSex
			End If
		End If
		If v_CurSex = 2 Then v_CurSex = v_MySex
	ElseIf v_CurSex = 2 Then
		v_CurSex = 1
	End If
End If

Function SqlDateAddString(Number, Date)
	If IsSqlDataBase = 1 Then
		SqlDateAddString = "DateAdd(d," & Number & "," & Date & ")"
	Else
		SqlDateAddString = "DateAdd('d'," & Number & "," & Date & ")"
	End If
End Function

Function SqlDateDiffString(Date1, Date2)
	If IsSqlDataBase = 1 Then
		SqlDateDiffString = "DateDiff(d," & Date1 & "," & Date2 & ")"
	Else
		SqlDateDiffString = "DateDiff('d'," & Date1 & "," & Date2 & ")"
	End If
End Function

Function SqlConcateString(String1, String2, String3)
	If IsSqlDataBase = 1 Then
		SqlConcateString = "Cast(" & String1 & " as varchar(10)) + Cast(" & String2 & " as varchar(10)) + Cast(" & String3 & " as varchar(10))"
	Else
		SqlConcateString = String1 & " & " & String2 & " & " & String3
	End If
End Function	

Sub CheckMyAvatar()
	Dim OldMyAvatar, NeedUpdate
	Dim NotifyMsg

	NeedUpdate = False
	If Request.Cookies("Period_" & Dvbbs.UserID) = "" Or Not IsDate(Request.Cookies("Period_" & Dvbbs.UserID)) Then
		NeedUpdate = True
	ElseIf DateDiff("d", Request.Cookies("Period_" & Dvbbs.UserID), Now()) > 0 Then
		NeedUpdate = True
	End If
	If NeedUpdate Then
		OldMyAvatar = v_MyAvatar
		NotifyMsg = UndressPeriod(v_MyAvatar, v_MySex, True)
		NotifyMsg = NotifyMsg & DeletePeriod()
		NotifyMsg = NotifyMsg & NotifyPeriod()
		NotifyMsg = NotifyMsg & UpdatePeriod()
		If v_MyAvatar <> OldMyAvatar Then Dvbbs.Execute ("Update Dv_User Set UserAvaSetting='" & v_MyAvatar & "' Where UserID=" & Dvbbs.UserID)
		NotifyMsg = NotifyMsg & DeletePhoto()
		Response.Cookies("Period_" & Dvbbs.UserID).Expires = Date() + 1
		Response.Cookies("Period_" & Dvbbs.UserID) = Year(Now()) & "-" & Month(Now()) & "-" & Day(Now()) & " " & Hour(Now()) & ":" & Minute(Now()) & ":" & Second(Now())
		Response.Cookies("Period_" & Dvbbs.UserID).Path = Dvbbs.CookiePath
		If NotifyMsg <> "" Then
			Call Dv_SendMsg(Dvbbs.MemberName, Dvbbs.Forum_Info(0), "形象系统通知", NotifyMsg)
			NeedShowMsg = True
		End If
	End If
End Sub

Function UndressPeriod(CurAvatarStr, CurAvatarSex, CheckPeriod)
	Dim AvatarStr, AvatarSex
	Dim AvatarSplit, ToolIDList
	Dim i, TempSplit, Rs, RetMsg, TempStr
	
	AvatarStr = CurAvatarStr
	AvatarSex = CurAvatarSex
	If IsNull(AvatarStr) Or AvatarStr = "" Then
		If AvatarSex = 1 Then
			AvatarStr = DefaultAvatarBoy
		Else
			AvatarStr = DefaultAvatarGirl
		End If
	Else
		AvatarSplit = Split(AvatarStr, "|")
		If UBound(AvatarSplit) <> 24 Then
			If AvatarSex = 1 Then
				AvatarStr = DefaultAvatarBoy
			Else
				AvatarStr = DefaultAvatarGirl
			End If
		Else
			AvatarStr = ""
			ToolIDList = ""
			For i = 0 To 24
				If AvatarSplit(i) <> "" Then
					TempSplit = Split(AvatarSplit(i), ".")
					If CheckPeriod Then
						If CInt(TempSplit(0)) > 20 Then
							Set Rs = Dvbbs.Plus_Execute("Select Fixdate,Period,Type,ItemID From Dv_Plus_Avatar_MyItems Where ItemID=" & TempSplit(0) & "And UserName='" & Dvbbs.MemberName & "'")
							If Rs.Eof Then
								AvatarSplit(i) = GetDefaultItemID(AvatarSex, i + 1)
							ElseIf v_ToolByUser <> "" And DateDiff("d", Rs(0), Now()) >= Rs(1) And Rs(1) > 0 And Rs(2) = 6 Then
								AvatarSplit(i) = GetDefaultItemID(AvatarSex, i + 1)
								If Not InStr(ToolIDList & "," , "," & Rs(3) & ",") > 0 Then
									ToolIDList = ToolIDList & "," & Rs(3)
								End If
							ElseIf v_ToolByUser = "" And DateDiff("d", Rs(0), Now()) >= Rs(1) And Rs(1) > 0 Then
								AvatarSplit(i) = GetDefaultItemID(AvatarSex, i + 1)
							End If
							Rs.Close
						End If
					End If
				End If
				If i > 0 Then AvatarStr = AvatarStr & "|"
				AvatarStr = AvatarStr & AvatarSplit(i)
			Next
			If ToolIDList <> "" Then
				ToolIDList = Mid(ToolIDList, 2)
				Set Rs = Dvbbs.Plus_Execute("Select i.Name,m.ID From Dv_Plus_Avatar_MyItems m Inner Join Dv_Plus_Avatar_Items i On m.ItemID=i.ID Where i.Class=6 And " & SqlDateDiffString("m.FixDate",SqlNowString) & ">=m.Period And m.Period>0 And m.UserName='" & Dvbbs.MemberName & "' And m.ItemID In (" & ToolIDList & ")")
				If Not Rs.Eof Then
					RetMsg = RetMsg & "以下整人道具已经过期，系统已经自动将它们从您的身上移除：" & vbCrLf
					TempStr = ""
					Do While Not Rs.Eof
						Dvbbs.Plus_Execute ("Delete From Dv_Plus_Avatar_MyItems Where ID=" & Rs(1))
						If TempStr <> "" Then TempStr = TempStr & "，"
						TempStr = TempStr & "《" & Rs(0) & "》"
						Rs.MoveNext
					Loop
					TempStr = TempStr & "。"
					RetMsg = RetMsg & TempStr & vbCrLf
				End If
				Rs.Close
			End If
		End If
	End If
	CurAvatarStr = AvatarStr
	UndressPeriod = RetMsg
End Function

Function GetDefaultItemID(CurSex, LayerNo)
	Select Case LayerNo
	Case 7
		If CurSex = 1 Then
			GetDefaultItemID = Split(DefaultAvatarBoy, "|")(6)
		Else
			GetDefaultItemID = Split(DefaultAvatarGirl, "|")(6)
		End If
	Case 8
		If CurSex = 1 Then
			GetDefaultItemID = Split(DefaultAvatarBoy, "|")(7)
		Else
			GetDefaultItemID = Split(DefaultAvatarGirl, "|")(7)
		End If
	Case 9
		If CurSex = 1 Then
			GetDefaultItemID = Split(DefaultAvatarBoy, "|")(8)
		Else
			GetDefaultItemID = Split(DefaultAvatarGirl, "|")(8)
		End If
	Case 11
		If CurSex = 1 Then
			GetDefaultItemID = Split(DefaultAvatarBoy, "|")(10)
		Else
			GetDefaultItemID = Split(DefaultAvatarGirl, "|")(10)
		End If
	Case 13
		If CurSex = 1 Then
			GetDefaultItemID = Split(DefaultAvatarBoy, "|")(12)
		Else
			GetDefaultItemID = Split(DefaultAvatarGirl, "|")(12)
		End If
	Case 14
		If CurSex = 1 Then
			GetDefaultItemID = Split(DefaultAvatarBoy, "|")(13)
		Else
			GetDefaultItemID = Split(DefaultAvatarGirl, "|")(13)
		End If
	Case 18
		If CurSex = 1 Then
			GetDefaultItemID = Split(DefaultAvatarBoy, "|")(17)
		Else
			GetDefaultItemID = Split(DefaultAvatarGirl, "|")(17)
		End If
	Case Else
		GetDefaultItemID = ""
	End Select
End Function

Function isInteger(Para)
	isInteger = False
	If Not (IsNull(Para) Or Trim(Para) = "" Or Not IsNumeric(Para)) Then
		If InStr(1, Para, ".") > 0 Or InStr(1, Para, "-") > 0 Then
			isInteger = False
		Else
			isInteger = True
		End If
	End If
End Function

Sub ShowSuc(SucMsg, LastPage)
	Dim TempStr

	Dvbbs.Head
	TempStr = template.html(16)
	TempStr = Replace(TempStr,"{$sucmsg}",SucMsg)
	If Request.ServerVariables("HTTP_REFERER") = "" Then
		TempStr = Replace(TempStr,"{$returnurl}","javascript:history.back()")
	Else
		TempStr = Replace(TempStr,"{$returnurl}",Request.ServerVariables("HTTP_REFERER"))
	End If
	If LastPage Then
		TempStr = Replace(TempStr,"{$LastPage}","true")
	Else
		TempStr = Replace(TempStr,"{$LastPage}","false")
	End If
	If LCase(Dvbbs.ScriptName) = "plus_avatar_photosave.asp" And (Request("action") = "SaveRequest" Or Request("action") = "PhotoMyself" Or Request("action") = "ConfirmRequest" Or Request("action") = "SaveDesign" Or Request("action") = "AcceptDesign") Or Request("action") = "DeletePhoto" Then
		TempStr = Replace(TempStr,"style=""width:98%""","")
	End If
	Response.Write TempStr
End Sub

Sub ShowSucWithURL(SucMsg, URLStr, ReturnMsg)
	Dim TempStr

	Dvbbs.Head
	TempStr = template.html(18)
	TempStr = Replace(TempStr,"{$sucmsg}",SucMsg)
	TempStr = Replace(TempStr,"{$returnurl}", URLStr)
	TempStr = Replace(TempStr,"{$ReturnMsg}",ReturnMsg)
	If LCase(Dvbbs.ScriptName) = "plus_avatar_photosave.asp" And (Request("action") = "SaveRequest" Or Request("action") = "PhotoMyself" Or Request("action") = "ConfirmRequest" Or Request("action") = "SaveDesign" Or Request("action") = "AcceptDesign") Or Request("action") = "DeletePhoto" Then
		TempStr = Replace(TempStr,"style=""width:98%""","")
	End If
	Response.Write TempStr
End Sub

Sub ShowErr(LastPage)
	Dim Show_Errmsg
	
	Dvbbs.Head
	Show_Errmsg = template.html(17)
	v_ErrCodes = Replace(v_ErrCodes, "{$color}", Dvbbs.MainSetting(1))
	Show_Errmsg = Replace(Show_Errmsg, "{$color}", Dvbbs.MainSetting(1))
	Show_Errmsg = Replace(Show_Errmsg, "{$errtitle}", Dvbbs.Forum_Info(0) & "-" & Dvbbs.Stats)
	Show_Errmsg = Replace(Show_Errmsg, "{$action}", Dvbbs.Stats)
	Show_Errmsg = Replace(Show_Errmsg, "{$ErrString}", v_ErrCodes)
	If LastPage Then
		Show_Errmsg = Replace(Show_Errmsg,"{$LastPage}","true")
	Else
		Show_Errmsg = Replace(Show_Errmsg,"{$LastPage}","false")
	End If
	If LCase(Dvbbs.ScriptName) = "plus_avatar_photosave.asp" And (Request("action") = "SaveRequest" Or Request("action") = "PhotoMyself" Or Request("action") = "ConfirmRequest" Or Request("action") = "SaveDesign" Or Request("action") = "AcceptDesign") Or Request("action") = "DeletePhoto" Then
		Show_Errmsg = Replace(Show_Errmsg,"style=""width:98%""","")
	End If
	Response.Write Show_Errmsg
End Sub

Function IsEmotionItem(ItemID)
	With AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes
		Select Case ItemID
		Case .getNamedItem("BoyEmotXiItemNo").Text, .getNamedItem("BoyEmotNuItemNo").Text, .getNamedItem("BoyEmotAiItemNo").Text, .getNamedItem("BoyEmotLeItemNo").Text
			IsEmotionItem = True
		Case .getNamedItem("GirlEmotXiItemNo").Text, .getNamedItem("GirlEmotNuItemNo").Text, .getNamedItem("GirlEmotAiItemNo").Text, .getNamedItem("GirlEmotLeItemNo").Text
			IsEmotionItem = True
		Case Else
			IsEmotionItem = False
		End Select
	End With
End Function

Function IsDefaultItem(ItemID)
	Dim DefaultSplit, i
	
	If CLng(ItemID) < 20 Then
		IsDefaultItem = True
	Else
		DefaultSplit = Split(DefaultAvatarBoy, "|")
		For i = 0 To UBound(DefaultSplit)
			If DefaultSplit(i) <> "" Then
				If CLng(ItemID) = Split(DefaultSplit(i), ".")(0) Then
					IsDefaultItem = True
					Exit For
				End If
			End If
		Next
		If i <= UBound(DefaultSplit) Then Exit Function
		DefaultSplit = Split(DefaultAvatarGirl, "|")
		For i = 0 To UBound(DefaultSplit)
			If DefaultSplit(i) <> "" Then
				If CLng(ItemID) = Split(DefaultSplit(i), ".")(0) Then
					IsDefaultItem = True
					Exit For
				End If
			End If
		Next
	End If
End Function

Sub Dv_SendMsg(Incept, Sender, Title, Content)
	
	Dim MsgSQL
	
	MsgSQL = "insert into Dv_Message (incept,sender,title,content,sendtime,flag,issend) values ('" & Incept & "','" & Sender & "','" & Title & "','" & Content & "'," & SqlNowString & ",0,1)"
	Dvbbs.Execute (MsgSQL)
	Update_User_Msg (Incept)
End Sub

Sub UPDATE_User_Msg(UserName)
	Dim msginfo, i, UP_UserInfo, newmsg
	newmsg = newincept(UserName)
	If newmsg > 0 Then
		msginfo = newincept(UserName) & "||" & inceptid(1, UserName) & "||" & inceptid(2, UserName)
	Else
		msginfo = "0||0||null"
	End If
	Dvbbs.Execute ("UPDATE Dv_User Set UserMsg='" & Dvbbs.CheckStr(msginfo) & "' WHERE username='" & Dvbbs.CheckStr(UserName) & "'")
	If UserName = Dvbbs.MemberName Then
		Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@usermsg").text=msginfo
	Else
		Call Dvbbs.NeedUpdateList(UserName, 1)
	End If
End Sub


Function newincept(iusername)
	Dim Rs
	
	Rs = Dvbbs.Execute("SELECT Count(id) FROM Dv_Message WHERE flag=0 And issend=1 And DelR=0 And incept='" & iusername & "'")
	newincept = Rs(0)
	Set Rs = Nothing
	If IsNull(newincept) Then newincept = 0
End Function

Function inceptid(stype, iusername)
	Dim Rs
	
	Set Rs = Dvbbs.Execute("SELECT top 1 id,sender FROM Dv_Message WHERE flag=0 And issend=1 And DelR=0 And incept='" & iusername & "'")
	If Not Rs.EOF Then
		If stype = 1 Then
			inceptid = Rs(0)
		Else
			inceptid = Rs(1)
		End If
	Else
		If stype = 1 Then
			inceptid = 0
		Else
			inceptid = "null"
		End If
	End If
	Set Rs = Nothing
End Function

Sub MakeAvatarXML()
	Dim XMLDOM
	
	Set XMLDOM = Server.CreateObject("msxml2.FreeThreadedDOMDocument"& MsxmlVersion)
	Call LoadAvatarInfo(XMLDOM)
	Call LoadAvatarType(XMLDOM)
	Application.Lock
	Set Application(Dvbbs.CacheName & "_Avatar") = XMLDOM.CloneNode(True)
	Application.UnLock
	Set XMLDOM = Nothing
End Sub

Sub LoadAvatarInfo(XMLDOM)
	Dim Node, SubNode
	Dim LocalPic, PicPath

	XMLDOM.appendChild (XMLDOM.createProcessingInstruction("xml", "version=""1.0"" encoding=""gb2312"""))
	XMLDOM.appendChild (XMLDOM.createElement("Plus_Avatar"))
	XMLDOM.documentElement.attributes.setNamedItem(XMLDOM.createNode(2, "ProductType", "")).Text = "Dv_Plus"
	XMLDOM.documentElement.attributes.setNamedItem(XMLDOM.createNode(2, "ProductID", "")).Text = "Avatar"
	XMLDOM.documentElement.attributes.setNamedItem(XMLDOM.createNode(2, "ProductName", "")).Text = "虚拟形象"
	XMLDOM.documentElement.attributes.setNamedItem(XMLDOM.createNode(2, "Version", "")).Text = "2.6"
	XMLDOM.documentElement.attributes.setNamedItem(XMLDOM.createNode(2, "Copyright", "")).Text = "LaoMiao"
	XMLDOM.documentElement.attributes.setNamedItem(XMLDOM.createNode(2, "ForumName", "")).Text = Dvbbs.Forum_Info(0)
	XMLDOM.documentElement.attributes.setNamedItem(XMLDOM.createNode(2, "ForumURL", "")).Text = Dvbbs.Forum_Info(1)

	LocalPic = 0                      ' 0-使用腾讯图片 1-使用本地图片
	If LocalPic = 1 Then
		PicPath = "Show/"
		                                ' 本地形象目录
	Else
		PicPath = "http://qqshow-item.qq.com/"
		                                ' 远程形象URL
	End If

	Set Node = XMLDOM.createNode(1, "AvatarInfo", "")
	XMLDOM.documentElement.appendChild (Node)
	Set SubNode = XMLDOM.createNode(2, "PhotoDefaultFontName", "")
	SubNode.Text = "宋体"          ' 照片默认的字体名称
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "PhotoDefaultFontSize", "")
	SubNode.Text = "12"            ' 照片默认的字体大小
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "PhotoDefaultFontBold", "")
	SubNode.Text = "0"             ' 照片默认的字体是否黑体 (0-否  1-是)
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "PhotoDefaultFontItalic", "")
	SubNode.Text = "0"             ' 照片默认的字体是否斜体 (0-否  1-是)
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "PhotoDefaultFontColor", "")
	SubNode.Text = "#ffffff"       ' 照片默认的字体颜色
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "AvatarWidth", "")
	SubNode.Text = 140             ' 形象的宽度
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "AvatarHeight", "")
	SubNode.Text = 226             ' 形象的高度
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "PhotoWidth", "")
	SubNode.Text = 280             ' 照片的宽度
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "PhotoHeight", "")
	SubNode.Text = 226             ' 照片的高度
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "DefaultAvatarBoy", "")
	SubNode.Text = DefaultAvatarBoy ' 默认的男性形象
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "DefaultAvatarGirl", "")
	SubNode.Text = DefaultAvatarGirl ' 默认的女性形象
	Node.attributes.setNamedItem (SubNode)
	If LCase(Request("action")) <> "xml" Then
		Set SubNode = XMLDOM.createNode(2, "LocalPic", "")
		SubNode.Text = LocalPic
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PicPath", "")
		SubNode.Text = PicPath
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "CanCreateImage", "")
		SubNode.Text = 1                 ' 生成照片的组件(0-无，1-ASPPainter)
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "SampleWidth", "")
		SubNode.Text = 84              ' 普通货品图片的宽度
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "SampleHeight", "")
		SubNode.Text = 84              ' 普通货品图片的高度
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "BigSampleWidth", "")
		SubNode.Text = 140             ' 大货品图片的宽度
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "BigSampleHeight", "")
		SubNode.Text = 140             ' 大货品图片的高度
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "InnerLeft1", "")
		SubNode.Text = 38              ' 脸部形象左缩进
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "InnerTop1", "")
		SubNode.Text = 38              ' 脸部形象上缩进
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "InnerWidth1", "")
		SubNode.Text = 64              ' 脸部形象的宽度
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "InnerHeight1", "")
		SubNode.Text = 64              ' 脸部形象的高度
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "InnerLeft2", "")
		SubNode.Text = 28              ' 上半身形象左缩进
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "InnerTop2", "")
		SubNode.Text = 38              ' 上半身形象上缩进
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "InnerWidth2", "")
		SubNode.Text = 84              ' 上半身形象的宽度
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "InnerHeight2", "")
		SubNode.Text = 120             ' 上半身形象的高度
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "EmotLayerStr", "")
		SubNode.Text = "11_13_14"      ' 表情的层代码
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "BoyEmotXiItemNo", "")
		SubNode.Text = 1035            ' 男性的“喜”表情编号
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "BoyEmotNuItemNo", "")
		SubNode.Text = 1033            ' 男性的“怒”表情编号
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "BoyEmotAiItemNo", "")
		SubNode.Text = 1034            ' 男性的“哀”表情编号
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "BoyEmotLeItemNo", "")
		SubNode.Text = 1365            ' 男性的“乐”表情编号
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "GirlEmotXiItemNo", "")
		SubNode.Text = 1031            ' 女性的“喜”表情编号
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "GirlEmotNuItemNo", "")
		SubNode.Text = 1029            ' 女性的“怒”表情编号
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "GirlEmotAiItemNo", "")
		SubNode.Text = 1030            ' 女性的“哀”表情编号
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "GirlEmotLeItemNo", "")
		SubNode.Text = 1377            ' 女性的“乐”表情编号
		Node.attributes.setNamedItem (SubNode)
	End If
	Call LoadAvatarConfig(XMLDOM, Node)
	Set SubNode = Nothing
	Set Node = Nothing
End Sub

Sub LoadAvatarConfig(XMLDOM, CurrentNode)
	Dim Rs, Node, Avatar_Setting
	
	Set Rs = Dvbbs.Plus_Execute("Select Top 1 * From Dv_Plus_Avatar_Config")
	If Not Rs.Eof Then
		Avatar_Setting = Split(Rs("Avatar_Setting"), ",")
		Avatar_Setting(21) = Replace(Avatar_Setting(21), "|", ",")
	Else
		Avatar_Setting = Split("10,100,10,8,1,90,5,5,5,10,3,50,5,20,10,5,1,5,100,2,1,405,UserAvatar/,10,10,3,3,5,10,1000,500,300,1000,500,300,500,1,1,500,200,0,,,,0,0,0,0,0,0,0", ",")
	End If
	Rs.Close
	Set Node = XMLDOM.createNode(2, "PhotoPath", "")
	Node.Text = Avatar_Setting(22)
	CurrentNode.attributes.setNamedItem (Node)
	Set Node = XMLDOM.createNode(2, "AllowRemoteCreatePhoto", "")
	Node.Text = Avatar_Setting(37)
	CurrentNode.attributes.setNamedItem (Node)
	Set Node = XMLDOM.createNode(2, "NormalRemoteCreatePrice", "")
	Node.Text = Avatar_Setting(38)
	CurrentNode.attributes.setNamedItem (Node)
	Set Node = XMLDOM.createNode(2, "VIPRemoteCreatePrice", "")
	Node.Text = Avatar_Setting(39)
	CurrentNode.attributes.setNamedItem (Node)
	If LCase(Request("action")) <> "xml" Then
		Set Node = XMLDOM.createNode(2, "CartLength", "")
		Node.Text = Avatar_Setting(0)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "FavoriteLength", "")
		Node.Text = Avatar_Setting(1)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "ItemListCount", "")
		Node.Text = Avatar_Setting(2)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "BigItemListCount", "")
		Node.Text = Avatar_Setting(3)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "BiggestItemListCount", "")
		Node.Text = Avatar_Setting(44)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "IsAllow", "")
		Node.Text = Avatar_Setting(4)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "AllowFace", "")
		Node.Text = Avatar_Setting(36)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "AutoDeleteDays", "")
		Node.Text = Avatar_Setting(5)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "AutoDeleteNotifyDays", "")
		Node.Text = Avatar_Setting(6)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "SendFeeRate", "")
		Node.Text = Avatar_Setting(7)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "SellFeeRate", "")
		Node.Text = Avatar_Setting(8)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "LowestSellPrice", "")
		Node.Text = Avatar_Setting(9)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "LowPrice", "")
		Node.Text = Avatar_Setting(10)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "FixOneDayFeeRate", "")
		Node.Text = Avatar_Setting(11)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "FixForeverFeeTimes", "")
		Node.Text = Avatar_Setting(12)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "NormalPhotoPrice", "")
		Node.Text = Avatar_Setting(13)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "VIPPhotoPrice", "")
		Node.Text = Avatar_Setting(14)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "PhotoPeriod", "")
		Node.Text = Avatar_Setting(15)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "DefPhotoStatus", "")
		Node.Text = Avatar_Setting(16)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "MaxPhotoUserCount", "")
		Node.Text = Avatar_Setting(17)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "PhotoBgSize", "")
		Node.Text = Avatar_Setting(18)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "NormalUploadPrice", "")
		Node.Text = Avatar_Setting(19)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "VIPUploadPrice", "")
		Node.Text = Avatar_Setting(20)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "AccoutermentSubTypeList", "")
		Node.Text = Avatar_Setting(21)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "CreatePhotoMode", "")
		Node.Text = Avatar_Setting(40)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "RemotePhotoServer", "")
		Node.Text = Avatar_Setting(41)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "RemotePhotoUserName", "")
		Node.Text = Avatar_Setting(42)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "RemotePhotoPassword", "")
		Node.Text = Avatar_Setting(43)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "MatchPeriod", "")
		Node.Text = Avatar_Setting(23)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "MinPersonCount", "")
		Node.Text = Avatar_Setting(24)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "MaxOpusCount", "")
		Node.Text = Avatar_Setting(25)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "MaxVoteCount", "")
		Node.Text = Avatar_Setting(26)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "VoteMoney", "")
		Node.Text = Avatar_Setting(27)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "MinVoteCount", "")
		Node.Text = Avatar_Setting(28)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "MatchMoney11", "")
		Node.Text = Avatar_Setting(29)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "MatchMoney12", "")
		Node.Text = Avatar_Setting(30)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "MatchMoney13", "")
		Node.Text = Avatar_Setting(31)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "MatchMoney21", "")
		Node.Text = Avatar_Setting(32)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "MatchMoney22", "")
		Node.Text = Avatar_Setting(33)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "MatchMoney23", "")
		Node.Text = Avatar_Setting(34)
		CurrentNode.attributes.setNamedItem (Node)
		Set Node = XMLDOM.createNode(2, "MatchMoney0", "")
		Node.Text = Avatar_Setting(35)
		CurrentNode.attributes.setNamedItem (Node)
	End If
	Set Node = Nothing
End Sub

Sub LoadPhotoItem(XMLDOM)
	Dim Node
	
	Set Node = XMLDOM.createNode(1, "PhotoBackgroundList", "")
	XMLDOM.documentElement.appendChild (Node)
	Call LoadPhotoElement(XMLDOM, Node, 0, "")
	Set Node = XMLDOM.createNode(1, "PhotoBodyBackList", "")
	XMLDOM.documentElement.appendChild (Node)
	Call LoadPhotoElement(XMLDOM, Node, 1, "")
	Set Node = XMLDOM.createNode(1, "PhotoBodyFrontList", "")
	XMLDOM.documentElement.appendChild (Node)
	Call LoadPhotoElement(XMLDOM, Node, 2, "")
	Set Node = XMLDOM.createNode(1, "PhotoForegroundList", "")
	XMLDOM.documentElement.appendChild (Node)
	Call LoadPhotoElement(XMLDOM, Node, 3, "")
	Set Node = XMLDOM.createNode(1, "PhotoAccoutermentList", "")
	XMLDOM.documentElement.appendChild (Node)
	Call LoadPhotoElement(XMLDOM, Node, 4, XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("AccoutermentSubTypeList").Text)
	Set Node = Nothing
End Sub

Sub LoadPhotoElement(XMLDOM, CurrentNode, ElementType, ElementParm)
	Dim Rs, ChildNode

	Select Case ElementType
	Case 0
		Set Rs = Dvbbs.Plus_Execute("Select ID,Name,Content,Vip From Dv_Plus_Avatar_Items Where Class=99 Order By ID Desc")
	Case 1
		Set Rs = Dvbbs.Plus_Execute("Select ID,Name,Content,Vip From Dv_Plus_Avatar_Items Where Class=98 Order By ID Desc")
	Case 2
		Set Rs = Dvbbs.Plus_Execute("Select ID,Name,Content,Vip From Dv_Plus_Avatar_Items Where Class=97 Order By ID Desc")
	Case 3
		Set Rs = Dvbbs.Plus_Execute("Select ID,Name,Content,Vip From Dv_Plus_Avatar_Items Where Class=96 Order By ID Desc")
	Case 4
		Set Rs = Dvbbs.Plus_Execute("Select ID,Name,Content,Vip From Dv_Plus_Avatar_Items Where Type In (" & ElementParm & ") Order By ID Desc")
	End Select
	Do While Not Rs.EOF
		Select Case ElementType
		Case 0
			Set ChildNode = XMLDOM.createNode(1, "PhotoBackground", "")
		Case 1
			Set ChildNode = XMLDOM.createNode(1, "PhotoBodyBack", "")
		Case 2
			Set ChildNode = XMLDOM.createNode(1, "PhotoBodyFront", "")
		Case 3
			Set ChildNode = XMLDOM.createNode(1, "PhotoForeground", "")
		Case 4
			Set ChildNode = XMLDOM.createNode(1, "PhotoAccouterment", "")
		End Select
		ChildNode.attributes.setNamedItem(XMLDOM.createNode(2, "ID", "")).Text = Rs(0)
		ChildNode.attributes.setNamedItem(XMLDOM.createNode(2, "Name", "")).Text = Rs(1)
		ChildNode.attributes.setNamedItem(XMLDOM.createNode(2, "Content", "")).Text = Rs(2)
		ChildNode.attributes.setNamedItem(XMLDOM.createNode(2, "VIP", "")).Text = Rs(3)
		CurrentNode.appendChild (ChildNode)
		Rs.MoveNext
	Loop
	Rs.Close
	Set ChildNode = Nothing
End Sub

Sub LoadAvatarType(XMLDOM)
	Dim Node, SubNode
	Dim Rs, SubRs, isFirst, SubTypeIDList, SubTypeNameList, TempRs, TempSubTypeIDList, TempSubTypeNameList, TempFirst

	Set Node = XMLDOM.createNode(1, "AvatarTypeList", "")
	XMLDOM.documentElement.appendChild (Node)
	Set SubNode = XMLDOM.createNode(1, "AvatarType", "")
	SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "TypeID", "")).Text = 0
	SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "TypeName", "")).Text = GetTypeName(100)
	SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "FirstSubTypeID", "")).Text = 100
	SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "SubTypeIDList", "")).Text = "100$$200$$300$$400$$700$$500$$600$$800"
	SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "SubTypeNameList", "")).Text = GetSubTypeName(100) & "$$" & GetSubTypeName(200) & "$$" & GetSubTypeName(300) & "$$" & GetSubTypeName(400) & "$$" & GetSubTypeName(700) & "$$" & GetSubTypeName(500) & "$$" & GetSubTypeName(600) & "$$" & GetSubTypeName(800)
	Node.appendChild (SubNode)
	Set Rs = Dvbbs.Plus_Execute("Select ID,TypeName From Dv_Plus_Avatar_Type Where Visible=1 Order By Orders")
	Do While Not Rs.EOF
		Set SubRs = Dvbbs.Plus_Execute("Select MyType,SubTypeName,ID From Dv_Plus_Avatar_SubType Where Visible=1 And ParentSubType=0 And TypeID=" & Rs(0) & " Order By Orders")
		If Not SubRs.EOF Then
			Set SubNode = XMLDOM.createNode(1, "AvatarType", "")
			isFirst = True
			SubTypeIDList = ""
			SubTypeNameList = ""
			Do While Not SubRs.EOF
				If Not isFirst Then
					SubTypeIDList = SubTypeIDList & "$$"
					SubTypeNameList = SubTypeNameList & "$$"
				Else
					SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "FirstSubTypeID", "")).Text = SubRs(0)
					isFirst = False
				End If
				Set TempRs = Dvbbs.Plus_Execute("Select MyType,SubTypeName From Dv_Plus_Avatar_SubType Where Visible=1 And ParentSubType=" & SubRs(2) & " And TypeID=" & Rs(0) & " Order By Orders")
				If Not TempRs.EOF Then
					TempSubTypeIDList = SubRs(0)
					TempSubTypeNameList = SubRs(1)
					Do While Not TempRs.EOF
						TempSubTypeIDList = TempSubTypeIDList & "||" & TempRs(0)
						TempSubTypeNameList = TempSubTypeNameList & "||" & TempRs(1)
						TempRs.MoveNext
					Loop
					SubTypeIDList = SubTypeIDList & TempSubTypeIDList
					SubTypeNameList = SubTypeNameList & TempSubTypeNameList
				Else
					SubTypeIDList = SubTypeIDList & SubRs(0)
					SubTypeNameList = SubTypeNameList & SubRs(1)
				End If
				TempRs.Close
				Set TempRs = Nothing
				SubRs.MoveNext
			Loop
			SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "TypeID", "")).Text = Rs(0)
			SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "TypeName", "")).Text = Rs(1)
			SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "SubTypeIDList", "")).Text = SubTypeIDList
			SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "SubTypeNameList", "")).Text = SubTypeNameList
			Node.appendChild (SubNode)
		End If
		SubRs.Close
		Set SubRs = Nothing
		Rs.MoveNext
	Loop
	Rs.Close
	Set Rs = Nothing
	Set SubNode = XMLDOM.createNode(1, "AvatarType", "")
	SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "TypeID", "")).Text = 96
	SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "TypeName", "")).Text = GetTypeName(196)
	SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "FirstSubTypeID", "")).Text = 196
	SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "SubTypeIDList", "")).Text = "196$$296$$396$$496$$596"
	SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "SubTypeNameList", "")).Text = GetSubTypeName(196) & "$$" & GetSubTypeName(296) & "$$" & GetSubTypeName(396) & "$$" & GetSubTypeName(496) & "$$" & GetSubTypeName(596)
	Node.appendChild (SubNode)
	Set SubNode = XMLDOM.createNode(1, "AvatarType", "")
	SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "TypeID", "")).Text = 97
	SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "TypeName", "")).Text = GetTypeName(197)
	SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "FirstSubTypeID", "")).Text = 197
	SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "SubTypeIDList", "")).Text = "197$$297$$397$$497$$597$$697"
	SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "SubTypeNameList", "")).Text = GetSubTypeName(197) & "$$" & GetSubTypeName(297) & "$$" & GetSubTypeName(397) & "$$" & GetSubTypeName(497) & "$$" & GetSubTypeName(597) & "$$" & GetSubTypeName(697)
	Node.appendChild (SubNode)
	'===== 形象大赛 =====
	'Set SubNode = XMLDOM.createNode(1, "AvatarType", "")
	'SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "TypeID", "")).Text = 94
	'SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "TypeName", "")).Text = GetTypeName(194)
	'SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "FirstSubTypeID", "")).Text = 194
	'SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "SubTypeIDList", "")).Text = "194$$294$$394$$494$$594"
	'SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "SubTypeNameList", "")).Text = GetSubTypeName(194) & "$$" & GetSubTypeName(294) & "$$" & GetSubTypeName(394) & "$$" & GetSubTypeName(494) & "$$" & GetSubTypeName(594)
	'Node.appendChild (SubNode)
	Set SubNode = XMLDOM.createNode(1, "AvatarType", "")
	SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "TypeID", "")).Text = 95
	SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "TypeName", "")).Text = GetTypeName(195)
	SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "FirstSubTypeID", "")).Text = 195
	SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "SubTypeIDList", "")).Text = "195$$295$$395$$495$$595$$695"
	SubNode.attributes.setNamedItem(XMLDOM.createNode(2, "SubTypeNameList", "")).Text = GetSubTypeName(195) & "$$" & GetSubTypeName(295) & "$$" & GetSubTypeName(395) & "$$" & GetSubTypeName(495) & "$$" & GetSubTypeName(595) & "$$" & GetSubTypeName(695)
	Node.appendChild (SubNode)
	Set SubNode = Nothing
End Sub

Sub GetCurrentAvatarXML(XMLDOM)
	Dim Node, SubNode
	Dim CurSubTypeIDList, CurSubTypeNameList, URLStr

	CurSubTypeIDList = ""
	CurSubTypeNameList = ""
	Set Node = XMLDOM.documentElement.selectSingleNode("/Plus_Avatar/AvatarTypeList/AvatarType[@TypeID='" & CurType & "']")
	CurSubTypeIDList = Node.attributes.getNamedItem("SubTypeIDList").Text
	CurSubTypeNameList = Node.attributes.getNamedItem("SubTypeNameList").Text
	Set Node = XMLDOM.createNode(1, "CurrentInfo", "")
	XMLDOM.documentElement.appendChild (Node)
	Set SubNode = XMLDOM.createNode(2, "CurTypeID", "")
	SubNode.Text = CurType
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "CurShopID", "")
	SubNode.Text = ShopID
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "CurTypeName", "")
	SubNode.Text = CurTypeName
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "CurSubTypeName", "")
	SubNode.Text = CurSubTypeName
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "CurSex", "")
	SubNode.Text = Sex
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "CurMySex", "")
	SubNode.Text = v_CurSex
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "CurSubTypeIDList", "")
	SubNode.Text = CurSubTypeIDList
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "CurSubTypeNameList", "")
	SubNode.Text = CurSubTypeNameList
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "CurIsBig", "")
	SubNode.Text = isBig
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "CurPageSize", "")
	SubNode.Text = AvatarPageSize
	Node.attributes.setNamedItem (SubNode)
	URLStr = ""
	If Request("mysex") <> "" Then URLStr = URLStr & "&mysex=" & v_MySex
	If Sex <> "" Then URLStr = URLStr & "&sex=" & Sex Else URLStr = URLStr & "&sex=2"
	If Request("shopid") <> "" Then URLStr = URLStr & "&shopid=" & ShopID
	If Request("search_str") <> "" Then URLStr = URLStr & "&search_str=" & Server.URLEncode(Trim(Request("search_str")))
	If Request("selgender") <> "" And Request("selgender") <> "0" Then URLStr = URLStr & "&selgender=" & Server.URLEncode(Trim(Request("selgender")))
	If Request("selprice_l") <> "" Then URLStr = URLStr & "&selprice_l=" & Server.URLEncode(Trim(Request("selprice_l")))
	If Request("selprice_h") <> "" Then URLStr = URLStr & "&selprice_h=" & Server.URLEncode(Trim(Request("selprice_h")))
	If Request("selperiod_l") <> "" Then URLStr = URLStr & "&selperiod_l=" & Server.URLEncode(Trim(Request("selperiod_l")))
	If Request("selperiod_h") <> "" Then URLStr = URLStr & "&selperiod_h=" & Server.URLEncode(Trim(Request("selperiod_h")))
	If Request("selflag") <> "" And Request("selflag") <> "0" Then URLStr = URLStr & "&selflag=" & Server.URLEncode(Trim(Request("selflag")))
	If URLStr <> "" Then URLStr = Mid(URLStr, 2)
	Set SubNode = XMLDOM.createNode(2, "CurURLStr", "")
	SubNode.Text = "?" & URLStr
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(1, "AvatarItemList", "")
	XMLDOM.documentElement.appendChild (SubNode)
	Set Node = XMLDOM.createNode(1, "Item", "")
	Node.attributes.setNamedItem (XMLDOM.createNode(2, "ItemID", ""))
	Node.attributes.setNamedItem (XMLDOM.createNode(2, "ItemNo", ""))
	Node.attributes.setNamedItem (XMLDOM.createNode(2, "ItemName", ""))
	Node.attributes.setNamedItem (XMLDOM.createNode(2, "ItemSex", ""))
	Node.attributes.setNamedItem (XMLDOM.createNode(2, "ItemLayer", ""))
	Node.attributes.setNamedItem (XMLDOM.createNode(2, "ItemInfo1", ""))
	Node.attributes.setNamedItem (XMLDOM.createNode(2, "ItemInfo2", ""))
	Node.attributes.setNamedItem (XMLDOM.createNode(2, "ItemInfo3", ""))
	Node.attributes.setNamedItem (XMLDOM.createNode(2, "ItemInfo4", ""))
	Node.attributes.setNamedItem (XMLDOM.createNode(2, "ItemInfo5", ""))
	Node.attributes.setNamedItem (XMLDOM.createNode(2, "ItemInfo6", ""))
	Node.attributes.setNamedItem (XMLDOM.createNode(2, "ItemClass", ""))
	Node.attributes.setNamedItem (XMLDOM.createNode(2, "URLEncode", ""))
	Node.attributes.setNamedItem (XMLDOM.createNode(2, "isHas", ""))
	Node.attributes.setNamedItem (XMLDOM.createNode(2, "isSellByMyself", ""))
	Node.attributes.setNamedItem (XMLDOM.createNode(2, "hasFavorite", ""))
	SubNode.appendChild (Node)
	Set Node = Nothing
	Set SubNode = Nothing
End Sub

Sub GetCurrentPhotoXML(XMLDOM)
	Dim Node, SubNode
	Dim CurSubTypeIDList, CurSubTypeNameList, URLStr
	Dim Rs

	CurSubTypeIDList = ""
	CurSubTypeNameList = ""
	Set Node = XMLDOM.documentElement.selectSingleNode("/Plus_Avatar/AvatarTypeList/AvatarType[@TypeID='" & CurType & "']")
	CurSubTypeIDList = Node.attributes.getNamedItem("SubTypeIDList").Text
	CurSubTypeNameList = Node.attributes.getNamedItem("SubTypeNameList").Text
	Set Node = XMLDOM.createNode(1, "CurrentInfo", "")
	XMLDOM.documentElement.appendChild (Node)
	Set SubNode = XMLDOM.createNode(2, "CurTypeID", "")
	SubNode.Text = CurType
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "CurShopID", "")
	SubNode.Text = ShopID
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "CurTypeName", "")
	SubNode.Text = CurTypeName
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "CurSubTypeName", "")
	SubNode.Text = CurSubTypeName
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "CurSex", "")
	SubNode.Text = v_CurSex
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "CurMySex", "")
	SubNode.Text = v_CurSex
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "CurSubTypeIDList", "")
	SubNode.Text = CurSubTypeIDList
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "CurSubTypeNameList", "")
	SubNode.Text = CurSubTypeNameList
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "CurPhotoID", "")
	SubNode.Text = PhotoID
	Node.attributes.setNamedItem (SubNode)
	If ShopID = 197 Or ((ShopID = 297 Or ShopID = 397 Or ShopID = 497) And PhotoID <> "") Then
		Call LoadPhotoInfo(XMLDOM, PhotoID, ShopID)
	ElseIf PhotoID = "" And (ShopID = 297 Or ShopID = 397 Or ShopID = 497) Then
		Set SubNode = XMLDOM.createNode(2, "CurPageSize", "")
		SubNode.Text = PhotoPageSize
		Node.attributes.setNamedItem (SubNode)
		URLStr = ""
		If Request("mysex") <> "" Then URLStr = URLStr & "&mysex=" & v_MySex
		If Request("shopid") <> "" Then URLStr = URLStr & "&shopid=" & ShopID
		If URLStr <> "" Then URLStr = Mid(URLStr, 2)
		Set SubNode = XMLDOM.createNode(2, "CurURLStr", "")
		SubNode.Text = "?" & URLStr
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(1, "PhotoList", "")
		XMLDOM.documentElement.appendChild (SubNode)
		Set Node = XMLDOM.createNode(1, "Photo", "")
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoID", ""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoName", ""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoSponsor", ""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "URLEncode", ""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoStatus", ""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "AddDate", ""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "EndDate", ""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoUserCount", ""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "IsConfirmed", ""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "IsDesigned", ""))
		SubNode.appendChild (Node)
	ElseIf ShopID = 597 Or ShopID = 697 Then
		Set SubNode = XMLDOM.createNode(2, "CurPageSize", "")
		SubNode.Text = PhotoPageSize
		Node.attributes.setNamedItem (SubNode)
		URLStr = ""
		If Request("mysex") <> "" Then URLStr = URLStr & "&mysex=" & v_MySex
		If Request("shopid") <> "" Then URLStr = URLStr & "&shopid=" & ShopID
		If Request("search_sponsor") <> "" Then URLStr = URLStr & "&search_sponsor=" & Server.URLEncode(Trim(Request("search_sponsor")))
		If Request("selusercount_l") <> "" Then URLStr = URLStr & "&selusercount_l=" & Server.URLEncode(Trim(Request("selusercount_l")))
		If Request("selusercount_h") <> "" Then URLStr = URLStr & "&selusercount_h=" & Server.URLEncode(Trim(Request("selusercount_h")))
		If Request("selurl") <> "" And Request("selurl") <> "0" Then URLStr = URLStr & "&selurl=" & Server.URLEncode(Trim(Request("selurl")))
		If Request("selupload") <> "" And Request("selupload") <> "0" Then URLStr = URLStr & "&selupload=" & Server.URLEncode(Trim(Request("selupload")))
		If URLStr <> "" Then URLStr = Mid(URLStr, 2)
		Set SubNode = XMLDOM.createNode(2, "CurURLStr", "")
		SubNode.Text = "?" & URLStr
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(1, "PhotoList", "")
		XMLDOM.documentElement.appendChild (SubNode)
		Set Node = XMLDOM.createNode(1, "Photo", "")
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoID", ""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoName", ""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoDate", ""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoParticipator", ""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoURL", ""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoStatus", ""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoIsOwner", ""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoUserCount", ""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoBackground", ""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoUploadFile",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoBodyBack",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoBodyFront",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoForeground",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoBgWidth",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoBgHeight",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoNameLeft",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoNameTop",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoNameFontName",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoNameFontSize",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoNameFontBold",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoNameFontItalic",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoNameFontColor",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoNameDirection",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoDate",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoDateLeft",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoDateTop",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoDateFontName",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoDateFontSize",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoDateFontBold",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoDateFontItalic",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoDateFontColor",""))
		Node.attributes.setNamedItem (XMLDOM.createNode(2, "PhotoDateDirection",""))
		SubNode.appendChild (Node)
	End If
	Set Node = Nothing
	Set SubNode = Nothing
End Sub

Sub LoadPhotoInfo(XMLDom, PhotoID, ShopID)
	Dim Node, SubNode, Rs
	
	Set Node = XMLDOM.createNode(1, "CurrentPhotoInfo", "")
	XMLDOM.documentElement.appendChild (Node)
	If ShopID = 197 Then
		Set SubNode = XMLDOM.createNode(2, "PhotoID", "")
		SubNode.Text = ""
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoName", "")
		SubNode.Text = ""
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoExplain", "")
		SubNode.Text = ""
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoSponsor", "")
		SubNode.Text = Dvbbs.MemberName
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoUserCount", "")
		SubNode.Text = 1
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoParticipator", "")
		SubNode.Text = Request("UserName")
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoStatus", "")
		SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("DefPhotoStatus").text
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoDate", "")
		SubNode.Text = Year(Now()) & "-" & Month(Now()) & "-" & Day(Now())
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoBackground", "")
		SubNode.Text = ""
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoUploadFile", "")
		SubNode.Text = ""
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoBgWidth", "")
		SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoWidth").text
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoBgHeight", "")
		SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoHeight").text
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoBodyBack", "")
		SubNode.Text = ""
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoBodyFront", "")
		SubNode.Text = ""
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoForeground", "")
		SubNode.Text = ""
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoIsOwner", "")
		SubNode.Text = "1"
		Node.attributes.setNamedItem (SubNode)
	ElseIf PhotoID <> "" Then
		Set Rs = Dvbbs.Plus_Execute("Select * From Dv_Plus_Avatar_Photo Where ID=" & PhotoID)
		Set SubNode = XMLDOM.createNode(2, "PhotoID", "")
		SubNode.Text = ReplaceHTML(Rs("ID"))
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoName", "")
		SubNode.Text = ReplaceHTML(Rs("Name"))
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoExplain", "")
		SubNode.Text = Dvbbs.ChkBadWords(Rs("Content"))
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoSponsor", "")
		SubNode.Text = Rs("FromUser")
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoUserCount", "")
		SubNode.Text = Rs("Child")
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoParticipator", "")
		Set AvatarRs = Dvbbs.Plus_Execute("Select UserName From Dv_Plus_Avatar_PhotoUser Where PhotoID=" & PhotoID & " And UserName<>'" & Rs("FromUser") & "'")
		If Not AvatarRs.Eof Then
			SubNode.Text = AvatarRs.GetString(, -1, "", ",", "")
			SubNode.Text = Left(SubNode.Text, Len(SubNode.Text) - 1)
		Else
			SubNode.Text = ""
		End If
		AvatarRs.Close
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoStatus", "")
		SubNode.Text = Rs("Status")
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoDate", "")
		SubNode.Text = Year(Rs("AddDate")) & "-" & Month(Rs("AddDate")) & "-" & Day(Rs("AddDate"))
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoBackground", "")
		Set AvatarRs = Dvbbs.Plus_Execute("Select Top 1 ID,Content From Dv_Plus_Avatar_Items Where ID=" & Rs("Background"))
		If Not AvatarRs.Eof Then
			SubNode.Text = AvatarRs.GetString(, 1, ".", "", "")
		Else
			SubNode.Text = ""
		End If
		AvatarRs.Close
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoUploadFile", "")
		If IsNull(Rs("UploadFile")) Then
			SubNode.Text = ""
		Else
			SubNode.Text = Rs("UploadFile")
		End If
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoBgWidth", "")
		SubNode.Text = Rs("Width")
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoBgHeight", "")
		SubNode.Text = Rs("Height")
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoBodyBack", "")
		Set AvatarRs = Dvbbs.Plus_Execute("Select Top 1 ID,Content From Dv_Plus_Avatar_Items Where ID=" & Rs("BackBody"))
		If Not AvatarRs.Eof Then
			SubNode.Text = AvatarRs.GetString(, 1, ".", "", "")
		Else
			SubNode.Text = ""
		End If
		AvatarRs.Close
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoBodyFront", "")
		Set AvatarRs = Dvbbs.Plus_Execute("Select Top 1 ID,Content From Dv_Plus_Avatar_Items Where ID=" & Rs("ForeBody"))
		If Not AvatarRs.Eof Then
			SubNode.Text = AvatarRs.GetString(, 1, ".", "", "")
		Else
			SubNode.Text = ""
		End If
		AvatarRs.Close
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoForeground", "")
		Set AvatarRs = Dvbbs.Plus_Execute("Select Top 1 ID,Content From Dv_Plus_Avatar_Items Where ID=" & Rs("Foreground"))
		If Not AvatarRs.Eof Then
			SubNode.Text = AvatarRs.GetString(, 1, ".", "", "")
		Else
			SubNode.Text = ""
		End If
		AvatarRs.Close
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoIsOwner", "")
		If LCase(Rs("FromUser")) = LCase(Dvbbs.MemberName) Then
			SubNode.Text = "1"
		Else
			SubNode.Text = "0"
		End If
		Node.attributes.setNamedItem (SubNode)
	End If
	If ShopID = 197 Or ((ShopID = 297 Or ShopID = 397) And PhotoID <> "") Then
		Set SubNode = XMLDOM.createNode(2, "PhotoIsDesigned", "")
		SubNode.Text = "0"
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoIsFinished", "")
		SubNode.Text = "0"
		Node.attributes.setNamedItem (SubNode)
	ElseIf PhotoID <> "" Then
		Set SubNode = XMLDOM.createNode(2, "PhotoIsDesigned", "")
		If IsNull(Rs("FinishDate")) Then
			SubNode.Text = "0"
		Else
			SubNode.Text = "1"
		End If
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoIsFinished", "")
		If IsNull(Rs("Finished")) Then
			SubNode.Text = "0"
		Else
			If Rs("Finished") = 0 Then
				SubNode.Text = "0"
			Else
				SubNode.Text = "1"
			End If
		End If
		Node.attributes.setNamedItem (SubNode)
	End If
	If Node.attributes.getNamedItem("PhotoIsDesigned").text = "0" Then
		Set SubNode = XMLDOM.createNode(2, "PhotoNameLeft", "")
		SubNode.Text = 3
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoNameWidth", "")
		If ShopID = 497 Then
			SubNode.Text = CInt(XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoDefaultFontSize").text) * IntUp(Dvbbs.strLength(Rs("Name")) / 1.4)
		Else
			SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("AvatarWidth").text
		End If
		Node.Attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoNameTop", "")
		SubNode.Text = CInt(XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoHeight").text) - 40
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoNameFontName", "")
		SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoDefaultFontName").text
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoNameFontSize", "")
		SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoDefaultFontSize").text
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoNameFontBold", "")
		SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoDefaultFontBold").text
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoNameFontItalic", "")
		SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoDefaultFontItalic").text
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoNameFontColor", "")
		SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoDefaultFontColor").text
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoNameDirection", "")
		SubNode.Text = 0
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoDateLeft", "")
		SubNode.Text = 3
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoDateWidth", "")
		If ShopID = 497 Then
			SubNode.Text = CInt(XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoDefaultFontSize").text) * IntUp(Dvbbs.strLength(Year(Rs("AddDate")) & "-" & Month(Rs("AddDate")) & "-" & Day(Rs("AddDate"))) / 1.4)
		Else
			SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("AvatarWidth").text
		End If
		Node.Attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoDateTop", "")
		SubNode.Text = CInt(XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoHeight").text) - 20
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoDateFontName", "")
		SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoDefaultFontName").text
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoDateFontSize", "")
		SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoDefaultFontSize").text
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoDateFontBold", "")
		SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoDefaultFontBold").text
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoDateFontItalic", "")
		SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoDefaultFontItalic").text
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoDateFontColor", "")
		SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoDefaultFontColor").text
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoDateDirection", "")
		SubNode.Text = 0
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoURL", "")
		SubNode.Text = ""
		Node.attributes.setNamedItem (SubNode)
	Else
		Set SubNode = XMLDOM.createNode(2, "PhotoNameLeft", "")
		SubNode.Text = Rs("PhotoNameLeft")
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoNameWidth", "")
		SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("AvatarWidth").text
		Node.Attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoNameTop", "")
		SubNode.Text = Rs("PhotoNameTop")
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoNameFontName", "")
		SubNode.Text = Rs("PhotoNameFont")
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoNameFontSize", "")
		SubNode.Text = Rs("PhotoNameSize")
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoNameFontBold", "")
		SubNode.Text = Rs("PhotoNameBold")
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoNameFontItalic", "")
		SubNode.Text = Rs("PhotoNameItalic")
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoNameFontColor", "")
		If IsNull(Rs("PhotoNameColor")) Then
			SubNode.Text = ""
		Else
			SubNode.Text = Rs("PhotoNameColor")
		End IF
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoNameDirection", "")
		SubNode.Text = Rs("PhotoNameDirection")
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoDateLeft", "")
		SubNode.Text = Rs("DateLeft")
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoDateWidth", "")
		SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("AvatarWidth").text
		Node.Attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoDateTop", "")
		SubNode.Text = Rs("DateTop")
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoDateFontName", "")
		SubNode.Text = Rs("DateFont")
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoDateFontSize", "")
		SubNode.Text = Rs("DateSize")
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoDateFontBold", "")
		SubNode.Text = Rs("DateBold")
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoDateFontItalic", "")
		SubNode.Text = Rs("DateItalic")
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoDateFontColor", "")
		If IsNull(Rs("DateColor")) Then
			SubNode.Text = ""
		Else
			SubNode.Text = Rs("DateColor")
		End If
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoDateDirection", "")
		SubNode.Text = Rs("DateDirection")
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PhotoURL", "")
		If IsNull(Rs("URL")) Then
			SubNode.Text = ""
		Else
			SubNode.Text = Rs("URL")
		End If
		Node.attributes.setNamedItem (SubNode)
	End If
	If (ShopID = 297 Or ShopID = 397 Or ShopID = 497) And PhotoID <> "" Then Rs.Close
	Call LoadPhotoUserInfo(XMLDOM, Node, PhotoID, ShopID)
	If PhotoID = "" Then
		Call LoadPhotoAccoutermentInfo(XMLDOM, Node, 0)
	Else
		Call LoadPhotoAccoutermentInfo(XMLDOM, Node, PhotoID)
	End If
	Set Node = Nothing
	Set SubNode = Nothing
End Sub

Sub LoadPhotoAccoutermentInfo(XMLDOM, CurrentNode, PhotoID)
	Dim Rs, i, TempRs
	Dim Node, SubNode
	
	For i = 1 To 6
		Set Rs = Dvbbs.Plus_Execute("Select * From Dv_Plus_Avatar_Accouterment Where PhotoID=" & PhotoID & " And SeqNo=" & i)
		If Not Rs.Eof Then
			Set Node = XMLDOM.createNode(1, "PhotoAccouterment", "")
			CurrentNode.appendChild (Node)	
			Set SubNode = XMLDOM.createNode(2, "SeqNo", "")
			SubNode.Text = i
			Node.Attributes.setNamedItem (SubNode)
			Set SubNode = XMLDOM.createNode(2, "ItemID", "")
			Set TempRs = Dvbbs.Plus_Execute("Select Top 1 ID,Content From Dv_Plus_Avatar_Items Where ID=" & Rs("ItemID"))
			If Not TempRs.Eof Then
				SubNode.Text = TempRs.GetString(, 1, ".", "", "")
			Else
				SubNode.Text = ""
			End If
			TempRs.Close
			Node.Attributes.setNamedItem (SubNode)
			Set SubNode = XMLDOM.createNode(2, "OuterLeft", "")
			SubNode.Text = Rs("OuterLeft")
			Node.Attributes.setNamedItem (SubNode)
			Set SubNode = XMLDOM.createNode(2, "OuterTop", "")
			SubNode.Text = Rs("OuterTop")
			Node.Attributes.setNamedItem (SubNode)
			Set SubNode = XMLDOM.createNode(2, "OuterWidth", "")
			SubNode.Text = Rs("OuterWidth")
			Node.Attributes.setNamedItem (SubNode)
			Set SubNode = XMLDOM.createNode(2, "OuterHeight", "")
			SubNode.Text = Rs("OuterHeight")
			Node.Attributes.setNamedItem (SubNode)
			Set SubNode = XMLDOM.createNode(2, "InnerLeft", "")
			SubNode.Text = Rs("InnerLeft")
			Node.Attributes.setNamedItem (SubNode)
			Set SubNode = XMLDOM.createNode(2, "InnerTop", "")
			SubNode.Text = Rs("InnerTop")
			Node.Attributes.setNamedItem (SubNode)
			Set SubNode = XMLDOM.createNode(2, "InnerWidth", "")
			SubNode.Text = Rs("InnerWidth")
			Node.Attributes.setNamedItem (SubNode)
			Set SubNode = XMLDOM.createNode(2, "InnerHeight", "")
			SubNode.Text = Rs("InnerHeight")
			Node.Attributes.setNamedItem (SubNode)
			Set SubNode = XMLDOM.createNode(2, "Direction", "")
			SubNode.Text = Rs("Direction")
			Node.Attributes.setNamedItem (SubNode)
		Else
			Set Node = XMLDOM.createNode(1, "PhotoAccouterment", "")
			CurrentNode.appendChild (Node)	
			Set SubNode = XMLDOM.createNode(2, "SeqNo", "")
			SubNode.Text = i
			Node.Attributes.setNamedItem (SubNode)
			Set SubNode = XMLDOM.createNode(2, "ItemID", "")
			SubNode.Text = ""
			Node.Attributes.setNamedItem (SubNode)
			Set SubNode = XMLDOM.createNode(2, "OuterLeft", "")
			SubNode.Text = IntUp((CInt(CurrentNode.attributes.getNamedItem("PhotoBgWidth").text) - CInt(XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("AvatarWidth").text)) / 2) * ((i - 1) mod 3)
			Node.Attributes.setNamedItem (SubNode)
			Set SubNode = XMLDOM.createNode(2, "OuterTop", "")
			SubNode.Text = 0
			Node.Attributes.setNamedItem (SubNode)
			Set SubNode = XMLDOM.createNode(2, "OuterWidth", "")
			SubNode.Text = CInt(XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("AvatarWidth").text)
			Node.Attributes.setNamedItem (SubNode)
			Set SubNode = XMLDOM.createNode(2, "OuterHeight", "")
			SubNode.Text = CInt(XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("AvatarHeight").text)
			Node.Attributes.setNamedItem (SubNode)
			Set SubNode = XMLDOM.createNode(2, "InnerLeft", "")
			SubNode.Text = 0
			Node.Attributes.setNamedItem (SubNode)
			Set SubNode = XMLDOM.createNode(2, "InnerTop", "")
			SubNode.Text = 0
			Node.Attributes.setNamedItem (SubNode)
			Set SubNode = XMLDOM.createNode(2, "InnerWidth", "")
			SubNode.Text = CInt(XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("AvatarWidth").text)
			Node.Attributes.setNamedItem (SubNode)
			Set SubNode = XMLDOM.createNode(2, "InnerHeight", "")
			SubNode.Text = CInt(XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("AvatarHeight").text)
			Node.Attributes.setNamedItem (SubNode)
			Set SubNode = XMLDOM.createNode(2, "Direction", "")
			SubNode.Text = 0
			Node.Attributes.setNamedItem (SubNode)
		End If
		Rs.Close
	Next
	Set Node = Nothing
	Set SubNode = Nothing
End Sub

Sub LoadPhotoUserInfo(XMLDOM, CurrentNode, PhotoID, ShopID)
	Dim Rs, Flag
	Dim PhotoUserCount
	Dim Node, SubNode
	Dim StepPos, LeftPos, i
	Dim AvatarWidth, AvatarHeight, PhotoWidth, PhotoHeight

	If ShopID = 197 Or ShopID = 297 Or ShopID = 397 Or ShopID = 497 Then
		AvatarWidth = CInt(XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("AvatarWidth").text)
		AvatarHeight = CInt(XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("AvatarHeight").text)
		PhotoWidth = CInt(XMLDOM.documentElement.selectSingleNode("CurrentPhotoInfo").attributes.getNamedItem("PhotoBgWidth").text)
		PhotoHeight = CInt(XMLDOM.documentElement.selectSingleNode("CurrentPhotoInfo").attributes.getNamedItem("PhotoBgHeight").text)
	
		If ShopID = 197 Then
			PhotoUserCount = 1
		Else
			PhotoUserCount = Dvbbs.Plus_Execute("Select Count(*) From Dv_Plus_Avatar_PhotoUser Where PhotoID=" & PhotoID & " And Confirmed=1")(0)
			If ShopID = 397 Then
				If Dvbbs.Plus_Execute("Select Top 1 PhotoID From Dv_Plus_Avatar_PhotoUser Where PhotoID=" & PhotoID & " And Confirmed=1 And UserName='" & Dvbbs.MemberName & "'").Eof Then
					PhotoUserCount = PhotoUserCount + 1
				End If
			End If
		End If
		StepPos = AvatarWidth \ 2
		If PhotoWidth + StepPos < AvatarWidth * PhotoUserCount - (PhotoUserCount - 1) * StepPos Then
			LeftPos = - AvatarWidth \ 4
			StepPos = (AvatarWidth * PhotoUserCount - (PhotoWidth + AvatarWidth \ 2)) / (PhotoUserCount - 1)
		Else
			LeftPos = ((PhotoWidth + AvatarWidth \ 2) - (AvatarWidth * PhotoUserCount - (PhotoUserCount - 1) * StepPos)) \ 2 - AvatarWidth \ 4
		End If
	End If
	i = 0
	If PhotoID = "" And (ShopID = 197 Or ShopID = 297 Or ShopID = 397 Or ShopID = 497) Then
		Set Node = XMLDOM.createNode(1, "PhotoUser", "")
		CurrentNode.appendChild (Node)	
		Call LoadOnePhotoUser(XMLDOM, Node, i, Dvbbs.MemberName, XMLDOM.documentElement.selectSingleNode("CurrentUserInfo").attributes.getNamedItem("MyAvatar").text, LeftPos, StepPos, AvatarWidth, AvatarHeight, PhotoWidth, PhotoHeight)
	Else
		If ShopID = 197 Or ShopID = 297 Or ShopID = 397 Or ShopID = 497 Then
			Set Rs = Dvbbs.Plus_Execute("Select * From Dv_Plus_Avatar_PhotoUser Where PhotoID=" & PhotoID & " And Confirmed=1")
		Else
			Set Rs = Dvbbs.Plus_Execute("Select * From Dv_Plus_Avatar_PhotoUser Where PhotoID=" & PhotoID & " Order By ConfirmTime")
		End If
		Do While Not Rs.Eof
			Set Node = XMLDOM.createNode(1, "PhotoUser", "")
			CurrentNode.appendChild (Node)	
			Flag = True
			If ShopID = 197 Or ShopID = 297 Or ShopID = 397 Or ShopID = 497 Then
				If CurrentNode.attributes.getNamedItem("PhotoIsDesigned").text = "0" Then
					Flag = False
				End If
			End If
			If Not Flag Then
				Call LoadOnePhotoUser(XMLDOM, Node, i, Rs("UserName"), Rs("UserAvaSetting"), LeftPos, StepPos, AvatarWidth, AvatarHeight, PhotoWidth, PhotoHeight)
			Else
				Set SubNode = XMLDOM.createNode(2, "UserName", "")
				SubNode.Text = Rs("UserName")
				Node.Attributes.setNamedItem (SubNode)
				Set SubNode = XMLDOM.createNode(2, "UserAvaSetting", "")
				SubNode.Text = Rs("UserAvaSetting")
				Node.Attributes.setNamedItem (SubNode)
				Set SubNode = XMLDOM.createNode(2, "LayerNo", "")
				SubNode.Text = Rs("LayerNo")
				Node.Attributes.setNamedItem (SubNode)
				Set SubNode = XMLDOM.createNode(2, "AvatarOuterLeft", "")
				SubNode.Text = Rs("OuterLeft")
				Node.Attributes.setNamedItem (SubNode)
				Set SubNode = XMLDOM.createNode(2, "AvatarOuterTop", "")
				SubNode.Text = Rs("OuterTop")
				Node.Attributes.setNamedItem (SubNode)
				Set SubNode = XMLDOM.createNode(2, "AvatarOuterWidth", "")
				SubNode.Text = Rs("OuterWidth")
				Node.Attributes.setNamedItem (SubNode)
				Set SubNode = XMLDOM.createNode(2, "AvatarOuterHeight", "")
				SubNode.Text = Rs("OuterHeight")
				Node.Attributes.setNamedItem (SubNode)
				Set SubNode = XMLDOM.createNode(2, "AvatarInnerLeft", "")
				SubNode.Text = Rs("InnerLeft")
				Node.Attributes.setNamedItem (SubNode)
				Set SubNode = XMLDOM.createNode(2, "AvatarInnerTop", "")
				SubNode.Text = Rs("InnerTop")
				Node.Attributes.setNamedItem (SubNode)
				Set SubNode = XMLDOM.createNode(2, "AvatarInnerWidth", "")
				SubNode.Text = Rs("InnerWidth")
				Node.Attributes.setNamedItem (SubNode)
				Set SubNode = XMLDOM.createNode(2, "AvatarInnerHeight", "")
				SubNode.Text = Rs("InnerHeight")
				Node.Attributes.setNamedItem (SubNode)
				Set SubNode = XMLDOM.createNode(2, "AvatarDirection", "")
				SubNode.Text = Rs("Direction")
				Node.Attributes.setNamedItem (SubNode)
				Set SubNode = XMLDOM.createNode(2, "UserNameLeft", "")
				SubNode.Text = Rs("NameLeft")
				Node.Attributes.setNamedItem (SubNode)
				Set SubNode = XMLDOM.createNode(2, "UserNameWidth", "")
				SubNode.Text = Rs("NameSize") * IntUp(Dvbbs.strLength(Rs("UserName")) / 1.4)
				Node.Attributes.setNamedItem (SubNode)
				Set SubNode = XMLDOM.createNode(2, "UserNameTop", "")
				SubNode.Text = Rs("NameTop")
				Node.Attributes.setNamedItem (SubNode)
				Set SubNode = XMLDOM.createNode(2, "UserNameFont", "")
				SubNode.Text = Rs("NameFont")
				Node.Attributes.setNamedItem (SubNode)
				Set SubNode = XMLDOM.createNode(2, "UserNameSize", "")
				SubNode.Text = Rs("NameSize")
				Node.Attributes.setNamedItem (SubNode)
				Set SubNode = XMLDOM.createNode(2, "UserNameBold", "")
				SubNode.Text = Rs("NameBold")
				Node.Attributes.setNamedItem (SubNode)
				Set SubNode = XMLDOM.createNode(2, "UserNameItalic", "")
				SubNode.Text = Rs("NameItalic")
				Node.Attributes.setNamedItem (SubNode)
				Set SubNode = XMLDOM.createNode(2, "UserNameColor", "")
				If IsNull(Rs("NameColor")) Then
					SubNode.Text = ""
				Else
					SubNode.Text = Rs("NameColor")
				End If
				Node.Attributes.setNamedItem (SubNode)
				Set SubNode = XMLDOM.createNode(2, "UserNameDirection", "")
				SubNode.Text = Rs("NameDirection")
				Node.Attributes.setNamedItem (SubNode)
			End If
			i = i + 1
			Rs.MoveNext
		Loop
		Rs.Close
		If ShopID = 397 Then
			If Dvbbs.Plus_Execute("Select Top 1 PhotoID From Dv_Plus_Avatar_PhotoUser Where PhotoID=" & PhotoID & " And Confirmed=1 And UserName='" & Dvbbs.MemberName & "'").Eof Then
				Set Node = XMLDOM.createNode(1, "PhotoUser", "")
				CurrentNode.appendChild (Node)	
				Call LoadOnePhotoUser(XMLDOM, Node, i, Dvbbs.MemberName, XMLDOM.documentElement.selectSingleNode("CurrentUserInfo").attributes.getNamedItem("MyAvatar").text, LeftPos, StepPos, AvatarWidth, AvatarHeight, PhotoWidth, PhotoHeight)
			End If
		End IF
	End if
	Set Node = Nothing
	Set SubNode = Nothing
End Sub

Sub LoadOnePhotoUser(XMLDOM, Node, nIndex, UserName, UserAvaSetting, LeftPos, StepPos, AvatarWidth, AvatarHeight, PhotoWidth, PhotoHeight)
	Dim SubNode
	
	Set SubNode = XMLDOM.createNode(2, "UserName", "")
	SubNode.Text = UserName
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "UserAvaSetting", "")
	SubNode.Text = UserAvaSetting
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "LayerNo", "")
	SubNode.Text = nIndex * 30 + 10
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "AvatarOuterLeft", "")
	SubNode.Text = Int(LeftPos + (AvatarWidth - StepPos) * nIndex)
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "AvatarOuterTop", "")
	SubNode.Text = (PhotoHeight - AvatarHeight) \ 2
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "AvatarOuterWidth", "")
	SubNode.Text = AvatarWidth
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "AvatarOuterHeight", "")
	SubNode.Text = AvatarHeight
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "AvatarInnerLeft", "")
	SubNode.Text = 0
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "AvatarInnerTop", "")
	SubNode.Text = 0
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "AvatarInnerWidth", "")
	SubNode.Text = AvatarWidth
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "AvatarInnerHeight", "")
	SubNode.Text = AvatarHeight
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "AvatarDirection", "")
	SubNode.Text = 0
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "UserNameLeft", "")
	SubNode.Text = Int(LeftPos + (AvatarWidth - StepPos) * nIndex) + (CInt(XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("AvatarWidth").text) - CInt(XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoDefaultFontSize").text) * IntUp(Dvbbs.strLength(UserName) / 2)) \ 2
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "UserNameWidth", "")
	SubNode.Text = CInt(XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoDefaultFontSize").text) * IntUp(Dvbbs.strLength(UserName) / 1.4)
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "UserNameTop", "")
	SubNode.Text = 3
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "UserNameFont", "")
	SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoDefaultFontName").text
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "UserNameSize", "")
	SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoDefaultFontSize").text
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "UserNameBold", "")
	SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoDefaultFontBold").text
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "UserNameItalic", "")
	SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoDefaultFontItalic").text
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "UserNameColor", "")
	SubNode.Text = XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoDefaultFontColor").text
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "UserNameDirection", "")
	SubNode.Text = 0
	Node.Attributes.setNamedItem (SubNode)
	Set SubNode = Nothing
End Sub

Sub GetCurrentSearchXML(XMLDOM)
	Dim Node, SubNode, SearchURL, TempSearch

	Set Node = XMLDOM.createNode(1, "CurrentSearchInfo", "")
	XMLDOM.documentElement.appendChild (Node)
	If ShopID = 597 Or ShopID = 697 Then
		Set SubNode = XMLDOM.createNode(2, "SearchSponsor", "")
		SubNode.Text = Dvbbs.CheckStr(Trim(Request("search_sponsor")))
		Node.attributes.setNamedItem (SubNode)
		SearchURL = ""
		If Request("search_sponsor") <> "" Then
			SearchURL = SearchURL & "&search_sponsor=" & Trim(Request("search_sponsor"))
		End If
		TempSearch = ""
		If Not (IsNull(Request("selUserCount_l")) Or Request("selUserCount_l") = "") Then
			If isInteger(Request("selUserCount_l")) Then
				TempSearch = Trim(Request("selUserCount_l")) & Template.Strings(47) & Template.Strings(13)
			End If
		End If
		If Request("selUserCount_l") <> "" Then
			SearchURL = SearchURL & "&selUserCount_l=" & Trim(Request("selUserCount_l"))
		End If
		If Not (IsNull(Request("selUserCount_h")) Or Request("selUserCount_h") = "") Then
			If isInteger(Request("selUserCount_h")) Then
				If TempSearch <> "" Then
					TempSearch = Trim(Request("selUserCount_l")) & Template.Strings(52) & Trim(Request("selUserCount_h")) & Template.Strings(47)
				Else
					TempSearch = Trim(Request("selUserCount_h")) & Template.Strings(47) & Template.Strings(14)
				End If
			End If
		End If
		If Request("selUserCount_h") <> "" Then
			SearchURL = SearchURL & "&selUserCount_h=" & Trim(Request("selUserCount_h"))
		End If
		Set SubNode = XMLDOM.createNode(2, "SearchUserCount", "")
		If TempSearch = "" Then
			SubNode.Text = Template.Strings(11)
		Else
			SubNode.Text = TempSearch
		End If
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "SearchCreated", "")
		Select Case Request("selurl")
		Case "1"
			SubNode.Text = Template.Strings(48)
		Case "2"
			SubNode.Text = Template.Strings(49)
		Case Else
			SubNode.Text = Template.Strings(11)
		End Select
		Node.attributes.setNamedItem (SubNode)
		If Request("selURL") <> "" And Request("selURL") <> "0" Then
			SearchURL = SearchURL & "&selURL=" & Trim(Request("selurl"))
		End If
		Set SubNode = XMLDOM.createNode(2, "SearchUploaded", "")
		Select Case Request("selupload")
		Case "1"
			SubNode.Text = Template.Strings(50)
		Case "2"
			SubNode.Text = Template.Strings(51)
		Case Else
			SubNode.Text = Template.Strings(11)
		End Select
		Node.attributes.setNamedItem (SubNode)
		If Request("selUpload") <> "" And Request("selUpload") <> "0" Then
			SearchURL = SearchURL & "&selUpload=" & Trim(Request("selupload"))
		End If
		Set SubNode = XMLDOM.createNode(2, "SearchURL", "")
		SubNode.Text = SearchURL
		Node.attributes.setNamedItem (SubNode)
	Else 
		Set SubNode = XMLDOM.createNode(2, "SearchStr", "")
		SubNode.Text = Dvbbs.CheckStr(Trim(Request("search_str")))
		Node.attributes.setNamedItem (SubNode)
		SearchURL = ""
		If Request("search_str") <> "" Then
			SearchURL = SearchURL & "&search_str=" & Trim(Request("search_str"))
		End If
		Set SubNode = XMLDOM.createNode(2, "SearchGender", "")
		Select Case Request("selgender")
		Case "1"
			SubNode.Text = Template.Strings(24)
		Case "2"
			SubNode.Text = Template.Strings(25)
		Case "3"
			SubNode.Text = Template.Strings(10)
		Case Else
			SubNode.Text = Template.Strings(11)
		End Select
		Node.attributes.setNamedItem (SubNode)
		If Request("selgender") <> "" And Request("selgender") <> "0" Then
			SearchURL = SearchURL & "&selgender=" & Trim(Request("selgender"))
		End If
		TempSearch = ""
		If Not (IsNull(Request("selprice_l")) Or Request("selprice_l") = "") Then
			If isInteger(Request("selprice_l")) Then
				TempSearch = Trim(Request("selprice_l")) & Template.Strings(7) & Template.Strings(13)
			End If
		End If
		If Request("selprice_l") <> "" Then
			SearchURL = SearchURL & "&selprice_l=" & Trim(Request("selprice_l"))
		End If
		If Not (IsNull(Request("selprice_h")) Or Request("selprice_h") = "") Then
			If isInteger(Request("selprice_h")) Then
				If TempSearch <> "" Then
					TempSearch = Trim(Request("selprice_l")) & Template.Strings(52) & Trim(Request("selprice_h")) & Template.Strings(7)
				Else
					TempSearch = TempSearch & Trim(Request("selprice_h")) & Template.Strings(7) & Template.Strings(14)
				End If
			End If
		End If
		If Request("selprice_h") <> "" Then
			SearchURL = SearchURL & "&selprice_h=" & Trim(Request("selprice_h"))
		End If
		Set SubNode = XMLDOM.createNode(2, "SearchPrice", "")
		If TempSearch = "" Then
			SubNode.Text = Template.Strings(11)
		Else
			SubNode.Text = TempSearch
		End If
		Node.attributes.setNamedItem (SubNode)
		TempSearch = ""
		If Not (IsNull(Request("selperiod_l")) Or Request("selperiod_l") = "") Then
			If isInteger(Request("selperiod_l")) Then
				TempSearch = Trim(Request("selperiod_l")) & Template.Strings(16) & Template.Strings(13)
			End If
		End If
		If Request("selperiod_l") <> "" Then
			SearchURL = SearchURL & "&selperiod_l=" & Trim(Request("selperiod_l"))
		End If
		If Not (IsNull(Request("selperiod_h")) Or Request("selperiod_h") = "") Then
			If isInteger(Request("selperiod_h")) Then
				If TempSearch <> "" Then
					TempSearch = Trim(Request("selperiod_l")) & Template.Strings(52) & Trim(Request("selperiod_h")) & Template.Strings(16)
				Else
					TempSearch = TempSearch & Trim(Request("selperiod_h")) & Template.Strings(16) & Template.Strings(14)
				End If
			End If
		End If
		If Request("selperiod_h") <> "" Then
			SearchURL = SearchURL & "&selperiod_h=" & Trim(Request("selperiod_h"))
		End If
		Set SubNode = XMLDOM.createNode(2, "SearchPeriod", "")
		If TempSearch = "" Then
			SubNode.Text = Template.Strings(11)
		Else
			SubNode.Text = TempSearch
		End If
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "SearchFlag", "")
		Select Case Request("selflag")
		Case "1"
			SubNode.Text = Template.Strings(18)
		Case "2"
			SubNode.Text = Template.Strings(19)
		Case "3"
			SubNode.Text = Template.Strings(20)
		Case "4"
			SubNode.Text = Template.Strings(21)
		Case Else
			SubNode.Text = Template.Strings(11)
		End Select
		Node.attributes.setNamedItem (SubNode)
		If Request("selflag") <> "" And Request("selflag") <> "0" Then
			SearchURL = SearchURL & "&selflag=" & Trim(Request("selflag"))
		End If
		Set SubNode = XMLDOM.createNode(2, "SearchURL", "")
		SubNode.Text = SearchURL
		Node.attributes.setNamedItem (SubNode)
	End If
	Set Node = Nothing
	Set SubNode = Nothing
End Sub

Sub GetCurrentUserInfoXML(XMLDOM, ShopID)
	Dim Node, SubNode, CookieAvatar, ChildNode, Rs

	Set Node = XMLDOM.createNode(1, "CurrentUserInfo", "")
	XMLDOM.documentElement.appendChild (Node)
	Set SubNode = XMLDOM.createNode(2, "MyUserID", "")
	SubNode.Text = Dvbbs.UserID
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "MyUserName", "")
	SubNode.Text = Dvbbs.MemberName
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "MyAvatar", "")
	If (ShopID Mod 100) = 97 Or (ShopID Mod 100) = 94 Then
		CookieAvatar = Request.Cookies("MyAvatar_" & Dvbbs.UserID)
		If CookieAvatar = "" Then
			SubNode.Text = v_MyAvatar
		Else
			If CheckPhotoAvatar(CookieAvatar) Then
				SubNode.Text = CookieAvatar
			Else
				SubNode.Text = v_MyAvatar
			End If
		End If
	Else
		SubNode.Text = v_MyAvatar
	End If
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "ToolByUser", "")
	SubNode.Text = v_ToolByUser
	Node.attributes.setNamedItem (SubNode)
	If v_ToolByUser <> "" Then
		Set SubNode = XMLDOM.createNode(2, "ToolPeriod", "")
		Set Rs = Dvbbs.Plus_Execute("Select Top 1 Period,FixDate From Dv_Plus_Avatar_MyItems Where '|" & v_MyAvatar & "' Like " & SqlConcateString("'%|'", "ItemID", "'.%'") & " And UserName='" & Dvbbs.MemberName & "' And (Type=6 Or Type=0)")
		If Not Rs.Eof Then
			If Rs(0) = 0 Then
				SubNode.Text = 0
			ElseIf DateDiff("d", Rs(1), Now()) >= Rs(0) Then
				SubNode.Text = -1
			Else
				SubNode.Text = FormatDateTime(DateAdd("d", Rs(1), Rs(0)), 2)
			End If
		Else
			SubNode.Text = 0
		End If
		Rs.Close
		Node.attributes.setNamedItem (SubNode)
	Else
		Set SubNode = XMLDOM.createNode(2, "ToolPeriod", "")
		SubNode.Text = 0
		Node.attributes.setNamedItem (SubNode)
	End If
	Set SubNode = XMLDOM.createNode(2, "MySex", "")
	SubNode.Text = v_MySex
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "MyVip", "")
	SubNode.Text = v_MyVip
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "MyClass", "")
	SubNode.Text = v_MyClass
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "IsMaster", "")
	If Dvbbs.Master Then
		SubNode.Text = "1"
	Else
		SubNode.Text = "0"
	End If
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "IsSuperBoardMaster", "")
	If Dvbbs.SuperBoardMaster Then
		SubNode.Text = "1"
	Else
		SubNode.Text = "0"
	End If
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "IsBoardMaster", "")
	If Dvbbs.BoardMaster Then
		SubNode.Text = "1"
	Else
		SubNode.Text = "0"
	End If
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "MaxMessageBytes", "")
	SubNode.Text = Dvbbs.GroupSetting(34)
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "MyMoney", "")
	SubNode.Text = v_MyMoney
	Node.attributes.setNamedItem (SubNode)
	Set SubNode = XMLDOM.createNode(2, "MyUserIsAva", "")
	SubNode.Text = v_MyUserIsAva
	Node.attributes.setNamedItem (SubNode)
	If ShopID = 197 Then
		Set Rs = Dvbbs.Execute("Select F_Friend From Dv_Friend Where F_UserName='" & Dvbbs.MemberName & "' And F_Mod=1 Order By F_AddTime Desc")
		Do While Not Rs.Eof
			Set ChildNode = XMLDOM.createNode(1, "MyFriend", "")
			Node.appendChild (ChildNode)
			Set SubNode = XMLDOM.createNode(2, "FriendName", "")
			SubNode.Text = Rs(0)
			ChildNode.attributes.setNamedItem (SubNode)
			Rs.MoveNext
		Loop
		Rs.Close
	End If
	Set SubNode = XMLDOM.createNode(2, "HasRemoteAccount", "")
	If Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_RemoteUser Where UserID=" & Dvbbs.UserID).Eof Then
		SubNode.Text = 1
	Else
		SubNode.Text = 0
	End If
	Node.attributes.setNamedItem (SubNode)
	Set Node = Nothing
	Set SubNode = Nothing
	Set ChildNode = Nothing
End Sub

Sub AvatarNav()
	Dim AvatarXSLT, AvatarXMLStyle, AvatarProc

	Set AvatarXMLStyle = Server.CreateObject("msxml2.FreeThreadedDOMDocument"& MsxmlVersion)
	'AvatarXMLStyle.loadXML Template.HTML(0)
	AvatarXMLStyle.load Server.MapPath("Dv_Plus/Avatar/Plus_Avatar_Nav.xslt")
	Set AvatarXSLT = Server.CreateObject("Msxml2.XSLTemplate" & MsxmlVersion)
	AvatarXSLT.stylesheet = AvatarXMLStyle
	Set AvatarProc = AvatarXSLT.createProcessor()
	AvatarProc.input = AvatarXMLDOM
	AvatarProc.Transform
	Response.Write AvatarProc.output
	Set AvatarXSLT = Nothing
	Set AvatarXMLStyle = Nothing
End Sub

Sub ShowMessage()
	Dim MsgSplit, Message
	
	If Clng(Dvbbs.SendMsgNum)>0 Then
		MsgSplit = Split(Dvbbs.MainHTML(12), "||")
		Message = MsgSplit(0) & MsgSplit(1)
		Message = Replace(Message,"{$smsid}",Dvbbs.SendMsgID)
		Message = Replace(Message,"{$sender}",Dvbbs.SendMsgUser)
		Response.Write Message
		NeedShowMsg = False
	End If
End Sub

Function UpdatePeriod()
	Dim Rs, RetMsg, TempStr
	
	RetMsg = ""
	Set Rs = Dvbbs.Plus_Execute("Select i.Name From Dv_Plus_Avatar_MyItems m Inner Join Dv_Plus_Avatar_Items i On m.ItemID=i.ID Where m.Type<>0 And m.Type<>5 And " & SqlDateDiffString("m.FixDate", SqlNowString) & ">=m.Period And " & SqlDateDiffString("m.FixDate", SqlNowString) & "<=" & (CInt(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("AutoDeleteDays").Text) - CInt(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("AutoDeleteNotifyDays").Text)) & " And m.Period>0 And m.UserName='" & Dvbbs.MemberName & "'")
	If Not Rs.Eof Then
		RetMsg = RetMsg & "以下商品已经过期：" & vbCrLf
		TempStr = Rs.GetString(, -1, "", "》，《", "")
		TempStr = "《" & Left(TempStr, Len(TempStr) - 2) & "。"
		RetMsg = RetMsg & TempStr & vbCrLf & vbCrLF & "请到以下地址查看过期商品。" & vbCrlf & "[align=center][b][URL=Plus_Avatar_Center.asp?shopid=600]查看过期商品[/URL][/b][/align]" & vbCrLf
		Dvbbs.Plus_Execute ("Update Dv_Plus_Avatar_MyItems Set Type=0 Where Type<>0 And Type<>5 And " & SqlDateDiffString("FixDate", SqlNowString) & ">=Period And Period>0 And UserName='" & Dvbbs.MemberName & "'")
	End If
	Rs.Close
	UpdatePeriod = RetMsg
End Function

Function NotifyPeriod()
	Dim Rs, RetMsg, TempStr
	
	RetMsg = ""
	Set Rs = Dvbbs.Plus_Execute("Select i.Name From Dv_Plus_Avatar_MyItems m Inner Join Dv_Plus_Avatar_Items i On m.ItemID=i.ID Where i.Class<>6 And m.Period>0 And " & SqlDateDiffString("m.FixDate", SqlNowString) & "-m.Period>" & (CInt(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("AutoDeleteDays").Text) - CInt(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("AutoDeleteNotifyDays").Text)) & " And " & SqlDateDiffString("m.FixDate", SqlNowString) & "-m.Period<=" & AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("AutoDeleteDays").Text & " And m.UserName='" & Dvbbs.MemberName & "'")
	If Not Rs.Eof Then
		RetMsg = RetMsg & "以下商品即将作废，一旦作废系统将自动清除它们，请您尽快翻新：" & vbCrLf
		TempStr = Rs.GetString(, -1, "", "》，《", "")
		TempStr = "《" & Left(TempStr, Len(TempStr) - 2) & "。"
		RetMsg = RetMsg & TempStr & vbCrLf & vbCrLf & "请到以下地址查看这些物品。" & vbCrlf & "[align=center][b][URL=Plus_Avatar_Center.asp?shopid=600]查看过期商品[/URL][/b][/align]" & vbCrLf
	End If
	Rs.Close
	NotifyPeriod = RetMsg
End Function

Function DeletePeriod()
	Dim Rs, RetMsg, TempStr
	
	RetMsg = ""
	Set Rs = Dvbbs.Plus_Execute("Select i.Name From Dv_Plus_Avatar_MyItems m Inner Join Dv_Plus_Avatar_Items i On m.ItemID=i.ID Where m.Period>0 And " & SqlDateDiffString("m.FixDate", SqlNowString) & "-m.Period>" & AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("AutoDeleteDays").Text & " And m.UserName='" & Dvbbs.MemberName & "'")
	If Not Rs.Eof Then
		RetMsg = RetMsg & "以下商品已经作废，系统已经将它们自动清除：" & vbCrLf
		TempStr = Rs.GetString(, -1, "", "》，《", "")
		TempStr = "《" & Left(TempStr, Len(TempStr) - 2) & "。"
		RetMsg = RetMsg & TempStr & vbCrLf
		Dvbbs.Plus_Execute ("Delete From Dv_Plus_Avatar_MyItems Where Period>0 And " & SqlDateDiffString("FixDate", SqlNowString) & "-Period>" & AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("AutoDeleteDays").Text & " And UserName='" & Dvbbs.MemberName & "'")
	End If
	Rs.Close
	DeletePeriod = RetMsg
End Function

Function DeletePhoto()
	Dim Rs, RetMsg
	
	RetMsg = ""
	Set Rs = Dvbbs.Plus_Execute("Select ID,Name From Dv_Plus_Avatar_Photo Where EndDate<" & SqlNowString & " And FromUser='" & Dvbbs.MemberName & "' And Finished=0")
	If Not Rs.Eof Then
		Do While Not Rs.EOF
			If RetMsg <> "" Then RetMsg = RetMsg & "》,《"
			RetMsg = RetMsg & Rs(1)
			Dvbbs.Plus_Execute ("Delete From Dv_Plus_Avatar_PhotoUser Where PhotoID=" & Rs(0))
			Dvbbs.Plus_Execute ("Delete From Dv_Plus_Avatar_Accouterment Where PhotoID=" & Rs(0))
			Rs.MoveNext
		Loop
		Dvbbs.Plus_Execute ("Delete From Dv_Plus_Avatar_Photo Where EndDate<" & SqlNowString & " And FromUser='" & Dvbbs.MemberName & "' And Finished=0")
		RetMsg = "以下尚未完成的照片已经过期，系统已经将它们自动删除：" & vbCrlf & "《" & RetMsg & "》。" & vbCrLf
	End If
	Rs.Close
	DeletePhoto = RetMsg
End Function

Function GetTypeName(ShopID)
	Select Case ShopID
	Case 100, 200, 300, 400, 500, 600, 700, 800
		GetTypeName = "我的物品"
	Case 194, 294, 394, 494, 594
		GetTypeName = "形象大赛"
	Case 195, 295, 395, 495, 595, 695
		GetTypeName = ""
	Case 196, 296, 396, 496, 596
		GetTypeName = "二手市场"
	Case 197, 297, 397, 497, 597, 697
		GetTypeName = "照相馆"
	End Select
End Function

Function GetSubTypeName(ShopID)
	Select Case ShopID
	Case 100
		GetSubTypeName = "衣帽"
	Case 200
		GetSubTypeName = "化妆"
	Case 300
		GetSubTypeName = "首饰"
	Case 400
		GetSubTypeName = "杂物"
	Case 500
		GetSubTypeName = "货架"
	Case 600
		GetSubTypeName = "过期"
	Case 700
		GetSubTypeName = "道具"
	Case 800
		GetSubTypeName = "收藏"
	Case 194
		GetSubTypeName = "本届大赛作品"
	Case 294
		GetSubTypeName = "历届大赛结果"
	Case 394
		GetSubTypeName = "参加下届大赛"
	Case 494
		GetSubTypeName = "我的参赛经历"
	Case 594
		GetSubTypeName = "我的评选经历"
	Case 195
		GetSubTypeName = "商品编码"
	Case 295
		GetSubTypeName = "到货时间"
	Case 395
		GetSubTypeName = "标价"
	Case 495
		GetSubTypeName = "VIP价"
	Case 595
		GetSubTypeName = "有效期"
	Case 695
		GetSubTypeName = "限购者"
	Case 196
		GetSubTypeName = "服装类"
	Case 296
		GetSubTypeName = "化妆类"
	Case 396
		GetSubTypeName = "首饰类"
	Case 496
		GetSubTypeName = "杂物类"
	Case 596
		GetSubTypeName = "道具类"
	Case 197
		GetSubTypeName = "发送新请求"
	Case 297
		GetSubTypeName = "发出的请求"
	Case 397
		GetSubTypeName = "收到的请求"
	Case 497
		GetSubTypeName = "确认的请求"
	Case 597
		GetSubTypeName = "我的虚拟相簿"
	Case 697
		GetSubTypeName = "大家的虚拟相簿"
	End Select
End Function

Function CartBag_GetInfo(CartBagArray, MyUserID)
	Dim CartBag

	CartBag = Request.Cookies("myAvatarBuy_" & MyUserID)
	If IsNull(CartBag) Then CartBag = ""
	If CartBag = "" Then
		ReDim CartBagArray(-1)
		CartBag_GetInfo = 0
	Else
		CartBagArray = Split(CartBag, "|")
		CartBag_GetInfo = UBound(CartBagArray) + 1
	End If
End Function

Function CartBag_SetInfo(CartBagArray, MyUserID)
	Dim CartBag, i
	
	CartBag = ""
	For i = 0 To UBound(CartBagArray)
		If CartBag <> "" Then CartBag = CartBag & "|"
		CartBag = CartBag & CartBagArray(i)
	Next
	Response.Cookies("myAvatarBuy_" & MyUserID) = CartBag
	CartBag_SetInfo = True
End Function

Function CardBag_GetSendMsg(CartBagArray, ItemID, SendToUserName)
	Dim i, SendSplit, MsgBody
		
	MsgBody = ""
	If CLng(ItemID) > 0 And SendToUserName <> "" Then
		For i = 0 To UBound(CartBagArray)
			SendSplit = Split(CartBagArray(i), "$")
			If UBound(SendSplit) = 2 Then
				If CLng(SendSplit(0)) = CLng(ItemID) And LCase(Trim(SendSplit(1))) = LCase(Trim(SendToUserName)) Then
					MsgBody = Dvbbs.CheckStr(SendSplit(2))
					Exit For
				End If
			End If
		Next
	End If
	CardBag_GetSendMsg = MsgBody
End Function

Function CartBag_UpdateSendMsg(CartBagArray, ItemID, SendToUserName, SendMsg)
	Dim i, SendSplit, SucFlag
	
	SucFlag = False
	If CLng(ItemID) > 0 And SendToUserName <> "" Then
		For i = 0 To UBound(CartBagArray)
			SendSplit = Split(CartBagArray(i), "$")
			If UBound(SendSplit) = 2 Then
				If CLng(SendSplit(0)) = CLng(ItemID) And LCase(Trim(SendSplit(1))) = LCase(Trim(SendToUserName)) Then
					SendSplit(2) = SendMsg
					SucFlag = True
				End If
				CartBagArray(i) = SendSplit(0) & "$" & SendSplit(1) & "$" & SendSplit(2)
			End If
		Next
	End If
	CartBag_UpdateSendMsg = SucFlag
End Function

Function CartBag_AddItem(CartBagArray, ItemID, SendToUserName, SendMsg)
	Dim CartBag,SucFlag
	
	SucFlag = False
	If CLng(ItemID) > 0 Then
		ReDim Preserve CartBagArray(UBound(CartBagArray) + 1)
		If SendToUserName <> "" Then
			CartBagArray(UBound(CartBagArray)) = CLng(ItemID) & "$" & SendToUserName & "$" & SendMsg
		Else
			CartBagArray(UBound(CartBagArray)) = CLng(ItemID)
		End If
		SucFlag = True
	End If
	CartBag_AddItem = True
End Function

Function CartBag_RemoveItem(CartBagArray, ItemSeqNo)
	Dim i, j, SucFlag

	SucFlag = False
	If ItemSeqNo > 0 Then
		For i = 0 To UBound(CartBagArray)
			If i + 1 = CLng(ItemSeqNo) Then
				For j = i To UBound(CartBagArray) - 1
					CartBagArray(j) = CartBagArray(j + 1)
				Next
				ReDim Preserve CartBagArray(UBound(CartBagArray) - 1)
				SucFlag = True
				Exit For
			End If
		Next
	End If
	CartBag_RemoveItem = SucFlag
End Function

Function CartBag_FindItem(CartBagArray, ItemID, SendToUserName)
	Dim CartBag, i, SendSplit, SucFlag
	
	SucFlag = False
	If CLng(ItemID) > 0 Then
		For i = 0 To UBound(CartBagArray)
			SendSplit = Split(CartBagArray(i), "$")
			If UBound(SendSplit) = 2 Then
				If SendToUserName <> "" Then
					If CLng(SendSplit(0)) = CLng(ItemID) And LCase(Trim(SendSplit(1))) = LCase(Trim(SendToUserName)) Then
						SucFlag = True
						Exit For
					End If
				End If
			Else
				If SendToUserName = "" Then
					If CLng(SendSplit(0)) = CLng(ItemID) Then
						SucFlag = True
						Exit For
					End If
				End If
			End If
		Next
	End If
	CartBag_FindItem = SucFlag
End Function

Function CartBag_CheckBuy(CartBagArray)
	Dim Rs, i, TempSplit, RetMsg, TempStr
	
	RetMsg = ""
	For i = 0 To UBound(CartBagArray)
		TempSplit = Split(CartBagArray(i), "$")
		If isInteger(TempSplit(0)) Then
			Set Rs = Dvbbs.Plus_Execute("Select Top 1 Name,Vip,Quantity,Flag From Dv_Plus_Avatar_Items Where ID=" & TempSplit(0))
			If Not Rs.EOF Then
				TempStr = CheckBuy(Rs(0), Rs(1), Rs(2), Rs(3))
				If TempStr <> "" Then
					If RetMsg <> "" Then RetMsg = RetMsg & "<br>"
					RetMsg = RetMsg & TempStr
				End If
				If UBound(TempSplit) = 2 Then
					If TempSplit(1) = "" Then
						If RetMsg <> "" Then RetMsg = RetMsg & "<br>"
						RetMsg = RetMsg & "<li>没有指定受赠者！"
					ElseIf LCase(Trim(Dvbbs.CheckStr(TempSplit(1)))) = LCase(Trim(Dvbbs.MemberName)) Then
						If RetMsg <> "" Then RetMsg = RetMsg & "<br>"
						RetMsg = RetMsg & "<li>不能给自己赠送商品！"
					ElseIf Dvbbs.Execute("Select Top 1 UserID From [Dv_User] Where UserName='" & TempSplit(1) & "'").Eof Then
						If RetMsg <> "" Then RetMsg = RetMsg & "<br>"
						RetMsg = RetMsg & "<li>受赠者 " & TempSplit(1) & " 不存在！"
					ElseIf Not Dvbbs.Plus_Execute("Select Top 1 ItemID From Dv_Plus_Avatar_MyItems Where UserName='" & TempSplit(1) & "' And ItemID=" & TempSplit(0)).Eof Then
						If RetMsg <> "" Then RetMsg = RetMsg & "<br>"
						RetMsg = RetMsg & "<li>用户 " & TempSplit(1) & " 已经拥有商品《" & Rs(0) & "》，无须赠送！"
					End If
				Else
					If Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_MyItems Where UserName='" & Dvbbs.MemberName & "' And ItemID=" & TempSplit(0)).EOF Then
						If RetMsg <> "" Then RetMsg = RetMsg & "<br>"
						RetMsg = RetMsg & "<li>不能再次购买已经拥有的商品《" & Rs(0) & "》！"
					End If
				End If
			Else
				If RetMsg <> "" Then RetMsg = RetMsg & "<br>"
				RetMsg = RetMsg & "<li>不能购买根本不存在的商品！"
			End If
			Rs.Close
		End If
	Next
	CartBag_CheckBuy = RetMsg
End Function

Function CartBag_CalcAmount(CartBagArray, MyVIP)
	Dim Rs, i, TotalAmount, SendSplit, CurPrice
	
	TotalAmount = 0
	For i = 0 To UBound(CartBagArray)
		SendSplit = Split(CartBagArray(i), "$")
		If isInteger(SendSplit(0)) Then
			Set Rs = Dvbbs.Plus_Execute("Select Top 1 Price1,Price2 From Dv_Plus_Avatar_Items Where ID=" & SendSplit(0))
			If Not Rs.EOF Then
				If MyVIP <> 1 Then
					CurPrice = Rs(0)
				Else
					CurPrice = Rs(1)
				End If
				TotalAmount = TotalAmount + CurPrice
				If UBound(SendSplit) = 2 Then TotalAmount = TotalAmount + Int(CurPrice * CDbl(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("SendFeeRate").Text) / 100 + 0.99)
			End If
			Rs.Close
		End If
	Next
	CartBag_CalcAmount = TotalAmount
End Function

Function CartBag_Settlement(CartBagArray, MyUserID, MyUserName)
	Dim SQL, Rs, i, SendSplit, CurPrice, CurType, CurAmount
	
	For i = 0 To UBound(CartBagArray)
		SendSplit = Split(CartBagArray(i), "$")
		If isInteger(SendSplit(0)) Then
			Set Rs = Dvbbs.Plus_Execute("Select Top 1 ID,Name,Price1,Price2,Period,Class From Dv_Plus_Avatar_Items Where ID=" & SendSplit(0))
			If Not Rs.EOF Then
				If v_MyVip <> 1 Then
					CurAmount = Rs(2)
				Else
					CurAmount = Rs(3)
				End If
				Dvbbs.Plus_Execute ("Update Dv_Plus_Avatar_Items Set Quantity=Quantity-1,TotalSales=TotalSales+1 Where ID=" & SendSplit(0))
				If UBound(SendSplit) < 2 Then
					Dvbbs.Plus_Execute ("Insert Into Dv_Plus_Avatar_MyItems (ItemID,UserName,FromUser,[Type],AddDate,FixDate,Period,Price) Values (" & Rs(0) & ",'" & MyUserName & "','" & MyUserName & "'," & Rs(5) & "," & SqlNowString & "," & SqlNowString & "," & Rs(4) & "," & CurAmount & ")")
					Dvbbs.Plus_Execute ("Delete From Dv_Plus_Avatar_Favorite Where ItemID=" & Rs(0) & " And UserName='" & MyUserName & "'")
				Else
					Dvbbs.Plus_Execute ("Insert Into Dv_Plus_Avatar_MyItems (ItemID,UserName,FromUser,[Type],AddDate,FixDate,Period,Price) Values (" & Rs(0) & ",'" & Dvbbs.CheckStr(SendSplit(1)) & "','" & MyUserName & "'," & Rs(5) & "," & SqlNowString & "," & SqlNowString & "," & Rs(4) & "," & CurAmount & ")")
					Dvbbs.Plus_Execute ("Delete From Dv_Plus_Avatar_Favorite Where ItemID=" & Rs(0) & " And UserName='" & Dvbbs.CheckStr(SendSplit(1)) & "'")
					CurAmount = CurAmount + Int(CurAmount * CDbl(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("SendFeeRate").Text) / 100 + 0.99)
					Call Dv_SendMsg(Dvbbs.CheckStr(Trim(SendSplit(1))), MyUserName, Replace(Template.Strings(2), "{$ItemName}", Rs(1)), Dvbbs.CheckStr(SendSplit(2)) & Replace(Template.Strings(3), "\n", vbCrLf))
				End If
				Call UpdateUserWealth(MyUserName, -CurAmount)
			End If
			Rs.Close
		End If
	Next
	CartBag_Settlement = True
	Response.Cookies("myAvatarBuy_" & MyUserID) = ""
End Function

Function CheckBuy(ItemName, ItemVIP, ItemQuantity, ItemFlag)
	Dim RetMsg
	
	RetMsg = ""
	If ItemVIP = 1 And v_MyVip <> 1 Then
		If RetMsg <> "" Then RetMsg = RetMsg & "<br>"
		RetMsg = RetMsg & "<li><font color=" & Dvbbs.MainSetting(1) & ">只有VIP会员才能购买或赠送商品《" & ItemName & "》！点击【<a href=""JoinVipGroup.asp""><font color=""blue""><b>这里</b></font></a>】加入VIP！</font>"
	End If
	If ItemQuantity <= 0 Then
		If RetMsg <> "" Then RetMsg = RetMsg & "<br>"
		RetMsg = RetMsg & "<li><font color=" & Dvbbs.MainSetting(1) & ">商品《" & ItemName & "》库存不足，您无法购买或赠送！</font>"
	End If
	If ItemFlag = 0 Then
		If RetMsg <> "" Then RetMsg = RetMsg & "<br>"
		RetMsg = RetMsg & "<li><font color=" & Dvbbs.MainSetting(1) & ">《" & ItemName & "》是保留商品，您无法购买或赠送！</font>"
	End If
	If ItemFlag = 1 And Dvbbs.MemberName = "" Then
		If RetMsg <> "" Then RetMsg = RetMsg & "<br>"
		RetMsg = RetMsg & "<li><font color=" & Dvbbs.MainSetting(1) & ">只有会员才能购买或赠送商品《" & ItemName & "》！"
	End If
	If ItemFlag = 2 And Not Dvbbs.Master And Not Dvbbs.BoardMaster And Not Dvbbs.SuperBoardMaster Then
		If RetMsg <> "" Then RetMsg = RetMsg & "<br>"
		RetMsg = RetMsg & "<li><font color=" & Dvbbs.MainSetting(1) & ">只有版主以上人员才能购买或赠送商品《" & ItemName & "》！</font>"
	End If
	If ItemFlag = 3 And Not Dvbbs.Master And Not Dvbbs.SuperBoardMaster Then
		If RetMsg <> "" Then RetMsg = RetMsg & "<br>"
		RetMsg = RetMsg & "<li><font color=" & Dvbbs.MainSetting(1) & ">只有超级版主和管理员才能购买或赠送商品《" & ItemName & "》！</font>"
	End If
	If ItemFlag = 4 And Not Dvbbs.Master Then
		If RetMsg <> "" Then RetMsg = RetMsg & "<br>"
		RetMsg = RetMsg & "<li><font color=" & Dvbbs.MainSetting(1) & ">只有管理员才能购买或赠送商品《" & ItemName & "》！</font>"
	End If
	CheckBuy = RetMsg
End Function

Sub UpdateUserWealth(UserName, Wealth)
	If Wealth > 0 Then
		Dvbbs.Execute ("UPDATE Dv_User Set UserWealth=UserWealth+" & Wealth & " Where UserName='" & UserName & "'")
	Else
		Dvbbs.Execute ("UPDATE Dv_User Set UserWealth=UserWealth-" & Abs(Wealth) & " Where UserName='" & UserName & "'")
	End If
	If LCase(UserName) = LCase(Dvbbs.MemberName) Then
		Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwealth").text = CLng(Dvbbs.UserSession.documentElement.selectSingleNode("userinfo/@userwealth").text) + Wealth
	Else
		Dvbbs.NeedUpdateList UserName, 1
	End If
End Sub

Function Avatar_GetInfo(AvatarStr, AvatarArray)
	Dim TempSplit,i
	
	If AvatarStr = "" Or IsNull(AvatarStr) Then
		ReDim AvatarArray(-1)
		Avatar_GetInfo = 0
	Else
		AvatarArray = Split(AvatarStr, "|")
		If UBound(AvatarArray) <> 24 Then
			ReDim AvatarArray(-1)
			Avatar_GetInfo = 0
		Else
			For i = 0 To UBound(AvatarArray)
				If AvatarArray(i) <> "" Then
					TempSplit = Split(AvatarArray(i), ".")
					If Not IsInteger(TempSplit(0)) Then
						Exit For
					End If
					AvatarArray(i) = CLng(TempSplit(0))
				End If
			Next
			If i <= UBound(AvatarArray) Then
				ReDim AvatarArray(-1)
				Avatar_GetInfo = 0
			Else
				Avatar_GetInfo = UBound(AvatarArray) + 1
			End If
		End If
	End If
End Function

Function Avatar_RemoveItem(AvatarArray, ItemID)
	Dim i, AvatarStr
	
	AvatarStr = ""
	For i = 0 To UBound(AvatarArray)
		If i > 0 Then AvatarStr = AvatarStr & "|"
		If AvatarArray(i) <> "" Then
			If CLng(AvatarArray(i)) <> CLng(ItemID) Then AvatarStr = AvatarStr & AvatarArray(i)
		End If
	Next
	Avatar_RemoveItem = AvatarStr
End Function

Function Avatar_CheckItem(AvatarArray, Sex)
	Dim i, j, Rs1, Rs2, TempSplit
	
	Avatar_CheckItem = ""
	For i = 0 To UBound(AvatarArray)
		If AvatarArray(i) <> "" Then
			For j = 0 To i - 1
				If AvatarArray(i) = AvatarArray(j) Then Exit For
			Next
			If j > i - 1 Then
				Set Rs1 = Dvbbs.Plus_Execute("Select Top 1 Sex,Content,Name,Class From Dv_Plus_Avatar_Items Where ID=" & AvatarArray(i))
				If Not Rs1.Eof Then
					If Rs1(0) <> 2 And Rs1(0) <> CInt(Sex) Then
						If Avatar_CheckItem <> "" Then Avatar_CheckItem = Avatar_CheckItem & "<br>"
						Avatar_CheckItem = Avatar_CheckItem & "<li>不能使用性别不符的商品《" & Rs1(2) & "》！"
					End If
					If Rs1(1) = "" Then
						If Avatar_CheckItem <> "" Then Avatar_CheckItem = Avatar_CheckItem & "<br>"
						Avatar_CheckItem = Avatar_CheckItem & "<li>不能使用有数据错误的商品《" & Rs1(2) & "》！"
					End If
					If Not InStr(1, "_" & Rs1(1) & "_", "_" & (i + 1) & "_") > 0 Then
						If Avatar_CheckItem <> "" Then Avatar_CheckItem = Avatar_CheckItem & "<br>"
						Avatar_CheckItem = Avatar_CheckItem & "<li>不能将商品《" & Rs1(2) & "》使用在错误的部位！"
					End If
					TempSplit = Split(Rs1(1), "_")
					For j = 0 To UBound(TempSplit)
						If CLng(AvatarArray(CInt(TempSplit(j)) - 1)) <> CLng(AvatarArray(i)) Then
							Exit For
						End If
					Next
					If j <= UBound(TempSplit) Then
						If Avatar_CheckItem <> "" Then Avatar_CheckItem = Avatar_CheckItem & "<br>"
						Avatar_CheckItem = Avatar_CheckItem & "<li>《" & Rs1(2) & "》是一个多部位商品，不能拆开使用！"
					End If
					If Rs1(3) = 6 And v_ToolByUser = "" Then
						If Avatar_CheckItem <> "" Then Avatar_CheckItem = Avatar_CheckItem & "<br>"
						Avatar_CheckItem = Avatar_CheckItem & "<li>不能对自己使用整人商品《" & Rs1(2) & "》！"
					End If
					Set Rs2 = Dvbbs.Plus_Execute("Select Top 1 Period,FixDate,Type From Dv_Plus_Avatar_MyItems Where UserName='" & Dvbbs.MemberName & "' And ItemID=" & AvatarArray(i))
					If Not Rs2.Eof Then
						If (Rs2(0) <> 0 And DateDiff("d", Rs2(1), Now()) >= Rs2(0)) Or Rs2(2) = 0 Then
							If Avatar_CheckItem <> "" Then Avatar_CheckItem = Avatar_CheckItem & "<br>"
							Avatar_CheckItem = Avatar_CheckItem & "<li>不能使用过期商品《" & Rs1(2) & "》！"
						End If
						If Rs2(2) = 5 Then
							If Avatar_CheckItem <> "" Then Avatar_CheckItem = Avatar_CheckItem & "<br>"
							Avatar_CheckItem = Avatar_CheckItem & "<li>不能使用自己正在出售的二手商品《" & Rs1(2) & "》！"
						End If
					End If
					Rs2.Close
				Else
					If Avatar_CheckItem <> "" Then Avatar_CheckItem = Avatar_CheckItem & "<br>"
					Avatar_CheckItem = Avatar_CheckItem & "<li>不能使用根本不存在的商品！"
				End If
				Rs1.Close
			End If
		Else
			If i = 6 Or i = 7 Or i = 8 Or i = 10 Or i = 12 Or i = 13 Or i = 17 Then
				If Avatar_CheckItem <> "" Then Avatar_CheckItem = Avatar_CheckItem & "<br>"
				Avatar_CheckItem = Avatar_CheckItem & "<li>第 " & i & " 层属于身体的基本部位，必须存在！"
			End If
		End If
	Next
End Function

Function Avatar_FilterBadSexItem(AvatarArray, Sex)
	Dim i, j, Rs, TempSplit, DefaultAvatarArray
	
	If Sex = 1 Then
		DefaultAvatarArray = Split(DefaultAvatarBoy, "|")
	Else
		DefaultAvatarArray = Split(DefaultAvatarGirl, "|")
	End If
	Avatar_FilterBadSexItem = True
	For i = 0 To UBound(AvatarArray)
		If AvatarArray(i) <> "" Then
			Set Rs = Dvbbs.Plus_Execute("Select Top 1 Sex,Content From Dv_Plus_Avatar_Items Where ID=" & AvatarArray(i))
			If Not Rs.Eof Then
				If Rs(0) <> 2 And Rs(0) <> CInt(Sex) Then
					If DefaultAvatarArray(i) <> "" Then
						AvatarArray(i) = Split(DefaultAvatarArray(i), ".")(0)
					Else
						AvatarArray(i) = ""
					End If
				Else
					If Rs(1) = "" Then
						Avatar_FilterBadSexItem = False
						Exit For
					End If
					If Not InStr(1, "_" & Rs(1) & "_", "_" & (i + 1) & "_") > 0 Then
						Avatar_FilterBadSexItem = False
						Exit For
					End If
					TempSplit = Split(Rs(1), "_")
					For j = 0 To UBound(TempSplit)
						If CLng(AvatarArray(CInt(TempSplit(j)) - 1)) <> CLng(AvatarArray(i)) Then
							Exit For
						End If
					Next
					If j <= UBound(TempSplit) Then
						Avatar_FilterBadSexItem = False
						Exit For
					End If
				End If
			Else
				Avatar_FilterBadSexItem = False
				Exit For
			End If
			Rs.Close
		Else
			If DefaultAvatarArray(i) <> "" Then AvatarArray(i) = Split(DefaultAvatarArray(i), ".")(0)
		End If
	Next
	If i <= UBound(AvatarArray) Then Rs.Close
End Function

Function Avatar_CheckBuy(AvatarArray)
	Dim Rs1, Rs2, i, j, RetMsg, TempStr
	
	RetMsg = ""
	For i = 0 To UBound(AvatarArray)
		If AvatarArray(i) <> "" Then
			If Not IsEmotionItem(AvatarArray(i)) And Not IsDefaultItem(AvatarArray(i)) Then
				For j = 0 To i - 1
					If AvatarArray(i) = AvatarArray(j) Then Exit For
				Next
				If j > i - 1 Then
					Set Rs1 = Dvbbs.Plus_Execute("Select Top 1 Name,Vip,Quantity,Flag From Dv_Plus_Avatar_Items Where ID=" & AvatarArray(i))
					If Not Rs1.EOF Then
						Set Rs2 = Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_MyItems Where UserName='" & Dvbbs.MemberName & "' And ItemID=" & AvatarArray(i))
						If Rs2.Eof Then
							TempStr = CheckBuy(Rs1(0), Rs1(1), Rs1(2), Rs1(3))
							If TempStr <> "" Then
								If RetMsg <> "" Then RetMsg = RetMsg & "<br>"
								RetMsg = RetMsg & TempStr
							End If
						End If
						Rs2.Close
					Else
						RetMsg = "<li>不能购买根本不存在的商品！"
						Exit For
					End If
					Rs1.Close
				End If
			End If
		End If
	Next
	Avatar_CheckBuy = RetMsg
End Function

Function CheckPhotoAvatar(PhotoAvatarStr)
	Dim TempSplit, i, j, RetFlag, PhotoAvatarArray, Rs
	
	RetFlag = True
	If PhotoAvatarStr = "" Or IsNull(PhotoAvatarStr) Then
		RetFlag = False
	Else
		PhotoAvatarArray = Split(PhotoAvatarStr, "|")
		If UBound(PhotoAvatarArray) <> 24 Then
			RetFlag = False
		Else
			For i = 0 To UBound(PhotoAvatarArray)
				If PhotoAvatarArray(i) <> "" Then
					TempSplit = Split(PhotoAvatarArray(i), ".")
					PhotoAvatarArray(i) = TempSplit(0)
					If Not IsInteger(PhotoAvatarArray(i)) Then
						RetFlag = False
						Exit For
					End If
					Set Rs = Dvbbs.Plus_Execute("Select Top 1 Sex,Content,Name,Class From Dv_Plus_Avatar_Items Where ID=" & PhotoAvatarArray(i))
					If Not Rs.Eof Then
						If Rs(0) <> 2 And Rs(0) <> CInt(v_MySex) Then
							' 不能使用性别不符的商品
							RetFlag = False
							Rs.Close
							Exit For
						End If
						If Rs(1) = "" Then
							' 不能使用有数据错误的商品
							RetFlag = False
							Rs.Close
							Exit For
						End If
						If Not InStr(1, "_" & Rs(1) & "_", "_" & (i + 1) & "_") > 0 Then
							' 不能将商品使用在错误的部位
							RetFlag = False
							Rs.Close
							Exit For
						End If
						TempSplit = Split(Rs(1), "_")
						For j = 0 To UBound(TempSplit)
							If CLng(PhotoAvatarArray(CInt(TempSplit(j)) - 1)) <> CLng(PhotoAvatarArray(i)) Then
								Exit For
							End If
						Next
						If j <= UBound(TempSplit) Then
							' 多部位商品，不能拆开使用
							RetFlag = False
							Rs.Close
							Exit For
						End If
					Else
						' 不能使用根本不存在的商品
						RetFlag = False
						Rs.Close
						Exit For
					End If
					Rs.Close
				Else
					If i = 6 Or i = 7 Or i = 8 Or i = 10 Or i = 12 Or i = 13 Or i = 17 Then
						' 基本的身体部位必须存在
						RetFlag = False
						Exit For
					End If
				End If
			Next
		End If
	End If
	CheckPhotoAvatar = RetFlag
End Function

Function ReplaceHTML(Str)
	Dim re,s
	
	S = Str
	Set re = new RegExp
	re.IgnoreCase = True
	re.Global = True
	re.Pattern = "<(.[^>]*)>"
	s = re.Replace(s, "")
	Set Re = Nothing
	ReplaceHTML = s
End Function

Function isAllowShow(AvatarStr)
	Dim AvatarSplit, TempSplit
	
	AvatarSplit = Split(AvatarStr, "|")
	If UBound(AvatarSplit) <> 24 Then
		isAllowShow = False
		Exit Function
	End If
	If AvatarSplit(6) = "" Or AvatarSplit(7) = "" Or AvatarSplit(8) = "" Or AvatarSplit(10) = "" Or AvatarSplit(12) = "" Or AvatarSplit(13) = "" Or AvatarSplit(17) = "" Then
		isAllowShow = False
		Exit Function
	End If
	If AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("IsAllow").Text = "0" Then
		TempSplit = Split(AvatarSplit(7), ".")
		If TempSplit(0) < 15 Then
			isAllowShow = False
			Exit Function
		End If
		TempSplit = Split(AvatarSplit(8), ".")
		If TempSplit(0) < 15 Then
			isAllowShow = False
			Exit Function
		End If
	End If
	isAllowShow = True
End Function

Function CalcLineCount(StrText, LineDelimiter)
	Dim LineCount, CurPos, StrLength

	If StrText = "" Then
		CalcLineCount = 0
		Exit Function
	End If
	LineCount = 1
	CurPos = 1
	StrLength = Len(StrText)
	Do While CurPos <= StrLength
		CurPos = InStr(CurPos, LCase(StrText), LCase(LineDelimiter))
		If CurPos > 0 Then
			CurPos = CurPos + Len(LineDelimiter)
			LineCount = LineCount + 1
		Else
			CurPos = StrLength + 1
		End If
	Loop
	CalcLineCount = LineCount
End Function

Function FilterAvatarLayer(AvatarStr)
	Dim AvatarSplit, i, RetValue
	
	AvatarSplit = Split(AvatarStr, "|")
	RetValue = ""
	For i = 0 To UBound(AvatarSplit)
		If i > 0 Then RetValue = RetValue & "|"
		If AvatarSplit(i) <> "" Then RetValue = RetValue & Split(AvatarSplit(i), ".")(0)
	Next
	FilterAvatarLayer = RetValue
End Function

Function IntUp(TheNumber)
	IntUp = - Int(- TheNumber)
End Function

Sub GetPhotoXML(XMLDOM, PhotoID)
	Dim Node, SubNode
		
	Call LoadAvatarInfo(XMLDOM)
	If PhotoID = "" Then
		Set Node = XMLDOM.createNode(1, "ErrorInfo", "")
		XMLDOM.documentElement.appendChild (Node)
		Set SubNode = XMLDOM.createNode(2, "ErrCode", "")
		SubNode.Text = -1
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "Description", "")
		SubNode.Text = "没有指定照片编号!"
		Node.attributes.setNamedItem (SubNode)
	ElseIf Not Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_Photo Where ID=" & PhotoID & " And Finished=1").Eof Then
		Call LoadPhotoInfo(XMLDOM, PhotoID, 497)
		Set Node = XMLDOM.createNode(1, "ErrorInfo", "")
		XMLDOM.documentElement.appendChild (Node)
		Set SubNode = XMLDOM.createNode(2, "ErrCode", "")
		SubNode.Text = 0
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "Description", "")
		SubNode.Text = "成功!"
		Node.attributes.setNamedItem (SubNode)
	ElseIf Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_Photo Where ID=" & PhotoID).Eof Then
		Set Node = XMLDOM.createNode(1, "ErrorInfo", "")
		XMLDOM.documentElement.appendChild (Node)
		Set SubNode = XMLDOM.createNode(2, "ErrCode", "")
		SubNode.Text = -2
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "Description", "")
		SubNode.Text = "该照片不存在!"
		Node.attributes.setNamedItem (SubNode)
	Else
		Set Node = XMLDOM.createNode(1, "ErrorInfo", "")
		XMLDOM.documentElement.appendChild (Node)
		Set SubNode = XMLDOM.createNode(2, "ErrCode", "")
		SubNode.Text = -3
		Node.attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "Description", "")
		SubNode.Text = "该照片尚未设计完成!"
		Node.attributes.setNamedItem (SubNode)
	End If
	Set Node = Nothing
	Set SubNode = Nothing
End Sub

Function CreateAvatarPhoto(PhotoID)
	Dim XMLDOM, PhotoURL, RetValue
	
	Set XMLDOM = Server.CreateObject("msxml2.FreeThreadedDOMDocument"& MsxmlVersion)
	Call GetPhotoXML(XMLDOM, PhotoID)
	If Len(XMLDOM.documentElement.selectSingleNode("CurrentPhotoInfo").attributes.getNamedItem("PhotoURL").text) < 5 Then
		Randomize
		PhotoURL = "Photo_" & PhotoID & "_" & Right("000000" & Int(Rnd * 1000000), 6) & ".png"
	Else
		PhotoURL = XMLDOM.documentElement.selectSingleNode("CurrentPhotoInfo").attributes.getNamedItem("PhotoURL").text
		PhotoURL = Left(PhotoURL, Len(PhotoURL) - 4) & ".png"
	End If
	If AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("CanCreateImage").text = "1" Then
		If AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("CreatePhotoMode").Text = "0" Then
			RetValue = CreateAvatarPhoto_1(XMLDOM, PhotoID, PhotoURL)
			If RetValue = 0 Then
				CreateAvatarPhoto = PhotoURL
			Else
				If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
				v_ErrCodes = v_ErrCodes & "<li>生成照片时发生错误，错误代码是：" & RetValue & "！"
				CreateAvatarPhoto = ""
			End If
		Else
			RetValue = RequestAvatarPhoto_1(PhotoID, PhotoURL)
			If RetValue = 0 Then
				CreateAvatarPhoto = PhotoURL
			Else
				CreateAvatarPhoto = ""
			End If
		End If
	Else
		If AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("CreatePhotoMode").Text = "0" Then
			If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
			v_ErrCodes = v_ErrCodes & "<li>服务器暂时关闭了照片生成功能！"
		End If
		CreateAvatarPhoto = ""
	End If
	Set XMLDOM = Nothing
End Function 

Function CreateRemoteAvatarPhoto(URL, PhotoID, ResponseData)
	Dim XMLDOM, RetValue, RemoteData
	
	Set XMLDOM = Server.CreateObject("msxml2.FreeThreadedDOMDocument"& MsxmlVersion)
	If Right(URL, 1) <> "/" Then URL = URL & "/"
	If LCase(Left(URL, 7)) <> "http://" Then URL = "http://" & URL
	URL = URL & "Plus_Avatar_Photo.asp?PhotoID=" & PhotoID & "&action=xml"
	XMLDOM.Async = False
	XMLDOM.ValidateOnParse = False
	RemoteData = GetRemoteText(URL)
	If ChrW(AscB(LeftB(RemoteData, 1))) = "E" And ChrW(AscB(MidB(RemoteData, 2, 1))) = "r" And ChrW(AscB(MidB(RemoteData, 3, 1))) = "r" Then
		v_ErrCodes = RemoteData
		CreateRemoteAvatarPhoto = ""
		Set XMLDOM = Nothing
		Exit Function
	ElseIf Not XMLDOM.LoadXML(RemoteData) Then
		v_ErrCodes = "Err,生成照片时发生错误，" & URL & "不是一个有效的连接或者XML文档尚未准备就绪！"
		CreateRemoteAvatarPhoto = ""
		Set XMLDOM = Nothing
		Exit Function
	ElseIf XMLDOM.documentElement.selectSingleNode("ErrorInfo").attributes.getNamedItem("ErrCode").text <> "0" Then
		v_ErrCodes = "Err,生成照片时发生错误，" & XMLDOM.documentElement.selectSingleNode("ErrorInfo").attributes.getNamedItem("Description").text & "！"
		CreateRemoteAvatarPhoto = ""
		Set XMLDOM = Nothing
		Exit Function
	End If
	ResponseData = ""
	RetValue = CreateAvatarPhoto_1(XMLDOM, PhotoID, ResponseData)
	If RetValue = 0 Then
		With XMLDOM.documentElement.selectSingleNode("CurrentPhotoInfo").attributes
			CreateRemoteAvatarPhoto = .getNamedItem("PhotoID").text & "|||" & .getNamedItem("PhotoName").text & "|||" & .getNamedItem("PhotoDate").text & "|||" & .getNamedItem("PhotoSponsor").text & "|||" & .getNamedItem("PhotoParticipator").text & "|||" & .getNamedItem("PhotoUserCount").text
		End With
	Else
		v_ErrCodes = "Err,生成照片时发生错误，错误代码是：" & RetValue & "！"
		CreateRemoteAvatarPhoto = ""
	End If
	Set XMLDOM = Nothing
End Function 

Function RequestAvatarPhoto_1(PhotoID, PhotoURL)
	Dim Node, AdoObj, URL, RemoteData, TempStr, FSOObj, FileName

	Set Node = AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes
	On Error Resume Next
	Set AdoObj = Server.CreateObject ("Adodb.Stream")
	If Err <> 0 Then
		Err.Clear
		On Error Goto 0
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>远程生成照片时发生错误，无法使用ADODB.Stream组件！"
		RequestAvatarPhoto_1 = -1001
		Exit Function
	End If
	On Error Goto 0
	URL = Node.getNamedItem("RemotePhotoServer").text & "Plus_Avatar_RemoteCreate.asp?MyURL=" & Server.URLEncode(Dvbbs.Forum_Info(1)) & "&PhotoID=" & PhotoID & "&UserName=" & Server.URLEncode(Node.getNamedItem("RemotePhotoUserName").text) & "&Password=" & Server.URLEncode(Node.getNamedItem("RemotePhotoPassword").text)
	RemoteData = GetRemoteFile(URL)
	If IsNull(RemoteData) Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>远程生成照片时发生错误，远程服务器地址错误，或服务器暂时关闭！"
		Set AdoObj = Nothing
		RequestAvatarPhoto_1 = -1002
		Exit Function
	ElseIf ChrW(AscB(LeftB(RemoteData, 1))) = "E" And ChrW(AscB(MidB(RemoteData, 2, 1))) = "r" And ChrW(AscB(MidB(RemoteData, 3, 1))) = "r" Then
		TempStr = Bytes2BStr(RemoteData)
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>远程生成照片时发生错误，" & Right(TempStr, Len(TempStr) - 4)
		Set AdoObj = Nothing
		RequestAvatarPhoto_1 = -1003
		Exit Function
	ElseIf ChrW(AscB(MidB(RemoteData, 2, 1))) <> "P" And ChrW(AscB(MidB(RemoteData, 3, 1))) <> "N" And ChrW(AscB(MidB(RemoteData, 4, 1))) <> "G" Then
		If v_ErrCodes <> "" Then v_ErrCodes = v_ErrCodes & "<br>"
		v_ErrCodes = v_ErrCodes & "<li>远程生成照片时发生错误，远程服务器出现如下异常：" & Bytes2BStr(RemoteData)
		Set AdoObj = Nothing
		RequestAvatarPhoto_1 = -1004
		Exit Function
	Else
		AdoObj.Type = 1
		AdoObj.Open
		AdoObj.Write RemoteData
		AdoObj.Position = 0
		Set FSOObj = Server.Createobject("Scripting.FileSystemObject")
		FileName = Server.MapPath(Node.getNamedItem("PhotoPath").text & PhotoURL)
		If FSOObj.FileExists(FileName) Then FSOObj.DeleteFile FileName
		Set FSOObj = Nothing
		AdoObj.SaveToFile FileName
		AdoObj.Close
	End If
	Set AdoObj = Nothing
	RequestAvatarPhoto_1 = 0
End Function

Function CreateAvatarPhoto_1(XMLDOM, PhotoID, PhotoURL)
	Dim Node, SubNode, ImgObj, RemoteURL, PhotoPath
	Dim i, j, k, BodySplit, BodyLayerArray(), TempLayer

	Set Node = AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes
	If PhotoURL = "" Then
		RemoteURL = XMLDOM.documentElement.selectSingleNode("/Plus_Avatar").attributes.getNamedItem("ForumURL").text
		IF Right(RemoteURL, 1) <> "/" Then RemoteURL = RemoteURL & "/"
		If LCase(Left(RemoteURL, 7)) <> "http://" Then RemoteURL = "http://" & RemoteURL
		PhotoPath = RemoteURL & XMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoPath").text
	Else
		RemoteURL = ""
		PhotoPath = AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").attributes.getNamedItem("PhotoPath").text
	End If
	With XMLDOM.documentElement.selectSingleNode("CurrentPhotoInfo").attributes
		On Error Resume Next
		Set ImgObj = Server.CreateObject("ASPPainter.Pictures")
		If Err <> 0 Then
			Err.Clear
			On Error Goto 0
			CreateAvatarPhoto_1 = -1
			Exit Function
		End If
		On Error Goto 0
		If .getNamedItem("PhotoUploadFile").text <> "" Then
			If Not ResizeImageFile_1(Node, ImgObj, PhotoPath & .getNamedItem("PhotoUploadFile").text, .getNamedItem("PhotoBgWidth").text, .getNamedItem("PhotoBgHeight").text, True, 0) Then
				Set ImgObj = Nothing
				CreateAvatarPhoto_1 = -2
				Exit Function
			End If
		ElseIf .getNamedItem("PhotoBackground").text <> "" Then
			If Not OpenImageFile_1(Node, ImgObj, .getNamedItem("PhotoBackground").text, 0) Then
				Set ImgObj = Nothing
				CreateAvatarPhoto_1 = -3
				Exit Function
			End If
			Call CropImage_1(ImgObj, 0, 0, .getNamedItem("PhotoBgWidth").text, .getNamedItem("PhotoBgHeight").text, 0)
		Else
			Call CreateBlankImage_1(ImgObj, .getNamedItem("PhotoBgWidth").text, .getNamedItem("PhotoBgHeight").text, 0)
		End If
		If .getNamedItem("PhotoBodyBack").text <> "" Then
			If Not MergeImageFile_1(Node, ImgObj, .getNamedItem("PhotoBodyBack").text, 0) Then
				ImgObj.DestroyAll
				Set ImgObj = Nothing
				CreateAvatarPhoto_1 = -4
				Exit Function
			End If
		End If
		i = 0
		For Each SubNode In XMLDOM.documentElement.selectNodes("/Plus_Avatar/CurrentPhotoInfo/PhotoAccouterment")
			If SubNode.attributes.getNamedItem("ItemID").text <> "" Then
				If Not ResizeImageFile_1(Node, ImgObj, SubNode.attributes.getNamedItem("ItemID").text, SubNode.attributes.getNamedItem("InnerWidth").text, SubNode.attributes.getNamedItem("InnerHeight").text, False, 1) Then
					ImgObj.DestroyAll
					Set ImgObj = Nothing
					CreateAvatarPhoto_1 = -5
					Exit Function
				End If
				Call CropImage_1(ImgObj, - CLng(SubNode.attributes.getNamedItem("InnerLeft").text), - CLng(SubNode.attributes.getNamedItem("InnerTop").text), SubNode.attributes.getNamedItem("OuterWidth").text, SubNode.attributes.getNamedItem("OuterHeight").text, 1)
				Call RotateImage_1(ImgObj, (CLng(SubNode.attributes.getNamedItem("Direction").text) Mod 4), 1)
				Call FlipImage_1(ImgObj, (CLng(SubNode.attributes.getNamedItem("Direction").text) \ 4), 1)
				Call MergeImage_1(ImgObj, SubNode.attributes.getNamedItem("OuterLeft").text, SubNode.attributes.getNamedItem("OuterTop").text, 0, 1)
				ImgObj.SetImageIndex 1
				ImgObj.Destroy
				ImgObj.SetImageIndex 0
			End If
			i = i + 1
			If i > 2 Then Exit For
		Next
		i = 0
		ReDim BodyLayerArray(CLng(.getNamedItem("PhotoUserCount").text) - 1)
		For Each SubNode In XMLDOM.documentElement.selectNodes("/Plus_Avatar/CurrentPhotoInfo/PhotoUser")
			BodyLayerArray(i) = CLng(SubNode.attributes.getNamedItem("LayerNo").text)
			i = i + 1
		Next
		For i = 0 To UBound(BodyLayerArray) - 1
			For j = i + 1 To UBound(BodyLayerArray)
				If BodyLayerArray(i) > BodyLayerArray(j) Then
					TempLayer = BodyLayerArray(i)
					BodyLayerArray(i) = BodyLayerArray(j)
					BodyLayerArray(j) = TempLayer
				End If
			Next
		Next
		For k = 0 To UBound(BodyLayerArray)
			Set SubNode = XMLDOM.documentElement.selectSingleNode("/Plus_Avatar/CurrentPhotoInfo/PhotoUser[@LayerNo='" & BodyLayerArray(k) & "']")
			BodySplit = Split(SubNode.attributes.getNamedItem("UserAvaSetting").text, "|")
			For i = 0 To UBound(BodySplit)
				If (i >= 4 And i <= 20) Or (CLng(.getNamedItem("PhotoUserCount").text) = 1 And i >= 2 And i <= 23) Then
					If BodySplit(i) <> "" Then Exit For
				End If
			Next
			If i <= UBound(BodySplit) Then
				If InStr(BodySplit(i), ".") Then
					If Not OpenImageFile_1(Node, ImgObj, BodySplit(i), 1) Then
						ImgObj.DestroyAll
						Set ImgObj = Nothing
						CreateAvatarPhoto_1 = -6
						Exit Function
					End If
				Else
					If Not OpenImageFile_1(Node, ImgObj, BodySplit(i) & "." & (i + 1), 1) Then
						ImgObj.DestroyAll
						Set ImgObj = Nothing
						CreateAvatarPhoto_1 = -7
						Exit Function
					End If
				End If
				Call CropImage_1(ImgObj, 0, 0, Node.getNamedItem("AvatarWidth").text, Node.getNamedItem("AvatarHeight").text, 1)
				For j = i To UBound(BodySplit)
					If (j >= 4 And j <= 20) Or (CLng(.getNamedItem("PhotoUserCount").text) = 1 And j >= 2 And j <= 23) Then
						If BodySplit(j) <> "" Then
							If InStr(BodySplit(j), ".") Then
								If Not MergeImageFile_1(Node, ImgObj, BodySplit(j), 1) Then
									ImgObj.DestroyAll
									Set ImgObj = Nothing
									CreateAvatarPhoto_1 = -8
									Exit Function
								End If
							Else
								If Not MergeImageFile_1(Node, ImgObj, BodySplit(j) & "." & (j + 1), 1) Then
									ImgObj.DestroyAll
									Set ImgObj = Nothing
									CreateAvatarPhoto_1 = -9
									Exit Function
								End If
							End If
						End If
					End If
				Next
				Call ResizeImage_1(Node, ImgObj, SubNode.attributes.getNamedItem("AvatarInnerWidth").text, SubNode.attributes.getNamedItem("AvatarInnerHeight").text, 1)
				Call CropImage_1(ImgObj, - CLng(SubNode.attributes.getNamedItem("AvatarInnerLeft").text), - CLng(SubNode.attributes.getNamedItem("AvatarInnerTop").text), SubNode.attributes.getNamedItem("AvatarOuterWidth").text, SubNode.attributes.getNamedItem("AvatarOuterHeight").text, 1)
				Call RotateImage_1(ImgObj, (CLng(SubNode.attributes.getNamedItem("AvatarDirection").text) Mod 4), 1)
				Call FlipImage_1(ImgObj, (CLng(SubNode.attributes.getNamedItem("AvatarDirection").text) \ 4), 1)
				Call MergeImage_1(ImgObj, SubNode.attributes.getNamedItem("AvatarOuterLeft").text, SubNode.attributes.getNamedItem("AvatarOuterTop").text, 0, 1)
				ImgObj.SetImageIndex 1
				ImgObj.Destroy
				ImgObj.SetImageIndex 0
			End If
		Next
		i = 0
		For Each SubNode In XMLDOM.documentElement.selectNodes("/Plus_Avatar/CurrentPhotoInfo/PhotoAccouterment")
			If i > 2 Then
				If SubNode.attributes.getNamedItem("ItemID").text <> "" Then
					If Not ResizeImageFile_1(Node, ImgObj, SubNode.attributes.getNamedItem("ItemID").text, SubNode.attributes.getNamedItem("InnerWidth").text, SubNode.attributes.getNamedItem("InnerHeight").text, False, 1) Then
						ImgObj.DestroyAll
						Set ImgObj = Nothing
						CreateAvatarPhoto_1 = -10
						Exit Function
					End If
					Call CropImage_1(ImgObj, - CLng(SubNode.attributes.getNamedItem("InnerLeft").text), - CLng(SubNode.attributes.getNamedItem("InnerTop").text), SubNode.attributes.getNamedItem("OuterWidth").text, SubNode.attributes.getNamedItem("OuterHeight").text, 1)
					Call RotateImage_1(ImgObj, (CLng(SubNode.attributes.getNamedItem("Direction").text) Mod 4), 1)
					Call FlipImage_1(ImgObj, (CLng(SubNode.attributes.getNamedItem("Direction").text) \ 4), 1)
					Call MergeImage_1(ImgObj, SubNode.attributes.getNamedItem("OuterLeft").text, SubNode.attributes.getNamedItem("OuterTop").text, 0, 1)
					ImgObj.SetImageIndex 1
					ImgObj.Destroy
					ImgObj.SetImageIndex 0
				End If
			End If
			i = i + 1
		Next
		If .getNamedItem("PhotoBodyFront").text <> "" Then
			If Not MergeImageFile_1(Node, ImgObj, .getNamedItem("PhotoBodyFront").text, 0) Then
				ImgObj.DestroyAll
				Set ImgObj = Nothing
				CreateAvatarPhoto_1 = -11
				Exit Function
			End If
		End If
		If .getNamedItem("PhotoForeground").text <> "" Then
			If Not MergeImageFile_1(Node, ImgObj, .getNamedItem("PhotoForeground").text, 0) Then
				ImgObj.DestroyAll
				Set ImgObj = Nothing
				CreateAvatarPhoto_1 = -12
				Exit Function
			End If
		End If
		For Each SubNode In XMLDOM.documentElement.selectNodes("/Plus_Avatar/CurrentPhotoInfo/PhotoUser")
			If SubNode.attributes.getNamedItem("UserNameColor").text <> "" Then
				Call TextOutImage(Node, ImgObj, SubNode.attributes.getNamedItem("UserName").text, SubNode.attributes.getNamedItem("UserNameLeft").text, SubNode.attributes.getNamedItem("UserNameWidth").text, SubNode.attributes.getNamedItem("UserNameTop").text, SubNode.attributes.getNamedItem("UserNameFont").text, SubNode.attributes.getNamedItem("UserNameSize").text, SubNode.attributes.getNamedItem("UserNameBold").text, SubNode.attributes.getNamedItem("UserNameItalic").text, SubNode.attributes.getNamedItem("UserNameColor").text, SubNode.attributes.getNamedItem("UserNameDirection").text, 0)
			End If
		Next
		If .getNamedItem("PhotoNameFontColor").text <> "" Then
			Call TextOutImage(Node, ImgObj, .getNamedItem("PhotoName").text, .getNamedItem("PhotoNameLeft").text, .getNamedItem("PhotoNameWidth").text, .getNamedItem("PhotoNameTop").text, .getNamedItem("PhotoNameFontName").text, .getNamedItem("PhotoNameFontSize").text, .getNamedItem("PhotoNameFontBold").text, .getNamedItem("PhotoNameFontItalic").text, .getNamedItem("PhotoNameFontColor").text, .getNamedItem("PhotoNameDirection").text, 0)
		End If
		If .getNamedItem("PhotoDateFontColor").text <> "" Then
			Call TextOutImage(Node, ImgObj, .getNamedItem("PhotoDate").text, .getNamedItem("PhotoDateLeft").text, .getNamedItem("PhotoDateWidth").text, .getNamedItem("PhotoDateTop").text, .getNamedItem("PhotoDateFontName").text, .getNamedItem("PhotoDateFontSize").text, .getNamedItem("PhotoDateFontBold").text, .getNamedItem("PhotoDateFontItalic").text, .getNamedItem("PhotoDateFontColor").text, .getNamedItem("PhotoDateDirection").text, 0)
		End If
	End With
	If PhotoURL = "" Then
		PhotoURL = SaveToResponse_1(ImgObj, 0)
	Else
		Call SaveToFile_1(ImgObj, Node.getNamedItem("PhotoPath").text & PhotoURL, 0)
	End If
	ImgObj.DestroyAll
	Set ImgObj = Nothing
	CreateAvatarPhoto_1 = 0
End Function

Sub SaveToFile_1(ImgObj, FileURL, ImageIndex)
	Dim OldImageIndex
	
	OldImageIndex = ImgObj.GetImageIndex
	If OldImageIndex <> ImageIndex Then ImgObj.SetImageIndex ImageIndex
	ImgObj.SetFormat 0
	ImgObj.SaveTofile Server.MapPath(FileURL)
	If OldImageIndex <> ImageIndex Then ImgObj.SetImageIndex OldImageIndex
End Sub

Function SaveToResponse_1(ImgObj, ImageIndex)
	Dim OldImageIndex, ResponseData
	
	OldImageIndex = ImgObj.GetImageIndex
	If OldImageIndex <> ImageIndex Then ImgObj.SetImageIndex ImageIndex
	ImgObj.SetFormat 0
	ResponseData = ImgObj.SaveToStream()
	SaveToResponse_1 = ResponseData
	If OldImageIndex <> ImageIndex Then ImgObj.SetImageIndex OldImageIndex
End Function

Function OpenImageFile_1(Node, ImgObj, pFile, ImageIndex)
	Dim ImageFileURL
	
	ImageFileURL = GetItemPicURL(Node, pFile)
	If Node.getNamedItem("LocalPic").Text = 1 Then
		OpenImageFile_1 = OpenLocalImageFile_1(ImgObj, ImageFileURL, ImageIndex)
	Else
		OpenImageFile_1 = OpenRemoteImageFile_1(ImgObj, ImageFileURL, ImageIndex)
	End If
End Function

Function OpenLocalImageFile_1(ImgObj, pFile, ImageIndex)
	Dim OldImageIndex
	
	OldImageIndex = ImgObj.GetImageIndex
	If OldImageIndex <> ImageIndex Then ImgObj.SetImageIndex ImageIndex
	On Error Resume Next
	ImgObj.LoadFile Server.MapPath(pFile)
	If Err <> 0 Then
		Err.Clear
		ImgObj.Destroy
		OpenLocalImageFile_1 = False
	Else
		OpenLocalImageFile_1 = True
	End If
	On Error Goto 0
	If OldImageIndex <> ImageIndex Then ImgObj.SetImageIndex OldImageIndex
End Function

Function OpenRemoteImageFile_1(ImgObj, pFile, ImageIndex)
	Dim OldImageIndex, RemoteData
	
	OldImageIndex = ImgObj.GetImageIndex
	If OldImageIndex <> ImageIndex Then ImgObj.SetImageIndex ImageIndex
	RemoteData = GetRemoteFile(pFile)
	If IsNull(RemoteData) Then
		OpenRemoteImageFile_1 = False
	Else
		On Error Resume Next
		ImgObj.LoadStream(RemoteData)
		If Err <> 0 Then
			Err.Clear
			OpenRemoteImageFile_1 = False
		Else
			OpenRemoteImageFile_1 = True
		End If
		On Error Goto 0
	End If
	If OldImageIndex <> ImageIndex Then ImgObj.SetImageIndex OldImageIndex
End Function

Sub CreateBlankImage_1(ImgObj, Width, Height, ImageIndex)
	Dim OldImageIndex
	
	OldImageIndex = ImgObj.GetImageIndex
	If OldImageIndex <> ImageIndex Then ImgObj.SetImageIndex ImageIndex
	ImgObj.SetBkColor 255, 255, 255, 255
	ImgObj.Create Width, Height
	ImgObj.SetColor 255, 255, 255, 255
	ImgObj.setColorAsTransparent
	If OldImageIndex <> ImageIndex Then ImgObj.SetImageIndex OldImageIndex
End Sub

Function ResizeImageFile_1(Node, ImgObj, pFile, Width, Height, bForcedLocal, ImageIndex)
	Dim OldWidth, OldHeight
	Dim OldImageIndex
	
	OldImageIndex = ImgObj.GetImageIndex
	If bForcedLocal Then
		If LCase(Left(pFile, 7)) = "http://" Then
			If Not OpenRemoteImageFile_1(ImgObj, pFile, 9) Then
				ResizeImageFile_1 = False
				Exit Function
			End If
		Else
			If Not OpenLocalImageFile_1(ImgObj, pFile, 9) Then
				ResizeImageFile_1 = False
				Exit Function
			End If
		End If
	Else
		If Not OpenImageFile_1(Node, ImgObj, pFile, 9) Then
			ResizeImageFile_1 = False
			Exit Function
		End If
	End If
	ImgObj.SetImageIndex 9
	OldWidth = ImgObj.Width
	OldHeight = ImgObj.Height
	Call CreateBlankImage_1(ImgObj, Width, Height, ImageIndex)
	If Width <> OldWidth Or Height <> OldHeight Then
		ImgObj.ResizeCopy ImageIndex, 9, 0, 0, 0, 0, Width, Height, OldWidth, OldHeight
	Else
		ImgObj.Copy ImageIndex, 9, 0, 0, 0, 0, Width, Height
	End If
	ImgObj.SetImageIndex 9
	ImgObj.Destroy
	ImgObj.SetImageIndex OldImageIndex
	ResizeImageFile_1 = True
End Function

Function MergeImageFile_1(Node, ImgObj, pFile, ImageIndex)
	Dim Width, Height
	Dim OldImageIndex
	
	OldImageIndex = ImgObj.GetImageIndex
	If OldImageIndex <> ImageIndex Then ImgObj.SetImageIndex ImageIndex
	Width = ImgObj.Width
	Height = ImgObj.Height
	If Not OpenImageFile_1(Node, ImgObj, pFile, 9) Then
		MergeImageFile_1 = False
		Exit Function
	End If
	ImgObj.Merge ImageIndex, 9, 0, 0, 0, 0, Width, Height, 100
	ImgObj.SetImageIndex 9
	ImgObj.Destroy
	ImgObj.SetImageIndex OldImageIndex
	MergeImageFile_1 = True
End Function

Sub CropImage_1(ImgObj, Left, Top, Width, Height, ImageIndex)
	Dim OldImageIndex, TempData
	
	OldImageIndex = ImgObj.GetImageIndex
	If OldImageIndex <> ImageIndex Then ImgObj.SetImageIndex ImageIndex
	If Left = 0 And Top = 0 And Width = ImgObj.Width And Height = ImgObj.Height Then Exit Sub
	TempData = ImgObj.SaveToStream()
	ImgObj.SetImageIndex 9
	ImgObj.LoadStream(TempData)
	Call CreateBlankImage_1(ImgObj, Width, Height, ImageIndex)
	ImgObj.Merge ImageIndex, 9, 0, 0, Left, Top, Width, Height, 100
	ImgObj.SetImageIndex 9
	ImgObj.Destroy
	ImgObj.SetImageIndex OldImageIndex
End Sub

Sub RotateImage_1(ImgObj, RotateMode, ImageIndex)
	Dim NewWidth, NewHeight, ColorIndex, OldWidth, OldHeight
	Dim i, j, Red, Green, Blue, Alpha
	Dim OldImageIndex, TempData
	
	If RotateMode = 0 Then Exit Sub
	OldImageIndex = ImgObj.GetImageIndex
	If OldImageIndex <> ImageIndex Then ImgObj.SetImageIndex ImageIndex
	OldWidth = ImgObj.Width
	OldHeight = ImgObj.Height
	If RotateMode = 1 Or RotateMode = 3 Then
		NewWidth = ImgObj.Height
		NewHeight = ImgObj.Width
	ElseIf RotateMode = 2 Then
		NewWidth = ImgObj.Width
		NewHeight = ImgObj.Height
	End If
	ColorIndex = ImgObj.GetColorIndex
	TempData = ImgObj.SaveToStream()
	ImgObj.SetImageIndex 9
	ImgObj.LoadStream(TempData)
	Call CreateBlankImage_1(ImgObj, NewWidth, NewHeight, ImageIndex)
	ImgObj.SetImageIndex ImageIndex
	ImgObj.SetColorIndex ColorIndex
	For i = 1 To OldWidth
		For j = 1 To OldHeight
			ImgObj.SetImageIndex 9
			Red = ImgObj.GetPixelRed((i - 1), (j - 1))
			Green = ImgObj.GetPixelGreen((i - 1), (j - 1))
			Blue = ImgObj.GetPixelBlue((i - 1), (j - 1))
			Alpha = ImgObj.GetPixelAlpha((i - 1), (j - 1))
			ImgObj.SetImageIndex ImageIndex
			ImgObj.SetColor Red, Green, Blue, Alpha
			If RotateMode = 1 Then
				ImgObj.SetPixel OldHeight - (j - 1), (i - 1)
			ElseIf RotateMode = 2 Then
				ImgObj.SetPixel OldWidth - (i - 1), OldHeight - (j - 1)
			ElseIf RotateMode = 3 Then
				ImgObj.SetPixel (j - 1), OldWidth - (i - 1)
			End If
		Next
	Next
	ImgObj.SetImageIndex 9
	ImgObj.Destroy
	ImgObj.SetImageIndex OldImageIndex
End Sub

Sub FlipImage_1(ImgObj, FlipMode, ImageIndex)
	Dim OldImageIndex
	
	If FlipMode = 0 Then Exit Sub
	OldImageIndex = ImgObj.GetImageIndex
	If OldImageIndex <> ImageIndex Then ImgObj.SetImageIndex ImageIndex
	If FlipMode = 1 Or FlipMode = 3 Then
		ImgObj.HorizontalFlip
	End If
	If FlipMode = 2 Or FlipMode = 3 Then
		ImgObj.VerticalFlip
	End If
	If OldImageIndex <> ImageIndex Then ImgObj.SetImageIndex OldImageIndex
End Sub

Sub MergeImage_1(ImgObj, dstLeft, dstTop, dstImageIndex, srcImageIndex)
	Dim dstWidth, dstHeight, srcWidth, srcHeight, srcLeft, srcTop
	Dim OldImageIndex
	
	OldImageIndex = ImgObj.GetImageIndex
	ImgObj.SetImageIndex dstImageIndex
	dstWidth = ImgObj.Width
	dstHeight = ImgObj.Height
	ImgObj.SetImageIndex srcImageIndex
	srcWidth = ImgObj.Width
	srcHeight = ImgObj.Height
	If dstLeft < 0 Then
		srcLeft = - dstLeft
		srcWidth = srcWidth + dstLeft
		dstLeft = 0
	Else
		srcLeft = 0
	End If
	If dstTop < 0 Then
		srcTop = - dstTop
		srcHeight = srcHeight + dstTop
		dstTop = 0
	Else
		srcTop = 0
	End If
	If dstLeft + srcWidth > dstWidth Then
		srcWidth = dstWidth - dstLeft + 1
	End If
	If dstTop + srcHeight > dstHeight Then
		srcHeight = dstHeight - dstTop + 1
	End If
	If srcWidth > 0 And srcHeight > 0 Then
		ImgObj.Merge dstImageIndex, srcImageIndex, dstLeft, dstTop, srcLeft, srcTop, srcWidth, srcHeight, 100
	End If
	ImgObj.SetImageIndex OldImageIndex
End Sub

Function ResizeImage_1(Node, ImgObj, Width, Height, ImageIndex)
	Dim OldWidth, OldHeight
	Dim OldImageIndex, TempData
	
	OldImageIndex = ImgObj.GetImageIndex
	If OldImageIndex <> ImageIndex Then ImgObj.SetImageIndex ImageIndex
	OldWidth = ImgObj.Width
	OldHeight = ImgObj.Height
	If Width <> OldWidth Or Height <> OldHeight Then
		TempData = ImgObj.SaveToStream()
		ImgObj.SetImageIndex 9
		ImgObj.LoadStream(TempData)
		Call CreateBlankImage_1(ImgObj, Width, Height, ImageIndex)
		ImgObj.SetImageIndex ImageIndex
		ImgObj.ResizeCopy ImageIndex, 9, 0, 0, 0, 0, Width, Height, OldWidth, OldHeight
		ImgObj.SetImageIndex 9
		ImgObj.Destroy
	End If
	ImgObj.SetImageIndex OldImageIndex
End Function

Sub TextOutImage(Node, ImgObj, strText, TextLeft, TextWidth, TextTop, TextFontName, TextFontSize, TextFontBold, TextFontItalic, TextFontColor, TextDirection, ImageIndex)
	Dim OldImageIndex, HighPt, CurFontSize, CurPx
	
	OldImageIndex = ImgObj.GetImageIndex
	Call CreateBlankImage_1(ImgObj, TextWidth + 6, TextFontSize + 6, 8)
	ImgObj.SetImageIndex 8
	ImgObj.SetFontName TextFontName
	If ImgObj.ExistFont <> 1 Then ImgObj.SetFontName Node.getNamedItem("PhotoDefaultFontName").text
	HighPt = Cint(TextFontSize)
	CurFontSize = CInt(TextFontSize)
	Do While CurFontSize > 0
		ImgObj.SetFontSize CurFontSize
		CurPx = ImgObj.GetFontHeight
		If CurPx <= CInt(TextFontSize) Then
			Exit Do
		Else
			HighPt = CurFontSize
		End If
		CurFontSize = CurFontSize - 1
	Loop
	If CurFontSize <= 0 Then CurFontSize = 9
	CurFontSize = HighPt
	ImgObj.SetFontSize CurFontSize
	ImgObj.SetColor 0, 0, 0, 255
	ImgObj.SetFontBold TextFontBold
	ImgObj.SetFontItalic TextFontItalic
	ImgObj.TextOut 4, 4, Trim(strText)
	ImgObj.SetColor Hex2Dec(Mid(TextFontColor, 2, 2)), Hex2Dec(Mid(TextFontColor, 4, 2)), Hex2Dec(Mid(TextFontColor, 6, 2)), 255
	ImgObj.TextOut 3, 3, Trim(strText)
	Call RotateImage_1(ImgObj, (CLng(TextDirection) Mod 4), 8)
	Call FlipImage_1(ImgObj, (CLng(TextDirection) \ 4), 8)
	Call MergeImage_1(ImgObj, TextLeft, TextTop, ImageIndex, 8)
	ImgObj.SetImageIndex 8
	ImgObj.Destroy
	ImgObj.SetImageIndex OldImageIndex
End Sub

Function GetPicURL(LocalPic, ItemLayer, ItemNo)
	If LocalPic = 0 Then
		GetPicURL = ItemNo & "/" & ItemLayer & "/00/"
	Else
		GetPicURL = ItemLayer & "/" & ItemNo & ".Gif"
	End If
End Function

Function GetItemPicURL(Node, ItemID)
	Dim ItemSplit, LayerSplit
	
	ItemSplit = Split(ItemID, ".")
	If UBound(ItemSplit) > 0 Then
		LayerSplit = Split(ItemSplit(1), "_")
		GetItemPicURL = Node.getNamedItem("PicPath").text & GetPicURL(Node.getNamedItem("LocalPic").text, LayerSplit(0), ItemSplit(0))
	Else
		GetItemPicURL = Node.getNamedItem("PicPath").text & GetPicURL(Node.getNamedItem("LocalPic").text, "0", ItemSplit(0))
	End If
End Function

Function GetRemoteFile(url)
	Dim Retrieval

	Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP")
	With Retrieval
		.Open "Get", url, False, "", ""
		On Error Resume Next
		.Send
		If Err <> 0 Then
			Err.Clear
			GetRemoteFile = NULL
		Else
			GetRemoteFile = .ResponseBody
		End If
		On Error Goto 0
	End With
	Set Retrieval = Nothing
End Function

Function GetRemoteText(url)
	Dim Retrieval

	Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP")
	With Retrieval
		.Open "Get", url, False, "", ""
		On Error Resume Next
		.Send
		If Err <> 0 Then
			Err.Clear
			GetRemoteText = "Err,照片信息的URL错误！"
		Else
			GetRemoteText = .ResponseText
		End If
		On Error Goto 0
	End With
	Set Retrieval = Nothing
End Function

Function Hex2Dec(HexStr)
	Dim Result, i, ch
	
	Result = 0
	For i = 1 To Len(Trim(HexStr))
		ch = Mid(Trim(HexStr), i, 1)
		If UCase(ch) >= "A" And UCase(ch) <= "F" Then
			Result = Result * 16 + Asc(UCase(ch)) - 55
		ElseIf UCase(ch) >= "0" And UCase(ch) <= "9" Then
			Result = Result * 16 + Asc(UCase(ch)) - 48
		End If
	Next
	Hex2Dec = Result
End Function

Function Bytes2BSTR(vIn)
	Dim strReturn, i, ThisCharCode, NextCharCode
	
	strReturn = ""
	For i = 1 To LenB(vIn)
		ThisCharCode = AscB(MidB(vIn,i,1))
		If ThisCharCode < &H80 Then
			strReturn = strReturn & Chr(ThisCharCode)
		Else
			NextCharCode = AscB(MidB(vIn,i+1,1))
			strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
			i = i + 1
		End If
	Next
	Bytes2BSTR = strReturn
End Function

Sub DispUser_1(SQL)
	If Not Dvbbs.Forum_Setting(82)<>"0" then
		SQL = Replace(SQL, " From ", ",UserAvaSetting From ")
	End If
End Sub

Sub DispUser_2(UserInfo, TempPart1, UserName)
	If Not Dvbbs.Forum_Setting(82)<>"0" Then
		Dim AvatarFlag
		AvatarFlag = True
		If IsNull(UserInfo(40)) Or UserInfo(40) = "" Then
			AvatarFlag = False
		ElseIf UBound(Split(UserInfo(40), "|")) <> 24 Then
			AvatarFlag = False
		Else
			UserInfo(40) = Replace(UserInfo(40), Chr(13), "")
		End If
		If Not AvatarFlag Then
			If UserInfo(7) = "1" Then
				UserInfo(40) = DefaultAvatarBoy
			Else
				UserInfo(40) = DefaultAvatarGirl
			End If
		End If
		TempPart1=Replace(TempPart1,"{$UserAvaSetting}",UserInfo(40))
		TempPart1=Replace(TempPart1,"{$UserIsAva}","1")
	Else
		TempPart1=Replace(TempPart1,"{$UserAvaSetting}","")
		TempPart1=Replace(TempPart1,"{$UserIsAva}","0")
	End If
	If Not Dvbbs.Forum_Setting(82) <> "0" Then
		If LCase(Trim(UserName)) = LCase(Trim(Dvbbs.MemberName)) Then
			TempPart1=Replace(TempPart1,"{$AvatarTitle}","您的虚拟形象")
			TempPart1=Replace(TempPart1,"{$AvatarUserName}","")
		Else
			TempPart1=Replace(TempPart1,"{$AvatarTitle}",UserName & "的虚拟形象")
			TempPart1=Replace(TempPart1,"{$AvatarUserName}",UserName)
		End If
		With AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes
			TempPart1=Replace(TempPart1,"{$AvatarWidth}",.getNamedItem("AvatarWidth").Text)
			TempPart1=Replace(TempPart1,"{$AvatarHeight}",.getNamedItem("AvatarHeight").Text)
			TempPart1=Replace(TempPart1,"{$InnerLeft1}",.getNamedItem("InnerLeft1").Text)
			TempPart1=Replace(TempPart1,"{$InnerTop1}",.getNamedItem("InnerTop1").Text)
			TempPart1=Replace(TempPart1,"{$InnerWidth1}",.getNamedItem("InnerWidth1").Text)
			TempPart1=Replace(TempPart1,"{$InnerHeight1}",.getNamedItem("InnerHeight1").Text)
			TempPart1=Replace(TempPart1,"{$InnerLeft2}",.getNamedItem("InnerLeft2").Text)
			TempPart1=Replace(TempPart1,"{$InnerTop2}",.getNamedItem("InnerTop2").Text)
			TempPart1=Replace(TempPart1,"{$InnerWidth2}",.getNamedItem("InnerWidth2").Text)
			TempPart1=Replace(TempPart1,"{$InnerHeight2}",.getNamedItem("InnerHeight2").Text)
			TempPart1=Replace(TempPart1,"{$LocalPic}",.getNamedItem("LocalPic").Text)
			TempPart1=Replace(TempPart1,"{$PicPath}",.getNamedItem("PicPath").Text)
		End With
	End If
End Sub

Sub UserManager_1(MainTable, UserFace)
	If Not Dvbbs.Forum_Setting(82) <> "0" Then
		If v_MyUserIsAva = 1 Or AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("AllowFace").Text = "0" Then
			If v_MyUserIsAva = 0 Then v_MyUserIsAva = 1
			With AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes
				If v_ToolByUser <> "" Then
					MainTable=Replace(MainTable,"{$user_Face}","<script language='javascript' src='Dv_Plus/Avatar/Plus_Avatar_Show.js'></script>" & _
						"<script language=javascript>DvbbsShowAvatar('" & v_MyAvatar & "," & v_ToolByUser & "','1','" & v_MyUserIsAva & "','0','" & .getNamedItem("AvatarWidth").text & "','" & .getNamedItem("AvatarHeight").text & "','" & .getNamedItem("InnerLeft1").text & "','" & .getNamedItem("InnerTop1").text & "','" & .getNamedItem("InnerWidth1").text & "','" & .getNamedItem("InnerHeight1").text & "','" & .getNamedItem("InnerLeft2").text & "','" & .getNamedItem("InnerTop2").text & "','" & .getNamedItem("InnerWidth2").text & "','" & .getNamedItem("InnerHeight2").text & "','','" & .getNamedItem("LocalPic").text & "','" & .getNamedItem("PicPath").text & "','0','0','您的虚拟形象','');</script>")
				Else
					MainTable=Replace(MainTable,"{$user_Face}","<script language='javascript' src='Dv_Plus/Avatar/Plus_Avatar_Show.js'></script>" & _
						"<script language=javascript>DvbbsShowAvatar('" & v_MyAvatar & "','1','" & v_MyUserIsAva & "','0','" & .getNamedItem("AvatarWidth").text & "','" & .getNamedItem("AvatarHeight").text & "','" & .getNamedItem("InnerLeft1").text & "','" & .getNamedItem("InnerTop1").text & "','" & .getNamedItem("InnerWidth1").text & "','" & .getNamedItem("InnerHeight1").text & "','" & .getNamedItem("InnerLeft2").text & "','" & .getNamedItem("InnerTop2").text & "','" & .getNamedItem("InnerWidth2").text & "','" & .getNamedItem("InnerHeight2").text & "','','" & .getNamedItem("LocalPic").text & "','" & .getNamedItem("PicPath").text & "','0','0','您的虚拟形象','');</script>")
				End If
			End With
			MainTable=Replace(MainTable,"用户头像","用户形象")
		Else
			MainTable=Replace(MainTable,"{$user_Face}",Dv_FilterJS(UserFace))
		End If
	Else
		MainTable=Replace(MainTable,"{$user_Face}",Dv_FilterJS(UserFace))
	End If
End Sub

Sub Index_1(XMLDOM)
	Dim AvatarFlag
	
	AvatarFlag = False
	If Not Dvbbs.Forum_Setting(82) <> "0" Then
		XMLDom.documentElement.appendChild(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").cloneNode(True))
		Call GetCurrentUserInfoXML(AvatarXMLDOM, 100)
		XMLDom.documentElement.appendChild(AvatarXMLDOM.documentElement.selectSingleNode("CurrentUserInfo").cloneNode(True))
		If (v_MyUserIsAva = 1 Or AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("AllowFace").Text = "0") Then
			AvatarFlag = True
		End If
		If AvatarFlag Then
			XMLDom.documentElement.selectSingleNode("CurrentUserInfo").Attributes.getNamedItem("MyUserIsAva").Text = "1"
		Else
			XMLDom.documentElement.selectSingleNode("CurrentUserInfo").Attributes.getNamedItem("MyUserIsAva").Text = "0"
		End If
	End If
End Sub

Sub Dispbbs_1(XMLDOM)
	If Not Dvbbs.Forum_Setting(82) <> "0" Then
		XMLDom.documentElement.appendChild(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").cloneNode(True))
	End If
End Sub

Sub Plus_Tools_Postings_1(NewUserName)
	Dvbbs.Plus_Execute("update Dv_Plus_Avatar_MyItems set username = '" & NewUserName & "' Where username='" & Dvbbs.MemberName & "'")
	Dvbbs.Plus_Execute("update Dv_Plus_Avatar_MyItems set fromuser = '" & NewUserName & "' Where fromuser='" & Dvbbs.MemberName & "'")
	Dvbbs.Plus_Execute("update Dv_Plus_Avatar_Favorite set username = '" & NewUserName & "' Where username='" & Dvbbs.MemberName & "'")
	Dvbbs.Plus_Execute("update Dv_Plus_Avatar_Photo set fromuser = '" & NewUserName & "' Where fromuser='" & Dvbbs.MemberName & "'")
	Dvbbs.Plus_Execute("update Dv_Plus_Avatar_PhotoUser set username = '" & NewUserName & "' Where username='" & Dvbbs.MemberName & "'")
End Sub

Sub Plus_Tools_Postings_2()
	Dim UserAvaSetting, ToolByUser, Rs

	Response.Write "<tr><td height=23 class=Tablebody1 colspan=2 align=center>"
	Response.Write "<B>该用户免疫的整人道具</B>"
	Response.Write "</td></tr>"
	UserAvaSetting = Dvbbs.Execute("Select Top 1 UserAvaSetting From Dv_User Where UserName='" & Dv_Tools.ToUserInfo(1) & "'")(0)
	If InStr(UserAvaSetting, ",") > 0 Then
		ToolByUser = Split(UserAvaSetting, ",")(1)
		UserAvaSetting = Split(UserAvaSetting, ",")(0)
	Else
		ToolByUser = ""
	End If
	Set Rs = Dvbbs.Plus_Execute("Select m.ItemID,i.Name,m.Period,m.FixDate,m.Type From Dv_Plus_Avatar_MyItems m Inner Join Dv_Plus_Avatar_Items i On m.ItemID=i.ID Where i.Class=6 And m.UserName='" & Dv_Tools.ToUserInfo(1) & "'")
	Do While Not Rs.Eof
		Response.Write "<tr>"
		Response.Write "<td height=23 class=Tablebody1 width=""30%"" align=right>《<b>" & Rs(1) & "</b>》</td>"
		Response.Write "<td height=23 class=Tablebody1 width=""70%"">"
		If InStr("|" & UserAvaSetting, "|" & Rs(0) & ".") > 0 Then
			Response.Write "正在被<b>" & ToolByUser & "</b>整蛊中，"
		ElseIf Rs(4) = 5 Then
			Response.Write "正在出售中，"
		End If
		If Rs(2) = 0 Then
			Response.Write "<font color=" & Dvbbs.MainSetting(1) & ">永不过期</font>"
		ElseIf DateDiff("d", Rs(3), Now()) >= Rs(2) Then
			Response.Write "已经过期"
		Else
			Response.Write "还有<b>" & (Rs(2) - DateDiff("d", Rs(3), Now())) & "</b>天过期"
		End If
		Response.Write "</td>"
		Response.Write "</tr>"
		Rs.MoveNext
	Loop
	Rs.Close
End Sub
%>