<!--- 
  Filename:     AdServer.cfm
  Created by:   Nate Weiss (NMW)
  Date Created: 2/18/2001
--->

<!--- Ad Images are in "Ads" subfolder, within current folder --->
<CFSET AdDir = GetDirectoryFromPath(GetCurrentTemplatePath()) & "Ads\">

<!--- Get a listing of GIF image files in the Ads folder --->
<!--- Result is a query object with a row for each image --->
<CFDIRECTORY
  DIRECTORY="#AdDir#"
  ACTION="LIST"
  FILTER="*.gif"
  NAME="GetAds">

<!--- Pick random number between one and number of images --->
<CFSET AdNum  = RandRange(1, GetAds.RecordCount)>
<!--- Grab the filename in chosen row of the GetAds query --->
<CFSET AdFileName = GetAds.Name[AdNum]>
<!--- Prepend dir to get full filesystem path to ad image --->
<CFSET AdFilePath = AdDir & AdFileName>

<!--- Send the chosen image back to the client --->
<CFCONTENT TYPE="image/gif" FILE="#AdFilePath#">