<%
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_search
Set xwfb_search = New cxwfb_search
Set Page = xwfb_search

' Page init processing
xwfb_search.Page_Init()

' Page main processing
xwfb_search.Page_Main()

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

' Page Rendering event
xwfb_search.Page_Render()
%>
<!--#include file="header.asp"-->
<script type="text/javascript">
// Page object
var xwfb_search = new ew_Page("xwfb_search");
xwfb_search.PageID = "search"; // Page ID
var EW_PAGE_ID = xwfb_search.PageID; // For backward compatibility
// Form object
var fxwfbsearch = new ew_Form("fxwfbsearch");
// Form_CustomValidate event
fxwfbsearch.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 %>
fxwfbsearch.ValidateRequired = true; // Use JavaScript validation
<% Else %>
fxwfbsearch.ValidateRequired = false; // No JavaScript validation
<% End If %>
// Dynamic selection lists
fxwfbsearch.Lists["x_bh"] = {"LinkField":"x_bh","Ajax":null,"AutoFill":false,"DisplayFields":["x_bhmc","","",""],"ParentFields":[],"FilterFields":[],"Options":[]};
fxwfbsearch.Lists["x_lmid"] = {"LinkField":"x_lmid","Ajax":null,"AutoFill":false,"DisplayFields":["x_lmmc","","",""],"ParentFields":["x_bh"],"FilterFields":["x_bh"],"Options":[]};
fxwfbsearch.Lists["x_sj"] = {"LinkField":"x_id","Ajax":null,"AutoFill":false,"DisplayFields":["x_sjmc","","",""],"ParentFields":["x_lmid"],"FilterFields":["x_lmid"],"Options":[]};
// Form object for search
// Validate function for search
fxwfbsearch.Validate = function(fobj) {
	if (!this.ValidateRequired)
		return true; // Ignore validation
	fobj = fobj || this.Form;
	this.PostAutoSuggest();
	var infix = "";
	elm = this.GetElements("x" + infix + "_id");
	if (elm && !ew_CheckInteger(elm.value))
		return this.OnError(elm, "<%= ew_JsEncode2(xwfb.id.FldErrMsg) %>");
	elm = this.GetElements("x" + infix + "_fbsj");
	if (elm && !ew_CheckDate(elm.value))
		return this.OnError(elm, "<%= ew_JsEncode2(xwfb.fbsj.FldErrMsg) %>");
	elm = this.GetElements("x" + infix + "_px");
	if (elm && !ew_CheckInteger(elm.value))
		return this.OnError(elm, "<%= ew_JsEncode2(xwfb.px.FldErrMsg) %>");
	elm = this.GetElements("x" + infix + "_hits");
	if (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;
}
</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_search.ShowPageHeader() %>
<% xwfb_search.ShowMessage %>
<form name="fxwfbsearch" id="fxwfbsearch" class="ewForm form-inline" action="<%= ew_CurrentPage %>" method="post">
<input type="hidden" name="t" value="xwfb">
<input type="hidden" name="a_search" id="a_search" value="S">
<table class="ewGrid"><tr><td>
<table id="tbl_xwfbsearch" class="table table-bordered table-striped">
<% If xwfb.id.Visible Then ' id %>
	<tr id="r_id">
		<td><span id="elh_xwfb_id"><%= xwfb.id.FldCaption %></span></td>
		<td><span class="ewSearchOperator"><%= Language.Phrase("=") %><input type="hidden" name="z_id" id="z_id" value="="></span></td>
		<td<%= xwfb.id.CellAttributes %>>
			<div style="white-space: nowrap;">
				<span id="el_xwfb_id" class="control-group">
<input type="text" data-field="x_id" name="x_id" id="x_id" placeholder="<%= xwfb.id.PlaceHolder %>" value="<%= xwfb.id.EditValue %>"<%= xwfb.id.EditAttributes %>>
</span>
			</div>
		</td>
	</tr>
<% End If %>
<% If xwfb.bh.Visible Then ' bh %>
	<tr id="r_bh">
		<td><span id="elh_xwfb_bh"><%= xwfb.bh.FldCaption %></span></td>
		<td><span class="ewSearchOperator"><%= Language.Phrase("=") %><input type="hidden" name="z_bh" id="z_bh" value="="></span></td>
		<td<%= xwfb.bh.CellAttributes %>>
			<div style="white-space: nowrap;">
				<span id="el_xwfb_bh" class="control-group">
<% 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.AdvancedSearch.SearchValue&"" 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">
fxwfbsearch.Lists["x_bh"].Options = <%= ew_IIf(IsArray(xwfb.bh.EditValue), ew_ArrayToJson(xwfb.bh.EditValue, 1), "[]") %>;
</script>
</span>
			</div>
		</td>
	</tr>
<% End If %>
<% If xwfb.lmid.Visible Then ' lmid %>
	<tr id="r_lmid">
		<td><span id="elh_xwfb_lmid"><%= xwfb.lmid.FldCaption %></span></td>
		<td><span class="ewSearchOperator"><%= Language.Phrase("=") %><input type="hidden" name="z_lmid" id="z_lmid" value="="></span></td>
		<td<%= xwfb.lmid.CellAttributes %>>
			<div style="white-space: nowrap;">
				<span id="el_xwfb_lmid" class="control-group">
<% 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.AdvancedSearch.SearchValue&"" 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">
fxwfbsearch.Lists["x_lmid"].Options = <%= ew_IIf(IsArray(xwfb.lmid.EditValue), ew_ArrayToJson(xwfb.lmid.EditValue, 1), "[]") %>;
</script>
</span>
			</div>
		</td>
	</tr>
<% End If %>
<% If xwfb.sj.Visible Then ' sj %>
	<tr id="r_sj">
		<td><span id="elh_xwfb_sj"><%= xwfb.sj.FldCaption %></span></td>
		<td><span class="ewSearchOperator"><%= Language.Phrase("=") %><input type="hidden" name="z_sj" id="z_sj" value="="></span></td>
		<td<%= xwfb.sj.CellAttributes %>>
			<div style="white-space: nowrap;">
				<span id="el_xwfb_sj" class="control-group">
<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.AdvancedSearch.SearchValue&"" 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">
fxwfbsearch.Lists["x_sj"].Options = <%= ew_IIf(IsArray(xwfb.sj.EditValue), ew_ArrayToJson(xwfb.sj.EditValue, 1), "[]") %>;
</script>
</span>
			</div>
		</td>
	</tr>
<% End If %>
<% If xwfb.xwbt.Visible Then ' xwbt %>
	<tr id="r_xwbt">
		<td><span id="elh_xwfb_xwbt"><%= xwfb.xwbt.FldCaption %></span></td>
		<td><span class="ewSearchOperator"><%= Language.Phrase("LIKE") %><input type="hidden" name="z_xwbt" id="z_xwbt" value="LIKE"></span></td>
		<td<%= xwfb.xwbt.CellAttributes %>>
			<div style="white-space: nowrap;">
				<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>
			</div>
		</td>
	</tr>
<% End If %>
<% If xwfb.fbsj.Visible Then ' fbsj %>
	<tr id="r_fbsj">
		<td><span id="elh_xwfb_fbsj"><%= xwfb.fbsj.FldCaption %></span></td>
		<td><span class="ewSearchOperator"><%= Language.Phrase("=") %><input type="hidden" name="z_fbsj" id="z_fbsj" value="="></span></td>
		<td<%= xwfb.fbsj.CellAttributes %>>
			<div style="white-space: nowrap;">
				<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("fxwfbsearch", "x_fbsj", "%Y-%m-%d");
</script>
<% End If %>
</span>
			</div>
		</td>
	</tr>
<% End If %>
<% If xwfb.pic.Visible Then ' pic %>
	<tr id="r_pic">
		<td><span id="elh_xwfb_pic"><%= xwfb.pic.FldCaption %></span></td>
		<td><span class="ewSearchOperator"><%= Language.Phrase("LIKE") %><input type="hidden" name="z_pic" id="z_pic" value="LIKE"></span></td>
		<td<%= xwfb.pic.CellAttributes %>>
			<div style="white-space: nowrap;">
				<span id="el_xwfb_pic" class="control-group">
<input type="text" data-field="x_pic" name="x_pic" id="x_pic" placeholder="<%= xwfb.pic.PlaceHolder %>" value="<%= xwfb.pic.EditValue %>"<%= xwfb.pic.EditAttributes %>>
<script type="text/javascript">
ew_CreateEditor("fxwfbsearch", "x_pic", 45, 6, <%= ew_IIf(xwfb.pic.ReadOnly Or False, "true", "false") %>);
</script>
</span>
			</div>
		</td>
	</tr>
<% End If %>
<% If xwfb.content.Visible Then ' content %>
	<tr id="r_content">
		<td><span id="elh_xwfb_content"><%= xwfb.content.FldCaption %></span></td>
		<td><span class="ewSearchOperator"><%= Language.Phrase("LIKE") %><input type="hidden" name="z_content" id="z_content" value="LIKE"></span></td>
		<td<%= xwfb.content.CellAttributes %>>
			<div style="white-space: nowrap;">
				<span id="el_xwfb_content" class="control-group">
<input type="text" data-field="x_content" name="x_content" id="x_content" placeholder="<%= xwfb.content.PlaceHolder %>" value="<%= xwfb.content.EditValue %>"<%= xwfb.content.EditAttributes %>>
<script type="text/javascript">
ew_CreateEditor("fxwfbsearch", "x_content", 45, 5, <%= ew_IIf(xwfb.content.ReadOnly Or False, "true", "false") %>);
</script>
</span>
			</div>
		</td>
	</tr>
<% End If %>
<% If xwfb.ishome.Visible Then ' ishome %>
	<tr id="r_ishome">
		<td><span id="elh_xwfb_ishome"><%= xwfb.ishome.FldCaption %></span></td>
		<td><span class="ewSearchOperator"><%= Language.Phrase("=") %><input type="hidden" name="z_ishome" id="z_ishome" value="="></span></td>
		<td<%= xwfb.ishome.CellAttributes %>>
			<div style="white-space: nowrap;">
				<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.AdvancedSearch.SearchValue&"" = 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>
			</div>
		</td>
	</tr>
<% End If %>
<% If xwfb.px.Visible Then ' px %>
	<tr id="r_px">
		<td><span id="elh_xwfb_px"><%= xwfb.px.FldCaption %></span></td>
		<td><span class="ewSearchOperator"><%= Language.Phrase("=") %><input type="hidden" name="z_px" id="z_px" value="="></span></td>
		<td<%= xwfb.px.CellAttributes %>>
			<div style="white-space: nowrap;">
				<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>
			</div>
		</td>
	</tr>
<% End If %>
<% If xwfb.hits.Visible Then ' hits %>
	<tr id="r_hits">
		<td><span id="elh_xwfb_hits"><%= xwfb.hits.FldCaption %></span></td>
		<td><span class="ewSearchOperator"><%= Language.Phrase("=") %><input type="hidden" name="z_hits" id="z_hits" value="="></span></td>
		<td<%= xwfb.hits.CellAttributes %>>
			<div style="white-space: nowrap;">
				<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>
			</div>
		</td>
	</tr>
<% End If %>
<% If xwfb.newkey.Visible Then ' newkey %>
	<tr id="r_newkey">
		<td><span id="elh_xwfb_newkey"><%= xwfb.newkey.FldCaption %></span></td>
		<td><span class="ewSearchOperator"><%= Language.Phrase("LIKE") %><input type="hidden" name="z_newkey" id="z_newkey" value="LIKE"></span></td>
		<td<%= xwfb.newkey.CellAttributes %>>
			<div style="white-space: nowrap;">
				<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>
			</div>
		</td>
	</tr>
<% End If %>
<% If xwfb.newtitle.Visible Then ' newtitle %>
	<tr id="r_newtitle">
		<td><span id="elh_xwfb_newtitle"><%= xwfb.newtitle.FldCaption %></span></td>
		<td><span class="ewSearchOperator"><%= Language.Phrase("LIKE") %><input type="hidden" name="z_newtitle" id="z_newtitle" value="LIKE"></span></td>
		<td<%= xwfb.newtitle.CellAttributes %>>
			<div style="white-space: nowrap;">
				<span id="el_xwfb_newtitle" class="control-group">
<input type="text" data-field="x_newtitle" name="x_newtitle" id="x_newtitle" placeholder="<%= xwfb.newtitle.PlaceHolder %>" value="<%= xwfb.newtitle.EditValue %>"<%= xwfb.newtitle.EditAttributes %>>
</span>
			</div>
		</td>
	</tr>
<% End If %>
<% If xwfb.newms.Visible Then ' newms %>
	<tr id="r_newms">
		<td><span id="elh_xwfb_newms"><%= xwfb.newms.FldCaption %></span></td>
		<td><span class="ewSearchOperator"><%= Language.Phrase("LIKE") %><input type="hidden" name="z_newms" id="z_newms" value="LIKE"></span></td>
		<td<%= xwfb.newms.CellAttributes %>>
			<div style="white-space: nowrap;">
				<span id="el_xwfb_newms" class="control-group">
<input type="text" data-field="x_newms" name="x_newms" id="x_newms" placeholder="<%= xwfb.newms.PlaceHolder %>" value="<%= xwfb.newms.EditValue %>"<%= xwfb.newms.EditAttributes %>>
</span>
			</div>
		</td>
	</tr>
<% End If %>
<% If xwfb.tags.Visible Then ' tags %>
	<tr id="r_tags">
		<td><span id="elh_xwfb_tags"><%= xwfb.tags.FldCaption %></span></td>
		<td><span class="ewSearchOperator"><%= Language.Phrase("LIKE") %><input type="hidden" name="z_tags" id="z_tags" value="LIKE"></span></td>
		<td<%= xwfb.tags.CellAttributes %>>
			<div style="white-space: nowrap;">
				<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>
			</div>
		</td>
	</tr>
<% End If %>
</table>
</td></tr></table>
<button class="btn btn-primary ewButton" name="btnAction" id="btnAction" type="submit"><%= Language.Phrase("Search") %></button>
<button class="btn ewButton" name="btnReset" id="btnReset" type="button" onclick="ew_ClearForm(this.form);"><%= Language.Phrase("Reset") %></button>
</form>
<script type="text/javascript">
fxwfbsearch.Init();
<% If EW_MOBILE_REFLOW And ew_IsMobile() Then %>
ew_Reflow();
<% End If %>
</script>
<%
xwfb_search.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_search = Nothing
%>
<%

' -----------------------------------------------------------------
' Page Class
'
Class cxwfb_search

	' Page ID
	Public Property Get PageID()
		PageID = "search"
	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_search"
	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 = "search"

		' 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.CanSearch 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
		xwfb.id.Visible = Not xwfb.IsAdd() And Not xwfb.IsCopy() And Not xwfb.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 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)
	' ----------------------------------------
	' -----------------------------------------------------------------
	' Page main processing
	'
	Sub Page_Main()

		' Set up Breadcrumb
		SetupBreadcrumb()
		If IsPageRequest Then ' Validate request

			' Get action
			xwfb.CurrentAction = ObjForm.GetValue("a_search")
			Select Case xwfb.CurrentAction
				Case "S" ' Get Search Criteria

					' Build search string for advanced search, remove blank field
					Dim sSrchStr
					Call LoadSearchValues() ' Get search values
					If ValidateSearch() Then
						sSrchStr = BuildAdvancedSearch()
					Else
						sSrchStr = ""
						FailureMessage = gsSearchError
					End If
					If sSrchStr <> "" Then
						sSrchStr = xwfb.UrlParm(sSrchStr)
						Call Page_Terminate("xwfblist.asp" & "?" & sSrchStr) ' Go to list page
					End If
			End Select
		End If

		' Restore search settings from Session
		If gsSearchError = "" Then
			Call LoadAdvancedSearch()
		End If

		' Render row for search
		xwfb.RowType = EW_ROWTYPE_SEARCH
		Call RenderRow()
	End Sub

	' -----------------------------------------------------------------
	' Build advanced search
	'
	Function BuildAdvancedSearch()
		Dim sSrchUrl
		sSrchUrl = ""
		Call BuildSearchUrl(sSrchUrl, xwfb.id, False) ' id
		Call BuildSearchUrl(sSrchUrl, xwfb.bh, False) ' bh
		Call BuildSearchUrl(sSrchUrl, xwfb.lmid, False) ' lmid
		Call BuildSearchUrl(sSrchUrl, xwfb.sj, False) ' sj
		Call BuildSearchUrl(sSrchUrl, xwfb.xwbt, False) ' xwbt
		Call BuildSearchUrl(sSrchUrl, xwfb.fbsj, False) ' fbsj
		Call BuildSearchUrl(sSrchUrl, xwfb.pic, False) ' pic
		Call BuildSearchUrl(sSrchUrl, xwfb.content, False) ' content
		Call BuildSearchUrl(sSrchUrl, xwfb.ishome, False) ' ishome
		Call BuildSearchUrl(sSrchUrl, xwfb.px, False) ' px
		Call BuildSearchUrl(sSrchUrl, xwfb.hits, False) ' hits
		Call BuildSearchUrl(sSrchUrl, xwfb.newkey, False) ' newkey
		Call BuildSearchUrl(sSrchUrl, xwfb.newtitle, False) ' newtitle
		Call BuildSearchUrl(sSrchUrl, xwfb.newms, False) ' newms
		Call BuildSearchUrl(sSrchUrl, xwfb.tags, False) ' tags
		If sSrchUrl <> "" Then sSrchUrl = sSrchUrl & "&"
		sSrchUrl = sSrchUrl & "cmd=search"
		BuildAdvancedSearch = sSrchUrl
	End Function

	' -----------------------------------------------------------------
	' Function to build search URL
	'
	Sub BuildSearchUrl(Url, Fld, OprOnly)
		Dim FldVal, FldOpr, FldCond, FldVal2, FldOpr2
		Dim FldParm
		Dim IsValidValue, sWrk
		sWrk = ""
		FldParm = Mid(Fld.FldVar, 3)
		FldVal = ObjForm.GetValue("x_" & FldParm)
		FldOpr = ObjForm.GetValue("z_" & FldParm)
		FldCond = ObjForm.GetValue("v_" & FldParm)
		FldVal2 = ObjForm.GetValue("y_" & FldParm)
		FldOpr2 = ObjForm.GetValue("w_" & FldParm)
		FldOpr = UCase(Trim(FldOpr))
		Dim lFldDataType
		If Fld.FldIsVirtual Then
			lFldDataType = EW_DATATYPE_STRING
		Else
			lFldDataType = Fld.FldDataType
		End If
		If FldOpr = "BETWEEN" Then
			IsValidValue = (lFldDataType <> EW_DATATYPE_NUMBER) Or _
				(lFldDataType = EW_DATATYPE_NUMBER And SearchValueIsNumeric(Fld, FldVal) And SearchValueIsNumeric(Fld, FldVal2))
			If FldVal <> "" And FldVal2 <> "" And IsValidValue Then
				sWrk = "x_" & FldParm & "=" & Server.URLEncode(FldVal) & _
					"&y_" & FldParm & "=" & Server.URLEncode(FldVal2) & _
					"&z_" & FldParm & "=" & Server.URLEncode(FldOpr)
			End If
		Else
			IsValidValue = (lFldDataType <> EW_DATATYPE_NUMBER) Or _
				(lFldDataType = EW_DATATYPE_NUMBER And SearchValueIsNumeric(Fld, FldVal))
			If FldVal <> "" And IsValidValue And ew_IsValidOpr(FldOpr, lFldDataType) Then
				sWrk = "x_" & FldParm & "=" & Server.URLEncode(FldVal) & _
					"&z_" & FldParm & "=" & Server.URLEncode(FldOpr)
			ElseIf FldOpr = "IS NULL" Or FldOpr = "IS NOT NULL" Or (FldOpr <> "" And OprOnly And ew_IsValidOpr(FldOpr, lFldDataType)) Then
				sWrk = "z_" & FldParm & "=" & Server.URLEncode(FldOpr)
			End If
			IsValidValue = (lFldDataType <> EW_DATATYPE_NUMBER) Or _
				(lFldDataType = EW_DATATYPE_NUMBER And SearchValueIsNumeric(Fld, FldVal2))
			If FldVal2 <> "" And IsValidValue And ew_IsValidOpr(FldOpr2, lFldDataType) Then
				If sWrk <> "" Then sWrk = sWrk & "&v_" & FldParm & "=" & FldCond & "&"
				sWrk = sWrk & "y_" & FldParm & "=" & Server.URLEncode(FldVal2) & _
					"&w_" & FldParm & "=" & Server.URLEncode(FldOpr2)
			ElseIf FldOpr2 = "IS NULL" Or FldOpr2 = "IS NOT NULL" Or (FldOpr2 <> "" And OprOnly And ew_IsValidOpr(FldOpr2, lFldDataType)) Then
				If sWrk <> "" Then sWrk = sWrk & "&v_" & FldParm & "=" & FldCond & "&"
				sWrk = sWrk & "w_" & FldParm & "=" & Server.URLEncode(FldOpr2)
			End If
		End If
		If sWrk <> "" Then
			If Url <> "" Then Url = Url & "&"
			Url = Url & sWrk
		End If
	End Sub

	Function SearchValueIsNumeric(Fld, Value)
		Dim wrkValue
		wrkValue = Value
		If ew_IsFloatFormat(Fld.FldType) Then wrkValue = ew_StrToFloat(wrkValue)
		SearchValueIsNumeric = IsNumeric(Value)
	End Function

	' -----------------------------------------------------------------
	'  Load search values for validation
	'
	Function LoadSearchValues()

		' Load search values
		xwfb.id.AdvancedSearch.SearchValue = ObjForm.GetValue("x_id")
		xwfb.id.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_id")
		xwfb.bh.AdvancedSearch.SearchValue = ObjForm.GetValue("x_bh")
		xwfb.bh.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_bh")
		xwfb.lmid.AdvancedSearch.SearchValue = ObjForm.GetValue("x_lmid")
		xwfb.lmid.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_lmid")
		xwfb.sj.AdvancedSearch.SearchValue = ObjForm.GetValue("x_sj")
		xwfb.sj.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_sj")
		xwfb.xwbt.AdvancedSearch.SearchValue = ObjForm.GetValue("x_xwbt")
		xwfb.xwbt.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_xwbt")
		xwfb.fbsj.AdvancedSearch.SearchValue = ObjForm.GetValue("x_fbsj")
		xwfb.fbsj.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_fbsj")
		xwfb.pic.AdvancedSearch.SearchValue = ObjForm.GetValue("x_pic")
		xwfb.pic.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_pic")
		xwfb.content.AdvancedSearch.SearchValue = ObjForm.GetValue("x_content")
		xwfb.content.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_content")
		xwfb.ishome.AdvancedSearch.SearchValue = ObjForm.GetValue("x_ishome")
		xwfb.ishome.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_ishome")
		xwfb.px.AdvancedSearch.SearchValue = ObjForm.GetValue("x_px")
		xwfb.px.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_px")
		xwfb.hits.AdvancedSearch.SearchValue = ObjForm.GetValue("x_hits")
		xwfb.hits.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_hits")
		xwfb.newkey.AdvancedSearch.SearchValue = ObjForm.GetValue("x_newkey")
		xwfb.newkey.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_newkey")
		xwfb.newtitle.AdvancedSearch.SearchValue = ObjForm.GetValue("x_newtitle")
		xwfb.newtitle.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_newtitle")
		xwfb.newms.AdvancedSearch.SearchValue = ObjForm.GetValue("x_newms")
		xwfb.newms.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_newms")
		xwfb.tags.AdvancedSearch.SearchValue = ObjForm.GetValue("x_tags")
		xwfb.tags.AdvancedSearch.SearchOperator = ObjForm.GetValue("z_tags")
	End Function

	' -----------------------------------------------------------------
	' 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
			' id

			xwfb.id.LinkCustomAttributes = ""
			xwfb.id.HrefValue = ""
			xwfb.id.TooltipValue = ""

			' 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 = ""

		' ------------
		'  Search Row
		' ------------

		ElseIf xwfb.RowType = EW_ROWTYPE_SEARCH Then ' Search row

			' id
			xwfb.id.EditCustomAttributes = ""
			xwfb.id.EditValue = ew_HtmlEncode(xwfb.id.AdvancedSearch.SearchValue)
			xwfb.id.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(xwfb.id.FldCaption))

			' bh
			xwfb.bh.EditCustomAttributes = ""
			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

			' lmid
			xwfb.lmid.EditCustomAttributes = ""
			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

			' sj
			xwfb.sj.EditCustomAttributes = ""
			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

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

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

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

			' content
			xwfb.content.EditCustomAttributes = ""
			xwfb.content.EditValue = xwfb.content.AdvancedSearch.SearchValue
			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.AdvancedSearch.SearchValue)
			xwfb.px.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(xwfb.px.FldCaption))

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

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

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

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

			' tags
			xwfb.tags.EditCustomAttributes = ""
			xwfb.tags.EditValue = ew_HtmlEncode(xwfb.tags.AdvancedSearch.SearchValue)
			xwfb.tags.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(xwfb.tags.FldCaption))
		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 search
	'
	Function ValidateSearch()

		' Initialize
		gsSearchError = ""

		' Check if validation required
		If Not EW_SERVER_VALIDATE Then
			ValidateSearch = True
			Exit Function
		End If
		If Not ew_CheckInteger(xwfb.id.AdvancedSearch.SearchValue) Then
			Call ew_AddMessage(gsSearchError, xwfb.id.FldErrMsg)
		End If
		If Not ew_CheckDate(xwfb.fbsj.AdvancedSearch.SearchValue) Then
			Call ew_AddMessage(gsSearchError, xwfb.fbsj.FldErrMsg)
		End If
		If Not ew_CheckInteger(xwfb.px.AdvancedSearch.SearchValue) Then
			Call ew_AddMessage(gsSearchError, xwfb.px.FldErrMsg)
		End If
		If Not ew_CheckInteger(xwfb.hits.AdvancedSearch.SearchValue) Then
			Call ew_AddMessage(gsSearchError, xwfb.hits.FldErrMsg)
		End If

		' Return validate result
		ValidateSearch = (gsSearchError = "")

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

	' -----------------------------------------------------------------
	' Load advanced search
	'
	Function LoadAdvancedSearch()
		Call xwfb.id.AdvancedSearch.Load()
		Call xwfb.bh.AdvancedSearch.Load()
		Call xwfb.lmid.AdvancedSearch.Load()
		Call xwfb.sj.AdvancedSearch.Load()
		Call xwfb.xwbt.AdvancedSearch.Load()
		Call xwfb.fbsj.AdvancedSearch.Load()
		Call xwfb.pic.AdvancedSearch.Load()
		Call xwfb.content.AdvancedSearch.Load()
		Call xwfb.ishome.AdvancedSearch.Load()
		Call xwfb.px.AdvancedSearch.Load()
		Call xwfb.hits.AdvancedSearch.Load()
		Call xwfb.newkey.AdvancedSearch.Load()
		Call xwfb.newtitle.AdvancedSearch.Load()
		Call xwfb.newms.AdvancedSearch.Load()
		Call xwfb.tags.AdvancedSearch.Load()
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 = "search"
		Call Breadcrumb.Add("search", 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
%>
