<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/css" href="http://<%=sitewebaddress%>/styles/rss.css" ?>
<%
'Sets the Locale ID session property - <ook!>www.ultra-dumb.co.uk</ook!>
Session.LCID = 2057
%><% Response.Buffer = true
   Response.ContentType = "application/rss+xml "
   
Function ApplyXMLFormatting(strInput)
  strInput = Replace(strInput,"&", "&amp;")
  strInput = Replace(strInput,"'", "&apos;")
  strInput = Replace(strInput,"""", "&quot;")
  strInput = Replace(strInput, ">", "&gt;")
  strInput = Replace(strInput,"<", "&lt;")
  strInput = Replace(strInput,"font", " ")
  strInput = Replace(strInput,"#000000", "white")
  ApplyXMLFormatting = strInput
End Function   
    %><%
Function return_RFC822_Date(myDate, offset)
   Dim myDay, myDays, myMonth, myYear
   Dim myHours, myMonths, mySeconds

   myDate = CDate(myDate)
   myDay = WeekdayName(Weekday(myDate),true)
   myDays = Day(myDate)
   myMonth = MonthName(Month(myDate), true)
   myYear = Year(myDate)
   myHours = zeroPad(Hour(myDate), 2)
   myMinutes = zeroPad(Minute(myDate), 2)
   mySeconds = zeroPad(Second(myDate), 2)

   return_RFC822_Date = myDay&", "& _
                                  myDays&" "& _
                                  myMonth&" "& _ 
                                  myYear&" "& _
                                  myHours&":"& _
                                  myMinutes&":"& _
                                  mySeconds&" "& _ 
                                  offset
End Function 
Function zeroPad(m, t)
   zeroPad = String(t-Len(m),"0")&m
End Function
%>
	
<!--#include file="../Connections/storedbase.asp" -->
<!--#include file="../includes/xmlvariables.asp"-->


<%
Dim rsProducts__sortvar
rsProducts__sortvar = "product_start DESC"
If (Request.QueryString("sort")   <> "") Then 
  rsProducts__sortvar = Request.QueryString("sort")  
End If
%>
<%
Dim rsProducts__showvar
rsProducts__showvar = "50"
If (Request.QueryString("show") <> "") Then 
  rsProducts__showvar = Request.QueryString("show")
End If
%>
<%
Dim rsProducts
Dim rsProducts_numRows

Set rsProducts = Server.CreateObject("ADODB.Recordset")
rsProducts.ActiveConnection = MM_storedbase_STRING
rsProducts.Source = "SELECT *  FROM q_products  WHERE product_id in (SELECT TOP " + Replace(rsProducts__showvar, "'", "''") + " product_id  FROM q_products  WHERE product_display = True ORDER BY product_start DESC)  ORDER BY " + Replace(rsProducts__sortvar, "'", "''") + ""
rsProducts.CursorType = 0
rsProducts.CursorLocation = 2
rsProducts.LockType = 1
rsProducts.Open()

rsProducts_numRows = 0
%>
<%
FUNCTION CropSentence(strText, intLength, strTrial) 
  Dim wsCount 
  Dim intTempSize 
  Dim intTotalLen 
  Dim strTemp 
  
  wsCount = 0 
  intTempSize = 0 
  intTotalLen = 0 
  intLength = intLength - Len(strTrial) 
  strTemp = "" 
    
  IF Len(strText) > intLength THEN 
    arrTemp = Split(strText, " ") 
    FOR EACH x IN arrTemp 
      IF Len(strTemp) <= intLength THEN 
        strTemp = strTemp & x & " " 
      END IF 
    NEXT 
      CropSentence = Left(strTemp, Len(strTemp) - 1) & strTrial 
  ELSE 
    CropSentence = strText 
  END IF 
END FUNCTION
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rsProducts_numRows = rsProducts_numRows + Repeat1__numRows
%>
<% DIM thumbname 'variable for holding calculated name of thumbnail (filename+t.extension ) if no alternative provided%>
<rss version="2.0" 
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:admin="http://webns.net/mvcb/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:atom="http://www.w3.org/2005/Atom">

  <channel>
    <title><%=ApplyXMLFormatting(sitetitlevar)%> - Latest Products in our online store</title>
    <link>http://<%=sitewebaddress%>/shop/latest.asp</link>
    <description>The latest items added to the <%=sitetitlevar%> online catalogue (<%=sitewebaddress%>)</description>
    <atom:link href="http://<%=sitewebaddress%>/rss/newitems.asp" rel="self" type="application/rss+xml" />
    <language>en-us</language>
    <copyright>Copyright <%=sitetitlevar%></copyright>
    <lastBuildDate><%=return_RFC822_Date(Now(), "GMT")%></lastBuildDate>
    <ttl>20</ttl>
	<image>
	<title><%=sitetitlevar%> - Latest Products in our online store</title>
	<url>http://<%=sitewebaddress%>/rss/media/LogoRssSmall.gif</url>
	<link>http://<%=sitewebaddress%>/shop/latest.asp</link></image>
    <% 
While ((Repeat1__numRows <> 0) AND (NOT rsProducts.EOF)) 
%><% 
	pricedisplayvar = "" 'variable to define pricing situation what should  be displayed
	
	'if sale or clearance and original price shown
	If 	(((rsProducts.Fields.Item("product_price").Value <> "" AND rsProducts.Fields.Item("product_rrp").Value <> "") )	OR 	((rsProducts.Fields.Item("product_price").Value <> "" AND rsProducts.Fields.Item("product_sale").Value <> "")) )Then
	pricedisplayvar = "<span class=wassm>Was<br>" & FormatNumber((rsProducts.Fields.Item("product_price").Value), 2, -2, -2, -2) & "<br></span>" 
	End If
	If 	(rsProducts.Fields.Item("product_price").Value <> "" AND rsProducts.Fields.Item("product_rrp").Value = "") 	OR 	(rsProducts.Fields.Item("product_price").Value <> "" AND rsProducts.Fields.Item("product_sale").Value = "") 	Then
	pricedisplayvar = FormatNumber((rsProducts.Fields.Item("product_price").Value), 2, -2, -2, -2) 'default to null price just in case
		If ((rsProducts.Fields.Item("product_rrp").Value) <> "") OR ((rsProducts.Fields.Item("product_price").Value) <> "") Then
		pricedisplayvar = pricedisplayvar & "<br>"
		End IF
	End If
	IF ((rsProducts.Fields.Item("product_rrp").Value) <> "") AND ((rsProducts.Fields.Item("product_sale").Value) <> "") Then 'we screwed up and had both sale and clear so just show special offer
	pricedisplayvar = pricedisplayvar & "<span class=clearancesm>Special Offer<br>" & FormatNumber((rsProducts.Fields.Item("product_sale").Value), 2, -2, -2, -2) & "</span>"
	Else
		If (rsProducts.Fields.Item("product_rrp").Value) <> "" Then 
		pricedisplayvar = pricedisplayvar & "<span class=clearancesm>Clearance<br>" & FormatNumber((rsProducts.Fields.Item("product_rrp").Value), 2, -2, -2, -2) & "</span>"
		End If  
		If (rsProducts.Fields.Item("product_sale").Value) <> "" Then 
	pricedisplayvar = pricedisplayvar & "<span class=salesm>Sale<br>" & FormatNumber((rsProducts.Fields.Item("product_sale").Value), 2, -2, -2, -2) & "</span>"
		End If  
	End If
	If (pricedisplayvar = "") AND ((rsProducts.Fields.Item("product_price").Value) <>"") Then 
	pricedisplayvar = FormatNumber((rsProducts.Fields.Item("product_price").Value), 2, -2, -2, -2) 
	End If  
			%>
			<% If pricedisplayvar <> "" Then 
			pricedesc = pricedisplayvar 
			Else 
			pricedesc = "Call" 
			End if %>
    <item>
      <title>New item in <%=ApplyXMLFormatting((rsProducts.Fields.Item("productsect_name").Value))%> &gt; <%=ApplyXMLFormatting((rsProducts.Fields.Item("productcat_name").Value))%>
      </title>
      <link>http://<%=sitewebaddress%>/shop/productdetail.asp?ID=<%=(rsProducts.Fields.Item("product_ID").Value)%>&amp;sectID=<%=(rsProducts.Fields.Item("productsect_ID").Value)%>&amp;catID=<%=(rsProducts.Fields.Item("productcat_ID").Value)%></link>
      <description><% If LEN((rsProducts.Fields.Item("product_thumb").Value)) > 3  Then 'display thumbnail only if it is specified, else show thumbnail+t 
	  redim thumbname(1)
	  thumbname(0) = "http://" & sitewebaddress & "/shop/media/" & (rsProducts.Fields.Item("productcat_folder").Value) & "/" & (rsProducts.Fields.Item("product_thumb").Value)
	  %>
	  <% ElseIF LEN((rsProducts.Fields.Item("product_pic").Value)) > 3 AND (rsProducts.Fields.Item("product_dispthumb").Value) = TRUE Then 'display thumbnail calculated from thumbnail+t only if main picture exists, else NULL %><% 
			IF  (rsProducts.Fields.Item("product_thumb").Value) <> "" Then 
			redim thumbname(1)
			thumbname(0) = (rsProducts.Fields.Item("product_thumb").Value)
			ELSE
			thumbname = Split((rsProducts.Fields.Item("product_pic").Value),  ".")
			thumbname(0) = thumbname(0) & "t." & thumbname(1)
			thumbname(0) = "http://" & sitewebaddress & "/shop/media/" & (rsProducts.Fields.Item("productcat_folder").Value) & "/" & thumbname(0) 
			END IF 
			Else
			thumbname(0) = "http://" & sitewebaddress & "/graphics/noimage.gif"
			End If%><![CDATA[<table><tr valign="top"><td><a href="http://<%=sitewebaddress%>/shop/productdetail.asp?ID=<%=(rsProducts.Fields.Item("product_ID").Value)%>&sectID=<%=(rsProducts.Fields.Item("productsect_ID").Value)%>&catID=<%=(rsProducts.Fields.Item("productcat_ID").Value)%>"><img border="0" hspace=10 src="<%=thumbname(0)%>"></a></td><td><%=((rsProducts.Fields.Item("product_name").Value))%> 
         <% If (rsProducts.Fields.Item("product_shdesc").Value) <>"" Then %> (<%=((rsProducts.Fields.Item("product_shdesc").Value))%>)<% End if %> <br><strong>£<%=(pricedesc)%></strong><br><% =(CropSentence(((rsProducts.Fields.Item("product_desc").Value)), 300, "...(more)")) %></td></tr>]]></description>
	<guid isPermaLink="false">http://<%=sitewebaddress%>/shop/productdetail.asp?ID=<%=(rsProducts.Fields.Item("product_ID").Value)%>&amp;sectID=<%=(rsProducts.Fields.Item("productsect_ID").Value)%>&amp;catID=<%=(rsProducts.Fields.Item("productcat_ID").Value)%></guid>
    <pubDate><%=return_RFC822_Date((rsProducts.Fields.Item("product_start").Value), "GMT")%></pubDate>
	


    </item>
    <% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  rsProducts.MoveNext()
Wend
%>
</channel>
</rss>

<%
rsProducts.Close()
Set rsProducts = Nothing
%>

