<%
Response.Buffer = EW_RESPONSE_BUFFER
%>
<!--#include file="ewcfg11.asp"-->
<!--#include file="xwfbinfo.asp"-->
<!--#include file="bhlminfo.asp"-->
<!--#include file="xwlminfo.asp"-->
<!--#include file="zlogininfo.asp"-->
<!--#include file="sjlminfo.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 xwfb_update
Set xwfb_update = New cxwfb_update
Set Page = xwfb_update

' Page init processing
xwfb_update.Page_Init()

' Page main processing
xwfb_update.Page_Main()

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

' Page Rendering event
xwfb_update.Page_Render()
%>
<!--#include file="header.asp"-->
<script type="text/javascript">
// Page object
var xwfb_update = new ew_Page("xwfb_update");
xwfb_update.PageID = "update"; // Page ID
var EW_PAGE_ID = xwfb_update.PageID; // For backward compatibility
// Form object
var fxwfbupdate = new ew_Form("fxwfbupdate");
// Validate form
fxwfbupdate.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;
	if (!ew_UpdateSelected(fobj)) {
		alert(ewLanguage.Phrase("NoFieldSelected"));
		return false;
	}
	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);
			elm = this.GetElements("x" + infix + "_bh");
			uelm = this.GetElements("u" + infix + "_bh");
			if (uelm && uelm.checked) {
				if (elm && !ew_HasValue(elm))
					return this.OnError(elm, ewLanguage.Phrase("EnterRequiredField") + " - <%= ew_JsEncode2(xwfb.bh.FldCaption) %>");
			}
			elm = this.GetElements("x" + infix + "_xwbt");
			uelm = this.GetElements("u" + infix + "_xwbt");
			if (uelm && uelm.checked) {
				if (elm && !ew_HasValue(elm))
					return this.OnError(elm, ewLanguage.Phrase("EnterRequiredField") + " - <%= ew_JsEncode2(xwfb.xwbt.FldCaption) %>");
			}
			elm = this.GetElements("x" + infix + "_fbsj");
			uelm = this.GetElements("u" + infix + "_fbsj");
			if (uelm && uelm.checked) {
				if (elm && !ew_HasValue(elm))
					return this.OnError(elm, ewLanguage.Phrase("EnterRequiredField") + " - <%= ew_JsEncode2(xwfb.fbsj.FldCaption) %>");
			}
			elm = this.GetElements("x" + infix + "_fbsj");
			uelm = this.GetElements("u" + infix + "_fbsj");
			if (uelm && uelm.checked && elm && !ew_CheckDate(elm.value))
					return this.OnError(elm, "<%= ew_JsEncode2(xwfb.fbsj.FldErrMsg) %>");
			elm = this.GetElements("x" + infix + "_content");
			uelm = this.GetElements("u" + infix + "_content");
			if (uelm && uelm.checked) {
				if (elm && !ew_HasValue(elm))
					return this.OnError(elm, ewLanguage.Phrase("EnterRequiredField") + " - <%= ew_JsEncode2(xwfb.content.FldCaption) %>");
			}
			elm = this.GetElements("x" + infix + "_px");
			uelm = this.GetElements("u" + infix + "_px");
			if (uelm && uelm.checked && elm && !ew_CheckInteger(elm.value))
					return this.OnError(elm, "<%= ew_JsEncode2(xwfb.px.FldErrMsg) %>");
			elm = this.GetElements("x" + infix + "_hits");
			uelm = this.GetElements("u" + infix + "_hits");
			if (uelm && uelm.checked && elm && !ew_CheckInteger(elm.value))
					return this.OnError(elm, "<%= ew_JsEncode2(xwfb.hits.FldErrMsg) %>");
			// Set up row object
			ew_ElementsToRow(fobj);
			// Fire Form_CustomValidate event
			if (!this.Form_CustomValidate(fobj))
				return false;
	}
	return true;
}
// Form_CustomValidate event
fxwfbupdate.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 %>
fxwfbupdate.ValidateRequired = true; // Use JavaScript validation
<% Else %>
fxwfbupdate.ValidateRequired = false; // No JavaScript validation
<% End If %>
// Dynamic selection lists
fxwfbupdate.Lists["x_bh"] = {"LinkField":"x_bh","Ajax":null,"AutoFill":false,"DisplayFields":["x_bhmc","","",""],"ParentFields":[],"FilterFields":[],"Options":[]};
fxwfbupdate.Lists["x_lmid"] = {"LinkField":"x_lmid","Ajax":null,"AutoFill":false,"DisplayFields":["x_lmmc","","",""],"ParentFields":["x_bh"],"FilterFields":["x_bh"],"Options":[]};
fxwfbupdate.Lists["x_sj"] = {"LinkField":"x_id","Ajax":null,"AutoFill":false,"DisplayFields":["x_sjmc","","",""],"ParentFields":["x_lmid"],"FilterFields":["x_lmid"],"Options":[]};
// Form object for search
</script>
<script type="text/javascript">
// Write your client script here, no need to add script tags.
</script>
<% If xwfb.Export = "" Then %>
<% Breadcrumb.Render() %>
<% End If %>
<% xwfb_update.ShowPageHeader() %>
<% xwfb_update.ShowMessage %>
<form name="fxwfbupdate" id="fxwfbupdate" class="ewForm form-inline" action="<%= ew_CurrentPage %>" method="post">
<input type="hidden" name="t" value="xwfb">
<input type="hidden" name="a_update" id="a_update" value="U">
<% For i = 0 to UBound(xwfb_update.RecKeys) %>
<input type="hidden" name="key_m" id="key_m" value="<%= ew_HtmlEncode(ew_GetKeyValue(xwfb_update.RecKeys(i))) %>">
<% Next %>
<table class="ewGrid"><tr><td>
<table id="tbl_xwfbupdate" class="table table-bordered table-striped">
<thead>
	<tr>
		<th><label class="checkbox"><strong><%= Language.Phrase("UpdateValue") %></strong><input type="checkbox" name="u" id="u" onclick="ew_SelectAll(this);"></label></th>
		<th><%= Language.Phrase("FieldName") %></th>
		<th><%= Language.Phrase("NewValue") %></th>
	</tr>
</thead>
<tbody>
<% If xwfb.bh.Visible Then ' bh %>
	<tr id="r_bh">
		<td class="ewCheckbox"<%= xwfb.bh.CellAttributes %>>
<label class="checkbox"><input type="checkbox" name="u_bh" id="u_bh" value="1"<% If xwfb.bh.MultiUpdate = "1" Then Response.Write " checked=""checked""" %>></label>
</td>
		<td<%= xwfb.bh.CellAttributes %>><span id="elh_xwfb_bh"><%= xwfb.bh.FldCaption %></span></td>
		<td<%= xwfb.bh.CellAttributes %>>
<% If xwfb.bh.SessionValue <> "" Then %>
<span<%= xwfb.bh.ViewAttributes %>>
<%= xwfb.bh.ViewValue %>
</span>
<input type="hidden" id="x_bh" name="x_bh" value="<%= ew_HtmlEncode(xwfb.bh.CurrentValue) %>">
<% Else %>
<% xwfb.bh.EditAttrs.UpdateAttribute "onchange", "ew_UpdateOpt.call(this, ['x_lmid']);" %>
<select data-field="x_bh" id="x_bh" name="x_bh"<%= xwfb.bh.EditAttributes %>>
<%
emptywrk = True
If IsArray(xwfb.bh.EditValue) Then
	arwrk = xwfb.bh.EditValue
	For rowcntwrk = 0 To UBound(arwrk, 2)
		If arwrk(0, rowcntwrk)&"" = xwfb.bh.CurrentValue&"" Then
			selwrk = " selected=""selected"""
			emptywrk = False
		Else
			selwrk = ""
		End If
%>
<option value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %>>
<%= arwrk(1, rowcntwrk) %>
</option>
<%
	Next
End If
%>
</select>
<script type="text/javascript">
fxwfbupdate.Lists["x_bh"].Options = <%= ew_IIf(IsArray(xwfb.bh.EditValue), ew_ArrayToJson(xwfb.bh.EditValue, 1), "[]") %>;
</script>
<% End If %>
<%= xwfb.bh.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.lmid.Visible Then ' lmid %>
	<tr id="r_lmid">
		<td class="ewCheckbox"<%= xwfb.lmid.CellAttributes %>>
<label class="checkbox"><input type="checkbox" name="u_lmid" id="u_lmid" value="1"<% If xwfb.lmid.MultiUpdate = "1" Then Response.Write " checked=""checked""" %>></label>
</td>
		<td<%= xwfb.lmid.CellAttributes %>><span id="elh_xwfb_lmid"><%= xwfb.lmid.FldCaption %></span></td>
		<td<%= xwfb.lmid.CellAttributes %>>
<% If xwfb.lmid.SessionValue <> "" Then %>
<span<%= xwfb.lmid.ViewAttributes %>>
<%= xwfb.lmid.ViewValue %>
</span>
<input type="hidden" id="x_lmid" name="x_lmid" value="<%= ew_HtmlEncode(xwfb.lmid.CurrentValue) %>">
<% Else %>
<% xwfb.lmid.EditAttrs.UpdateAttribute "onchange", "ew_UpdateOpt.call(this, ['x_sj']);" %>
<select data-field="x_lmid" id="x_lmid" name="x_lmid"<%= xwfb.lmid.EditAttributes %>>
<%
emptywrk = True
If IsArray(xwfb.lmid.EditValue) Then
	arwrk = xwfb.lmid.EditValue
	For rowcntwrk = 0 To UBound(arwrk, 2)
		If arwrk(0, rowcntwrk)&"" = xwfb.lmid.CurrentValue&"" Then
			selwrk = " selected=""selected"""
			emptywrk = False
		Else
			selwrk = ""
		End If
%>
<option value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %>>
<%= arwrk(1, rowcntwrk) %>
</option>
<%
	Next
End If
%>
</select>
<script type="text/javascript">
fxwfbupdate.Lists["x_lmid"].Options = <%= ew_IIf(IsArray(xwfb.lmid.EditValue), ew_ArrayToJson(xwfb.lmid.EditValue, 1), "[]") %>;
</script>
<% End If %>
<%= xwfb.lmid.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.sj.Visible Then ' sj %>
	<tr id="r_sj">
		<td class="ewCheckbox"<%= xwfb.sj.CellAttributes %>>
<label class="checkbox"><input type="checkbox" name="u_sj" id="u_sj" value="1"<% If xwfb.sj.MultiUpdate = "1" Then Response.Write " checked=""checked""" %>></label>
</td>
		<td<%= xwfb.sj.CellAttributes %>><span id="elh_xwfb_sj"><%= xwfb.sj.FldCaption %></span></td>
		<td<%= xwfb.sj.CellAttributes %>>
<% If xwfb.sj.SessionValue <> "" Then %>
<span<%= xwfb.sj.ViewAttributes %>>
<%= xwfb.sj.ViewValue %>
</span>
<input type="hidden" id="x_sj" name="x_sj" value="<%= ew_HtmlEncode(xwfb.sj.CurrentValue) %>">
<% Else %>
<select data-field="x_sj" id="x_sj" name="x_sj"<%= xwfb.sj.EditAttributes %>>
<%
emptywrk = True
If IsArray(xwfb.sj.EditValue) Then
	arwrk = xwfb.sj.EditValue
	For rowcntwrk = 0 To UBound(arwrk, 2)
		If arwrk(0, rowcntwrk)&"" = xwfb.sj.CurrentValue&"" Then
			selwrk = " selected=""selected"""
			emptywrk = False
		Else
			selwrk = ""
		End If
%>
<option value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %>>
<%= arwrk(1, rowcntwrk) %>
</option>
<%
	Next
End If
%>
</select>
<script type="text/javascript">
fxwfbupdate.Lists["x_sj"].Options = <%= ew_IIf(IsArray(xwfb.sj.EditValue), ew_ArrayToJson(xwfb.sj.EditValue, 1), "[]") %>;
</script>
<% End If %>
<%= xwfb.sj.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.xwbt.Visible Then ' xwbt %>
	<tr id="r_xwbt">
		<td class="ewCheckbox"<%= xwfb.xwbt.CellAttributes %>>
<label class="checkbox"><input type="checkbox" name="u_xwbt" id="u_xwbt" value="1"<% If xwfb.xwbt.MultiUpdate = "1" Then Response.Write " checked=""checked""" %>></label>
</td>
		<td<%= xwfb.xwbt.CellAttributes %>><span id="elh_xwfb_xwbt"><%= xwfb.xwbt.FldCaption %></span></td>
		<td<%= xwfb.xwbt.CellAttributes %>>
<span id="el_xwfb_xwbt" class="control-group">
<input type="text" data-field="x_xwbt" name="x_xwbt" id="x_xwbt" size="30" maxlength="50" placeholder="<%= xwfb.xwbt.PlaceHolder %>" value="<%= xwfb.xwbt.EditValue %>"<%= xwfb.xwbt.EditAttributes %>>
</span>
<%= xwfb.xwbt.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.fbsj.Visible Then ' fbsj %>
	<tr id="r_fbsj">
		<td class="ewCheckbox"<%= xwfb.fbsj.CellAttributes %>>
<label class="checkbox"><input type="checkbox" name="u_fbsj" id="u_fbsj" value="1"<% If xwfb.fbsj.MultiUpdate = "1" Then Response.Write " checked=""checked""" %>></label>
</td>
		<td<%= xwfb.fbsj.CellAttributes %>><span id="elh_xwfb_fbsj"><%= xwfb.fbsj.FldCaption %></span></td>
		<td<%= xwfb.fbsj.CellAttributes %>>
<span id="el_xwfb_fbsj" class="control-group">
<input type="text" data-field="x_fbsj" name="x_fbsj" id="x_fbsj" placeholder="<%= xwfb.fbsj.PlaceHolder %>" value="<%= xwfb.fbsj.EditValue %>"<%= xwfb.fbsj.EditAttributes %>>
<% If Not xwfb.fbsj.ReadOnly And Not xwfb.fbsj.Disabled And xwfb.fbsj.EditAttrs.Item("readonly") = "" And xwfb.fbsj.EditAttrs.Item("disabled") = "" Then %>
<button id="cal_x_fbsj" name="cal_x_fbsj" class="btn" type="button"><img src="images/calendar.png" alt="<%= Language.Phrase("PickDate") %>" title="<%= Language.Phrase("PickDate") %>" style="border: 0;"></button><script type="text/javascript">
ew_CreateCalendar("fxwfbupdate", "x_fbsj", "%Y-%m-%d");
</script>
<% End If %>
</span>
<%= xwfb.fbsj.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.pic.Visible Then ' pic %>
	<tr id="r_pic">
		<td class="ewCheckbox"<%= xwfb.pic.CellAttributes %>>
<label class="checkbox"><input type="checkbox" name="u_pic" id="u_pic" value="1"<% If xwfb.pic.MultiUpdate = "1" Then Response.Write " checked=""checked""" %>></label>
</td>
		<td<%= xwfb.pic.CellAttributes %>><span id="elh_xwfb_pic"><%= xwfb.pic.FldCaption %></span></td>
		<td<%= xwfb.pic.CellAttributes %>>
<span id="el_xwfb_pic" class="control-group">
<textarea data-field="x_pic" class="editor" name="x_pic" id="x_pic" cols="45" rows="6" placeholder="<%= xwfb.pic.PlaceHolder %>"<%= xwfb.pic.EditAttributes %>><%= xwfb.pic.EditValue %></textarea><script type="text/javascript">
ew_CreateEditor("fxwfbupdate", "x_pic", 45, 6, <%= ew_IIf(xwfb.pic.ReadOnly Or False, "true", "false") %>);
</script>
</span>
<%= xwfb.pic.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.content.Visible Then ' content %>
	<tr id="r_content">
		<td class="ewCheckbox"<%= xwfb.content.CellAttributes %>>
<label class="checkbox"><input type="checkbox" name="u_content" id="u_content" value="1"<% If xwfb.content.MultiUpdate = "1" Then Response.Write " checked=""checked""" %>></label>
</td>
		<td<%= xwfb.content.CellAttributes %>><span id="elh_xwfb_content"><%= xwfb.content.FldCaption %></span></td>
		<td<%= xwfb.content.CellAttributes %>>
<span id="el_xwfb_content" class="control-group">
<textarea data-field="x_content" class="editor" name="x_content" id="x_content" cols="45" rows="5" placeholder="<%= xwfb.content.PlaceHolder %>"<%= xwfb.content.EditAttributes %>><%= xwfb.content.EditValue %></textarea><script type="text/javascript">
ew_CreateEditor("fxwfbupdate", "x_content", 45, 5, <%= ew_IIf(xwfb.content.ReadOnly Or False, "true", "false") %>);
</script>
</span>
<%= xwfb.content.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.ishome.Visible Then ' ishome %>
	<tr id="r_ishome">
		<td class="ewCheckbox"<%= xwfb.ishome.CellAttributes %>>
<label class="checkbox"><input type="checkbox" name="u_ishome" id="u_ishome" value="1"<% If xwfb.ishome.MultiUpdate = "1" Then Response.Write " checked=""checked""" %>></label>
</td>
		<td<%= xwfb.ishome.CellAttributes %>><span id="elh_xwfb_ishome"><%= xwfb.ishome.FldCaption %></span></td>
		<td<%= xwfb.ishome.CellAttributes %>>
<span id="el_xwfb_ishome" class="control-group">
<div id="tp_x_ishome" class="<%= EW_ITEM_TEMPLATE_CLASSNAME %>"><input type="radio" name="x_ishome" id="x_ishome" value="{value}"<%= xwfb.ishome.EditAttributes %>></div>
<div id="dsl_x_ishome" data-repeatcolumn="5" class="ewItemList">
<%
emptywrk = True
arwrk = xwfb.ishome.EditValue
If IsArray(arwrk) Then
	rowswrk = UBound(arwrk, 2)	
	For rowcntwrk = 0 To rowswrk
		If xwfb.ishome.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_ishome" name="x_ishome" id="x_ishome_<%= rowcntwrk %>" value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %><%= xwfb.ishome.EditAttributes %>><%= arwrk(1, rowcntwrk) %></label>
<%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 5, 2) %>
<%
	Next
End If
%>
</div>
</span>
<%= xwfb.ishome.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.px.Visible Then ' px %>
	<tr id="r_px">
		<td class="ewCheckbox"<%= xwfb.px.CellAttributes %>>
<label class="checkbox"><input type="checkbox" name="u_px" id="u_px" value="1"<% If xwfb.px.MultiUpdate = "1" Then Response.Write " checked=""checked""" %>></label>
</td>
		<td<%= xwfb.px.CellAttributes %>><span id="elh_xwfb_px"><%= xwfb.px.FldCaption %></span></td>
		<td<%= xwfb.px.CellAttributes %>>
<span id="el_xwfb_px" class="control-group">
<input type="text" data-field="x_px" name="x_px" id="x_px" size="30" placeholder="<%= xwfb.px.PlaceHolder %>" value="<%= xwfb.px.EditValue %>"<%= xwfb.px.EditAttributes %>>
</span>
<%= xwfb.px.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.hits.Visible Then ' hits %>
	<tr id="r_hits">
		<td class="ewCheckbox"<%= xwfb.hits.CellAttributes %>>
<label class="checkbox"><input type="checkbox" name="u_hits" id="u_hits" value="1"<% If xwfb.hits.MultiUpdate = "1" Then Response.Write " checked=""checked""" %>></label>
</td>
		<td<%= xwfb.hits.CellAttributes %>><span id="elh_xwfb_hits"><%= xwfb.hits.FldCaption %></span></td>
		<td<%= xwfb.hits.CellAttributes %>>
<span id="el_xwfb_hits" class="control-group">
<input type="text" data-field="x_hits" name="x_hits" id="x_hits" size="30" placeholder="<%= xwfb.hits.PlaceHolder %>" value="<%= xwfb.hits.EditValue %>"<%= xwfb.hits.EditAttributes %>>
</span>
<%= xwfb.hits.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.newkey.Visible Then ' newkey %>
	<tr id="r_newkey">
		<td class="ewCheckbox"<%= xwfb.newkey.CellAttributes %>>
<label class="checkbox"><input type="checkbox" name="u_newkey" id="u_newkey" value="1"<% If xwfb.newkey.MultiUpdate = "1" Then Response.Write " checked=""checked""" %>></label>
</td>
		<td<%= xwfb.newkey.CellAttributes %>><span id="elh_xwfb_newkey"><%= xwfb.newkey.FldCaption %></span></td>
		<td<%= xwfb.newkey.CellAttributes %>>
<span id="el_xwfb_newkey" class="control-group">
<input type="text" data-field="x_newkey" name="x_newkey" id="x_newkey" size="30" maxlength="255" placeholder="<%= xwfb.newkey.PlaceHolder %>" value="<%= xwfb.newkey.EditValue %>"<%= xwfb.newkey.EditAttributes %>>
</span>
<%= xwfb.newkey.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.newtitle.Visible Then ' newtitle %>
	<tr id="r_newtitle">
		<td class="ewCheckbox"<%= xwfb.newtitle.CellAttributes %>>
<label class="checkbox"><input type="checkbox" name="u_newtitle" id="u_newtitle" value="1"<% If xwfb.newtitle.MultiUpdate = "1" Then Response.Write " checked=""checked""" %>></label>
</td>
		<td<%= xwfb.newtitle.CellAttributes %>><span id="elh_xwfb_newtitle"><%= xwfb.newtitle.FldCaption %></span></td>
		<td<%= xwfb.newtitle.CellAttributes %>>
<span id="el_xwfb_newtitle" class="control-group">
<textarea data-field="x_newtitle" name="x_newtitle" id="x_newtitle" cols="35" rows="4" placeholder="<%= xwfb.newtitle.PlaceHolder %>"<%= xwfb.newtitle.EditAttributes %>><%= xwfb.newtitle.EditValue %></textarea>
</span>
<%= xwfb.newtitle.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.newms.Visible Then ' newms %>
	<tr id="r_newms">
		<td class="ewCheckbox"<%= xwfb.newms.CellAttributes %>>
<label class="checkbox"><input type="checkbox" name="u_newms" id="u_newms" value="1"<% If xwfb.newms.MultiUpdate = "1" Then Response.Write " checked=""checked""" %>></label>
</td>
		<td<%= xwfb.newms.CellAttributes %>><span id="elh_xwfb_newms"><%= xwfb.newms.FldCaption %></span></td>
		<td<%= xwfb.newms.CellAttributes %>>
<span id="el_xwfb_newms" class="control-group">
<textarea data-field="x_newms" name="x_newms" id="x_newms" cols="35" rows="4" placeholder="<%= xwfb.newms.PlaceHolder %>"<%= xwfb.newms.EditAttributes %>><%= xwfb.newms.EditValue %></textarea>
</span>
<%= xwfb.newms.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwfb.tags.Visible Then ' tags %>
	<tr id="r_tags">
		<td class="ewCheckbox"<%= xwfb.tags.CellAttributes %>>
<label class="checkbox"><input type="checkbox" name="u_tags" id="u_tags" value="1"<% If xwfb.tags.MultiUpdate = "1" Then Response.Write " checked=""checked""" %>></label>
</td>
		<td<%= xwfb.tags.CellAttributes %>><span id="elh_xwfb_tags"><%= xwfb.tags.FldCaption %></span></td>
		<td<%= xwfb.tags.CellAttributes %>>
<span id="el_xwfb_tags" class="control-group">
<input type="text" data-field="x_tags" name="x_tags" id="x_tags" size="30" maxlength="255" placeholder="<%= xwfb.tags.PlaceHolder %>" value="<%= xwfb.tags.EditValue %>"<%= xwfb.tags.EditAttributes %>>
</span>
<%= xwfb.tags.CustomMsg %></td>
	</tr>
<% End If %>
</tbody>
</table>
</td></tr></table>
<button class="btn btn-primary ewButton" name="btnAction" id="btnAction" type="submit"><%= Language.Phrase("UpdateBtn") %></button>
</form>
<script type="text/javascript">
fxwfbupdate.Init();
<% If EW_MOBILE_REFLOW And ew_IsMobile() Then %>
ew_Reflow();
<% End If %>
</script>
<%
xwfb_update.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 xwfb_update = Nothing
%>
<%

' -----------------------------------------------------------------
' Page Class
'
Class cxwfb_update

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

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

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

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

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

	' Page Url
	Public Property Get PageUrl()
		PageUrl = ew_CurrentPage() & "?"
		If xwfb.UseTokenInUrl Then PageUrl = PageUrl & "t=" & xwfb.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 xwfb.UseTokenInUrl Then
			IsPageRequest = False
			If Not (ObjForm Is Nothing) Then
				IsPageRequest = (xwfb.TableVar = ObjForm.GetValue("t"))
			End If
			If Request.QueryString("t").Count > 0 Then
				IsPageRequest = (xwfb.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(xwfb) Then Set xwfb = New cxwfb
		Set Table = xwfb

		' Initialize urls
		' Initialize other table object

		If IsEmpty(bhlm) Then Set bhlm = New cbhlm

		' Initialize other table object
		If IsEmpty(xwlm) Then Set xwlm = New cxwlm

		' Initialize other table object
		If IsEmpty(zlogin) Then Set zlogin = New czlogin

		' Initialize other table object
		If IsEmpty(sjlm) Then Set sjlm = New csjlm

		' Initialize form object
		Set ObjForm = Nothing

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

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

		' 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("xwfblist.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

		xwfb.CurrentAction = ew_IIf(Request.QueryString("a").Count > 0, Request.QueryString("a") & "", ObjForm.GetValue("a_list") & "") ' Set up current action

		' 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 xwfb = 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 RecKeys
	Dim Disabled
	Dim Recordset
	Dim UpdateCount

	' -----------------------------------------------------------------
	' Page main processing
	'
	Sub Page_Main()
		Dim sKeyName
		Dim sKey
		Dim nKeySelected
		Dim bUpdateSelected
		UpdateCount = 0

		' Set up Breadcrumb
		SetupBreadcrumb()
		RecKeys = xwfb.GetRecordKeys() ' Load record keys
		If ObjForm.GetValue("a_update")&"" <> "" Then

			' Get action
			xwfb.CurrentAction = ObjForm.GetValue("a_update")
			Call LoadFormValues() ' Get form values

			' Validate form
			If Not ValidateForm() Then
				xwfb.CurrentAction = "I" ' Form error, reset action
				FailureMessage = gsFormError
			End If
		Else
			Call LoadMultiUpdateValues() ' Load initial values to form
		End If
		If Not IsArray(RecKeys) Then
			Call Page_Terminate("xwfblist.asp") ' No records selected, return to list
		End If
		Select Case xwfb.CurrentAction
			Case "U" ' Update
				If UpdateRows() Then ' Update Records based on key
					SuccessMessage = Language.Phrase("UpdateSuccess") ' Set update success message
					Call Page_Terminate(xwfb.ReturnUrl) ' Return to caller
				Else
					Call RestoreFormValues() ' Restore form values
				End If
		End Select

		' Render row
		xwfb.RowType = EW_ROWTYPE_EDIT ' Render edit

		' Render row
		Call xwfb.ResetAttrs()
		Call RenderRow()
	End Sub

	' -----------------------------------------------------------------
	' Load initial values to form if field values are identical in all selected records
	'
	Sub LoadMultiUpdateValues()
		If Not EW_DEBUG_ENABLED Then On Error Resume Next
		Dim Rs, i, OldValue, NewValue
		xwfb.CurrentFilter = xwfb.GetKeyFilter()

		' Load recordset
		Set Rs = LoadRecordset()
		i = 1
		Do While Not Rs.Eof
			If i = 1 Then
				xwfb.bh.DbValue = ew_Conv(Rs("bh"), Rs("bh").Type)
				xwfb.lmid.DbValue = ew_Conv(Rs("lmid"), Rs("lmid").Type)
				xwfb.sj.DbValue = ew_Conv(Rs("sj"), Rs("sj").Type)
				xwfb.xwbt.DbValue = ew_Conv(Rs("xwbt"), Rs("xwbt").Type)
				xwfb.fbsj.DbValue = ew_Conv(Rs("fbsj"), Rs("fbsj").Type)
				xwfb.pic.DbValue = ew_Conv(Rs("pic"), Rs("pic").Type)
				xwfb.content.DbValue = ew_Conv(Rs("content"), Rs("content").Type)
				xwfb.ishome.DbValue = ew_Conv(Rs("ishome"), Rs("ishome").Type)
				xwfb.px.DbValue = ew_Conv(Rs("px"), Rs("px").Type)
				xwfb.hits.DbValue = ew_Conv(Rs("hits"), Rs("hits").Type)
				xwfb.newkey.DbValue = ew_Conv(Rs("newkey"), Rs("newkey").Type)
				xwfb.newtitle.DbValue = ew_Conv(Rs("newtitle"), Rs("newtitle").Type)
				xwfb.newms.DbValue = ew_Conv(Rs("newms"), Rs("newms").Type)
				xwfb.tags.DbValue = ew_Conv(Rs("tags"), Rs("tags").Type)
			Else
				OldValue = xwfb.bh.DbValue
				NewValue = ew_Conv(Rs("bh"), Rs("bh").Type)
				If Not ew_CompareValue(OldValue, NewValue) Then
					xwfb.bh.CurrentValue = Null
				End If
				OldValue = xwfb.lmid.DbValue
				NewValue = ew_Conv(Rs("lmid"), Rs("lmid").Type)
				If Not ew_CompareValue(OldValue, NewValue) Then
					xwfb.lmid.CurrentValue = Null
				End If
				OldValue = xwfb.sj.DbValue
				NewValue = ew_Conv(Rs("sj"), Rs("sj").Type)
				If Not ew_CompareValue(OldValue, NewValue) Then
					xwfb.sj.CurrentValue = Null
				End If
				OldValue = xwfb.xwbt.DbValue
				NewValue = ew_Conv(Rs("xwbt"), Rs("xwbt").Type)
				If Not ew_CompareValue(OldValue, NewValue) Then
					xwfb.xwbt.CurrentValue = Null
				End If
				OldValue = xwfb.fbsj.DbValue
				NewValue = ew_Conv(Rs("fbsj"), Rs("fbsj").Type)
				If Not ew_CompareValue(OldValue, NewValue) Then
					xwfb.fbsj.CurrentValue = Null
				End If
				OldValue = xwfb.pic.DbValue
				NewValue = ew_Conv(Rs("pic"), Rs("pic").Type)
				If Not ew_CompareValue(OldValue, NewValue) Then
					xwfb.pic.CurrentValue = Null
				End If
				OldValue = xwfb.content.DbValue
				NewValue = ew_Conv(Rs("content"), Rs("content").Type)
				If Not ew_CompareValue(OldValue, NewValue) Then
					xwfb.content.CurrentValue = Null
				End If
				OldValue = xwfb.ishome.DbValue
				NewValue = ew_Conv(Rs("ishome"), Rs("ishome").Type)
				If Not ew_CompareValue(OldValue, NewValue) Then
					xwfb.ishome.CurrentValue = Null
				End If
				OldValue = xwfb.px.DbValue
				NewValue = ew_Conv(Rs("px"), Rs("px").Type)
				If Not ew_CompareValue(OldValue, NewValue) Then
					xwfb.px.CurrentValue = Null
				End If
				OldValue = xwfb.hits.DbValue
				NewValue = ew_Conv(Rs("hits"), Rs("hits").Type)
				If Not ew_CompareValue(OldValue, NewValue) Then
					xwfb.hits.CurrentValue = Null
				End If
				OldValue = xwfb.newkey.DbValue
				NewValue = ew_Conv(Rs("newkey"), Rs("newkey").Type)
				If Not ew_CompareValue(OldValue, NewValue) Then
					xwfb.newkey.CurrentValue = Null
				End If
				OldValue = xwfb.newtitle.DbValue
				NewValue = ew_Conv(Rs("newtitle"), Rs("newtitle").Type)
				If Not ew_CompareValue(OldValue, NewValue) Then
					xwfb.newtitle.CurrentValue = Null
				End If
				OldValue = xwfb.newms.DbValue
				NewValue = ew_Conv(Rs("newms"), Rs("newms").Type)
				If Not ew_CompareValue(OldValue, NewValue) Then
					xwfb.newms.CurrentValue = Null
				End If
				OldValue = xwfb.tags.DbValue
				NewValue = ew_Conv(Rs("tags"), Rs("tags").Type)
				If Not ew_CompareValue(OldValue, NewValue) Then
					xwfb.tags.CurrentValue = Null
				End If
			End If
			i = i + 1
			Rs.MoveNext
		Loop
		Rs.Close
		Set Rs = Nothing
	End Sub

	' -----------------------------------------------------------------
	'  Set up key value
	'
	Function SetupKeyValues(key)
		Dim sKeyFld
		Dim sWrkFilter, sFilter
		sKeyFld = key
		If Not IsNumeric(sKeyFld) Then
			SetupKeyValues = False
			Exit Function
		End If
		xwfb.id.CurrentValue = sKeyFld ' Set up key value
		SetupKeyValues = True
	End Function

	' -----------------------------------------------------------------
	' Update all selected rows
	'
	Function UpdateRows()
		If Not EW_DEBUG_ENABLED Then On Error Resume Next
		Dim sKey, sThisKey
		Dim Rs, RsOld, RsNew, sSql, i
		Conn.BeginTrans

		' Get old recordset
		xwfb.CurrentFilter = xwfb.GetKeyFilter()
		sSql = xwfb.SQL
		Set Rs = Server.CreateObject("ADODB.Recordset")
		Rs.CursorLocation = EW_CURSORLOCATION
		Rs.Open sSql, Conn, 1, EW_RECORDSET_LOCKTYPE
		Set RsOld = ew_CloneRs(Rs)

		' Update all rows
		sKey = ""
		For i = 0 to UBound(RecKeys)
			If SetupKeyValues(RecKeys(i)) Then
				sThisKey = RecKeys(i)
				xwfb.SendEmail = False ' Do not send email on update success
				UpdateCount = UpdateCount + 1 ' Update record count for records being updated
				UpdateRows = EditRow() ' Update this row
			Else
				UpdateRows = False
			End If
			If Not UpdateRows Then Exit For ' Update failed
			If sKey <> "" Then sKey = sKey & ", "
			sKey = sKey & sThisKey
		Next
		If UpdateRows Then
			Conn.CommitTrans ' Commit transaction

			' Get new recordset
			Set Rs = Conn.Execute(sSql)
			Set RsNew = ew_CloneRs(Rs)
		Else
			Conn.RollbackTrans ' Rollback transaction
		End If
		Set Rs = Nothing
		Set RsOld = Nothing
		Set RsNew = Nothing
	End Function

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

		' Get upload data
	End Function

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

		' Load values from form
		If Not xwfb.bh.FldIsDetailKey Then xwfb.bh.FormValue = ObjForm.GetValue("x_bh")
		xwfb.bh.MultiUpdate = ObjForm.GetValue("u_bh")
		If Not xwfb.lmid.FldIsDetailKey Then xwfb.lmid.FormValue = ObjForm.GetValue("x_lmid")
		xwfb.lmid.MultiUpdate = ObjForm.GetValue("u_lmid")
		If Not xwfb.sj.FldIsDetailKey Then xwfb.sj.FormValue = ObjForm.GetValue("x_sj")
		xwfb.sj.MultiUpdate = ObjForm.GetValue("u_sj")
		If Not xwfb.xwbt.FldIsDetailKey Then xwfb.xwbt.FormValue = ObjForm.GetValue("x_xwbt")
		xwfb.xwbt.MultiUpdate = ObjForm.GetValue("u_xwbt")
		If Not xwfb.fbsj.FldIsDetailKey Then xwfb.fbsj.FormValue = ObjForm.GetValue("x_fbsj")
		If Not xwfb.fbsj.FldIsDetailKey Then xwfb.fbsj.CurrentValue = ew_UnFormatDateTime(xwfb.fbsj.CurrentValue, 5)
		xwfb.fbsj.MultiUpdate = ObjForm.GetValue("u_fbsj")
		If Not xwfb.pic.FldIsDetailKey Then xwfb.pic.FormValue = ObjForm.GetValue("x_pic")
		xwfb.pic.MultiUpdate = ObjForm.GetValue("u_pic")
		If Not xwfb.content.FldIsDetailKey Then xwfb.content.FormValue = ObjForm.GetValue("x_content")
		xwfb.content.MultiUpdate = ObjForm.GetValue("u_content")
		If Not xwfb.ishome.FldIsDetailKey Then xwfb.ishome.FormValue = ObjForm.GetValue("x_ishome")
		xwfb.ishome.MultiUpdate = ObjForm.GetValue("u_ishome")
		If Not xwfb.px.FldIsDetailKey Then xwfb.px.FormValue = ObjForm.GetValue("x_px")
		xwfb.px.MultiUpdate = ObjForm.GetValue("u_px")
		If Not xwfb.hits.FldIsDetailKey Then xwfb.hits.FormValue = ObjForm.GetValue("x_hits")
		xwfb.hits.MultiUpdate = ObjForm.GetValue("u_hits")
		If Not xwfb.newkey.FldIsDetailKey Then xwfb.newkey.FormValue = ObjForm.GetValue("x_newkey")
		xwfb.newkey.MultiUpdate = ObjForm.GetValue("u_newkey")
		If Not xwfb.newtitle.FldIsDetailKey Then xwfb.newtitle.FormValue = ObjForm.GetValue("x_newtitle")
		xwfb.newtitle.MultiUpdate = ObjForm.GetValue("u_newtitle")
		If Not xwfb.newms.FldIsDetailKey Then xwfb.newms.FormValue = ObjForm.GetValue("x_newms")
		xwfb.newms.MultiUpdate = ObjForm.GetValue("u_newms")
		If Not xwfb.tags.FldIsDetailKey Then xwfb.tags.FormValue = ObjForm.GetValue("x_tags")
		xwfb.tags.MultiUpdate = ObjForm.GetValue("u_tags")
		If Not xwfb.id.FldIsDetailKey Then xwfb.id.FormValue = ObjForm.GetValue("x_id")
	End Function

	' -----------------------------------------------------------------
	' Restore form values
	'
	Function RestoreFormValues()
		xwfb.bh.CurrentValue = xwfb.bh.FormValue
		xwfb.lmid.CurrentValue = xwfb.lmid.FormValue
		xwfb.sj.CurrentValue = xwfb.sj.FormValue
		xwfb.xwbt.CurrentValue = xwfb.xwbt.FormValue
		xwfb.fbsj.CurrentValue = xwfb.fbsj.FormValue
		xwfb.fbsj.CurrentValue = ew_UnFormatDateTime(xwfb.fbsj.CurrentValue, 5)
		xwfb.pic.CurrentValue = xwfb.pic.FormValue
		xwfb.content.CurrentValue = xwfb.content.FormValue
		xwfb.ishome.CurrentValue = xwfb.ishome.FormValue
		xwfb.px.CurrentValue = xwfb.px.FormValue
		xwfb.hits.CurrentValue = xwfb.hits.FormValue
		xwfb.newkey.CurrentValue = xwfb.newkey.FormValue
		xwfb.newtitle.CurrentValue = xwfb.newtitle.FormValue
		xwfb.newms.CurrentValue = xwfb.newms.FormValue
		xwfb.tags.CurrentValue = xwfb.tags.FormValue
		xwfb.id.CurrentValue = xwfb.id.FormValue
	End Function

	' -----------------------------------------------------------------
	' Load recordset
	'
	Function LoadRecordset()

		' Call Recordset Selecting event
		Dim sFilter
		sFilter = xwfb.CurrentFilter
		Call xwfb.Recordset_Selecting(sFilter)
		xwfb.CurrentFilter = sFilter

		' Load list page sql
		Dim sSql
		sSql = xwfb.ListSQL
		Call ew_SetDebugMsg("LoadRecordset: " & sSql) ' Show SQL for debugging

		' Load recordset
		Dim RsRecordset
		Set RsRecordset = ew_LoadRecordset(sSql)

		' Call Recordset Selected event
		Call xwfb.Recordset_Selected(RsRecordset)
		Set LoadRecordset = RsRecordset
	End Function

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

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

		' Load sql based on filter
		xwfb.CurrentFilter = sFilter
		sSql = xwfb.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 xwfb.Row_Selected(RsRow)
		xwfb.id.DbValue = RsRow("id")
		xwfb.bh.DbValue = RsRow("bh")
		xwfb.lmid.DbValue = RsRow("lmid")
		xwfb.sj.DbValue = RsRow("sj")
		xwfb.xwbt.DbValue = RsRow("xwbt")
		xwfb.fbsj.DbValue = RsRow("fbsj")
		xwfb.pic.DbValue = RsRow("pic")
		xwfb.content.DbValue = RsRow("content")
		xwfb.ishome.DbValue = RsRow("ishome")
		xwfb.px.DbValue = RsRow("px")
		xwfb.hits.DbValue = RsRow("hits")
		xwfb.newkey.DbValue = RsRow("newkey")
		xwfb.newtitle.DbValue = RsRow("newtitle")
		xwfb.newms.DbValue = RsRow("newms")
		xwfb.tags.DbValue = RsRow("tags")
	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
		xwfb.id.m_DbValue = Rs("id")
		xwfb.bh.m_DbValue = Rs("bh")
		xwfb.lmid.m_DbValue = Rs("lmid")
		xwfb.sj.m_DbValue = Rs("sj")
		xwfb.xwbt.m_DbValue = Rs("xwbt")
		xwfb.fbsj.m_DbValue = Rs("fbsj")
		xwfb.pic.m_DbValue = Rs("pic")
		xwfb.content.m_DbValue = Rs("content")
		xwfb.ishome.m_DbValue = Rs("ishome")
		xwfb.px.m_DbValue = Rs("px")
		xwfb.hits.m_DbValue = Rs("hits")
		xwfb.newkey.m_DbValue = Rs("newkey")
		xwfb.newtitle.m_DbValue = Rs("newtitle")
		xwfb.newms.m_DbValue = Rs("newms")
		xwfb.tags.m_DbValue = Rs("tags")
	End Sub

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

		' Initialize urls
		' Call Row Rendering event

		Call xwfb.Row_Rendering()

		' ---------------------------------------
		'  Common render codes for all row types
		' ---------------------------------------
		' id
		' bh
		' lmid
		' sj
		' xwbt
		' fbsj
		' pic
		' content
		' ishome
		' px
		' hits
		' newkey
		' newtitle
		' newms
		' tags
		' -----------
		'  View  Row
		' -----------

		If xwfb.RowType = EW_ROWTYPE_VIEW Then ' View row

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

			' bh
			If xwfb.bh.CurrentValue & "" <> "" Then
				sFilterWrk = "[bh]" & ew_SearchString("=", xwfb.bh.CurrentValue, EW_DATATYPE_NUMBER)
			sSqlWrk = "SELECT [bh], [bhmc] AS [DispFld], '' AS [Disp2Fld], '' AS [Disp3Fld], '' AS [Disp4Fld] FROM [bhlm]"
			sWhereWrk = ""
			Call ew_AddFilter(sWhereWrk, sFilterWrk)

			' Call Lookup selecting
			Call xwfb.Lookup_Selecting(xwfb.bh, sWhereWrk)
			If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
				Set RsWrk = Conn.Execute(sSqlWrk)
				If Not RsWrk.Eof Then
					xwfb.bh.ViewValue = RsWrk("DispFld")
				Else
					xwfb.bh.ViewValue = xwfb.bh.CurrentValue
				End If
				RsWrk.Close
				Set RsWrk = Nothing
			Else
				xwfb.bh.ViewValue = Null
			End If
			xwfb.bh.ViewCustomAttributes = ""

			' lmid
			If xwfb.lmid.CurrentValue & "" <> "" Then
				sFilterWrk = "[lmid]" & ew_SearchString("=", xwfb.lmid.CurrentValue, EW_DATATYPE_NUMBER)
			sSqlWrk = "SELECT [lmid], [lmmc] AS [DispFld], '' AS [Disp2Fld], '' AS [Disp3Fld], '' AS [Disp4Fld] FROM [xwlm]"
			sWhereWrk = ""
			Call ew_AddFilter(sWhereWrk, sFilterWrk)

			' Call Lookup selecting
			Call xwfb.Lookup_Selecting(xwfb.lmid, sWhereWrk)
			If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
				Set RsWrk = Conn.Execute(sSqlWrk)
				If Not RsWrk.Eof Then
					xwfb.lmid.ViewValue = RsWrk("DispFld")
				Else
					xwfb.lmid.ViewValue = xwfb.lmid.CurrentValue
				End If
				RsWrk.Close
				Set RsWrk = Nothing
			Else
				xwfb.lmid.ViewValue = Null
			End If
			xwfb.lmid.ViewCustomAttributes = ""

			' sj
			If xwfb.sj.CurrentValue & "" <> "" Then
				sFilterWrk = "[id]" & ew_SearchString("=", xwfb.sj.CurrentValue, EW_DATATYPE_NUMBER)
			sSqlWrk = "SELECT [id], [sjmc] AS [DispFld], '' AS [Disp2Fld], '' AS [Disp3Fld], '' AS [Disp4Fld] FROM [sjlm]"
			sWhereWrk = ""
			Call ew_AddFilter(sWhereWrk, sFilterWrk)

			' Call Lookup selecting
			Call xwfb.Lookup_Selecting(xwfb.sj, sWhereWrk)
			If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
				Set RsWrk = Conn.Execute(sSqlWrk)
				If Not RsWrk.Eof Then
					xwfb.sj.ViewValue = RsWrk("DispFld")
				Else
					xwfb.sj.ViewValue = xwfb.sj.CurrentValue
				End If
				RsWrk.Close
				Set RsWrk = Nothing
			Else
				xwfb.sj.ViewValue = Null
			End If
			xwfb.sj.ViewCustomAttributes = ""

			' xwbt
			xwfb.xwbt.ViewValue = xwfb.xwbt.CurrentValue
			xwfb.xwbt.ViewCustomAttributes = ""

			' fbsj
			xwfb.fbsj.ViewValue = xwfb.fbsj.CurrentValue
			xwfb.fbsj.ViewValue = ew_FormatDateTime(xwfb.fbsj.ViewValue, 5)
			xwfb.fbsj.ViewCustomAttributes = ""

			' pic
			xwfb.pic.ViewValue = xwfb.pic.CurrentValue
			xwfb.pic.ViewCustomAttributes = ""

			' content
			xwfb.content.ViewValue = xwfb.content.CurrentValue
			xwfb.content.ViewCustomAttributes = ""

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

			' px
			xwfb.px.ViewValue = xwfb.px.CurrentValue
			xwfb.px.ViewCustomAttributes = ""

			' hits
			xwfb.hits.ViewValue = xwfb.hits.CurrentValue
			xwfb.hits.ViewCustomAttributes = ""

			' newkey
			xwfb.newkey.ViewValue = xwfb.newkey.CurrentValue
			xwfb.newkey.ViewCustomAttributes = ""

			' newtitle
			xwfb.newtitle.ViewValue = xwfb.newtitle.CurrentValue
			xwfb.newtitle.ViewCustomAttributes = ""

			' newms
			xwfb.newms.ViewValue = xwfb.newms.CurrentValue
			xwfb.newms.ViewCustomAttributes = ""

			' tags
			xwfb.tags.ViewValue = xwfb.tags.CurrentValue
			xwfb.tags.ViewCustomAttributes = ""

			' View refer script
			' bh

			xwfb.bh.LinkCustomAttributes = ""
			xwfb.bh.HrefValue = ""
			xwfb.bh.TooltipValue = ""

			' lmid
			xwfb.lmid.LinkCustomAttributes = ""
			xwfb.lmid.HrefValue = ""
			xwfb.lmid.TooltipValue = ""

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

			' xwbt
			xwfb.xwbt.LinkCustomAttributes = ""
			xwfb.xwbt.HrefValue = ""
			xwfb.xwbt.TooltipValue = ""

			' fbsj
			xwfb.fbsj.LinkCustomAttributes = ""
			xwfb.fbsj.HrefValue = ""
			xwfb.fbsj.TooltipValue = ""

			' pic
			xwfb.pic.LinkCustomAttributes = ""
			xwfb.pic.HrefValue = ""
			xwfb.pic.TooltipValue = ""

			' content
			xwfb.content.LinkCustomAttributes = ""
			xwfb.content.HrefValue = ""
			xwfb.content.TooltipValue = ""

			' ishome
			xwfb.ishome.LinkCustomAttributes = ""
			xwfb.ishome.HrefValue = ""
			xwfb.ishome.TooltipValue = ""

			' px
			xwfb.px.LinkCustomAttributes = ""
			xwfb.px.HrefValue = ""
			xwfb.px.TooltipValue = ""

			' hits
			xwfb.hits.LinkCustomAttributes = ""
			xwfb.hits.HrefValue = ""
			xwfb.hits.TooltipValue = ""

			' newkey
			xwfb.newkey.LinkCustomAttributes = ""
			xwfb.newkey.HrefValue = ""
			xwfb.newkey.TooltipValue = ""

			' newtitle
			xwfb.newtitle.LinkCustomAttributes = ""
			xwfb.newtitle.HrefValue = ""
			xwfb.newtitle.TooltipValue = ""

			' newms
			xwfb.newms.LinkCustomAttributes = ""
			xwfb.newms.HrefValue = ""
			xwfb.newms.TooltipValue = ""

			' tags
			xwfb.tags.LinkCustomAttributes = ""
			xwfb.tags.HrefValue = ""
			xwfb.tags.TooltipValue = ""

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

		ElseIf xwfb.RowType = EW_ROWTYPE_EDIT Then ' Edit row

			' bh
			xwfb.bh.EditCustomAttributes = ""
			If xwfb.bh.SessionValue <> "" Then
				xwfb.bh.CurrentValue = xwfb.bh.SessionValue
			If xwfb.bh.CurrentValue & "" <> "" Then
				sFilterWrk = "[bh]" & ew_SearchString("=", xwfb.bh.CurrentValue, EW_DATATYPE_NUMBER)
			sSqlWrk = "SELECT [bh], [bhmc] AS [DispFld], '' AS [Disp2Fld], '' AS [Disp3Fld], '' AS [Disp4Fld] FROM [bhlm]"
			sWhereWrk = ""
			Call ew_AddFilter(sWhereWrk, sFilterWrk)

			' Call Lookup selecting
			Call xwfb.Lookup_Selecting(xwfb.bh, sWhereWrk)
			If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
				Set RsWrk = Conn.Execute(sSqlWrk)
				If Not RsWrk.Eof Then
					xwfb.bh.ViewValue = RsWrk("DispFld")
				Else
					xwfb.bh.ViewValue = xwfb.bh.CurrentValue
				End If
				RsWrk.Close
				Set RsWrk = Nothing
			Else
				xwfb.bh.ViewValue = Null
			End If
			xwfb.bh.ViewCustomAttributes = ""
			Else
			sFilterWrk = ""
			sSqlWrk = "SELECT [bh], [bhmc] AS [DispFld], '' AS [Disp2Fld], '' AS [Disp3Fld], '' AS [Disp4Fld], '' AS [SelectFilterFld], '' AS [SelectFilterFld2], '' AS [SelectFilterFld3], '' AS [SelectFilterFld4] FROM [bhlm]"
			sWhereWrk = ""
			Call ew_AddFilter(sWhereWrk, sFilterWrk)

			' Call Lookup selecting
			Call xwfb.Lookup_Selecting(xwfb.bh, sWhereWrk)
			If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
			Set RsWrk = Server.CreateObject("ADODB.Recordset")
			RsWrk.Open sSqlWrk, Conn
			If Not RsWrk.Eof Then
				arwrk = RsWrk.GetRows
			Else
				arwrk = ""
			End If
			RsWrk.Close
			Set RsWrk = Nothing
			arwrk = ew_AddItemToArray(arwrk, 0, Array("", Language.Phrase("PleaseSelect"), "", "", "", "", "", "", ""))
			xwfb.bh.EditValue = arwrk
			End If

			' lmid
			xwfb.lmid.EditCustomAttributes = ""
			If xwfb.lmid.SessionValue <> "" Then
				xwfb.lmid.CurrentValue = xwfb.lmid.SessionValue
			If xwfb.lmid.CurrentValue & "" <> "" Then
				sFilterWrk = "[lmid]" & ew_SearchString("=", xwfb.lmid.CurrentValue, EW_DATATYPE_NUMBER)
			sSqlWrk = "SELECT [lmid], [lmmc] AS [DispFld], '' AS [Disp2Fld], '' AS [Disp3Fld], '' AS [Disp4Fld] FROM [xwlm]"
			sWhereWrk = ""
			Call ew_AddFilter(sWhereWrk, sFilterWrk)

			' Call Lookup selecting
			Call xwfb.Lookup_Selecting(xwfb.lmid, sWhereWrk)
			If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
				Set RsWrk = Conn.Execute(sSqlWrk)
				If Not RsWrk.Eof Then
					xwfb.lmid.ViewValue = RsWrk("DispFld")
				Else
					xwfb.lmid.ViewValue = xwfb.lmid.CurrentValue
				End If
				RsWrk.Close
				Set RsWrk = Nothing
			Else
				xwfb.lmid.ViewValue = Null
			End If
			xwfb.lmid.ViewCustomAttributes = ""
			Else
			sFilterWrk = ""
			sSqlWrk = "SELECT [lmid], [lmmc] AS [DispFld], '' AS [Disp2Fld], '' AS [Disp3Fld], '' AS [Disp4Fld], [bh] AS [SelectFilterFld], '' AS [SelectFilterFld2], '' AS [SelectFilterFld3], '' AS [SelectFilterFld4] FROM [xwlm]"
			sWhereWrk = ""
			Call ew_AddFilter(sWhereWrk, sFilterWrk)

			' Call Lookup selecting
			Call xwfb.Lookup_Selecting(xwfb.lmid, sWhereWrk)
			If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
			Set RsWrk = Server.CreateObject("ADODB.Recordset")
			RsWrk.Open sSqlWrk, Conn
			If Not RsWrk.Eof Then
				arwrk = RsWrk.GetRows
			Else
				arwrk = ""
			End If
			RsWrk.Close
			Set RsWrk = Nothing
			arwrk = ew_AddItemToArray(arwrk, 0, Array("", Language.Phrase("PleaseSelect"), "", "", "", "", "", "", ""))
			xwfb.lmid.EditValue = arwrk
			End If

			' sj
			xwfb.sj.EditCustomAttributes = ""
			If xwfb.sj.SessionValue <> "" Then
				xwfb.sj.CurrentValue = xwfb.sj.SessionValue
			If xwfb.sj.CurrentValue & "" <> "" Then
				sFilterWrk = "[id]" & ew_SearchString("=", xwfb.sj.CurrentValue, EW_DATATYPE_NUMBER)
			sSqlWrk = "SELECT [id], [sjmc] AS [DispFld], '' AS [Disp2Fld], '' AS [Disp3Fld], '' AS [Disp4Fld] FROM [sjlm]"
			sWhereWrk = ""
			Call ew_AddFilter(sWhereWrk, sFilterWrk)

			' Call Lookup selecting
			Call xwfb.Lookup_Selecting(xwfb.sj, sWhereWrk)
			If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
				Set RsWrk = Conn.Execute(sSqlWrk)
				If Not RsWrk.Eof Then
					xwfb.sj.ViewValue = RsWrk("DispFld")
				Else
					xwfb.sj.ViewValue = xwfb.sj.CurrentValue
				End If
				RsWrk.Close
				Set RsWrk = Nothing
			Else
				xwfb.sj.ViewValue = Null
			End If
			xwfb.sj.ViewCustomAttributes = ""
			Else
			sFilterWrk = ""
			sSqlWrk = "SELECT [id], [sjmc] AS [DispFld], '' AS [Disp2Fld], '' AS [Disp3Fld], '' AS [Disp4Fld], [lmid] AS [SelectFilterFld], '' AS [SelectFilterFld2], '' AS [SelectFilterFld3], '' AS [SelectFilterFld4] FROM [sjlm]"
			sWhereWrk = ""
			Call ew_AddFilter(sWhereWrk, sFilterWrk)

			' Call Lookup selecting
			Call xwfb.Lookup_Selecting(xwfb.sj, sWhereWrk)
			If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
			Set RsWrk = Server.CreateObject("ADODB.Recordset")
			RsWrk.Open sSqlWrk, Conn
			If Not RsWrk.Eof Then
				arwrk = RsWrk.GetRows
			Else
				arwrk = ""
			End If
			RsWrk.Close
			Set RsWrk = Nothing
			arwrk = ew_AddItemToArray(arwrk, 0, Array("", Language.Phrase("PleaseSelect"), "", "", "", "", "", "", ""))
			xwfb.sj.EditValue = arwrk
			End If

			' xwbt
			xwfb.xwbt.EditCustomAttributes = ""
			xwfb.xwbt.EditValue = ew_HtmlEncode(xwfb.xwbt.CurrentValue)
			xwfb.xwbt.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(xwfb.xwbt.FldCaption))

			' fbsj
			xwfb.fbsj.EditCustomAttributes = ""
			xwfb.fbsj.EditValue = ew_FormatDateTime(xwfb.fbsj.CurrentValue, 5)
			xwfb.fbsj.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(xwfb.fbsj.FldCaption))

			' pic
			xwfb.pic.EditCustomAttributes = ""
			xwfb.pic.EditValue = xwfb.pic.CurrentValue
			xwfb.pic.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(xwfb.pic.FldCaption))

			' content
			xwfb.content.EditCustomAttributes = ""
			xwfb.content.EditValue = xwfb.content.CurrentValue
			xwfb.content.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(xwfb.content.FldCaption))

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

			' px
			xwfb.px.EditCustomAttributes = ""
			xwfb.px.EditValue = ew_HtmlEncode(xwfb.px.CurrentValue)
			xwfb.px.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(xwfb.px.FldCaption))

			' hits
			xwfb.hits.EditCustomAttributes = ""
			xwfb.hits.EditValue = ew_HtmlEncode(xwfb.hits.CurrentValue)
			xwfb.hits.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(xwfb.hits.FldCaption))

			' newkey
			xwfb.newkey.EditCustomAttributes = ""
			xwfb.newkey.EditValue = ew_HtmlEncode(xwfb.newkey.CurrentValue)
			xwfb.newkey.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(xwfb.newkey.FldCaption))

			' newtitle
			xwfb.newtitle.EditCustomAttributes = ""
			xwfb.newtitle.EditValue = xwfb.newtitle.CurrentValue
			xwfb.newtitle.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(xwfb.newtitle.FldCaption))

			' newms
			xwfb.newms.EditCustomAttributes = ""
			xwfb.newms.EditValue = xwfb.newms.CurrentValue
			xwfb.newms.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(xwfb.newms.FldCaption))

			' tags
			xwfb.tags.EditCustomAttributes = ""
			xwfb.tags.EditValue = ew_HtmlEncode(xwfb.tags.CurrentValue)
			xwfb.tags.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(xwfb.tags.FldCaption))

			' Edit refer script
			' bh

			xwfb.bh.HrefValue = ""

			' lmid
			xwfb.lmid.HrefValue = ""

			' sj
			xwfb.sj.HrefValue = ""

			' xwbt
			xwfb.xwbt.HrefValue = ""

			' fbsj
			xwfb.fbsj.HrefValue = ""

			' pic
			xwfb.pic.HrefValue = ""

			' content
			xwfb.content.HrefValue = ""

			' ishome
			xwfb.ishome.HrefValue = ""

			' px
			xwfb.px.HrefValue = ""

			' hits
			xwfb.hits.HrefValue = ""

			' newkey
			xwfb.newkey.HrefValue = ""

			' newtitle
			xwfb.newtitle.HrefValue = ""

			' newms
			xwfb.newms.HrefValue = ""

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

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

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

		' Initialize
		gsFormError = ""
		Dim lUpdateCnt
		lUpdateCnt = 0
		If xwfb.bh.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
		If xwfb.lmid.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
		If xwfb.sj.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
		If xwfb.xwbt.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
		If xwfb.fbsj.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
		If xwfb.pic.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
		If xwfb.content.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
		If xwfb.ishome.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
		If xwfb.px.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
		If xwfb.hits.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
		If xwfb.newkey.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
		If xwfb.newtitle.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
		If xwfb.newms.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
		If xwfb.tags.MultiUpdate = "1" Then lUpdateCnt = lUpdateCnt + 1
		If lUpdateCnt = 0 Then
			gsFormError = Language.Phrase("NoFieldSelected")
			ValidateForm = False
			Exit Function
		End If

		' Check if validation required
		If Not EW_SERVER_VALIDATE Then
			ValidateForm = (gsFormError = "")
			Exit Function
		End If
		If xwfb.bh.MultiUpdate <> "" And Not xwfb.bh.FldIsDetailKey And Not IsNull(xwfb.bh.FormValue) And xwfb.bh.FormValue&"" = "" Then
			Call ew_AddMessage(gsFormError, Language.Phrase("EnterRequiredField") & " - " & xwfb.bh.FldCaption)
		End If
		If xwfb.xwbt.MultiUpdate <> "" And Not xwfb.xwbt.FldIsDetailKey And Not IsNull(xwfb.xwbt.FormValue) And xwfb.xwbt.FormValue&"" = "" Then
			Call ew_AddMessage(gsFormError, Language.Phrase("EnterRequiredField") & " - " & xwfb.xwbt.FldCaption)
		End If
		If xwfb.fbsj.MultiUpdate <> "" And Not xwfb.fbsj.FldIsDetailKey And Not IsNull(xwfb.fbsj.FormValue) And xwfb.fbsj.FormValue&"" = "" Then
			Call ew_AddMessage(gsFormError, Language.Phrase("EnterRequiredField") & " - " & xwfb.fbsj.FldCaption)
		End If
		If xwfb.fbsj.MultiUpdate <> "" Then
			If Not ew_CheckDate(xwfb.fbsj.FormValue) Then
				Call ew_AddMessage(gsFormError, xwfb.fbsj.FldErrMsg)
			End If
		End If
		If xwfb.content.MultiUpdate <> "" And Not xwfb.content.FldIsDetailKey And Not IsNull(xwfb.content.FormValue) And xwfb.content.FormValue&"" = "" Then
			Call ew_AddMessage(gsFormError, Language.Phrase("EnterRequiredField") & " - " & xwfb.content.FldCaption)
		End If
		If xwfb.px.MultiUpdate <> "" Then
			If Not ew_CheckInteger(xwfb.px.FormValue) Then
				Call ew_AddMessage(gsFormError, xwfb.px.FldErrMsg)
			End If
		End If
		If xwfb.hits.MultiUpdate <> "" Then
			If Not ew_CheckInteger(xwfb.hits.FormValue) Then
				Call ew_AddMessage(gsFormError, xwfb.hits.FldErrMsg)
			End If
		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 = xwfb.KeyFilter
		xwfb.CurrentFilter  = sFilter
		sSql = xwfb.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 bh
			Call xwfb.bh.SetDbValue(Rs, xwfb.bh.CurrentValue, Null, xwfb.bh.ReadOnly Or xwfb.bh.MultiUpdate&"" <> "1")

			' Field lmid
			Call xwfb.lmid.SetDbValue(Rs, xwfb.lmid.CurrentValue, Null, xwfb.lmid.ReadOnly Or xwfb.lmid.MultiUpdate&"" <> "1")

			' Field sj
			Call xwfb.sj.SetDbValue(Rs, xwfb.sj.CurrentValue, Null, xwfb.sj.ReadOnly Or xwfb.sj.MultiUpdate&"" <> "1")

			' Field xwbt
			Call xwfb.xwbt.SetDbValue(Rs, xwfb.xwbt.CurrentValue, Null, xwfb.xwbt.ReadOnly Or xwfb.xwbt.MultiUpdate&"" <> "1")

			' Field fbsj
			Call xwfb.fbsj.SetDbValue(Rs, ew_UnFormatDateTime(xwfb.fbsj.CurrentValue, 5), Null, xwfb.fbsj.ReadOnly Or xwfb.fbsj.MultiUpdate&"" <> "1")

			' Field pic
			Call xwfb.pic.SetDbValue(Rs, xwfb.pic.CurrentValue, Null, xwfb.pic.ReadOnly Or xwfb.pic.MultiUpdate&"" <> "1")

			' Field content
			Call xwfb.content.SetDbValue(Rs, xwfb.content.CurrentValue, Null, xwfb.content.ReadOnly Or xwfb.content.MultiUpdate&"" <> "1")

			' Field ishome
			Call xwfb.ishome.SetDbValue(Rs, xwfb.ishome.CurrentValue, Null, xwfb.ishome.ReadOnly Or xwfb.ishome.MultiUpdate&"" <> "1")

			' Field px
			Call xwfb.px.SetDbValue(Rs, xwfb.px.CurrentValue, Null, xwfb.px.ReadOnly Or xwfb.px.MultiUpdate&"" <> "1")

			' Field hits
			Call xwfb.hits.SetDbValue(Rs, xwfb.hits.CurrentValue, Null, xwfb.hits.ReadOnly Or xwfb.hits.MultiUpdate&"" <> "1")

			' Field newkey
			Call xwfb.newkey.SetDbValue(Rs, xwfb.newkey.CurrentValue, Null, xwfb.newkey.ReadOnly Or xwfb.newkey.MultiUpdate&"" <> "1")

			' Field newtitle
			Call xwfb.newtitle.SetDbValue(Rs, xwfb.newtitle.CurrentValue, Null, xwfb.newtitle.ReadOnly Or xwfb.newtitle.MultiUpdate&"" <> "1")

			' Field newms
			Call xwfb.newms.SetDbValue(Rs, xwfb.newms.CurrentValue, Null, xwfb.newms.ReadOnly Or xwfb.newms.MultiUpdate&"" <> "1")

			' Field tags
			Call xwfb.tags.SetDbValue(Rs, xwfb.tags.CurrentValue, Null, xwfb.tags.ReadOnly Or xwfb.tags.MultiUpdate&"" <> "1")

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

			' Call Row Updating event
			bUpdateRow = xwfb.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 xwfb.CancelMessage <> "" Then
					FailureMessage = xwfb.CancelMessage
					xwfb.CancelMessage = ""
				Else
					FailureMessage = Language.Phrase("UpdateCancelled")
				End If
				EditRow = False
			End If
		End If

		' Call Row Updated event
		If EditRow Then
			Call xwfb.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", xwfb.TableVar, "xwfblist.asp", xwfb.TableVar, True)
		PageId = "update"
		Call Breadcrumb.Add("update", 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
%>
