<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet
[
<!ENTITY nbsp
"<xsl:text xmlns:xsl='http://www.w3.org/1999/XSL/Transform' disable-output-escaping='yes'>&amp;nbsp;</xsl:text>">

<!ENTITY laquo
"<xsl:text xmlns:xsl='http://www.w3.org/1999/XSL/Transform' disable-output-escaping='yes'>&amp;laquo;</xsl:text>">

<!ENTITY raquo
"<xsl:text xmlns:xsl='http://www.w3.org/1999/XSL/Transform' disable-output-escaping='yes'>&amp;raquo;</xsl:text>">

<!ENTITY middot
"<xsl:text xmlns:xsl='http://www.w3.org/1999/XSL/Transform' disable-output-escaping='yes'>&amp;middot;</xsl:text>">
]>
  <!--
      ======================================================================================================================================================
    -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
  <xsl:output method="xml" indent="yes"/>
  <!--
      ======================================================================================================================================================
    -->
  <ag:localization xmlns:ag="http://ns.adobe.com/silver/1.0">
    <item id="Next" zstring="$$$/AgWPG/Templates/HTML/output/Next=Next"/>
    <item id="Previous" zstring="$$$/AgWPG/Templates/HTML/output/Previous=Previous"/>
    <item id="Fullsize" zstring="$$$/AgWPG/Templates/HTML/output/Fullsize=Fullsize"/>
    <item id="Index" zstring="$$$/AgWPG/Templates/HTML/output/Index=Index"/>
    <item id="more" zstring="$$$/AgWPG/Templates/HTML/output/more=more"/>
    <item id="EmptyGallery" zstring="$$$/AgWPG/Templates/HTML/output/EmptyGalleryMessage=There are no images in this gallery." />
    <item id="AdobeLightroomBeta" zstring="$$$/AgWPG/Templates/HTML/output/LongAppName=Adobe Lightroom Beta"/>
    <item id="AdobeLightroomWebSite" zstring="$$$/AgWPG/Templates/HTML/output/UpdateSite=http://labs.adobe.com/technologies/lightroom/" />
  </ag:localization>
  <!--
      ======================================================================================================================================================
    -->
  <xsl:param name="beginOutputAtIndex" select="number( /photoCollection/samples/@beginOutputAtIndex )"/>
  <xsl:param name="endOutputAtIndex" select="number( /photoCollection/samples/@endOutputAtIndex )"/>
  <xsl:param name="firstSampleIndex" select="number( /photoCollection/samples/@firstSampleIndex )"/>
  <xsl:param name="numImages" select="number( /photoCollection/samples/@totalGallerySize )"/>
  <xsl:param name="indexGridCellsWide" select="number( /photoCollection/display/style/@numCols )"/>
  <xsl:param name="smallGridCellsWide" select="$indexGridCellsWide - 2"/>
  <xsl:param name="indexGridCellsTall" select="number( /photoCollection/display/style/@numRows )"/>
  <xsl:param name="numCellsInIndexGrid" select="$indexGridCellsWide * $indexGridCellsTall"/>
  <xsl:param name="numCellsInSmallGrid" select="$smallGridCellsWide * $indexGridCellsTall"/>
  <xsl:param name="includeStyleSwitcher" select="false"/>
  <xsl:param name="samplesImgCount" select="count( /photoCollection/samples/img )"/>
  <!--
      ======================================================================================================================================================
    -->
  <xsl:template match="photoCollection">
    <xsl:param name="sourceXMLFileName">
      <xsl:value-of select="concat( siteParams/mode/@value, &quot;-source.xml&quot; )"/>
    </xsl:param>

    <files>
      <!-- copy source xml to a file for ease of development -->
      <!--  uncomment the next block to save out a copy of the raw xml files that are fed to this transformer. -->
      <file name="{$sourceXMLFileName}">
       <xsl:copy-of select="/" />
      </file>
      <!-- - - - - - - - -
          custom css
        - - - - - - - - -->
      <xsl:if test="siteParams/mode/@value = 'all' or siteParams/mode/@value = 'customCSS'">
        <xsl:call-template name="customCSS"/>
      </xsl:if>
      <!-- Fix for defect 1340326 : if no images are selected display something -->
      <xsl:if test="$numImages = 0">
        <xsl:call-template name="noImagesSelected"/>
      </xsl:if>
      <!-- - - - - - - - -
          main indexes
        - - - - - - - - -->
      <xsl:if test="siteParams/mode/@value = 'all' or siteParams/mode/@value = 'mainIndex'">
        <xsl:for-each select="samples/img">
          <xsl:if test="( $firstSampleIndex - 1 + position() ) = 1">
            <xsl:call-template name="outerIndex"/>
          </xsl:if>
          <xsl:if test="( $firstSampleIndex - 1 + position() - 1 ) mod $numCellsInIndexGrid = 0">
            <xsl:call-template name="indexPage"/>
          </xsl:if>
        </xsl:for-each>
      </xsl:if>
      <!-- - - - - - - - -
          large preview
        - - - - - - - - -->
      <xsl:if test="siteParams/mode/@value = 'all' or siteParams/mode/@value = 'detail'">
        <xsl:for-each select="samples/img">
          <xsl:if test="( position() > 1 or $firstSampleIndex = 1 ) and ( position() &lt; $samplesImgCount or $numImages = ( $samplesImgCount + $firstSampleIndex - 1 ) )">
            <!--
              This left hand expression ensures that for incremental update we don't emit an erroneous
              'first' page.  the info on the previous image to what was requested is provided
              per our request (we said includeBefore="1" in demangler.xslt).  We ask for
              it so that we know what filename to include in our 'previous' link.

              The same holds true for the right hand part of the expression - - don't emit a page
              for the last samples/img if it is incremental (otherwise it won't have a valid 'next'
              link).
              -->
            <xsl:call-template name="previewFullFile">
              <xsl:with-param name="this" select="'large'"/>
              <xsl:with-param name="other" select="'small'"/>
              <xsl:with-param name="includeThumbnails" select="'yes'"/>
            </xsl:call-template>
          </xsl:if>
        </xsl:for-each>
      </xsl:if>
    </files>
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <!-- Generate Index pages, $imagesPagePage specifies how many thumbs in the grid per page -->
  <xsl:template name="indexPage">
    <xsl:param name="firstImage" select="$firstSampleIndex - 1 + position()"/>
    <xsl:param name="pathToRoot" select="'../'"/>
    <xsl:param name="pathToContent" select="''"/>

    <xsl:call-template name="indexPageWithPathSupport">
      <xsl:with-param name="firstImage" select="$firstImage"/>
      <xsl:with-param name="pathToRoot" select="$pathToRoot"/>
      <xsl:with-param name="homeDir" select="'content/'"/>
      <xsl:with-param name="pathToContent" select="$pathToContent"/>
    </xsl:call-template>
  </xsl:template>

  <!-- Generate Index pages, $imagesPagePage specifies how many thumbs in the grid per page -->
  <xsl:template name="indexPageWithPathSupport">
    <xsl:param name="firstImage" select="$firstSampleIndex - 1 + position()"/>
    <xsl:param name="pathToRoot"/>
    <xsl:param name="homeDir"/>
    <xsl:param name="pathToContent"/>
    <xsl:param name="betaLink" />
    
    <file doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" doctype-public="-//W3C//DTD XHTML 1.1//EN">
      <xsl:attribute name="name">
        <xsl:call-template name="indexLink">
          <xsl:with-param name="pathToContent" select="$homeDir"/>
          <xsl:with-param name="scale" select="'thumb'"/>
          <xsl:with-param name="imageNumber" select="$firstImage"/>
        </xsl:call-template>
      </xsl:attribute>
      <!-- ./layoutGrid.htm -->
      <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
        <head xmlns="http://www.w3.org/1999/xhtml">
          <meta xmlns="http://www.w3.org/1999/xhtml" http-equiv="Content-Type" content="text/html; charset=UTF-8" />
          <meta xmlns="http://www.w3.org/1999/xhtml" name="KEYWORDS" content="photography,software,photos,digital darkroom,gallery,image,photographer" />
          <meta xmlns="http://www.w3.org/1999/xhtml" name="generator" content="Adobe Lightroom" />
          <title xmlns="http://www.w3.org/1999/xhtml">
            <xsl:value-of select="ancestor::photoCollection/display/metadata/siteTitle/@value"/>
          </title>
          <!-- STYLE -->
          <xsl:call-template name="display">
            <xsl:with-param name="pathToRoot" select="$pathToRoot"/>
            <xsl:with-param name="pathToContent" select="$pathToContent"/>
          </xsl:call-template>

          <xsl:if test="$includeStyleSwitcher">
            <link xmlns="http://www.w3.org/1999/xhtml" rel="alternate stylesheet" type="text/css" href="css/backdrop_000.css" title="backdrop_000"/>
            <link xmlns="http://www.w3.org/1999/xhtml" rel="alternate stylesheet" type="text/css" href="css/backdrop_020.css" title="backdrop_020"/>
            <link xmlns="http://www.w3.org/1999/xhtml" rel="alternate stylesheet" type="text/css" href="css/backdrop_030.css" title="backdrop_030"/>
            <link xmlns="http://www.w3.org/1999/xhtml" rel="alternate stylesheet" type="text/css" href="css/backdrop_grad.css" title="backdrop_grad"/>
            <script xmlns="http://www.w3.org/1999/xhtml" type="text/javascript" src="js/styleswitcher.js">
				<xsl:comment>padding for ie</xsl:comment>
			</script>
          </xsl:if>
          <!-- Lightroom Interaction -->
          <xsl:call-template name="lightroomInteraction">
            <xsl:with-param name="pathToRoot" select="$pathToRoot"/>
            <xsl:with-param name="size" select="'thumb'"/>
          </xsl:call-template>
          <xsl:comment>[if lt IE 7.]&gt; &lt;script defer type="text/javascript" src="<xsl:value-of select="$pathToRoot" />resources/js/pngfix.js"&gt;&lt;/script&gt; &lt;![endif]</xsl:comment>
		  <xsl:comment>[if gt IE 6]&gt; &lt;link rel="stylesheet" href="<xsl:value-of select="$pathToRoot" />resources/css/ie7.css"&gt;&lt;/link&gt; &lt;![endif]</xsl:comment>
		  <xsl:comment>[if lt IE 7.]&gt; &lt;link rel="stylesheet" href="<xsl:value-of select="$pathToRoot" />resources/css/ie6.css"&gt;&lt;/link&gt; &lt;![endif]</xsl:comment>
		</head>
        <body xmlns="http://www.w3.org/1999/xhtml">
          <!-- BEGIN WRAPPER -->
          <div xmlns="http://www.w3.org/1999/xhtml" id="wrapper">
            <!-- IDENTITY PLATE -->
            <xsl:call-template name="idplate">
              <xsl:with-param name="pathToRoot" select="$pathToRoot"/>
              <xsl:with-param name="pathToContent" select="$pathToContent"/>
            </xsl:call-template>
            <!-- SITE TITLE -->
            <xsl:call-template name="sitetitle"/>
            <!-- DESCRIPTION HEADER -->
            <xsl:call-template name="collectionHeader"/>
            <!-- BEGIN STAGE -->
            <div xmlns="http://www.w3.org/1999/xhtml" id="stage">
              <!-- THUMBNAILS -->
              <xsl:call-template name="thumbnails5X3">
                <xsl:with-param name="pathToRoot" select="$pathToRoot"/>
                <xsl:with-param name="pathToContent" select="$pathToContent"/>
              </xsl:call-template>
            </div>
			<div xmlns="http://www.w3.org/1999/xhtml" class="clear">
				<xsl:comment>padding for ie</xsl:comment>
			</div>
            <!-- END STAGE -->
            <!-- STYLE SWITCHER -->
            <xsl:call-template name="styleswitcher"/>
            <!-- PAGINATION -->
            <xsl:if test="$numCellsInIndexGrid &lt; $numImages">
              <xsl:call-template name="pagination">
                <xsl:with-param name="imagesPerPage" select="$numCellsInIndexGrid"/>
                <xsl:with-param name="scale" select="'thumb'"/>
                <xsl:with-param name="pathToRoot" select="$pathToRoot"/>
                <xsl:with-param name="pathToContent" select="$pathToContent"/>
                <xsl:with-param name="indexGridCellsWide" select="$indexGridCellsWide"/>
              </xsl:call-template>
            </xsl:if>
            <!-- QUICK JUMP -->
            <xsl:call-template name="quickjump">
              <xsl:with-param name="scale" select="'small'"/>
            </xsl:call-template>
            <!-- CONTACT INFO -->
            <xsl:call-template name="contact"/>
          </div>
          <!-- END GRID -->
          <xsl:if test="$betaLink">
            <xsl:copy-of select="$betaLink"/>
          </xsl:if>
        </body>
      </html>
      <!-- end ./layoutGrid.htm -->
    </file>
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <xsl:template name="idplate">
    <xsl:param name="pathToRoot"/>
    <xsl:param name="pathToContent"/>
    <xsl:param name="logoPNG" select="concat( $pathToContent, 'logo.png' )"/>
    <xsl:param name="homePage" select="ancestor::photoCollection/display/style/@homePage"/>
    <xsl:param name="includeIdPlate"
      select="/photoCollection/@mode = 'preview' or /photoCollection/display/style/@idplateEnabled = 'true'"/>
    <!-- ./idplate.inc -->
    <xsl:if test="$includeIdPlate">
      <div xmlns="http://www.w3.org/1999/xhtml" id="idplate">
        <div xmlns="http://www.w3.org/1999/xhtml" class="logo">
          <a xmlns="http://www.w3.org/1999/xhtml" href="{$homePage}">
			  <img xmlns="http://www.w3.org/1999/xhtml" class="pngDelayDisplay" src="{$logoPNG}" alt="Logo" />
          </a>
        </div>
      </div>
    </xsl:if>
    <!-- end ./idplate.inc -->
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <xsl:template name="sitetitle">
    <!-- ./sitetitle.inc -->
    <div xmlns="http://www.w3.org/1999/xhtml" id="sitetitle">
      <h1 xmlns="http://www.w3.org/1999/xhtml" onclick="clickTarget( this, 'siteTitle.text' );" id="liveUpdateSiteTitle">
        <xsl:value-of select="ancestor::photoCollection/display/metadata/siteTitle/@value"/>
      </h1>
    </div>
    <!-- end ./sitetitle.inc -->
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <xsl:template name="collectionHeader">
    <!-- ./collectionHeader.inc -->
    <div xmlns="http://www.w3.org/1999/xhtml" id="collectionHeader">
      <!--    <h1 xmlns="http://www.w3.org/1999/xhtml" id="liveUpdateCollectionTitle"><xsl:call-template name="verbatim"><xsl:with-param name="element" select="ancestor::photoCollection/display/metadata/groupTitle/@value"/></xsl:call-template></h1> -->
      <h1 xmlns="http://www.w3.org/1999/xhtml" onclick="clickTarget( this, 'groupTitle.text' );" id="liveUpdateCollectionTitle">
        <xsl:value-of select="ancestor::photoCollection/display/metadata/groupTitle/@value"/>
      </h1>
      <!--            <p xmlns="http://www.w3.org/1999/xhtml" id="liveUpdateCollectionDescription"><xsl:call-template name="verbatim"><xsl:with-param name="element" select="ancestor::photoCollection/display/metadata/groupDescription/@value"/></xsl:call-template></p> -->
      <p xmlns="http://www.w3.org/1999/xhtml" onclick="clickTarget( this, 'groupDescription.text' );" id="liveUpdateCollectionDescription">
        <xsl:value-of select="ancestor::photoCollection/display/metadata/groupDescription/@value"/>
      </p>
    </div>
    <!-- end ./collectionHeader.inc -->
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <xsl:template name="thumbnails5X3">
    <xsl:param name="pathToRoot"/>
    <xsl:param name="pathToContent"/>

    <!-- ./index5X3.inc -->
    <div xmlns="http://www.w3.org/1999/xhtml" id="index">
      <xsl:call-template name="gridBlock">
        <xsl:with-param name="numRows" select="$indexGridCellsTall"/>
        <xsl:with-param name="numCols" select="$indexGridCellsWide"/>
        <xsl:with-param name="itemIndex" select="position()"/>
        <xsl:with-param name="pathToRoot" select="$pathToRoot"/>
        <xsl:with-param name="pathToContent" select="$pathToContent"/>
      </xsl:call-template>
    </div>
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <!-- insert numRows rows of numCols cols -->
  <xsl:template name="emptyGridBlock">
    <xsl:param name="numRows"/>
    <xsl:param name="numCols"/>
    <xsl:param name="itemIndex"/>
    <xsl:call-template name="emptyGridRow">
      <xsl:with-param name="numCols" select="$numCols"/>
      <xsl:with-param name="bottomRow" select="$numRows &lt;= 1"/>
    </xsl:call-template>
	<div xmlns="http://www.w3.org/1999/xhtml" class="clear">
		<xsl:comment>padding for ie</xsl:comment>
	</div>
    <xsl:if test="$numRows &gt; 1">
      <xsl:call-template name="emptyGridBlock">
        <xsl:with-param name="numRows" select="$numRows - 1"/>
        <xsl:with-param name="numCols" select="$numCols"/>
        <xsl:with-param name="itemIndex" select="$itemIndex + $numCols"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <!-- insert numRows rows of numCols cols -->
  <xsl:template name="gridBlock">
    <xsl:param name="pathToRoot"/>
    <xsl:param name="pathToContent"/>
    <xsl:param name="numRows"/>
    <xsl:param name="numCols"/>
    <xsl:param name="itemIndex"/>
    <xsl:param name="selectedItemIndex"/>
    <xsl:param name="allFullLinks"/>
    <xsl:call-template name="gridRow">
      <xsl:with-param name="pathToRoot" select="$pathToRoot"/>
      <xsl:with-param name="pathToContent" select="$pathToContent"/>
      <xsl:with-param name="numCols" select="$numCols"/>
      <xsl:with-param name="itemIndex" select="$itemIndex"/>
      <xsl:with-param name="selectedItemIndex" select="$selectedItemIndex"/>
      <xsl:with-param name="allFullLinks" select="$allFullLinks"/>
      <xsl:with-param name="bottomRow" select="$numRows &lt;= 1"/>
    </xsl:call-template>
	<div xmlns="http://www.w3.org/1999/xhtml" class="clear">
		<xsl:comment>padding for ie</xsl:comment>
	</div>
    <xsl:if test="$numRows &gt; 1">
      <xsl:choose>
        <xsl:when test="following-sibling::*[$numCols]">
          <xsl:for-each select="following-sibling::*[$numCols]">
            <xsl:call-template name="gridBlock">
              <xsl:with-param name="pathToRoot" select="$pathToRoot"/>
              <xsl:with-param name="pathToContent" select="$pathToContent"/>
              <xsl:with-param name="numRows" select="$numRows - 1"/>
              <xsl:with-param name="numCols" select="$numCols"/>
              <xsl:with-param name="itemIndex" select="$itemIndex + $numCols"/>
              <xsl:with-param name="selectedItemIndex" select="$selectedItemIndex"/>
              <xsl:with-param name="allFullLinks" select="$allFullLinks"/>
            </xsl:call-template>
          </xsl:for-each>
        </xsl:when>
        <xsl:otherwise>
          <xsl:call-template name="emptyGridBlock">
            <xsl:with-param name="numRows" select="$numRows - 1"/>
            <xsl:with-param name="numCols" select="$numCols"/>
            <xsl:with-param name="itemIndex" select="$itemIndex + $numCols"/>
          </xsl:call-template>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:if>
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <xsl:template name="styleswitcher">
    <xsl:if test="$includeStyleSwitcher">
      <!-- ./styleswitcher.inc -->
      <div xmlns="http://www.w3.org/1999/xhtml" id="styleswitcher">
        <a xmlns="http://www.w3.org/1999/xhtml" href="#" onclick="setActiveStyleSheet('backdrop_grad'); return false;">
			<img xmlns="http://www.w3.org/1999/xhtml" src="images/misc/swatch_grad.gif" alt="" />
        </a>
        <a xmlns="http://www.w3.org/1999/xhtml" href="#" onclick="setActiveStyleSheet('backdrop_000'); return false;">
			<img xmlns="http://www.w3.org/1999/xhtml" src="images/misc/swatch_black.gif" alt="" />
        </a>
        <a xmlns="http://www.w3.org/1999/xhtml" href="#" onclick="setActiveStyleSheet('backdrop_020'); return false;">
			<img xmlns="http://www.w3.org/1999/xhtml" src="images/misc/swatch_dark.gif" alt="" />
        </a>
        <a xmlns="http://www.w3.org/1999/xhtml" href="#" onclick="setActiveStyleSheet('backdrop_030'); return false;">
			<img xmlns="http://www.w3.org/1999/xhtml" src="images/misc/swatch_light.gif" alt="" />
        </a>
      </div>
	  <div xmlns="http://www.w3.org/1999/xhtml" class="clear">
		  <xsl:comment>padding for ie</xsl:comment>
	  </div>
      <!-- end ./styleswitcher.inc -->
    </xsl:if>
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <xsl:template name="pagination">
    <!-- ./pagination.inc -->
    <xsl:param name="pathToRoot"/>
    <xsl:param name="pathToContent"/>
    <xsl:param name="imagesPerPage"/>
    <xsl:param name="scale"/>
    <xsl:param name="curPageNumber"
      select="ceiling( ( $firstSampleIndex - 1 + position() ) div $imagesPerPage )"/>
    <xsl:param name="firstItemNumber" select="( $curPageNumber - 1 ) * $imagesPerPage + 1"/>
    <xsl:param name="lastItemNumberX" select="$curPageNumber * $imagesPerPage"/>
    <xsl:param name="lastItemNumber">
      <xsl:choose>
        <xsl:when test="$lastItemNumberX &gt; $numImages">
          <xsl:value-of select="$numImages"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$lastItemNumberX"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:param>
    <xsl:param name="prevLink"/>
    <xsl:param name="indexGridCellsWide"/>

    <div xmlns="http://www.w3.org/1999/xhtml" class="pagination">
      <ul xmlns="http://www.w3.org/1999/xhtml">
        <xsl:for-each select="ancestor::photoCollection/samples/*[1]">
          <xsl:call-template name="pageNavigation">
            <xsl:with-param name="pathToRoot" select="$pathToRoot"/>
            <xsl:with-param name="pathToContent" select="$pathToContent"/>
            <xsl:with-param name="currentPage" select="$curPageNumber"/>
            <xsl:with-param name="scale" select="$scale"/>
            <xsl:with-param name="imagesPerPage" select="$imagesPerPage"/>
            <xsl:with-param name="indexGridCellsWide" select="$indexGridCellsWide"/>
            <xsl:with-param name="numPages" select="ceiling( $numImages div $imagesPerPage )"/>
          </xsl:call-template>
        </xsl:for-each>
        <li xmlns="http://www.w3.org/1999/xhtml" class="previous">
          <xsl:choose>
            <xsl:when test="$curPageNumber &gt; 1">
              <a xmlns="http://www.w3.org/1999/xhtml" class="paginationLinks">
                <xsl:attribute name="href">
                  <xsl:call-template name="indexLink">
                    <xsl:with-param name="pathToContent" select="$pathToContent"/>
                    <xsl:with-param name="scale" select="$scale"/>
                    <xsl:with-param name="imageNumber"
                      select="( $curPageNumber - 1 ) * $imagesPerPage"/>
                  </xsl:call-template>
                </xsl:attribute>
                <xsl:call-template name="ZSTR">
                  <xsl:with-param name="id" select="'Previous'"/>
                </xsl:call-template>
              </a>
            </xsl:when>
            <xsl:otherwise>
              <xsl:call-template name="ZSTR">
                <xsl:with-param name="id" select="'Previous'"/>
              </xsl:call-template>
            </xsl:otherwise>
          </xsl:choose>
        </li>
        <li xmlns="http://www.w3.org/1999/xhtml" class="next">
          <xsl:choose>
            <xsl:when test="$curPageNumber * $imagesPerPage &lt; $numImages">
              <a xmlns="http://www.w3.org/1999/xhtml" class="paginationLinks">
                <xsl:attribute name="href">
                  <xsl:call-template name="indexLink">
                    <xsl:with-param name="pathToContent" select="$pathToContent"/>
                    <xsl:with-param name="scale" select="$scale"/>
                    <xsl:with-param name="imageNumber"
                      select="( $curPageNumber ) * $imagesPerPage + 1"/>
                  </xsl:call-template>
                </xsl:attribute>
                <xsl:call-template name="ZSTR">
                  <xsl:with-param name="id" select="'Next'"/>
                </xsl:call-template>
              </a>
            </xsl:when>
            <xsl:otherwise>
              <xsl:call-template name="ZSTR">
                <xsl:with-param name="id" select="'Next'"/>
              </xsl:call-template>
            </xsl:otherwise>
          </xsl:choose>
        </li>
      </ul>
    </div>
    <!-- end ./pagination.inc -->
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <!-- insert page sequence -->
  <xsl:template name="pageNavigation">
    <xsl:param name="pathToRoot"/>
    <xsl:param name="pathToContent"/>
    <xsl:param name="imagesPerPage"/>
    <xsl:param name="scale"/>
    <xsl:param name="currentPage"/>
    <xsl:param name="numPages"/>
    <xsl:param name="indexGridCellsWide"/>
    <xsl:param name="numOfLinks">
      <xsl:choose>
        <xsl:when test="$indexGridCellsWide &gt; 3">
          <xsl:value-of select="20"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="10"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:param>
    <xsl:param name="pagesBefore">
      <xsl:value-of select="$numOfLinks div 2"/>
    </xsl:param>
    <xsl:param name="pagesAfter">
      <xsl:value-of select="$numOfLinks div 2"/>
    </xsl:param>

    <xsl:call-template name="pageNavigation_pagesBefore">
      <xsl:with-param name="pathToRoot" select="$pathToRoot"/>
      <xsl:with-param name="pathToContent" select="$pathToContent"/>
      <xsl:with-param name="imagesPerPage" select="$imagesPerPage"/>
      <xsl:with-param name="currentPage" select="$currentPage - 1"/>
      <xsl:with-param name="numRepeats" select="$pagesBefore"/>
      <xsl:with-param name="numPages" select="$numPages"/>
      <xsl:with-param name="scale" select="$scale"/>
    </xsl:call-template>
    <xsl:call-template name="pageNavigation_onePageLink">
      <xsl:with-param name="pathToRoot" select="$pathToRoot"/>
      <xsl:with-param name="pathToContent" select="$pathToContent"/>
      <xsl:with-param name="imagesPerPage" select="$imagesPerPage"/>
      <xsl:with-param name="withLink" select="0"/>
      <xsl:with-param name="pageNumber" select="$currentPage"/>
      <xsl:with-param name="scale" select="$scale"/>
    </xsl:call-template>
    <xsl:call-template name="pageNavigation_pagesAfter">
      <xsl:with-param name="pathToRoot" select="$pathToRoot"/>
      <xsl:with-param name="pathToContent" select="$pathToContent"/>
      <xsl:with-param name="imagesPerPage" select="$imagesPerPage"/>
      <xsl:with-param name="currentPage" select="$currentPage + 1"/>
      <xsl:with-param name="numRepeats" select="$pagesAfter"/>
      <xsl:with-param name="numPages" select="$numPages"/>
      <xsl:with-param name="scale" select="$scale"/>
    </xsl:call-template>
  </xsl:template>
  <!--
      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -->
  <xsl:template name="pageNavigation_pagesBefore">
    <xsl:param name="pathToRoot"/>
    <xsl:param name="pathToContent"/>
    <xsl:param name="scale"/>
    <xsl:param name="imagesPerPage"/>
    <xsl:param name="currentPage"/>
    <xsl:param name="numRepeats"/>
    <xsl:param name="numPages"/>
    <xsl:if test="$numRepeats &gt; 0 and $currentPage &gt; 0">
      <xsl:call-template name="pageNavigation_pagesBefore">
        <xsl:with-param name="pathToRoot" select="$pathToRoot"/>
        <xsl:with-param name="pathToContent" select="$pathToContent"/>
        <xsl:with-param name="imagesPerPage" select="$imagesPerPage"/>
        <xsl:with-param name="currentPage" select="$currentPage - 1"/>
        <xsl:with-param name="numRepeats" select="$numRepeats - 1"/>
        <xsl:with-param name="numPages" select="$numPages"/>
        <xsl:with-param name="scale" select="$scale"/>
      </xsl:call-template>
      <xsl:call-template name="pageNavigation_onePageLink">
        <xsl:with-param name="pathToRoot" select="$pathToRoot"/>
        <xsl:with-param name="pathToContent" select="$pathToContent"/>
        <xsl:with-param name="imagesPerPage" select="$imagesPerPage"/>
        <xsl:with-param name="withLink" select="1"/>
        <xsl:with-param name="pageNumber" select="$currentPage"/>
        <xsl:with-param name="scale" select="$scale"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
  <!--  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
  <xsl:template name="pageNavigation_pagesAfter">
    <xsl:param name="pathToRoot"/>
    <xsl:param name="pathToContent"/>
    <xsl:param name="scale"/>
    <xsl:param name="imagesPerPage"/>
    <xsl:param name="currentPage"/>
    <xsl:param name="numRepeats"/>
    <xsl:param name="numPages"/>
    <xsl:if test="$numRepeats &gt; 0 and $currentPage &lt;= $numPages">
      <xsl:call-template name="pageNavigation_onePageLink">
        <xsl:with-param name="pathToRoot" select="$pathToRoot"/>
        <xsl:with-param name="pathToContent" select="$pathToContent"/>
        <xsl:with-param name="imagesPerPage" select="$imagesPerPage"/>
        <xsl:with-param name="withLink" select="1"/>
        <xsl:with-param name="pageNumber" select="$currentPage"/>
        <xsl:with-param name="scale" select="$scale"/>
      </xsl:call-template>
      <xsl:call-template name="pageNavigation_pagesAfter">
        <xsl:with-param name="pathToRoot" select="$pathToRoot"/>
        <xsl:with-param name="pathToContent" select="$pathToContent"/>
        <xsl:with-param name="imagesPerPage" select="$imagesPerPage"/>
        <xsl:with-param name="currentPage" select="$currentPage + 1"/>
        <xsl:with-param name="numRepeats" select="$numRepeats - 1"/>
        <xsl:with-param name="numPages" select="$numPages"/>
        <xsl:with-param name="scale" select="$scale"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
  <!--  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
  <xsl:template name="pageNavigation_onePageLink">
    <xsl:param name="pathToRoot"/>
    <xsl:param name="pathToContent"/>
    <xsl:param name="scale"/>
    <xsl:param name="imagesPerPage"/>
    <xsl:param name="pageNumber"/>
    <xsl:param name="withLink"/>
    <li xmlns="http://www.w3.org/1999/xhtml">
      <xsl:choose>
        <xsl:when test="$withLink">
          <a xmlns="http://www.w3.org/1999/xhtml">
            <xsl:attribute name="href">
              <xsl:call-template name="indexLink">
                <xsl:with-param name="pathToContent" select="$pathToContent"/>
                <xsl:with-param name="scale" select="$scale"/>
                <xsl:with-param name="imageNumber" select="( $pageNumber - 1 ) * $imagesPerPage + 1" />
              </xsl:call-template>
            </xsl:attribute>
            <xsl:value-of select="$pageNumber"/>
          </a>
        </xsl:when>
        <xsl:otherwise>
          <xsl:attribute name="class">current</xsl:attribute>
          <xsl:value-of select="$pageNumber"/>
        </xsl:otherwise>
      </xsl:choose>
    </li>
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <xsl:template name="quickjump">
    <xsl:param name="scale"/>
    <!-- ./quickjump.inc -->
    <!--
<div xmlns="http://www.w3.org/1999/xhtml" id="quickjump">

	<script xmlns="http://www.w3.org/1999/xhtml" type="text/javascript" src="js/quickjump.js" >
		<xsl:comment>padding for ie</xsl:comment>
	</script>

<select xmlns="http://www.w3.org/1999/xhtml" name="QuickJump" size="1" class="jumpTo" onchange="jumpTo(this);">
        <option xmlns="http://www.w3.org/1999/xhtml" value="index.html">Jump to Image...</option>
        <xsl:for-each select="ancestor::photoCollection/samples/*">
                <option xmlns="http://www.w3.org/1999/xhtml">
                <xsl:attribute name='value'><xsl:call-template name="convertFileName"><xsl:with-param name="size" select="$scale" /></xsl:call-template></xsl:attribute>
                #<xsl:value-of select="format-number( $firstSampleIndex - 1 + position(), '000' )" /> - 
                <xsl:value-of select="@filename" />
                </option>
        </xsl:for-each>
</select>
</div>
<div xmlns="http://www.w3.org/1999/xhtml" class="clear"></div>
-->
    <!-- end ./quickjump.inc -->
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <xsl:template name="addAHref">
    <xsl:param name="href" />
    <xsl:param name="content" />
    <xsl:param name="skip" />
	
    <xsl:choose>
      <xsl:when test="$skip">
        <a xmlns="http://www.w3.org/1999/xhtml" >
          <xsl:copy-of select="$content" />
	</a>
      </xsl:when>
      <xsl:otherwise>
        <a xmlns="http://www.w3.org/1999/xhtml" href="{$href}">
          <xsl:copy-of select="$content" />
	</a>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <xsl:template name="contact">
    <!-- ./contact.inc -->
    <div xmlns="http://www.w3.org/1999/xhtml" id="contact">
      <xsl:call-template name="addAHref">
        <xsl:with-param name="href" select="ancestor::photoCollection/display/metadata/contactInfo/@link" />
        <xsl:with-param name="skip" select="/photoCollection/@mode = 'preview'"/>
        <xsl:with-param name="content">
          <span xmlns="http://www.w3.org/1999/xhtml" onclick="clickTarget( this, 'contactInfo.text' );" id="liveUpdateContactInfo">
            <xsl:value-of select="ancestor::photoCollection/display/metadata/contactInfo/@value"/>
          </span>
        </xsl:with-param>
      </xsl:call-template>
    </div>
    <div xmlns="http://www.w3.org/1999/xhtml" class="clear">
      <xsl:comment>padding for ie</xsl:comment>
    </div>
    <!-- end ./contact.inc -->
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <xsl:template name="emptyGridRow">
    <xsl:param name="bottomRow"/>
    <xsl:param name="numCols"/>
    <xsl:param name="class">
      <xsl:if test="$numCols &lt;= 1">borderRight</xsl:if>
      <xsl:text> </xsl:text>
      <xsl:if test="$bottomRow">borderBottom</xsl:if>
    </xsl:param>

    <!-- ROW 3 -->
    <div xmlns="http://www.w3.org/1999/xhtml" class="emptyThumbnail borderTopLeft {$class}"><xsl:text> </xsl:text></div>
    <xsl:if test="$numCols &gt; 1">
      <xsl:call-template name="emptyGridRow">
        <xsl:with-param name="numCols" select="$numCols - 1"/>
        <xsl:with-param name="bottomRow" select="$bottomRow"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <!-- insert a thumbnail image including text and link -->
  <xsl:template name="gridRow">
    <xsl:param name="pathToRoot"/>
    <xsl:param name="pathToContent"/>
    <xsl:param name="iconFullSizePNG" select="concat( $pathToRoot, 'resources/misc/icon_fullsize.png' )"/>
    <xsl:param name="numCols"/>
    <xsl:param name="itemIndex"/>
    <xsl:param name="allFullLinks"/>
    <xsl:param name="selectedItemIndex"/>
    <xsl:param name="bottomRow"/>
    <xsl:param name="selected">
      <xsl:if test="$selectedItemIndex = $itemIndex">selected</xsl:if>
    </xsl:param>
    <xsl:param name="prePreviewFull">
      <xsl:call-template name="convertFileName">
        <xsl:with-param name="size" select="'large'"/>
      </xsl:call-template>
    </xsl:param>
    <xsl:param name="previewFull" select="concat( $pathToContent, $prePreviewFull )"/>
    <xsl:param name="imageID" select="concat( 'ID', @imageID )"/>
    <xsl:param name="thumbImg" select="concat( $pathToRoot, rendition[@size='thumb']/@path )"/>
    <xsl:param name="filename" select="@filename" />
    <xsl:param name="tipname" select="@tipname" />
    <xsl:param name="class">
      <xsl:if test="$numCols &lt;= 1">borderRight</xsl:if>
      <xsl:text> </xsl:text>
      <xsl:if test="$bottomRow">borderBottom</xsl:if>
    </xsl:param>
    <!-- ROW 2 -->
    <div id="tempDiv"><xsl:value-of select="displayname"/>
    	<!--The xslt lib in os x 10.6 will ignore the endding tag when there is nothing between the tags,
			that will bring errors in browsers-->
		<xsl:comment>padding for OS X 10.6</xsl:comment>
	</div>
    <script xmlns="http://www.w3.org/1999/xhtml" type="text/javascript">
		var nameDiv = document.getElementById("tempDiv");
		var thumbnailName = getName(nameDiv.innerHTML);
		try {
			nameDiv.parentNode.removeChild(nameDiv);
		} catch (e) {}
	</script>
    <div xmlns="http://www.w3.org/1999/xhtml" class="thumbnail borderTopLeft {$class} {$selected}"
      onclick="window.location.href='{$previewFull}'">
      <div xmlns="http://www.w3.org/1999/xhtml" class="itemNumber">
        <xsl:value-of select="$firstSampleIndex - 1 + $itemIndex"/>
      </div>
      <div xmlns="http://www.w3.org/1999/xhtml"
        onmouseover="window.gridOn( this.parentNode, '{$imageID}_thumb' );"
        onmouseout="window.gridOff( this.parentNode );" class="alignmentOuterGrid">
        <xsl:if test="hasfilename = true()">
        <div xmlns="http://www.w3.org/1999/xhtml" class="alignmentOuter">
	      <div xmlns="http://www.w3.org/1999/xhtml" class="alignmentMiddle">
	        <div xmlns="http://www.w3.org/1999/xhtml" class="alignmentInner">
	          <div xmlns="http://www.w3.org/1999/xhtml" class="AdjustZIndex">
	            <a xmlns="http://www.w3.org/1999/xhtml" href="{$previewFull}"
	              onclick="return needThumbImgLink;">
				  <img xmlns="http://www.w3.org/1999/xhtml" src="{$thumbImg}" id="{$imageID}_thumb" alt="{$tipname}" />
	            </a>
	          </div>
	        </div>
	      </div>
        </div>
        <div xmlns="http://www.w3.org/1999/xhtml" class="thumbnailName">
		  <p xmlns="http://www.w3.org/1999/xhtml" onclick="clickTarget( this, 'thumbnailname' );" id="thumbnailName">
			<script xmlns="http://www.w3.org/1999/xhtml" type="text/javascript">
				document.write(thumbnailName);
			</script>
		  </p>
		</div>
        </xsl:if>
        <xsl:if test="hasfilename = false()">
        <div xmlns="http://www.w3.org/1999/xhtml" class="alignmentOuter2">
	      <div xmlns="http://www.w3.org/1999/xhtml" class="alignmentMiddle">
	        <div xmlns="http://www.w3.org/1999/xhtml" class="alignmentInner">
	          <div xmlns="http://www.w3.org/1999/xhtml" class="AdjustZIndex">
	            <a xmlns="http://www.w3.org/1999/xhtml" href="{$previewFull}"
	              onclick="return needThumbImgLink;">
				  <img xmlns="http://www.w3.org/1999/xhtml" src="{$thumbImg}" id="{$imageID}_thumb" alt="{$tipname}" />
	            </a>
	          </div>
	        </div>
	      </div>
        </div>
        </xsl:if>
      </div>
    </div>
    <xsl:if test="$numCols &gt; 1">
      <xsl:choose>
        <xsl:when test="following-sibling::*[1]">
          <xsl:for-each select="following-sibling::*[1]">
            <xsl:call-template name="gridRow">
              <xsl:with-param name="pathToRoot" select="$pathToRoot"/>
              <xsl:with-param name="pathToContent" select="$pathToContent"/>
              <xsl:with-param name="numCols" select="$numCols - 1"/>
              <xsl:with-param name="itemIndex" select="$itemIndex + 1"/>
              <xsl:with-param name="selectedItemIndex" select="$selectedItemIndex"/>
              <xsl:with-param name="allFullLinks" select="$allFullLinks"/>
              <xsl:with-param name="bottomRow" select="$bottomRow"/>
            </xsl:call-template>
          </xsl:for-each>
        </xsl:when>
        <xsl:otherwise>
          <xsl:call-template name="emptyGridRow">
            <xsl:with-param name="numCols" select="$numCols - 1"/>
            <xsl:with-param name="bottomRow" select="$bottomRow"/>
          </xsl:call-template>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:if>
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <!-- Insert CSS style stuff from web xml -->
  <xsl:template name="display">
    <xsl:param name="pathToRoot"/>
    <xsl:param name="pathToContent"/>
    <xsl:param name="size"/>
    <xsl:param name="customCSS" select="concat( $pathToContent, /photoCollection/display/style/@cssVersion, '_custom.css' )"/>
    <xsl:param name="masterCSS" select="concat( $pathToRoot, 'resources/css/master.css' )"/>
    <link xmlns="http://www.w3.org/1999/xhtml" rel="stylesheet" type="text/css" media="screen"
      title="Custom Settings" href="{$customCSS}"/>
    <link xmlns="http://www.w3.org/1999/xhtml" rel="stylesheet" type="text/css" media="screen"
      title="Custom Settings" href="{$masterCSS}"/>
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <!-- PUT COMMENT HERE -->
  <xsl:template name="customCSS">
    <xsl:param name="customCSSFileName" select="concat('content/', /photoCollection/display/style/@cssVersion, '_custom.css' )"/>
    <file name="{$customCSSFileName}">
      <xsl:for-each select="/photoCollection/display[1]/css">@import url( " <xsl:value-of
          select="@href"/>" );</xsl:for-each>
      <xsl:for-each select="/photoCollection/display[1]/style">
        <xsl:value-of select="@css"/>
      </xsl:for-each>
    </file>
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <!-- PUT COMMENT HERE -->
  <xsl:template name="noImagesSelected">
    <file name="index.html" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
      doctype-public="-//W3C//DTD XHTML 1.1//EN">
      <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
        <head xmlns="http://www.w3.org/1999/xhtml">
          <meta xmlns="http://www.w3.org/1999/xhtml" http-equiv="Content-Type"
            content="text/html; charset=UTF-8"/>
          <meta xmlns="http://www.w3.org/1999/xhtml" name="generator" content="Adobe Lightroom"/>
          <title xmlns="http://www.w3.org/1999/xhtml">
            <xsl:value-of select="ancestor::photoCollection/display/metadata/siteTitle/@value"/>
          </title>
        </head>
        <body xmlns="http://www.w3.org/1999/xhtml">
          <xsl:call-template name="ZSTR">
            <xsl:with-param name="id" select="'EmptyGallery'"/>
          </xsl:call-template>
        </body>
      </html>
    </file>
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <!-- PUT COMMENT HERE -->
  <xsl:template name="outerIndex">
    <xsl:call-template name="indexPageWithPathSupport">
      <xsl:with-param name="firstImage" select="0"/>
      <xsl:with-param name="pathToRoot" select="''"/>
      <xsl:with-param name="pathToContent" select="'content/'"/>
      <xsl:with-param name="homeDir" select="''"/>

	<!-- Lightroom is no longer beta.
		Disable this block so that the html output is not stamped with a beta link.
		To re-enable the beta branding, uncomment this section.

      <xsl:with-param name="betaLink">
        <div class="betaLink" xmlns="http://www.w3.org/1999/xhtml">
          <a>
            <xsl:attribute name="href">
              <xsl:call-template name="ZSTR">
                <xsl:with-param name="id" select="'AdobeLightroomWebSite'"/>
              </xsl:call-template>
            </xsl:attribute>
            <xsl:call-template name="ZSTR">
              <xsl:with-param name="id" select="'AdobeLightroomBeta'"/>
            </xsl:call-template>
          </a>
        </div>
      </xsl:with-param>
	-->
    </xsl:call-template>
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <!-- Convert a filename to its html file name. -->
  <xsl:template name="convertFileName">
    <xsl:param name="filename" select="@filename"/>
    <xsl:param name="size"/>
    <xsl:param name="itemIndex"/>
    <xsl:param name="itemIndex_real">
      <xsl:choose>
        <xsl:when test="$itemIndex">
          <xsl:value-of select="$itemIndex"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="position()"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:param>
    <xsl:choose>
      <xsl:when test="$size = 'small'">
        <xsl:call-template name="indexLink">
          <xsl:with-param name="imageNumber" select="$firstSampleIndex - 1 + $itemIndex_real"/>
          <xsl:with-param name="scale" select="$size"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="concat($filename, '_', $size, '.html')"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <!-- Find the name of an index.html file that this nth image is found on -->
  <!--
      ======================================================================================================================================================
    -->
  <!-- Find the name of an INDEXNAME.html file that this nth image is found on -->
  <xsl:template name="indexLink">
    <xsl:param name="pathToContent"/>
    <xsl:param name="imageNumber"/>
    <xsl:param name="scale"/>
    <xsl:param name="nameBase">
      <xsl:choose>
        <xsl:when test="$scale = 'small'">small_index</xsl:when>
        <xsl:otherwise>index</xsl:otherwise>
      </xsl:choose>
    </xsl:param>
    <xsl:param name="numImgsPerPage">
      <xsl:choose>
        <xsl:when test="$scale = 'small'">
          <xsl:value-of select="$numCellsInSmallGrid"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$numCellsInIndexGrid"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:param>
    <!--
                <xsl:choose>
                        <xsl:when test="$scale = 'small'" >
                                <xsl:call-template name="convertFileName">
                                        <xsl:with-param name="filename" select="ancestor::photoCollection/samples/*[$imageNumber]/@filename" />
                                        <xsl:with-param name="size" select="$scale" />
                                </xsl:call-template>
                        </xsl:when>
                        <xsl:otherwise>
-->
    <xsl:choose>
      <xsl:when test="$imageNumber &lt;= $numImgsPerPage">
        <xsl:value-of select="concat( $pathToContent, $nameBase, '.html' )"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of
          select="concat( $pathToContent, $nameBase, '_', ceiling( $imageNumber div $numImgsPerPage ) , '.html')"
        />
      </xsl:otherwise>
    </xsl:choose>
    <!--
                        </xsl:otherwise>
                </xsl:choose>
-->
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <!-- Insert text div's for each attribute on element -->
  <xsl:template name="imageText">
    <xsl:param name="element"/>
    <xsl:param name="size"/>
    <xsl:for-each select="$element/@*">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <xsl:attribute name="class">
          <xsl:value-of select="concat( name(), ' ', name(), '_', $size )"/>
        </xsl:attribute>
        <xsl:value-of select="."/>
      </div>
    </xsl:for-each>
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <!-- Verbatim copy something -->
  <xsl:template name="verbatim">
    <xsl:param name="element"/>
    <xsl:for-each select="$element">
      <xsl:copy-of select="*|text()"/>
    </xsl:for-each>
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <!-- Generate a separate html page for each image  -->
  <xsl:template match="img" name="previewFullFile">
    <xsl:param name="other"/>
    <xsl:param name="this"/>
    <file doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
      doctype-public="-//W3C//DTD XHTML 1.1//EN">
      <xsl:attribute name="name">content/<xsl:call-template name="convertFileName">
          <xsl:with-param name="size" select="$this"/>
        </xsl:call-template></xsl:attribute>
      <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
        <!--HAS_WEBDNA_TAGS-->
        <head xmlns="http://www.w3.org/1999/xhtml">
          <meta xmlns="http://www.w3.org/1999/xhtml" http-equiv="Content-Type"
            content="text/html; charset=UTF-8"/>
          <meta xmlns="http://www.w3.org/1999/xhtml" name="generator" content="Adobe Lightroom"/>
          <title xmlns="http://www.w3.org/1999/xhtml">
            <xsl:value-of select="ancestor::photoCollection/display/metadata/siteTitle/@value"/>
          </title>
          <!-- STYLE -->
          <xsl:call-template name="display">
            <xsl:with-param name="pathToRoot" select="'../'"/>
            <xsl:with-param name="pathToContent" select="''"/>
          </xsl:call-template>
          <xsl:if test="$includeStyleSwitcher">
            <link xmlns="http://www.w3.org/1999/xhtml" rel="alternate stylesheet" type="text/css"
              href="css/backdrop_000.css" title="backdrop_000"/>
            <link xmlns="http://www.w3.org/1999/xhtml" rel="alternate stylesheet" type="text/css"
              href="css/backdrop_020.css" title="backdrop_020"/>
            <link xmlns="http://www.w3.org/1999/xhtml" rel="alternate stylesheet" type="text/css"
              href="css/backdrop_030.css" title="backdrop_030"/>
            <link xmlns="http://www.w3.org/1999/xhtml" rel="alternate stylesheet" type="text/css"
              href="css/backdrop_grad.css" title="backdrop_grad"/>
		  <script xmlns="http://www.w3.org/1999/xhtml" type="text/javascript" src="js/styleswitcher.js">
			  <xsl:comment>padding for ie</xsl:comment>
		  </script>
		  <script xmlns="http://www.w3.org/1999/xhtml" type="text/javascript" src="js/cutName.js">
			  <xsl:comment>padding for ie</xsl:comment>
		  </script>
          </xsl:if>
          <!-- Lightroom Interaction -->
          <xsl:call-template name="lightroomInteraction">
            <xsl:with-param name="pathToRoot" select="'../'"/>
            <xsl:with-param name="size" select="'large'"/>
            <xsl:with-param name="showInPhotoBin" select="1" />
          </xsl:call-template>
          <xsl:comment>[if lt IE 7.]&gt; &lt;script defer type="text/javascript"
            src="../resources/js/pngfix.js"&gt;&lt;/script&gt; &lt;![endif]</xsl:comment>
		  <xsl:comment>[if gt IE 6]&gt; &lt;link rel="stylesheet" href="../resources/css/ie7.css"&gt;&lt;/link&gt; &lt;![endif]</xsl:comment>
		  <xsl:comment>[if lt IE 7.]&gt; &lt;link rel="stylesheet" href="../resources/css/ie6.css"&gt;&lt;/link&gt; &lt;![endif]</xsl:comment>
        </head>
        <body xmlns="http://www.w3.org/1999/xhtml">
          <!-- BEGIN WRAPPER -->
          <div xmlns="http://www.w3.org/1999/xhtml" id="wrapper2">
            <!-- IDENTITY PLATE -->
            <xsl:call-template name="idplate">
              <xsl:with-param name="pathToRoot" select="'../'"/>
              <xsl:with-param name="pathToContent" select="''"/>
            </xsl:call-template>
            <!-- SITE TITLE -->
            <xsl:call-template name="sitetitle"/>
            <!-- DESCRIPTION HEADER -->
            <xsl:call-template name="collectionHeader"/>
            <!-- BEGIN STAGE -->
            <div xmlns="http://www.w3.org/1999/xhtml" id="stage2">
              <!-- PREVIEW FULL -->
              <xsl:call-template name="previewFull"/>
            </div>
			<div xmlns="http://www.w3.org/1999/xhtml" class="clear">
				<xsl:comment>padding for ie</xsl:comment>
			</div>
            <!-- END STAGE -->
            <!-- STYLE SWITCHER -->
            <xsl:call-template name="styleswitcher"/>
            <!-- QUICK JUMP -->
            <xsl:call-template name="quickjump">
              <xsl:with-param name="scale" select="'large'"/>
            </xsl:call-template>
            <!-- CONTACT INFO -->
            <xsl:call-template name="contact"/>
          </div>
          <!-- END GRID -->
        </body>
      </html>
    </file>
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <xsl:template name="previewFull">
    <xsl:param name="imageID" select="concat( 'ID', @imageID )"/>
    <xsl:param name="largeImageSrc" select="concat( '../', rendition[@size='large']/@path )"/>
    <xsl:param name="filename" select="@filename" />
    <xsl:param name="tipname" select="@tipname" />
    <xsl:param name="largeImageWidth">
      <xsl:value-of select="rendition[@size='large']/@width"/>
    </xsl:param>
    <xsl:param name="largeImageHeight">
      <xsl:value-of select="rendition[@size='large']/@height"/>
    </xsl:param>
    <xsl:param name="fullSizeLink">
      <xsl:call-template name="convertFileName">
        <xsl:with-param name="size" select="'large'"/>
      </xsl:call-template>
    </xsl:param>
    <xsl:param name="indexLink">
      <xsl:call-template name="indexLink">
        <xsl:with-param name="imageNumber" select="$firstSampleIndex - 1 + position()"/>
        <xsl:with-param name="size" select="'large'"/>
      </xsl:call-template>
    </xsl:param>
    <!-- ./previewFull.inc -->
    <div xmlns="http://www.w3.org/1999/xhtml" id="previewFull"
      class="borderTopLeft borderBottomRight">
      <div xmlns="http://www.w3.org/1999/xhtml" id="detailTitle"
              onclick="clickTarget( this, 'perImageSetting-title', '{$imageID}' );"><xsl:text> </xsl:text>
              <xsl:call-template name="verbatim">
                <xsl:with-param name="element" select="text/title"/>
              </xsl:call-template>
      </div>
      <div xmlns="http://www.w3.org/1999/xhtml" class="detailNav">
        <ul xmlns="http://www.w3.org/1999/xhtml">
          <li xmlns="http://www.w3.org/1999/xhtml" class="previous">
             <xsl:choose>
               <xsl:when test="preceding-sibling::*[1]">
                 <xsl:for-each select="preceding-sibling::*[1]">
                   <a xmlns="http://www.w3.org/1999/xhtml" class="detailLinks">
                     <xsl:attribute name="href">
                       <xsl:call-template name="convertFileName">
                         <xsl:with-param name="size" select="'large'"/>
                       </xsl:call-template>
                     </xsl:attribute>
                     <xsl:call-template name="ZSTR">
                       <xsl:with-param name="id" select="'Previous'"/>
                     </xsl:call-template>
                   </a>
                 </xsl:for-each>
               </xsl:when>
               <xsl:otherwise>
                 <xsl:call-template name="ZSTR">
                   <xsl:with-param name="id" select="'Previous'"/>
                 </xsl:call-template>
               </xsl:otherwise>
             </xsl:choose>
           </li>
           <li xmlns="http://www.w3.org/1999/xhtml" class="index">
             <a xmlns="http://www.w3.org/1999/xhtml" href="{$indexLink}" class="detailLinks">
               <xsl:call-template name="ZSTR">
                 <xsl:with-param name="id" select="'Index'"/>
               </xsl:call-template>
             </a>
           </li>
           <li xmlns="http://www.w3.org/1999/xhtml" class="next">
             <xsl:choose>
               <xsl:when test="following-sibling::*[1]">
                 <xsl:for-each select="following-sibling::*[1]">
                   <a xmlns="http://www.w3.org/1999/xhtml" class="detailLinks">
                     <xsl:attribute name="href">
                       <xsl:call-template name="convertFileName">
                         <xsl:with-param name="size" select="'large'"/>
                       </xsl:call-template>
                     </xsl:attribute>
                     <xsl:call-template name="ZSTR">
                       <xsl:with-param name="id" select="'Next'"/>
                     </xsl:call-template>
                   </a>
                 </xsl:for-each>
               </xsl:when>
               <xsl:otherwise>
                 <xsl:call-template name="ZSTR">
                   <xsl:with-param name="id" select="'Next'"/>
                 </xsl:call-template>
               </xsl:otherwise>
             </xsl:choose>
           </li>
         </ul>
      </div>
      <!-- IMAGE -->
      <div id="tempDiv"><xsl:value-of select="displayname"/>
      	  <!--The xslt lib in os x 10.6 will ignore the endding tag when there is nothing between the tags,
			that will bring errors in browsers-->
	  	  <xsl:comment>padding for OS X 10.6</xsl:comment>
	  </div>
      <div id="tempWidth"><xsl:value-of select="displaywidth"/>
      	  <!--The xslt lib in os x 10.6 will ignore the endding tag when there is nothing between the tags,
			that will bring errors in browsers-->
      	  <xsl:comment>padding for OS X 10.6</xsl:comment>
	  </div>
	    <script xmlns="http://www.w3.org/1999/xhtml" type="text/javascript">
			var nameDiv = document.getElementById("tempDiv");
			var widthDiv = document.getElementById("tempWidth");
			var width = parseInt(widthDiv.innerHTML, 10);
			var largeName = addSpace(nameDiv.innerHTML, width - 14);
			try {
				nameDiv.parentNode.removeChild(nameDiv);
				widthDiv.parentNode.removeChild(widthDiv);
			} catch (e) {}
		</script>
      <div xmlns="http://www.w3.org/1999/xhtml" id="detailImage">
			<a xmlns="http://www.w3.org/1999/xhtml" href="{$indexLink}">
			  <img xmlns="http://www.w3.org/1999/xhtml" src="{$largeImageSrc}"
				  width="{$largeImageWidth}" height="{$largeImageHeight}" id="{$imageID}" alt="{$tipname}" />
			</a>
            <xsl:if test="hasfilename = true()">
				<div xmlns="http://www.w3.org/1999/xhtml" class="largeName">
		          <p xmlns="http://www.w3.org/1999/xhtml" onclick="clickTarget( this, 'largename' );" id="largeName">
					<script xmlns="http://www.w3.org/1999/xhtml" type="text/javascript">
						document.write(largeName);
					</script>
				  </p>
				</div>
			</xsl:if>
      </div>

	  <div xmlns="http://www.w3.org/1999/xhtml" id="detailCaption"
		  		onclick="clickTarget( this, 'perImageSetting-description', '{$imageID}' );"><xsl:text> </xsl:text>
		  <xsl:call-template name="verbatim">
			<xsl:with-param name="element" select="text/description"/>
		  </xsl:call-template>
      </div>
    </div>
    <!-- end ./previewFull.inc -->
  </xsl:template>
  <!--
      ======================================================================================================================================================
    -->
  <xsl:template name="lightroomInteraction">
    <xsl:param name="pathToRoot"/>
    <xsl:param name="size"/>
    <xsl:param name="showInPhotoBin"/>
    <script xmlns="http://www.w3.org/1999/xhtml" type="text/javascript">
	  window.AgMode = "<xsl:value-of select="/photoCollection/@mode"/>";
      cellRolloverColor=<xsl:value-of select="concat( '&quot;', /photoCollection/display/style/@cellRolloverColor, '&quot;' )"/>;
      cellColor=<xsl:value-of select="concat( '&quot;', /photoCollection/display/style/@cellColor, '&quot;' )"/>;
      <xsl:if test="$showInPhotoBin = 1">
      window.AgOnLoad = function() {
                        tellLightroomWhatImagesWeAreUsing(); 
                        <xsl:value-of select="concat( 'callCallback( &quot;showInPhotoBin&quot;, &quot;', @imageID, '&quot; );' )"/> 
                        <xsl:value-of select="concat( 'callCallback( &quot;setActiveImageSize&quot;, &quot;', $size, '&quot; );' )"/>
                }
      </xsl:if>
        </script>
		<script xmlns="http://www.w3.org/1999/xhtml" type="text/javascript" src="{$pathToRoot}resources/js/liveUpdate.js">
			<xsl:comment>padding for ie</xsl:comment>
		</script>
		<script xmlns="http://www.w3.org/1999/xhtml" type="text/javascript" src="{$pathToRoot}resources/js/cutName.js">
			<xsl:comment>padding for ie</xsl:comment>
		</script>
  </xsl:template>
  <!--
      ======================================================================================================================================================
      ======================================================================================================================================================
    -->
  <!-- Utility Functions -->
  <!-- ZSTR : lookup the translated string for the this identifier.  The identifier must be listed in the ag:localization section of this document. -->
  <!-- NOTE : ZSTR will provide localized strings only for strings found in Adobe-built templates. -->
  <xsl:template name="ZSTR">
    <xsl:param name="id"/>
    <xsl:param name="value" select="/photoCollection/display/localization/item[@id=$id]/@localized"/>
    <xsl:choose>
      <xsl:when test="$value">
        <xsl:value-of select="$value"/>
      </xsl:when>
      <xsl:otherwise>
        <!-- insert *** around the text to call attention to the fact that this id is missing from
           the localization section of the source xml file. -->
        <xsl:value-of select="concat( '***', $id, '***' )"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>
