<!--#include file="owFunctions/I_GeneralFunctions.asp"-->
<!--#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 idCategory, sIDProduct, sDescription, sPrice, sSmallImageURL, sBToBPrice, sVisits
	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Sub ActionSubroutine()

		If ( iOWRowsShown = "" ) Or ( NOT IsNumeric(iOWRowsShown) ) Then
			iOWRowsShown = 5
		End If
		
		' define the array to store products (2 columns)
		Randomize()
		iRandomNumber = Int (1000*Rnd)+1
		sSQLText = "SELECT TOP " & iOWRowsShown & " idProduct, description, details, price, smallImageURL, bToBPrice, visits, Rnd(" & -1*iRandomNumber & "*idProduct) AS RandCol FROM Products WHERE showInHome=-1 AND active=-1 ORDER BY 8"
		Call DB_getFromDatabase(sSQLText, rsStoreData, "")
		If ( NOT rsStoreData.EOF ) Then
			Response.Write "<table cellpadding=3 border=0 width=100" & "%" & ">"
			While ( NOT rsStoreData.EOF )
				Response.Write "<tr><td width=" & (100/iNumColums) & "%" & "><table cellpadding=0 cellspacing=0 border=0 width=100" & "%" & " style='border-top:1px solid #CCCCCC;'><tr>"
				For iX = 0 to (iNumColums-1)
					Response.Write "<td valign=top width=" & (100/iNumColums) & "%" & ">"
					sIDProduct		= rsStoreData("idProduct")
					sDescription	= rsStoreData("description") 
					sPrice			= rsStoreData("price")
					sBToBPrice		= rsStoreData("bToBprice")
					sVisits			= rsStoreData("visits")
					sSmallImageURL	= rsStoreData("smallImageURL")
					
					call singleProd(rsStoreData)
					Response.Write "</td>"
					rsStoreData.MoveNext
					If ( rsStoreData.EOF ) Then
						For iX1 = iX to (iNumColums-1)
							Response.Write "<td width=" & (100/iNumColums) & "%" & "></td>"
						Next
						Exit For
					End If
				Next
				Response.Write "</tr></table></td></tr>"
			Wend
			Response.Write "</table>"
		End If
		Call DB_closeRecordset(rsStoreData)
		
	End Sub
	'************************************************************************************
		
		
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	sub singleProd(rsStoreData)
	
		' get the category this product is in so we can display links to "Buy now" and to view it's details
		sSQLText = "SELECT c.idCategory FROM categories c, CatProdMap cp, products p WHERE p.idProduct=cp.idProduct AND cp.idCategory=c.idCategory AND p.idProduct = " & sIDProduct
		Call DB_getFromDatabase(sSQLText, rsStoreData2,"")
		If ( NOT rsStoreData2.EOF ) Then
			idCategory = rsStoreData2("idCategory")
		Else
			idCategory = 1
		End If
		Call DB_closeRecordset(rsStoreData2)
		%>
		<table height=110 cellspacing=0 border=0 width="100%" cellpadding="0">
			<tr> 
				<td width=5 valign="top"><img src="../owTemplates/images/ClearDot.gif" width="5" height="1"></td>
				<td valign="top"> 
					<table width="100%" border="0" cellspacing="0" cellpadding="5" align="left">
						<tr> 
							<td> 
								<center>
								<%call prodImage(rsStoreData)%>
								<%call prodDetail(rsStoreData)%>
							</td>
						</tr>
					</table>
				</td>
				<td valign="top" width="10">&nbsp; </td>
			</tr>
		</table>
		<br><br>
		<%
	end sub
	'************************************************************************************
	
	
	
	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	sub prodImage(rsStoreData)
	
		Response.Write "<center><table width=100" & "%" & " height=200 cellpadding=0 cellspacing=0 border=0><tr><td align=center>"
		If ( Trim(sSmallImageURL) <> "" ) Then
			%>
			<a href="owProductDetail.asp?idproduct=<%=rsStoreData("idProduct")%>&idCategory=<%=idCategory%>"><img src='<%=sOWImagesDir%>/small/<%=sSmallImageURL%>' alt="<%=server.HTMLEncode(rsStoreData("description"))%>" border=0 width=150></a><br>
			<%
		Else
			%>
			<a href="owProductDetail.asp?idproduct=<%=rsStoreData("idProduct")%>&idCategory=<%=idCategory%>"><img src='owTemplates/images/imageNA.gif' alt=" <%=Server.HTMLEncode(LANG_DT( "IMAGENOTAVAILABLE", "Image not available" ))%> " border=0></a><br>
			<%
		End If
		Response.Write "</td></tr></table></center>"
	
	end sub
	'************************************************************************************
		


	'************************************************************************************
	'*																					*
	'*																					*
	'*																					*
	'************************************************************************************
	Sub prodDetail(rsStoreData)
	
		Dim rsStoreData2

		Response.Write "<font size=+1 color=660000>"

		if sBtoBPrice>0 and (bOWShowBtoBPrice or ACCNT_InGroup(iLoginAccountUnq, C_GROUP_WHOLESALE)) then
			Response.Write CONVERSION_Currency(sBToBPrice)
		Else
			Response.Write CONVERSION_Currency(sPrice)
		End If

		%>
		</font>

		<table cellpadding=0 cellspacing=0 border=0 height=40><tr><td valign=top><a href="owProductDetail.asp?idproduct=<%=sIDProduct%>&idCategory=<%=idCategory%>"><%=sDescription%></a></b></td></tr></table>
	
		<table cellpadding=0 cellspacing=0 border=0 width=100%>
			<tr>
				<td>
					<br><%=LANG_DT( "DEFAULT_POPU", "Popularity" )%>:  <%=sVisits%> 
				</td>
				<td align=right>
					<a href="owBasket/owAddItem.asp?idProduct=<%=sIDProduct%>"><img src="owTemplates/images/English/small_addCart.gif" border="0"></a>
				</td>
			</tr>
		</table>
		<%
		
	End Sub
	'************************************************************************************
%>