%@ LANGUAGE=VBScript %>
<%
Response.Buffer = True
Dim connect, recordset, whereclause, query, key, itemNumber
Dim lineIndex, begin_search, preOrder, asapOrder, asapDesc, fullOrderBy
Dim pageNumber, uniqueID, newID, asapIfr, prefix, suffix
uniqueID = "facility_290"
If Session("uniqueID_facility_290") = "" Then
Session("uniqueID_facility_290") = uniqueID
newID = 1
End If
If Session("uniqueID_facility_290") <> uniqueID Then
Session("uniqueID_facility_290") = uniqueID
newID = 1
End If
asapDesc = Request("asapDesc")
If asapDesc = "1" Then
asapDesc = " DESC"
End If
preOrder = " ORDER BY facility."
asapOrder = Request("asapOrder")
' iframe stuff here ------------------------------
asapIfr = Request("asapIfr")
If asapIfr <> "" Then
Session("asapIfr_facility_290") = asapIfr
End If
If Session("asapIfr_facility_290") <> "" Then
asapIfr = Session("asapIfr_facility_290")
End If
lineIndex = 0
Dim Facility
Dim allRecords
Dim asapPages
Dim asapChapters
Dim asapChapter
Dim URL
Dim start10
Dim stop10
Dim next1
Dim previous1
Dim Nextbutton
Dim Previousbutton
Dim nexturl
Dim previousurl
Dim NoResults
%>
<%
pageNumber = CInt(Request("pageNumber"))
If PageNumber = 0 then
pageNumber = 1
End If
' Get the form information in local variables
Facility = Trim(Request("Facility"))
If Facility <> "" Then
newID = 1
End If
If newID = 1 Then
begin_search = 1
Else
begin_search = Request("begin_search")
End If
If begin_search = 1 Then
fullOrderBy = " ORDER BY facility.Facility"
Session("fullOrderBy_facility_290") = fullOrderBy
whereclause = "WHERE "
If Facility <> "" Then
whereclause = whereclause & "facility.Facility LIKE '%" & Facility & "%' AND "
End If
If Right(whereclause, 4) = "AND " Then
whereclause = Left(whereclause, Len(whereclause) - 4) ' strip off 'AND '
Else
whereclause = Left(whereclause, Len(whereclause) - 6) ' strip off 'WHERE '
End If
query = "SELECT * FROM facility " & whereclause
Session("SSS_query_facility_290") = query
End If
If Session("SSS_query_facility_290") = "" Then
fullOrderBy = " ORDER BY facility.Facility"
Session("fullOrderBy_facility_290") = fullOrderBy
query = " SELECT * FROM facility " & whereclause
Session("SSS_query_facility_290") = query
query = query + fullOrderBy
Else
If asapOrder = "" Then
fullOrderBy = Session("fullOrderBy_facility_290")
query = Session("SSS_query_facility_290") + fullOrderBy
Else
fullOrderBy = preOrder + asapOrder + asapDesc
Session("fullOrderBy_facility_290") = fullOrderBy
query = Session("SSS_query_facility_290") + fullOrderBy
End If
End If
set recordset = Server.CreateObject("ADODB.Recordset")
recordset.CursorType = 3 ' adOpenStatic
recordset.PageSize = 90
recordset.Open query, connect
if not recordset.eof then
recordset.AbsolutePage = CInt(pageNumber)
end if
allRecords = recordset.RecordCount
Session("allRecords_facility_290") = allRecords
asapPages = (allRecords / 90)
%>
directory Search Results
<%
If asapIfr = "" Then
%>
<%
Else
prefix = "javascript:newWindow('"
suffix = "')"
End If
%>
<%
if NoResults = True Then
%>
Sorry, no records in the database matched your search parameters. Click Back and try again.
<%
End If ' No match
%>
<%
' total of pages
If asapPages - Int(asapPages) > 0 Then
asapPages = Int(asapPages) + 1
End If
' this is the total number of chapters holding the pages
asapChapters = asapPages / 10
If asapChapters - Int(asapChapters) > 0 Then
asapChapters = Int(asapChapters) + 1
End If
' this is the current chapter
asapChapter = pageNumber * .1
If asapChapter = 0 Then
asapChapter = 1
End If
If asapChapter - Int(asapChapter) > 0 Then
asapChapter = Int(asapChapter) + 1
End If
' this would be the first page in the current chapter
start10 = (asapChapter * 10) - 9
' this would be the last page in the current chapter
stop10 = asapChapter * 10
If stop10 > asapPages Then
stop10 = asapPages
End If
next1 = stop10 + 1
previous1 = start10 - 1
Nextbutton = "directory_search_results.asp?pageNumber=" + CStr(next1)
Previousbutton = "directory_search_results.asp?pageNumber=" + CStr(previous1)
%>
<%
End If
' loops through entire range of numbers
For i = start10 to stop10
URL = "directory_search_results.asp?pageNumber=" + CStr(i)
If i = pageNumber Then
%>