%@ ENABLESESSIONSTATE = False %>
<%
Option Explicit ' Means variables must be defined before used
Function htmlNotifyEncode(rsdata)
If IsNull(rsdata) Then
htmlNotifyEncode = ""
Else
htmlNotifyEncode = Server.htmlEncode(rsdata)
End If
End Function
Function StripHostPlus(URL)
' Turn absolute addresses into relative ones.
DIM govSlash
govSlash = InStr(LCase(URL), ".gov")
If govSlash <> 0 Then
StripHostPlus = Right(URL, Len(URL) - govSlash - 4)
End If
End Function
DIM conn, rs, sqlStmt
' Either select only released items, or include the item specified by ID.
If Request.QueryString("ID") <> "" Then
sqlStmt = "SELECT SNGNews.*, SNGCategories.Category AS CatName, SNGCategories.SiteSection FROM SNGNews INNER JOIN SNGCategories ON SNGNews.CategoryID=SNGCategories.ID WHERE (Released<>0 AND ReadyEnglish<>0 AND Date < Now() AND (PullDate Is Null OR PullDate > Now())) OR SNGNews.ID=" & id & " ORDER BY Date DESC LIMIT 20;"
Else
sqlStmt = "SELECT SNGNews.*, SNGCategories.Category AS CatName, SNGCategories.SiteSection FROM SNGNews INNER JOIN SNGCategories ON SNGNews.CategoryID=SNGCategories.ID WHERE Released<>0 AND ReadyEnglish<>0 AND Date < Now() AND (PullDate Is Null OR PullDate > Now()) ORDER BY Date DESC LIMIT 20;"
End If
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.CursorLocation = 3 ' adUseClient
rs.CacheSize = 5
rs.Open sqlStmt, "SiteContent"
DIM title, intro, adate, linkText, link, image, reccount, align, hspace, category, alt, iwidth, iheight, otherlang
' SETUP First Story Information
category = Server.htmlEncode(rs.Fields("CatName"))
title = Server.htmlEncode(rs.Fields("Title"))
intro = Server.htmlEncode(rs.Fields("Intro"))
adate = FormatDateTime(rs.Fields("Date"), 1)
adate = Right(adate, Len(adate) - InStr(adate, ","))
adate = Left(adate, InStr(adate, ",")-1)
link = StripHostPlus(rs.Fields("URL"))
image = rs.Fields("Picture")
iwidth = rs.Fields("PictureWidth")
iheight = rs.Fields("PictureHeight")
alt = htmlNotifyEncode(rs.Fields("PictureText"))
otherlang = rs.Fields("ReadySpanish")
' Change the spacing of the intro paragraph based on the length of the intro.
' The hope is to fill the space down the tip of the downward arrow.
' It can grow longer if necessary.
DIM ratio, headsize
If Len(intro) < 225 Then
ratio = "175%"
ElseIf Len(intro) < 400 Then
ratio = "125%"
Else
ratio = "100%"
End If
If Len(title) < 43 Then
headsize = "22px;"
ElseIf Len(title) < 54 Then
headsize = "20px;"
Else
headsize = "18px;"
End If
Function AudioFromImageLocation(URL)
DIM Slash
Slash = InStr(StrReverse(URL), "/")
if Slash <> 0 Then
AudioFromImageLocation = Left(URL, Len(URL) - Slash + 1) & "audio/story.m3u"
'response.write AudioFromImageLocation
End If
End Function
%>