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

' Define page object
Dim sjlm_list
Set sjlm_list = New csjlm_list
Set Page = sjlm_list

' Page init processing
sjlm_list.Page_Init()

' Page main processing
sjlm_list.Page_Main()

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

' Page Rendering event
sjlm_list.Page_Render()
%>
<!--#include file="header.asp"-->
<% If sjlm.Export = "" Then %>
<script type="text/javascript">
// Page object
var sjlm_list = new ew_Page("sjlm_list");
sjlm_list.PageID = "list"; // Page ID
var EW_PAGE_ID = sjlm_list.PageID; // For backward compatibility
// Form object
var fsjlmlist = new ew_Form("fsjlmlist");
fsjlmlist.FormKeyCountName = '<%= sjlm_list.FormKeyCountName %>';
// Form_CustomValidate event
fsjlmlist.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 %>
fsjlmlist.ValidateRequired = true; // Use JavaScript validation
<% Else %>
fsjlmlist.ValidateRequired = false; // No JavaScript validation
<% End If %>
// Dynamic selection lists
fsjlmlist.Lists["x_bh"] = {"LinkField":"x_bh","Ajax":null,"AutoFill":false,"DisplayFields":["x_bhmc","","",""],"ParentFields":[],"FilterFields":[],"Options":[]};
fsjlmlist.Lists["x_lmid"] = {"LinkField":"x_lmid","Ajax":null,"AutoFill":false,"DisplayFields":["x_lmmc","","",""],"ParentFields":[],"FilterFields":[],"Options":[]};
// Form object for search
</script>
<script type="text/javascript">
// Write your client script here, no need to add script tags.
</script>
<% End If %>
<% If sjlm.Export = "" Then %>
<% Breadcrumb.Render() %>
<% End If %>
<% If sjlm.CurrentMasterTable = "" And sjlm_list.ExportOptions.Visible Then %>
<div class="ewListExportOptions"><% sjlm_list.ExportOptions.Render "body", "", "", "", "", "" %></div>
<% End If %>
<% If (sjlm.Export = "") Or (EW_EXPORT_MASTER_RECORD And sjlm.Export = "print") Then %>
<%
gsMasterReturnUrl = "xwlmlist.asp"
If sjlm_list.DbMasterFilter <> "" And sjlm.CurrentMasterTable = "xwlm" Then
	If sjlm_list.MasterRecordExists Then
		If sjlm.CurrentMasterTable = sjlm.TableVar Then gsMasterReturnUrl = gsMasterReturnUrl & "?" & EW_TABLE_SHOW_MASTER & "="
%>
<% If sjlm_list.ExportOptions.Visible Then %>
<div class="ewListExportOptions"><% sjlm_list.ExportOptions.Render "body", "", "", "", "", "" %></div>
<% End If %>
<!--#include file="xwlmmaster.asp"-->
<%
	End If
End If
%>
<% End If %>
<%

' Load recordset
Set sjlm_list.Recordset = sjlm_list.LoadRecordset()
	sjlm_list.TotalRecs = sjlm_list.Recordset.RecordCount
	sjlm_list.StartRec = 1
	If sjlm_list.DisplayRecs <= 0 Then ' Display all records
		sjlm_list.DisplayRecs = sjlm_list.TotalRecs
	End If
	If Not (sjlm.ExportAll And sjlm.Export <> "") Then
		sjlm_list.SetUpStartRec() ' Set up start record position
	End If
sjlm_list.RenderOtherOptions()
%>
<% sjlm_list.ShowPageHeader() %>
<% sjlm_list.ShowMessage %>
<table class="ewGrid"><tr><td class="ewGridContent">
<% If sjlm.Export = "" Then %>
<div class="ewGridUpperPanel">
<% If sjlm.CurrentAction <> "gridadd" And sjlm.CurrentAction <> "gridedit" Then %>
<form name="ewPagerForm" class="ewForm form-inline" action="<%= ew_CurrentPage %>">
<table class="ewPager">
<tr><td>
<% If Not IsObject(sjlm_list.Pager) Then Set sjlm_list.Pager = ew_NewPrevNextPager(sjlm_list.StartRec, sjlm_list.DisplayRecs, sjlm_list.TotalRecs) %>
<% If sjlm_list.Pager.RecordCount > 0 Then %>
<table class="ewStdTable"><tbody><tr><td>
	<%= Language.Phrase("Page") %>&nbsp;
<div class="input-prepend input-append">
<!--first page button-->
	<% If sjlm_list.Pager.FirstButton.Enabled Then %>
	<a class="btn btn-small" href="<%= sjlm_list.PageUrl %>start=<%= sjlm_list.Pager.FirstButton.Start %>"><i class="icon-step-backward"></i></a>
	<% Else %>
	<a class="btn btn-small disabled"><i class="icon-step-backward"></i></a>
	<% End If %>
<!--previous page button-->
	<% If sjlm_list.Pager.PrevButton.Enabled Then %>
	<a class="btn btn-small" href="<%= sjlm_list.PageUrl %>start=<%= sjlm_list.Pager.PrevButton.Start %>"><i class="icon-prev"></i></a>
	<% Else %>
	<a class="btn btn-small disabled"><i class="icon-prev"></i></a>
	<% End If %>
<!--current page number-->
	<input class="input-mini" type="text" name="<%= EW_TABLE_PAGE_NO %>" value="<%= sjlm_list.Pager.CurrentPage %>">
<!--next page button-->
	<% If sjlm_list.Pager.NextButton.Enabled Then %>
	<a class="btn btn-small" href="<%= sjlm_list.PageUrl %>start=<%= sjlm_list.Pager.NextButton.Start %>"><i class="icon-play"></i></a>
	<% Else %>
	<a class="btn btn-small disabled"><i class="icon-play"></i></a>
	<% End If %>
<!--last page button-->
	<% If sjlm_list.Pager.LastButton.Enabled Then %>
	<a class="btn btn-small" href="<%= sjlm_list.PageUrl %>start=<%= sjlm_list.Pager.LastButton.Start %>"><i class="icon-step-forward"></i></a>
	<% Else %>
	<a class="btn btn-small disabled"><i class="icon-step-forward"></i></a>
	<% End If %>
</div>
	&nbsp;<%= Language.Phrase("of") %>&nbsp;<%= sjlm_list.Pager.PageCount %>
</td>
<td>
	&nbsp;&nbsp;&nbsp;&nbsp;
	<%= Language.Phrase("Record") %>&nbsp;<%= sjlm_list.Pager.FromIndex %>&nbsp;<%= Language.Phrase("To") %>&nbsp;<%= sjlm_list.Pager.ToIndex %>&nbsp;<%= Language.Phrase("Of") %>&nbsp;<%= sjlm_list.Pager.RecordCount %>
</td>
</tr></tbody></table>
<% Else %>
	<% If Security.CanList Then %>
	<% If sjlm_list.SearchWhere = "0=101" Then %>
	<p><%= Language.Phrase("EnterSearchCriteria") %></p>
	<% Else %>
	<p><%= Language.Phrase("NoRecord") %></p>
	<% End If %>
	<% Else %>
	<p><%= Language.Phrase("NoPermission") %></p>
	<% End If %>
<% End If %>
</td>
<% If sjlm_list.TotalRecs > 0 Then %>
<td>
	&nbsp;&nbsp;&nbsp;&nbsp;
<input type="hidden" name="t" value="sjlm">
<select name="<%= EW_TABLE_REC_PER_PAGE %>" class="input-small" onchange="this.form.submit();">
<option value="20"<% If sjlm_list.DisplayRecs = 20 Then %> selected="selected"<% End If %>>20</option>
<option value="30"<% If sjlm_list.DisplayRecs = 30 Then %> selected="selected"<% End If %>>30</option>
<option value="40"<% If sjlm_list.DisplayRecs = 40 Then %> selected="selected"<% End If %>>40</option>
<option value="ALL"<% If sjlm.RecordsPerPage = -1 Then %> selected="selected"<% End If %>><%= Language.Phrase("AllRecords") %></option>
</select>
</td>
<% End If %>
</tr></table>
</form>
<% End If %>
<div class="ewListOtherOptions">
<%
	sjlm_list.AddEditOptions.Render "body", "", "", "", "", ""
	sjlm_list.DetailOptions.Render "body", "", "", "", "", ""
	sjlm_list.ActionOptions.Render "body", "", "", "", "", ""
%>
</div>
</div>
<% End If %>
<form name="fsjlmlist" id="fsjlmlist" class="ewForm form-inline" action="<%= ew_CurrentPage %>" method="post">
<input type="hidden" name="t" value="sjlm">
<div id="gmp_sjlm" class="ewGridMiddlePanel">
<% If sjlm_list.TotalRecs > 0 Then %>
<table id="tbl_sjlmlist" class="ewTable ewTableSeparate">
<%= sjlm.TableCustomInnerHtml %>
<thead><!-- Table header -->
	<tr class="ewTableHeader">
<%
Call sjlm_list.RenderListOptions()

' Render list options (header, left)
sjlm_list.ListOptions.Render "header", "left", "", "", "", ""
%>
<% If sjlm.id.Visible Then ' id %>
	<% If sjlm.SortUrl(sjlm.id) = "" Then %>
		<td><div id="elh_sjlm_id" class="sjlm_id"><div class="ewTableHeaderCaption"><%= sjlm.id.FldCaption %></div></div></td>
	<% Else %>
		<td><div class="ewPointer" onclick="ew_Sort(event,'<%= sjlm.SortUrl(sjlm.id) %>',1);"><div id="elh_sjlm_id" class="sjlm_id">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= sjlm.id.FldCaption %></span><span class="ewTableHeaderSort"><% If sjlm.id.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf sjlm.id.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<% If sjlm.bh.Visible Then ' bh %>
	<% If sjlm.SortUrl(sjlm.bh) = "" Then %>
		<td><div id="elh_sjlm_bh" class="sjlm_bh"><div class="ewTableHeaderCaption"><%= sjlm.bh.FldCaption %></div></div></td>
	<% Else %>
		<td><div class="ewPointer" onclick="ew_Sort(event,'<%= sjlm.SortUrl(sjlm.bh) %>',1);"><div id="elh_sjlm_bh" class="sjlm_bh">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= sjlm.bh.FldCaption %></span><span class="ewTableHeaderSort"><% If sjlm.bh.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf sjlm.bh.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<% If sjlm.lmid.Visible Then ' lmid %>
	<% If sjlm.SortUrl(sjlm.lmid) = "" Then %>
		<td><div id="elh_sjlm_lmid" class="sjlm_lmid"><div class="ewTableHeaderCaption"><%= sjlm.lmid.FldCaption %></div></div></td>
	<% Else %>
		<td><div class="ewPointer" onclick="ew_Sort(event,'<%= sjlm.SortUrl(sjlm.lmid) %>',1);"><div id="elh_sjlm_lmid" class="sjlm_lmid">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= sjlm.lmid.FldCaption %></span><span class="ewTableHeaderSort"><% If sjlm.lmid.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf sjlm.lmid.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<% If sjlm.sjmc.Visible Then ' sjmc %>
	<% If sjlm.SortUrl(sjlm.sjmc) = "" Then %>
		<td><div id="elh_sjlm_sjmc" class="sjlm_sjmc"><div class="ewTableHeaderCaption"><%= sjlm.sjmc.FldCaption %></div></div></td>
	<% Else %>
		<td><div class="ewPointer" onclick="ew_Sort(event,'<%= sjlm.SortUrl(sjlm.sjmc) %>',1);"><div id="elh_sjlm_sjmc" class="sjlm_sjmc">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= sjlm.sjmc.FldCaption %></span><span class="ewTableHeaderSort"><% If sjlm.sjmc.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf sjlm.sjmc.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<% If sjlm.sjmc2.Visible Then ' sjmc2 %>
	<% If sjlm.SortUrl(sjlm.sjmc2) = "" Then %>
		<td><div id="elh_sjlm_sjmc2" class="sjlm_sjmc2"><div class="ewTableHeaderCaption"><%= sjlm.sjmc2.FldCaption %></div></div></td>
	<% Else %>
		<td><div class="ewPointer" onclick="ew_Sort(event,'<%= sjlm.SortUrl(sjlm.sjmc2) %>',1);"><div id="elh_sjlm_sjmc2" class="sjlm_sjmc2">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= sjlm.sjmc2.FldCaption %></span><span class="ewTableHeaderSort"><% If sjlm.sjmc2.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf sjlm.sjmc2.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<% If sjlm.px.Visible Then ' px %>
	<% If sjlm.SortUrl(sjlm.px) = "" Then %>
		<td><div id="elh_sjlm_px" class="sjlm_px"><div class="ewTableHeaderCaption"><%= sjlm.px.FldCaption %></div></div></td>
	<% Else %>
		<td><div class="ewPointer" onclick="ew_Sort(event,'<%= sjlm.SortUrl(sjlm.px) %>',1);"><div id="elh_sjlm_px" class="sjlm_px">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= sjlm.px.FldCaption %></span><span class="ewTableHeaderSort"><% If sjlm.px.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf sjlm.px.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<% If sjlm.urllb.Visible Then ' urllb %>
	<% If sjlm.SortUrl(sjlm.urllb) = "" Then %>
		<td><div id="elh_sjlm_urllb" class="sjlm_urllb"><div class="ewTableHeaderCaption"><%= sjlm.urllb.FldCaption %></div></div></td>
	<% Else %>
		<td><div class="ewPointer" onclick="ew_Sort(event,'<%= sjlm.SortUrl(sjlm.urllb) %>',1);"><div id="elh_sjlm_urllb" class="sjlm_urllb">
			<div class="ewTableHeaderBtn"><span class="ewTableHeaderCaption"><%= sjlm.urllb.FldCaption %></span><span class="ewTableHeaderSort"><% If sjlm.urllb.Sort = "ASC" Then %><span class="caret ewSortUp"></span><% ElseIf sjlm.urllb.Sort = "DESC" Then %><span class="caret"></span><% End If %></span></div>
        </div></div></td>
	<% End If %>
<% End If %>		
<%

' Render list options (header, right)
sjlm_list.ListOptions.Render "header", "right", "", "", "", ""
%>
	</tr>
</thead>
<tbody><!-- Table body -->
<%
If (sjlm.ExportAll And sjlm.Export <> "") Then
	sjlm_list.StopRec = sjlm_list.TotalRecs
Else

	' Set the last record to display
	If sjlm_list.TotalRecs > sjlm_list.StartRec + sjlm_list.DisplayRecs - 1 Then
		sjlm_list.StopRec = sjlm_list.StartRec + sjlm_list.DisplayRecs - 1
	Else
		sjlm_list.StopRec = sjlm_list.TotalRecs
	End If
End If

' Move to first record
sjlm_list.RecCnt = sjlm_list.StartRec - 1
If Not sjlm_list.Recordset.Eof Then
	sjlm_list.Recordset.MoveFirst
	If sjlm_list.StartRec > 1 Then sjlm_list.Recordset.Move sjlm_list.StartRec - 1
ElseIf Not sjlm.AllowAddDeleteRow And sjlm_list.StopRec = 0 Then
	sjlm_list.StopRec = sjlm.GridAddRowCount
End If

' Initialize Aggregate
sjlm.RowType = EW_ROWTYPE_AGGREGATEINIT
Call sjlm.ResetAttrs()
Call sjlm_list.RenderRow()
sjlm_list.RowCnt = 0

' Output date rows
Do While CLng(sjlm_list.RecCnt) < CLng(sjlm_list.StopRec)
	sjlm_list.RecCnt = sjlm_list.RecCnt + 1
	If CLng(sjlm_list.RecCnt) >= CLng(sjlm_list.StartRec) Then
		sjlm_list.RowCnt = sjlm_list.RowCnt + 1

	' Set up key count
	sjlm_list.KeyCount = sjlm_list.RowIndex
	Call sjlm.ResetAttrs()
	sjlm.CssClass = ""
	If sjlm.CurrentAction = "gridadd" Then
	Else
		Call sjlm_list.LoadRowValues(sjlm_list.Recordset) ' Load row values
	End If
	sjlm.RowType = EW_ROWTYPE_VIEW ' Render view

	' Set up row id / data-rowindex
	sjlm.RowAttrs.AddAttributes Array(Array("data-rowindex", sjlm_list.RowCnt), Array("id", "r" & sjlm_list.RowCnt & "_sjlm"), Array("data-rowtype", sjlm.RowType))

	' Render row
	Call sjlm_list.RenderRow()

	' Render list options
	Call sjlm_list.RenderListOptions()
%>
	<tr<%= sjlm.RowAttributes %>>
<%

' Render list options (body, left)
sjlm_list.ListOptions.Render "body", "left", sjlm_list.RowCnt, "", "", ""
%>
	<% If sjlm.id.Visible Then ' id %>
		<td<%= sjlm.id.CellAttributes %>>
<span<%= sjlm.id.ViewAttributes %>>
<%= sjlm.id.ListViewValue %>
</span>
<a id="<%= sjlm_list.PageObjName & "_row_" & sjlm_list.RowCnt %>"></a></td>
	<% End If %>
	<% If sjlm.bh.Visible Then ' bh %>
		<td<%= sjlm.bh.CellAttributes %>>
<span<%= sjlm.bh.ViewAttributes %>>
<%= sjlm.bh.ListViewValue %>
</span>
</td>
	<% End If %>
	<% If sjlm.lmid.Visible Then ' lmid %>
		<td<%= sjlm.lmid.CellAttributes %>>
<span<%= sjlm.lmid.ViewAttributes %>>
<%= sjlm.lmid.ListViewValue %>
</span>
</td>
	<% End If %>
	<% If sjlm.sjmc.Visible Then ' sjmc %>
		<td<%= sjlm.sjmc.CellAttributes %>>
<span<%= sjlm.sjmc.ViewAttributes %>>
<%= sjlm.sjmc.ListViewValue %>
</span>
</td>
	<% End If %>
	<% If sjlm.sjmc2.Visible Then ' sjmc2 %>
		<td<%= sjlm.sjmc2.CellAttributes %>>
<span<%= sjlm.sjmc2.ViewAttributes %>>
<%= sjlm.sjmc2.ListViewValue %>
</span>
</td>
	<% End If %>
	<% If sjlm.px.Visible Then ' px %>
		<td<%= sjlm.px.CellAttributes %>>
<span<%= sjlm.px.ViewAttributes %>>
<%= sjlm.px.ListViewValue %>
</span>
</td>
	<% End If %>
	<% If sjlm.urllb.Visible Then ' urllb %>
		<td<%= sjlm.urllb.CellAttributes %>>
<span<%= sjlm.urllb.ViewAttributes %>>
<%= sjlm.urllb.ListViewValue %>
</span>
</td>
	<% End If %>
<%

' Render list options (body, right)
sjlm_list.ListOptions.Render "body", "right", sjlm_list.RowCnt, "", "", ""
%>
	</tr>
<%
	End If
	If sjlm.CurrentAction <> "gridadd" Then
		sjlm_list.Recordset.MoveNext()
	End If
Loop
%>
</tbody>
</table>
<% End If %>
<% If sjlm.CurrentAction = "" Then %>
<input type="hidden" name="a_list" id="a_list" value="">
<% End If %>
</div>
</form>
<%

' Close recordset and connection
sjlm_list.Recordset.Close
Set sjlm_list.Recordset = Nothing
%>
<% If sjlm_list.TotalRecs > 0 Then %>
<% If sjlm.Export = "" Then %>
<div class="ewGridLowerPanel">
<% If sjlm.CurrentAction <> "gridadd" And sjlm.CurrentAction <> "gridedit" Then %>
<form name="ewPagerForm" class="ewForm form-inline" action="<%= ew_CurrentPage %>">
<table class="ewPager">
<tr><td>
<% If Not IsObject(sjlm_list.Pager) Then Set sjlm_list.Pager = ew_NewPrevNextPager(sjlm_list.StartRec, sjlm_list.DisplayRecs, sjlm_list.TotalRecs) %>
<% If sjlm_list.Pager.RecordCount > 0 Then %>
<table class="ewStdTable"><tbody><tr><td>
	<%= Language.Phrase("Page") %>&nbsp;
<div class="input-prepend input-append">
<!--first page button-->
	<% If sjlm_list.Pager.FirstButton.Enabled Then %>
	<a class="btn btn-small" href="<%= sjlm_list.PageUrl %>start=<%= sjlm_list.Pager.FirstButton.Start %>"><i class="icon-step-backward"></i></a>
	<% Else %>
	<a class="btn btn-small disabled"><i class="icon-step-backward"></i></a>
	<% End If %>
<!--previous page button-->
	<% If sjlm_list.Pager.PrevButton.Enabled Then %>
	<a class="btn btn-small" href="<%= sjlm_list.PageUrl %>start=<%= sjlm_list.Pager.PrevButton.Start %>"><i class="icon-prev"></i></a>
	<% Else %>
	<a class="btn btn-small disabled"><i class="icon-prev"></i></a>
	<% End If %>
<!--current page number-->
	<input class="input-mini" type="text" name="<%= EW_TABLE_PAGE_NO %>" value="<%= sjlm_list.Pager.CurrentPage %>">
<!--next page button-->
	<% If sjlm_list.Pager.NextButton.Enabled Then %>
	<a class="btn btn-small" href="<%= sjlm_list.PageUrl %>start=<%= sjlm_list.Pager.NextButton.Start %>"><i class="icon-play"></i></a>
	<% Else %>
	<a class="btn btn-small disabled"><i class="icon-play"></i></a>
	<% End If %>
<!--last page button-->
	<% If sjlm_list.Pager.LastButton.Enabled Then %>
	<a class="btn btn-small" href="<%= sjlm_list.PageUrl %>start=<%= sjlm_list.Pager.LastButton.Start %>"><i class="icon-step-forward"></i></a>
	<% Else %>
	<a class="btn btn-small disabled"><i class="icon-step-forward"></i></a>
	<% End If %>
</div>
	&nbsp;<%= Language.Phrase("of") %>&nbsp;<%= sjlm_list.Pager.PageCount %>
</td>
<td>
	&nbsp;&nbsp;&nbsp;&nbsp;
	<%= Language.Phrase("Record") %>&nbsp;<%= sjlm_list.Pager.FromIndex %>&nbsp;<%= Language.Phrase("To") %>&nbsp;<%= sjlm_list.Pager.ToIndex %>&nbsp;<%= Language.Phrase("Of") %>&nbsp;<%= sjlm_list.Pager.RecordCount %>
</td>
</tr></tbody></table>
<% Else %>
	<% If Security.CanList Then %>
	<% If sjlm_list.SearchWhere = "0=101" Then %>
	<p><%= Language.Phrase("EnterSearchCriteria") %></p>
	<% Else %>
	<p><%= Language.Phrase("NoRecord") %></p>
	<% End If %>
	<% Else %>
	<p><%= Language.Phrase("NoPermission") %></p>
	<% End If %>
<% End If %>
</td>
<% If sjlm_list.TotalRecs > 0 Then %>
<td>
	&nbsp;&nbsp;&nbsp;&nbsp;
<input type="hidden" name="t" value="sjlm">
<select name="<%= EW_TABLE_REC_PER_PAGE %>" class="input-small" onchange="this.form.submit();">
<option value="20"<% If sjlm_list.DisplayRecs = 20 Then %> selected="selected"<% End If %>>20</option>
<option value="30"<% If sjlm_list.DisplayRecs = 30 Then %> selected="selected"<% End If %>>30</option>
<option value="40"<% If sjlm_list.DisplayRecs = 40 Then %> selected="selected"<% End If %>>40</option>
<option value="ALL"<% If sjlm.RecordsPerPage = -1 Then %> selected="selected"<% End If %>><%= Language.Phrase("AllRecords") %></option>
</select>
</td>
<% End If %>
</tr></table>
</form>
<% End If %>
<div class="ewListOtherOptions">
<%
	sjlm_list.AddEditOptions.Render "body", "bottom", "", "", "", ""
	sjlm_list.DetailOptions.Render "body", "bottom", "", "", "", ""
	sjlm_list.ActionOptions.Render "body", "bottom", "", "", "", ""
%>
</div>
</div>
<% End If %>
<% End If %>
</td></tr></table>
<% If sjlm.Export = "" Then %>
<script type="text/javascript">
fsjlmlist.Init();
<% If EW_MOBILE_REFLOW And ew_IsMobile() Then %>
ew_Reflow();
<% End If %>
</script>
<% End If %>
<%
sjlm_list.ShowPageFooter()
If EW_DEBUG_ENABLED Then Response.Write ew_DebugMsg()
%>
<% If sjlm.Export = "" Then %>
<script type="text/javascript">
// Write your table-specific startup script here
// document.write("page loaded");
</script>
<% End If %>
<!--#include file="footer.asp"-->
<%

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

' -----------------------------------------------------------------
' Page Class
'
Class csjlm_list

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

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

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

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

	' Grid form hidden field names
	Dim FormName
	Dim FormActionName
	Dim FormKeyName
	Dim FormOldKeyName
	Dim FormBlankRowName
	Dim FormKeyCountName

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

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

	' Common urls
	Dim AddUrl
	Dim EditUrl
	Dim CopyUrl
	Dim DeleteUrl
	Dim ViewUrl
	Dim ListUrl

	' Export urls
	Dim ExportPrintUrl
	Dim ExportHtmlUrl
	Dim ExportExcelUrl
	Dim ExportWordUrl
	Dim ExportXmlUrl
	Dim ExportCsvUrl
	Dim ExportPdfUrl

	' Inline urls
	Dim InlineAddUrl
	Dim InlineCopyUrl
	Dim InlineEditUrl
	Dim GridAddUrl
	Dim GridEditUrl
	Dim MultiDeleteUrl
	Dim MultiUpdateUrl

	' 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 sjlm.UseTokenInUrl Then
			IsPageRequest = False
			If Not (ObjForm Is Nothing) Then
				IsPageRequest = (sjlm.TableVar = ObjForm.GetValue("t"))
			End If
			If Request.QueryString("t").Count > 0 Then
				IsPageRequest = (sjlm.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

		' Grid form hidden field names
		FormName = "fsjlmlist"
		FormActionName = "k_action"
		FormKeyName = "k_key"
		FormOldKeyName = "k_oldkey"
		FormBlankRowName = "k_blankrow"
		FormKeyCountName = "key_count"

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

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

		' Initialize urls
		ExportPrintUrl = PageUrl & "export=print"
		ExportExcelUrl = PageUrl & "export=excel"
		ExportWordUrl = PageUrl & "export=word"
		ExportHtmlUrl = PageUrl & "export=html"
		ExportXmlUrl = PageUrl & "export=xml"
		ExportCsvUrl = PageUrl & "export=csv"
		ExportPdfUrl = PageUrl & "export=pdf"
		AddUrl = "sjlmadd.asp?" & EW_TABLE_SHOW_DETAIL & "="
		InlineAddUrl = PageUrl & "a=add"
		GridAddUrl = PageUrl & "a=gridadd"
		GridEditUrl = PageUrl & "a=gridedit"
		MultiDeleteUrl = "sjlmdelete.asp"
		MultiUpdateUrl = "sjlmupdate.asp"

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

		' Initialize other table object
		If IsEmpty(xwfb) Then Set xwfb = New cxwfb

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

		' Initialize form object
		Set ObjForm = Nothing

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

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

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

		' List options
		Set ListOptions = New cListOptions
		ListOptions.TableVar = sjlm.TableVar

		' Export options
		Set ExportOptions = New cListOptions
		ExportOptions.TableVar = sjlm.TableVar
		ExportOptions.Tag = "div"
		ExportOptions.TagClassName = "ewExportOption"

		' Other options
		Set AddEditOptions = New cListOptions
		AddEditOptions.Tag = "div"
		AddEditOptions.TagClassName = "ewAddEditOption"
		Set DetailOptions = New cListOptions
		DetailOptions.Tag = "div"
		DetailOptions.TagClassName = "ewDetailOption"
		Set ActionOptions = New cListOptions
		ActionOptions.Tag = "div"
		ActionOptions.TagClassName = "ewActionOption"
	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.CanList Then
			Call Security.SaveLastUrl()
			Call Page_Terminate("login.asp")
		End If

		' Get export parameters
		If Request.QueryString("export").Count > 0 Then
			sjlm.Export = Request.QueryString("export")
		ElseIf Request.ServerVariables("HTTP_CONTENT_TYPE") = "application/x-www-form-urlencoded" Then
			If Request.Form("exporttype").Count > 0 Then
				sjlm.Export = Request.Form("exporttype")
			End If
		Else
			sjlm.ExportReturnUrl = ew_CurrentUrl()
		End If
		gsExport = sjlm.Export ' Get export parameter, used in header
		gsExportFile = sjlm.TableVar ' Get export file, used in header
		Dim Charset ' Charset used in header
		If EW_CHARSET <> "" Then
			Charset = ";charset=" & EW_CHARSET
		Else
			Charset = ""
		End If
		If sjlm.Export = "excel" Then
			Response.ContentType = "application/vnd.ms-excel" & Charset
			Response.AddHeader "Content-Disposition", "attachment; filename=" & gsExportFile & ".xls"
		End If
		If sjlm.Export = "word" Then
			Response.ContentType = "application/vnd.ms-word" & Charset
			Response.AddHeader "Content-Disposition", "attachment; filename=" & gsExportFile & ".doc"
		End If

		' Get grid add count
		Dim gridaddcnt
		gridaddcnt = Request.QueryString(EW_TABLE_GRID_ADD_ROW_COUNT)
		If IsNumeric(gridaddcnt) Then
			If gridaddcnt > 0 Then
				sjlm.GridAddRowCount = gridaddcnt
			End If
		End If

		' Set up list options
		SetupListOptions()

		' Setup export options
		SetupExportOptions()

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

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

		' Setup other options
		SetupOtherOptions()

		' Set "checkbox" visible
		If UBound(sjlm.CustomActions.CustomArray) >= 0 Then
			ListOptions.GetItem("checkbox").Visible = True
		End If

		'??? Update url if printer friendly for Pdf
		'???if ($this->PrinterFriendlyForPdf)
		'???	$this->ExportOptions->Items["pdf"]->Body = str_replace($this->ExportPdfUrl, $this->ExportPrintUrl . "&pdf=1", $this->ExportOptions->Items["pdf"]->Body);

	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()

		'???if ($this->Export == "print" && @$_GET["pdf"] == "1") { // Printer friendly version and with pdf=1 in URL parameters
		'???	$pdf = new cExportPdf($GLOBALS["Table"]);
		'???	$pdf->Text = ob_get_contents(); // Set the content as the HTML of current page (printer friendly version)
		'???	ob_end_clean();
		'???	$pdf->Export();
		'???}
		' 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 sjlm = Nothing
		Set ListOptions = 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 ListOptions ' List options
	Dim ExportOptions ' Export options
	Dim AddEditOptions ' Other options (add edit)
	Dim DetailOptions ' Other options (detail)
	Dim ActionOptions ' Other options (action)
	Dim DisplayRecs ' Number of display records
	Dim StartRec, StopRec, TotalRecs, RecRange
	Dim SearchWhere
	Dim RecCnt
	Dim EditRowCnt
	Dim StartRowCnt
	Dim RowCnt, RowIndex
	Dim Attrs
	Dim RecPerRow, ColCnt
	Dim KeyCount
	Dim RowAction
	Dim RowOldKey ' Row old key (for copy)
	Dim DbMasterFilter, DbDetailFilter
	Dim MasterRecordExists
	Dim MultiSelectKey
	Dim Command
	Dim RestoreSearch
	Dim xwfb_Count
	Dim Recordset, OldRecordset

	' -----------------------------------------------------------------
	' Page main processing
	'
	Sub Page_Main()
		DisplayRecs = 20
		RecRange = 10
		RecCnt = 0 ' Record count
		KeyCount = 0 ' Key count
		StartRowCnt = 1

		' Search filters
		Dim sSrchAdvanced, sSrchBasic, sFilter
		sSrchAdvanced = "" ' Advanced search filter
		sSrchBasic = "" ' Basic search filter
		SearchWhere = "" ' Search where clause
		sFilter = ""

		' Restore search
		RestoreSearch = False

		' Get command
		Command = LCase(Request.QueryString("cmd")&"")

		' Master/Detail
		DbMasterFilter = "" ' Master filter
		DbDetailFilter = "" ' Detail filter
		If IsPageRequest Then ' Validate request

			' Process custom action first
			ProcessCustomAction()

			' Set up records per page dynamically
			SetUpDisplayRecs()

			' Handle reset command
			ResetCmd()

			' Set up master detail parameters
			SetUpMasterParms()

			' Set up Breadcrumb
			SetupBreadcrumb()

			' Hide list options
			If sjlm.Export <> "" Then
				Call ListOptions.HideAllOptions(Array("sequence"))
				ListOptions.UseDropDownButton = False ' Disable drop down button
				ListOptions.UseButtonGroup = False ' Disable button group
			ElseIf sjlm.CurrentAction = "gridadd" Or sjlm.CurrentAction = "gridedit" Then
				Call ListOptions.HideAllOptions(Array())
				ListOptions.UseDropDownButton = False ' Disable drop down button
				ListOptions.UseButtonGroup = False ' Disable button group
			End If

			' Hide export options
			If sjlm.Export <> "" Or sjlm.CurrentAction <> "" Then
				ExportOptions.HideAllOptions(Array())
			End If

			' Hide other options
			If sjlm.Export <> "" Then
				AddEditOptions.HideAllOptions(Array())
				DetailOptions.HideAllOptions(Array())
				ActionOptions.HideAllOptions(Array())
			End If

			' Set Up Sorting Order
			SetUpSortOrder()
		End If ' End Validate Request

		' Restore display records
		If sjlm.RecordsPerPage <> "" Then
			DisplayRecs = sjlm.RecordsPerPage ' Restore from Session
		Else
			DisplayRecs = 20 ' Load default
		End If

		' Load Sorting Order
		LoadSortOrder()
		sFilter = ""
		If Not Security.CanList Then
			sFilter = "(0=1)" ' Filter all records
		End If

		' Restore master/detail filter
		DbMasterFilter = sjlm.MasterFilter ' Restore master filter
		DbDetailFilter = sjlm.DetailFilter ' Restore detail filter
		Call ew_AddFilter(sFilter, DbDetailFilter)
		Call ew_AddFilter(sFilter, SearchWhere)
		Dim RsMaster

		' Load master record
		If sjlm.MasterFilter <> "" And sjlm.CurrentMasterTable = "xwlm" Then
			Set RsMaster = xwlm.LoadRs(DbMasterFilter)
			MasterRecordExists = Not (RsMaster Is Nothing)
			If Not MasterRecordExists Then
				FailureMessage = Language.Phrase("NoRecord") ' Set no record found
				Call Page_Terminate(sjlm.ReturnUrl) ' Return to caller
			Else
				Call xwlm.LoadListRowValues(RsMaster)
				xwlm.RowType = EW_ROWTYPE_MASTER ' Master row
				Call xwlm.RenderListRow()
				RsMaster.Close
				Set RsMaster = Nothing
			End If
		End If

		' Set up filter in Session
		sjlm.SessionWhere = sFilter
		sjlm.CurrentFilter = ""

		' Export Data only
		If ew_InArray(sjlm.Export, Array("html","word","excel","xml","csv","email","pdf")) Then
			ExportData()
			Call Page_Terminate("") ' Terminate response
			Response.End
		End If
	End Sub

	' -----------------------------------------------------------------
	' Set up number of records displayed per page
	'
	Sub SetUpDisplayRecs()
		Dim sWrk
		sWrk = Request.QueryString(EW_TABLE_REC_PER_PAGE)
		If sWrk <> "" Then
			If IsNumeric(sWrk) Then
				DisplayRecs = CInt(sWrk)
			Else
				If LCase(sWrk) = "all" Then ' Display all records
					DisplayRecs = -1
				Else
					DisplayRecs = 20 ' Non-numeric, load default
				End If
			End If
			sjlm.RecordsPerPage = DisplayRecs ' Save to Session

			' Reset start position
			StartRec = 1
			sjlm.StartRecordNumber = StartRec
		End If
	End Sub

	' -----------------------------------------------------------------
	'  Build filter for all keys
	'
	Function BuildKeyFilter()
		Dim rowindex, sThisKey
		Dim sKey
		Dim sWrkFilter, sFilter
		sWrkFilter = ""

		' Update row index and get row key
		rowindex = 1
		ObjForm.Index = rowindex
		sThisKey = ObjForm.GetValue("k_key") & ""
		Do While (sThisKey <> "")
			If SetupKeyValues(sThisKey) Then
				sFilter = sjlm.KeyFilter
				If sWrkFilter <> "" Then sWrkFilter = sWrkFilter & " OR "
				sWrkFilter = sWrkFilter & sFilter
			Else
				sWrkFilter = "0=1"
				Exit Do
			End If

			' Update row index and get row key
			rowindex = rowindex + 1 ' Next row
			ObjForm.Index = rowindex
			sThisKey = ObjForm.GetValue("k_key") & ""
		Loop
		BuildKeyFilter = sWrkFilter
	End Function

	' -----------------------------------------------------------------
	' Set up key values
	'
	Function SetupKeyValues(key)
		Dim arrKeyFlds
		arrKeyFlds = Split(key&"", EW_COMPOSITE_KEY_SEPARATOR)
		If UBound(arrKeyFlds) >= 0 Then
			sjlm.id.FormValue = arrKeyFlds(0)
			If Not IsNumeric(sjlm.id.FormValue) Then
				SetupKeyValues = False
				Exit Function
			End If
		End If
		SetupKeyValues = True
	End Function

	' -----------------------------------------------------------------
	' Set up Sort parameters based on Sort Links clicked
	'
	Sub SetUpSortOrder()
		Dim sOrderBy
		Dim sSortField, sLastSort, sThisSort
		Dim bCtrl

		' Check for an Order parameter
		If Request.QueryString("order").Count > 0 Then
			sjlm.CurrentOrder = Request.QueryString("order")
			sjlm.CurrentOrderType = Request.QueryString("ordertype")

			' Field id
			Call sjlm.UpdateSort(sjlm.id)

			' Field bh
			Call sjlm.UpdateSort(sjlm.bh)

			' Field lmid
			Call sjlm.UpdateSort(sjlm.lmid)

			' Field sjmc
			Call sjlm.UpdateSort(sjlm.sjmc)

			' Field sjmc2
			Call sjlm.UpdateSort(sjlm.sjmc2)

			' Field px
			Call sjlm.UpdateSort(sjlm.px)

			' Field urllb
			Call sjlm.UpdateSort(sjlm.urllb)
			sjlm.StartRecordNumber = 1 ' Reset start position
		End If
	End Sub

	' -----------------------------------------------------------------
	' Load Sort Order parameters
	'
	Sub LoadSortOrder()
		Dim sOrderBy
		sOrderBy = sjlm.SessionOrderBy ' Get order by from Session
		If sOrderBy = "" Then
			If sjlm.SqlOrderBy <> "" Then
				sOrderBy = sjlm.SqlOrderBy
				sjlm.SessionOrderBy = sOrderBy
			End If
		End If
	End Sub

	' -----------------------------------------------------------------
	' Reset command based on querystring parameter cmd=
	' - RESET: reset search parameters
	' - RESETALL: reset search & master/detail parameters
	' - RESETSORT: reset sort parameters
	'
	Sub ResetCmd()

		' Check if reset command
		If Left(Command,5) = "reset" Then

			' Reset master/detail keys
			If Command = "resetall" Then
				sjlm.CurrentMasterTable = "" ' Clear master table
				DbMasterFilter = ""
				DbDetailFilter = ""
				sjlm.lmid.SessionValue = ""
				sjlm.bh.SessionValue = ""
			End If

			' Reset Sort Criteria
			If Command = "resetsort" Then
				Dim sOrderBy
				sOrderBy = ""
				sjlm.SessionOrderBy = sOrderBy
				sjlm.id.Sort = ""
				sjlm.bh.Sort = ""
				sjlm.lmid.Sort = ""
				sjlm.sjmc.Sort = ""
				sjlm.sjmc2.Sort = ""
				sjlm.px.Sort = ""
				sjlm.urllb.Sort = ""
			End If

			' Reset start position
			StartRec = 1
			sjlm.StartRecordNumber = StartRec
		End If
	End Sub

	' Set up list options
	Sub SetupListOptions()
		Dim item

		' Add group option item
		ListOptions.Add(ListOptions.GroupOptionName)
		Set item = ListOptions.GetItem(ListOptions.GroupOptionName)
		item.Body = ""
		item.OnLeft = False
		item.Visible = False

		' View
		ListOptions.Add("view")
		Set item = ListOptions.GetItem("view")
		item.CssStyle = "white-space: nowrap;"
		item.Visible = Security.CanView
		item.OnLeft = False

		' Edit
		ListOptions.Add("edit")
		Set item = ListOptions.GetItem("edit")
		item.CssStyle = "white-space: nowrap;"
		item.Visible = Security.CanEdit
		item.OnLeft = False

		' Copy
		ListOptions.Add("copy")
		Set item = ListOptions.GetItem("copy")
		item.CssStyle = "white-space: nowrap;"
		item.Visible = Security.CanAdd
		item.OnLeft = False

		' Detail table xwfb
		ListOptions.Add("detail_xwfb")
		Set item = ListOptions.GetItem("detail_xwfb")
		item.CssStyle = "white-space: nowrap;"
		item.Visible = Security.AllowList(CurrentProjectID & "xwfb") And Not sjlm.ShowMultipleDetails
		item.OnLeft = False
		item.ShowInButtonGroup = False

		' Multiple details
		If sjlm.ShowMultipleDetails Then
			ListOptions.Add("details")
			Set item = ListOptions.GetItem("details")
			item.CssStyle = "white-space: nowrap;"
			item.Visible = sjlm.ShowMultipleDetails
			item.OnLeft = False
			item.ShowInButtonGroup = False
		End If

		' Checkbox
		ListOptions.Add("checkbox")
		Set item = ListOptions.GetItem("checkbox")
		item.Visible = Security.CanDelete
		item.OnLeft = False
		item.Header = "<label class=""checkbox""><input type=""checkbox"" name=""key"" id=""key"" onclick=""ew_SelectAllKey(this);""></label>"
		item.ShowInDropDown = False
		item.ShowInButtonGroup = False

		' Drop down button for ListOptions
		ListOptions.UseDropDownButton = False
		ListOptions.DropDownButtonPhrase = Language.Phrase("ButtonListOptions")
		ListOptions.UseButtonGroup = False
		ListOptions.ButtonClass = "btn-small" ' Class for button group
		Call ListOptions_Load()

		' Set up group item visibility
		ListOptions.GetItem(ListOptions.GroupOptionName).Visible = ListOptions.GroupOptionVisible
	End Sub

	' Render list options
	Sub RenderListOptions()
		Dim item, links
		ListOptions.LoadDefault()
		If Security.CanView Then
			ListOptions.GetItem("view").Body = "<a class=""ewRowLink ewView"" data-caption=""" & ew_HtmlTitle(Language.Phrase("ViewLink")) & """ href=""" & ew_HtmlEncode(ViewUrl) & """>" & Language.Phrase("ViewLink") & "</a>"
		Else
			ListOptions.GetItem("view").Body = ""
		End If
		Set item = ListOptions.GetItem("edit")
		If Security.CanEdit Then
			item.Body = "<a class=""ewRowLink ewEdit"" data-caption=""" & ew_HtmlTitle(Language.Phrase("EditLink")) & """ href=""" & ew_HtmlEncode(EditUrl) & """>" & Language.Phrase("EditLink") & "</a>"
		Else
			item.Body = ""
		End If
		Set item = ListOptions.GetItem("copy")
		If Security.CanAdd Then
			item.Body = "<a class=""ewRowLink ewCopy"" data-caption=""" & ew_HtmlTitle(Language.Phrase("CopyLink")) & """ href=""" & ew_HtmlEncode(CopyUrl) & """>" & Language.Phrase("CopyLink") & "</a>"
		Else
			item.Body = ""
		End If
		Dim DetailViewTblVar, DetailCopyTblVar, DetailEditTblVar, body
		DetailViewTblVar = ""
		DetailCopyTblVar = ""
		DetailEditTblVar = ""
		If Security.AllowList(CurrentProjectID & "xwfb") Then
			Set item = ListOptions.GetItem("detail_xwfb")
			body = Language.Phrase("DetailLink") & Language.TablePhrase("xwfb", "TblCaption")
			body = body & Replace(Language.Phrase("DetailCount"), "%c", xwfb_Count)
			body = "<a class=""btn btn-small ewRowLink ewDetailList"" data-action=""list"" href=""" & ew_HtmlEncode("xwfblist.asp?" & EW_TABLE_SHOW_MASTER & "=sjlm&bh=" & sjlm.bh.CurrentValue&"" & "&lmid=" & sjlm.lmid.CurrentValue&"" & "&id=" & sjlm.id.CurrentValue&"" & "") & """>" & body & "</a>"
			links = ""
			If xwfb.DetailView And Security.CanView And Security.AllowView(CurrentProjectID & "xwfb") Then
				links = links & "<li><a class=""ewRowLink ewDetailView"" data-action=""view"" href=""" & ew_HtmlEncode(sjlm.ViewUrl(EW_TABLE_SHOW_DETAIL & "=xwfb")) & """>" & Language.Phrase("MasterDetailViewLink") & "</a></li>"
				If DetailViewTblVar <> "" Then DetailViewTblVar = DetailViewTblVar & ","
				DetailViewTblVar = DetailViewTblVar & "xwfb"
			End If
			If xwfb.DetailEdit And Security.CanEdit And Security.AllowEdit(CurrentProjectID & "xwfb") Then
				links = links & "<li><a class=""ewRowLink ewDetailEdit"" data-action=""edit"" href=""" & ew_HtmlEncode(sjlm.EditUrl(EW_TABLE_SHOW_DETAIL & "=xwfb")) & """>" & Language.Phrase("MasterDetailEditLink") & "</a></li>"
				If DetailEditTblVar <> "" Then DetailEditTblVar = DetailEditTblVar & ","
				DetailEditTblVar = DetailEditTblVar & "xwfb"
			End If
			If xwfb.DetailAdd And Security.CanAdd And Security.AllowAdd(CurrentProjectID & "xwfb") Then
				links = links & "<li><a class=""ewRowLink ewDetailCopy"" data-action=""add"" href=""" & ew_HtmlEncode(sjlm.CopyUrl(EW_TABLE_SHOW_DETAIL & "=xwfb")) & """>" & Language.Phrase("MasterDetailCopyLink") & "</a></li>"
				If DetailCopyTblVar <> "" Then DetailCopyTblVar = DetailCopyTblVar & ","
				DetailCopyTblVar = DetailCopyTblVar & "xwfb"
			End If
			If links <> "" Then
				body = body & "<button class=""btn btn-small dropdown-toggle"" data-toggle=""dropdown""><b class=""caret""></b></button>"
				body = body & "<ul class=""dropdown-menu"">" & links & "</ul>"
			End If
			body = "<div class=""btn-group"">" & body & "</div>"
			item.Body = body
			If sjlm.ShowMultipleDetails Then item.Visible = False
		End If
		If sjlm.ShowMultipleDetails Then
			body = Language.Phrase("MultipleMasterDetails")
			body = "<div class=""btn-group"">" & _
				"<a class=""btn btn-small ewRowLink ewDetailView"" data-action=""list"" href=""" & ew_HtmlEncode(sjlm.ViewUrl(EW_TABLE_SHOW_DETAIL & "=" & DetailViewTblVar)) & """>" & body & "</a>"
			links = ""
			If DetailViewTblVar <> "" Then
				links = links & "<li><a class=""ewRowLink ewDetailView"" data-action=""view"" href=""" & ew_HtmlEncode(sjlm.ViewUrl(EW_TABLE_SHOW_DETAIL & "=" & DetailViewTblVar)) & """>" & Language.Phrase("MasterDetailViewLink") & "</a></li>"
			End If
			If DetailEditTblVar <> "" Then
				links = links & "<li><a class=""ewRowLink ewDetailEdit"" data-action=""edit"" href=""" & ew_HtmlEncode(sjlm.EditUrl(EW_TABLE_SHOW_DETAIL & "=" & DetailEditTblVar)) & """>" & Language.Phrase("MasterDetailEditLink") & "</a></li>"
			End If
			If DetailCopyTblVar <> "" Then
				links = links & "<li><a class=""ewRowLink ewDetailCopy"" data-action=""add"" href=""" & ew_HtmlEncode(sjlm.CopyUrl(EW_TABLE_SHOW_DETAIL & "=" & DetailCopyTblVar)) & """>" & Language.Phrase("MasterDetailCopyLink") & "</a></li>"
			End If
			If links <> "" Then
				body = body & "<button class=""btn btn-small dropdown-toggle"" data-toggle=""dropdown"">&nbsp;<b class=""caret""></b></button>"
				body = body & "<ul class=""dropdown-menu"">" & links & "</ul>"
			End If
			body = body & "</div>"

			' Multiple details
			Set item = ListOptions.GetItem("details")
			item.Body = body
		End If
		ListOptions.GetItem("checkbox").Body = "<label class=""checkbox""><input type=""checkbox"" name=""key_m"" value=""" & ew_HtmlEncode(sjlm.id.CurrentValue) & """ onclick='ew_ClickMultiCheckbox(event, this);'></label>"
		Call RenderListOptionsExt()
		Call ListOptions_Rendered()
	End Sub

	' Set up other options
	Sub SetupOtherOptions()
		Dim opt, item, DetailTableLink, ar, i
		Set opt = AddEditOptions

		' Add
		Call opt.Add("add")
		Set item = opt.GetItem("add")
		item.Body = "<a class=""ewAddEdit ewAdd"" href=""" & ew_HtmlEncode(AddUrl) & """>" & Language.Phrase("AddLink") & "</a>"
		item.Visible = (AddUrl <> "" And Security.CanAdd)
		Set opt = DetailOptions
		DetailTableLink = ""
		Call opt.Add("detailadd_xwfb")
		Set item = opt.GetItem("detailadd_xwfb")
		item.Body = "<a class=""ewDetailAddGroup ewDetailAdd"" href=""" & ew_HtmlEncode(sjlm.AddUrl & "?" & EW_TABLE_SHOW_DETAIL & "=xwfb") & """>" & Language.Phrase("AddLink") & "&nbsp;" & sjlm.TableCaption & "/" & xwfb.TableCaption & "</a>"
		item.Visible = (xwfb.DetailAdd And Security.AllowAdd(CurrentProjectID & "xwfb") And Security.CanAdd)
		If item.Visible Then
			If DetailTableLink <> "" Then DetailTableLink = DetailTableLink & ","
			DetailTableLink = DetailTableLink & "xwfb"
		End If

		' Add multiple details
		If sjlm.ShowMultipleDetails Then
			Call opt.Add("detailsadd")
			Set item = opt.GetItem("detailsadd")
			item.Body = "<a class=""ewDetailAddGroup ewDetailAdd"" href=""" & ew_HtmlEncode(sjlm.AddUrl & "?" & EW_TABLE_SHOW_DETAIL & "=" & DetailTableLink) & """>" & Language.Phrase("AddMasterDetailLink") & "</a>"
			item.Visible = (DetailTableLink <> "" And Security.CanAdd)

			' Hide single master/detail items
			ar = Split(DetailTableLink, ",")
			For i = 0 to UBound(ar)
				Set item = opt.GetItem("detailadd_" & ar(i))
				item.Visible = False
			Next
		End If
		Set opt = ActionOptions

		' Add multi delete
		Call opt.Add("multidelete")
		Set item = opt.GetItem("multidelete")
		item.Body = "<a class=""ewAction ewMultiDelete"" href="""" onclick=""ew_SubmitSelected(document.fsjlmlist, '" & MultiDeleteUrl & "', ewLanguage.Phrase('DeleteMultiConfirmMsg'));return false;"">" & Language.Phrase("DeleteSelectedLink") & "</a>"
		item.Visible = (Security.CanDelete)

		' Set up options default
		Set opt = AddEditOptions
		opt.DropDownButtonPhrase = Language.Phrase("ButtonAddEdit")
		opt.UseDropDownButton = False
		opt.UseButtonGroup = True
		opt.ButtonClass = "btn-small" ' Class for button group
		Call opt.Add(opt.GroupOptionName)
		Set item = opt.GetItem(opt.GroupOptionName)
		item.Body = ""
		item.Visible = False
		Set opt = DetailOptions
		opt.DropDownButtonPhrase = Language.Phrase("ButtonDetails")
		opt.UseDropDownButton = False
		opt.UseButtonGroup = True
		opt.ButtonClass = "btn-small" ' Class for button group
		Call opt.Add(opt.GroupOptionName)
		Set item = opt.GetItem(opt.GroupOptionName)
		item.Body = ""
		item.Visible = False
		Set opt = ActionOptions
		opt.DropDownButtonPhrase = Language.Phrase("ButtonActions")
		opt.UseDropDownButton = False
		opt.UseButtonGroup = True
		opt.ButtonClass = "btn-small" ' Class for button group
		Call opt.Add(opt.GroupOptionName)
		Set item = opt.GetItem(opt.GroupOptionName)
		item.Body = ""
		item.Visible = False
	End Sub

	' Render other options
	Sub RenderOtherOptions()
		Dim opt, item, i, Action, Name
			Set opt = ActionOptions
			For i = 0 to UBound(sjlm.CustomActions.CustomArray)
				Action = sjlm.CustomActions.CustomArray(i)(0)
				Name = sjlm.CustomActions.CustomArray(i)(1)

				' Add custom action
				Call opt.Add("custom_" & Action)
				Set item = opt.GetItem("custom_" & Action)
				item.Body = "<a class=""ewAction ewCustomAction"" href="""" onclick=""ew_SubmitSelected(document.fsjlmlist, '" & ew_CurrentUrl & "', null, '" & Action & "');return false;"">" & Name & "</a>"
			Next

			' Hide grid edit, multi-delete and multi-update
			If TotalRecs <= 0 Then
				Set opt = AddEditOptions
				Set item = opt.GetItem("gridedit")
				If (Not item Is Nothing) Then item.Visible = False
				Set opt = ActionOptions
				Set item = opt.GetItem("multidelete")
				If (Not item Is Nothing) Then item.Visible = False
				Set item = opt.GetItem("multiupdate")
				If (Not item Is Nothing) Then item.Visible = False
			End If
	End Sub

	' Process custom action
	Sub ProcessCustomAction()
		Dim sFilter, sSql, UserAction, Processed
		sFilter = sjlm.GetKeyFilter
		UserAction = Request.Form("useraction") & ""
		Processed = False
		If sFilter <> "" And UserAction <> "" Then
			sjlm.CurrentFilter = sFilter
			sSql = sjlm.SQL
			Conn.BeginTrans

			' Load recordset
			Dim Rs
			Set Rs = ew_LoadRecordset(sSql)
			If Not Rs.Eof Then Rs.MoveFirst

			' Call row custom action event
			Do While Not Rs.Eof
				Processed = Row_CustomAction(UserAction, Rs)
				If Not Processed Then
					Exit Do
				Else
					Rs.MoveNext
				End If
			Loop
			Rs.Close
			Set Rs = Nothing
			If Processed Then
				Conn.CommitTrans ' Commit the changes
				If SuccessMessage = "" Then
					SuccessMessage = Replace(Language.Phrase("CustomActionCompleted"), "%s", UserAction) ' Set up success message
				End If
			Else
				Conn.RollbackTrans ' Rollback transaction

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

					' Use the message, do nothing
				ElseIf sjlm.CancelMessage <> "" Then
					FailureMessage = sjlm.CancelMessage
					sjlm.CancelMessage = ""
				Else
					FailureMessage = Replace(Language.Phrase("CustomActionCancelled"), "%s", UserAction)
				End If
			End If
		End If
	End Sub

	Function RenderListOptionsExt()
	End Function
	Dim Pager

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

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

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

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

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

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

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

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

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

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

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

		' Load sql based on filter
		sjlm.CurrentFilter = sFilter
		sSql = sjlm.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 sjlm.Row_Selected(RsRow)
		sjlm.id.DbValue = RsRow("id")
		sjlm.bh.DbValue = RsRow("bh")
		sjlm.lmid.DbValue = RsRow("lmid")
		sjlm.sjmc.DbValue = RsRow("sjmc")
		sjlm.sjmc2.DbValue = RsRow("sjmc2")
		sjlm.px.DbValue = RsRow("px")
		sjlm.urllb.DbValue = RsRow("urllb")
		sjlm.js.DbValue = RsRow("js")
		sjlm.pic.DbValue = RsRow("pic")
		sjlm.seobt.DbValue = RsRow("seobt")
		sjlm.seogjc.DbValue = RsRow("seogjc")
		sjlm.seoms.DbValue = RsRow("seoms")
		sDetailFilter = xwfb.SqlDetailFilter_sjlm
		sDetailFilter = Replace(sDetailFilter, "@bh@", ew_AdjustSql(sjlm.bh.DbValue))
		sDetailFilter = Replace(sDetailFilter, "@lmid@", ew_AdjustSql(sjlm.lmid.DbValue))
		sDetailFilter = Replace(sDetailFilter, "@sj@", ew_AdjustSql(sjlm.id.DbValue))
		xwfb.CurrentMasterTable = "sjlm"
		xwfb_Count = xwfb.LoadRecordCount(sDetailFilter)
	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
		sjlm.id.m_DbValue = Rs("id")
		sjlm.bh.m_DbValue = Rs("bh")
		sjlm.lmid.m_DbValue = Rs("lmid")
		sjlm.sjmc.m_DbValue = Rs("sjmc")
		sjlm.sjmc2.m_DbValue = Rs("sjmc2")
		sjlm.px.m_DbValue = Rs("px")
		sjlm.urllb.m_DbValue = Rs("urllb")
		sjlm.js.m_DbValue = Rs("js")
		sjlm.pic.m_DbValue = Rs("pic")
		sjlm.seobt.m_DbValue = Rs("seobt")
		sjlm.seogjc.m_DbValue = Rs("seogjc")
		sjlm.seoms.m_DbValue = Rs("seoms")
	End Sub

	' Load old record
	Function LoadOldRecord()

		' Load key values from Session
		Dim bValidKey
		bValidKey = True
		If sjlm.GetKey("id")&"" <> "" Then
			sjlm.id.CurrentValue = sjlm.GetKey("id") ' id
		Else
			bValidKey = False
		End If

		' Load old recordset
		If bValidKey Then
			sjlm.CurrentFilter = sjlm.KeyFilter
			Dim sSql
			sSql = sjlm.SQL
			Set OldRecordset = ew_LoadRecordset(sSql)
			Call LoadRowValues(OldRecordset) ' Load row values
		Else
			OldRecordset = Null
		End If
		LoadOldRecord = bValidKey
	End Function

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

		' Initialize urls
		ViewUrl = sjlm.ViewUrl("")
		EditUrl = sjlm.EditUrl("")
		InlineEditUrl = sjlm.InlineEditUrl
		CopyUrl = sjlm.CopyUrl("")
		InlineCopyUrl = sjlm.InlineCopyUrl
		DeleteUrl = sjlm.DeleteUrl

		' Call Row Rendering event
		Call sjlm.Row_Rendering()

		' ---------------------------------------
		'  Common render codes for all row types
		' ---------------------------------------
		' id
		' bh
		' lmid
		' sjmc
		' sjmc2
		' px
		' urllb
		' js
		' pic
		' seobt
		' seogjc
		' seoms
		' -----------
		'  View  Row
		' -----------

		If sjlm.RowType = EW_ROWTYPE_VIEW Then ' View row

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

			' bh
			If sjlm.bh.CurrentValue & "" <> "" Then
				sFilterWrk = "[bh]" & ew_SearchString("=", sjlm.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 sjlm.Lookup_Selecting(sjlm.bh, sWhereWrk)
			If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
				Set RsWrk = Conn.Execute(sSqlWrk)
				If Not RsWrk.Eof Then
					sjlm.bh.ViewValue = RsWrk("DispFld")
				Else
					sjlm.bh.ViewValue = sjlm.bh.CurrentValue
				End If
				RsWrk.Close
				Set RsWrk = Nothing
			Else
				sjlm.bh.ViewValue = Null
			End If
			sjlm.bh.ViewCustomAttributes = ""

			' lmid
			If sjlm.lmid.CurrentValue & "" <> "" Then
				sFilterWrk = "[lmid]" & ew_SearchString("=", sjlm.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 sjlm.Lookup_Selecting(sjlm.lmid, sWhereWrk)
			If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk
				Set RsWrk = Conn.Execute(sSqlWrk)
				If Not RsWrk.Eof Then
					sjlm.lmid.ViewValue = RsWrk("DispFld")
				Else
					sjlm.lmid.ViewValue = sjlm.lmid.CurrentValue
				End If
				RsWrk.Close
				Set RsWrk = Nothing
			Else
				sjlm.lmid.ViewValue = Null
			End If
			sjlm.lmid.ViewCustomAttributes = ""

			' sjmc
			sjlm.sjmc.ViewValue = sjlm.sjmc.CurrentValue
			sjlm.sjmc.ViewCustomAttributes = ""

			' sjmc2
			sjlm.sjmc2.ViewValue = sjlm.sjmc2.CurrentValue
			sjlm.sjmc2.ViewCustomAttributes = ""

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

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

			' View refer script
			' id

			sjlm.id.LinkCustomAttributes = ""
			sjlm.id.HrefValue = ""
			sjlm.id.TooltipValue = ""

			' bh
			sjlm.bh.LinkCustomAttributes = ""
			sjlm.bh.HrefValue = ""
			sjlm.bh.TooltipValue = ""

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

			' sjmc
			sjlm.sjmc.LinkCustomAttributes = ""
			sjlm.sjmc.HrefValue = ""
			sjlm.sjmc.TooltipValue = ""

			' sjmc2
			sjlm.sjmc2.LinkCustomAttributes = ""
			sjlm.sjmc2.HrefValue = ""
			sjlm.sjmc2.TooltipValue = ""

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

			' urllb
			sjlm.urllb.LinkCustomAttributes = ""
			sjlm.urllb.HrefValue = ""
			sjlm.urllb.TooltipValue = ""
		End If

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

	' Set up export options
	Sub SetupExportOptions()
		Dim item

		' Printer friendly
		ExportOptions.Add("print")
		Set item = ExportOptions.GetItem("print")
		item.Body = "<a href=""" & ExportPrintUrl & """ class=""ewExportLink ewPrint"" data-caption=""" & ew_HtmlEncode(Language.Phrase("PrinterFriendlyText")) & """>" & Language.Phrase("PrinterFriendly") & "</a>"
		item.Visible = True

		' Export to Excel
		ExportOptions.Add("excel")
		Set item = ExportOptions.GetItem("excel")
		item.Body = "<a href=""" & ExportExcelUrl & """ class=""ewExportLink ewExcel"" data-caption=""" & ew_HtmlEncode(Language.Phrase("ExportToExcelText")) & """>" & Language.Phrase("ExportToExcel") & "</a>"
		item.Visible = True

		' Export to Word
		ExportOptions.Add("word")
		Set item = ExportOptions.GetItem("word")
		item.Body = "<a href=""" & ExportWordUrl & """ class=""ewExportLink ewWord"" data-caption=""" & ew_HtmlEncode(Language.Phrase("ExportToWordText")) & """>" & Language.Phrase("ExportToWord") & "</a>"
		item.Visible = True

		' Export to Html
		ExportOptions.Add("html")
		Set item = ExportOptions.GetItem("html")
		item.Body = "<a href=""" & ExportHtmlUrl & """ class=""ewExportLink ewHtml"" data-caption=""" & ew_HtmlEncode(Language.Phrase("ExportToHtmlText")) & """>" & Language.Phrase("ExportToHtml") & "</a>"
		item.Visible = False

		' Export to Xml
		ExportOptions.Add("xml")
		Set item = ExportOptions.GetItem("xml")
		item.Body = "<a href=""" & ExportXmlUrl & """ class=""ewExportLink ewXml"" data-caption=""" & ew_HtmlEncode(Language.Phrase("ExportToXmlText")) & """>" & Language.Phrase("ExportToXml") & "</a>"
		item.Visible = False

		' Export to Csv
		ExportOptions.Add("csv")
		Set item = ExportOptions.GetItem("csv")
		item.Body = "<a href=""" & ExportCsvUrl & """ class=""ewExportLink ewCsv"" data-caption=""" & ew_HtmlEncode(Language.Phrase("ExportToCsvText")) & """>" & Language.Phrase("ExportToCsv") & "</a>"
		item.Visible = False

		' Export to Pdf
		ExportOptions.Add("pdf")
		Set item = ExportOptions.GetItem("pdf")
		item.Body = "<a href=""" & ExportPdfUrl & """ class=""ewExportLink ewPdf"" data-caption=""" & ew_HtmlEncode(Language.Phrase("ExportToPDFText")) & """>" & Language.Phrase("ExportToPDF") & "</a>"
		item.Visible = False

		' Export to Email
		ExportOptions.Add("email")
		Set item = ExportOptions.GetItem("email")
		item.Body = "<a id=""emf_sjlm"" href=""javascript:void(0);"" class=""ewExportLink ewEmail"" data-caption=""" & Language.Phrase("ExportToEmailText") & """  onclick=""ew_EmailDialogShow({lnk:'emf_sjlm',hdr:ewLanguage.Phrase('ExportToEmail'),f:document.fsjlmlist,sel:false});"">" & Language.Phrase("ExportToEmail") & "</a>"
		item.Visible = False

		' Drop down button for export
		ExportOptions.UseDropDownButton = False
		ExportOptions.DropDownButtonPhrase = Language.Phrase("ButtonExport")

		' Add group option item
		ExportOptions.Add(ExportOptions.GroupOptionName)
		Set item = ExportOptions.GetItem(ExportOptions.GroupOptionName)
		item.Body = ""
		item.Visible = False
	End Sub

	' -----------------------------------------------------------------
	' Export data in HTML/CSV/Word/Excel/XML/Email format
	'
	Sub ExportData()
		Dim XmlDoc
		Dim ExportDoc
		Dim ExportStyle

		' Default export style
		ExportStyle = "h"

		' Load recordset
		Set Rs = LoadRecordset()
		TotalRecs = Rs.RecordCount
		StartRec = 1

		' Export all
		If sjlm.ExportAll Then
			StopRec = TotalRecs

			' Set script timeout
			If EW_EXPORT_ALL_TIME_LIMIT > 0 Then
				Server.ScriptTimeout = EW_EXPORT_ALL_TIME_LIMIT
			End If

		' Export 1 page only
		Else
			SetUpStartRec() ' Set Up Start Record Position

			' Set the last record to display
			If DisplayRecs <= 0 Then
				StopRec = TotalRecs
			Else
				StopRec = StartRec + DisplayRecs - 1
			End If
		End If
		If sjlm.Export = "xml" Then
			Set XmlDoc = New cXMLDocument
		Else
			Set ExportDoc = New cExportDocument
			Set ExportDoc.Table = sjlm
			Call ExportDoc.ChangeStyle("h")
		End If
		Dim ParentTable
		ParentTable = ""
		Dim rsmaster

		' Export master record
		If EW_EXPORT_MASTER_RECORD And sjlm.MasterFilter <> "" And sjlm.CurrentMasterTable = "xwlm" Then
			Set rsmaster = xwlm.LoadRs(DbMasterFilter) ' Load master record
			If Not rsmaster.Eof Then
				If sjlm.Export = "xml" Then
					ParentTable = "xwlm"
					Call xwlm.ExportXmlDocument(XmlDoc, False, rsmaster, 1, 1, "")
				Else
					ExportStyle = ExportDoc.Style
					Call ExportDoc.ChangeStyle("v") ' Change to vertical
					If sjlm.Export <> "csv" Or EW_EXPORT_MASTER_RECORD_FOR_CSV Then
						Call xwlm.ExportDocument(ExportDoc, rsmaster, 1, 1, "")
						Call ExportDoc.ExportEmptyRow()
					End If
					Call ExportDoc.ChangeStyle(ExportStyle) ' Restore
				End If
				rsmaster.Close()
			End If
			Set rsmaster = Nothing
		End If
		If sjlm.Export = "xml" Then
			Call sjlm.ExportXmlDocument(XmlDoc, (ParentTable <> ""), rs, StartRec, StopRec, "")
		Else
			Dim sHeader
			sHeader = PageHeader
			Call Page_DataRendering(sHeader)
			ExportDoc.Text = ExportDoc.Text & sHeader
			Call sjlm.ExportDocument(ExportDoc, rs, StartRec, StopRec, "")
			Dim sFooter
			sFooter = PageFooter
			Call Page_DataRendered(sFooter)
			ExportDoc.Text = ExportDoc.Text & sFooter
		End If

		' Close recordset and connection
		Rs.Close
		Set Rs = Nothing

		' Export header and footer
		If sjlm.Export <> "xml" Then
			Call ExportDoc.ExportHeaderAndFooter()
		End If
		If sjlm.Export = "xml" Then
			XmlDoc.Output
			Set XmlDoc = Nothing
		Else
			If sjlm.Export = "email" Then
				Response.Write ExportEmail(ExportDoc.Text)
			ElseIf sjlm.Export = "pdf" Then
				Call ExportPdf(ExportDoc.Text)
			Else
				Response.Write ExportDoc.Text
			End If
			Set ExportDoc = Nothing
		End If
	End Sub

	' -----------------------------------------------------------------
	' Set up Master Detail based on querystring parameter
	'
	Sub SetUpMasterParms()
		Dim bValidMaster, sMasterTblVar
		bValidMaster = False

		' Get the keys for master table
		If Request.QueryString(EW_TABLE_SHOW_MASTER).Count > 0 Then
			sMasterTblVar = Request.QueryString(EW_TABLE_SHOW_MASTER)
			If sMasterTblVar = "" Then
				bValidMaster = True
				DbMasterFilter = ""
				DbDetailFilter = ""
			End If
			If sMasterTblVar = "xwlm" Then
				bValidMaster = True
				If Request.QueryString("lmid").Count > 0 Then
					xwlm.lmid.QueryStringValue = Request.QueryString("lmid")
					sjlm.lmid.QueryStringValue = xwlm.lmid.QueryStringValue
					sjlm.lmid.SessionValue = sjlm.lmid.QueryStringValue
					If Not IsNumeric(xwlm.lmid.QueryStringValue) Then bValidMaster = False
				Else
					bValidMaster = False
				End If
				If Request.QueryString("bh").Count > 0 Then
					xwlm.bh.QueryStringValue = Request.QueryString("bh")
					sjlm.bh.QueryStringValue = xwlm.bh.QueryStringValue
					sjlm.bh.SessionValue = sjlm.bh.QueryStringValue
					If Not IsNumeric(xwlm.bh.QueryStringValue) Then bValidMaster = False
				Else
					bValidMaster = False
				End If
			End If
		End If
		If bValidMaster Then

			' Save current master table
			sjlm.CurrentMasterTable = sMasterTblVar

			' Reset start record counter (new master key)
			StartRec = 1
			sjlm.StartRecordNumber = StartRec

			' Clear previous master session values
			If sMasterTblVar <> "xwlm" Then
				If sjlm.lmid.QueryStringValue = "" Then sjlm.lmid.SessionValue = ""
				If sjlm.bh.QueryStringValue = "" Then sjlm.bh.SessionValue = ""
			End If
		End If
		DbMasterFilter = sjlm.MasterFilter '  Get master filter
		DbDetailFilter = sjlm.DetailFilter ' Get detail filter
	End Sub

	' Set up Breadcrumb
	Sub SetupBreadcrumb()
		Dim PageId, url
		Set Breadcrumb = New cBreadcrumb
		url = ew_CurrentUrl
		url = ew_RegExReplace("\?cmd=reset(all){0,1}$", url, "") ' Remove cmd=reset / cmd=resetall
		Call Breadcrumb.Add("list", sjlm.TableVar, url, sjlm.TableVar, True)
	End Sub

	Sub ExportPdf(html)
		Response.Write html
	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

	' ListOptions Load event
	Sub ListOptions_Load()

		'Example: 
		' Dim opt
		' Set opt = ListOptions.Add("new")
		' opt.OnLeft = True ' Link on left
		' opt.MoveTo 0 ' Move to first column

	End Sub

	' ListOptions Rendered event
	Sub ListOptions_Rendered()

		'Example: 
		'ListOptions.GetItem("new").Body = "xxx"

	End Sub

	' Row Custom Action event
	Function Row_CustomAction(action, rs)

		' Return False to abort
		Row_CustomAction = True
	End Function
End Class
%>
