<!--#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/											*
	'*																					*
	'************************************************************************************

	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Sub ActionSubroutine()

		Call DeleteOldSearchResults()
		Call SearchProducts()
		
	End Sub
	'************************************************************************************

	
	'************************************************************************************
	'*																					*
	'*	This displays the search form.													*
	'*																					*
	'************************************************************************************
	Sub SearchProducts()

		%>
		<script type="text/javascript" src="../owManager/Script/fValConfig.js"></script>
		<script type="text/javascript" src="../owManager/Script/fValidate.js"></script>
		
		<script language='JavaScript1.2' type='text/javascript'>
	
			function SubmitForm(objForm, sAction){
			
				if ( validateForm( objForm, false, false, false, true, 17 ) )
				{
					objForm.sAction.value = sAction;
					objForm.submit();
				}else{
					return false;
				}
			}
			
		</script>
		
		<center>
		<form action="PrepareResults.asp" method="post" onSubmit='return SubmitForm(this, "ASearch");'>
		<input type = "hidden" name = "sAction" value = "ASearch">
		<input type = "hidden" name = "sReferer" value = "<%=Server.HTMLEncode(Request.ServerVariables("HTTP_REFERER"))%>">
			<table width=<%=sOWStoreTableWidth%> border=0 style='border: 1px solid #000000;' cellspacing=0 cellpadding=5>
				<tr bgcolor="#eeeeee"> 
					<td colspan=2 style='border-bottom: 1px solid #000000;'><b><%=LANG_DT( "SEARCH_ADVSEARCH", "Advanced Search" )%></b></td>
				</tr>
				<tr>     
					<td><%=LANG_DT( "SEARCH_CAT", "Category" )%></td>
					<td>
						<select name="sIDCategory">
							<option value=''><%=LANG_DT( "SEARCH_ALLCAT", "Search All Categories" )%></option>
							<%Call STRUCTURE_RecurseCategories(0, iLevel, "SELECT", -1)%>
						</select>
					</td>
				</tr>
				<tr> 
					<td height="31"><%=LANG_DT( "SEARCH_PRICE", "Price" )%></td>
					<td height="31">
						<%=LANG_DT( "SEARCH_FROM", "From" )%> &nbsp;<%=sOWCurrencySymbol%><%VALIDATE_textbox "sInitialPrice", "0", 6, "textbox", "decimalr|bok"%>
						<%=LANG_DT( "SEARCH_TO", "To" )%> &nbsp;<%=sOWCurrencySymbol%><%VALIDATE_textbox "sFinalPrice", "0", 6, "textbox", "decimalr|bok"%>
					</td>
				</tr>
				<tr> 
					<td><%=LANG_DT( "SEARCH_KEYWORDS", "Keywords<br>(seperate keywords with a comma)" )%></td>
					<td><%VALIDATE_textbox "sKeywords", "", 40, "textbox", "blank"%></td>
				</tr>
				<tr> 
					<td align=right colspan=2 style='border-top: 1px solid #000000;'>
						<input type="submit" name="Submit" value=" <%=LANG_DT( "SEARCH_GO", "Search for Products" )%> &gt; ">
					</td>
				</tr>
			</table>
		</form>
		<%

	End Sub
	'************************************************************************************
	
	
	'************************************************************************************
	'*																					*
	'*	This deletes all old search results.											*
	'*																					*
	'************************************************************************************
	Sub DeleteOldSearchResults()

		Dim rsStoreData, sSQLText
		
		Set rsStoreData = CreateObject("ADODB.Recordset")
		sSQLText = "SELECT * FROM owSearches WHERE DateChanged < #" & CONVERSION_FormatDate(DateAdd("h", -1, NOW), "L") & "#"
		Call DB_getFromDatabase(sSQLText, rsStoreData,"")
		If ( NOT rsStoreData.EOF ) Then
			' drop all the old temp tables
			While ( NOT rsStoreData.EOF )
				Call DB_updateDatabase ("DELETE FROM owSearchResults WHERE idSearch = " & rsStoreData("idSearch"))
				rsStoreData.MoveNext
			Wend
			' delete the entries of these old temp tables
			Call DB_updateDatabase ("DELETE FROM owSearches WHERE DateChanged < #" & CONVERSION_FormatDate(DateAdd("h", -1, NOW), "L") & "#")
		End If
		rsStoreData.Close
		Set rsStoreData = Nothing

	End Sub
	'************************************************************************************
%>