<!--- 
 Filename:   WapMov.cfm
 Created by:  Nate Weiss (NMW)
 Purpose:   Displays film information for WAP users
--->

<!--- Include WAP Content-Type and Prologue --->
<cfinclude template="WapIncludePrologue.cfm">

<!--- We need to limit how many cards we send --->
<cfset maxCardsPerDeck = 5>

<!--- Get movies from database --->
<cfquery datasource="ows" name="getMovies" 
 cachedwithin="#createTimeSpan(0,0,15,0)#">
 SELECT FilmID, MovieTitle, Summary, DateInTheaters
 FROM Films
 ORDER BY MovieTitle
</cfquery>

<!--- A FilmID must be passed in the URL --->
<cfparam name="URL.filmID" type="numeric">

<!--- Find the passed FilmID's row in query --->
<cfset startRow = listFind(valueList(getMovies.FilmID), URL.filmID)>

<!--- We'll start at that row, and end 5 rows later --->
<cfset endRow = startRow + maxCardsPerDeck - 1>
<wml>
 <!--- All cards need a way back to movie list --->
 <template>
  <do type="accept" label="List">
   <go href="WapIndex4.cfm#movies"/>
  </do>
 </template>
 <!--- Create a card for each movie --->
 <cfoutput query="getMovies" startrow="#startRow#" maxrows="#maxCardsPerDeck#">
  
  <card id="Film#FilmID#">
  
   <!--- Show "Next" navigation, unless at end --->
   <cfif currentRow lt recordCount>
    <!--- What is the next film? --->
    <cfset nextID = filmID[currentRow + 1]>
    
    <do type="options" label="Next">
     <!--- If next film is in this deck --->
     <cfif currentRow neq endRow>
      <go href="##Film#nextID#"/>
     <!--- If next film not in this deck ---> 
     <cfelse> 
      <go href="?FilmID=#nextID#"/>
     </cfif>
    </do>
   </cfif>
   
   <!--- Display information about this movie--->
   <p>
    <b>#MovieTitle#</b><br/>
    <i>Opens #dateFormat(DateInTheaters, "mmm d")#.</i><br/>
    #Summary#<br/>
   </p>
  </card>
 </cfoutput>
</wml>
