<%
Function alertMsg(str,url)
	dim urlstr 
	if url<>"" then
		urlstr="location.href='"&url&"'"
	end if
	echo("<script>alert('"&str&"');"&urlstr&"</script>")
End Function


Function echo(str)
	response.write(str)
End Function


Function die()
	response.End()
End Function

Function URLDecode(enStr)
  dim deStr
  dim c,i,v
  deStr=""
  for i=1 to len(enStr)
  c=Mid(enStr,i,1)
  if c="%" then
  v=eval("&h"+Mid(enStr,i+1,2))
  if v<128 then
  deStr=deStr&chr(v)
  i=i+2
  else
  if isvalidhex(mid(enstr,i,3)) then
  if isvalidhex(mid(enstr,i+3,3)) then
  v=eval("&h"+Mid(enStr,i+1,2)+Mid(enStr,i+4,2))
  deStr=deStr&chr(v)
  i=i+5
  else
  v=eval("&h"+Mid(enStr,i+1,2)+cstr(hex(asc(Mid(enStr,i+3,1)))))
  deStr=deStr&chr(v)
  i=i+3 
  end if 
  else 
  destr=destr&c
  end if
  end if
  else
  if c="+" then
  deStr=deStr&" "
  else
  deStr=deStr&c
  end if
  end if
  Next
  URLDecode=deStr
end Function

Function isvalidhex(str)
  dim c
  isvalidhex=true
  str=ucase(str)
  if len(str)<>3 then isvalidhex=false:exit Function
  if left(str,1)<>"%" then isvalidhex=false:exit Function
  c=mid(str,2,1)
  if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit Function
  c=mid(str,3,1)
  if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit Function
end Function 


Function openUrl(url,responsetype)
	dim http
	set http=server.createobject("microsoft.xmlhttp")
	http.open "get",url,false
	http.send
	if http.readystate<>4 then
		exit Function
	end if
	if responsetype=1 then
		openUrl = http.responsetext
	elseif responsetype=2 then	
		openUrl=bytesToBSTR(http.responseBody,"utf-8")
	end if
	set http=nothing
End Function


Function bytesToBstr(body,cset)
	dim objstream,s
	s="stream"
	set objstream = Server.CreateObject("adodb."&s)
	objstream.Type = 1
	objstream.Mode =3
	objstream.Open
	objstream.Write body
	objstream.Position = 0
	objstream.Type = 2
	objstream.Charset = cset
	bytesToBstr = objstream.ReadText
	objstream.Close
	set objstream = nothing
End Function


Function getForm(element,ftype)
	Select case ftype
		case "get"
			getForm=request.QueryString(element)
			Exit Function
		case "post"
			getForm=request.Form(element)
			Exit Function
		case "both"
			getForm=request(element)
			Exit Function
	End Select
End Function


Function fsoFileRead(filepath) 
	dim objfso,objcoungfile 
	Set objfso = Server.CreateObject("Scripting.FileSystemObject") 
	Set objcoungfile = objfso.OpenTextFile(Server.MapPath(filepath),1,True) 
	If objCountFile.AtEndOfStream = false Then fsoFileRead = objcoungfile.ReadAll 
	objcoungfile.Close 
	Set objcoungfile=Nothing 
	Set objfso = Nothing 
End Function


Function createFolder(foldername) 
	dim objfso,objfolder
	Set objfso = server.createobject("Scripting.FileSystemObject")
	Set objfolder = objfso.CreateFolder(Server.MapPath(foldername))
	createFolder = objfolder.Path
	Set objfolder=nothing
	Set objfso=nothing
End Function


Function IsFolder(Folder)
	dim fso
    Set fso = server.createobject("Scripting.FileSystemObject")
	If fso.FolderExists(server.MapPath(Folder)) Then  
		IsFolder = True
	Else
		IsFolder = False
	End If
	Set fso=nothing
End Function

Function createHtml(path,str)
	dim getfolder,fcount,folder,fso,fout
	getfolder=split(path,"/")
	For fcount=0 to Ubound(getfolder)-1
		if folder="" then
			folder=getfolder(fcount)
		else
			folder=folder&"/"&getfolder(fcount)
		end if
		If IsFolder(folder)=false then
			createFolder folder
		End if
	Next
	Set fso = Server.CreateObject("Scripting.FileSystemObject")
	Set fout = fso.CreateTextFile(server.mappath(path))
	fout.Write str
	fout.close
	set fout=nothing
	set fso = nothing
End Function

Function own_http()
		dim ssort
		ssort=trim(request.servervariables("server_port"))
		own_http="http://"&trim(request.servervariables("server_name"))
		if ssort<>"80" then own_http=own_http&":"&ssort
		if right(own_http,1)<>"/" then own_http=own_http&"/"
End Function


Function createXmlObj(strxml)
	dim xmlobj
	Set xmlobj = Server.CreateObject("Microsoft.XMLDOM") 
	xmlobj.validateonparse = true     '告诉解析器文件是否有效
	xmlobj.async=false 
	xmlobj.loadXML(strxml)
	set createXmlObj=xmlobj
	set xmlobj=nothing 
End Function



Function getUnionResourceTypeList(ccuserid)
	dim httpreq,strxml,xmldoc,options,str_typelist,typelength,bigtypename,options2,smalltypelength,smalltypevalue,smallbigtypename
	response.Charset="gb2312"
	'echo "http://trade.bokecc.com/trade/action/getcategory.jsp?uid="&ccuserid
	'die
	strxml=openUrl("http://trade.bokecc.com/trade/action/getcategory.jsp?uid="&ccuserid,1)
	If Left(strxml, 5) <> "<?xml" Or InStr(strxml, "</root>") = 0 Then
 	    echo strxml
  		die()
	End If
	set xmldoc=createXmlObj(strxml)
	set options=xmldoc.selectNodes("root/playlists")
	str_typelist="<div style='background-color:#89C3E4; width:100%; height:25px;padding-top:5px;'><span style='font-size:14px; color:red;border:2px solid red;margin-left: 20px;'>点 此 拖 动</span><span style='float:right;margin-right: 15px;margin-top: -15px;font-size:14px;'onclick=""document.getElementById('categoryNameDiv').style.display='none'""><a href=# ><b> 关 闭 分 类 列 表 </b></a></span></div>"
	for typelength=0 to options.length-1
		bigtypename=options(typelength).GetAttributeNode("name").Nodevalue
		set options2=options(typelength).selectNodes("playlist")
		str_typelist=str_typelist&"<ul>"
		str_typelist=str_typelist&"<div>"&bigtypename&"</div>"
		for smalltypelength=0 to options2.length-1
			smalltypevalue=options2(smalltypelength).GetAttributeNode("id").Nodevalue
			smallbigtypename=options2(smalltypelength).GetAttributeNode("name").Nodevalue
			str_typelist=str_typelist&"<li>"&smalltypevalue&":"&smallbigtypename&"</li>"
		next
		str_typelist=str_typelist+"</ul>"
	next
	str_typelist="<div class='netstyle'  >"&str_typelist&"</div>"
	if err.number<>0	 then 
		str_typelist="<div class='netstyle'   >"&lang_errordes_array(0)&err.number&"---"&lang_errordes_array(0)&err.description&"</div>"
	end if
	set options=nothing
	set options2=nothing
	echo str_typelist
	die()
end Function

%>