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

<!--- 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="WapIndex.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>

