File: D:/web/coventrydemolition/inc-multiple-logo-header.asp
<script>
// (SS,16/9/15) script to allow different logos to be shown
var logos = [];
<%
' routine to make comparisons for sort
Function CompareFiles(AFileA, AFileB)
CompareFiles = AFileA.Name > AFileB.Name
End Function
Function SortFiles(files)
ReDim sorted(files.Count - 1)
Dim file, i, j
i = 0
For Each file in files
Set sorted(i) = file
i = i + 1
Next
For i = 0 to files.Count - 2
For j = i + 1 to files.Count - 1
If CompareFiles(sorted(i), sorted(j)) Then
Dim tmp
Set tmp = sorted(i)
Set sorted(i) = sorted(j)
Set sorted(j) = tmp
End If
Next
Next
SortFiles = sorted
End Function
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim files
Set files = fso.GetFolder(fso.GetFolder("D:\web\covdem\logos")).Files
Dim file, LExt
For Each file in SortFiles(files)
'Print the name of all files in the test folder
'Response.write(file.Name & " = " & file.DateLastModified & "<br>")
' (SS,16/9/15) filter for png and jpg files (ignores thumbs.db)
LExt = Right(LCase(file.Name), 4)
If LExt = ".png" Or LExt = ".jpg" Then
Response.Write " logos.push('" & file.Name & "');" & NL
End If
Next
%>
</script>
<%
' (SS,18/8/15) set chosen logo
Dim LDefaultLogo, LSessionOrCookieLogo
If Request.QueryString("logo") <> "" Then
Session("logo") = Request.QueryString("logo")
Else ' if not specified try getting from cookie
Session("logo") = GetCookie("logo")
End If
If Session("logo") = "" Or Not(IsNumeric(Session("logo"))) Then
LDefaultLogo = 0
Else
LDefaultLogo = CInt(Session("logo"))
End If
%>
<script>
var default_logo = <%=LDefaultLogo%>;
</script>