<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--  $Id$  -->
<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" indent="no" doctype-system="http://www.w3.org/TR/html4/strict.dtd" doctype-public="-//W3C//DTD HTML 4.01//EN" encoding="utf-8" />

    <xsl:include href="/app/tools/bookpub/templates/global.xsl" />

    <xsl:template name="pickLayout">
        <div class="CatalogSearch">
            <xsl:choose>
                <xsl:when test="count(BookList/Book) = 0">
                    <p>No books are available under this heading.</p>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="numericListNavSetup" />
                    <xsl:call-template name="bookList" />
                </xsl:otherwise>
            </xsl:choose>
        </div>
    </xsl:template>

    <xsl:template name="numericListNavSetup">
        <xsl:call-template name="alphaListNav">
            <xsl:with-param name="pagination">/Root/BookList/Pagination</xsl:with-param>
            <xsl:with-param name="extraParams">
                <xsl:if test="/Root/Params/ContributorID">&amp;ContributorID=<xsl:value-of select="/Root/Params/ContributorID" /></xsl:if>
                <xsl:if test="/Root/Params/ImprintID">&amp;ImprintID=<xsl:value-of select="/Root/Params/ImprintID" /></xsl:if>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:call-template name="numericListNav">
            <xsl:with-param name="pagination">/Root/BookList/Pagination</xsl:with-param>
            <xsl:with-param name="extraParams">
                <xsl:if test="/Root/Params/ContributorID">&amp;ContributorID=<xsl:value-of select="/Root/Params/ContributorID" /></xsl:if>
                <xsl:if test="/Root/Params/ImprintID">&amp;ImprintID=<xsl:value-of select="/Root/Params/ImprintID" /></xsl:if>
            </xsl:with-param>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="bookList">
        <table class="Table">
            <thead>
                <tr class="Table-row Table-row-header">
                    <th class="Table-col">Title</th>
                    <th class="Table-col">Subtitle</th>
                    <xsl:choose>
                        <xsl:when test="BookList/Book/ContributorHash/Contributor">
                            <th class="Table-col">Contributor</th>
                        </xsl:when>
                        <xsl:otherwise>
                            <th class="Table-col">Author</th>
                        </xsl:otherwise>
                    </xsl:choose>
                    <xsl:if test="ImprintList/Imprint">
                        <th class="Table-col">Imprint</th>
                    </xsl:if>
                    <xsl:if test="Access/bookpub/catalog/edit_book">
                        <th class="Table-col Table-col-icon">Edit</th>
                    </xsl:if>
                </tr>
            </thead>
            <tbody>
                <xsl:for-each select="BookList/Book">
                    <tr class="Table-row Table-row-data">
                        <td class="Table-col"><a href="catalog?BookID={BookID}&amp;c=show_book"><xsl:value-of select="Title" /></a></td>
                        <td class="Table-col"><xsl:value-of select="Subtitle" /></td>
                        <xsl:choose>
                            <xsl:when test="ContributorHash/Contributor">
                                <td class="Table-col">
                                    <xsl:for-each select="ContributorHash/Contributor">
                                        <xsl:value-of select="ContributorRole/Description" /> : <xsl:value-of select="Name" /><br />
                                    </xsl:for-each>
                                </td>
                            </xsl:when>
                            <xsl:otherwise>
                                <td class="Table-col"><xsl:value-of select="AuthorName" /></td>
                            </xsl:otherwise>
                        </xsl:choose>
                        <xsl:if test="/Root/ImprintList/Imprint">
                            <xsl:variable name="bookImprintID"><xsl:value-of select="/Root/Params/ImprintID" /></xsl:variable>
                            <td class="Table-col"><xsl:value-of select="/Root/ImprintList/Imprint[ImprintID = $bookImprintID]/Name" /></td>
                        </xsl:if>
                        <xsl:if test="/Root/Access/bookpub/catalog/edit_book">
                            <td class="Table-col Table-col-icon">
                                <a href="catalog?c=edit_book&amp;BookID={BookID}" title="Edit" class="js-tooltip">
                                    <xsl:call-template name="icon">
                                        <xsl:with-param name="type" select="'edit'" />
                                        <xsl:with-param name="role" select="'action'" />
                                    </xsl:call-template>
                                </a>
                            </td>
                        </xsl:if>
                    </tr>
                </xsl:for-each>
            </tbody>
        </table>
    </xsl:template>

</xsl:stylesheet>
