<!--#include file = "private.asp"-->
<%
Dim sStyleID, sStyleName, sStyleDir, sStyleCSS, sStyleUploadDir, sStyleWidth, sStyleHeight, sStyleMemo, nStyleIsSys, sStyleStateFlag, sStyleDetectFromWord, sStyleInitMode, sStyleBaseUrl, sStyleUploadObject, sStyleAutoDir, sStyleBaseHref, sStyleContentPath, sStyleAutoRemote, sStyleShowBorder, sAutoDetectLanguage, sDefaultLanguage, sStyleAllowBrowse
Dim sSLTFlag, sSLTMinSize, sSLTOkSize, sSYWZFlag, sSYText, sSYFontColor, sSYFontSize, sSYFontName, sSYPicPath, sSLTSYObject, sSLTSYExt, sSYWZMinWidth, sSYShadowColor, sSYShadowOffset, sSYWZMinHeight, sSYWZPosition, sSYWZTextWidth, sSYWZTextHeight, sSYWZPaddingH, sSYWZPaddingV, sSYTPFlag, sSYTPMinWidth, sSYTPMinHeight, sSYTPPosition, sSYTPPaddingH, sSYTPPaddingV, sSYTPImageWidth, sSYTPImageHeight, sSYTPOpacity, sCusDirFlag
Dim sStyleFileExt, sStyleFlashExt, sStyleImageExt, sStyleMediaExt, sStyleRemoteExt, sStyleLocalExt, sStyleFileSize, sStyleFlashSize, sStyleImageSize, sStyleMediaSize, sStyleRemoteSize, sStyleLocalSize
Dim sToolBarID, sToolBarName, sToolBarOrder, sToolBarButton
Dim nStyleID
sPosition = sPosition & "样式管理"

If sAction = "STYLEPREVIEW" Then
	Call InitStyle()
	Call ShowStylePreview()
	Response.End
End If


Call Header()
Call ShowPosition()
Call Content()
Call Footer()


Sub Content()
	Select Case sAction
	Case "UPDATECONFIG"
		Call DoUpdateConfig()
	Case "COPY"
		Call InitStyle()
		Call DoCopy()
		Call ShowStyleList()
	Case "STYLEADD"
		Call ShowStyleForm("ADD")
	Case "STYLESET"
		Call InitStyle()
		Call ShowStyleForm("SET")
	Case "STYLEADDSAVE"
		Call CheckStyleForm()
		Call DoStyleAddSave()
	Case "STYLESETSAVE"
		Call CheckStyleForm()
		Call DoStyleSetSave()
	Case "STYLEDEL"
		Call InitStyle()
		Call DoStyleDel()
		Call ShowStyleList()
	Case "CODE"
		Call InitStyle()
		Call ShowStyleCode()
	Case "TOOLBAR"
		Call InitStyle()
		Call ShowToolBarList()
	Case "TOOLBARADD"
		Call InitStyle()
		Call DoToolBarAdd()
		Call ShowToolBarList()
	Case "TOOLBARMODI"
		Call InitStyle()
		Call DoToolBarModi()
		Call ShowToolBarList()
	Case "TOOLBARDEL"
		Call InitStyle()
		Call DoToolBarDel()
		Call ShowToolBarList()
	Case "BUTTONSET"
		Call InitStyle()
		Call InitToolBar()
		Call ShowButtonList()
	Case "BUTTONSAVE"
		Call InitStyle()
		Call InitToolBar()
		Call DoButtonSave()
	Case Else
		Call ShowStyleList()
	End Select
End Sub


Sub ShowPosition()
	Response.Write "<table border=0 cellspacing=1 align=center class=navi>" & _
		"<tr><th>" & sPosition & "</th></tr>" & _
		"<tr><td align=center>[<a href='?'>所有样式列表</a>]&nbsp;&nbsp;&nbsp;&nbsp;[<a href='?action=styleadd'>新建一样式</a>]&nbsp;&nbsp;&nbsp;&nbsp;[<a href='?action=updateconfig'>更新所有样式的前台配置文件</a>]</td></tr>" & _
		"</table><br>"
End Sub

Sub ShowMessage(str)
	Response.Write "<table border=0 cellspacing=1 align=center class=list><tr><td>" & str & "</td></tr></table><br>"
End Sub

Sub ShowStyleList()
	Call ShowMessage("<b class=blue>以下为当前所有样式列表：</b>")

	Response.Write "<table border=0 cellpadding=0 cellspacing=1 class=list align=center>" & _
		"<form action='?action=del' method=post name=myform>" & _
		"<tr align=center>" & _
			"<th width='10%'>样式名</th>" & _
			"<th width='10%'>最佳宽度</th>" & _
			"<th width='10%'>最佳高度</th>" & _
			"<th width='45%'>说明</th>" & _
			"<th width='25%'>管理</th>" & _
		"</tr>"

	Dim sManage, i, aCurrStyle
	For i = 1 To Ubound(aStyle)
		aCurrStyle = Split(aStyle(i), "|||")
		sManage = "<a href='?action=stylepreview&id=" & i & "' target='_blank'>预览</a>|<a href='?action=code&id=" & i & "'>代码</a>|<a href='?action=styleset&id=" & i & "'>设置</a>|<a href='?action=toolbar&id=" & i & "'>工具栏</a>|<a href='?action=copy&id=" & i & "'>拷贝</a>|<a href='?action=styledel&id=" & i & "' onclick=""return confirm('提示：您确定要删除此样式吗？')"">删除</a>"
		Response.Write "<tr align=center>" & _
			"<td>" & outHTML(aCurrStyle(0)) & "</td>" & _
			"<td>" & aCurrStyle(4) & "</td>" & _
			"<td>" & aCurrStyle(5) & "</td>" & _
			"<td align=left>" & outHTML(aCurrStyle(26)) & "</td>" & _
			"<td>" & sManage & "</td>" & _
			"</tr>"
	Next
	
	Response.Write "</table><br>"

	Call ShowMessage("<b class=blue>提示：</b>您可以通过“拷贝”样式以达到快速新建样式的目的。")

End Sub

Sub DoCopy()
	Dim i, b, sNewID, sNewName
	b = False
	i = 0
	Do While b = False
		i = i + 1
		sNewName = sStyleName & i
		If StyleName2ID(sNewName) = -1 Then
			b = True
		End If
	Loop

	Dim nNewStyleID
	nNewStyleID = Ubound(aStyle) + 1
	Redim Preserve aStyle(nNewStyleID)
	aStyle(nNewStyleID) = sNewName & Mid(aStyle(nStyleID), Len(sStyleName)+1)

	Dim nToolbarNum, nNewToolbarID, aCurrToolbar
	nToolbarNum = Ubound(aToolbar)
	For i = 1 To nToolbarNum
		aCurrToolbar = Split(aToolbar(i), "|||")
		If aCurrToolbar(0) = sStyleID Then
			nNewToolbarID = Ubound(aToolbar) + 1
			Redim Preserve aToolbar(nNewToolbarID)
			aToolbar(nNewToolbarID) = nNewStyleID & "|||" & aCurrToolbar(1) & "|||" & aCurrToolbar(2) & "|||" & aCurrToolbar(3)
		End If
	Next

	Call WriteConfig()
	Call WriteStyle(nNewStyleID)
	Call GoUrl("?")

End Sub

Function StyleName2ID(str)
	Dim i
	StyleName2ID = -1
	For i = 1 To UBound(aStyle)
		If Lcase(Split(aStyle(i), "|||")(0)) = Lcase(str) Then
			StyleName2ID = i
			Exit Function
		End If
	Next
End Function

Sub ShowStyleForm(sFlag)
	Dim s_Title, s_Action
	Dim s_FormStateFlag, s_FormDetectFromWord, s_FormInitMode, s_FormBaseUrl, s_FormUploadObject, s_FormAutoDir, s_FormAutoRemote, s_FormShowBorder, s_FormAutoDetectLanguage, s_FormDefaultLanguage, s_FormSLTFlag, s_FormSYWZFlag, s_FormSLTSYObject, s_FormAllowBrowse, s_FormSYTPFlag, s_FormSYWZPosition, s_FormSYTPPosition, s_FormCusDirFlag
	
	If sFlag = "ADD" Then
		sStyleID = ""
		sStyleName = ""
		sStyleDir = "blue"
		sStyleCSS = "coolblue"
		sStyleUploadDir = "UploadFile/"
		sStyleBaseHref = ""
		sStyleContentPath = ""
		sStyleWidth = "550"
		sStyleHeight = "350"
		sStyleMemo = ""
		nStyleIsSys = 0
		s_Title = "新增样式"
		s_Action = "StyleAddSave"
		sStyleFileExt = "rar|zip|exe|doc|xls|chm|hlp"
		sStyleFlashExt = "swf"
		sStyleImageExt = "gif|jpg|jpeg|bmp"
		sStyleMediaExt = "rm|mp3|wav|mid|midi|ra|avi|mpg|mpeg|asf|asx|wma|mov"
		sStyleRemoteExt = "gif|jpg|bmp"
		sStyleFileSize = "500"
		sStyleFlashSize = "100"
		sStyleImageSize = "100"
		sStyleMediaSize = "100"
		sStyleRemoteSize = "100"
		sStyleStateFlag = "1"
		sStyleAutoRemote = "1"
		sStyleShowBorder = "0"
		sAutoDetectLanguage = "1"
		sDefaultLanguage = "zh-cn"
		sStyleAllowBrowse = "0"
		sStyleUploadObject = "0"
		sStyleAutoDir = "0"
		sStyleDetectFromWord = "1"
		sStyleInitMode = "EDIT"
		sStyleBaseUrl = "1"
		sSLTFlag = "0"
		sSLTMinSize = "300"
		sSLTOkSize = "120"
		sSYWZFlag = "0"
		sSYText = "版权所有..."
		sSYFontColor = "000000"
		sSYFontSize = "12"
		sSYFontName = "宋体"
		sSYPicPath = ""
		sSLTSYObject = "0"
		sSLTSYExt = "bmp|jpg|jpeg|gif"
		sSYWZMinWidth = "100"
		sSYShadowColor = "FFFFFF"
		sSYShadowOffset = "1"
		sStyleLocalExt = "gif|jpg|bmp|wmz"
		sStyleLocalSize = "100"
		sSYWZMinHeight = "100"
		sSYWZPosition = "1"
		sSYWZTextWidth = "66"
		sSYWZTextHeight = "17"
		sSYWZPaddingH = "5"
		sSYWZPaddingV = "5"
		sSYTPFlag = "0"
		sSYTPMinWidth = "100"
		sSYTPMinHeight = "100"
		sSYTPPosition = "1"
		sSYTPPaddingH = "5"
		sSYTPPaddingV = "5"
		sSYTPImageWidth = "88"
		sSYTPImageHeight = "31"
		sSYTPOpacity = "1"
		sCusDirFlag = "0"
	Else
		sStyleName = inHTML(sStyleName)
		sStyleDir = inHTML(sStyleDir)
		sStyleCSS = inHTML(sStyleCSS)
		sStyleUploadDir = inHTML(sStyleUploadDir)
		sStyleBaseHref = inHTML(sStyleBaseHref)
		sStyleContentPath = inHTML(sStyleContentPath)
		sStyleMemo = inHTML(sStyleMemo)
		sSYText = inHTML(sSYText)
		sSYFontColor = inHTML(sSYFontColor)
		sSYFontSize = inHTML(sSYFontSize)
		sSYFontName = inHTML(sSYFontName)
		sSYPicPath = inHTML(sSYPicPath)
		s_Title = "设置样式"
		s_Action = "StyleSetSave"
	End If

	s_FormStateFlag = InitSelect("d_stateflag", Split("显示|不显示", "|"), Split("1|0", "|"), sStyleStateFlag, "", "")
	s_FormAutoRemote = InitSelect("d_autoremote", Split("自动上传|不自动上传", "|"), Split("1|0", "|"), sStyleAutoRemote, "", "")
	s_FormShowBorder = InitSelect("d_showborder", Split("默认显示|默认不显示", "|"), Split("1|0", "|"), sStyleShowBorder, "", "")
	s_FormAutoDetectLanguage = InitSelect("d_autodetectlanguage", Split("自动检测|不自动检测", "|"), Split("1|0", "|"), sAutoDetectLanguage, "", "")
	s_FormDefaultLanguage = InitSelect("d_defaultlanguage", Split("简体中文|繁体中文|英文", "|"), Split("zh-cn|zh-tw|en", "|"), sDefaultLanguage, "", "")
	s_FormAllowBrowse = InitSelect("d_allowbrowse", Split("是,开启|否,关闭", "|"), Split("1|0", "|"), sStyleAllowBrowse, "", "")

	s_FormUploadObject = InitSelect("d_uploadobject", Split("无组件上传类|ASPUpload上传组件|SA-FileUp上传组件|LyfUpload上传组件", "|"), Split("0|1|2|3", "|"), sStyleUploadObject, "", "")
	s_FormAutoDir = InitSelect("d_autodir", Split("不使用|年目录|年月目录|年月日目录", "|"), Split("0|1|2|3", "|"), sStyleAutoDir, "", "")
	s_FormDetectFromWord = InitSelect("d_detectfromword", Split("自动检测有提示|不自动检测", "|"), Split("1|0", "|"), sStyleDetectFromWord, "", "")
	s_FormInitMode = InitSelect("d_initmode", Split("代码模式|编辑模式|文本模式|预览模式", "|"), Split("CODE|EDIT|TEXT|VIEW", "|"), sStyleInitMode, "", "")
	s_FormBaseUrl = InitSelect("d_baseurl", Split("相对路径|绝对根路径|绝对全路径", "|"), Split("0|1|2", "|"), sStyleBaseUrl, "", "")

	s_FormSLTFlag = InitSelect("d_sltflag", Split("使用|不使用", "|"), Split("1|0", "|"), sSLTFlag, "", "")
	s_FormSYWZFlag = InitSelect("d_sywzflag", Split("使用|不使用", "|"), Split("1|0", "|"), sSYWZFlag, "", "")
	s_FormSLTSYObject = InitSelect("d_sltsyobject", Split("AspJpeg图形组件", "|"), Split("0", "|"), sSLTSYObject, "", "")

	s_FormSYTPFlag = InitSelect("d_sytpflag", Split("使用|不使用", "|"), Split("1|0", "|"), sSYTPFlag, "", "")
	s_FormSYWZPosition = InitSelect("d_sywzposition", Split("左上|左中|左下|中上|中中|中下|右上|右中|右下", "|"), Split("1|2|3|4|5|6|7|8|9", "|"), sSYWZPosition, "", "")
	s_FormSYTPPosition = InitSelect("d_sytpposition", Split("左上|左中|左下|中上|中中|中下|右上|右中|右下", "|"), Split("1|2|3|4|5|6|7|8|9", "|"), sSYTPPosition, "", "")
	s_FormCusDirFlag = InitSelect("d_cusdirflag", Split("禁用|启用", "|"), Split("0|1", "|"), sCusDirFlag, "", "")

	Response.Write "<table border=0 cellpadding=0 cellspacing=1 align=center class=form>" & _
			"<form action='?action=" & s_Action & "&id=" & sStyleID & "' method=post name=myform>" & _
			"<tr><th colspan=4>&nbsp;&nbsp;" & s_Title & "（鼠标移到输入框可看说明，带*号为必填项）</th></tr>" & _
			"<tr><td width='15%'>样式名称：</td><td width='35%'><input type=text class=input size=20 name=d_name title='引用此样式的名字，不要加特殊符号' value=""" & sStyleName & """> <span class=red>*</span></td><td width='15%'>初始模式：</td><td width='35%'>" & s_FormInitMode & " <span class=red>*</span></td></tr>" & _
			"<tr><td width='15%'>图片目录：</td><td width='35%'><input type=text class=input size=20 name=d_dir title='存放此样式图片文件的目录名，必须在ButtonImage下' value=""" & sStyleDir & """> <span class=red>*</span></td><td width='15%'>样式目录：</td><td width='35%'><input type=text class=input size=20 name=d_css title='存放此样式css文件的目录名，必须在CSS下' value=""" & sStyleCSS & """> <span class=red>*</span></td></tr>" & _
			"<tr><td width='15%'>最佳宽度：</td><td width='35%'><input type=text class=input name=d_width size=20 title='最佳引用效果的宽度，数字型' value='" & sStyleWidth & "'> <span class=red>*</span></td><td width='15%'>最佳高度：</td><td width='35%'><input type=text class=input name=d_height size=20 title='最佳引用效果的高度，数字型' value='" & sStyleHeight & "'> <span class=red>*</span></td></tr>" & _
			"<tr><td width='15%'>状 态 栏：</td><td width='35%'>" & s_FormStateFlag & " <span class=red>*</span></td><td width='15%'>Word粘贴：</td><td width='35%'>" & s_FormDetectFromWord & " <span class=red>*</span></td></tr>" & _
			"<tr><td width='15%'>远程文件：</td><td width='35%'>" & s_FormAutoRemote & " <span class=red>*</span></td><td width='15%'>指导方针：</td><td width='35%'>" & s_FormShowBorder & " <span class=red>*</span></td></tr>" & _
			"<tr><td width='15%'>自动语言检测：</td><td width='35%'>" & s_FormAutoDetectLanguage & " <span class=red>*</span></td><td width='15%'>默认语言：</td><td width='35%'>" & s_FormDefaultLanguage & " <span class=red>*</span></td></tr>" & _
			"<tr><td>备注说明：</td><td colspan=3><input type=text name=d_memo size=90 title='此样式的说明，更有利于调用' value=""" & sStyleMemo & """></td></tr>" & _
			"<tr><td colspan=4><span class=red>&nbsp;&nbsp;&nbsp;上传相关设置（只有在使用相对路径模式时，才要设置显示路径和内容路径）：</span></td></tr>" & _
			"<tr><td width='15%'>上传组件：</td><td width='35%'>" & s_FormUploadObject & " <span class=red>*</span></td><td width='15%'>年月日自动目录：</td><td width='35%'>" & s_FormAutoDir & " <span class=red>*</span></td></tr>" & _
			"<tr><td width='15%'>上传文件浏览：</td><td width='35%'>" & s_FormAllowBrowse & " <span class=red>*</span></td><td width='15%'>自定上传路径接口：</td><td width='35%'>" & s_FormCusDirFlag & "</td></tr>" & _
			"<tr><td width='15%'>路径模式：</td><td width='35%'>" & s_FormBaseUrl & " <span class=red>*</span> <a href='#baseurl'>说明</a></td><td width='15%'>上传路径：</td><td width='35%'><input type=text class=input size=20 name=d_uploaddir title='上传文件所存放路径，相对eWebEditor根目录文件的路径' value=""" & sStyleUploadDir & """> <span class=red>*</span></td></tr>" & _
			"<tr><td width='15%'>显示路径：</td><td width='35%'><input type=text class=input size=20 name=d_basehref title='显示内容页所存放路径，必须以&quot;/&quot;开头' value=""" & sStyleBaseHref & """></td><td width='15%'>内容路径：</td><td width='35%'><input type=text class=input size=20 name=d_contentpath title='实际保存在内容中的路径，相对显示路径的路径，不能以&quot;/&quot;开头' value=""" & sStyleContentPath & """></td></tr>" & _
			"<tr><td colspan=4><span class=red>&nbsp;&nbsp;&nbsp;允许上传文件类型及文件大小设置（文件大小单位为KB，0表示不允许）：</span></td></tr>" & _
			"<tr><td width='15%'>图片类型：</td><td width='35%'><input type=text class=input name=d_imageext size=20 title='用于图片相关的上传' value='" & sStyleImageExt & "'></td><td width='15%'>图片限制：</td><td width='35%'><input type=text class=input name=d_imagesize size=20 title='数字型，单位KB' value='" & sStyleImageSize & "'>KB</td></tr>" & _
			"<tr><td width='15%'>Flash类型：</td><td width='35%'><input type=text class=input name=d_flashext size=20 title='用于插入Flash动画' value='" & sStyleFlashExt & "'></td><td width='15%'>Flash限制：</td><td width='35%'><input type=text class=input name=d_flashsize size=20 title='数字型，单位KB' value='" & sStyleFlashSize & "'>KB</td></tr>" & _
			"<tr><td width='15%'>媒体类型：</td><td width='35%'><input type=text class=input name=d_mediaext size=20 title='用于插入媒体文件' value='" & sStyleMediaExt & "'></td><td width='15%'>媒体限制：</td><td width='35%'><input type=text class=input name=d_mediasize size=20 title='数字型，单位KB' value='" & sStyleMediaSize & "'>KB</td></tr>" & _
			"<tr><td width='15%'>其它类型：</td><td width='35%'><input type=text class=input name=d_fileext size=20 title='用于插入其它文件' value='" & sStyleFileExt & "'></td><td width='15%'>其它限制：</td><td width='35%'><input type=text class=input name=d_filesize size=20 title='数字型，单位KB' value='" & sStyleFileSize & "'>KB</td></tr>" & _
			"<tr><td width='15%'>远程类型：</td><td width='35%'><input type=text class=input name=d_remoteext size=20 title='用于自动上传远程文件' value='" & sStyleRemoteExt & "'></td><td width='15%'>远程限制：</td><td width='35%'><input type=text class=input name=d_remotesize size=20 title='数字型，单位KB' value='" & sStyleRemoteSize & "'>KB</td></tr>" & _
			"<tr><td width='15%'>本地类型：</td><td width='35%'><input type=text class=input name=d_localext size=20 title='用于自动上传本地文件' value='" & sStyleLocalExt & "'></td><td width='15%'>本地限制：</td><td width='35%'><input type=text class=input name=d_localsize size=20 title='数字型，单位KB' value='" & sStyleLocalSize & "'>KB</td></tr>" & _
			"<tr><td colspan=4><span class=red>&nbsp;&nbsp;&nbsp;缩略图及水印相关设置：</span></td></tr>" & _
			"<tr><td width='15%'>图形处理组件：</td><td width='35%'>" & s_FormSLTSYObject & "</td><td width='15%'>处理图形扩展名：</td><td width='35%'><input type=text name=d_sltsyext size=20 class=input value=""" & sSLTSYExt & """></td></tr>" & _
			"<tr><td width='15%'>缩略图使用状态：</td><td width='35%'>" & s_FormSLTFlag & "</td><td width='15%'>缩略图长度条件</td><td width='35%'><input type=text name=d_sltminsize size=20 class=input title='图形的长度只有达到此最小长度要求时才会生成缩略图，数字型' value='" & sSLTMinSize & "'>px</td></tr>" & _
			"<tr><td width='15%'>缩略图生成长度：</td><td width='35%'><input type=text name=d_sltoksize size=20 class=input title='生成的缩略图长度值，数字型' value='" & sSLTOkSize & "'>px</td><td width='15%'>&nbsp;</td><td width='35%'>&nbsp;</td></tr>" & _
			"<tr><td width='15%'>文字水印使用状态：</td><td width='35%'>" & s_FormSYWZFlag & "</td><td width='15%'>文字水印启用条件：</td><td width='35%'>宽:<input type=text name=d_sywzminwidth size=4 class=input title='图形的宽度只有达到此最小宽度要求时才会生成水印，数字型' value='" & sSYWZMinWidth & "'>px&nbsp; 高:<input type=text name=d_sywzminheight size=4 class=input title='图形的高度只有达到此最小高度要求时才会生成水印，数字型' value='" & sSYWZMinHeight & "'>px</td></tr>" & _
			"<tr><td width='15%'>文字水印内容：</td><td width='35%'><input type=text name=d_sytext size=20 class=input title='当使用文字水印时的文字内容' value=""" & sSYText & """></td><td width='15%'>文字水印字体颜色：</td><td width='35%'><input type=text name=d_syfontcolor size=20 class=input title='当使用文字水印时文字的颜色' value=""" & sSYFontColor & """></td></tr>" & _
			"<tr><td width='15%'>文字水印阴影颜色：</td><td width='35%'><input type=text name=d_syshadowcolor size=20 class=input title='当使用文字水印时的文字阴影颜色' value=""" & sSYShadowColor & """></td><td width='15%'>文字水印阴影大小：</td><td width='35%'><input type=text name=d_syshadowoffset size=20 class=input title='当使用文字水印时文字的阴影大小' value=""" & sSYShadowOffset & """>px</td></tr>" & _
			"<tr><td width='15%'>文字水印字体大小：</td><td width='35%'><input type=text name=d_syfontsize size=20 class=input title='当使用文字水印时文字的字体大小' value=""" & sSYFontSize & """>px</td><td width='15%'>文字水印字体名称：</td><td width='35%'><input type=text name=d_syfontname size=20 class=input title='当使用文字水印时文字的字体名' value=""" & sSYFontName & """></td></tr>" & _
			"<tr><td width='15%'>文字水印位置：</td><td width='35%'>" & s_FormSYWZPosition & "</td><td width='15%'>文字水印边距：</td><td width='35%'>左右:<input type=text name=d_sywzpaddingh size=4 class=input title='居左时作用为左边距，居右时作用为右边距，数字型' value='" & sSYWZPaddingH & "'>px&nbsp; 上下:<input type=text name=d_sywzpaddingv size=4 class=input title='居上时作用为上边距，居下时作用为下边柜，数字型' value='" & sSYWZPaddingV & "'>px</td></tr>" & _
			"<tr><td width='15%'>文字水印文字占位：</td><td width='35%'>宽:<input type=text name=d_sywztextwidth size=4 class=input title='水印文字的占位宽度，由字数、字体大小等设置的效果确定，数字型' value='" & sSYWZTextWidth & "'>px&nbsp; 高:<input type=text name=d_sywztextheight size=4 class=input title='水印文字的占位高度，由字数、字体大小等设置的效果确定，数字型' value='" & sSYWZTextHeight & "'>px&nbsp; <input type=button value='检测宽高' onclick='doCheckWH(1)'></td><td width='15%'></td><td width='35%'></td></tr>" & _
			"<tr><td width='15%'>图片水印使用状态：</td><td width='35%'>" & s_FormSYTPFlag & "</td><td width='15%'>图片水印启用条件：</td><td width='35%'>宽:<input type=text name=d_sytpminwidth size=4 class=input title='图形的宽度只有达到此最小宽度要求时才会生成水印，数字型' value='" & sSYTPMinWidth & "'>px&nbsp; 高:<input type=text name=d_sytpminheight size=4 class=input title='图形的高度只有达到此最小高度要求时才会生成水印，数字型' value='" & sSYTPMinHeight & "'>px</td></tr>" & _
			"<tr><td width='15%'>图片水印位置：</td><td width='35%'>" & s_FormSYTPPosition & "</td><td width='15%'>图片水印边距：</td><td width='35%'>左右:<input type=text name=d_sytppaddingh size=4 class=input title='居左时作用为左边距，居右时作用为右边距，数字型' value='" & sSYTPPaddingH & "'>px&nbsp; 上下:<input type=text name=d_sytppaddingv size=4 class=input title='居上时作用为上边距，居下时作用为下边柜，数字型' value='" & sSYTPPaddingV & "'>px</td></tr>" & _
			"<tr><td width='15%'>图片水印图片路径：</td><td width='35%'><input type=text name=d_sypicpath size=20 class=input title='当使用图片水印时图片的路径' value=""" & sSYPicPath & """></td><td width='15%'>图片水印透明度：</td><td width='35%'><input type=text name=d_sytpopacity size=20 class=input title='0至1间的数字，如0.5表示半透明' value=""" & sSYTPOpacity & """></td></tr>" & _
			"<tr><td width='15%'>图片水印图片占位：</td><td width='35%'>宽:<input type=text name=d_sytpimagewidth size=4 class=input title='水印图片的宽度，数字型' value='" & sSYTPImageWidth & "'>px&nbsp; 高:<input type=text name=d_sytpimageheight size=4 class=input title='水印图片的高度，数字型' value='" & sSYTPImageHeight & "'>px&nbsp; <input type=button value='检测宽高' onclick='doCheckWH(2)'></td><td width='15%'></td><td width='35%'></td></tr>" & _
			"<tr><td width='15%'>水印宽高检测区：</td><td width='85%' colspan=3><span id=tdPreview></span></td></tr>" & _
			"<tr><td align=center colspan=4><input type=submit value='  提交  ' align=absmiddle>&nbsp;<input type=reset name=btnReset value='  重填  '></td></tr>" & _
			"</form>" & _
			"</table><br>"


	Dim sMsg
	sMsg = "<a name=baseurl></a><p><span class=blue><b>路径模式设置说明：</b></span><br>" & _
		"<b>相对路径：</b>指所有的相关上传或自动插入文件路径，编辑后都以""UploadFile/...""或""../UploadFile/...""形式呈现，当使用此模式时，显示路径和内容路径必填，显示路径必须以""/""开头和结尾，内容路径设置中不能以""/""开头。<br>" & _
		"<b>绝对根路径：</b>指所有的相关上传或自动插入文件路径，编辑后都以""/UploadFile/...""这种形式呈现，当使用此模式时，显示路径和内容路径不必填。<br>" & _
		"<b>绝对全路径：</b>指所有的相关上传或自动插入文件路径，编辑后都以""http://127.0.0.1/UploadFile/...""这种形式呈现，当使用此模式时，显示路径和内容路径不必填。</p>"

	Call ShowMessage(sMsg)

End Sub

Sub InitStyle()
	Dim b, aCurrStyle
	b = False
	sStyleID = Trim(Request("id"))
	If IsNumeric(sStyleID) = True Then
		nStyleID = Clng(sStyleID)
		If nStyleID <= Ubound(aStyle) Then
			aCurrStyle = Split(aStyle(nStyleID), "|||")
			sStyleName = aCurrStyle(0)
			sStyleDir = aCurrStyle(1)
			sStyleCSS = aCurrStyle(2)
			sStyleUploadDir = aCurrStyle(3)
			sStyleBaseHref = aCurrStyle(22)
			sStyleContentPath = aCurrStyle(23)
			sStyleWidth = aCurrStyle(4)
			sStyleHeight = aCurrStyle(5)
			sStyleMemo = aCurrStyle(26)
			sStyleFileExt = aCurrStyle(6)
			sStyleFlashExt = aCurrStyle(7)
			sStyleImageExt = aCurrStyle(8)
			sStyleMediaExt = aCurrStyle(9)
			sStyleRemoteExt = aCurrStyle(10)
			sStyleFileSize = aCurrStyle(11)
			sStyleFlashSize = aCurrStyle(12)
			sStyleImageSize = aCurrStyle(13)
			sStyleMediaSize = aCurrStyle(14)
			sStyleRemoteSize = aCurrStyle(15)
			sStyleStateFlag = aCurrStyle(16)
			sStyleAutoRemote = aCurrStyle(24)
			sStyleShowBorder = aCurrStyle(25)
			sAutoDetectLanguage = aCurrStyle(27)
			sDefaultLanguage = aCurrStyle(28)
			sStyleUploadObject = aCurrStyle(20)
			sStyleAutoDir = aCurrStyle(21)
			sStyleDetectFromWord = aCurrStyle(17)
			sStyleInitMode = aCurrStyle(18)
			sStyleBaseUrl = aCurrStyle(19)
			sSLTFlag = aCurrStyle(29)
			sSLTMinSize = aCurrStyle(30)
			sSLTOkSize = aCurrStyle(31)
			sSYWZFlag = aCurrStyle(32)
			sSYText = aCurrStyle(33)
			sSYFontColor = aCurrStyle(34)
			sSYFontSize = aCurrStyle(35)
			sSYFontName = aCurrStyle(36)
			sSYPicPath = aCurrStyle(37)
			sSLTSYObject = aCurrStyle(38)
			sSLTSYExt = aCurrStyle(39)
			sSYWZMinWidth = aCurrStyle(40)
			sSYShadowColor = aCurrStyle(41)
			sSYShadowOffset = aCurrStyle(42)
			sStyleAllowBrowse = aCurrStyle(43)
			sStyleLocalExt = aCurrStyle(44)
			sStyleLocalSize = aCurrStyle(45)
			sSYWZMinHeight = aCurrStyle(46)
			sSYWZPosition = aCurrStyle(47)
			sSYWZTextWidth = aCurrStyle(48)
			sSYWZTextHeight = aCurrStyle(49)
			sSYWZPaddingH = aCurrStyle(50)
			sSYWZPaddingV = aCurrStyle(51)
			sSYTPFlag = aCurrStyle(52)
			sSYTPMinWidth = aCurrStyle(53)
			sSYTPMinHeight = aCurrStyle(54)
			sSYTPPosition = aCurrStyle(55)
			sSYTPPaddingH = aCurrStyle(56)
			sSYTPPaddingV = aCurrStyle(57)
			sSYTPImageWidth = aCurrStyle(58)
			sSYTPImageHeight = aCurrStyle(59)
			sSYTPOpacity = aCurrStyle(60)
			sCusDirFlag = aCurrStyle(61)
			b = True
		End If
	End If
	If b = False Then
		GoError "无效的样式ID号，请通过页面上的链接进行操作！"
	End If
End Sub

Sub CheckStyleForm()
	sStyleName = Trim(Request("d_name"))
	sStyleDir = Trim(Request("d_dir"))
	sStyleCSS = Trim(Request("d_css"))
	sStyleUploadDir = Trim(Request("d_uploaddir"))
	sStyleBaseHref = Trim(Request("d_basehref"))
	sStyleContentPath = Trim(Request("d_contentpath"))
	sStyleWidth = Trim(Request("d_width"))
	sStyleHeight = Trim(Request("d_height"))
	sStyleMemo = Trim(Request("d_memo"))
	sStyleImageExt = Trim(Request("d_imageext"))
	sStyleFlashExt = Trim(Request("d_flashext"))
	sStyleMediaExt = Trim(Request("d_mediaext"))
	sStyleRemoteExt = Trim(Request("d_remoteext"))
	sStyleFileExt = Trim(Request("d_fileext"))
	sStyleImageSize = Trim(Request("d_imagesize"))
	sStyleFlashSize = Trim(Request("d_flashsize"))
	sStyleMediaSize = Trim(Request("d_mediasize"))
	sStyleRemoteSize = Trim(Request("d_remotesize"))
	sStyleFileSize = Trim(Request("d_filesize"))
	sStyleStateFlag = Trim(Request("d_stateflag"))
	sStyleAutoRemote = Trim(Request("d_autoremote"))
	sStyleShowBorder = Trim(Request("d_showborder"))
	sAutoDetectLanguage = Trim(Request("d_autodetectlanguage"))
	sDefaultLanguage = Trim(Request("d_defaultlanguage"))
	sStyleUploadObject = Trim(Request("d_uploadobject"))
	sStyleAutoDir = Trim(Request("d_autodir"))
	sStyleDetectFromWord = Trim(Request("d_detectfromword"))
	sStyleInitMode = Trim(Request("d_initmode"))
	sStyleBaseUrl = Trim(Request("d_baseurl"))
	sSLTFlag = Trim(Request("d_sltflag"))
	sSLTMinSize = Trim(Request("d_sltminsize"))
	sSLTOkSize = Trim(Request("d_sltoksize"))
	sSYWZFlag = Trim(Request("d_sywzflag"))
	sSYText = Trim(Request("d_sytext"))
	sSYFontColor = Trim(Request("d_syfontcolor"))
	sSYFontSize = Trim(Request("d_syfontsize"))
	sSYFontName = Trim(Request("d_syfontname"))
	sSYPicPath = Trim(Request("d_sypicpath"))
	sSLTSYObject = Trim(Request("d_sltsyobject"))
	sSLTSYExt = Trim(Request("d_sltsyext"))
	sSYWZMinWidth = Trim(Request("d_sywzminwidth"))
	sSYShadowColor = Trim(Request("d_syshadowcolor"))
	sSYShadowOffset = Trim(Request("d_syshadowoffset"))
	sStyleAllowBrowse = Trim(Request("d_allowbrowse"))
	sStyleLocalExt = Trim(Request("d_localext"))
	sStyleLocalSize = Trim(Request("d_localsize"))
	sSYWZMinHeight = Trim(Request("d_sywzminheight"))
	sSYWZPosition = Trim(Request("d_sywzposition"))
	sSYWZTextWidth = Trim(Request("d_sywztextwidth"))
	sSYWZTextHeight = Trim(Request("d_sywztextheight"))
	sSYWZPaddingH = Trim(Request("d_sywzpaddingh"))
	sSYWZPaddingV = Trim(Request("d_sywzpaddingv"))
	sSYTPFlag = Trim(Request("d_sytpflag"))
	sSYTPMinWidth = Trim(Request("d_sytpminwidth"))
	sSYTPMinHeight = Trim(Request("d_sytpminheight"))
	sSYTPPosition = Trim(Request("d_sytpposition"))
	sSYTPPaddingH = Trim(Request("d_sytppaddingh"))
	sSYTPPaddingV = Trim(Request("d_sytppaddingv"))
	sSYTPImageWidth = Trim(Request("d_sytpimagewidth"))
	sSYTPImageHeight = Trim(Request("d_sytpimageheight"))
	sSYTPOpacity = Trim(Request("d_sytpopacity"))
	sCusDirFlag = Trim(Request("d_cusdirflag"))

	sStyleUploadDir = Replace(sStyleUploadDir, "\", "/")
	sStyleBaseHref = Replace(sStyleBaseHref, "\", "/")
	sStyleContentPath = Replace(sStyleContentPath, "\", "/")
	If Right(sStyleUploadDir, 1) <> "/" Then sStyleUploadDir = sStyleUploadDir & "/"
	If Right(sStyleBaseHref, 1) <> "/" Then sStyleBaseHref = sStyleBaseHref & "/"
	If Right(sStyleContentPath, 1) <> "/" Then sStyleContentPath = sStyleContentPath & "/"

	If sStyleName = "" Then
		GoError "样式名不能为空！"
	End If
	If IsSafeStr(sStyleName) = False Then
		GoError "样式名请勿包含特殊字符！"
	End If
	If sStyleDir = "" Then
		GoError "按钮图片目录名不能为空！"
	End If
	If IsSafeStr(sStyleDir) = False Then
		GoError "按钮图片目录名请勿包含特殊字符！"
	End If
	If sStyleCSS = "" Then
		GoError "样式CSS目录名不能为空！"
	End If
	If IsSafeStr(sStyleCSS) = False Then
		GoError "样式CSS目录名请勿包含特殊字符！"
	End If

	If sStyleUploadDir = "" Then
		GoError "上传路径不能为空！"
	End If
	If IsSafeStr(sStyleUploadDir) = False Then
		GoError "上传路径请勿包含特殊字符！"
	End If
	Select Case sStyleBaseUrl
	Case "0"
		If sStyleBaseHref = "" Then
			GoError "当使用相对路径模式时，显示路径不能为空！"
		End If
		If IsSafeStr(sStyleBaseHref) = False Then
			GoError "当使用相对路径模式时，显示路径请勿包含特殊字符！"
		End If
		If Left(sStyleBaseHref, 1) <> "/" Then
			GoError "当使用相对路径模式时，显示路径必须以&quot;/&quot;开头！"
		End If

		If sStyleContentPath = "" Then
			GoError "当使用相对路径模式时，内容路径不能为空！"
		End If
		If IsSafeStr(sStyleContentPath) = False Then
			GoError "当使用相对路径模式时，内容路径请勿包含特殊字符！"
		End If
		If Left(sStyleContentPath, 1) = "/" Then
			GoError "当使用相对路径模式时，内容路径不能以&quot;/&quot;开头！"
		End If
	Case "1", "2"
		sStyleBaseHref = ""
		sStyleContentPath = ""
	End Select
	
	If IsNumeric(sStyleWidth) = False Then
		GoError "请填写有效的最佳引用宽度！"
	End If
	If IsNumeric(sStyleHeight) = False Then
		GoError "请填写有效的最佳引用高度！"
	End If

	If IsNumeric(sStyleImageSize) = False Then
		GoError "请填写有效的图片限制大小！"
	End If
	If IsNumeric(sStyleFlashSize) = False Then
		GoError "请填写有效的Flash限制大小！"
	End If
	If IsNumeric(sStyleMediaSize) = False Then
		GoError "请填写有效的媒体文件限制大小！"
	End If
	If IsNumeric(sStyleFileSize) = False Then
		GoError "请填写有效的其它文件限制大小！"
	End If
	If IsNumeric(sStyleRemoteSize) = False Then
		GoError "请填写有效的远程文件限制大小！"
	End If
	If IsNumeric(sStyleLocalSize) = False Then
		GoError "请填写有效的本地文件限制大小！"
	End If

	If IsNumeric(sSLTMinSize) = False Then
		GoError "请填写有效的缩略图使用最小长度条件，不能为空，且为数字型！"
	End If
	If IsNumeric(sSLTOkSize) = False Then
		GoError "请填写有效的缩略图生成长度，不能为空，且为数字型！"
	End If

	If IsNumeric(sSYWZMinWidth) = False Then
		GoError "请填写有效的文字水印启用的最小宽度条件，不能为空，且为数字型！"
	End If
	If IsNumeric(sSYWZMinHeight) = False Then
		GoError "请填写有效的文字水印启用的最小高度条件，不能为空，且为数字型！"
	End If
	If sSYText = "" Then
		GoError "请填写有效水印文字内容，不能为空！"
	End If
	If isValidColor(sSYFontColor) = False Then
		GoError "请填写有效的水印文字颜色，6位长度，如黑色：000000！"
	End If
	If isValidColor(sSYShadowColor) = False Then
		GoError "请填写有效的水印文字阴影颜色，6位长度，如白色：FFFFFF！"
	End If
	If IsNumeric(sSYShadowOffset) = False Then
		GoError "请填写有效的水印文字阴影大小，不能为空，且为数字型！"
	End If
	If IsNumeric(sSYFontSize) = False Then
		GoError "请填写有效的水印文字大小，不能为空，且为数字型！"
	End If
	If sSYFontName = "" Then
		GoError "请填写水印文字字体名称，不能为空！"
	End If

	If IsNumeric(sSYWZPaddingH) = False Then
		GoError "请填写有效的文字水印左右边距，不能为空，且为数字型！"
	End If
	If IsNumeric(sSYWZPaddingV) = False Then
		GoError "请填写有效的文字水印上下边距，不能为空，且为数字型！"
	End If
	If IsNumeric(sSYWZTextWidth) = False Then
		GoError "请填写有效的文字水印文字宽占位，不能为空，且为数字型！"
	End If
	If IsNumeric(sSYWZTextHeight) = False Then
		GoError "请填写有效的文字水印文字高占位，不能为空，且为数字型！"
	End If
	If IsNumeric(sSYTPMinWidth) = False Then
		GoError "请填写有效的图片水印启用的最小宽度条件，不能为空，且为数字型！"
	End If
	If IsNumeric(sSYTPMinHeight) = False Then
		GoError "请填写有效的图片水印启用的最小高度条件，不能为空，且为数字型！"
	End If
	If IsNumeric(sSYTPPaddingH) = False Then
		GoError "请填写有效的图片水印左右边距，不能为空，且为数字型！"
	End If
	If IsNumeric(sSYTPPaddingV) = False Then
		GoError "请填写有效的图片水印上下边距，不能为空，且为数字型！"
	End If
	If IsNumeric(sSYTPOpacity) = False Then
		GoError "请填写有效的图片水印透明度，不能为空，且为0至1的数字！"
	End If
	If IsNumeric(sSYTPImageWidth) = False Then
		GoError "请填写有效的图片水印文字宽占位，不能为空，且为数字型！"
	End If
	If IsNumeric(sSYTPImageHeight) = False Then
		GoError "请填写有效的图片水印文字高占位，不能为空，且为数字型！"
	End If
End Sub

Sub DoStyleAddSave()

	If StyleName2ID(sStyleName) <> -1 Then
		GoError "此样式名已经存在，请用另一个样式名！"
	End If

	Dim nNewStyleID
	nNewStyleID = Ubound(aStyle) + 1
	Redim Preserve aStyle(nNewStyleID)

	aStyle(nNewStyleID) = sStyleName & "|||" & sStyleDir & "|||" & sStyleCSS & "|||" & sStyleUploadDir & "|||" & sStyleWidth & "|||" & sStyleHeight & "|||" & sStyleFileExt & "|||" & sStyleFlashExt & "|||" & sStyleImageExt & "|||" & sStyleMediaExt & "|||" & sStyleRemoteExt & "|||" & sStyleFileSize & "|||" & sStyleFlashSize & "|||" & sStyleImageSize & "|||" & sStyleMediaSize & "|||" & sStyleRemoteSize & "|||" & sStyleStateFlag & "|||" & sStyleDetectFromWord & "|||" & sStyleInitMode & "|||" & sStyleBaseUrl & "|||" & sStyleUploadObject & "|||" & sStyleAutoDir & "|||" & sStyleBaseHref & "|||" & sStyleContentPath & "|||" & sStyleAutoRemote & "|||" & sStyleShowBorder & "|||" & sStyleMemo & "|||" & sAutoDetectLanguage & "|||" & sDefaultLanguage & "|||" & sSLTFlag & "|||" & sSLTMinSize & "|||" & sSLTOkSize & "|||" & sSYWZFlag & "|||" & sSYText & "|||" & sSYFontColor & "|||" & sSYFontSize & "|||" & sSYFontName & "|||" & sSYPicPath & "|||" & sSLTSYObject & "|||" & sSLTSYExt & "|||" & sSYWZMinWidth & "|||" & sSYShadowColor & "|||" & sSYShadowOffset & "|||" & sStyleAllowBrowse & "|||" & sStyleLocalExt & "|||" & sStyleLocalSize & "|||" & sSYWZMinHeight & "|||" & sSYWZPosition & "|||" & sSYWZTextWidth & "|||" & sSYWZTextHeight & "|||" & sSYWZPaddingH & "|||" & sSYWZPaddingV & "|||" & sSYTPFlag & "|||" & sSYTPMinWidth & "|||" & sSYTPMinHeight & "|||" & sSYTPPosition & "|||" & sSYTPPaddingH & "|||" & sSYTPPaddingV & "|||" & sSYTPImageWidth & "|||" & sSYTPImageHeight & "|||" & sSYTPOpacity & "|||" & sCusDirFlag

	Call WriteConfig()
	Call WriteStyle(nNewStyleID)

	Call ShowMessage("<b><span class=red>样式增加成功！</span></b><li><a href='?action=toolbar&id=" & nNewStyleID & "'>设置此样式下的工具栏</a>")

End Sub

Sub DoUpdateConfig()
	Dim i
	Call WriteConfig()
	For i = 1 To UBound(aStyle)
		Call WriteStyle(i)
	Next
	Call ShowMessage("<b><span class=red>所有样式的前台配置文件更新操作成功！</span></b><li><a href='?'>返回所有样式列表</a>")
End Sub

Sub DoStyleSetSave()
	Dim n, s_OldStyleName
	sStyleID = Trim(Request("id"))
	If IsNumeric(sStyleID) = True Then
		n = StyleName2ID(sStyleName)
		If CStr(n) <> sStyleID And n <> -1 Then
			GoError "此样式名已经存在，请用另一个样式名！"
		End If
		
		If Clng(sStyleID) < 1 And Clng(sStyleID)>UBound(aStyle) Then
			GoError "无效的样式ID号，请通过页面上的链接进行操作！"
		End If

		s_OldStyleName = Split(aStyle(Clng(sStyleID)), "|||")(0)

		aStyle(Clng(sStyleID)) = sStyleName & "|||" & sStyleDir & "|||" & sStyleCSS & "|||" & sStyleUploadDir & "|||" & sStyleWidth & "|||" & sStyleHeight & "|||" & sStyleFileExt & "|||" & sStyleFlashExt & "|||" & sStyleImageExt & "|||" & sStyleMediaExt & "|||" & sStyleRemoteExt & "|||" & sStyleFileSize & "|||" & sStyleFlashSize & "|||" & sStyleImageSize & "|||" & sStyleMediaSize & "|||" & sStyleRemoteSize & "|||" & sStyleStateFlag & "|||" & sStyleDetectFromWord & "|||" & sStyleInitMode & "|||" & sStyleBaseUrl & "|||" & sStyleUploadObject & "|||" & sStyleAutoDir & "|||" & sStyleBaseHref & "|||" & sStyleContentPath & "|||" & sStyleAutoRemote & "|||" & sStyleShowBorder & "|||" & sStyleMemo & "|||" & sAutoDetectLanguage & "|||" & sDefaultLanguage & "|||" & sSLTFlag & "|||" & sSLTMinSize & "|||" & sSLTOkSize & "|||" & sSYWZFlag & "|||" & sSYText & "|||" & sSYFontColor & "|||" & sSYFontSize & "|||" & sSYFontName & "|||" & sSYPicPath & "|||" & sSLTSYObject & "|||" & sSLTSYExt & "|||" & sSYWZMinWidth & "|||" & sSYShadowColor & "|||" & sSYShadowOffset & "|||" & sStyleAllowBrowse & "|||" & sStyleLocalExt & "|||" & sStyleLocalSize & "|||" & sSYWZMinHeight & "|||" & sSYWZPosition & "|||" & sSYWZTextWidth & "|||" & sSYWZTextHeight & "|||" & sSYWZPaddingH & "|||" & sSYWZPaddingV & "|||" & sSYTPFlag & "|||" & sSYTPMinWidth & "|||" & sSYTPMinHeight & "|||" & sSYTPPosition & "|||" & sSYTPPaddingH & "|||" & sSYTPPaddingV & "|||" & sSYTPImageWidth & "|||" & sSYTPImageHeight & "|||" & sSYTPOpacity & "|||" & sCusDirFlag

	Else
		GoError "无效的样式ID号，请通过页面上的链接进行操作！"
	End If

	Call WriteConfig()
	If LCase(s_OldStyleName) <> LCase(sStyleName) Then
		Call DeleteFile(s_OldStyleName)
	End If
	Call WriteStyle(Clng(sStyleID))

	Call ShowMessage("<b><span class=red>样式修改成功！</span></b><li><a href='?action=stylepreview&id=" & sStyleID & "' target='_blank'>预览此样式</a><li><a href='?action=toolbar&id=" & sStyleID & "'>设置此样式下的工具栏</a>")

End Sub

Sub DoStyleDel()
	aStyle(Clng(sStyleID)) = ""
	Call WriteConfig()
	Call DeleteFile(sStyleName)
	Call GoUrl("?")
End Sub

Sub ShowStylePreview()
	Response.Write "<html><head>" & _
		"<title>样式预览</title>" & _
		"<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & _
		"</head><body>" & _
		"<input type=hidden name=content1  value=''>" & _
		"<iframe ID='eWebEditor1' src='../ewebeditor.htm?id=content1&style=" & sStyleName & "' frameborder=0 scrolling=no width='" & sStyleWidth & "' HEIGHT='" & sStyleHeight & "'></iframe>" & _
		"</body></html>"
End Sub

Sub ShowStyleCode()
	Response.Write "<table border=0 cellspacing=1 align=center class=list>" & _
		"<tr><th>样式（" & outHTML(sStyleName) & "）的最佳调用代码如下（其中XXX按实际关联的表单项进行修改）：</th></tr>" & _
		"<tr><td><textarea rows=5 cols=65 style='width:100%'><iframe ID=""eWebEditor1"" src=""ewebeditor.htm?id=XXX&style=" & sStyleName & """ frameborder=""0"" scrolling=""no"" width=""" & sStyleWidth & """ height=""" & sStyleHeight & """></iframe></textarea></td></tr>" & _
		"</table>"
End Sub

Sub ShowToolBarList()

	Call ShowMessage("<b class=blue>样式（" & outHTML(sStyleName) & "）下的工具栏管理：</b>")

	Dim s_AddForm, s_ModiForm, i, aCurrToolbar

	If nStyleIsSys = 1 Then
		s_AddForm = ""
	Else
		Dim nMaxOrder
		nMaxOrder = 0
		For i = 1 To UBound(aToolbar)
			aCurrToolbar = Split(aToolbar(i), "|||")
			If aCurrToolbar(0) = sStyleID Then
				If Clng(aCurrToolbar(3)) > nMaxOrder Then
					nMaxOrder = Clng(aCurrToolbar(3))
				End If
			End If
		Next
		nMaxOrder = nMaxOrder + 1

		s_AddForm = "<hr width='80%' align=center size=1><table border=0 cellpadding=4 cellspacing=0 align=center>" & _
		"<form action='?id=" & sStyleID & "&action=toolbaradd' name='addform' method=post>" & _
		"<tr><td>工具栏名：<input type=text name=d_name size=20 class=input value='工具栏" & nMaxOrder & "'> 排序号：<input type=text name=d_order size=5 value='" & nMaxOrder & "' class=input> <input type=submit name=b1 value='新增工具栏'></td></tr>" & _
		"</form></table><hr width='80%' align=center size=1>"
	End If

	Dim s_Manage, s_SubmitButton
	s_ModiForm = "<form action='?id=" & sStyleID & "&action=toolbarmodi' name=modiform method=post>" & _
		"<table border=0 cellpadding=0 cellspacing=1 align=center class=form>" & _
		"<tr align=center><th>ID</th><th>工具栏名</th><th>排序号</th><th>操作</th></tr>"

	For i = 1 To UBound(aToolbar)
		aCurrToolbar = Split(aToolbar(i), "|||")
		If aCurrToolbar(0) = sStyleID Then
			s_Manage = "<a href='?id=" & sStyleID & "&action=buttonset&toolbarid=" & i & "'>按钮设置</a>"
			s_Manage = s_Manage & "|<a href='?id=" & sStyleID & "&action=toolbardel&delid=" & i & "'>删除</a>"
			s_ModiForm = s_ModiForm & "<tr align=center>" & _
				"<td>" & i & "</td>" & _
				"<td><input type=text name='d_name" & i & "' value=""" & inHTML(aCurrToolbar(2)) & """ size=30 class=input></td>" & _
				"<td><input type=text name='d_order" & i & "' value='" & aCurrToolbar(3) & "' size=5 class=input></td>" & _
				"<td>" & s_Manage & "</td>" & _
				"</tr>"
		End If
	Next

	s_SubmitButton = "<tr><td colspan=4 align=center><input type=submit name=b1 value='  修改  '></td></tr>"
	s_ModiForm = s_ModiForm & s_SubmitButton & "</table></form>"

	Response.Write s_AddForm & s_ModiForm

End Sub

Sub DoToolBarAdd()
	Dim s_Name, s_Order
	s_Name = Trim(Request("d_name"))
	s_Order = Trim(Request("d_order"))
	If s_Name = "" Then
		GoError "工具栏名不能为空！"
	End If
	If IsNumeric(s_Order) = False Then
		GoError "无效的工具栏排序号，排序号必须为数字！"
	End If

	Dim nToolbarNum
	nToolbarNum = Ubound(aToolbar) + 1
	Redim Preserve aToolbar(nToolbarNum)
	aToolbar(nToolbarNum) = sStyleID & "||||||" & s_Name & "|||" & s_Order

	Call WriteConfig()
	Call WriteStyle(Clng(sStyleID))

	Response.Write "<script language=javascript>alert(""工具栏（" & outHTML(s_Name) & "）增加操作成功！"");</script>"
	Call GoUrl("?action=toolbar&id=" & sStyleID)
End Sub

Sub DoToolBarModi()
	Dim s_Name, s_Order, i, aCurrToolbar

	For i = 1 To UBound(aToolbar)
		aCurrToolbar = Split(aToolbar(i), "|||")
		If aCurrToolbar(0) = sStyleID Then
			s_Name = Trim(Request("d_name" & i))
			s_Order = Trim(Request("d_order" & i))
			If s_Name = "" Or IsNumeric(s_Order) = False Then 
				aCurrToolbar(0) = ""
				s_Name = ""
			End If
			aToolbar(i) = aCurrToolbar(0) & "|||" & aCurrToolbar(1) & "|||" & s_Name & "|||" & s_Order
		End If
	Next

	Call WriteConfig()
	Call WriteStyle(Clng(sStyleID))

	Response.Write "<script language=javascript>alert('工具栏修改操作成功！');</script>"
	Call GoUrl("?action=toolbar&id=" & sStyleID)

End Sub

Sub DoToolBarDel()
	Dim s_DelID
	s_DelID = Trim(Request("delid"))
	If IsNumeric(s_DelID) = True Then
		aToolbar(Clng(s_DelID)) = ""
		Call WriteConfig()
		Call WriteStyle(Clng(sStyleID))
		Response.Write "<script language=javascript>alert('工具栏（ID：" & s_DelID & "）删除操作成功！');</script>"
		Call GoUrl("?action=toolbar&id=" & sStyleID)
	End If
End Sub

Sub InitToolBar()
	Dim b, aCurrToolbar, nToolbarID
	b = False
	sToolBarID = Trim(Request("toolbarid"))
	If IsNumeric(sToolBarID) = True Then
		If Clng(sToolBarID) <= UBound(aToolbar) And Clng(sToolBarID) > 0 Then
			aCurrToolbar = Split(aToolbar(Clng(sToolbarID)), "|||")
			sToolBarName = aCurrToolbar(2)
			sToolBarOrder = aCurrToolbar(3)
			sToolBarButton = aCurrToolbar(1)
			b = True
		End If
	End If
	If b = False Then
		GoError "无效的工具栏ID号，请通过页面上的链接进行操作！"
	End If
End Sub

Sub ShowButtonList()

	Call ShowMessage("<b class=blue>当前样式：<span class=red>" & outHTML(sStyleName) & "</span>&nbsp;&nbsp;当前工具栏：<span class=red>" & outHTML(sToolBarName) & "</span></b>")
	
	Dim i, n

	Dim s_Option1
	s_Option1 = ""
	For i = 1 To UBound(aButton, 1)
		If aButton(i, 8) = 1 Then
			s_Option1 = s_Option1 & "<option value='" & aButton(i, 1) & "'>" & aButton(i, 2) & "</option>"
		End If
	Next

	Dim aSelButton, s_Option2, s_Temp
	aSelButton = Split(sToolBarButton, "|")
	s_Option2 = ""
	For i = 0 To UBound(aSelButton)
		s_Temp = Code2Title(aSelButton(i))
		If s_Temp <> "" Then
			s_Option2 = s_Option2 & "<option value='" & aSelButton(i) & "'>" & s_Temp & "</option>"
		End If
	Next


%>

<script language=javascript>
function Add() {
	var sel1=document.myform.d_b1;
	var sel2=document.myform.d_b2;
	if (sel1.selectedIndex<0) {
		alert("请选择一个待选按钮！");
		return;
	}
	sel2.options[sel2.length]=new Option(sel1.options[sel1.selectedIndex].innerHTML,sel1.options[sel1.selectedIndex].value);
}

function Del() {
	var sel=document.myform.d_b2;
	var nIndex = sel.selectedIndex;
	var nLen = sel.length;
	if (nLen<1) return;
	if (nIndex<0) {
		alert("请选择一个已选按钮！");
		return;
	}
	for (var i=nIndex;i<nLen-1;i++) {
		sel.options[i].value=sel.options[i+1].value;
		sel.options[i].innerHTML=sel.options[i+1].innerHTML;
	}
	sel.length=nLen-1;
}

function Up() {
	var sel=document.myform.d_b2;
	var nIndex = sel.selectedIndex;
	var nLen = sel.length;
	if ((nLen<1)||(nIndex==0)) return;
	if (nIndex<0) {
		alert("请选择一个要移动的已选按钮！");
		return;
	}
	var sValue=sel.options[nIndex].value;
	var sHTML=sel.options[nIndex].innerHTML;
	sel.options[nIndex].value=sel.options[nIndex-1].value;
	sel.options[nIndex].innerHTML=sel.options[nIndex-1].innerHTML;
	sel.options[nIndex-1].value=sValue;
	sel.options[nIndex-1].innerHTML=sHTML;
	sel.selectedIndex=nIndex-1;
}

function Down() {
	var sel=document.myform.d_b2;
	var nIndex = sel.selectedIndex;
	var nLen = sel.length;
	if ((nLen<1)||(nIndex==nLen-1)) return;
	if (nIndex<0) {
		alert("请选择一个要移动的已选按钮！");
		return;
	}
	var sValue=sel.options[nIndex].value;
	var sHTML=sel.options[nIndex].innerHTML;
	sel.options[nIndex].value=sel.options[nIndex+1].value;
	sel.options[nIndex].innerHTML=sel.options[nIndex+1].innerHTML;
	sel.options[nIndex+1].value=sValue;
	sel.options[nIndex+1].innerHTML=sHTML;
	sel.selectedIndex=nIndex+1;
}

function checkform() {
	var sel=document.myform.d_b2;
	var nLen = sel.length;
	var str="";
	for (var i=0;i<nLen;i++) {
		if (i>0) str+="|";
		str+=sel.options[i].value;
	}
	document.myform.d_button.value=str;
	return true;
}

</script>

<%


	Dim s_SubmitButton
	If nStyleIsSys = 1 Then
		s_SubmitButton = ""
	Else
		s_SubmitButton = "<input type=submit name=b value=' 保存设置 '>"
	End If
	Response.Write "<table border=0 cellpadding=5 cellspacing=0 align=center>" & _
		"<form action='?action=buttonsave&id=" & sStyleID & "&toolbarid=" & sToolBarID & "' method=post name=myform onsubmit='return checkform()'>" & _
		"<tr align=center><td>可选按钮</td><td></td><td>已选按钮</td><td></td></tr>" & _
		"<tr align=center>" & _
			"<td><select name='d_b1' size=20 style='width:250px' ondblclick='Add()'>" & s_Option1 & "</select></td>" & _
			"<td><input type=button name=b1 value=' → ' onclick='Add()'><br><br><input type=button name=b1 value=' ← ' onclick='Del()'></td>" & _
			"<td><select name='d_b2' size=20 style='width:250px' ondblclick='Del()'>" & s_Option2 & "</select></td>" & _
			"<td><input type=button name=b3 value='↑' onclick='Up()'><br><br><br><input type=button name=b4 value='↓' onclick='Down()'></td>" & _
		"</tr>" & _
		"<input type=hidden name='d_button' value=''>" & _
		"<tr><td colspan=4 align=right>" & s_SubmitButton & "</td></tr>" & _
		"</form></table>"


	Response.Write "<table border=0 cellspacing=1 align=center class=list>" & _
		"<tr><th colspan=4>以下是按钮图片对照表（部分下拉框或特殊按钮可能没图）：</th></tr>"
	n = 0
	Dim m
	m = 0
	For i = 1 To UBound(aButton)
		If aButton(i, 8) = 1 Then
			m = m + 1
			n = m Mod 4
			If n = 1 Then
				Response.Write "<tr>"
			End If
			Response.Write "<td>"
			If aButton(i, 3) <> "" Then
				Response.Write "<img border=0 align=absmiddle src='../buttonimage/" & sStyleDir & "/" & aButton(i, 3) & "'>"
			End If
			Response.Write aButton(i, 2)
			Response.Write "</td>"
			If n = 0 Then
				Response.Write "</tr>"
			End If
		End If
	Next
	If n > 0 Then
		For i = 1 To 4 - n
			Response.Write "<td>&nbsp;</td>"
		Next
		Response.Write "</tr>"
	End if
	Response.Write "</table>"
End Sub

Function Code2Title(s_Code)
	Dim i
	Code2Title = ""
	For i = 1 To UBound(aButton)
		If UCase(aButton(i, 1)) = UCase(s_Code) Then
			Code2Title = aButton(i, 2)
			Exit Function
		End If
	Next
End Function

Sub DoButtonSave()
	Dim s_Button, nToolBarID, aCurrToolbar
	s_Button = Trim(Request("d_button"))

	nToolBarID = Clng(sToolBarID)
	aCurrToolbar = Split(aToolbar(nToolBarID), "|||")
	aToolbar(nToolBarID) = aCurrToolbar(0) & "|||" & s_Button & "|||" & aCurrToolbar(2) & "|||" & aCurrToolbar(3)

	Call WriteConfig()
	Call WriteStyle(Clng(sStyleID))

	Call ShowMessage("<b><span class=red>工具栏按钮设置保存成功！</span></b><li><a href='?action=stylepreview&id=" & sStyleID & "' target='_blank'>预览此样式</a><li><a href='?action=toolbar&id=" & sStyleID & "'>返回工具栏管理</a><li><a href='?action=buttonset&id=" & sStyleID & "&toolbarid=" & sToolBarID & "'>重新设置此工具栏下的按钮</a>")

End Sub

Function InitSelect(s_FieldName, a_Name, a_Value, v_InitValue, s_Sql, s_AllName)
	Dim i
	InitSelect = "<select name='" & s_FieldName & "' size=1>"
	If s_AllName <> "" Then
		InitSelect = InitSelect & "<option value=''>" & s_AllName & "</option>"
	End If
	If s_Sql <> "" Then
		oRs.Open s_Sql, oConn, 0, 1
		Do While Not oRs.Eof
			InitSelect = InitSelect & "<option value=""" & inHTML(oRs(1)) & """"
			If oRs(1) = v_InitValue Then
				InitSelect = InitSelect & " selected"
			End If
			InitSelect = InitSelect & ">" & outHTML(oRs(0)) & "</option>"
			oRs.MoveNext
		Loop
		oRs.Close
	Else
		For i = 0 To UBound(a_Name)
			InitSelect = InitSelect & "<option value=""" & inHTML(a_Value(i)) & """"
			If a_Value(i) = v_InitValue Then
				InitSelect = InitSelect & " selected"
			End If
			InitSelect = InitSelect & ">" & outHTML(a_Name(i)) & "</option>"
		Next
	End If
	InitSelect = InitSelect & "</select>"
End Function



Sub WriteStyle(n_StyleID)
	Dim sConfig
	Dim aTmpStyle

	sConfig = ""
	aTmpStyle = Split(aStyle(n_StyleID), "|||")
	sConfig = sConfig & "config.ButtonDir = """ & aTmpStyle(1) & """;" & Vbcrlf
	sConfig = sConfig & "config.StyleUploadDir = """ & aTmpStyle(3) & """;" & Vbcrlf
	sConfig = sConfig & "config.InitMode = """ & aTmpStyle(18) & """;" & Vbcrlf
	sConfig = sConfig & "config.AutoDetectPasteFromWord = """ & aTmpStyle(17) & """;" & Vbcrlf
	sConfig = sConfig & "config.BaseUrl = """ & aTmpStyle(19) & """;" & Vbcrlf
	sConfig = sConfig & "config.BaseHref = """ & aTmpStyle(22) & """;" & Vbcrlf
	sConfig = sConfig & "config.AutoRemote = """ & aTmpStyle(24) & """;" & Vbcrlf
	sConfig = sConfig & "config.ShowBorder = """ & aTmpStyle(25) & """;" & Vbcrlf
	sConfig = sConfig & "config.StateFlag = """ & aTmpStyle(16) & """;" & Vbcrlf
	sConfig = sConfig & "config.CssDir = """ & aTmpStyle(2) & """;" & Vbcrlf
	sConfig = sConfig & "config.AutoDetectLanguage = """ & aTmpStyle(27) & """;" & Vbcrlf
	sConfig = sConfig & "config.DefaultLanguage = """ & aTmpStyle(28) & """;" & Vbcrlf
	sConfig = sConfig & "config.AllowBrowse = """ & aTmpStyle(43) & """;" & Vbcrlf
	sConfig = sConfig & "config.AllowImageSize = """ & aTmpStyle(13) & """;" & Vbcrlf
	sConfig = sConfig & "config.AllowFlashSize = """ & aTmpStyle(12) & """;" & Vbcrlf
	sConfig = sConfig & "config.AllowMediaSize = """ & aTmpStyle(14) & """;" & Vbcrlf
	sConfig = sConfig & "config.AllowFileSize = """ & aTmpStyle(11) & """;" & Vbcrlf
	sConfig = sConfig & "config.AllowRemoteSize = """ & aTmpStyle(15) & """;" & Vbcrlf
	sConfig = sConfig & "config.AllowLocalSize = """ & aTmpStyle(45) & """;" & Vbcrlf
	sConfig = sConfig & Vbcrlf
	sConfig = sConfig & "function showToolbar(){" & Vbcrlf
	sConfig = sConfig & Vbcrlf

	sConfig = sConfig & chr(9) & "document.write ("""
	sConfig = sConfig & "<table border=0 cellpadding=0 cellspacing=0 width='100%' class='Toolbar' id='eWebEditor_Toolbar'>"

	Dim s_Order, s_ID, n, aTmpToolbar
	s_Order = ""
	s_ID = ""
	For n = 1 To UBound(aToolbar)
		If aToolbar(n) <> "" Then
			aTmpToolbar = Split(aToolbar(n), "|||")
			If aTmpToolbar(0) = CStr(n_StyleID) Then
				If s_ID <> "" Then
					s_ID = s_ID & "|"
					s_Order = s_Order & "|"
				End If
				s_ID = s_ID & CStr(n)
				s_Order = s_Order & aTmpToolbar(3)
			End If
		End If
	Next

	Dim a_ID, a_Order, aTmpButton, i
	If s_ID <> "" Then
		a_ID = Split(s_ID, "|")
		a_Order = Split(s_Order, "|")
		For n = 0 To UBound(a_Order)
			a_Order(n) = Clng(a_Order(n))
			a_ID(n) = Clng(a_ID(n))
		Next
		a_ID = Sort(a_ID, a_Order)
		For n = 0 To UBound(a_ID)
			aTmpToolbar = Split(aToolbar(a_ID(n)), "|||")
			aTmpButton = Split(aTmpToolbar(1), "|")

			sConfig = sConfig & "<tr><td><div class=yToolbar>"
			For i = 0 To UBound(aTmpButton)
				If UCase(aTmpButton(i)) = "MAXIMIZE" Then
					sConfig = sConfig & """);" & Vbcrlf
					sConfig = sConfig & Vbcrlf

					sConfig = sConfig & chr(9) & "if (sFullScreen==""1""){" & Vbcrlf
					sConfig = sConfig & chr(9) & chr(9) & "document.write (""" & Code2HTML("Minimize", aTmpStyle(1)) & """);" & Vbcrlf
					sConfig = sConfig & chr(9) & "}else{" & Vbcrlf
					sConfig = sConfig & chr(9) & chr(9) & "document.write (""" & Code2HTML(aTmpButton(i), aTmpStyle(1)) & """);" & Vbcrlf
					sConfig = sConfig & chr(9) & "}" & Vbcrlf
					sConfig = sConfig & Vbcrlf

					sConfig = sConfig & chr(9) & "document.write ("""
				Else
					sConfig = sConfig & Code2HTML(aTmpButton(i), aTmpStyle(1))
				End If
			Next
			sConfig = sConfig & "</div></td></tr>"
		Next
	Else
		sConfig = sConfig & "<tr><td></td></tr>"
	End If

	sConfig = sConfig & "</table>"");" & Vbcrlf
	sConfig = sConfig & Vbcrlf
	sConfig = sConfig & "}" & Vbcrlf	

	Call WriteFile("../style/" & LCase(aTmpStyle(0)) & ".js", sConfig)

End Sub

Function Code2HTML(s_Code, s_ButtonDir)
	Dim i, s_FixedWidth
	Code2HTML = ""
	For i = 1 To UBound(aButton, 1)
		If UCase(aButton(i, 1)) = UCase(s_Code) Then
			Select Case aButton(i, 5)
			Case 0
				Code2HTML = "<DIV CLASS=" & aButton(i, 7) & " TITLE='""+lang[""" & aButton(i, 1) & """]+""' onclick=\""" & aButton(i, 6) & "\""><IMG CLASS=Ico SRC='buttonimage/" & s_ButtonDir & "/" & aButton(i, 3) & "'></DIV>"
			Case 1
				Select Case aButton(i, 1)
				Case "FontName"
					s_FixedWidth = " style='width:115px'"
				Case "FontSize"
					s_FixedWidth = " style='width:55px'"
				Case "FormatBlock"
					s_FixedWidth = " style='width:90px'"
				Case "ZoomSelect"
					s_FixedWidth = " style='width:55px'"
				Case Else
					s_FixedWidth = ""
				End Select

				If aButton(i, 4) <> "" Then
					Code2HTML = "<SELECT" & s_FixedWidth & " CLASS=" & aButton(i, 7) & " onchange=\""" & aButton(i, 6) & "\"">" & aButton(i, 4) & "</SELECT>"
				Else
					Code2HTML = "<SELECT" & s_FixedWidth & " CLASS=" & aButton(i, 7) & " onchange=\""" & aButton(i, 6) & "\"">""+lang[""" & aButton(i, 1) & """]+""</SELECT>"
				End If
			Case 2
				Code2HTML = "<DIV CLASS=" & aButton(i, 7) & ">" & aButton(i, 4) & "</DIV>"
			End Select
			Exit Function
		End If
	Next
End Function

Sub DeleteFile(s_StyleName)
	On Error Resume Next
	Dim oFSO, sMapFileName
	Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
	sMapFileName = Server.MapPath("../style/" & LCase(s_StyleName) & ".js")
	If oFSO.FileExists(sMapFileName) Then
		oFSO.DeleteFile(sMapFileName)
	End If
	Set oFSO = Nothing
End Sub

Sub GoUrl(url)
	Response.Write "<script language=javascript>location.href=""" & url & """;</script>"
	Response.End
End Sub

Function isValidColor(str)
	Dim re
	Set re = new RegExp
	re.Pattern = "[A-Fa-f0-9]{6}"
	isValidColor = re.Test(str)
	Set re = Nothing
End Function
%>