<%
Response.Buffer = EW_RESPONSE_BUFFER
%>
<!--#include file="ewcfg11.asp"-->
<!--#include file="websetinfo.asp"-->
<!--#include file="zlogininfo.asp"-->
<!--#include file="aspfn11.asp"-->
<!--#include file="md5.asp"-->
<!--#include file="userfn11.asp"-->
<% Session.Timeout = 900 %>
<% Call ew_Header(False, EW_CHARSET) %>
<%

' Define page object
Dim webset_edit
Set webset_edit = New cwebset_edit
Set Page = webset_edit

' Page init processing
webset_edit.Page_Init()

' Page main processing
webset_edit.Page_Main()

' Global Page Rendering event (in userfn*.asp)
Page_Rendering()

' Page Rendering event
webset_edit.Page_Render()
%>
<!--#include file="header.asp"-->
<script type="text/javascript">
// Page object
var webset_edit = new ew_Page("webset_edit");
webset_edit.PageID = "edit"; // Page ID
var EW_PAGE_ID = webset_edit.PageID; // For backward compatibility
// Form object
var fwebsetedit = new ew_Form("fwebsetedit");
// Validate form
fwebsetedit.Validate = function() {
	if (!this.ValidateRequired)
		return true; // Ignore validation
	var $ = jQuery, fobj = this.GetForm(), $fobj = $(fobj);
	this.PostAutoSuggest();
	if ($fobj.find("#a_confirm").val() == "F")
		return true;
	var elm, felm, uelm, addcnt = 0;
	var $k = $fobj.find("#" + this.FormKeyCountName); // Get key_count
	var rowcnt = ($k[0]) ? parseInt($k.val(), 10) : 1;
	var startcnt = (rowcnt == 0) ? 0 : 1; // Check rowcnt == 0 => Inline-Add
	var gridinsert = $fobj.find("#a_list").val() == "gridinsert";
	for (var i = startcnt; i <= rowcnt; i++) {
		var infix = ($k[0]) ? String(i) : "";
		$fobj.data("rowindex", infix);
			// Set up row object
			ew_ElementsToRow(fobj);
			// Fire Form_CustomValidate event
			if (!this.Form_CustomValidate(fobj))
				return false;
	}
	// Process detail forms
	var dfs = $fobj.find("input[name='detailpage']").get();
	for (var i = 0; i < dfs.length; i++) {
		var df = dfs[i], val = df.value;
		if (val && ewForms[val])
			if (!ewForms[val].Validate())
				return false;
	}
	return true;
}
// Form_CustomValidate event
fwebsetedit.Form_CustomValidate = 
 function(fobj) { // DO NOT CHANGE THIS LINE!
 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
// Use JavaScript validation or not
<% If EW_CLIENT_VALIDATE Then %>
fwebsetedit.ValidateRequired = true; // Use JavaScript validation
<% Else %>
fwebsetedit.ValidateRequired = false; // No JavaScript validation
<% End If %>
// Dynamic selection lists
// Form object for search
</script>
<link rel="stylesheet" href="../editor/themes/default/default.css" />
<link rel="stylesheet" href="../editor/plugins/code/prettify.css" />
<script charset="utf-8" src="../editor/kindeditor.js"></script>
<script charset="utf-8" src="../editor/lang/zh_CN.js"></script>
<script charset="utf-8" src="../editor/plugins/code/prettify.js"></script>
<script>
		KindEditor.ready(function(K) {
			var editor1 = K.editor({
				cssPath : '../editor/plugins/code/prettify.css',
				uploadJson : '../editor/asp/upload_json.asp',
				fileManagerJson : '../editor/asp/file_manager_json.asp',
				allowFileManager : true,
				afterBlur : function() { this.sync(); K.ctrl(document, 13, function() {  K('form[name=fwebsetadd]')[0].submit(); }); K.ctrl(this.edit.doc, 13, function() {  K('form[name=fwebsetadd]')[0].submit(); });}
			});
			K('#image1').click(function() {
					editor1.loadPlugin('image', function() {
						editor1.plugin.imageDialog({
							showRemote : false,
							imageUrl : K('#x_logo').val(),
							clickFn : function(url, title, width, height, border, align) {
								K('#x_logo').val(url);
								editor1.hideDialog();
							}
						});
					});
				});
				K('#image2').click(function() {
					editor1.loadPlugin('image', function() {
						editor1.plugin.imageDialog({
							showRemote : false,
							imageUrl : K('#x_wxtp').val(),
							clickFn : function(url, title, width, height, border, align) {
								K('#x_wxtp').val(url);
								editor1.hideDialog();
							}
						});
					});
				});
		});
		
</script>
<script type="text/javascript">
// Write your client script here, no need to add script tags.
</script>
<% If webset.Export = "" Then %>
<% Breadcrumb.Render() %>
<% End If %>
<% webset_edit.ShowPageHeader() %>
<% webset_edit.ShowMessage %>
<form name="fwebsetedit" id="fwebsetedit" class="ewForm form-inline" action="<%= ew_CurrentPage %>" method="post">
<input type="hidden" name="a_table" id="a_table" value="webset">
<input type="hidden" name="a_edit" id="a_edit" value="U">
<table class="ewGrid"><tr><td>
<table id="tbl_websetedit" class="table table-bordered table-striped">
<% If webset.id.Visible Then ' id %>
	<tr id="r_id">
		<td><span id="elh_webset_id"><%= webset.id.FldCaption %></span></td>
		<td<%= webset.id.CellAttributes %>>
<span id="el_webset_id" class="control-group">
<span<%= webset.id.ViewAttributes %>>
<%= webset.id.EditValue %>
</span>
</span>
<input type="hidden" data-field="x_id" name="x_id" id="x_id" value="<%= Server.HTMLEncode(webset.id.CurrentValue&"") %>">
<%= webset.id.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.webname.Visible Then ' webname %>
	<tr id="r_webname">
		<td><span id="elh_webset_webname"><%= webset.webname.FldCaption %></span></td>
		<td<%= webset.webname.CellAttributes %>>
<span id="el_webset_webname" class="control-group">
<input type="text" data-field="x_webname" name="x_webname" id="x_webname" size="30" maxlength="200" placeholder="<%= webset.webname.PlaceHolder %>" value="<%= webset.webname.EditValue %>"<%= webset.webname.EditAttributes %>>
</span>
<%= webset.webname.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.ym.Visible Then ' ym %>
	<tr id="r_ym">
		<td><span id="elh_webset_ym"><%= webset.ym.FldCaption %></span></td>
		<td<%= webset.ym.CellAttributes %>>
<span id="el_webset_ym" class="control-group">
<input type="text" data-field="x_ym" name="x_ym" id="x_ym" size="30" maxlength="255" placeholder="<%= webset.ym.PlaceHolder %>" value="<%= webset.ym.EditValue %>"<%= webset.ym.EditAttributes %>>
</span>
<%= webset.ym.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.icp.Visible Then ' icp %>
	<tr id="r_icp">
		<td><span id="elh_webset_icp"><%= webset.icp.FldCaption %></span></td>
		<td<%= webset.icp.CellAttributes %>>
<span id="el_webset_icp" class="control-group">
<input type="text" data-field="x_icp" name="x_icp" id="x_icp" size="30" maxlength="50" placeholder="<%= webset.icp.PlaceHolder %>" value="<%= webset.icp.EditValue %>"<%= webset.icp.EditAttributes %>>
</span>
<%= webset.icp.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.lxr.Visible Then ' lxr %>
	<tr id="r_lxr">
		<td><span id="elh_webset_lxr"><%= webset.lxr.FldCaption %></span></td>
		<td<%= webset.lxr.CellAttributes %>>
<span id="el_webset_lxr" class="control-group">
<input type="text" data-field="x_lxr" name="x_lxr" id="x_lxr" size="30" maxlength="50" placeholder="<%= webset.lxr.PlaceHolder %>" value="<%= webset.lxr.EditValue %>"<%= webset.lxr.EditAttributes %>>
</span>
<%= webset.lxr.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.sj.Visible Then ' sj %>
	<tr id="r_sj">
		<td><span id="elh_webset_sj"><%= webset.sj.FldCaption %></span></td>
		<td<%= webset.sj.CellAttributes %>>
<span id="el_webset_sj" class="control-group">
<input type="text" data-field="x_sj" name="x_sj" id="x_sj" size="30" maxlength="50" placeholder="<%= webset.sj.PlaceHolder %>" value="<%= webset.sj.EditValue %>"<%= webset.sj.EditAttributes %>>
</span>
<%= webset.sj.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.zj.Visible Then ' zj %>
	<tr id="r_zj">
		<td><span id="elh_webset_zj"><%= webset.zj.FldCaption %></span></td>
		<td<%= webset.zj.CellAttributes %>>
<span id="el_webset_zj" class="control-group">
<input type="text" data-field="x_zj" name="x_zj" id="x_zj" size="30" maxlength="50" placeholder="<%= webset.zj.PlaceHolder %>" value="<%= webset.zj.EditValue %>"<%= webset.zj.EditAttributes %>>
</span>
<%= webset.zj.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.cz.Visible Then ' cz %>
	<tr id="r_cz">
		<td><span id="elh_webset_cz"><%= webset.cz.FldCaption %></span></td>
		<td<%= webset.cz.CellAttributes %>>
<span id="el_webset_cz" class="control-group">
<input type="text" data-field="x_cz" name="x_cz" id="x_cz" size="30" maxlength="50" placeholder="<%= webset.cz.PlaceHolder %>" value="<%= webset.cz.EditValue %>"<%= webset.cz.EditAttributes %>>
</span>
<%= webset.cz.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.dz.Visible Then ' dz %>
	<tr id="r_dz">
		<td><span id="elh_webset_dz"><%= webset.dz.FldCaption %></span></td>
		<td<%= webset.dz.CellAttributes %>>
<span id="el_webset_dz" class="control-group">
<input type="text" data-field="x_dz" name="x_dz" id="x_dz" size="30" maxlength="50" placeholder="<%= webset.dz.PlaceHolder %>" value="<%= webset.dz.EditValue %>"<%= webset.dz.EditAttributes %>>
</span>
<%= webset.dz.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.yx.Visible Then ' yx %>
	<tr id="r_yx">
		<td><span id="elh_webset_yx"><%= webset.yx.FldCaption %></span></td>
		<td<%= webset.yx.CellAttributes %>>
<span id="el_webset_yx" class="control-group">
<input type="text" data-field="x_yx" name="x_yx" id="x_yx" size="30" maxlength="50" placeholder="<%= webset.yx.PlaceHolder %>" value="<%= webset.yx.EditValue %>"<%= webset.yx.EditAttributes %>>
</span>
<%= webset.yx.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.phone400.Visible Then ' phone400 %>
	<tr id="r_phone400">
		<td><span id="elh_webset_phone400"><%= webset.phone400.FldCaption %></span></td>
		<td<%= webset.phone400.CellAttributes %>>
<span id="el_webset_phone400" class="control-group">
<input type="text" data-field="x_phone400" name="x_phone400" id="x_phone400" size="30" maxlength="50" placeholder="<%= webset.phone400.PlaceHolder %>" value="<%= webset.phone400.EditValue %>"<%= webset.phone400.EditAttributes %>>
</span>
<%= webset.phone400.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.qq1.Visible Then ' qq1 %>
	<tr id="r_qq1">
		<td><span id="elh_webset_qq1"><%= webset.qq1.FldCaption %></span></td>
		<td<%= webset.qq1.CellAttributes %>>
<span id="el_webset_qq1" class="control-group">
<input type="text" data-field="x_qq1" name="x_qq1" id="x_qq1" size="30" maxlength="50" placeholder="<%= webset.qq1.PlaceHolder %>" value="<%= webset.qq1.EditValue %>"<%= webset.qq1.EditAttributes %>>
</span>
<%= webset.qq1.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.qq2.Visible Then ' qq2 %>
	<tr id="r_qq2">
		<td><span id="elh_webset_qq2"><%= webset.qq2.FldCaption %></span></td>
		<td<%= webset.qq2.CellAttributes %>>
<span id="el_webset_qq2" class="control-group">
<input type="text" data-field="x_qq2" name="x_qq2" id="x_qq2" size="30" maxlength="50" placeholder="<%= webset.qq2.PlaceHolder %>" value="<%= webset.qq2.EditValue %>"<%= webset.qq2.EditAttributes %>>
</span>
<%= webset.qq2.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.qq3.Visible Then ' qq3 %>
	<tr id="r_qq3">
		<td><span id="elh_webset_qq3"><%= webset.qq3.FldCaption %></span></td>
		<td<%= webset.qq3.CellAttributes %>>
<span id="el_webset_qq3" class="control-group">
<input type="text" data-field="x_qq3" name="x_qq3" id="x_qq3" size="30" maxlength="50" placeholder="<%= webset.qq3.PlaceHolder %>" value="<%= webset.qq3.EditValue %>"<%= webset.qq3.EditAttributes %>>
</span>
<%= webset.qq3.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.qq4.Visible Then ' qq4 %>
	<tr id="r_qq4">
		<td><span id="elh_webset_qq4"><%= webset.qq4.FldCaption %></span></td>
		<td<%= webset.qq4.CellAttributes %>>
<span id="el_webset_qq4" class="control-group">
<input type="text" data-field="x_qq4" name="x_qq4" id="x_qq4" size="30" maxlength="50" placeholder="<%= webset.qq4.PlaceHolder %>" value="<%= webset.qq4.EditValue %>"<%= webset.qq4.EditAttributes %>>
</span>
<%= webset.qq4.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.wxh.Visible Then ' wxh %>
	<tr id="r_wxh">
		<td><span id="elh_webset_wxh"><%= webset.wxh.FldCaption %></span></td>
		<td<%= webset.wxh.CellAttributes %>>
<span id="el_webset_wxh" class="control-group">
<input type="text" data-field="x_wxh" name="x_wxh" id="x_wxh" size="30" maxlength="50" placeholder="<%= webset.wxh.PlaceHolder %>" value="<%= webset.wxh.EditValue %>"<%= webset.wxh.EditAttributes %>>
</span>
<%= webset.wxh.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.wxtp.Visible Then ' wxtp %>
	<tr id="r_wxtp">
		<td><span id="elh_webset_wxtp"><%= webset.wxtp.FldCaption %></span></td>
		<td<%= webset.wxtp.CellAttributes %>>
<span id="el_webset_wxtp" class="control-group">
<input type="text" id="x_wxtp" name="x_wxtp" value="<%= webset.wxtp.EditValue %>" /> <input type="button" id="image2" value="选择图片" />
</span>
<%= webset.wxtp.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.ww.Visible Then ' ww %>
	<tr id="r_ww">
		<td><span id="elh_webset_ww"><%= webset.ww.FldCaption %></span></td>
		<td<%= webset.ww.CellAttributes %>>
<span id="el_webset_ww" class="control-group">
<input type="text" data-field="x_ww" name="x_ww" id="x_ww" size="30" maxlength="50" placeholder="<%= webset.ww.PlaceHolder %>" value="<%= webset.ww.EditValue %>"<%= webset.ww.EditAttributes %>>
</span>
<%= webset.ww.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.tongji.Visible Then ' tongji %>
	<tr id="r_tongji">
		<td><span id="elh_webset_tongji"><%= webset.tongji.FldCaption %></span></td>
		<td<%= webset.tongji.CellAttributes %>>
<span id="el_webset_tongji" class="control-group">
<textarea data-field="x_tongji" name="x_tongji" id="x_tongji" cols="35" rows="4" placeholder="<%= webset.tongji.PlaceHolder %>"<%= webset.tongji.EditAttributes %>><%= webset.tongji.EditValue %></textarea>
</span>
<%= webset.tongji.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.ishtml.Visible Then ' ishtml %>
	<tr id="r_ishtml">
		<td><span id="elh_webset_ishtml"><%= webset.ishtml.FldCaption %></span></td>
		<td<%= webset.ishtml.CellAttributes %>>
<span id="el_webset_ishtml" class="control-group">
<div id="tp_x_ishtml" class="<%= EW_ITEM_TEMPLATE_CLASSNAME %>"><input type="radio" name="x_ishtml" id="x_ishtml" value="{value}"<%= webset.ishtml.EditAttributes %>></div>
<div id="dsl_x_ishtml" data-repeatcolumn="5" class="ewItemList">
<%
emptywrk = True
arwrk = webset.ishtml.EditValue
If IsArray(arwrk) Then
	rowswrk = UBound(arwrk, 2)	
	For rowcntwrk = 0 To rowswrk
		If webset.ishtml.CurrentValue&"" = arwrk(0, rowcntwrk)&"" Then
			selwrk = " checked=""checked"""
			emptywrk = False
		Else
			selwrk = ""
		End If

		' Note: No spacing within the LABEL tag
%>
<%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 5, 1) %>
<label class="radio"><input type="radio" data-field="x_ishtml" name="x_ishtml" id="x_ishtml_<%= rowcntwrk %>" value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %><%= webset.ishtml.EditAttributes %>><%= arwrk(1, rowcntwrk) %></label>
<%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 5, 2) %>
<%
	Next
End If
%>
</div>
</span>
<%= webset.ishtml.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.isqq.Visible Then ' isqq %>
	<tr id="r_isqq">
		<td><span id="elh_webset_isqq"><%= webset.isqq.FldCaption %></span></td>
		<td<%= webset.isqq.CellAttributes %>>
<span id="el_webset_isqq" class="control-group">
<div id="tp_x_isqq" class="<%= EW_ITEM_TEMPLATE_CLASSNAME %>"><input type="radio" name="x_isqq" id="x_isqq" value="{value}"<%= webset.isqq.EditAttributes %>></div>
<div id="dsl_x_isqq" data-repeatcolumn="5" class="ewItemList">
<%
emptywrk = True
arwrk = webset.isqq.EditValue
If IsArray(arwrk) Then
	rowswrk = UBound(arwrk, 2)	
	For rowcntwrk = 0 To rowswrk
		If webset.isqq.CurrentValue&"" = arwrk(0, rowcntwrk)&"" Then
			selwrk = " checked=""checked"""
			emptywrk = False
		Else
			selwrk = ""
		End If

		' Note: No spacing within the LABEL tag
%>
<%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 5, 1) %>
<label class="radio"><input type="radio" data-field="x_isqq" name="x_isqq" id="x_isqq_<%= rowcntwrk %>" value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %><%= webset.isqq.EditAttributes %>><%= arwrk(1, rowcntwrk) %></label>
<%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 5, 2) %>
<%
	Next
End If
%>
</div>
</span>
<%= webset.isqq.CustomMsg %></td>
	</tr>
<% End If %>
<% If webset.logo.Visible Then ' logo %>
	<tr id="r_logo">
		<td><span id="elh_webset_logo"><%= webset.logo.FldCaption %></span></td>
		<td<%= webset.logo.CellAttributes %>>
<span id="el_webset_logo" class="control-group">
<input type="text" id="x_logo" name="x_logo" value="<%= webset.logo.EditValue %>" /> <input type="button" id="image1" value="选择图片" />
</span>
<%= webset.logo.CustomMsg %></td>
	</tr>
<% End If %>
</table>
</td></tr></table>
<button class="btn btn-primary ewButton" name="btnAction" id="btnAction" type="submit"><%= Language.Phrase("EditBtn") %></button>
</form>
<script type="text/javascript">
fwebsetedit.Init();
<% If EW_MOBILE_REFLOW And ew_IsMobile() Then %>
ew_Reflow();
<% End If %>
</script>
<%
webset_edit.ShowPageFooter()
If EW_DEBUG_ENABLED Then Response.Write ew_DebugMsg()
%>
<script type="text/javascript">
// Write your table-specific startup script here
// document.write("page loaded");
</script>
<!--#include file="footer.asp"-->
<%

' Drop page object
Set webset_edit = Nothing
%>
<%

' -----------------------------------------------------------------
' Page Class
'
Class cwebset_edit

	' Page ID
	Public Property Get PageID()
		PageID = "edit"
	End Property

	' Project ID
	Public Property Get ProjectID()
		ProjectID = "{2B78E68A-24C3-4D57-9E98-91476C455DCC}"
	End Property

	' Table Name
	Public Property Get TableName()
		TableName = "webset"
	End Property

	' Page Object Name
	Public Property Get PageObjName()
		PageObjName = "webset_edit"
	End Property

	' Page Name
	Public Property Get PageName()
		PageName = ew_CurrentPage()
	End Property

	' Page Url
	Public Property Get PageUrl()
		PageUrl = ew_CurrentPage() & "?"
		If webset.UseTokenInUrl Then PageUrl = PageUrl & "t=" & webset.TableVar & "&" ' add page token
	End Property

	' Message
	Public Property Get Message()
		Message = Session(EW_SESSION_MESSAGE)
	End Property

	Public Property Let Message(v)
		Dim msg
		msg = Session(EW_SESSION_MESSAGE)
		Call ew_AddMessage(msg, v)
		Session(EW_SESSION_MESSAGE) = msg
	End Property

	Public Property Get FailureMessage()
		FailureMessage = Session(EW_SESSION_FAILURE_MESSAGE)
	End Property

	Public Property Let FailureMessage(v)
		Dim msg
		msg = Session(EW_SESSION_FAILURE_MESSAGE)
		Call ew_AddMessage(msg, v)
		Session(EW_SESSION_FAILURE_MESSAGE) = msg
	End Property

	Public Property Get SuccessMessage()
		SuccessMessage = Session(EW_SESSION_SUCCESS_MESSAGE)
	End Property

	Public Property Let SuccessMessage(v)
		Dim msg
		msg = Session(EW_SESSION_SUCCESS_MESSAGE)
		Call ew_AddMessage(msg, v)
		Session(EW_SESSION_SUCCESS_MESSAGE) = msg
	End Property

	Public Property Get WarningMessage()
		WarningMessage = Session(EW_SESSION_WARNING_MESSAGE)
	End Property

	Public Property Let WarningMessage(v)
		Dim msg
		msg = Session(EW_SESSION_WARNING_MESSAGE)
		Call ew_AddMessage(msg, v)
		Session(EW_SESSION_WARNING_MESSAGE) = msg
	End Property

	' Show Message
	Public Sub ShowMessage()
		Dim hidden, html, sMessage
		hidden = False
		html = ""

		' Message
		sMessage = Message
		Call Message_Showing(sMessage, "")
		If sMessage <> "" Then ' Message in Session, display
			If Not hidden Then sMessage = "<button type=""button"" class=""close"" data-dismiss=""alert"">&times;</button>" & sMessage
			html = html & "<div class=""alert alert-success ewSuccess"">" & sMessage & "</div>"
			Session(EW_SESSION_MESSAGE) = "" ' Clear message in Session
		End If

		' Warning message
		Dim sWarningMessage
		sWarningMessage = WarningMessage
		Call Message_Showing(sWarningMessage, "warning")
		If sWarningMessage <> "" Then ' Message in Session, display
			If Not hidden Then sWarningMessage = "<button type=""button"" class=""close"" data-dismiss=""alert"">&times;</button>" & sWarningMessage
			html = html & "<div class=""alert alert-warning ewWarning"">" & sWarningMessage & "</div>"
			Session(EW_SESSION_WARNING_MESSAGE) = "" ' Clear message in Session
		End If

		' Success message
		Dim sSuccessMessage
		sSuccessMessage = SuccessMessage
		Call Message_Showing(sSuccessMessage, "success")
		If sSuccessMessage <> "" Then ' Message in Session, display
			If Not hidden Then sSuccessMessage = "<button type=""button"" class=""close"" data-dismiss=""alert"">&times;</button>" & sSuccessMessage
			html = html & "<div class=""alert alert-success ewSuccess"">" & sSuccessMessage & "</div>"
			Session(EW_SESSION_SUCCESS_MESSAGE) = "" ' Clear message in Session
		End If

		' Failure message
		Dim sErrorMessage
		sErrorMessage = FailureMessage
		Call Message_Showing(sErrorMessage, "failure")
		If sErrorMessage <> "" Then ' Message in Session, display
			If Not hidden Then sErrorMessage = "<button type=""button"" class=""close"" data-dismiss=""alert"">&times;</button>" & sErrorMessage
			html = html & "<div class=""alert alert-error ewError"">" & sErrorMessage & "</div>"
			Session(EW_SESSION_FAILURE_MESSAGE) = "" ' Clear message in Session
		End If
		Response.Write "<table class=""ewStdTable""><tr><td><div class=""ewMessageDialog""" & ew_IIf(hidden, " style=""display: none;""", "") & ">" & html & "</div></td></tr></table>"
	End Sub
	Dim PageHeader
	Dim PageFooter

	' Show Page Header
	Public Sub ShowPageHeader()
		Dim sHeader
		sHeader = PageHeader
		Call Page_DataRendering(sHeader)
		If sHeader <> "" Then ' Header exists, display
			Response.Write "<p>" & sHeader & "</p>"
		End If
	End Sub

	' Show Page Footer
	Public Sub ShowPageFooter()
		Dim sFooter
		sFooter = PageFooter
		Call Page_DataRendered(sFooter)
		If sFooter <> "" Then ' Footer exists, display
			Response.Write "<p>" & sFooter & "</p>"
		End If
	End Sub

	' -----------------------
	'  Validate Page request
	'
	Public Function IsPageRequest()
		If webset.UseTokenInUrl Then
			IsPageRequest = False
			If Not (ObjForm Is Nothing) Then
				IsPageRequest = (webset.TableVar = ObjForm.GetValue("t"))
			End If
			If Request.QueryString("t").Count > 0 Then
				IsPageRequest = (webset.TableVar = Request.QueryString("t"))
			End If
		Else
			IsPageRequest = True
		End If
	End Function

	' -----------------------------------------------------------------
	'  Class initialize
	'  - init objects
	'  - open ADO connection
	'
	Private Sub Class_Initialize()
		If IsEmpty(StartTimer) Then StartTimer = Timer ' Init start time

		' Initialize language object
		If IsEmpty(Language) Then
			Set Language = New cLanguage
			Call Language.LoadPhrases()
		End If

		' Initialize table object
		If IsEmpty(webset) Then Set webset = New cwebset
		Set Table = webset

		' Initialize urls
		' Initialize other table object

		If IsEmpty(zlogin) Then Set zlogin = New czlogin

		' Initialize form object
		Set ObjForm = Nothing

		' Intialize page id (for backward compatibility)
		EW_PAGE_ID = "edit"

		' Initialize table name (for backward compatibility)
		EW_TABLE_NAME = "webset"

		' Open connection to the database
		If IsEmpty(Conn) Then Call ew_Connect()
	End Sub

	' -----------------------------------------------------------------
	'  Subroutine Page_Init
	'  - called before page main
	'  - check Security
	'  - set up response header
	'  - call page load events
	'
	Sub Page_Init()
		Set Security = New cAdvancedSecurity
		If Not Security.IsLoggedIn() Then Call Security.AutoLogin()
		If Not Security.IsLoggedIn() Then
			Call Security.SaveLastUrl()
			Call Page_Terminate("login.asp")
		End If

		' Table Permission loading event
		Call Security.TablePermission_Loading()
		Call Security.LoadCurrentUserLevel(ProjectID & TableName)

		' Table Permission loaded event
		Call Security.TablePermission_Loaded()
		If Not Security.IsLoggedIn() Then
			Call Security.SaveLastUrl()
			Call Page_Terminate("login.asp")
		End If
		If Not Security.CanEdit Then
			Call Security.SaveLastUrl()
			Call Page_Terminate("websetlist.asp")
		End If

		' Create form object
		'If Request.ServerVariables("HTTP_CONTENT_TYPE") = "application/x-www-form-urlencoded" Then

			Set ObjForm = New cFormObj

		'Else
		'	Set ObjForm = ew_GetUploadObj()
		'End If

		webset.CurrentAction = ew_IIf(Request.QueryString("a").Count > 0, Request.QueryString("a") & "", ObjForm.GetValue("a_list") & "") ' Set up current action
		webset.id.Visible = Not webset.IsAdd() And Not webset.IsCopy() And Not webset.IsGridAdd()

		' Global page loading event (in userfn7.asp)
		Page_Loading()

		' Page load event, used in current page
		Page_Load()
	End Sub

	' -----------------------------------------------------------------
	'  Class terminate
	'  - clean up page object
	'
	Private Sub Class_Terminate()
		Call Page_Terminate("")
	End Sub

	' -----------------------------------------------------------------
	'  Subroutine Page_Terminate
	'  - called when exit page
	'  - clean up ADO connection and objects
	'  - if url specified, redirect to url
	'
	Sub Page_Terminate(url)

		' Page unload event, used in current page
		Call Page_Unload()

		' Global page unloaded event (in userfn60.asp)
		Call Page_Unloaded()
		Dim sRedirectUrl
		sReDirectUrl = url
		Call Page_Redirecting(sReDirectUrl)
		If Not (Conn Is Nothing) Then Conn.Close ' Close Connection
		Set Conn = Nothing
		Set Security = Nothing
		Set webset = Nothing
		Set ObjForm = Nothing

		' Go to url if specified
		If sReDirectUrl <> "" Then
			If Response.Buffer Then Response.Clear
			Response.Redirect sReDirectUrl
		End If
	End Sub

	'
	'  Subroutine Page_Terminate (End)
	' ----------------------------------------

	Dim DbMasterFilter, DbDetailFilter

	' -----------------------------------------------------------------
	' Page main processing
	'
	Sub Page_Main()
		Dim sReturnUrl
		sReturnUrl = ""

		' Load key from QueryString
		If Request.QueryString("id").Count > 0 Then
			webset.id.QueryStringValue = Request.QueryString("id")
		End If

		' Set up Breadcrumb
		SetupBreadcrumb()

		' Process form if post back
		If ObjForm.GetValue("a_edit")&"" <> "" Then
			webset.CurrentAction = ObjForm.GetValue("a_edit") ' Get action code
			Call LoadFormValues() ' Get form values
		Else
			webset.CurrentAction = "I" ' Default action is display
		End If

		' Check if valid key
		If webset.id.CurrentValue = "" Then Call Page_Terminate("websetlist.asp") ' Invalid key, return to list

		' Validate form if post back
		If ObjForm.GetValue("a_edit")&"" <> "" Then
			If Not ValidateForm() Then
				webset.CurrentAction = "" ' Form error, reset action
				FailureMessage = gsFormError
				webset.EventCancelled = True ' Event cancelled
				Call LoadRow() ' Restore row
				Call RestoreFormValues() ' Restore form values if validate failed
			End If
		End If
		Select Case webset.CurrentAction
			Case "I" ' Get a record to display
				If Not LoadRow() Then ' Load Record based on key
					If FailureMessage = "" Then FailureMessage = Language.Phrase("NoRecord") ' No record found
					Call Page_Terminate("websetlist.asp") ' No matching record, return to list
				End If
			Case "U" ' Update
				webset.SendEmail = True ' Send email on update success
				If EditRow() Then ' Update Record based on key
					SuccessMessage = Language.Phrase("UpdateSuccess") ' Update success
					sReturnUrl = webset.ReturnUrl
					If ew_GetPageName(sReturnUrl) = "websetview.asp" Then sReturnUrl = webset.ViewUrl("") ' View paging, return to view page with keyurl directly
					Call Page_Terminate(sReturnUrl) ' Return to caller
				Else
					webset.EventCancelled = True ' Event cancelled
					Call LoadRow() ' Restore row
					Call RestoreFormValues() ' Restore form values if update failed
				End If
		End Select

		' Render the record
		webset.RowType = EW_ROWTYPE_EDIT ' Render as edit

		' Render row
		Call webset.ResetAttrs()
		Call RenderRow()
	End Sub
	Dim Pager

	' -----------------------------------------------------------------
	' Set up Starting Record parameters based on Pager Navigation
	'
	Sub SetUpStartRec()
		Dim PageNo

		' Exit if DisplayRecs = 0
		If DisplayRecs = 0 Then Exit Sub
		If IsPageRequest Then ' Validate request

			' Check for a START parameter
			If Request.QueryString(EW_TABLE_START_REC).Count > 0 Then
				StartRec = Request.QueryString(EW_TABLE_START_REC)
				webset.StartRecordNumber = StartRec
			ElseIf Request.QueryString(EW_TABLE_PAGE_NO).Count > 0 Then
				PageNo = Request.QueryString(EW_TABLE_PAGE_NO)
				If IsNumeric(PageNo) Then
					StartRec = (PageNo-1)*DisplayRecs+1
					If StartRec <= 0 Then
						StartRec = 1
					ElseIf StartRec >= ((TotalRecs-1)\DisplayRecs)*DisplayRecs+1 Then
						StartRec = ((TotalRecs-1)\DisplayRecs)*DisplayRecs+1
					End If
					webset.StartRecordNumber = StartRec
				End If
			End If
		End If
		StartRec = webset.StartRecordNumber

		' Check if correct start record counter
		If Not IsNumeric(StartRec) Or StartRec = "" Then ' Avoid invalid start record counter
			StartRec = 1 ' Reset start record counter
			webset.StartRecordNumber = StartRec
		ElseIf CLng(StartRec) > CLng(TotalRecs) Then ' Avoid starting record > total records
			StartRec = ((TotalRecs-1)\DisplayRecs)*DisplayRecs+1 ' Point to last page first record
			webset.StartRecordNumber = StartRec
		ElseIf (StartRec-1) Mod DisplayRecs <> 0 Then
			StartRec = ((StartRec-1)\DisplayRecs)*DisplayRecs+1 ' Point to page boundary
			webset.StartRecordNumber = StartRec
		End If
	End Sub

	' -----------------------------------------------------------------
	' Function Get upload files
	'
	Function GetUploadFiles()

		' Get upload data
	End Function

	' -----------------------------------------------------------------
	' Load form values
	'
	Function LoadFormValues()

		' Load values from form
		If Not webset.id.FldIsDetailKey Then webset.id.FormValue = ObjForm.GetValue("x_id")
		If Not webset.webname.FldIsDetailKey Then webset.webname.FormValue = ObjForm.GetValue("x_webname")
		If Not webset.ym.FldIsDetailKey Then webset.ym.FormValue = ObjForm.GetValue("x_ym")
		If Not webset.icp.FldIsDetailKey Then webset.icp.FormValue = ObjForm.GetValue("x_icp")
		If Not webset.lxr.FldIsDetailKey Then webset.lxr.FormValue = ObjForm.GetValue("x_lxr")
		If Not webset.sj.FldIsDetailKey Then webset.sj.FormValue = ObjForm.GetValue("x_sj")
		If Not webset.zj.FldIsDetailKey Then webset.zj.FormValue = ObjForm.GetValue("x_zj")
		If Not webset.cz.FldIsDetailKey Then webset.cz.FormValue = ObjForm.GetValue("x_cz")
		If Not webset.dz.FldIsDetailKey Then webset.dz.FormValue = ObjForm.GetValue("x_dz")
		If Not webset.yx.FldIsDetailKey Then webset.yx.FormValue = ObjForm.GetValue("x_yx")
		If Not webset.phone400.FldIsDetailKey Then webset.phone400.FormValue = ObjForm.GetValue("x_phone400")
		If Not webset.qq1.FldIsDetailKey Then webset.qq1.FormValue = ObjForm.GetValue("x_qq1")
		If Not webset.qq2.FldIsDetailKey Then webset.qq2.FormValue = ObjForm.GetValue("x_qq2")
		If Not webset.qq3.FldIsDetailKey Then webset.qq3.FormValue = ObjForm.GetValue("x_qq3")
		If Not webset.qq4.FldIsDetailKey Then webset.qq4.FormValue = ObjForm.GetValue("x_qq4")
		If Not webset.wxh.FldIsDetailKey Then webset.wxh.FormValue = ObjForm.GetValue("x_wxh")
		If Not webset.wxtp.FldIsDetailKey Then webset.wxtp.FormValue = ObjForm.GetValue("x_wxtp")
		If Not webset.ww.FldIsDetailKey Then webset.ww.FormValue = ObjForm.GetValue("x_ww")
		If Not webset.tongji.FldIsDetailKey Then webset.tongji.FormValue = ObjForm.GetValue("x_tongji")
		If Not webset.ishtml.FldIsDetailKey Then webset.ishtml.FormValue = ObjForm.GetValue("x_ishtml")
		If Not webset.isqq.FldIsDetailKey Then webset.isqq.FormValue = ObjForm.GetValue("x_isqq")
		If Not webset.logo.FldIsDetailKey Then webset.logo.FormValue = ObjForm.GetValue("x_logo")
	End Function

	' -----------------------------------------------------------------
	' Restore form values
	'
	Function RestoreFormValues()
		Call LoadRow()
		webset.id.CurrentValue = webset.id.FormValue
		webset.webname.CurrentValue = webset.webname.FormValue
		webset.ym.CurrentValue = webset.ym.FormValue
		webset.icp.CurrentValue = webset.icp.FormValue
		webset.lxr.CurrentValue = webset.lxr.FormValue
		webset.sj.CurrentValue = webset.sj.FormValue
		webset.zj.CurrentValue = webset.zj.FormValue
		webset.cz.CurrentValue = webset.cz.FormValue
		webset.dz.CurrentValue = webset.dz.FormValue
		webset.yx.CurrentValue = webset.yx.FormValue
		webset.phone400.CurrentValue = webset.phone400.FormValue
		webset.qq1.CurrentValue = webset.qq1.FormValue
		webset.qq2.CurrentValue = webset.qq2.FormValue
		webset.qq3.CurrentValue = webset.qq3.FormValue
		webset.qq4.CurrentValue = webset.qq4.FormValue
		webset.wxh.CurrentValue = webset.wxh.FormValue
		webset.wxtp.CurrentValue = webset.wxtp.FormValue
		webset.ww.CurrentValue = webset.ww.FormValue
		webset.tongji.CurrentValue = webset.tongji.FormValue
		webset.ishtml.CurrentValue = webset.ishtml.FormValue
		webset.isqq.CurrentValue = webset.isqq.FormValue
		webset.logo.CurrentValue = webset.logo.FormValue
	End Function

	' -----------------------------------------------------------------
	' Load row based on key values
	'
	Function LoadRow()
		Dim RsRow, sSql, sFilter
		sFilter = webset.KeyFilter

		' Call Row Selecting event
		Call webset.Row_Selecting(sFilter)

		' Load sql based on filter
		webset.CurrentFilter = sFilter
		sSql = webset.SQL
		Call ew_SetDebugMsg("LoadRow: " & sSql) ' Show SQL for debugging
		Set RsRow = ew_LoadRow(sSql)
		If RsRow.Eof Then
			LoadRow = False
		Else
			LoadRow = True
			RsRow.MoveFirst
			Call LoadRowValues(RsRow) ' Load row values
		End If
		RsRow.Close
		Set RsRow = Nothing
	End Function

	' -----------------------------------------------------------------
	' Load row values from recordset
	'
	Sub LoadRowValues(RsRow)
		Dim sDetailFilter
		If Not EW_DEBUG_ENABLED Then On Error Resume Next
		If RsRow.Eof Then Exit Sub

		' Call Row Selected event
		Call webset.Row_Selected(RsRow)
		webset.id.DbValue = RsRow("id")
		webset.webname.DbValue = RsRow("webname")
		webset.ym.DbValue = RsRow("ym")
		webset.icp.DbValue = RsRow("icp")
		webset.lxr.DbValue = RsRow("lxr")
		webset.sj.DbValue = RsRow("sj")
		webset.zj.DbValue = RsRow("zj")
		webset.cz.DbValue = RsRow("cz")
		webset.dz.DbValue = RsRow("dz")
		webset.yx.DbValue = RsRow("yx")
		webset.phone400.DbValue = RsRow("phone400")
		webset.qq1.DbValue = RsRow("qq1")
		webset.qq2.DbValue = RsRow("qq2")
		webset.qq3.DbValue = RsRow("qq3")
		webset.qq4.DbValue = RsRow("qq4")
		webset.wxh.DbValue = RsRow("wxh")
		webset.wxtp.DbValue = RsRow("wxtp")
		webset.ww.DbValue = RsRow("ww")
		webset.tongji.DbValue = RsRow("tongji")
		webset.ishtml.DbValue = RsRow("ishtml")
		webset.isqq.DbValue = RsRow("isqq")
		webset.logo.DbValue = RsRow("logo")
	End Sub

	' Load DbValue from recordset
	Sub LoadDbValues(Rs)
		If Not EW_DEBUG_ENABLED Then On Error Resume Next
		If Rs.Eof Then Exit Sub
		webset.id.m_DbValue = Rs("id")
		webset.webname.m_DbValue = Rs("webname")
		webset.ym.m_DbValue = Rs("ym")
		webset.icp.m_DbValue = Rs("icp")
		webset.lxr.m_DbValue = Rs("lxr")
		webset.sj.m_DbValue = Rs("sj")
		webset.zj.m_DbValue = Rs("zj")
		webset.cz.m_DbValue = Rs("cz")
		webset.dz.m_DbValue = Rs("dz")
		webset.yx.m_DbValue = Rs("yx")
		webset.phone400.m_DbValue = Rs("phone400")
		webset.qq1.m_DbValue = Rs("qq1")
		webset.qq2.m_DbValue = Rs("qq2")
		webset.qq3.m_DbValue = Rs("qq3")
		webset.qq4.m_DbValue = Rs("qq4")
		webset.wxh.m_DbValue = Rs("wxh")
		webset.wxtp.m_DbValue = Rs("wxtp")
		webset.ww.m_DbValue = Rs("ww")
		webset.tongji.m_DbValue = Rs("tongji")
		webset.ishtml.m_DbValue = Rs("ishtml")
		webset.isqq.m_DbValue = Rs("isqq")
		webset.logo.m_DbValue = Rs("logo")
	End Sub

	' -----------------------------------------------------------------
	' Render row values based on field settings
	'
	Sub RenderRow()

		' Initialize urls
		' Call Row Rendering event

		Call webset.Row_Rendering()

		' ---------------------------------------
		'  Common render codes for all row types
		' ---------------------------------------
		' id
		' webname
		' ym
		' icp
		' lxr
		' sj
		' zj
		' cz
		' dz
		' yx
		' phone400
		' qq1
		' qq2
		' qq3
		' qq4
		' wxh
		' wxtp
		' ww
		' tongji
		' ishtml
		' isqq
		' logo
		' -----------
		'  View  Row
		' -----------

		If webset.RowType = EW_ROWTYPE_VIEW Then ' View row

			' id
			webset.id.ViewValue = webset.id.CurrentValue
			webset.id.ViewCustomAttributes = ""

			' webname
			webset.webname.ViewValue = webset.webname.CurrentValue
			webset.webname.ViewCustomAttributes = ""

			' ym
			webset.ym.ViewValue = webset.ym.CurrentValue
			webset.ym.ViewCustomAttributes = ""

			' icp
			webset.icp.ViewValue = webset.icp.CurrentValue
			webset.icp.ViewCustomAttributes = ""

			' lxr
			webset.lxr.ViewValue = webset.lxr.CurrentValue
			webset.lxr.ViewCustomAttributes = ""

			' sj
			webset.sj.ViewValue = webset.sj.CurrentValue
			webset.sj.ViewCustomAttributes = ""

			' zj
			webset.zj.ViewValue = webset.zj.CurrentValue
			webset.zj.ViewCustomAttributes = ""

			' cz
			webset.cz.ViewValue = webset.cz.CurrentValue
			webset.cz.ViewCustomAttributes = ""

			' dz
			webset.dz.ViewValue = webset.dz.CurrentValue
			webset.dz.ViewCustomAttributes = ""

			' yx
			webset.yx.ViewValue = webset.yx.CurrentValue
			webset.yx.ViewCustomAttributes = ""

			' phone400
			webset.phone400.ViewValue = webset.phone400.CurrentValue
			webset.phone400.ViewCustomAttributes = ""

			' qq1
			webset.qq1.ViewValue = webset.qq1.CurrentValue
			webset.qq1.ViewCustomAttributes = ""

			' qq2
			webset.qq2.ViewValue = webset.qq2.CurrentValue
			webset.qq2.ViewCustomAttributes = ""

			' qq3
			webset.qq3.ViewValue = webset.qq3.CurrentValue
			webset.qq3.ViewCustomAttributes = ""

			' qq4
			webset.qq4.ViewValue = webset.qq4.CurrentValue
			webset.qq4.ViewCustomAttributes = ""

			' wxh
			webset.wxh.ViewValue = webset.wxh.CurrentValue
			webset.wxh.ViewCustomAttributes = ""

			' wxtp
			webset.wxtp.ViewValue = webset.wxtp.CurrentValue
			webset.wxtp.ViewCustomAttributes = ""

			' ww
			webset.ww.ViewValue = webset.ww.CurrentValue
			webset.ww.ViewCustomAttributes = ""

			' tongji
			webset.tongji.ViewValue = webset.tongji.CurrentValue
			If Not IsNull(webset.tongji.ViewValue) Then
				webset.tongji.ViewValue = Replace(webset.tongji.ViewValue, vbLf, "<br>")
			End If
			webset.tongji.ViewCustomAttributes = ""

			' ishtml
			If Not IsNull(webset.ishtml.CurrentValue) Then
				Select Case webset.ishtml.CurrentValue & ""
					Case webset.ishtml.FldTagValue(1)
						webset.ishtml.ViewValue = ew_IIf(webset.ishtml.FldTagCaption(1) <> "", webset.ishtml.FldTagCaption(1), webset.ishtml.CurrentValue)
					Case webset.ishtml.FldTagValue(2)
						webset.ishtml.ViewValue = ew_IIf(webset.ishtml.FldTagCaption(2) <> "", webset.ishtml.FldTagCaption(2), webset.ishtml.CurrentValue)
					Case Else
						webset.ishtml.ViewValue = webset.ishtml.CurrentValue
				End Select
			Else
				webset.ishtml.ViewValue = Null
			End If
			webset.ishtml.ViewCustomAttributes = ""

			' isqq
			If Not IsNull(webset.isqq.CurrentValue) Then
				Select Case webset.isqq.CurrentValue & ""
					Case webset.isqq.FldTagValue(1)
						webset.isqq.ViewValue = ew_IIf(webset.isqq.FldTagCaption(1) <> "", webset.isqq.FldTagCaption(1), webset.isqq.CurrentValue)
					Case webset.isqq.FldTagValue(2)
						webset.isqq.ViewValue = ew_IIf(webset.isqq.FldTagCaption(2) <> "", webset.isqq.FldTagCaption(2), webset.isqq.CurrentValue)
					Case Else
						webset.isqq.ViewValue = webset.isqq.CurrentValue
				End Select
			Else
				webset.isqq.ViewValue = Null
			End If
			webset.isqq.ViewCustomAttributes = ""

			' logo
			webset.logo.ViewValue = webset.logo.CurrentValue
			webset.logo.ViewCustomAttributes = ""

			' View refer script
			' id

			webset.id.LinkCustomAttributes = ""
			webset.id.HrefValue = ""
			webset.id.TooltipValue = ""

			' webname
			webset.webname.LinkCustomAttributes = ""
			webset.webname.HrefValue = ""
			webset.webname.TooltipValue = ""

			' ym
			webset.ym.LinkCustomAttributes = ""
			webset.ym.HrefValue = ""
			webset.ym.TooltipValue = ""

			' icp
			webset.icp.LinkCustomAttributes = ""
			webset.icp.HrefValue = ""
			webset.icp.TooltipValue = ""

			' lxr
			webset.lxr.LinkCustomAttributes = ""
			webset.lxr.HrefValue = ""
			webset.lxr.TooltipValue = ""

			' sj
			webset.sj.LinkCustomAttributes = ""
			webset.sj.HrefValue = ""
			webset.sj.TooltipValue = ""

			' zj
			webset.zj.LinkCustomAttributes = ""
			webset.zj.HrefValue = ""
			webset.zj.TooltipValue = ""

			' cz
			webset.cz.LinkCustomAttributes = ""
			webset.cz.HrefValue = ""
			webset.cz.TooltipValue = ""

			' dz
			webset.dz.LinkCustomAttributes = ""
			webset.dz.HrefValue = ""
			webset.dz.TooltipValue = ""

			' yx
			webset.yx.LinkCustomAttributes = ""
			webset.yx.HrefValue = ""
			webset.yx.TooltipValue = ""

			' phone400
			webset.phone400.LinkCustomAttributes = ""
			webset.phone400.HrefValue = ""
			webset.phone400.TooltipValue = ""

			' qq1
			webset.qq1.LinkCustomAttributes = ""
			webset.qq1.HrefValue = ""
			webset.qq1.TooltipValue = ""

			' qq2
			webset.qq2.LinkCustomAttributes = ""
			webset.qq2.HrefValue = ""
			webset.qq2.TooltipValue = ""

			' qq3
			webset.qq3.LinkCustomAttributes = ""
			webset.qq3.HrefValue = ""
			webset.qq3.TooltipValue = ""

			' qq4
			webset.qq4.LinkCustomAttributes = ""
			webset.qq4.HrefValue = ""
			webset.qq4.TooltipValue = ""

			' wxh
			webset.wxh.LinkCustomAttributes = ""
			webset.wxh.HrefValue = ""
			webset.wxh.TooltipValue = ""

			' wxtp
			webset.wxtp.LinkCustomAttributes = ""
			webset.wxtp.HrefValue = ""
			webset.wxtp.TooltipValue = ""

			' ww
			webset.ww.LinkCustomAttributes = ""
			webset.ww.HrefValue = ""
			webset.ww.TooltipValue = ""

			' tongji
			webset.tongji.LinkCustomAttributes = ""
			webset.tongji.HrefValue = ""
			webset.tongji.TooltipValue = ""

			' ishtml
			webset.ishtml.LinkCustomAttributes = ""
			webset.ishtml.HrefValue = ""
			webset.ishtml.TooltipValue = ""

			' isqq
			webset.isqq.LinkCustomAttributes = ""
			webset.isqq.HrefValue = ""
			webset.isqq.TooltipValue = ""

			' logo
			webset.logo.LinkCustomAttributes = ""
			webset.logo.HrefValue = ""
			webset.logo.TooltipValue = ""

		' ----------
		'  Edit Row
		' ----------

		ElseIf webset.RowType = EW_ROWTYPE_EDIT Then ' Edit row

			' id
			webset.id.EditCustomAttributes = ""
			webset.id.EditValue = webset.id.CurrentValue
			webset.id.ViewCustomAttributes = ""

			' webname
			webset.webname.EditCustomAttributes = ""
			webset.webname.EditValue = ew_HtmlEncode(webset.webname.CurrentValue)
			webset.webname.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(webset.webname.FldCaption))

			' ym
			webset.ym.EditCustomAttributes = ""
			webset.ym.EditValue = ew_HtmlEncode(webset.ym.CurrentValue)
			webset.ym.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(webset.ym.FldCaption))

			' icp
			webset.icp.EditCustomAttributes = ""
			webset.icp.EditValue = ew_HtmlEncode(webset.icp.CurrentValue)
			webset.icp.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(webset.icp.FldCaption))

			' lxr
			webset.lxr.EditCustomAttributes = ""
			webset.lxr.EditValue = ew_HtmlEncode(webset.lxr.CurrentValue)
			webset.lxr.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(webset.lxr.FldCaption))

			' sj
			webset.sj.EditCustomAttributes = ""
			webset.sj.EditValue = ew_HtmlEncode(webset.sj.CurrentValue)
			webset.sj.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(webset.sj.FldCaption))

			' zj
			webset.zj.EditCustomAttributes = ""
			webset.zj.EditValue = ew_HtmlEncode(webset.zj.CurrentValue)
			webset.zj.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(webset.zj.FldCaption))

			' cz
			webset.cz.EditCustomAttributes = ""
			webset.cz.EditValue = ew_HtmlEncode(webset.cz.CurrentValue)
			webset.cz.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(webset.cz.FldCaption))

			' dz
			webset.dz.EditCustomAttributes = ""
			webset.dz.EditValue = ew_HtmlEncode(webset.dz.CurrentValue)
			webset.dz.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(webset.dz.FldCaption))

			' yx
			webset.yx.EditCustomAttributes = ""
			webset.yx.EditValue = ew_HtmlEncode(webset.yx.CurrentValue)
			webset.yx.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(webset.yx.FldCaption))

			' phone400
			webset.phone400.EditCustomAttributes = ""
			webset.phone400.EditValue = ew_HtmlEncode(webset.phone400.CurrentValue)
			webset.phone400.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(webset.phone400.FldCaption))

			' qq1
			webset.qq1.EditCustomAttributes = ""
			webset.qq1.EditValue = ew_HtmlEncode(webset.qq1.CurrentValue)
			webset.qq1.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(webset.qq1.FldCaption))

			' qq2
			webset.qq2.EditCustomAttributes = ""
			webset.qq2.EditValue = ew_HtmlEncode(webset.qq2.CurrentValue)
			webset.qq2.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(webset.qq2.FldCaption))

			' qq3
			webset.qq3.EditCustomAttributes = ""
			webset.qq3.EditValue = ew_HtmlEncode(webset.qq3.CurrentValue)
			webset.qq3.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(webset.qq3.FldCaption))

			' qq4
			webset.qq4.EditCustomAttributes = ""
			webset.qq4.EditValue = ew_HtmlEncode(webset.qq4.CurrentValue)
			webset.qq4.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(webset.qq4.FldCaption))

			' wxh
			webset.wxh.EditCustomAttributes = ""
			webset.wxh.EditValue = ew_HtmlEncode(webset.wxh.CurrentValue)
			webset.wxh.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(webset.wxh.FldCaption))

			' wxtp
			webset.wxtp.EditCustomAttributes = ""
			webset.wxtp.EditValue = ew_HtmlEncode(webset.wxtp.CurrentValue)
			webset.wxtp.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(webset.wxtp.FldCaption))

			' ww
			webset.ww.EditCustomAttributes = ""
			webset.ww.EditValue = ew_HtmlEncode(webset.ww.CurrentValue)
			webset.ww.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(webset.ww.FldCaption))

			' tongji
			webset.tongji.EditCustomAttributes = ""
			webset.tongji.EditValue = webset.tongji.CurrentValue
			webset.tongji.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(webset.tongji.FldCaption))

			' ishtml
			webset.ishtml.EditCustomAttributes = ""
			Redim arwrk(1, 1)
			arwrk(0, 0) = webset.ishtml.FldTagValue(1)
			arwrk(1, 0) = ew_IIf(webset.ishtml.FldTagCaption(1) <> "", webset.ishtml.FldTagCaption(1), webset.ishtml.FldTagValue(1))
			arwrk(0, 1) = webset.ishtml.FldTagValue(2)
			arwrk(1, 1) = ew_IIf(webset.ishtml.FldTagCaption(2) <> "", webset.ishtml.FldTagCaption(2), webset.ishtml.FldTagValue(2))
			webset.ishtml.EditValue = arwrk

			' isqq
			webset.isqq.EditCustomAttributes = ""
			Redim arwrk(1, 1)
			arwrk(0, 0) = webset.isqq.FldTagValue(1)
			arwrk(1, 0) = ew_IIf(webset.isqq.FldTagCaption(1) <> "", webset.isqq.FldTagCaption(1), webset.isqq.FldTagValue(1))
			arwrk(0, 1) = webset.isqq.FldTagValue(2)
			arwrk(1, 1) = ew_IIf(webset.isqq.FldTagCaption(2) <> "", webset.isqq.FldTagCaption(2), webset.isqq.FldTagValue(2))
			webset.isqq.EditValue = arwrk

			' logo
			webset.logo.EditCustomAttributes = ""
			webset.logo.EditValue = webset.logo.CurrentValue
			webset.logo.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(webset.logo.FldCaption))

			' Edit refer script
			' id

			webset.id.HrefValue = ""

			' webname
			webset.webname.HrefValue = ""

			' ym
			webset.ym.HrefValue = ""

			' icp
			webset.icp.HrefValue = ""

			' lxr
			webset.lxr.HrefValue = ""

			' sj
			webset.sj.HrefValue = ""

			' zj
			webset.zj.HrefValue = ""

			' cz
			webset.cz.HrefValue = ""

			' dz
			webset.dz.HrefValue = ""

			' yx
			webset.yx.HrefValue = ""

			' phone400
			webset.phone400.HrefValue = ""

			' qq1
			webset.qq1.HrefValue = ""

			' qq2
			webset.qq2.HrefValue = ""

			' qq3
			webset.qq3.HrefValue = ""

			' qq4
			webset.qq4.HrefValue = ""

			' wxh
			webset.wxh.HrefValue = ""

			' wxtp
			webset.wxtp.HrefValue = ""

			' ww
			webset.ww.HrefValue = ""

			' tongji
			webset.tongji.HrefValue = ""

			' ishtml
			webset.ishtml.HrefValue = ""

			' isqq
			webset.isqq.HrefValue = ""

			' logo
			webset.logo.HrefValue = ""
		End If
		If webset.RowType = EW_ROWTYPE_ADD Or webset.RowType = EW_ROWTYPE_EDIT Or webset.RowType = EW_ROWTYPE_SEARCH Then ' Add / Edit / Search row
			Call webset.SetupFieldTitles()
		End If

		' Call Row Rendered event
		If webset.RowType <> EW_ROWTYPE_AGGREGATEINIT Then
			Call webset.Row_Rendered()
		End If
	End Sub

	' -----------------------------------------------------------------
	' Validate form
	'
	Function ValidateForm()

		' Initialize
		gsFormError = ""

		' Check if validation required
		If Not EW_SERVER_VALIDATE Then
			ValidateForm = (gsFormError = "")
			Exit Function
		End If

		' Return validate result
		ValidateForm = (gsFormError = "")

		' Call Form Custom Validate event
		Dim sFormCustomError
		sFormCustomError = ""
		ValidateForm = ValidateForm And Form_CustomValidate(sFormCustomError)
		If sFormCustomError <> "" Then
			Call ew_AddMessage(gsFormError, sFormCustomError)
		End If
	End Function

	' -----------------------------------------------------------------
	' Update record based on key values
	'
	Function EditRow()
		If Not EW_DEBUG_ENABLED Then On Error Resume Next
		Dim Rs, sSql, sFilter
		Dim RsChk, sSqlChk, sFilterChk
		Dim bUpdateRow
		Dim RsOld, RsNew
		Dim sIdxErrMsg

		' Clear any previous errors
		Err.Clear
		sFilter = webset.KeyFilter
		webset.CurrentFilter  = sFilter
		sSql = webset.SQL
		Set Rs = Server.CreateObject("ADODB.Recordset")
		Rs.CursorLocation = EW_CURSORLOCATION
		Rs.Open sSql, Conn, 1, EW_RECORDSET_LOCKTYPE
		If Err.Number <> 0 Then
			Message = Err.Description
			Rs.Close
			Set Rs = Nothing
			EditRow = False
			Exit Function
		End If

		' Clone old recordset object
		Set RsOld = ew_CloneRs(Rs)
		Call LoadDbValues(RsOld)
		If Rs.Eof Then
			EditRow = False ' Update Failed
		Else

			' Field webname
			Call webset.webname.SetDbValue(Rs, webset.webname.CurrentValue, Null, webset.webname.ReadOnly)

			' Field ym
			Call webset.ym.SetDbValue(Rs, webset.ym.CurrentValue, Null, webset.ym.ReadOnly)

			' Field icp
			Call webset.icp.SetDbValue(Rs, webset.icp.CurrentValue, Null, webset.icp.ReadOnly)

			' Field lxr
			Call webset.lxr.SetDbValue(Rs, webset.lxr.CurrentValue, Null, webset.lxr.ReadOnly)

			' Field sj
			Call webset.sj.SetDbValue(Rs, webset.sj.CurrentValue, Null, webset.sj.ReadOnly)

			' Field zj
			Call webset.zj.SetDbValue(Rs, webset.zj.CurrentValue, Null, webset.zj.ReadOnly)

			' Field cz
			Call webset.cz.SetDbValue(Rs, webset.cz.CurrentValue, Null, webset.cz.ReadOnly)

			' Field dz
			Call webset.dz.SetDbValue(Rs, webset.dz.CurrentValue, Null, webset.dz.ReadOnly)

			' Field yx
			Call webset.yx.SetDbValue(Rs, webset.yx.CurrentValue, Null, webset.yx.ReadOnly)

			' Field phone400
			Call webset.phone400.SetDbValue(Rs, webset.phone400.CurrentValue, Null, webset.phone400.ReadOnly)

			' Field qq1
			Call webset.qq1.SetDbValue(Rs, webset.qq1.CurrentValue, Null, webset.qq1.ReadOnly)

			' Field qq2
			Call webset.qq2.SetDbValue(Rs, webset.qq2.CurrentValue, Null, webset.qq2.ReadOnly)

			' Field qq3
			Call webset.qq3.SetDbValue(Rs, webset.qq3.CurrentValue, Null, webset.qq3.ReadOnly)

			' Field qq4
			Call webset.qq4.SetDbValue(Rs, webset.qq4.CurrentValue, Null, webset.qq4.ReadOnly)

			' Field wxh
			Call webset.wxh.SetDbValue(Rs, webset.wxh.CurrentValue, Null, webset.wxh.ReadOnly)

			' Field wxtp
			Call webset.wxtp.SetDbValue(Rs, webset.wxtp.CurrentValue, Null, webset.wxtp.ReadOnly)

			' Field ww
			Call webset.ww.SetDbValue(Rs, webset.ww.CurrentValue, Null, webset.ww.ReadOnly)

			' Field tongji
			Call webset.tongji.SetDbValue(Rs, webset.tongji.CurrentValue, Null, webset.tongji.ReadOnly)

			' Field ishtml
			Call webset.ishtml.SetDbValue(Rs, webset.ishtml.CurrentValue, Null, webset.ishtml.ReadOnly)

			' Field isqq
			Call webset.isqq.SetDbValue(Rs, webset.isqq.CurrentValue, Null, webset.isqq.ReadOnly)

			' Field logo
			Call webset.logo.SetDbValue(Rs, webset.logo.CurrentValue, Null, webset.logo.ReadOnly)

			' Check recordset update error
			If Err.Number <> 0 Then
				FailureMessage = Err.Description
				Rs.Close
				Set Rs = Nothing
				EditRow = False
				Exit Function
			End If

			' Call Row Updating event
			bUpdateRow = webset.Row_Updating(RsOld, Rs)
			If bUpdateRow Then

				' Clone new recordset object
				Set RsNew = ew_CloneRs(Rs)
				EditRow = True
				If EditRow Then
					Rs.Update
				End If
				If Err.Number <> 0 Or Not EditRow Then
					If Err.Description <> "" Then FailureMessage = Err.Description
					EditRow = False
				Else
					EditRow = True
				End If
				If EditRow Then
				End If
			Else
				Rs.CancelUpdate

				' Set up error message
				If SuccessMessage <> "" Or FailureMessage <> "" Then

					' Use the message, do nothing
				ElseIf webset.CancelMessage <> "" Then
					FailureMessage = webset.CancelMessage
					webset.CancelMessage = ""
				Else
					FailureMessage = Language.Phrase("UpdateCancelled")
				End If
				EditRow = False
			End If
		End If

		' Call Row Updated event
		If EditRow Then
			Call webset.Row_Updated(RsOld, RsNew)
		End If
		Rs.Close
		Set Rs = Nothing
		If IsObject(RsOld) Then
			RsOld.Close
			Set RsOld = Nothing
		End If
		If IsObject(RsNew) Then
			RsNew.Close
			Set RsNew = Nothing
		End If
	End Function

	' Set up Breadcrumb
	Sub SetupBreadcrumb()
		Dim PageId, url
		Set Breadcrumb = New cBreadcrumb
		Call Breadcrumb.Add("list", webset.TableVar, "websetlist.asp", webset.TableVar, True)
		PageId = "edit"
		Call Breadcrumb.Add("edit", PageId, ew_CurrentUrl, "", False)
	End Sub

	' Page Load event
	Sub Page_Load()

		'Response.Write "Page Load"
	End Sub

	' Page Unload event
	Sub Page_Unload()

		'Response.Write "Page Unload"
	End Sub

	' Page Redirecting event
	Sub Page_Redirecting(url)

		'url = newurl
	End Sub

	' Message Showing event
	' typ = ""|"success"|"failure"|"warning"
	Sub Message_Showing(msg, typ)

		' Example:
		'If typ = "success" Then
		'	msg = "your success message"
		'ElseIf typ = "failure" Then
		'	msg = "your failure message"
		'ElseIf typ = "warning" Then
		'	msg = "your warning message"
		'Else
		'	msg = "your message"
		'End If

	End Sub

	' Page Render event
	Sub Page_Render()

		'Response.Write "Page Render"
	End Sub

	' Page Data Rendering event
	Sub Page_DataRendering(header)

		' Example:
		'header = "your header"

	End Sub

	' Page Data Rendered event
	Sub Page_DataRendered(footer)

		' Example:
		'footer = "your footer"

	End Sub

	' Form Custom Validate event
	Function Form_CustomValidate(CustomError)

		'Return error message in CustomError
		Form_CustomValidate = True
	End Function
End Class
%>
