<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:dyn="http://exslt.org/dynamic" extension-element-prefixes="dyn">
    <xsl:output method="html" indent="no" doctype-system="" encoding="utf-8" />

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

    <xsl:template name="matcherErrorMessages">
        <xsl:call-template name="errorMessageBox">
            <xsl:with-param name="errorMessage">
                <xsl:if test="Messages/Message/Code = 'unmatch_failed'">Unable to undo this match.</xsl:if>
            </xsl:with-param>
        </xsl:call-template>
    </xsl:template>

    <xsl:variable name="sortOrder">
        <xsl:choose>
            <xsl:when test="normalize-space(/Root/Params/sort_order)">descending</xsl:when>
            <xsl:otherwise>ascending</xsl:otherwise>
        </xsl:choose>
    </xsl:variable>

    <xsl:template name="pickLayout">
        <div class="Matcher-manage" id="manageImport">
            <xsl:call-template name="helpLink" />
            <div class="Matcher-manage-file-name">
                <span class="FileName"><xsl:value-of select="File/PrettyFileName" /></span>
            </div>

            <table class="Table Matcher-manage-table">
                <thead>
                    <tr class="Table-row Table-row-header">
                        <th class="Table-col Matcher-manage-table-col">Service</th>
                        <th class="Table-col Matcher-manage-table-col">Records</th>
                        <th class="Table-col Matcher-manage-table-col">Exceptions (Left/Initial)</th>
                    </tr>
                </thead>
                <tbody>
                    <tr class="Table-row Table-row-data">
                        <td class="Table-col Matcher-manage-table-col"><xsl:value-of select="File/ServiceName" /></td>
                        <td class="Table-col Matcher-manage-table-col"><xsl:value-of select="File/Records" /></td>
                        <td class="Table-col Matcher-manage-table-col"><xsl:value-of select="File/RemainingExceptions" />/<xsl:value-of select="File/TotalExceptions" /></td>
                    </tr>
                </tbody>
            </table>
        </div>

        <div class="Matcher-exceptions">
            <xsl:call-template name="navLinks" />
            <xsl:call-template name="matcherChart" />
            <div class="Matcher-matches">
                <xsl:if test="Sale/ProductID = '' or Sale/ProductID = 0">
                    <div class="Matcher-search">

                        <h2 class="Matcher-search-header">
                            <xsl:choose>
                                <xsl:when test="normalize-space(Sale/ProductID) and Sale/ProductID != 0">
                                    Current Match
                                </xsl:when>
                                <xsl:otherwise>
                                    Suggested
                                    <xsl:if test="Sale/ProductType = 'BOOK'">Book</xsl:if>
                                    <xsl:if test="Sale/ProductType = 'CHAP'">Chapter</xsl:if>
                                    Matches
                                </xsl:otherwise>
                            </xsl:choose>
                        </h2>

                        <form action="/bookpub/matcher" name="matcherSearch" class="matcherSearch">
                            <input type="hidden" name="sale" value="{Sale/SaleID}" />
                            <input type="hidden" name="c" value="sale" />
                            <input type="hidden" name="trackerPage" value="{Params/trackerPage}" />
                            <script src="/production/javascript/validateSearch.js?v=1" type="text/javascript"></script>
                            <xsl:variable name="matcherSearchItems">
                                <map>
                                    <mapEntry><name>Smart</name><value>smart</value></mapEntry>
                                    <mapEntry><name>All</name><value>all</value></mapEntry>
                                    <mapEntry><name>Authors</name><value>author</value></mapEntry>
                                    <mapEntry><name>Titles</name><value>title</value></mapEntry>
                                    <mapEntry><name>ISBN10</name><value>isbn10</value></mapEntry>
                                    <mapEntry><name>ISBN13</name><value>isbn13</value></mapEntry>
                                </map>
                            </xsl:variable>
                            <span id="searchText"></span>
                            <div class="Form-group Form-group-horizontal">
                                <div class="Form-item">
                                    <div class="ControlsGroup ControlsGroup-type-input">
                                        <label class="ControlsGroup-item">
                                            <xsl:call-template name="uiDropdown">
                                                <xsl:with-param name="items" select="$matcherSearchItems"/>
                                                <xsl:with-param name="name" select="'search_type'"/>
                                                <xsl:with-param name="active" select="Params/search_type"/>
                                                <xsl:with-param name="className" select="'Matcher-search-dropdown'"/>
                                            </xsl:call-template>
                                        </label>

                                        <Label class="InputWrapper InputWrapper-with-icon InputWrapper-with-icon-right ControlsGroup-item Matcher-search-input">
                                            <input class="Input" type="text" placeholder="Search..." name="search" maxlength="100" value="{Params/search}" onFocus="this.select();"/>
                                            <label class="InputWrapper-icon Icon-trigger InputWrapper-icon-search">
                                                <input type="submit" name="Go"/>
                                                <xsl:call-template name="icon">
                                                    <xsl:with-param name="type" select="'search'" />
                                                    <xsl:with-param name="role" select="'action'" />
                                                </xsl:call-template>
                                            </label>
                                        </Label>
                                    </div>
                                    <span id="ERRORsearch" class="Form-error"></span>
                                </div>
                                <div class="Form-item">
                                    <xsl:call-template name="uiButton">
                                        <xsl:with-param name="name" select="'Go'" />
                                        <xsl:with-param name="elemType" select="'submit'" />
                                        <xsl:with-param name="content" select="'Search'" />
                                    </xsl:call-template>
                                </div>
                                <div class="Form-item">
                                    <xsl:call-template name="uiButton">
                                        <xsl:with-param name="name" select="'clear'" />
                                        <xsl:with-param name="content" select="'Clear'" />
                                        <xsl:with-param name="onClick">
                                            document.forms['matcherSearch'].elements['search'].value = '';
                                        </xsl:with-param>
                                    </xsl:call-template>
                                </div>
                            </div>
                            <xsl:if test="normalize-space(Params/search)">
                                <div class="Matcher-return-button-container">
                                    <xsl:call-template name="uiButton">
                                        <xsl:with-param name="name" select="'clear'" />
                                        <xsl:with-param name="content" select="'Return To Suggestions'" />
                                        <xsl:with-param name="url">
                                            <xsl:text>/bookpub/matcher?c=sale&amp;sale=</xsl:text>
                                            <xsl:value-of select="Sale/SaleID" />
                                            <xsl:text>&amp;trackerPage=</xsl:text>
                                            <xsl:value-of select="Params/trackerPage" />
                                        </xsl:with-param>
                                    </xsl:call-template>
                                </div>
                            </xsl:if>
                        </form>
                    </div>
                </xsl:if>
                <div class="Matcher-matcher">
                    <form action="/bookpub/matcher" name="match">
                        <input type="hidden" name="sale" value="{Sale/SaleID}" />
                        <input type="hidden" name="trackerPage" value="{Params/trackerPage}" />
                        <span id="ERRORproduct" class="Form-error"></span>
                        <xsl:if test="not(Params/search)">
                            <xsl:call-template name="messages" />
                        </xsl:if>
                        <xsl:if test="normalize-space(Sale/ProductID) and Sale/ProductID != 0">
                            <xsl:call-template name="uiWarning">
                                <xsl:with-param name="type" select="'success'" />
                                <xsl:with-param name="description">
                                    This sale has been matched.
                                </xsl:with-param>
                            </xsl:call-template>
                        </xsl:if>
                        <xsl:if test="File/RemainingExceptions = 0">
                            <xsl:call-template name="uiWarning">
                                <xsl:with-param name="type" select="'success'" />
                                <xsl:with-param name="description">
                                    All exceptions resolved for <span class="FileName"><xsl:value-of select="File/PrettyFileName"/></span>.
                                </xsl:with-param>
                            </xsl:call-template>
                        </xsl:if>
                        <xsl:if test="Sale">
                            <xsl:call-template name="suggestedChart" />
                        </xsl:if>
                        <fieldset class="Form-fieldset Form-fieldset-buttons">
                            <xsl:if test="normalize-space(Sale/ProductID) and Sale/ProductID != 0 and Sale/ImportStatus != 1">
                                <input type="hidden" name="c" value="unmatch" />
                                <xsl:call-template name="uiButton">
                                    <xsl:with-param name="content" select="'Undo Match'" />
                                    <xsl:with-param name="className" select="'Form-button'" />
                                    <xsl:with-param name="elemType" select="'submit'" />
                                    <xsl:with-param name="name" select="'submit'" />
                                    <xsl:with-param name="disabled">
                                        <xsl:if test="Sale/ImportStatus != 2 and Sale/ImportStatus != 3">
                                            <xsl:text>true</xsl:text>
                                        </xsl:if>
                                    </xsl:with-param>
                                </xsl:call-template>
                            </xsl:if>
                            <xsl:if test="(normalize-space(Products/Product/ProductID)) and (Sale/ProductID = '' or Sale/ProductID = 0)">
                                <input type="hidden" name="c" value="match" />
                                <xsl:call-template name="uiButton">
                                    <xsl:with-param name="content" select="'Match to Catalog'" />
                                    <xsl:with-param name="className" select="'Form-button'" />
                                    <xsl:with-param name="elemType" select="'submit'" />
                                    <xsl:with-param name="name" select="'submitMatch'" />
                                    <xsl:with-param name="disabled" select="'true'" />
                                </xsl:call-template>
                            </xsl:if>
                            <xsl:call-template name="uiButton">
                                <xsl:with-param name="content" select="'Back to Summary'" />
                                <xsl:with-param name="className" select="'Form-button'" />
                                <xsl:with-param name="url">
                                    <xsl:text>/bookpub/tracker?page=</xsl:text>
                                    <xsl:value-of select="Params/trackerPage" />
                                    <xsl:text>#file</xsl:text>
                                    <xsl:value-of select="File/FileID" />
                                </xsl:with-param>
                            </xsl:call-template>
                        </fieldset>
                    </form>
                </div>
            </div>
        </div>
    </xsl:template>

    <xsl:template name="matcherChart">
        <div class="Matcher-chart">
            <xsl:if test="not(Sale)">
                <xsl:call-template name="uiWarning">
                    <xsl:with-param name="type" select="'error'" />
                    <xsl:with-param name="description">
                        Line #<xsl:value-of select="Params/line" /> does not exist in this file.
                    </xsl:with-param>
                </xsl:call-template>
            </xsl:if>
            <xsl:if test="Sale">
                <table class="Table">
                    <thead>
                    <tr class="Table-row Table-row-header">
                        <th class="Table-col">Type</th>
                        <th class="Table-col">Author</th>
                        <th class="Table-col">Title</th>
                        <th class="Table-col">Subtitle</th>
                        <th class="Table-col">Format</th>
                        <th class="Table-col">ISBN13</th>
                        <xsl:if test="normalize-space(Sale/rISBN10)">
                            <th class="Table-col">ISBN10</th>
                        </xsl:if>
                        <xsl:if test="normalize-space(Sale/rClientProductID)">
                            <th class="Table-col">Client&#160;Service&#160;ID</th>
                        </xsl:if>
                        <xsl:if test="normalize-space(Sale/ServiceProductID)">
                            <th class="Table-col">Vendor&#160;ID</th>
                        </xsl:if>
                        <th class="Table-col">List Price</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr class="Table-row Table-row-data">
                        <td class="Table-col"><xsl:value-of select="Sale/ProductTypeString" /></td>
                        <td class="Table-col"><xsl:value-of select="Sale/rAuthor" /></td>
                        <td class="Table-col"><xsl:value-of select="Sale/rTitle" /></td>
                        <td class="Table-col"><xsl:value-of select="Sale/rSubtitle" /></td>
                        <td class="Table-col"><xsl:value-of select="Sale/FormatTypeString" /></td>
                        <td class="Table-col"><xsl:value-of select="Sale/rISBN13" /></td>
                        <xsl:if test="normalize-space(Sale/rISBN10)">
                            <td class="Table-col"><xsl:value-of select="Sale/rISBN10" /></td>
                        </xsl:if>
                        <xsl:if test="normalize-space(Sale/rClientProductID)">
                            <td class="Table-col"><xsl:value-of select="Sale/rClientProductID" /></td>
                        </xsl:if>
                        <xsl:if test="normalize-space(Sale/ServiceProductID)">
                            <td class="Table-col"><xsl:value-of select="Sale/ServiceProductID" /></td>
                        </xsl:if>
                        <td class="Table-col">
                            <xsl:value-of select="Sale/ListPrice" />&#160;(<xsl:value-of select="/Root/PriceTypes/PriceType[PriceTypeID = /Root/Sale/PriceTypeID]/Display" />)
                        </td>
                    </tr>
                    </tbody>
                </table>
            </xsl:if>
        </div>
    </xsl:template>

    <xsl:template name="suggestedChart">
        <xsl:if test="Params/search">
            <div class="TextNode">
                <p>
                    <strong><xsl:value-of select="count(Products/Product)" /></strong>
                    result<xsl:if test="count(Products/Product) != 1">s</xsl:if> found for <strong>'<xsl:value-of select="Params/search" />'</strong>
                </p>
            </div>
        </xsl:if>
        <div class="Matcher-matches-chart js-sticky-table">
            <xsl:if test="Products">
                <div class="Table-sticky-header">
                    <div class="Table-wrapper Table-wrapper-sticky-header">
                        <table class="Table Table-with-highlight Matcher-matches-table">
                            <thead>
                                <xsl:call-template name="productHeaderRow"/>
                            </thead>
                        </table>
                    </div>
                </div>
                <div class="Table-wrapper Matcher-matches-chart-wrapper Table-wrapper-sticky-body">
                    <table class="Table Table-with-highlight Matcher-matches-table">
                        <tbody>
                            <xsl:choose>
                                <xsl:when test="Params/sort = 'format'">
                                    <xsl:for-each select="Products/Product">
                                    <xsl:sort select="translate(ProductFormat/BookFormatType/Description,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')" data-type="text" order="{$sortOrder}" />
                                    <xsl:sort select="translate(ProductFormat/BookFormatSubtype/Description,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"  data-type="text" order="{$sortOrder}" />
                                    <xsl:call-template name="productDataRow"/>
                                    </xsl:for-each>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:variable name="sortParam">
                                        <xsl:choose>
                                            <xsl:when test="Params/sort = 'author'">translate(Book/AuthorName,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')</xsl:when>
                                            <xsl:when test="Params/sort = 'title'">translate(Book/Title,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')</xsl:when>
                                            <xsl:when test="Params/sort = 'subtitle'">translate(Book/Subtitle,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')</xsl:when>
                                            <xsl:when test="Params/sort = 'isbn10'">translate(ISBN10,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')</xsl:when>
                                            <xsl:when test="Params/sort = 'isbn13'">translate(ISBN13,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')</xsl:when>
                                            <xsl:when test="Params/sort = 'list_price' and $sortOrder = 'ascending'">MinPrice</xsl:when>
                                            <xsl:when test="Params/sort = 'list_price' and $sortOrder = 'descending'">MaxPrice</xsl:when>
                                        </xsl:choose>
                                    </xsl:variable>
                                    <xsl:variable name="dataType">
                                        <xsl:choose>
                                            <xsl:when test="Params/sort = 'isbn10' or Params/sort = 'isbn13' or Params/sort = 'list_price'">number</xsl:when>
                                            <xsl:otherwise>text</xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:variable>
                                    <xsl:for-each select="Products/Product">
                                        <xsl:sort select="dyn:evaluate($sortParam)" data-type="{$dataType}" order="{$sortOrder}" />
                                        <xsl:call-template name="productDataRow"/>
                                    </xsl:for-each>
                                </xsl:otherwise>
                            </xsl:choose>
                        </tbody>
                    </table>
                </div>
            </xsl:if>
        </div>
    </xsl:template>

    <xsl:template name="matcherFilesSort">
        <xsl:param name="name" />
        <xsl:param name="caption" />
        <xsl:variable name="sortLink">/bookpub/matcher?c=sale&amp;sale=<xsl:value-of select="Params/sale"/>&amp;<xsl:if test="Params/search_type">search_type=<xsl:value-of select="Params/search_type"/>&amp;</xsl:if><xsl:if test="Params/search">search=<xsl:value-of select="Params/search"/></xsl:if>&amp;trackerPage=<xsl:value-of select="/Root/Params/trackerPage" />&amp;</xsl:variable>
        <xsl:variable name="sortLinkWithType">
            <xsl:value-of select="$sortLink" />
            <xsl:text>sort=</xsl:text>
            <xsl:value-of select="$name" />
            <xsl:if test="Params/sort = $name and not(Params/sort_order)">
                <xsl:text>&amp;sort_order=1</xsl:text>
            </xsl:if>
        </xsl:variable>
        <xsl:call-template name="uiTableSorting">
            <xsl:with-param name="caption" select="$caption" />
            <xsl:with-param name="sortBy" select="Params/sort"/>
            <xsl:with-param name="name" select="$name"/>
            <xsl:with-param name="sortReverse" select="Params/sort_order" />
            <xsl:with-param name="onClick">
                location.href = '<xsl:value-of select="$sortLinkWithType" />'
            </xsl:with-param>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="productHeaderRow">
        <xsl:variable name="sortLink">/bookpub/matcher?c=sale&amp;sale=<xsl:value-of select="Params/sale"/>&amp;<xsl:if test="Params/search_type">search_type=<xsl:value-of select="Params/search_type"/>&amp;</xsl:if><xsl:if test="Params/search">search=<xsl:value-of select="Params/search"/></xsl:if>&amp;trackerPage=<xsl:value-of select="/Root/Params/trackerPage" />&amp;</xsl:variable>
        <tr class="Table-row Table-row-header">
            <xsl:if test="not(normalize-space(Sale/ProductID)) or Sale/ProductID = 0">
                <th class="Table-col Table-col-header">Choose</th>
            </xsl:if>
            <th class="Table-col Table-col-header">
                <xsl:call-template name="matcherFilesSort">
                    <xsl:with-param name="name" select="'author'"/>
                    <xsl:with-param name="caption" select="'Author'" />
                </xsl:call-template>
            </th>
            <th class="Table-col">
                <xsl:call-template name="matcherFilesSort">
                    <xsl:with-param name="name" select="'title'"/>
                    <xsl:with-param name="caption" select="'Title'" />
                </xsl:call-template>
            </th>
            <th class="Table-col">
                <xsl:call-template name="matcherFilesSort">
                    <xsl:with-param name="name" select="'subtitle'"/>
                    <xsl:with-param name="caption" select="'Subtitle'" />
                </xsl:call-template>
            </th>
            <th class="Table-col">
                <xsl:call-template name="matcherFilesSort">
                    <xsl:with-param name="name" select="'format'"/>
                    <xsl:with-param name="caption" select="'Format'" />
                </xsl:call-template>
            </th>
            <th class="Table-col">
                <xsl:call-template name="matcherFilesSort">
                    <xsl:with-param name="name" select="'isbn13'"/>
                    <xsl:with-param name="caption" select="'ISBN13'" />
                </xsl:call-template>
            </th>
            <th class="Table-col">
                <xsl:call-template name="matcherFilesSort">
                    <xsl:with-param name="name" select="'isbn10'"/>
                    <xsl:with-param name="caption" select="'ISBN10'" />
                </xsl:call-template>
            </th>
            <th class="Table-col">
                <xsl:call-template name="matcherFilesSort">
                    <xsl:with-param name="name" select="'list_price'"/>
                    <xsl:with-param name="caption" select="'List Price(s)'" />
                </xsl:call-template>
            </th>
        </tr>
    </xsl:template>

    <xsl:template name="productDataRow">
        <xsl:variable name="alreadyMatched">
            <xsl:choose>
                <xsl:when test="normalize-space(/Root/Sale/ProductID) and /Root/Sale/ProductID != 0">1</xsl:when>
                <xsl:otherwise>0</xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:variable name="typeMatch">
            <xsl:choose>
                <xsl:when test="/Root/User/ClientID = 365">1</xsl:when>
                <xsl:when test="/Root/Sale/ProductType = 'PBOK'">
                    <xsl:choose>
                        <xsl:when test="ProductFormat/BookFormatType/Code = 'AA'">0</xsl:when>
                        <xsl:when test="ProductFormat/BookFormatType/Code = 'AJ'">0</xsl:when>
                        <xsl:when test="ProductFormat/BookFormatType/Code = 'DA'">0</xsl:when>
                        <xsl:when test="ProductFormat/BookFormatType/Code = 'DG'">0</xsl:when>
                        <xsl:when test="ProductFormat/BookFormatType/Code = 'DH'">0</xsl:when>
                        <xsl:when test="ProductFormat/BookFormatType/Code = 'DO'">0</xsl:when>
                        <xsl:when test="ProductFormat/BookFormatType/Code = 'DZ'">0</xsl:when>
                        <xsl:otherwise>1</xsl:otherwise>
                    </xsl:choose>
                </xsl:when>
                <xsl:when test="ProductFormat/BookFormatType/Code = 'AA'">1</xsl:when>
                <xsl:when test="ProductFormat/BookFormatType/Code = 'AJ'">1</xsl:when>
                <xsl:when test="ProductFormat/BookFormatType/Code = 'BZ'">1</xsl:when>
                <xsl:when test="ProductFormat/BookFormatType/Code = 'DA'">1</xsl:when>
                <xsl:when test="ProductFormat/BookFormatType/Code = 'DG'">1</xsl:when>
                <xsl:when test="ProductFormat/BookFormatType/Code = 'DH'">1</xsl:when>
                <xsl:when test="ProductFormat/BookFormatType/Code = 'DO'">1</xsl:when>
                <xsl:when test="ProductFormat/BookFormatType/Code = 'DZ'">1</xsl:when>
                <xsl:when test="ProductFormat/BookFormatType/Code = 'EA'">1</xsl:when>
                <xsl:when test="ProductFormat/BookFormatType/Code = 'EC'">1</xsl:when>
                <xsl:when test="ProductFormat/BookFormatType/Code = 'ED'">1</xsl:when>
                <xsl:when test="ProductFormat/BookFormatType/Code = 'JD'">1</xsl:when>
                <xsl:when test="ProductFormat/BookFormatType/Code = 'AN'">1</xsl:when>
                <xsl:when test="ProductFormat/BookFormatType/Code = 'SA'">1</xsl:when>
                <xsl:otherwise>0</xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <tr class="Table-row Table-row-data">
            <xsl:if test="$typeMatch = 0">
                <xsl:attribute name="class">Table-row Table-row-data Matcher-disabled-row</xsl:attribute>
            </xsl:if>
            <xsl:if test="$alreadyMatched = 0">
                <td class="Table-col Table-col-data">
                    <xsl:call-template name="uiRadio">
                        <xsl:with-param name="name" select="'product'"/>
                        <xsl:with-param name="onClick">
                            enableField('match','submitMatch');
                        </xsl:with-param>
                        <xsl:with-param name="disabled">
                            <xsl:if test="$typeMatch = 0">true</xsl:if>
                        </xsl:with-param>
                        <xsl:with-param name="value" select="ProductID"/>
                    </xsl:call-template>
                </td>
            </xsl:if>
            <td class="Table-col Table-col-data">
                <xsl:for-each select="Authors/Author">
                    <xsl:if test="position() != 1">; </xsl:if>
                    <span>
                        <xsl:if test="(translate(.,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') = translate(substring-before(/Root/Sale/rAuthor,','),'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') or translate(.,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') = translate(/Root/Sale/rAuthor,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') ) and $alreadyMatched = 0">
                            <xsl:attribute name="class">Matcher-exact-match</xsl:attribute>
                        </xsl:if>
                        <xsl:value-of select="." />
                    </span>
                </xsl:for-each>
            </td>
            <td class="Table-col Table-col-data">
                <xsl:if test="translate(Book/Title,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') = translate(/Root/Sale/rTitle,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') and $alreadyMatched = 0">
                    <xsl:attribute name="class">Table-col Matcher-exact-match</xsl:attribute>
                </xsl:if>
                <xsl:value-of select="Book/Title" />
            </td>
            <td class="Table-col Table-col-data">
                <xsl:if test="translate(Book/Subtitle,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') = translate(/Root/Sale/rSubtitle,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') and $alreadyMatched = 0">
                    <xsl:attribute name="class">Table-col Matcher-exact-match</xsl:attribute>
                </xsl:if>
                <xsl:value-of select="Book/Subtitle" />
            </td>
            <xsl:variable name="formatTypeString">
                <xsl:value-of select="ProductFormat/BookFormatType/Description" />
                <xsl:if test="normalize-space(ProductFormat/BookFormatSubtype/Description)">
                    <xsl:text> - </xsl:text><xsl:value-of select="ProductFormat/BookFormatSubtype/Description" />
                </xsl:if>
            </xsl:variable>
            <td class="Table-col Table-col-data">
                <xsl:if test="$formatTypeString = /Root/Sale/FormatTypeString and $alreadyMatched = 0">
                    <xsl:attribute name="class">Table-col Matcher-exact-match</xsl:attribute>
                </xsl:if>
                <xsl:value-of select="$formatTypeString" />
            </td>
            <td class="Table-col Table-col-data">
                <xsl:if test="ISBN13 = /Root/Sale/rISBN13 and $alreadyMatched = 0">
                    <xsl:attribute name="class">Table-col Matcher-exact-match</xsl:attribute>
                </xsl:if>
                <xsl:value-of select="ISBN13" />
            </td>
            <td class="Table-col Table-col-data">
                <xsl:if test="ISBN10 = /Root/Sale/rISBN10 and $alreadyMatched = 0">
                    <xsl:attribute name="class">Table-col Matcher-exact-match</xsl:attribute>
                </xsl:if>
                <xsl:value-of select="ISBN10" />
            </td>
            <td class="Table-col Table-col-data">
                <xsl:for-each select="Pricing/Price">
                    <xsl:sort select="DisplayPrice/@value" data-type="number" order="{$sortOrder}" />
                    <xsl:variable name="priceTypeID" select="PriceTypeID" />
                    <span>
                        <xsl:if test="DisplayPrice = /Root/Sale/ListPrice and $alreadyMatched = 0">
                            <xsl:attribute name="class">Matcher-exact-match</xsl:attribute>
                        </xsl:if>
                        <xsl:value-of select="DisplayPrice" />
                    </span>
                    <xsl:text>&#160;</xsl:text>
                    <span>
                        <xsl:if test="PriceTypeID = /Root/Sale/PriceTypeID and DisplayPrice = /Root/Sale/ListPrice and $alreadyMatched = 0">
                            <xsl:attribute name="class">Matcher-exact-match</xsl:attribute>
                        </xsl:if>
                        <xsl:text>(</xsl:text><xsl:value-of select="/Root/PriceTypes/PriceType[PriceTypeID = $priceTypeID]/Display" /><xsl:text>)</xsl:text>
                    </span>
                    <br />
                </xsl:for-each>
            </td>
        </tr>
    </xsl:template>

    <xsl:template name="navLinks">
        <div class="Matcher-navigation">
            <div class="Matcher-navigation-item Matcher-navigation-prev">

                <xsl:attribute name="class">
                    <xsl:text>Matcher-navigation-item Matcher-navigation-next</xsl:text>
                    <xsl:if test="not(normalize-space(Sale/PreviousUnfixedID)) and not(normalize-space(Sale/PreviousErrorID))">
                        <xsl:text> Matcher-navigation-item-hidden</xsl:text>
                    </xsl:if>
                </xsl:attribute>

                <xsl:call-template name="uiButton">
                    <xsl:with-param name="content" select="'Previous Exception'" />
                    <xsl:with-param name="className" select="'Matcher-navigation-button'" />
                    <xsl:with-param name="disabled">
                        <xsl:if test="normalize-space(Sale/PreviousUnfixedID) = ''">true</xsl:if>
                    </xsl:with-param>
                    <xsl:with-param name="iconLeftType" select="'arrow-left'" />
                    <xsl:with-param name="url">
                        <xsl:text>?sale=</xsl:text>
                        <xsl:value-of select="Sale/PreviousUnfixedID" />
                        <xsl:text>&amp;trackerPage=</xsl:text>
                        <xsl:value-of select="Params/trackerPage" />
                        <xsl:text>&amp;c=sale</xsl:text>
                    </xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="uiButton">
                    <xsl:with-param name="content" select="''" />
                    <xsl:with-param name="className" select="'Matcher-navigation-button Matcher-navigation-button-arrow'" />
                    <xsl:with-param name="disabled">
                        <xsl:if test="normalize-space(Sale/PreviousErrorID) = ''">true</xsl:if>
                    </xsl:with-param>
                    <xsl:with-param name="iconLeftType" select="'arrow-left'" />
                    <xsl:with-param name="url">
                        <xsl:text>?sale=</xsl:text>
                        <xsl:value-of select="Sale/PreviousErrorID" />
                        <xsl:text>&amp;trackerPage=</xsl:text>
                        <xsl:value-of select="Params/trackerPage" />
                        <xsl:text>&amp;c=sale</xsl:text>
                    </xsl:with-param>
                </xsl:call-template>
            </div>
            <div class="Matcher-navigation-item Matcher-navigation-line">
                <form action="/bookpub/matcher" name="lineSearch">
                    <input type="hidden" name="c" value="sale" />
                    <input type="hidden" name="trackerPage" value="{Params/trackerPage}" />
                    <input type="hidden" name="file" value="{File/FileID}" />

                    <div class="Form-group Form-group-horizontal">
                        <div class="Form-item Form-item-horizontal">
                            <label class="Form-label">
                                <span class="Form-label-caption">Go To Line #</span>
                                <div class="Form-input-wrapper">
                                    <input class="Input Form-input Matcher-manage-input" type="text" name="line" size="7" maxlength="10" onFocus="this.select();">
                                        <xsl:attribute name="value">
                                            <xsl:if test="Sale/LineNum"><xsl:value-of select="Sale/LineNum" /></xsl:if>
                                            <xsl:if test="not(Sale/LineNum) and Params/line"><xsl:value-of select="Params/line" /></xsl:if>
                                        </xsl:attribute>
                                    </input>
                                </div>
                            </label>
                        </div>
                        <div class="Form-item">
                            <xsl:call-template name="uiButton">
                                <xsl:with-param name="content" select="'Go'" />
                                <xsl:with-param name="elemType" select="'submit'" />
                            </xsl:call-template>
                        </div>
                    </div>
                </form>
            </div>
            <div class="Matcher-navigation-item Matcher-navigation-next">

                <xsl:attribute name="class">
                    <xsl:text>Matcher-navigation-item Matcher-navigation-next</xsl:text>
                    <xsl:if test="not(normalize-space(Sale/NextErrorID)) and not(normalize-space(Sale/NextUnfixedID))">
                        <xsl:text> Matcher-navigation-item-hidden</xsl:text>
                    </xsl:if>
                </xsl:attribute>

                <xsl:call-template name="uiButton">
                    <xsl:with-param name="content" select="''" />
                    <xsl:with-param name="className" select="'Matcher-navigation-button Matcher-navigation-button-arrow'" />
                    <xsl:with-param name="disabled">
                        <xsl:if test="normalize-space(Sale/NextErrorID) = ''">true</xsl:if>
                    </xsl:with-param>
                    <xsl:with-param name="iconRightType" select="'arrow-right'" />
                    <xsl:with-param name="url">
                        <xsl:text>?sale=</xsl:text>
                        <xsl:value-of select="Sale/NextErrorID" />
                        <xsl:text>&amp;trackerPage=</xsl:text>
                        <xsl:value-of select="Params/trackerPage" />
                        <xsl:text>&amp;c=sale</xsl:text>
                    </xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="uiButton">
                    <xsl:with-param name="content" select="'Next Exception'" />
                    <xsl:with-param name="className" select="'Matcher-navigation-button'" />
                    <xsl:with-param name="disabled">
                        <xsl:if test="normalize-space(Sale/NextUnfixedID) = ''">true</xsl:if>
                    </xsl:with-param>
                    <xsl:with-param name="iconRightType" select="'arrow-right'" />
                    <xsl:with-param name="url">
                        <xsl:text>?sale=</xsl:text>
                        <xsl:value-of select="Sale/NextUnfixedID" />
                        <xsl:text>&amp;trackerPage=</xsl:text>
                        <xsl:value-of select="Params/trackerPage" />
                        <xsl:text>&amp;c=sale</xsl:text>
                    </xsl:with-param>
                </xsl:call-template>
            </div>
        </div>
    </xsl:template>

</xsl:stylesheet>
