<%
Response.Buffer = EW_RESPONSE_BUFFER
%>
<!--#include file="ewcfg7.asp"-->
<!--#include file="xwfbinfo.asp"-->
<!--#include file="bhlminfo.asp"-->
<!--#include file="xwlminfo.asp"-->
<!--#include file="zlogininfo.asp"-->
<!--#include file="sjlminfo.asp"-->
<!--#include file="aspfn7.asp"-->
<!--#include file="userfn7.asp"-->
<% Session.Timeout = 900 %>
<%
Response.Expires = 0
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader "pragma", "no-cache"
Response.AddHeader "cache-control", "private, no-cache, no-store, must-revalidate"
%>
<%

' Define page object
Dim xwfb_search
Set xwfb_search = New cxwfb_search
Set Page = xwfb_search

' Page init processing
Call xwfb_search.Page_Init()

' Page main processing
Call xwfb_search.Page_Main()
%>
<!--#include file="header.asp"-->
<script type="text/javascript">
<!--
// Create page object
var xwfb_search = new ew_Page("xwfb_search");
// page properties
xwfb_search.PageID = "search"; // page ID
var EW_PAGE_ID = xwfb_search.PageID; // for backward compatibility
// extend page with validate function for search
xwfb_search.ValidateSearch = function(fobj) {
	if (!this.ValidateRequired)
		return true; // ignore validation
	var infix = "";
	elm = fobj.elements["x" + infix + "_id"];
	if (elm && !ew_CheckInteger(elm.value))
		return ew_OnError(this, elm, "无效的整数型 - 编号");
	elm = fobj.elements["x" + infix + "_fbsj"];
	if (elm && !ew_CheckDate(elm.value))
		return ew_OnError(this, elm, "日期无效, 例 ： 年-月-日 - 发布时间");
	elm = fobj.elements["x" + infix + "_px"];
	if (elm && !ew_CheckInteger(elm.value))
		return ew_OnError(this, elm, "无效的整数型 - 排序");
	// Call Form Custom Validate event
	if (!this.Form_CustomValidate(fobj)) return false;
	for (var i=0;i<fobj.elements.length;i++) {
		var elem = fobj.elements[i];
		if (elem.name.substring(0,2) == "s_" || elem.name.substring(0,3) == "sv_")
			elem.value = "";
	}
	return true;
}
// extend page with Form_CustomValidate function
xwfb_search.Form_CustomValidate = 
 function(fobj) { // DO NOT CHANGE THIS LINE!
 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
xwfb_search.SelectAllKey = function(elem) {
	ew_SelectAll(elem);
}
<% If EW_CLIENT_VALIDATE Then %>
xwfb_search.ValidateRequired = true; // uses JavaScript validation
<% Else %>
xwfb_search.ValidateRequired = false; // no JavaScript validation
<% End If %>
//-->
</script>
<script type="text/javascript" src="fckeditor/fckeditor.js"></script>
<script type="text/javascript">
<!--
_width_multiplier = 16;
_height_multiplier = 60;
var ew_DHTMLEditors = [];
// update value from editor to textarea
function ew_UpdateTextArea() {
	if (typeof ew_DHTMLEditors != 'undefined' && typeof FCKeditorAPI != 'undefined') {			
			var inst;			
			for (inst in FCKeditorAPI.__Instances)
				FCKeditorAPI.__Instances[inst].UpdateLinkedField();
	}
}
// update value from textarea to editor
function ew_UpdateDHTMLEditor(name) {
	if (typeof ew_DHTMLEditors != 'undefined' && typeof FCKeditorAPI != 'undefined') {
		var inst = FCKeditorAPI.GetInstance(name);		
		if (inst)
			inst.SetHTML(inst.LinkedField.value)
	}
}
// focus editor
function ew_FocusDHTMLEditor(name) {
	if (typeof ew_DHTMLEditors != 'undefined' && typeof FCKeditorAPI != 'undefined') {
		var inst = FCKeditorAPI.GetInstance(name);	
		if (inst && inst.EditorWindow) {
			inst.EditorWindow.focus();
		}
	}
}
//-->
</script>
<link rel="stylesheet" type="text/css" media="all" href="calendar/calendar-win2k-1.css" title="win2k-1">
<script type="text/javascript" src="calendar/calendar.js"></script>
<script type="text/javascript" src="calendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="calendar/calendar-setup.js"></script>
<script language="JavaScript" type="text/javascript">
<!--
// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->
</script>
<p><span class="aspmaker">搜索 表: 信息管理<br><br>
<a href="<%= xwfb.ReturnUrl %>">返回列表</a></span></p>
<% xwfb_search.ShowMessage %>
<form name="fxwfbsearch" id="fxwfbsearch" action="<%= ew_CurrentPage %>" method="post">
<p>
<input type="hidden" name="t" id="t" value="xwfb">
<input type="hidden" name="a_search" id="a_search" value="S">
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
	<tr<%= xwfb.id.RowAttributes %>>
		<td class="ewTableHeader">编号</td>
		<td<%= xwfb.id.CellAttributes %>><span class="ewSearchOpr">=<input type="hidden" name="z_id" id="z_id" value="="></span></td>
		<td<%= xwfb.id.CellAttributes %>>
			<table cellspacing="0" class="ewItemTable"><tr>
				<td><span class="aspmaker">
<input type="text" name="x_id" id="x_id" value="<%= xwfb.id.EditValue %>"<%= xwfb.id.EditAttributes %>>
</span></td>
			</tr></table>
		</td>
	</tr>
	<tr<%= xwfb.bh.RowAttributes %>>
		<td class="ewTableHeader">一级栏目</td>
		<td<%= xwfb.bh.CellAttributes %>><span class="ewSearchOpr">=<input type="hidden" name="z_bh" id="z_bh" value="="></span></td>
		<td<%= xwfb.bh.CellAttributes %>>
			<table cellspacing="0" class="ewItemTable"><tr>
				<td><span class="aspmaker">
<select id="x_bh" name="x_bh" onchange="ew_UpdateOpt('x_lmid','x_bh',xwfb_search.ar_x_lmid);"<%= 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>
</span></td>
			</tr></table>
		</td>
	</tr>
	<tr<%= xwfb.lmid.RowAttributes %>>
		<td class="ewTableHeader">二级栏目</td>
		<td<%= xwfb.lmid.CellAttributes %>><span class="ewSearchOpr">=<input type="hidden" name="z_lmid" id="z_lmid" value="="></span></td>
		<td<%= xwfb.lmid.CellAttributes %>>
			<table cellspacing="0" class="ewItemTable"><tr>
				<td><span class="aspmaker">
<select id="x_lmid" name="x_lmid" onchange="ew_UpdateOpt('x_sj','x_lmid',xwfb_search.ar_x_sj);"<%= 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>
<%
jswrk = "" ' Initialise
If IsArray(xwfb.lmid.EditValue) Then
	arwrk = xwfb.lmid.EditValue
	For rowcntwrk = 1 To UBound(arwrk, 2)
		If jswrk <> "" Then jswrk = jswrk & ","
		jswrk = jswrk & "['" & ew_JsEncode(arwrk(0, rowcntwrk)) & "'," ' Value
		jswrk = jswrk & "'" & ew_JsEncode(arwrk(1, rowcntwrk)) & "'," ' Display field 1
		jswrk = jswrk & "'" & ew_JsEncode(arwrk(2, rowcntwrk)) & "'," ' Display field 2
		jswrk = jswrk & "'" & ew_JsEncode(arwrk(3, rowcntwrk)) & "']" ' Filter field
	Next
End If
%>
<script type="text/javascript">
<!--
xwfb_search.ar_x_lmid = [<%= jswrk %>];
//-->
</script>
</span></td>
			</tr></table>
		</td>
	</tr>
	<tr<%= xwfb.sj.RowAttributes %>>
		<td class="ewTableHeader">三级栏目</td>
		<td<%= xwfb.sj.CellAttributes %>><span class="ewSearchOpr">=<input type="hidden" name="z_sj" id="z_sj" value="="></span></td>
		<td<%= xwfb.sj.CellAttributes %>>
			<table cellspacing="0" class="ewItemTable"><tr>
				<td><span class="aspmaker">
<select 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>
<%
jswrk = "" ' Initialise
If IsArray(xwfb.sj.EditValue) Then
	arwrk = xwfb.sj.EditValue
	For rowcntwrk = 1 To UBound(arwrk, 2)
		If jswrk <> "" Then jswrk = jswrk & ","
		jswrk = jswrk & "['" & ew_JsEncode(arwrk(0, rowcntwrk)) & "'," ' Value
		jswrk = jswrk & "'" & ew_JsEncode(arwrk(1, rowcntwrk)) & "'," ' Display field 1
		jswrk = jswrk & "'" & ew_JsEncode(arwrk(2, rowcntwrk)) & "'," ' Display field 2
		jswrk = jswrk & "'" & ew_JsEncode(arwrk(3, rowcntwrk)) & "']" ' Filter field
	Next
End If
%>
<script type="text/javascript">
<!--
xwfb_search.ar_x_sj = [<%= jswrk %>];
//-->
</script>
</span></td>
			</tr></table>
		</td>
	</tr>
	<tr<%= xwfb.xwbt.RowAttributes %>>
		<td class="ewTableHeader">标题</td>
		<td<%= xwfb.xwbt.CellAttributes %>><span class="ewSearchOpr">包含<input type="hidden" name="z_xwbt" id="z_xwbt" value="LIKE"></span></td>
		<td<%= xwfb.xwbt.CellAttributes %>>
			<table cellspacing="0" class="ewItemTable"><tr>
				<td><span class="aspmaker">
<input type="text" name="x_xwbt" id="x_xwbt" size="30" maxlength="50" value="<%= xwfb.xwbt.EditValue %>"<%= xwfb.xwbt.EditAttributes %>>
</span></td>
			</tr></table>
		</td>
	</tr>
	<tr<%= xwfb.fbsj.RowAttributes %>>
		<td class="ewTableHeader">发布时间</td>
		<td<%= xwfb.fbsj.CellAttributes %>><span class="ewSearchOpr">=<input type="hidden" name="z_fbsj" id="z_fbsj" value="="></span></td>
		<td<%= xwfb.fbsj.CellAttributes %>>
			<table cellspacing="0" class="ewItemTable"><tr>
				<td><span class="aspmaker">
<input type="text" name="x_fbsj" id="x_fbsj" value="<%= xwfb.fbsj.EditValue %>"<%= xwfb.fbsj.EditAttributes %>>
&nbsp;<img src="images/calendar.png" id="cal_x_fbsj" name="cal_x_fbsj" alt="选择日期" style="cursor:pointer;cursor:hand;">
<script type="text/javascript">
Calendar.setup({
	inputField : "x_fbsj", // ID of the input field
	ifFormat : "%Y-%m-%d", // the date format
	button : "cal_x_fbsj" // ID of the button
});
</script>
</span></td>
			</tr></table>
		</td>
	</tr>
	<tr<%= xwfb.pic.RowAttributes %>>
		<td class="ewTableHeader">图片信息</td>
		<td<%= xwfb.pic.CellAttributes %>><span class="ewSearchOpr">包含<input type="hidden" name="z_pic" id="z_pic" value="LIKE"></span></td>
		<td<%= xwfb.pic.CellAttributes %>>
			<table cellspacing="0" class="ewItemTable"><tr>
				<td><span class="aspmaker">
<textarea name="x_pic" id="x_pic" cols="45" rows="6"<%= xwfb.pic.EditAttributes %>><%= xwfb.pic.EditValue %></textarea>
<script type="text/javascript">
<!--
ew_DHTMLEditors.push(new ew_DHTMLEditor("x_pic", function() {
	var sBasePath = 'fckeditor/';
	var oFCKeditor = new FCKeditor('x_pic', 45*_width_multiplier, 6*_height_multiplier);
	oFCKeditor.BasePath = sBasePath;
	oFCKeditor.ReplaceTextarea();
	this.active = true;
}));
-->
</script>
</span></td>
			</tr></table>
		</td>
	</tr>
	<tr<%= xwfb.content.RowAttributes %>>
		<td class="ewTableHeader">详细内容</td>
		<td<%= xwfb.content.CellAttributes %>><span class="ewSearchOpr">包含<input type="hidden" name="z_content" id="z_content" value="LIKE"></span></td>
		<td<%= xwfb.content.CellAttributes %>>
			<table cellspacing="0" class="ewItemTable"><tr>
				<td><span class="aspmaker">
<textarea name="x_content" id="x_content" cols="45" rows="5"<%= xwfb.content.EditAttributes %>><%= xwfb.content.EditValue %></textarea>
<script type="text/javascript">
<!--
ew_DHTMLEditors.push(new ew_DHTMLEditor("x_content", function() {
	var sBasePath = 'fckeditor/';
	var oFCKeditor = new FCKeditor('x_content', 45*_width_multiplier, 5*_height_multiplier);
	oFCKeditor.BasePath = sBasePath;
	oFCKeditor.ReplaceTextarea();
	this.active = true;
}));
-->
</script>
</span></td>
			</tr></table>
		</td>
	</tr>
	<tr<%= xwfb.ishome.RowAttributes %>>
		<td class="ewTableHeader">首页显示</td>
		<td<%= xwfb.ishome.CellAttributes %>><span class="ewSearchOpr">=<input type="hidden" name="z_ishome" id="z_ishome" value="="></span></td>
		<td<%= xwfb.ishome.CellAttributes %>>
			<table cellspacing="0" class="ewItemTable"><tr>
				<td><span class="aspmaker">
<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" repeatcolumn="5">
<%
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><input type="radio" name="x_ishome" id="x_ishome" 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></td>
			</tr></table>
		</td>
	</tr>
	<tr<%= xwfb.px.RowAttributes %>>
		<td class="ewTableHeader">排序</td>
		<td<%= xwfb.px.CellAttributes %>><span class="ewSearchOpr">=<input type="hidden" name="z_px" id="z_px" value="="></span></td>
		<td<%= xwfb.px.CellAttributes %>>
			<table cellspacing="0" class="ewItemTable"><tr>
				<td><span class="aspmaker">
<input type="text" name="x_px" id="x_px" size="30" value="<%= xwfb.px.EditValue %>"<%= xwfb.px.EditAttributes %>>
</span></td>
			</tr></table>
		</td>
	</tr>
</table>
</div>
</td></tr></table>
<p>
<input type="button" name="Action" id="Action" value="    搜索    " onclick="ew_SubmitSearch(xwfb_search, this.form);">
<input type="button" name="Reset" id="Reset" value="    重置    " onclick="ew_ClearForm(this.form);">
</form>
<script language="JavaScript" type="text/javascript">
<!--
ew_UpdateOpts([['x_lmid','x_bh',xwfb_search.ar_x_lmid],['x_sj','x_lmid',xwfb_search.ar_x_sj]]);
//-->
</script>
<script type="text/javascript">
<!--
ew_CreateEditor();  // Create DHTML editor(s)
//-->
</script>
<script language="JavaScript" 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

	' 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)
		If Session(EW_SESSION_MESSAGE) <> "" Then ' Append
			Session(EW_SESSION_MESSAGE) = Session(EW_SESSION_MESSAGE) & "<br>" & v
		Else
			Session(EW_SESSION_MESSAGE) = v
		End If
	End Property

	' Show Message
	Public Sub ShowMessage()
		If Message <> "" Then ' Message in Session, display
			Response.Write "<p><span class=""ewMessage"">" & Message & "</span></p>"
			Session(EW_SESSION_MESSAGE) = "" ' Clear message in Session
		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()

		' Initialize table object
		Set xwfb = New cxwfb

		' Initialize other table object
		Set bhlm = New cbhlm

		' Initialize other table object
		Set xwlm = New cxwlm

		' Initialize other table object
		Set zlogin = New czlogin

		' Initialize other table object
		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
		Set Conn = Server.CreateObject("ADODB.Connection")
		Conn.Open EW_DB_CONNECTION_STRING
	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(TableName)

		' Table Permission loaded event
		Call Security.TablePermission_Loaded()
		If Not Security.CanSearch Then
			Call Security.SaveLastUrl()
			Call Page_Terminate("xwfblist.asp")
		End If

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

		' Page load event, used in current page
		Call 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()
		If Not (Conn Is Nothing) Then Conn.Close ' Close Connection
		Set Conn = Nothing
		Set Security = Nothing
		Set xwfb = Nothing

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

	'
	'  Subroutine Page_Terminate (End)
	' ----------------------------------------
	' -----------------------------------------------------------------
	' Page main processing
	'
	Sub Page_Main()
		Set ObjForm = New cFormObj
		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 = ""
						Message = gsSearchError
					End If
					If sSrchStr <> "" Then
						Set ObjForm = Nothing ' Close form object
						sSrchStr = xwfb.UrlParm(sSrchStr)
						Call Page_Terminate("xwfblist.asp" & "?" & sSrchStr) ' Go to list page
					End If
			End Select
		End If

		' Close form object
		Set ObjForm = Nothing

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

		' Field id
		Call BuildSearchUrl(sSrchUrl, xwfb.id)

		' Field bh
		Call BuildSearchUrl(sSrchUrl, xwfb.bh)

		' Field lmid
		Call BuildSearchUrl(sSrchUrl, xwfb.lmid)

		' Field sj
		Call BuildSearchUrl(sSrchUrl, xwfb.sj)

		' Field xwbt
		Call BuildSearchUrl(sSrchUrl, xwfb.xwbt)

		' Field fbsj
		Call BuildSearchUrl(sSrchUrl, xwfb.fbsj)

		' Field pic
		Call BuildSearchUrl(sSrchUrl, xwfb.pic)

		' Field content
		Call BuildSearchUrl(sSrchUrl, xwfb.content)

		' Field ishome
		Call BuildSearchUrl(sSrchUrl, xwfb.ishome)

		' Field px
		Call BuildSearchUrl(sSrchUrl, xwfb.px)
		BuildAdvancedSearch = sSrchUrl
	End Function

	' -----------------------------------------------------------------
	' Function to build search URL
	'
	Sub BuildSearchUrl(Url, Fld)
		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))
		If FldOpr = "BETWEEN" Then
			IsValidValue = (Fld.FldDataType <> EW_DATATYPE_NUMBER) Or _
				(Fld.FldDataType = EW_DATATYPE_NUMBER And IsNumeric(FldVal) And IsNumeric(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
		ElseIf FldOpr = "IS NULL" Or FldOpr = "IS NOT NULL" Then
			sWrk = "x_" & FldParm & "=" & Server.URLEncode(FldVal) & _
				"&z_" & FldParm & "=" & Server.URLEncode(FldOpr)
		Else
			IsValidValue = (Fld.FldDataType <> EW_DATATYPE_NUMBER) Or _
				(Fld.FldDataType = EW_DATATYPE_NUMBER And IsNumeric(FldVal))
			If FldVal <> "" And IsValidValue And ew_IsValidOpr(FldOpr, Fld.FldDataType) Then
				sWrk = "x_" & FldParm & "=" & Server.URLEncode(FldVal) & _
					"&z_" & FldParm & "=" & Server.URLEncode(FldOpr)
			End If
			IsValidValue = (Fld.FldDataType <> EW_DATATYPE_NUMBER) Or _
				(Fld.FldDataType = EW_DATATYPE_NUMBER And IsNumeric(FldVal2))
			If FldVal2 <> "" And IsValidValue And ew_IsValidOpr(FldOpr2, Fld.FldDataType) Then
				If sWrk <> "" Then sWrk = sWrk & "&v_" & FldParm & "=" & FldCond & "&"
				sWrk = sWrk & "y_" & FldParm & "=" & Server.URLEncode(FldVal2) & _
					"&w_" & FldParm & "=" & Server.URLEncode(FldOpr2)
			End If
		End If
		If sWrk <> "" Then
			If Url <> "" Then Url = Url & "&"
			Url = Url & sWrk
		End If
	End Sub

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

		' Load search values
		xwfb.id.AdvancedSearch.SearchValue = ObjForm.GetValue("x_id")
		xwfb.bh.AdvancedSearch.SearchValue = ObjForm.GetValue("x_bh")
		xwfb.lmid.AdvancedSearch.SearchValue = ObjForm.GetValue("x_lmid")
		xwfb.sj.AdvancedSearch.SearchValue = ObjForm.GetValue("x_sj")
		xwfb.xwbt.AdvancedSearch.SearchValue = ObjForm.GetValue("x_xwbt")
		xwfb.fbsj.AdvancedSearch.SearchValue = ObjForm.GetValue("x_fbsj")
		xwfb.pic.AdvancedSearch.SearchValue = ObjForm.GetValue("x_pic")
		xwfb.content.AdvancedSearch.SearchValue = ObjForm.GetValue("x_content")
		xwfb.ishome.AdvancedSearch.SearchValue = ObjForm.GetValue("x_ishome")
		xwfb.px.AdvancedSearch.SearchValue = ObjForm.GetValue("x_px")
	End Function

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

		' Call Row Rendering event
		Call xwfb.Row_Rendering()

		' ---------------------------------------
		'  Common render codes for all row types
		' ---------------------------------------
		' id

		xwfb.id.CellCssStyle = ""
		xwfb.id.CellCssClass = ""

		' bh
		xwfb.bh.CellCssStyle = ""
		xwfb.bh.CellCssClass = ""

		' lmid
		xwfb.lmid.CellCssStyle = ""
		xwfb.lmid.CellCssClass = ""

		' sj
		xwfb.sj.CellCssStyle = ""
		xwfb.sj.CellCssClass = ""

		' xwbt
		xwfb.xwbt.CellCssStyle = ""
		xwfb.xwbt.CellCssClass = ""

		' fbsj
		xwfb.fbsj.CellCssStyle = ""
		xwfb.fbsj.CellCssClass = ""

		' pic
		xwfb.pic.CellCssStyle = ""
		xwfb.pic.CellCssClass = ""

		' content
		xwfb.content.CellCssStyle = ""
		xwfb.content.CellCssClass = ""

		' ishome
		xwfb.ishome.CellCssStyle = ""
		xwfb.ishome.CellCssClass = ""

		' px
		xwfb.px.CellCssStyle = ""
		xwfb.px.CellCssClass = ""

		' -----------
		'  View  Row
		' -----------

		If xwfb.RowType = EW_ROWTYPE_VIEW Then ' View row

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

			' bh
			If xwfb.bh.CurrentValue & "" <> "" Then
				sSqlWrk = "SELECT [bhmc] FROM [bhlm] WHERE [bh] = " & ew_AdjustSql(xwfb.bh.CurrentValue) & ""
				Set RsWrk = Conn.Execute(sSqlWrk)
				If Not RsWrk.Eof Then
					xwfb.bh.ViewValue = RsWrk("bhmc")
				Else
					xwfb.bh.ViewValue = xwfb.bh.CurrentValue
				End If
				RsWrk.Close
				Set RsWrk = Nothing
			Else
				xwfb.bh.ViewValue = Null
			End If
			xwfb.bh.CssStyle = ""
			xwfb.bh.CssClass = ""
			xwfb.bh.ViewCustomAttributes = ""

			' lmid
			If xwfb.lmid.CurrentValue & "" <> "" Then
				sSqlWrk = "SELECT [lmmc] FROM [xwlm] WHERE [lmid] = " & ew_AdjustSql(xwfb.lmid.CurrentValue) & ""
				Set RsWrk = Conn.Execute(sSqlWrk)
				If Not RsWrk.Eof Then
					xwfb.lmid.ViewValue = RsWrk("lmmc")
				Else
					xwfb.lmid.ViewValue = xwfb.lmid.CurrentValue
				End If
				RsWrk.Close
				Set RsWrk = Nothing
			Else
				xwfb.lmid.ViewValue = Null
			End If
			xwfb.lmid.CssStyle = ""
			xwfb.lmid.CssClass = ""
			xwfb.lmid.ViewCustomAttributes = ""

			' sj
			If xwfb.sj.CurrentValue & "" <> "" Then
				sSqlWrk = "SELECT [sjmc] FROM [sjlm] WHERE [id] = " & ew_AdjustSql(xwfb.sj.CurrentValue) & ""
				Set RsWrk = Conn.Execute(sSqlWrk)
				If Not RsWrk.Eof Then
					xwfb.sj.ViewValue = RsWrk("sjmc")
				Else
					xwfb.sj.ViewValue = xwfb.sj.CurrentValue
				End If
				RsWrk.Close
				Set RsWrk = Nothing
			Else
				xwfb.sj.ViewValue = Null
			End If
			xwfb.sj.CssStyle = ""
			xwfb.sj.CssClass = ""
			xwfb.sj.ViewCustomAttributes = ""

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

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

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

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

			' ishome
			If Not IsNull(xwfb.ishome.CurrentValue) Then
				Select Case xwfb.ishome.CurrentValue
					Case "0"
						xwfb.ishome.ViewValue = "否"
					Case "1"
						xwfb.ishome.ViewValue = "是"
					Case Else
						xwfb.ishome.ViewValue = xwfb.ishome.CurrentValue
				End Select
			Else
				xwfb.ishome.ViewValue = Null
			End If
			xwfb.ishome.CssStyle = ""
			xwfb.ishome.CssClass = ""
			xwfb.ishome.ViewCustomAttributes = ""

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

			' View refer script
			' id

			xwfb.id.HrefValue = ""

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

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

		ElseIf xwfb.RowType = EW_ROWTYPE_SEARCH Then ' Search row

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

			' bh
			xwfb.bh.EditCustomAttributes = ""
			sSqlWrk = "SELECT [bh], [bhmc], '' AS Disp2Fld, '' AS SelectFilterFld FROM [bhlm]"
			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("", "请选择"))
			xwfb.bh.EditValue = arwrk

			' lmid
			xwfb.lmid.EditCustomAttributes = ""
			sSqlWrk = "SELECT [lmid], [lmmc], '' AS Disp2Fld, [bh] FROM [xwlm]"
			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("", "请选择", ""))
			xwfb.lmid.EditValue = arwrk

			' sj
			xwfb.sj.EditCustomAttributes = ""
			sSqlWrk = "SELECT [id], [sjmc], '' AS Disp2Fld, [lmid] FROM [sjlm]"
			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("", "请选择", ""))
			xwfb.sj.EditValue = arwrk

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

			' fbsj
			xwfb.fbsj.EditCustomAttributes = ""
			xwfb.fbsj.EditValue = xwfb.fbsj.AdvancedSearch.SearchValue

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

			' content
			xwfb.content.EditCustomAttributes = ""
			xwfb.content.EditValue = ew_HtmlEncode(xwfb.content.AdvancedSearch.SearchValue)

			' ishome
			xwfb.ishome.EditCustomAttributes = ""
			Redim arwrk(1, 1)
			arwrk(0, 0) = "0"
			arwrk(1, 0) = "否"
			arwrk(0, 1) = "1"
			arwrk(1, 1) = "是"
			xwfb.ishome.EditValue = arwrk

			' px
			xwfb.px.EditCustomAttributes = ""
			xwfb.px.EditValue = ew_HtmlEncode(xwfb.px.AdvancedSearch.SearchValue)
		End If

		' Call Row Rendered event
		Call xwfb.Row_Rendered()
	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
			If gsSearchError <> "" Then gsSearchError = gsSearchError & "<br>"
			gsSearchError = gsSearchError & "无效的整数型 - 编号"
		End If
		If Not ew_CheckDate(xwfb.fbsj.AdvancedSearch.SearchValue) Then
			If gsSearchError <> "" Then gsSearchError = gsSearchError & "<br>"
			gsSearchError = gsSearchError & "日期无效, 例 ： 年-月-日 - 发布时间"
		End If
		If Not ew_CheckInteger(xwfb.px.AdvancedSearch.SearchValue) Then
			If gsSearchError <> "" Then gsSearchError = gsSearchError & "<br>"
			gsSearchError = gsSearchError & "无效的整数型 - 排序"
		End If

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

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

	' -----------------------------------------------------------------
	' Load advanced search
	'
	Function LoadAdvancedSearch()
		xwfb.id.AdvancedSearch.SearchValue = xwfb.GetAdvancedSearch("x_id")
		xwfb.bh.AdvancedSearch.SearchValue = xwfb.GetAdvancedSearch("x_bh")
		xwfb.lmid.AdvancedSearch.SearchValue = xwfb.GetAdvancedSearch("x_lmid")
		xwfb.sj.AdvancedSearch.SearchValue = xwfb.GetAdvancedSearch("x_sj")
		xwfb.xwbt.AdvancedSearch.SearchValue = xwfb.GetAdvancedSearch("x_xwbt")
		xwfb.fbsj.AdvancedSearch.SearchValue = xwfb.GetAdvancedSearch("x_fbsj")
		xwfb.pic.AdvancedSearch.SearchValue = xwfb.GetAdvancedSearch("x_pic")
		xwfb.content.AdvancedSearch.SearchValue = xwfb.GetAdvancedSearch("x_content")
		xwfb.ishome.AdvancedSearch.SearchValue = xwfb.GetAdvancedSearch("x_ishome")
		xwfb.px.AdvancedSearch.SearchValue = xwfb.GetAdvancedSearch("x_px")
End Function

	' Page Load event
	Sub Page_Load()

		'Response.Write "Page Load"
	End Sub

	' Page Unload event
	Sub Page_Unload()

		'Response.Write "Page Unload"
	End Sub

	' Form Custom Validate event
	Function Form_CustomValidate(CustomError)

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