<!--#include file="../owFunctions/I_GeneralFunctions.asp"-->
<%sPath = "../"%>
<!--#include file="../owTemplates/Template.asp"-->
<%
	'************************************************************************************
	'*																					*
	'*	MODIFICATION TO THIS SCRIPT OR ANY FILES INCLUDED WITH 							*
	'*		ONEWORLDSTORE IS DONE AT YOUR OWN RISK!										*
	'*	Product  : OneWorldStore														*
	'*	Version  : 9.0000																*
	'*	Modified : June 2004															*
	'*	Copyright:	Copyright (C) 2004 OneWorldStore.Com								*
	'*				Registration Number: 1024507										*
	'*				http://strategis.ic.gc.ca/											*
	'*																					*
	'************************************************************************************
	
	Dim sIDSearch, sQuerystring, sKeywords
	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Sub ActionSubroutine()
	
		sIDSearch		= Trim(Request("sIDSearch"))
		sQuerystring	= "sIDSearch=" & sIDSearch
		%>
		<script language='JavaScript1.2' type='text/javascript'>
	
			function PaginationLink(sQueryString){
				document.location = "DisplayResults.asp?" + sQueryString;
			}
			
		</script>
		<%Call RefreshSearchResults()%>
		<table width=<%=sOWStoreTableWidth%> border=0 style='border: 1px solid #000000;' cellspacing=0 cellpadding=5>
			<tr bgcolor="#eeeeee"><td style='border-bottom: 1px solid #000000;'><b><%=LANG_DT( "SEARCHD_HEAD", "Product Search Results" )%></b></td></tr>
			<tr>
				<td>
					<%
					' get the keywords & other search criteria to print out
					sSQLText = "SELECT Keywords, InitialPrice, FinalPrice, IDSupplier, IDCategory FROM owSearches WHERE idSearch = " & sIDSearch
					Call DB_getFromDatabase(sSQLText, rsStoreData, "")
					If ( NOT rsStoreData.EOF ) Then
						sKeywords = Trim(rsStoreData("Keywords"))
						%>
						<table>
							<%If ( Trim(rsStoreData("Keywords")) <> "" ) Then%>
							<tr>
								<td><b><%=LANG_DT( "SEARCHD_KEYWORDS", "Keywords" )%>:</td>
								<td><%=sKeywords%></td>
							</tr>
							<%End If%>
							<%If ( Trim(rsStoreData("InitialPrice")) <> "" ) And ( Trim(rsStoreData("FinalPrice")) <> "" ) Then%>
							<tr>
								<td><b><%=LANG_DT( "SEARCHD_PRICE", "Price Between" )%>:</td>
								<td><%=CONVERSION_Currency(Trim(rsStoreData("InitialPrice")))%> <%=LANG_DT( "SEARCHD_AND", "And" )%> <%=CONVERSION_Currency(Trim(rsStoreData("FinalPrice")))%></td>
							</tr>
							<%End If%>
							<%If ( Trim(rsStoreData("IDCategory")) <> "" ) Then%>
							<tr>
								<td><b><%=LANG_DT( "SEARCHD_CAT", "Category" )%>:</td>
								<td><%=Trim(rsStoreData("IDCategory"))%></td>
							</tr>
							<%End If%>
						</table>
						<%
					End If
					Call DB_closeRecordset(rsStoreData)
					%>
				</tD>
			</tr>
			<tr>
				<td style='border-top: 1px solid #000000;'>&nbsp;</td>
			</tr>
			<tr>
				<td>
					<%Call SearchConf()%>
				</td>
			</tr>
		</table>		
		<%
		
	End Sub
	'************************************************************************************

	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Sub SearchConf()
		
		sSQLCount = "SELECT Count(*) FROM owSearchResults R, Products P WHERE R.idSearch = " & Request("sIDSearch") & " AND R.idProduct = P.idProduct"
		sSQLText = "SELECT P.idProduct, P.SKU, P.Description, P.ListPrice, P.Price, P.imageURL, P.SmallImageUrl, P.bToBPrice, P.visits, C.idCategory, C.categoryDesc, C.idParentCategory, C.imageCategory FROM owSearchResults R, Products P, Categories C WHERE R.idProduct = P.idProduct AND R.idCategory = C.idCategory AND R.idSearch = " & Request("sIDSearch")

		iBeginPagination = SetupPagination( sSQLCount, bResetTtlNumItems, bResetDBLoc )
		Call PaginationQuery( sSQLText, rsStoreData, iBeginPagination )
		If ( rsStoreData.EOF ) Then
			If ( sKeywords = "OW_NEW" ) Then
				Response.Write "<center><B>" & LANG_DT( "SEARCHD_NONEW", "Sorry, there are no new products at this time." ) & "</b></center>"
			Else
				Response.Write "<center><B>" & LANG_DT( "SEARCHD_NONEFOUND", "Sorry, no products were found using your search criteria." ) & "</b></center>"
			End If
		Else
			Call TEMPLATE_PrintRecordsetNav( sURL, iOWNumPerPage, iTtlNumItems, iDBLoc, sQuerystring )
			sSQLCount = 0
			While ( ( NOT rsStoreData.EOF ) And ( sSQLCount < iOWNumPerPage ) )
				sIdProduct		= rsStoreData("idProduct")
				sDescription	= rsStoreData("description")   
				sPrice			= rsStoreData("price")   
				sBtoBPrice		= rsStoreData("bToBPrice")   
				slistprice		= rsStoreData("listprice")
				sSmallImageUrl	= rsStoreData("smallImageUrl")   
				sVisits			= rsStoreData("visits")
				sIDCategory		= rsStoreData("idCategory")
				Call TEMPLATE_ProductListingDisplay( sSmallImageUrl, sDescription, slistprice, sPrice, sBtoBPrice, 0, sVisits, sIdProduct, sIDCategory )
				sSQLCount = sSQLCount + 1
				rsStoreData.moveNext
			Wend
		End If
		Call DB_closeRecordset(rsStoreData)

	End Sub
	'************************************************************************************
	
	
	'************************************************************************************
	'*																					*
	'*	This resets the timeout period of the search results to the current time.		*
	'*																					*
	'************************************************************************************
	Sub RefreshSearchResults()
	
		If ( Trim(Request("sIDSearch")) <> "" ) Then
			Call DB_updateDatabase ("UPDATE owSearches SET DateChanged = #" & CONVERSION_FormatDate(Now(), "L") & "# WHERE idSearch = " & Request("sIDSearch"))
		End If
	
	End Sub
	'************************************************************************************
%>