<%
'This code is copyright (c) Internet Business Solutions SL, all rights reserved.
'The contents of this file are protect under law as the intellectual property
'of Internet Business Solutions SL. Any use, reproduction, disclosure or copying
'of any kind without the express and written permission of Internet Business 
'Solutions SL is forbidden.
'Author: Vince Reid, vince@virtualred.net
	prodoptions=""
	saveLCID = Session.LCID
	productdisplayscript(noproductoptions<>true) %>
			<table width="<%=innertablewidth%>" border="0" cellspacing="<%=innertablespacing%>" cellpadding="<%=innertablepadding%>" bgcolor="<%=innertablebg%>">
<%	if productcolumns="" then productcolumns=1
	if IsEmpty(showcategories) OR showcategories=true then %>
			  <tr>
				<td colspan="<%=productcolumns%>">
				  <table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
					  <td class="prodnavigation" align="<%=headeralign%>"><strong><p class="prodnavigation"><% response.write tslist %></p></strong></td>
					  <td align="right">&nbsp;<% if nobuyorcheckout<>true then %><a href="cart.asp"><img src="images/checkout.gif" border="0" alt="<%=xxCOTxt%>" /></a><% end if %></td>
					</tr>
				  </table>
				</td>
			  </tr>
<%	end if
if nowholesalediscounts=true AND Session("clientUser")<>"" then
	if ((Session("clientActions") AND 8) = 8) OR ((Session("clientActions") AND 16) = 16) then noshowdiscounts=true
end if
if noshowdiscounts<>true then
	Session.LCID = 1033
	sSQL = "SELECT DISTINCT "&getlangid("cpnName",1024)&" FROM coupons LEFT OUTER JOIN cpnassign ON coupons.cpnID=cpnassign.cpaCpnID WHERE ("
	addor = ""
	if catid<>"0" then
		sSQL = sSQL & addor & "((cpnSitewide=0 OR cpnSitewide=3) AND cpaType=1 AND cpaAssignment IN ('"&Replace(topsectionids,",","','")&"'))"
		addor = " OR "
	end if
	tdt = Date()
	sSQL = sSQL & addor & "(cpnSitewide=1 OR cpnSitewide=2)) AND cpnNumAvail>0 AND cpnEndDate>="&datedelim&VSUSDate(tdt)&datedelim&" AND cpnIsCoupon=0"
	Session.LCID = saveLCID
	rs2.Open sSQL,cnn,0,1
	if NOT rs2.EOF then
%>
			  <tr>
				<td align="left" colspan="<%=productcolumns%>">
				  <p><strong><%=xxDsProd%></strong><br /><font color="#FF0000" size="1">
				  <%	do while NOT rs2.EOF
							response.write rs2(getlangid("cpnName",1024)) & "<br />"
							rs2.MoveNext
						loop %></font></p>
				</td>
			  </tr>
<%	end if
	rs2.Close
end if
		If iNumOfPages > 1 AND pagebarattop=1 Then 
%>
			  <tr>
				<td colspan="<%=productcolumns%>" align="center" class="pagenums"><p class="pagenums"><%
					Response.Write writepagebar(CurPage, iNumOfPages) & "<br />" %><img src="images/clearpixel.gif" width="300" height="5" alt="" /></p></td>
			  </tr>
<%
		end if
netnav = true
if instr(Request.ServerVariables("HTTP_USER_AGENT"), "compatible") > 0 OR instr(Request.ServerVariables("HTTP_USER_AGENT"), "Gecko") > 0 then netnav = false
function atb(size)
	if netnav then
		atb = CInt(size / 2 + 1)
	else
		atb = size
	end if
end function
	Do While Not rs.EOF And Count < rs.PageSize
		if Trim(rs(getlangid("pLongDescription",4)))<>"" OR NOT (Trim(rs("pLargeImage"))="" OR IsNull(rs("pLargeImage")) OR Trim(rs("pLargeImage"))="prodimages/") then
			if (rs("pSell") AND 4)=4 then
				startlink="<a href='"&cleanforurl(rs("pName"))&".asp"&IIfVr(catid<>"" AND catid<>"0" AND int(catid)<>rs("pSection") AND nocatid<>TRUE,"?cat="&catid,"")&"'>"
				endlink="</a>"
			elseif detailslink<>"" then
				startlink=replace(replace(detailslink,"%largeimage%", rs("pLargeImage")),"%pid%", rs("pId"))
				endlink=detailsendlink
			else
				startlink="<a href='proddetail.asp?prod="&Server.URLEncode(rs("pId"))&IIfVr(catid<>"" AND catid<>"0" AND int(catid)<>rs("pSection") AND nocatid<>TRUE,"&cat="&catid,"")&"'>"
				endlink="</a>"
			end if
		else
			startlink=""
			endlink=""
		end if
		Session.LCID = 1033
		if NOT isrootsection then
			if IsNull(rs("pSection")) then thetopts = 0 else thetopts = rs("pSection")
			gotdiscsection = false
			for cpnindex=0 to adminProdsPerPage-1
				if aDiscSection(0,cpnindex)=thetopts then
					gotdiscsection = true
					exit for
				elseif aDiscSection(0,cpnindex)="" then
					exit for
				end if
			next
			aDiscSection(0,cpnindex) = thetopts
			if NOT gotdiscsection then
				topcpnids = thetopts
				for index=0 to 10
					if thetopts=0 then
						exit for
					else
						sSQL = "SELECT topSection FROM sections WHERE sectionID=" & thetopts
						rs2.Open sSQL,cnn,0,1
						if NOT rs2.EOF then
							thetopts = rs2("topSection")
							topcpnids = topcpnids & "," & thetopts
						else
							rs2.Close
							exit for
						end if
						rs2.Close
					end if
				next
				aDiscSection(1,cpnindex) = topcpnids
			else
				topcpnids = aDiscSection(1,cpnindex)
			end if
		end if
		alldiscounts = ""
		if noshowdiscounts<>true then
			tdt = Date()
			sSQL = "SELECT DISTINCT "&getlangid("cpnName",1024)&" FROM coupons LEFT OUTER JOIN cpnassign ON coupons.cpnID=cpnassign.cpaCpnID WHERE (cpnSitewide=0 OR cpnSitewide=3) AND cpnNumAvail>0 AND cpnEndDate>="&datedelim&VSUSDate(tdt)&datedelim&" AND cpnIsCoupon=0 AND ((cpaType=2 AND cpaAssignment='"&rs("pID")&"')"
			if NOT isrootsection then sSQL = sSQL & " OR (cpaType=1 AND cpaAssignment IN ('"&Replace(topcpnids,",","','")&"') AND NOT cpaAssignment IN ('"&Replace(topsectionids,",","','")&"'))"
			sSQL = sSQL & ")"
			rs2.Open sSQL,cnn,0,1
			do while NOT rs2.EOF
				alldiscounts = alldiscounts & rs2(getlangid("cpnName",1024)) & "<br />"
				rs2.MoveNext
			loop
			rs2.Close
		end if
		Session.LCID = saveLCID
		if Count MOD productcolumns = 0 then response.write "<tr>" %>
				<td width="<%=Int(100 / productcolumns)%>%" align="center" valign="top">
				  <table width="100%" border="0" cellspacing="4" cellpadding="4">
			  <% if showproductid=true then response.write "<tr><td><div class=""prodid""><strong>" & xxPrId & ":</strong> " & rs("pID") & "</div></td></tr>" %>
				    <tr>
					  <td width="100%" align="center" valign="middle">
						<% if Trim(rs("pImage"))="" or IsNull(rs("pImage")) or Trim(rs("pImage"))="prodimages/" then %>
						  &nbsp;
						<% else %>
						  <%=startlink%><img class="prodimage" src="<%=rs("pImage")%>" border="0" alt="<%=Replace(rs(getlangid("pName",1))&"","""","&quot;")%>" /><%=endlink%>
						<% end if %>
					  </td>
					</tr>
<%	if currencyseparator="" then currencyseparator=" "
	updatepricescript(noproductoptions<>true)
	thedesc = trim(rs(getlangid("pDescription",2))) %>
	<form method="post" name="tForm<%=Count%>" action="cart.asp" onsubmit="return formvalidator<%=Count%>(this)">
					<tr>
					  <td width="100%">
					    <strong><div class="prodname"><%=startlink & rs(getlangid("pName",1)) & endlink & xxDot%></div></strong><% if alldiscounts<>"" then response.write "<font color=""#FF0000""><strong><span class=""discountsapply"">"&xxDsApp&"</span></strong><br /><font size=""1""><div class=""proddiscounts"">" & alldiscounts & "</div></font></font>" %>
<%	if thedesc<>"" then response.write "<div class=""proddescription"">" & thedesc & "</div>" else response.write "<br />"
optionshavestock=true
if IsArray(prodoptions) AND noproductoptions<>true then
	response.write "<div class=""prodoptions""><table border='0' cellspacing='1' cellpadding='1' width='100%'>"
	for rowcounter=0 to UBOUND(prodoptions,2)
		index=0
		gotSelection=false
		cacheThis=NOT useStockManagement
		do while index < (maxprodopts-1) AND aOption(0,index)<>0
			if aOption(0,index)=Int(prodoptions(0,rowcounter)) then
				gotSelection=true
				exit do
			end if
			index = index + 1
		loop
		if NOT gotSelection then
			aOption(2,index) = false
			sSQL="SELECT optID,"&getlangid("optName",32)&","&getlangid("optGrpName",16)&","&OWSP&"optPriceDiff,optType,optFlags,optStock,optPriceDiff AS optDims FROM options INNER JOIN optiongroup ON options.optGroup=optiongroup.optGrpID WHERE optGroup="&prodoptions(0,rowcounter)&" ORDER BY optID"
			rs2.Open sSQL,cnn,0,1
			if NOT rs2.EOF then
				if Abs(Int(rs2("optType")))=3 then
					aOption(2,index)=true
					fieldHeight = cInt((cDbl(rs2("optDims"))-Int(rs2("optDims")))*100.0)
					aOption(1,index) = "<tr><td align='right' width='30%'><strong>"&rs2(getlangid("optGrpName",16))&":</strong></td><td align=""left""> <input type='hidden' name='optnPLACEHOLDER' value='"&rs2("optID")&"' />"
					if fieldHeight<>1 then
						aOption(1,index) = aOption(1,index) & "<textarea wrap='virtual' name='voptnPLACEHOLDER' cols='"&atb(Int(rs2("optDims")))&"' rows='"&fieldHeight&"'>"
						aOption(1,index) = aOption(1,index) & rs2(getlangid("optName",32))&"</textarea>"
					else
						aOption(1,index) = aOption(1,index) & "<input maxlength='255' type='text' name='voptnPLACEHOLDER' size='"&atb(Int(rs2("optDims")))&"' value="""&Replace(rs2(getlangid("optName",32)),"""","&quot;")&""" />"
					end if
					aOption(1,index) = aOption(1,index) & "</td></tr>"
				else
					aOption(1,index) = "<tr><td align='right' width='30%'><strong>"&rs2(getlangid("optGrpName",16))&":</strong></td><td align=""left""> <select class=""prodoption"" onchange='updatepricePLACEHOLDER();' name='optnPLACEHOLDER' size='1'>"
					if Int(rs2("optType"))>0 then aOption(1,index) = aOption(1,index) & "<option value=''>"&xxPlsSel&"</option>"
					do while not rs2.EOF
						aOption(1,index) = aOption(1,index) & "<option "
						if useStockManagement AND ((rs("pSell") AND 2)=2) AND rs2("optStock") <= 0 then aOption(1,index) = aOption(1,index) & "class=""oostock"" " else aOption(2,index)=true
						aOption(1,index) = aOption(1,index) & "value='"&rs2("optID")&"'>"&rs2(getlangid("optName",32))
						if hideoptpricediffs<>true AND cDbl(rs2("optPriceDiff"))<>0 then
							aOption(1,index) = aOption(1,index) & " ("
							if cDbl(rs2("optPriceDiff")) > 0 then aOption(1,index) = aOption(1,index) & "+"
							if (rs2("optFlags") AND 1) = 1 then
								cacheThis=false
								aOption(1,index) = aOption(1,index) & FormatEuroCurrency((rs("pPrice")*rs2("optPriceDiff"))/100.0)&")"
							else
								aOption(1,index) = aOption(1,index) & FormatEuroCurrency(rs2("optPriceDiff"))&")"
							end if
						end if
						aOption(1,index) = aOption(1,index) & "</option>"&vbCrLf
						rs2.MoveNext
					loop
					aOption(1,index) = aOption(1,index) & "</select></td></tr>"
				end if
			end if
			if cacheThis then aOption(0,index) = Int(prodoptions(0,rowcounter))
			rs2.Close
		end if
		response.write Replace(Replace(aOption(1,index),"optnPLACEHOLDER","optn"&rowcounter),"updatepricePLACEHOLDER",IIfVr((rs("pPrice")=0 AND pricezeromessage<>"") OR noprice=true,"dummyfunc","updateprice"&Count),1,1)
		optionshavestock = (optionshavestock AND aOption(2,index))
	next
	response.write "</table></div>"
end if
					if noprice<>true then
						if cDbl(rs("pListPrice"))<>0.0 then response.write Replace(xxListPrice, "%s", FormatEuroCurrency(rs("pListPrice"))) & "<br />"
						if rs("pPrice")=0 AND pricezeromessage<>"" then
							response.write "<div class=""prodprice"">" & pricezeromessage & "</div>"
						else
							response.write "<div class=""prodprice""><strong>" & xxPrice & ":</strong> <span class=""price"" id=""pricediv" & Count & """>" & FormatEuroCurrency(rs("pPrice")) & "</span> "
							if showtaxinclusive=true AND (rs("pExemptions") AND 2)<>2 then response.write Replace(ssIncTax,"%s", "<span id=""pricedivti" & Count & """>" & FormatEuroCurrency(rs("pPrice")+(rs("pPrice")*countryTax/100.0)) & "</span> ")
							response.write "</div>"
							extracurr = ""
							if currRate1<>0 AND currSymbol1<>"" then extracurr = replace(currFormat1, "%s", FormatNumber(rs("pPrice")*currRate1, checkDPs(currSymbol1))) & currencyseparator
							if currRate2<>0 AND currSymbol2<>"" then extracurr = extracurr & replace(currFormat2, "%s", FormatNumber(rs("pPrice")*currRate2, checkDPs(currSymbol2))) & currencyseparator
							if currRate3<>0 AND currSymbol3<>"" then extracurr = extracurr & replace(currFormat3, "%s", FormatNumber(rs("pPrice")*currRate3, checkDPs(currSymbol3)))
							if extracurr<>"" then response.write "<div class=""prodcurrency""><span class=""extracurr"" id=""pricedivec" & Count & """>" & extracurr & "</span></div>"
						end if
					end if %>
					  </td>
					</tr><%
if nobuyorcheckout<>true then
	response.write "<tr><td align=""center"">"
	if useStockManagement then
		if ((rs("pSell") AND 2)=2) then isInStock = optionshavestock else isInStock = Int(rs("pInStock")) > 0
	else
		isInStock = Int(cStr((rs("pSell") AND 1))) <> 0
	end if
	if isInStock then
%>
<input type="hidden" name="id" value="<%=rs("pID")%>" />
<input type="hidden" name="mode" value="add" />
<input type="hidden" name="frompage" value="<%=Request.ServerVariables("URL")&IIfVr(Trim(Request.ServerVariables("QUERY_STRING"))<>"","?","")&Request.ServerVariables("QUERY_STRING")%>" />
<%		if showquantonproduct=true then response.write "<input type=""text"" name=""quant"" size=""2"" maxlength=""5"" value=""1"" />"
		if custombuybutton<>"" then response.write custombuybutton else response.write "<input align=""middle"" type=""image"" src=""images/buy.gif"" />"
	else
		response.write "<strong>"&xxOutStok&"</strong>"
	end if
	response.write "</td></tr>"
end if%>			</form>
				  </table>
				</td><%
		Count = Count + 1
		rs.MoveNext
		if Count MOD productcolumns = 0 then
			response.write "</tr>"
			if Not rs.EOF And Count < rs.PageSize then
				response.write "<tr>"
				for index=1 to productcolumns
					response.write "<td align=""center""><hr width=""70%"" align=""center"" /></td>"
				next
				response.write "</tr>"
			end if
		end if
	loop
	if Count MOD productcolumns <> 0 then
		do while Count MOD productcolumns <> 0
			response.write "<td width="""&Int(100 / productcolumns)&"%"" align=""center"">&nbsp;</td>"
			Count = Count + 1
		loop
		response.write "</tr>"
	end if
%>			  <tr>
				<td colspan="<%=productcolumns%>" align="center" class="pagenums"><p class="pagenums"><%
					If iNumOfPages > 1 AND nobottompagebar<>true Then Response.Write writepagebar(CurPage, iNumOfPages) %><br />
				<img src="images/clearpixel.gif" width="300" height="1" alt="" /></p></td>
			  </tr>
			</table>