<CFSILENT>
  <!--- Tag Attributes --->
  <!--- MerchID to display (from Merchandise table) --->
  <CFPARAM NAME="ATTRIBUTES.MerchID" TYPE="numeric">
  <!--- Controls whether to show "Add To Cart" link --->
  <CFPARAM NAME="ATTRIBUTES.ShowAddLink" TYPE="boolean" DEFAULT="Yes">
  
  <!--- Get information about this part from database --->
  <!--- Query-Caching cuts down on database accesses. --->
  <CFQUERY NAME="GetMerch" DATASOURCE="#REQUEST.DataSource#"
    CACHEDWITHIN="#CreateTimeSpan(0,1,0,0)#">
    SELECT 
      m.MerchName, m.MerchDescription, m.MerchPrice,
      m.ImageNameSmall, m.ImageNameLarge,
      f.FilmID, f.MovieTitle
    FROM 
      Merchandise m INNER JOIN Films f 
      ON m.FilmID = f.FilmID
    WHERE 
      m.MerchID = #ATTRIBUTES.MerchID#  
  </CFQUERY>

  <!--- Exit tag silently (no error) if item not found --->
  <CFIF GetMerch.RecordCount NEQ 1>
    <CFEXIT>
  </CFIF>
  
  <!--- URL for "Add To Cart" link/button --->
  <CFSET AddLinkURL = "StoreCart.cfm?AddMerchID=#ATTRIBUTES.MerchID#">
</CFSILENT>

<!--- Now display information about the merchandise --->
<CFOUTPUT>
  <TABLE WIDTH="300" CELLSPACING="0" BORDER="0">
    <TR>
      <!--- Pictures go on left --->
      <TD ALIGN="center">
        <!--- If there is an image available for item  --->
        <!--- (allow user to click for bigger picture) --->
        <CFIF GetMerch.ImageNameLarge NEQ "">
          <A HREF="../images/#GetMerch.ImageNameLarge#">
            <IMG SRC="../images/#GetMerch.ImageNameSmall#" BORDER="0"
            ALT="#GetMerch.MerchName# (click for larger picture)"></A>
        </CFIF>
      </TD>
      <!--- Item description, price, etc., go on right --->
      <TD STYLE="font-family:arial;font-size:12px">
        <!--- Name of item, associated movie title, etc --->
        <STRONG>#GetMerch.MerchName#</STRONG><BR>
        <FONT SIZE="1">From the film: #GetMerch.MovieTitle#</FONT><BR>
        #GetMerch.MerchDescription#<BR>
        <!--- Display Price --->
        <B>Price: #LSCurrencyFormat(GetMerch.MerchPrice)#</B>
        
        <!--- If we are supposed to show an "AddToCart" link --->
        <CFIF ATTRIBUTES.ShowAddLink>
          <A HREF="#AddLinkURL#">Add To Cart</A><BR>
        </CFIF>
      </TD>
    </TR>
  </TABLE>
</CFOUTPUT>