<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp" -->
<!--#include file="Dv_Plus/Avatar/Plus_Avatar_Const.asp"-->
<%
Dim ShopID, CurPage, Sex, CurType, isBig, AvatarPageSize, TotalRec, PageCount, CurTypeName, CurSubTypeName

If Dvbbs.Forum_Setting(82) <> "0" Then
	Response.redirect "showerr.asp?ErrCodes=<li>该论坛尚未开启虚拟形象功能，不能查看形象商品！&action=plus"
Else
	ShopID = Dvbbs.CheckStr(Request("ShopID"))
	If Not IsNumeric(ShopID) Or IsNull(ShopID) Or ShopID = "" Then
		ShopID = 100
	ElseIf ShopID < 1 And Abs(ShopID Mod 100) <> 95 Then
		ShopID = 100
	End If
	CurType = (Abs(ShopID) Mod 100)
	If (CurType = 94 Or CurType = 95 Or CurType = 96 Or CurType = 97 Or CurType = 0) And Abs(ShopID) \ 100 <= 50 Then
		CurType = (Abs(ShopID) Mod 100)
		isBig = 0
		CurTypeName = GetTypeName(ShopID)
		CurSubTypeName = GetSubTypeName(ShopID)
	Else
		Set AvatarRs = Dvbbs.Plus_Execute("SELECT s.TypeID, s.isBig, t.TypeName, s.SubTypeName, s.ParentSubType, p.SubTypeName AS ParentName FROM (Dv_Plus_Avatar_SubType AS s LEFT JOIN Dv_Plus_Avatar_SubType AS p ON s.ParentSubType = p.ID) INNER JOIN Dv_Plus_Avatar_Type AS t ON t.ID = s.TypeID Where s.MyType=" & ShopID)
		If AvatarRs.EOF Or AvatarRs.Bof Then
			ShopID = 100
			CurType = 0
			isBig = 0
			CurTypeName = GetTypeName(ShopID)
			CurSubTypeName = GetSubTypeName(ShopID)
		Else
			CurType = AvatarRs(0)
			isBig = AvatarRs(1)
			CurTypeName = AvatarRs(2)
			If AvatarRs(4) <> 0 Then
				CurSubTypeName = AvatarRs(5) & "(" & AvatarRs(3) & ")"
			Else
				CurSubTypeName = AvatarRs(3)
			End If
		End If
		Set AvatarRs = Nothing
	End If
	If CurType = 97 Then
		Response.Write "<script>parent.location='Plus_Avatar_Photo.asp?ShopID=" & ShopID & "';</script>"
		Response.End
	End If
	If CurType = 94 Then
		Response.Write "<script>parent.location='Plus_Avatar_Match.asp?ShopID=" & ShopID & "';</script>"
		Response.End
	End If
	Sex = Dvbbs.CheckStr(Request("Sex"))
	If IsNull(Sex) Or Sex = "" Then Sex = v_CurSex
	If Sex = 2 Then Sex = ""
	CurPage = Request("page")
	If CurPage = "" Or Not isInteger(CurPage) Then
		CurPage = 1
	Else
		CurPage = CLng(CurPage)
	End If
	Dvbbs.LoadTemplates ("Avatar")
	If isBig = 0 Or isBig = 3 Then
		AvatarPageSize = CInt(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("ItemListCount").Text)
	ElseIf isBig = 1 Then
		AvatarPageSize = CInt(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("BigItemListCount").Text)
	Else
		AvatarPageSize = CInt(AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("BiggestItemListCount").Text)
	End If
	Call GetCurrentAvatarXML(AvatarXMLDOM)
	Call GetCurrentUserInfoXML(AvatarXMLDOM, ShopID)
	If CurType = 95 Then Call GetCurrentSearchXML(AvatarXMLDOM)
	Call ItemListToXML(AvatarXMLDOM)
	If Request("action") = "xml" Then
		Response.Clear
		Response.Charset = "gb2312"
		Response.ContentType = "text/xml"
		Response.Write "<?xml version=""1.0"" encoding=""gb2312""?>" & vbNewLine
		Response.Write AvatarXMLDOM.documentElement.XML
	Else
		Response.Expires=0
		Dvbbs.Head
		Response.Write vbNewLine
		Response.Write "<script>"
		Response.Write vbNewLine
		Response.Write "if (parent.location==self.location) parent.location='Plus_Avatar_Center.asp';"
		Response.Write vbNewLine
		Response.Write "</script>"
		Response.Write vbNewLine
		If NeedShowMsg Then Call ShowMessage
		Call Main
		Response.Write "</body></html>"
	End If
	Set AvatarXMLDOM = Nothing
End If

Sub ItemListToXML(XMLDOM)
	Dim AvatarSQL, CurItemClass, CurUserPrice, CurSexSQL, i, CurCount
	Dim Node, SubNode, EmptyNode
	
	If CurType = 0 Then
		If ShopID = 500 Then
			If v_MyVip <> 1 Then
				CurUserPrice = "Price1"
			Else
				CurUserPrice = "Price2"
			End If
			AvatarSQL = "Select m.ID as ItemID,m.ItemID as ItemNo,i.Name as ItemName,i.Sex As ItemSex,i.Content as ItemLayer,m.SalePrice as ItemInfo1,i." & CurUserPrice & " as ItemInfo2,m.Period as ItemInfo3,m.AddDate as ItemInfo4,m.FromUser as ItemInfo5,m.FixDate as ItemInfo6,i.Class From Dv_Plus_Avatar_MyItems m Inner Join Dv_Plus_Avatar_Items i On i.ID=m.ItemID Where m.Type=5 And m.UserName='" & Dvbbs.MemberName & "' Order By m.ID Desc"
		ElseIf ShopID = 600 Then
			If v_MyVip <> 1 Then
				CurUserPrice = "Price1"
			Else
				CurUserPrice = "Price2"
			End If
			AvatarSQL = "Select m.ID as ItemID,m.ItemID as ItemNo,i.Name as ItemName,i.Sex As ItemSex,i.Content as ItemLayer,m.Price as ItemInfo1,i." & CurUserPrice & " as ItemInfo2,m.Period as ItemInfo3,m.AddDate as ItemInfo4,m.FromUser as ItemInfo5,m.FixDate as ItemInfo6,i.Class From Dv_Plus_Avatar_MyItems m Inner Join Dv_Plus_Avatar_Items i On i.ID=m.ItemID Where m.Type=0 And m.UserName='" & Dvbbs.MemberName & "' Order By m.ID Desc"
		ElseIf ShopID = 800 Then
			AvatarSQL = "Select f.ID as ItemID,f.ItemID as ItemNo,i.Name as ItemName,i.Sex As ItemSex,i.Content as ItemLayer,i.Price1 as ItemInfo1,i.Price2 as ItemInfo2,i.Period as ItemInfo3,i.Quantity as ItemInfo4,i.Vip as ItemInfo5,i.Flag as ItemInfo6,i.Class From Dv_Plus_Avatar_Favorite f Inner Join Dv_Plus_Avatar_Items i On i.ID=f.ItemID Where f.UserName='" & Dvbbs.MemberName & "' Order By f.ID Desc"
		ElseIf ShopID = 700 Then
			If v_MyVip <> 1 Then
				CurUserPrice = "Price1"
			Else
				CurUserPrice = "Price2"
			End If
			AvatarSQL = "Select m.ID as ItemID,m.ItemID as ItemNo,i.Name as ItemName,i.Sex As ItemSex,i.Content as ItemLayer,m.Price as ItemInfo1,i." & CurUserPrice & " as ItemInfo2,m.Period as ItemInfo3,m.AddDate as ItemInfo4,m.FromUser as ItemInfo5,m.FixDate as ItemInfo6,i.Class From Dv_Plus_Avatar_MyItems m Inner Join Dv_Plus_Avatar_Items i On i.ID=m.ItemID Where m.Type=6 And '|" & v_MyAvatar & "' Not Like " & SqlConcateString("'%|'", "m.ItemID", "'.%'") & " And m.UserName='" & Dvbbs.MemberName & "' Order By m.ID Desc"
		Else
			CurItemClass = ShopID \ 100
			If v_MyVip <> 1 Then
				CurUserPrice = "Price1"
			Else
				CurUserPrice = "Price2"
			End If
			AvatarSQL = "Select m.ID as ItemID,m.ItemID as ItemNo,i.Name as ItemName,i.Sex As ItemSex,i.Content as ItemLayer,m.Price as ItemInfo1,i." & CurUserPrice & " as ItemInfo2,m.Period as ItemInfo3,m.AddDate as ItemInfo4,m.FromUser as ItemInfo5,m.FixDate as ItemInfo6,i.Class From Dv_Plus_Avatar_MyItems m Inner Join Dv_Plus_Avatar_Items i On i.ID=m.ItemID Where m.Type=" & CurItemClass & " And m.UserName='" & Dvbbs.MemberName & "' Order By m.ID Desc"
		End If
	ElseIf CurType = 96 Then
		If Sex = "1" Or Sex = "0" Then
			CurSexSQL = " And (i.Sex=" & Sex & " Or i.Sex=2)"
		Else
			CurSexSQL = ""
		End If
		If v_MyVip <> 1 Then
			CurUserPrice = "Price1"
		Else
			CurUserPrice = "Price2"
		End If
		CurItemClass = ShopID \ 100
		If ShopID = 596 Then CurItemClass = 6
		AvatarSQL = "Select m.ID as ItemID,m.ItemID as ItemNo,i.Name as ItemName,i.Sex As ItemSex,i.Content as ItemLayer,i." & CurUserPrice & " as ItemInfo1,m.SalePrice as ItemInfo2,i.Period as ItemInfo3,m.Period as ItemInfo4,m.FixDate as ItemInfo5,m.UserName as ItemInfo6,i.Class From Dv_Plus_Avatar_MyItems m Inner Join Dv_Plus_Avatar_Items i On i.ID=m.ItemID Where m.Type=5 And i.Class=" & CurItemClass & CurSexSQL & " Order By m.ID Desc"
	ElseIf CurType = 95 Then
		AvatarSQL = "Select ID as ItemID,ID as ItemNo,Name as ItemName,Sex as ItemSex,Content as ItemLayer,Price1 as ItemInfo1,Price2 as ItemInfo2,Period as ItemInfo3,Quantity as ItemInfo4,Vip as ItemInfo5,Flag as ItemInfo6,Class From Dv_Plus_Avatar_Items Where Flag>0 And Type>0 And Not (Content Is Null)"
		If Not (IsNull(Request("search_str")) Or Request("search_str") = "") Then
			AvatarSQL = AvatarSQL & " And Name Like '%" & Dvbbs.CheckStr(Trim(Request("search_str"))) & "%'"
		End If
		Select Case Request("selgender")
		Case "1"
			AvatarSQL = AvatarSQL & " And Sex=1"
		Case "2"
			AvatarSQL = AvatarSQL & " And Sex=0"
		Case "3"
			AvatarSQL = AvatarSQL & " And Sex=2"
		End Select
		If Not (IsNull(Request("selprice_l")) Or Request("selprice_l") = "") Then
			If isInteger(Request("selprice_l")) Then
				If v_MyVip <> 1 Then
					AvatarSQL = AvatarSQL & " And Price1>=" & Request("selprice_l")
				Else
					AvatarSQL = AvatarSQL & " And Price2>=" & Request("selprice_l")
				End If
			End If
		End If
		If Not (IsNull(Request("selprice_h")) Or Request("selprice_h") = "") Then
			If isInteger(Request("selprice_h")) Then
				If v_MyVip <> 1 Then
					AvatarSQL = AvatarSQL & " And Price1<=" & Request("selprice_h")
				Else
					AvatarSQL = AvatarSQL & " And Price2<=" & Request("selprice_h")
				End If
			End If
		End If
		If Not (IsNull(Request("selperiod_l")) Or Request("selperiod_l") = "") Then
			If isInteger(Request("selperiod_l")) Then
				AvatarSQL = AvatarSQL & " And Period>=" & Request("selperiod_l")
			End If
		End If
		If Not (IsNull(Request("selperiod_h")) Or Request("selperiod_h") = "") Then
			If isInteger(Request("selperiod_h")) Then
				AvatarSQL = AvatarSQL & " And period<=" & Request("selperiod_h")
			End If
		End If
		Select Case Request("selflag")
		Case "1", "2", "3", "4"
			AvatarSQL = AvatarSQL & " And Flag>=" & Request("selflag")
		End Select
		AvatarSQL = AvatarSQL & " Order By "
		Select Case Abs(ShopID)
		Case 195
			AvatarSQL = AvatarSQL & "ID"
		Case 295
			AvatarSQL = AvatarSQL & "DateAndTime"
		Case 395
			AvatarSQL = AvatarSQL & "Price1"
		Case 495
			AvatarSQL = AvatarSQL & "Price2"
		Case 595
			AvatarSQL = AvatarSQL & "Period"
		Case Else
			AvatarSQL = AvatarSQL & "Flag"
		End Select
		If ShopID > 0 Then
			AvatarSQL = AvatarSQL & " Asc"
		Else
			AvatarSQL = AvatarSQL & " Desc"
		End If
	Else
		If ShopID = 199 Then
			If Sex = "1" Or Sex = "0" Then
				CurSexSQL = " And (Sex=" & Sex & " or Sex=2)"
			Else
				CurSexSQL = ""
			End If
			If IsSqlDataBase = 0 Then
				AvatarSQL = "Select Top 100 ID as ItemID,ID as ItemNo,Name as ItemName,Sex as ItemSex,Content as ItemLayer,Price1 as ItemInfo1,Price2 as ItemInfo2,Period as ItemInfo3,Quantity as ItemInfo4,Vip as ItemInfo5,Flag as ItemInfo6,Class From Dv_Plus_Avatar_Items Where Flag>0 And Type>0 And Not (Content Is Null)" & CurSexSQL & " Order By Format(DateAndTime,'yyyy-mm-dd') Desc,ID Desc"
			Else
				AvatarSQL = "Select Top 100 ID as ItemID,ID as ItemNo,Name as ItemName,Sex as ItemSex,Content as ItemLayer,Price1 as ItemInfo1,Price2 as ItemInfo2,Period as ItemInfo3,Quantity as ItemInfo4,Vip as ItemInfo5,Flag as ItemInfo6,Class From Dv_Plus_Avatar_Items Where Flag>0 And Type>0 And Not (Content Is Null)" & CurSexSQL & " Order By Convert(varchar(10),DateAndTime,102) Desc,ID Desc"
			End If
		ElseIf ShopID = 299 Then
			If Sex = "1" Or Sex = "0" Then
				CurSexSQL = " And (Sex=" & Sex & " or Sex=2)"
			Else
				CurSexSQL = ""
			End If
			AvatarSQL = "Select Top 100 ID as ItemID,ID as ItemNo,Name as ItemName,Sex as ItemSex,Content as ItemLayer,Price1 as ItemInfo1,Price2 as ItemInfo2,Period as ItemInfo3,Quantity as ItemInfo4,Vip as ItemInfo5,Flag as ItemInfo6,Class From Dv_Plus_Avatar_Items Where Flag>0 And Type>0 And Not (Content Is Null) And TotalSales>0" & CurSexSQL & " Order By TotalSales Desc,ID Desc"
		ElseIf ShopID = 399 Then
			If Sex = "1" Or Sex = "0" Then
				CurSexSQL = " And (Sex=" & Sex & " or Sex=2)"
			Else
				CurSexSQL = ""
			End If
			AvatarSQL = "Select Top 100 ID as ItemID,ID as ItemNo,Name as ItemName,Sex as ItemSex,Content as ItemLayer,Price1 as ItemInfo1,Price2 as ItemInfo2,Period as ItemInfo3,Quantity as ItemInfo4,Vip as ItemInfo5,Flag as ItemInfo6,Class From Dv_Plus_Avatar_Items Where Flag>0 And Type>0 And Not (Content Is Null) And Vip<>0" & CurSexSQL & " Order By ID Desc"
		ElseIf ShopID = 499 Then
			If Sex = "1" Or Sex = "0" Then
				CurSexSQL = " And (Sex=" & Sex & " or Sex=2)"
			Else
				CurSexSQL = ""
			End If
			If v_MyVip <> 1 Then
				CurUserPrice = "Price1"
			Else
				CurUserPrice = "Price2"
			End If
			AvatarSQL = "Select Top 100 ID as ItemID,ID as ItemNo,Name as ItemName,Sex as ItemSex,Content as ItemLayer,Price1 as ItemInfo1,Price2 as ItemInfo2,Period as ItemInfo3,Quantity as ItemInfo4,Vip as ItemInfo5,Flag as ItemInfo6,Class From Dv_Plus_Avatar_Items Where Flag>0 And Type>0 And Not (Content Is Null) And " & CurUserPrice & "<=" & AvatarXMLDOM.documentElement.selectSingleNode("AvatarInfo").Attributes.getNamedItem("LowPrice").Text & CurSexSQL & " Order By ID Desc"
		Else
			If Sex = "1" Or Sex = "0" Then
				CurSexSQL = " And (Sex=" & Sex & " or Sex=2)"
			Else
				CurSexSQL = ""
			End If
			Set AvatarRs = Dvbbs.Plus_Execute("Select ID From Dv_Plus_Avatar_SubType Where MyType = " & ShopID & " And ParentSubType = 0")
			If Not AvatarRs.Eof Then
				Set AvatarRs = Dvbbs.Plus_Execute("Select MyType From Dv_Plus_Avatar_SubType Where ParentSubType = " & AvatarRs(0))
				If Not AvatarRs.Eof Then
					Dim TempStr
					TempStr = AvatarRs.GetString(,-1, "",",","0")
					TempStr = Left(TempStr, Len(TempStr) - 1)
					AvatarSQL = " And (Type = " & ShopID & " Or Type In (" & TempStr & "))"
				Else
					AvatarSQL = " And Type = " & ShopID
				End If
			Else
				AvatarSQL = " And Type = " & ShopID
			End If
			AvatarRs.Close
			Set AvatarRs = Nothing
			AvatarSQL = "Select ID as ItemID,ID as ItemNo,Name as ItemName,Sex as ItemSex,Content as ItemLayer,Price1 as ItemInfo1,Price2 as ItemInfo2,Period as ItemInfo3,Quantity as ItemInfo4,Vip as ItemInfo5,Flag as ItemInfo6,Class From Dv_Plus_Avatar_Items Where Flag>0 And Type>0 And Not (Content Is Null)" & AvatarSQL & CurSexSQL & " Order By ID Desc"
		End If
	End If
	CurCount = 0
	Set EmptyNode = XMLDOM.documentElement.selectSingleNode("AvatarItemList/Item").CloneNode(True)
	Set AvatarRs = Server.CreateObject("ADODB.Recordset")
	If Cint(Dvbbs.Forum_Setting(92))=1 Then
		If Not IsObject(Plus_Conn) Then Plus_ConnectionDatabase
		AvatarRs.Open AvatarSQL,Plus_Conn,1,1
	Else
		If Not IsObject(Conn) Then ConnectionDatabase
		AvatarRs.Open AvatarSQL,Conn,1,1
	End If
	If Not AvatarRs.EOF Then
		TotalRec = AvatarRs.RecordCount
		Set Node = XMLDOM.documentElement.selectSingleNode("CurrentInfo")
		Set SubNode = XMLDOM.createNode(2, "TotalRec", "")
		SubNode.Text = TotalRec
		Node.Attributes.setNamedItem (SubNode)
		If TotalRec Mod AvatarPageSize = 0 Then
			PageCount = TotalRec \ AvatarPageSize
		Else
			PageCount = TotalRec \ AvatarPageSize + 1
		End If
		Set SubNode = XMLDOM.createNode(2, "PageCount", "")
		SubNode.Text = PageCount
		Node.Attributes.setNamedItem (SubNode)
		If CurPage > PageCount Then CurPage = PageCount
		If CurPage < 1 Then CurPage = 1
		Set SubNode = XMLDOM.createNode(2, "CurPage", "")
		SubNode.Text = CurPage
		Node.Attributes.setNamedItem (SubNode)
		AvatarRs.MoveFirst
		If CurPage > 1 Then
			AvatarRs.Move (CurPage - 1) * AvatarPageSize
		End If
		AvatarSQL = AvatarRs.GetRows(AvatarPageSize)
		Set SubNode = XMLDOM.documentElement.selectSingleNode("AvatarItemList")
		For i = 0 To UBound(AvatarSQL, 2)
			If i > 0 Then
				Set Node = EmptyNode.CloneNode(True)
				SubNode.appendChild (Node)
			Else
				Set Node = XMLDOM.documentElement.selectSingleNode("AvatarItemList/Item")
			End If
			Node.Attributes.getNamedItem("ItemID").Text = AvatarSQL(0, i)
			Node.Attributes.getNamedItem("ItemNo").Text = AvatarSQL(1, i)
			Node.Attributes.getNamedItem("ItemName").Text = AvatarSQL(2, i)
			Node.Attributes.getNamedItem("ItemSex").Text = AvatarSQL(3, i)
			Node.Attributes.getNamedItem("ItemLayer").Text = AvatarSQL(4, i)
			Node.Attributes.getNamedItem("ItemInfo1").Text = AvatarSQL(5, i)
			Node.Attributes.getNamedItem("ItemInfo2").Text = AvatarSQL(6, i)
			If CurType = 0 And ShopID <> 800 Then
				If AvatarSQL(7, i) = 0 Then
					Node.Attributes.getNamedItem("ItemInfo3").Text = 0
				Else
					If AvatarSQL(7, i) = DateDiff("d", AvatarSQL(10, i), Now()) Then
						Node.Attributes.getNamedItem("ItemInfo3").Text = -1
					Else
						Node.Attributes.getNamedItem("ItemInfo3").Text = AvatarSQL(7, i) - DateDiff("d", AvatarSQL(10, i), Now())
					End If
				End If
				Node.Attributes.getNamedItem("ItemInfo4").Text = FormatDateTime(AvatarSQL(8, i), 2)
			Else
				Node.Attributes.getNamedItem("ItemInfo3").Text = AvatarSQL(7, i)
				If CurType = 96 Then
					If AvatarSQL(8, i) = 0 Then
						Node.Attributes.getNamedItem("ItemInfo4").Text = 0
					Else
						If AvatarSQL(8, i) = DateDiff("d", AvatarSQL(9, i), Now) Then
							Node.Attributes.getNamedItem("ItemInfo4").Text = -1
						Else
							Node.Attributes.getNamedItem("ItemInfo4").Text = AvatarSQL(8, i) - DateDiff("d", AvatarSQL(9, i), Now)
						End If
					End If
				Else
					Node.Attributes.getNamedItem("ItemInfo4").Text = AvatarSQL(8, i)
				End If
			End If
			If CurType = 0 And ShopID <> 800 Then
				If LCase(AvatarSQL(9, i)) = LCase(Dvbbs.MemberName) Then
					Node.Attributes.getNamedItem("ItemInfo5").Text = ""
				Else
					Node.Attributes.getNamedItem("ItemInfo5").Text = AvatarSQL(9, i)
				End If
			Else
				If CurType = 96 Then
					Node.Attributes.getNamedItem("ItemInfo5").Text = FormatDateTime(AvatarSQL(9, i), 2)
				Else
					Node.Attributes.getNamedItem("ItemInfo5").Text = AvatarSQL(9, i)
				End If
			End If
			If CurType = 0 And ShopID <> 800 Then
				If  DateDiff("n", AvatarSQL(8, i), AvatarSQL(10, i)) = 0 Then
					Node.Attributes.getNamedItem("ItemInfo6").Text = ""
				Else
					Node.Attributes.getNamedItem("ItemInfo6").Text = FormatDateTime(AvatarSQL(10, i), 2)
				End If
			Else
				Node.Attributes.getNamedItem("ItemInfo6").Text = AvatarSQL(10, i)
			End If
			Node.Attributes.getNamedItem("ItemClass").Text = AvatarSQL(11, i)
			If CurType = 0 And ShopID <> 800 Then
				Node.Attributes.getNamedItem("URLEncode").Text = Server.URLEncode(AvatarSQL(9, i))
			ElseIf CurType = 96 Then
				Node.Attributes.getNamedItem("URLEncode").Text = Server.URLEncode(AvatarSQL(10, i))
			Else
				Node.Attributes.getNamedItem("URLEncode").Text = ""
			End If
			If CurType = 0 Then
				If ShopID = 800 Then
					Node.Attributes.getNamedItem("isHas").Text = 0
				Else
					Node.Attributes.getNamedItem("isHas").Text = 1
				End If
			ElseIf Dvbbs.Plus_Execute("Select Top 1 ItemID From Dv_Plus_Avatar_MyItems Where ItemID=" & AvatarSQL(1, i) & " And UserName='" & Dvbbs.MemberName & "'").EOF Then
				Node.Attributes.getNamedItem("isHas").Text = 0
			Else
				Node.Attributes.getNamedItem("isHas").Text = 1
			End If
			If CurType = 96 And LCase(AvatarSQL(10, i)) = LCase(Dvbbs.MemberName) Then
				Node.Attributes.getNamedItem("isSellByMyself").Text = 1
			Else
				Node.Attributes.getNamedItem("isSellByMyself").Text = 0
			End If
			If Dvbbs.UserID > 0 Then
				If Dvbbs.Plus_Execute("Select Top 1 ID From Dv_Plus_Avatar_Favorite Where ItemID = " & AvatarSQL(1, i) & " And UserName = '" & Dvbbs.MemberName & "'").Eof Then
					Node.Attributes.getNamedItem("hasFavorite").Text = 0
				Else
					Node.Attributes.getNamedItem("hasFavorite").Text = 1
				End If
			Else
				Node.Attributes.getNamedItem("hasFavorite").Text = 0
			End If
			CurCount = CurCount + 1
		Next
	Else
		Set Node = XMLDOM.documentElement.selectSingleNode("CurrentInfo")
		Set SubNode = XMLDOM.createNode(2, "TotalRec", "")
		SubNode.Text = 0
		Node.Attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "PageCount", "")
		SubNode.Text = 0
		Node.Attributes.setNamedItem (SubNode)
		Set SubNode = XMLDOM.createNode(2, "CurPage", "")
		SubNode.Text = 0
		Node.Attributes.setNamedItem (SubNode)
	End If
	Set SubNode = XMLDOM.documentElement.selectSingleNode("AvatarItemList")
	If (CurCount Mod 2) <> 0 And CurCount < AvatarPageSize And CurCount > 0 Then
		For i = CurCount + 1 To CurCount + 1
			If i > 1 Then
				Set Node = EmptyNode.CloneNode(True)
			Else
				Set Node = XMLDOM.documentElement.selectSingleNode("AvatarItemList/Item")
			End If
			If i > 1 Then SubNode.appendChild (Node)
		Next
		CurCount = CurCount + 1
	ElseIf CurCount = 0 Then
		For i = 1 To 2
			If i > 1 Then
				Set Node = EmptyNode.CloneNode(True)
			Else
				Set Node = XMLDOM.documentElement.selectSingleNode("AvatarItemList/Item")
			End If
			If i > 1 Then SubNode.appendChild (Node)
		Next
		CurCount = 2
	End If
	Set Node = XMLDOM.documentElement.selectSingleNode("CurrentInfo")
	Set SubNode = XMLDOM.createNode(2, "FrameHeight", "")
	If Node.Attributes.getNamedItem("CurIsBig").Text = "0" Then
		SubNode.text = (CurCount \ 2) * 160 + 70
	ElseIf Node.Attributes.getNamedItem("CurIsBig").Text = "3" Then
		SubNode.text = (CurCount \ 2) * 185 + 70
	ElseIf Node.Attributes.getNamedItem("CurIsBig").Text = "1" Then
		SubNode.text = (CurCount \ 2) * 185 + 70
	Else
		SubNode.text = (CurCount \ 2) * 240 + 70
	End If
	Node.Attributes.setNamedItem (SubNode)
	Set Node = Nothing
	Set SubNode = Nothing
	AvatarRs.Close
	Set AvatarRs = Nothing
End Sub

Sub Main()
	Dim AvatarXSLT, AvatarXMLStyle, AvatarProc
	
	Set AvatarXMLStyle = Server.CreateObject("msxml2.FreeThreadedDOMDocument"& MsxmlVersion)
	'AvatarXMLStyle.loadXML template.HTML(2)
	AvatarXMLStyle.load Server.MapPath("Dv_Plus/Avatar/Plus_Avatar_Items.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
%>