%@ Language=VBScript %>
<% OPTION EXPLICIT %>
<%
'Get section HTML - Description, images and product titles for links
Dim rsSubSection, strTitle
Dim strSubSectionHTML
Dim strSubSection, strSubSectionAlt, strHeading, strDesc1, strImage1, strAlt1, strDesc2, strImage2, strAlt2, strDesc3, strImage3, strAlt3, strImage4, strAlt4, strImage5, strAlt5, strImage6, strAlt6
Dim strDescHTML1, strDescHTML2, strDescHTML3, strImgHTML
Dim noCount, intItem
'Get the text
set rsSubSection = Server.CreateObject("ADODB.Recordset")
strSQL = "select iitemID, ssubsecSubSection, ssubsecHeading, iitemDesc1, iitemDesc2, iitemDesc3 from tvSubSectionItems where ssubsecID ='" & intSubSectionID & "'"
rsSubSection.Open strSQL, cnnConn, 1, 4
rsSubSection.MoveFirst
strTitle = rsSubSection("ssubsecSubSection")
strSubSection = "
" & rsSubSection("ssubsecSubSection") & "
"
strSubSectionAlt = rsSubSection("ssubsecSubSection")
strHeading = rsSubSection("ssubsecHeading")
If strHeading <> "" then
strHeading = "
" & rsSubSection("ssubsecHeading") & "
"
Else
strHeading = ""
End If
strDesc1 = rsSubSection("iitemDesc1")
strDesc2 = rsSubSection("iitemDesc2")
strDesc3 = rsSubSection("iitemDesc3")
intItem = rsSubSection("iitemID")
'Close recordset
rsSubSection.Close
'Get the image from the section table
strSQL = "select ssecsubImage from tssecSection where ssecID ='" & intSectionID & "'"
rsSubSection.Open strsql, cnnConn, 1, 4
Dim strSubSectionImage
strSubSectionImage = rsSubSection("ssecsubImage")
rsSubSection.Close
'Get the images using rsSubSection
strSQL = "select iImageFile, iImageAlt, ximgOrder from tvItemImages where iitemID='" & intItem & "' order by ximgOrder"
rsSubSection.Open strSQL, cnnConn, 1, 4
'Count how many images we have
rsSubSection.MoveFirst
noCount = 0
While not rsSubSection.EOF
noCount = noCount + 1
rsSubSection.MoveNext
Wend
rsSubSection.MoveFirst
'We will always have para 1 and image
strDescHTML1 = "
" & strDesc1 & "
"
strDescHTML1 = Replace(strDescHTML1, chr(10), " ")
'Do we have second paragraph and image?
if strDesc2 <> "" then
if noCount < 2 then
strDescHTML2 = "
" & strDesc2 & "
"
Else
rsSubSection.MoveNext
strDescHTML2 = "
" & strDesc2 & "
"
End If
strDescHTML2 = Replace(strDescHTML2, chr(10), " ")
Else
strDescHTML2 = ""
End If
'Do we have third paragraph and image?
if strDesc3 <> "" then
if noCount < 3 then
strDescHTML3 = "
" & strDesc3 & "
"
Else
rsSubSection.MoveNext
strDescHTML3 = "
" & strDesc3 & "
"
End If
strDescHTML3 = Replace(strDescHTML3, chr(10), " ")
Else
strDescHTML3 = ""
End If
'Do we have images 4, 5, or 6?
If noCount < 4 then
strImgHTML = ""
Else
strImgHTML = strImgHTML & "
"
rsSection.MoveNext
While not rsSection.EOF
strImgHTML = strImgHTML & " "
WEnd
End If
'Close rsSubSection
rsSubSection.Close
'Write out the product links & info request links
Dim rsSubSectionProducts
set rsSubSectionProducts = Server.CreateObject("ADODB.RECORDSET")
'Get the products for this subsection
strSQL = "select pprodID, pprodName from tvSubSectionProducts where ssubsecID='" & intSubSectionID & "' order by pprodName"
rsSubSectionProducts.Open strSQL, cnnConn, 1, 4
If rsSubSectionProducts.EOF and rsSubSectionProducts.BOF then
strProductLinks = strProductLinks & "
"
rsSubSectionProducts.close
Else
'Write the top of the table
strProductLinks = strProductLinks & "
"
'Count the records
Dim intRecCount
intRecCount = 6 ' Used to account for initial rows and link to forms
rsSubSectionProducts.MoveFirst
While not rsSubSectionProducts.EOF
intRecCount = intRecCount + 1
rsSubSectionProducts.MoveNext
WEND
Dim strProductLinks
rsSubSectionProducts.MoveFirst
strProductLinks = strProductLinks & "