<!--                                                                  -->
<!--  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="" />

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

    <xsl:template name="pickLayout">
        <section class="Mapface MainBaseSection">
            <xsl:if test="Form/MapFaceFile/RemainingErrors/@raw = 0">
                <xsl:call-template name="successMessageGeneral">
                    <xsl:with-param name="successMessage">All mapping exceptions resolved for this file!</xsl:with-param>
                </xsl:call-template>
            </xsl:if>
            <xsl:if test="Form/MapFaceFile/Status = 3">
                <p class="successGeneral messageBox" id="successGeneralMessageBox">
                    All mappings have been approved for this file!
                </p>
            </xsl:if>
            <xsl:call-template name="fileInfo" />
            <xsl:call-template name="lineInfo" />
            <xsl:call-template name="mappingForm" />
        </section>
        <script type="text/javascript" src="/production/javascript/rps/mapface.js?v=10" />
        <xsl:call-template name="pagePrepJavascript" />
    </xsl:template>

    <xsl:variable name="saleID" select="/Root/Form/SaleGroup/Sale/SaleID" />
    <xsl:variable name="saleProductType">
        <xsl:choose>
            <xsl:when test="/Root/Form/SaleImportErrorList/SaleImportError[SaleID = $saleID and ErrorType = 3 and Mapped = 'N']"></xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="/Root/Form/SaleGroup/Sale[SaleID = $saleID]/ProductType" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:variable name="status" select="/Root/Form/MapFaceTempMapping/Status" />
    <xsl:variable name="mapService">
        <xsl:if test="/Root/Form/MapFaceTempMapping/ServiceID != 0">
            <xsl:value-of select="/Root/Form/MapFaceTempMapping/ServiceID" />
        </xsl:if>
    </xsl:variable>
    <xsl:variable name="saleService">
        <xsl:choose>
            <xsl:when test="/Root/Form/SaleImportErrorList/SaleImportError[SaleID = $saleID and ErrorType = 1 and Mapped = 'N']"></xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="/Root/Form/SaleGroup/Sale[SaleID = $saleID]/ServiceID" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:variable name="disableService">
        <xsl:choose>
            <xsl:when test="normalize-space($saleService) or (normalize-space($mapService) and $status != 2)">1</xsl:when>
            <xsl:otherwise>0</xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:variable name="mapCountry" select="/Root/Form/MapFaceTempMapping/CountryCode" />
    <xsl:variable name="saleCountry">
        <xsl:choose>
            <xsl:when test="/Root/Form/SaleImportErrorList/SaleImportError[SaleID = $saleID and ErrorType = 2 and Mapped = 'N']"></xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="/Root/Form/SaleGroup/Sale[SaleID = $saleID]/CountryCode" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:variable name="disableCountry">
        <xsl:choose>
            <xsl:when test="normalize-space($saleCountry) or (normalize-space($mapCountry) and $status != 2)">1</xsl:when>
            <xsl:otherwise>0</xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:variable name="disableProductType">
        <xsl:choose>
            <xsl:when test="normalize-space($saleProductType) or (normalize-space($mapProductType) and $status != 2)">1</xsl:when>
            <xsl:otherwise>0</xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:variable name="mapFormatType" select="/Root/Form/MapFaceTempMapping/FormatType" />
    <xsl:variable name="saleFormatType">
        <xsl:choose>
            <xsl:when test="/Root/Form/SaleImportErrorList/SaleImportError[SaleID = $saleID and ErrorType = 4 and Mapped = 'N']"></xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="/Root/Form/SaleGroup/Sale[SaleID = $saleID]/FormatType" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:variable name="disableFormatType">
        <xsl:choose>
            <xsl:when test="normalize-space($saleFormatType) or (normalize-space($mapFormatType) and $status != 2)">1</xsl:when>
            <xsl:when test="$isPhysicalProduct = 1">1</xsl:when>
            <xsl:otherwise>0</xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:variable name="mapMediaType">
        <xsl:if test="/Root/Form/MapFaceTempMapping/MediaType != 0">
            <xsl:value-of select="/Root/Form/MapFaceTempMapping/MediaType" />
        </xsl:if>
    </xsl:variable>
    <xsl:variable name="saleMediaType">
        <xsl:choose>
            <xsl:when test="/Root/Form/SaleImportErrorList/SaleImportError[SaleID = $saleID and ErrorType = 5 and Mapped = 'N']"></xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="/Root/Form/SaleGroup/Sale[SaleID = $saleID]/MediaType" />
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:variable name="disableMediaType">
        <xsl:choose>
            <xsl:when test="normalize-space($saleMediaType) or (normalize-space($mapMediaType) and $status != 2)">1</xsl:when>
            <xsl:when test="$isPhysicalProduct = 1">1</xsl:when>
            <xsl:otherwise>0</xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    <xsl:variable name="allMapped">
        <xsl:choose>
            <xsl:when test="$disableService = 1 and $disableCountry = 1 and $disableProductType = 1 and $disableFormatType = 1 and $disableMediaType = 1">1</xsl:when>
            <xsl:otherwise>0</xsl:otherwise>
        </xsl:choose>
    </xsl:variable>

    <xsl:template name="fileInfo">
        <fieldset id="fileInfoFieldset" class="Form-fieldset">
            <h3>File</h3>
            <xsl:call-template name="navLinks" />
            <table class="Table" id="fileInfo">
                <thead>
                    <tr class="Table-row Table-row-header">
                        <th class="Table-col">Customer</th>
                        <th class="Table-col">Service</th>
                        <th class="Table-col">File Name</th>
                        <th class="Table-col">Received</th>
                        <th class="Table-col"># of Errors</th>
                        <th class="Table-col">Errors Mapped</th>
                        <th class="Table-col">Errors Approved</th>
                        <th class="Table-col">Resolving User</th>
                    </tr>
                </thead>
                <tbody>
                    <tr class="Table-row Table-row-data">
                        <td class="Table-col"><xsl:value-of select="Form/MapFaceFile/ClientName" /></td>
                        <td class="Table-col"><xsl:value-of select="Form/File/ServiceName" /></td>
                        <td class="Table-col"><xsl:value-of select="Form/File/OrigFileName" /></td>
                        <td class="Table-col"><xsl:value-of select="Form/File/DateCreatedPretty" /></td>
                        <td class="Table-col"><xsl:value-of select="Form/MapFaceFile/InitialErrors" /></td>
                        <td class="Table-col"><xsl:value-of select="Form/MapFaceFile/InitialErrors - Form/MapFaceFile/RemainingErrors" /></td>
                        <td class="Table-col"><xsl:value-of select="Form/MapFaceFile/ApprovedMappings" /></td>
                        <td class="Table-col">
                            <xsl:choose>
                                <xsl:when test="normalize-space(Form/MapFaceFile/ResolvingUserName)">
                                    <xsl:value-of select="Form/MapFaceFile/ResolvingUserName" />
                                </xsl:when>
                                <xsl:otherwise>None</xsl:otherwise>
                            </xsl:choose>
                        </td>
                    </tr>
                </tbody>
            </table>
        </fieldset>
    </xsl:template>

    <xsl:template name="navLinks">
        <div class="Pagination-previous-next">
            <div class="Pagination-item">
                <xsl:if test="normalize-space(Form/PrevGroupNum)">
                    <xsl:call-template name="uiButton">
                        <xsl:with-param name="url">
                            <xsl:if test="normalize-space(Form/PrevGroupNum)">?file=<xsl:value-of select="Params/file" />&amp;mappingGroup=<xsl:value-of select="Form/PrevGroupNum" />&amp;c=map</xsl:if>
                        </xsl:with-param>
                        <xsl:with-param name="content" select="'Previous'"/>
                        <xsl:with-param name="type" select="'default'"/>
                        <xsl:with-param name="iconLeftType" select="'arrow-left'"/>
                        <xsl:with-param name="disabled">
                            <xsl:if test="not(normalize-space(Form/PrevGroupNum))">
                                <xsl:text>true</xsl:text>
                            </xsl:if>
                        </xsl:with-param>
                    </xsl:call-template>
                </xsl:if>
            </div>
            <div class="Pagination-title">
                <xsl:value-of select="Form/CurrentPage" /> of <xsl:value-of select="Form/TotalGroupCount" />
            </div>
            <div class="Pagination-item">
                <xsl:if test="normalize-space(Form/NextGroupNum)">
                    <xsl:call-template name="uiButton">
                        <xsl:with-param name="url">
                            <xsl:if test="normalize-space(Form/NextGroupNum)">?file=<xsl:value-of select="Params/file" />&amp;mappingGroup=<xsl:value-of select="Form/NextGroupNum" />&amp;c=map</xsl:if>
                        </xsl:with-param>
                        <xsl:with-param name="content" select="'Next'"/>
                        <xsl:with-param name="type" select="'default'"/>
                        <xsl:with-param name="iconRightType" select="'arrow-right'"/>
                        <xsl:with-param name="disabled">
                            <xsl:if test="not(normalize-space(Form/NextGroupNum))">
                                <xsl:text>true</xsl:text>
                            </xsl:if>
                        </xsl:with-param>
                    </xsl:call-template>
                </xsl:if>
            </div>
        </div>
    </xsl:template>

    <xsl:template name="lineInfo">
        <fieldset id="lineInfoFieldset" class="Form-fieldset">
            <input type="hidden" name="saleCount" id="saleCount" value="{Form/SaleCount}" />
            <h3>Line</h3>
            <table class="Table" id="lineInfo">
                <thead>
                    <tr class="Table-row Table-row-header">
                        <th class="Table-col">Line</th>
                        <th class="Table-col">Artist</th>
                        <th class="Table-col">Album</th>
                        <th class="Table-col">Track</th>
                        <th class="Table-col">ISRC</th>
                        <th class="Table-col">UPC</th>
                        <th class="Table-col">Units</th>
                        <xsl:if test="$isPhysicalProduct != 1"><th class="Table-col">Price</th></xsl:if>
                        <xsl:if test="$isPhysicalProduct = 1"><th class="Table-col">Revenue</th></xsl:if>
                    </tr>
                </thead>
                <tbody>
                    <xsl:for-each select="Form/SaleGroup/Sale">
                        <xsl:call-template name="saleRow" />
                    </xsl:for-each>
                </tbody>
            </table>
            <xsl:if test="Form/SaleCount > 5">
                <div id="showMoreLines" class="showMore">
                    <xsl:call-template name="uiButton">
                        <xsl:with-param name="content" select="'More...'" />
                        <xsl:with-param name="type" select="'default'" />
                        <xsl:with-param name="className" select="'Form-button Show-more-button'" />
                        <xsl:with-param name="url">javascript:showMoreLines(5,<xsl:value-of select="Form/MapFaceTempMapping/MapFaceTempMappingID" />)</xsl:with-param>
                    </xsl:call-template>
                </div>
            </xsl:if>
        </fieldset>
    </xsl:template>

    <xsl:template name="mappingForm">
        <fieldset id="mappingFormFieldset" class="Form-fieldset">
            <h3>Mapping</h3>
            <form name="createMapping" id="createMapping" method="post" action="mapface">
                <input type="hidden" name="formSubmit" value="1" />
                <input type="hidden" name="c" value="map" />
                <input type="hidden" name="file" value="{Params/file}" />
                <input type="hidden" name="mappingGroup" value="{Form/CurrentGroupNum}" />
                <xsl:variable name="serviceStatus">
                    <xsl:choose>
                        <xsl:when test="normalize-space($mapService) and $status = 3">approved</xsl:when>
                        <xsl:when test="normalize-space($mapService) and $status = 1">mapped</xsl:when>
                        <xsl:when test="not(normalize-space($saleService))">hi</xsl:when>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="productTypeStatus">
                    <xsl:choose>
                        <xsl:when test="normalize-space($mapProductType) and $status = 3">approved</xsl:when>
                        <xsl:when test="normalize-space($mapProductType) and $status = 1">mapped</xsl:when>
                        <xsl:when test="not(normalize-space($saleProductType))">hi</xsl:when>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="formatTypeStatus">
                    <xsl:choose>
                        <xsl:when test="(normalize-space($mapFormatType) or (normalize-space($mapProductType) and $isPhysicalProduct = 1)) and $status = 3">approved</xsl:when>
                        <xsl:when test="(normalize-space($mapFormatType) or (normalize-space($mapProductType) and $isPhysicalProduct = 1)) and $status = 1">mapped</xsl:when>
                        <xsl:when test="not(normalize-space($saleFormatType)) and $isPhysicalProduct != 1">hi</xsl:when>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="mediaTypeStatus">
                    <xsl:choose>
                        <xsl:when test="(normalize-space($mapMediaType) or (normalize-space($mapProductType) and $isPhysicalProduct = 1)) and $status = 3">approved</xsl:when>
                        <xsl:when test="(normalize-space($mapMediaType) or (normalize-space($mapProductType) and $isPhysicalProduct = 1)) and $status = 1">mapped</xsl:when>
                        <xsl:when test="not(normalize-space($saleMediaType))">hi</xsl:when>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="countryStatus">
                    <xsl:choose>
                        <xsl:when test="normalize-space($mapCountry) and $status = 3">approved</xsl:when>
                        <xsl:when test="normalize-space($mapCountry) and $status = 1">mapped</xsl:when>
                        <xsl:when test="not(normalize-space($saleCountry))">hi</xsl:when>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="serviceClass">
                    <xsl:choose>
                        <xsl:when test="Form/Mappings/serviceID/serviceID and normalize-space($serviceStatus)">
                            <xsl:value-of select="$serviceStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/countryCode/serviceID and normalize-space($countryStatus)">
                            <xsl:value-of select="$countryStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/productType/serviceID and normalize-space($productTypeStatus)">
                            <xsl:value-of select="$productTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/formatType/serviceID and normalize-space($formatTypeStatus)">
                            <xsl:value-of select="$formatTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/mediaType/serviceID and normalize-space($mediaTypeStatus)">
                            <xsl:value-of select="$mediaTypeStatus" />
                        </xsl:when>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="serviceSingleClass">
                    <xsl:choose>
                        <xsl:when test="Form/Mappings/serviceID/service and normalize-space($serviceStatus)">
                            <xsl:value-of select="$serviceStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/countryCode/service and normalize-space($countryStatus)">
                            <xsl:value-of select="$countryStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/productType/service and normalize-space($productTypeStatus)">
                            <xsl:value-of select="$productTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/formatType/service and normalize-space($formatTypeStatus)">
                            <xsl:value-of select="$formatTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/mediaType/service and normalize-space($mediaTypeStatus)">
                            <xsl:value-of select="$mediaTypeStatus" />
                        </xsl:when>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="retailerClass">
                    <xsl:choose>
                        <xsl:when test="Form/Mappings/serviceID/retailer and normalize-space($serviceStatus)">
                            <xsl:value-of select="$serviceStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/countryCode/retailer and normalize-space($countryStatus)">
                            <xsl:value-of select="$countryStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/productType/retailer and normalize-space($productTypeStatus)">
                            <xsl:value-of select="$productTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/formatType/retailer and normalize-space($formatTypeStatus)">
                            <xsl:value-of select="$formatTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/mediaType/retailer and normalize-space($mediaTypeStatus)">
                            <xsl:value-of select="$mediaTypeStatus" />
                        </xsl:when>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="countryClass">
                    <xsl:choose>
                        <xsl:when test="Form/Mappings/serviceID/countryCode and normalize-space($serviceStatus)">
                            <xsl:value-of select="$serviceStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/countryCode/countryCode and normalize-space($countryStatus)">
                            <xsl:value-of select="$countryStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/productType/countryCode and normalize-space($productTypeStatus)">
                            <xsl:value-of select="$productTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/formatType/countryCode and normalize-space($formatTypeStatus)">
                            <xsl:value-of select="$formatTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/mediaType/countryCode and normalize-space($mediaTypeStatus)">
                            <xsl:value-of select="$mediaTypeStatus" />
                        </xsl:when>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="productTypeClass">
                    <xsl:choose>
                        <xsl:when test="Form/Mappings/serviceID/productType and normalize-space($serviceStatus)">
                            <xsl:value-of select="$serviceStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/countryCode/productType and normalize-space($countryStatus)">
                            <xsl:value-of select="$countryStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/productType/productType and normalize-space($productTypeStatus)">
                            <xsl:value-of select="$productTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/formatType/productType and normalize-space($formatTypeStatus)">
                            <xsl:value-of select="$formatTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/mediaType/productType and normalize-space($mediaTypeStatus)">
                            <xsl:value-of select="$mediaTypeStatus" />
                        </xsl:when>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="formatTypeClass">
                    <xsl:choose>
                        <xsl:when test="Form/Mappings/serviceID/formatType and normalize-space($serviceStatus)">
                            <xsl:value-of select="$serviceStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/countryCode/formatType and normalize-space($countryStatus)">
                            <xsl:value-of select="$countryStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/productType/formatType and normalize-space($productTypeStatus)">
                            <xsl:value-of select="$productTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/formatType/formatType and normalize-space($formatTypeStatus)">
                            <xsl:value-of select="$formatTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/mediaType/formatType and normalize-space($mediaTypeStatus)">
                            <xsl:value-of select="$mediaTypeStatus" />
                        </xsl:when>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="mediaTypeClass">
                    <xsl:choose>
                        <xsl:when test="Form/Mappings/serviceID/mediaType and normalize-space($serviceStatus)">
                            <xsl:value-of select="$serviceStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/countryCode/mediaType and normalize-space($countryStatus)">
                            <xsl:value-of select="$countryStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/productType/mediaType and normalize-space($productTypeStatus)">
                            <xsl:value-of select="$productTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/formatType/mediaType and normalize-space($formatTypeStatus)">
                            <xsl:value-of select="$formatTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/mediaType/mediaType and normalize-space($mediaTypeStatus)">
                            <xsl:value-of select="$mediaTypeStatus" />
                        </xsl:when>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="salesTypeClass">
                    <xsl:choose>
                        <xsl:when test="Form/Mappings/serviceID/salesType and normalize-space($serviceStatus)">
                            <xsl:value-of select="$serviceStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/countryCode/salesType and normalize-space($countryStatus)">
                            <xsl:value-of select="$countryStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/productType/salesType and normalize-space($productTypeStatus)">
                            <xsl:value-of select="$productTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/formatType/salesType and normalize-space($formatTypeStatus)">
                            <xsl:value-of select="$formatTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/mediaType/salesType and normalize-space($mediaTypeStatus)">
                            <xsl:value-of select="$mediaTypeStatus" />
                        </xsl:when>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="typeClass">
                    <xsl:choose>
                        <xsl:when test="Form/Mappings/serviceID/type and normalize-space($serviceStatus)">
                            <xsl:value-of select="$serviceStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/countryCode/type and normalize-space($countryStatus)">
                            <xsl:value-of select="$countryStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/productType/type and normalize-space($productTypeStatus)">
                            <xsl:value-of select="$productTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/formatType/type and normalize-space($formatTypeStatus)">
                            <xsl:value-of select="$formatTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/mediaType/type and normalize-space($mediaTypeStatus)">
                            <xsl:value-of select="$mediaTypeStatus" />
                        </xsl:when>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="assetTypeClass">
                    <xsl:choose>
                        <xsl:when test="Form/Mappings/serviceID/assetType and normalize-space($serviceStatus)">
                            <xsl:value-of select="$serviceStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/countryCode/assetType and normalize-space($countryStatus)">
                            <xsl:value-of select="$countryStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/productType/assetType and normalize-space($productTypeStatus)">
                            <xsl:value-of select="$productTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/formatType/assetType and normalize-space($formatTypeStatus)">
                            <xsl:value-of select="$formatTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/mediaType/assetType and normalize-space($mediaTypeStatus)">
                            <xsl:value-of select="$mediaTypeStatus" />
                        </xsl:when>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="mediaCodeClass">
                    <xsl:choose>
                        <xsl:when test="Form/Mappings/serviceID/mediaCode and normalize-space($serviceStatus)">
                            <xsl:value-of select="$serviceStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/countryCode/mediaCode and normalize-space($countryStatus)">
                            <xsl:value-of select="$countryStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/productType/mediaCode and normalize-space($productTypeStatus)">
                            <xsl:value-of select="$productTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/formatType/mediaCode and normalize-space($formatTypeStatus)">
                            <xsl:value-of select="$formatTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/mediaType/mediaCode and normalize-space($mediaTypeStatus)">
                            <xsl:value-of select="$mediaTypeStatus" />
                        </xsl:when>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="deliveryTypeClass">
                    <xsl:choose>
                        <xsl:when test="Form/Mappings/serviceID/deliveryType and normalize-space($serviceStatus)">
                            <xsl:value-of select="$serviceStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/countryCode/deliveryType and normalize-space($countryStatus)">
                            <xsl:value-of select="$countryStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/productType/deliveryType and normalize-space($productTypeStatus)">
                            <xsl:value-of select="$productTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/formatType/deliveryType and normalize-space($formatTypeStatus)">
                            <xsl:value-of select="$formatTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/mediaType/deliveryType and normalize-space($mediaTypeStatus)">
                            <xsl:value-of select="$mediaTypeStatus" />
                        </xsl:when>
                    </xsl:choose>
                </xsl:variable>
                <xsl:variable name="deliveryFormatClass">
                    <xsl:choose>
                        <xsl:when test="Form/Mappings/serviceID/deliveryFormat and normalize-space($serviceStatus)">
                            <xsl:value-of select="$serviceStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/countryCode/deliveryFormat and normalize-space($countryStatus)">
                            <xsl:value-of select="$countryStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/productType/deliveryFormat and normalize-space($productTypeStatus)">
                            <xsl:value-of select="$productTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/formatType/deliveryFormat and normalize-space($formatTypeStatus)">
                            <xsl:value-of select="$formatTypeStatus" />
                        </xsl:when>
                        <xsl:when test="Form/Mappings/mediaType/deliveryFormat and normalize-space($mediaTypeStatus)">
                            <xsl:value-of select="$mediaTypeStatus" />
                        </xsl:when>
                    </xsl:choose>
                </xsl:variable>
                <table class="Table Mapface-mappingtable" id="mapping">
                    <thead>
                        <tr class="Table-row Table-row-header">
                            <xsl:if test="Form/MappingCriteria/serviceID">
                                <th id="serviceHeader" class="Table-col {$serviceClass}">
                                    <xsl:value-of select="Form/FileHeaders/serviceID" />
                                </th>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/service">
                                <th id="serviceSingleHeader" class="Table-col {$serviceSingleClass}">
                                    <xsl:value-of select="Form/FileHeaders/service" />
                                </th>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/retailer">
                                <th id="retailerHeader" class="Table-col {$retailerClass}">
                                    <xsl:value-of select="Form/FileHeaders/retailer" />
                                </th>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/productType">
                                <th id="productTypeHeader" class="Table-col {$productTypeClass}">
                                    <xsl:value-of select="Form/FileHeaders/productType" />
                                </th>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/formatType">
                                <th id="formatTypeHeader" class="Table-col {$formatTypeClass}">
                                    <xsl:value-of select="Form/FileHeaders/formatType" />
                                </th>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/mediaType">
                                <th id="mediaTypeHeader" class="Table-col {$mediaTypeClass}">
                                    <xsl:value-of select="Form/FileHeaders/mediaType" />
                                </th>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/assetType">
                                <th id="assetTypeHeader" class="Table-col {$assetTypeClass}">
                                    <xsl:value-of select="Form/FileHeaders/assetType" />
                                </th>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/salesType">
                                <th id="salesTypeHeader" class="Table-col {$salesTypeClass}">
                                    <xsl:value-of select="Form/FileHeaders/salesType" />
                                </th>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/type">
                                <th id="typeHeader" class="Table-col {$typeClass}">
                                    <xsl:value-of select="Form/FileHeaders/type" />
                                </th>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/mediaCode">
                                <th id="mediaCodeHeader" class="Table-col {$mediaCodeClass}">
                                    <xsl:value-of select="Form/FileHeaders/mediaCode" />
                                </th>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/deliveryType">
                                <th id="deliveryTypeHeader" class="Table-col {$deliveryTypeClass}">
                                    <xsl:value-of select="Form/FileHeaders/deliveryType" />
                                </th>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/deliveryFormat">
                                <th id="deliveryFormatHeader" class="Table-col {$deliveryFormatClass}">
                                    <xsl:value-of select="Form/FileHeaders/deliveryFormat" />
                                </th>
                            </xsl:if>
                            <!-- RSD-12247 Start -->
                            <xsl:if test="Form/MappingCriteria/_network">
                                <th id="formatTypeHeader" class="Table-col {$formatTypeClass}">
                                    <xsl:value-of select="Form/FileHeaders/_network" />
                                </th>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/_eventType">
                                <th id="formatTypeHeader" class="Table-col {$formatTypeClass}">
                                    <xsl:value-of select="Form/FileHeaders/_eventType" />
                                </th>
                            </xsl:if>

                            <xsl:if test="Form/MappingCriteria/_mediaType">
                                <th id="mediaTypeHeader" class="Table-col {$mediaTypeClass}">
                                    <xsl:value-of select="Form/FileHeaders/_mediaType" />
                                </th>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/_assetType">
                                <th id="mediaTypeHeader" class="Table-col {$mediaTypeClass}">
                                    <xsl:value-of select="Form/FileHeaders/_assetType" />
                                </th>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/_group">
                                <th id="mediaTypeHeader" class="Table-col {$mediaTypeClass}">
                                    <xsl:value-of select="Form/FileHeaders/_group" />
                                </th>
                            </xsl:if>
                             <!-- RSD-12247 End-->
                            <xsl:if test="Form/MappingCriteria/countryCode">
                                <th id="countryHeader" class="Table-col {$countryClass}">
                                    <xsl:value-of select="Form/FileHeaders/countryCode" />
                                </th>
                            </xsl:if>
                        </tr>
                    </thead>
                    <tbody>
                        <tr class="Table-row Table-row-data">
                            <xsl:if test="Form/MappingCriteria/serviceID">
                                <td id="serviceRow" class="Table-col {$serviceClass}">
                                    <xsl:value-of select="Form/MappingCriteria/serviceID" />
                                </td>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/service">
                                <td id="serviceSingleRow" class="Table-col {$serviceClass}">
                                    <xsl:value-of select="Form/MappingCriteria/service" />
                                </td>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/retailer">
                                <td id="retailerRow" class="Table-col {$serviceClass}">
                                    <xsl:value-of select="Form/MappingCriteria/retailer" />
                                </td>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/productType">
                                <td id="productTypeRow" class="Table-col {$productTypeClass}">
                                    <xsl:value-of select="Form/MappingCriteria/productType" />
                                </td>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/formatType">
                                <td id="formatTypeRow" class="Table-col {$formatTypeClass}">
                                    <xsl:value-of select="Form/MappingCriteria/formatType" />
                                </td>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/mediaType">
                                <td id="mediaTypeRow" class="Table-col {$mediaTypeClass}">
                                    <xsl:value-of select="Form/MappingCriteria/mediaType" />
                                </td>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/assetType">
                                <td id="assetTypeRow" class="Table-col {$assetTypeClass}">
                                    <xsl:value-of select="Form/MappingCriteria/assetType" />
                                </td>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/salesType">
                                <td id="salesTypeRow" class="Table-col {$salesTypeClass}">
                                    <xsl:value-of select="Form/MappingCriteria/salesType" />
                                </td>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/type">
                                <td id="typeRow" class="Table-col {$typeClass}">
                                    <xsl:value-of select="Form/MappingCriteria/type" />
                                </td>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/mediaCode">
                                <td id="mediaCodeRow" class="Table-col {$mediaCodeClass}">
                                    <xsl:value-of select="Form/MappingCriteria/mediaCode" />
                                </td>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/deliveryType">
                                <td id="deliveryTypeRow" class="Table-col {$deliveryTypeClass}">
                                    <xsl:value-of select="Form/MappingCriteria/deliveryType" />
                                </td>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/deliveryFormat">
                                <td id="deliveryFormatRow" class="Table-col {$deliveryFormatClass}">
                                    <xsl:value-of select="Form/MappingCriteria/deliveryFormat" />
                                </td>
                            </xsl:if>
                            <!-- RSD-12247 Start -->
                            <xsl:if test="Form/MappingCriteria/_network">
                                <td id="formatTypeRow" class="Table-col {$formatTypeClass}">
                                    <xsl:value-of select="Form/MappingCriteria/_network" />
                                </td>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/_eventType">
                                <td id="formatTypeRow" class="Table-col {$formatTypeClass}">
                                    <xsl:value-of select="Form/MappingCriteria/_eventType" />
                                </td>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/_mediaType">
                                <td id="mediaTypeRow" class="Table-col {$mediaTypeClass}">
                                    <xsl:value-of select="Form/MappingCriteria/_mediaType" />
                                </td>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/_assetType">
                                <td id="mediaTypeRow" class="Table-col {$mediaTypeClass}">
                                    <xsl:value-of select="Form/MappingCriteria/_assetType" />
                                </td>
                            </xsl:if>
                            <xsl:if test="Form/MappingCriteria/_group">
                                <td id="mediaTypeRow" class="Table-col {$mediaTypeClass}">
                                    <xsl:value-of select="Form/MappingCriteria/_group" />
                                </td>
                            </xsl:if>
                            <!-- RSD-12247 End -->
                            <xsl:if test="Form/MappingCriteria/countryCode">
                                <td id="countryRow" class="Table-col {$countryClass}">
                                    <xsl:value-of select="Form/MappingCriteria/countryCode" />
                                </td>
                            </xsl:if>
                        </tr>
                    </tbody>
                </table>
                <table class="Table Mapface-newvalues" id="newValues">
                    <thead>
                        <tr class="Table-row Table-row-header">
                            <th class="Table-col Mapface-rsvalue"></th>
                            <th class="Table-col {$serviceStatus}">Service</th>
                            <th class="Table-col {$productTypeStatus}">Product Type</th>
                            <xsl:if test="$isPhysicalProduct != 1">
                                <th class="Table-col {$formatTypeStatus}">Format Type</th>
                            </xsl:if>
                            <th class="Table-col {$mediaTypeStatus}">Media Type</th>
                            <th class="Table-col Mapface-countrycode {$countryStatus}">Country</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr class="Table-row Table-row-data">
                            <td class="Table-col Mapface-rsvalue">RS Values</td>
                            <td class="Table-col {$serviceStatus}">
                                <xsl:variable name="selectedServiceID">
                                    <xsl:choose>
                                        <xsl:when test="normalize-space($saleService)">
                                            <xsl:value-of select="$saleService" />
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:value-of select="$mapService" />
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </xsl:variable>
                                <xsl:variable name="selectedServiceName">
                                    <xsl:choose>
                                        <xsl:when test="normalize-space(Form/ServiceList/Service[ServiceID = $selectedServiceID]/ServiceName)">
                                            <xsl:value-of select="Form/ServiceList/Service[ServiceID = $selectedServiceID]/ServiceName" />
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:value-of select="Form/MapFaceTempMapping/ServiceName" />
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </xsl:variable>
                                <div id="myAutoComplete" class="Mapface-autocomplete  yui-ac">
                                    <input id="Form_MapFaceTempMapping_ServiceName" name="Form_MapFaceTempMapping_ServiceName" type="text" class="Input Form-input serviceNameField" value="{$selectedServiceName}" >
                                        <xsl:if test="$disableService = 1">
                                            <xsl:attribute name="disabled">disabled</xsl:attribute>
                                        </xsl:if>
                                    </input>
                                    <span id="noMatchWarning" class="yui-ac-warning"></span>
                                    <xsl:if test="not(normalize-space($saleService))">
                                        <input type="hidden" name="Form_MapFaceTempMapping_ServiceID" id="Form_MapFaceTempMapping_ServiceID" value="{$selectedServiceID}" />
                                        <script src="/production/javascript/autocomplete/service.js?v=4" type="text/javascript"></script>
                                    </xsl:if>
                                </div>
                            </td>
                            <td class="Table-col {$productTypeStatus}">
                                <xsl:variable name="selectedProductType">
                                    <xsl:choose>
                                        <xsl:when test="normalize-space($saleProductType)">
                                            <xsl:value-of select="$saleProductType" />
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:value-of select="$mapProductType" />
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </xsl:variable>
                                <label class="Form-label">
                                    <xsl:variable name="selectProductTypeList">
                                        <map>
                                            <mapEntry><name>Select...</name><value></value></mapEntry>
                                            <mapEntry><name>Album</name><value>A</value></mapEntry>
                                            <mapEntry><name>Track</name><value>T</value></mapEntry>
                                            <xsl:if test="$disableProductType = 1 and $isPhysicalProduct = 1">
                                                <mapEntry><name>Blu-ray Disc</name><value>U</value></mapEntry>
                                                <mapEntry><name>Cassette</name><value>4</value></mapEntry>
                                                <mapEntry><name>Cassette Single</name><value>K</value></mapEntry>
                                                <mapEntry><name>CD</name><value>2</value></mapEntry>
                                                <mapEntry><name>Double CD</name><value>B</value></mapEntry>
                                                <mapEntry><name>CD Single</name><value>C</value></mapEntry>
                                                <mapEntry><name>DVD</name><value>9</value></mapEntry>
                                                <mapEntry><name>DVD/CD Set</name><value>D</value></mapEntry>
                                                <mapEntry><name>EP</name><value>7</value></mapEntry>
                                                <mapEntry><name>LP</name><value>1</value></mapEntry>
                                                <mapEntry><name>LP5</name><value>P</value></mapEntry>
                                                <mapEntry><name>VHS</name><value>3</value></mapEntry>
                                            </xsl:if>
                                        </map>
                                    </xsl:variable>
                                    <xsl:call-template name="uiDropdown">
                                        <xsl:with-param name="className" select="'Mapface-productType'"/>
                                        <xsl:with-param name="items" select="$selectProductTypeList"/>
                                        <xsl:with-param name="id" select="'Form_MapFaceTempMapping_ProductType'"/>
                                        <xsl:with-param name="name" select="'Form_MapFaceTempMapping_ProductType'"/>
                                        <xsl:with-param name="active" select="$selectedProductType"/>
                                        <xsl:with-param name="disabled"><xsl:if test="$disableProductType = 1">true</xsl:if></xsl:with-param>
                                        <xsl:with-param name="onChange">checkProductType()</xsl:with-param>
                                    </xsl:call-template>
                                </label>
                            </td>
                            <xsl:if test="$isPhysicalProduct != 1">
                                <td class="Table-col {$formatTypeStatus}">
                                    <input type="hidden" name="formatTypeMapped" id="formatTypeMapped" value="0">
                                        <xsl:if test="normalize-space($saleFormatType)">
                                            <xsl:attribute name="value">1</xsl:attribute>
                                        </xsl:if>
                                    </input>
                                    <xsl:variable name="selectedFormatType">
                                        <xsl:choose>
                                            <xsl:when test="normalize-space($saleFormatType)">
                                                <xsl:value-of select="$saleFormatType" />
                                            </xsl:when>
                                            <xsl:otherwise>
                                                <xsl:value-of select="$mapFormatType" />
                                            </xsl:otherwise>
                                        </xsl:choose>
                                    </xsl:variable>
                                    <label class="Form-label">
                                        <!-- See RPS/File/Sale.pm for format codes -->
                                        <xsl:variable name="selectFormatTypeList">
                                            <map>
                                                <mapEntry><name>Select...</name><value></value></mapEntry>
                                                <mapEntry><name>Download</name><value>D</value></mapEntry>
                                                <mapEntry><name>Premium download</name><value>H</value></mapEntry>
                                                <mapEntry><name>Upgrade download</name><value>I</value></mapEntry>
                                                <mapEntry><name>Dual download</name><value>E</value></mapEntry>
                                                <mapEntry><name>Tethered download</name><value>T</value></mapEntry>
                                                <mapEntry><name>Variable price download</name><value>P</value></mapEntry>
                                                <mapEntry><name>Ringtone</name><value>R</value></mapEntry>
                                                <mapEntry><name>Stream</name><value>S</value></mapEntry>
                                                <mapEntry><name>Background music</name><value>B</value></mapEntry>
                                                <mapEntry><name>Jukebox</name><value>J</value></mapEntry>
                                                <mapEntry><name>Performance Income</name><value>O</value></mapEntry>
                                                <mapEntry><name>Ephemeral</name><value>L</value></mapEntry>
                                                <mapEntry><name>Non-Ephemeral</name><value>N</value></mapEntry>
                                            </map>
                                        </xsl:variable>
                                        <xsl:call-template name="uiDropdown">
                                            <xsl:with-param name="items" select="$selectFormatTypeList"/>
                                            <xsl:with-param name="id" select="'Form_MapFaceTempMapping_FormatType'"/>
                                            <xsl:with-param name="name" select="'Form_MapFaceTempMapping_FormatType'"/>
                                            <xsl:with-param name="active" select="$selectedFormatType"/>
                                            <xsl:with-param name="disabled"><xsl:if test="$disableFormatType = 1">true</xsl:if></xsl:with-param>
                                            <xsl:with-param name="className" select="'Mapface-formatType'"/>
                                        </xsl:call-template>
                                    </label>
                                </td>
                            </xsl:if>
                            <td class="Table-col {$mediaTypeStatus}">
                                <input type="hidden" name="mediaTypeMapped" id="mediaTypeMapped" value="0">
                                    <xsl:if test="normalize-space($saleMediaType)">
                                        <xsl:attribute name="value">1</xsl:attribute>
                                    </xsl:if>
                                </input>
                                <xsl:variable name="selectedMediaType">
                                    <xsl:choose>
                                        <xsl:when test="normalize-space($saleMediaType)">
                                            <xsl:value-of select="$saleMediaType" />
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:value-of select="$mapMediaType" />
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </xsl:variable>
                                <label class="Form-label">
                                    <xsl:variable name="selectMediaTypeList">
                                        <map>
                                            <mapEntry><name>Select...</name><value></value></mapEntry>
                                            <mapEntry><name>Audio</name><value>1</value></mapEntry>
                                            <mapEntry><name>Video</name><value>2</value></mapEntry>
                                        </map>
                                    </xsl:variable>
                                    <xsl:call-template name="uiDropdown">
                                        <xsl:with-param name="items" select="$selectMediaTypeList"/>
                                        <xsl:with-param name="id" select="'Form_MapFaceTempMapping_MediaType'"/>
                                        <xsl:with-param name="name" select="'Form_MapFaceTempMapping_MediaType'"/>
                                        <xsl:with-param name="active" select="$selectedMediaType"/>
                                        <xsl:with-param name="disabled"><xsl:if test="$disableMediaType = 1">true</xsl:if></xsl:with-param>
                                        <xsl:with-param name="className" select="'Mapface-mediaType'"/>
                                    </xsl:call-template>
                                </label>
                            </td>
                            <td class="Table-col Mapface-countrycode {$countryStatus}">
                                <xsl:variable name="selectedCountry">
                                    <xsl:choose>
                                        <xsl:when test="normalize-space($saleCountry)">
                                            <xsl:value-of select="$saleCountry" />
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:value-of select="$mapCountry" />
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </xsl:variable>
                                <label class="Form-label">
                                    <xsl:variable name="selectCountryCodeList">
                                        <map>
                                            <mapEntry><name>Select...</name><value></value></mapEntry>
                                            <xsl:for-each select="Form/CountryList/Country">
                                                <mapEntry>
                                                    <name><xsl:value-of select="CountryCode" /> - <xsl:value-of select="Name" /></name>
                                                    <value><xsl:value-of select="CountryCode" /></value>
                                                </mapEntry>
                                            </xsl:for-each>
                                        </map>
                                    </xsl:variable>
                                    <xsl:call-template name="uiDropdown">
                                        <xsl:with-param name="items" select="$selectCountryCodeList"/>
                                        <xsl:with-param name="id" select="'Form_MapFaceTempMapping_CountryCode'"/>
                                        <xsl:with-param name="name" select="'Form_MapFaceTempMapping_CountryCode'"/>
                                        <xsl:with-param name="active" select="$selectedCountry"/>
                                        <xsl:with-param name="disabled"><xsl:if test="$disableCountry= 1">true</xsl:if></xsl:with-param>
                                        <xsl:with-param name="className" select="'Mapface-countryCode'"/>
                                    </xsl:call-template>
                                </label>
                            </td>
                        </tr>
                        <tr class="Table-row Table-row-data">
                            <td class="Table-col"></td>
                            <td class="Table-col">
                                <xsl:call-template name="inlineError">
                                    <xsl:with-param name="path">Form/MapFaceTempMapping/ServiceName</xsl:with-param>
                                    <xsl:with-param name="displayName">Service</xsl:with-param>
                                </xsl:call-template>
                            </td>
                            <td class="Table-col">
                                <xsl:call-template name="inlineError">
                                    <xsl:with-param name="path">Form/MapFaceTempMapping/ProductType</xsl:with-param>
                                    <xsl:with-param name="displayName">Product Type</xsl:with-param>
                                </xsl:call-template>
                            </td>
                            <xsl:if test="$isPhysicalProduct != 1">
                                <td class="Table-col">
                                    <xsl:call-template name="inlineError">
                                        <xsl:with-param name="path">Form/MapFaceTempMapping/FormatType</xsl:with-param>
                                        <xsl:with-param name="displayName">Format Type</xsl:with-param>
                                    </xsl:call-template>
                                </td>
                            </xsl:if>
                            <td class="Table-col">
                                <xsl:call-template name="inlineError">
                                    <xsl:with-param name="path">Form/MapFaceTempMapping/MediaType</xsl:with-param>
                                    <xsl:with-param name="displayName">Media Type</xsl:with-param>
                                </xsl:call-template>
                            </td>
                            <td class="Table-col">
                                <xsl:call-template name="inlineError">
                                    <xsl:with-param name="path">Form/MapFaceTempMapping/CountryCode</xsl:with-param>
                                    <xsl:with-param name="displayName">Country</xsl:with-param>
                                </xsl:call-template>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <div id="approveSection" class="Mapface-approve">
                    <xsl:if test="$allMapped = 1">
                        <xsl:choose>
                            <xsl:when test="$status = 3 or $status = 4">
                                <xsl:attribute name="id">approvedSection</xsl:attribute>
                                Approved
                                <xsl:call-template name="icon">
                                    <xsl:with-param name="type" select="'complete'" />
                                </xsl:call-template>
                            </xsl:when>
                            <xsl:when test="Form/MapFaceTempMapping/ResolvingUserID = User/UserID">
                                Not Approved
                            </xsl:when>
                            <xsl:otherwise>
                                <a href="/rps/mapface?c=approve&amp;mapID={Form/MapFaceTempMapping/MapFaceTempMappingID}">
                                    <xsl:if test="Form/MapFaceFile/InitialErrors/@raw - Form/MapFaceFile/ApprovedMappings/@raw = 1">
                                        <xsl:attribute name="href">javascript:confirmFinalApproval(<xsl:value-of select="Form/MapFaceTempMapping/MapFaceTempMappingID" />)</xsl:attribute>
                                    </xsl:if>
                                    Approve
                                </a>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:if>
                </div>
                <xsl:if test="Form/MapFaceTempMapping/MapFaceTempMappingHistoryList/MapFaceTempMappingHistory">
                    <div id="mappingHistory">
                        <table id="history">
                            <xsl:for-each select="Form/MapFaceTempMapping/MapFaceTempMappingHistoryList/MapFaceTempMappingHistory">
                                <xsl:variable name="action">
                                    <xsl:if test="Action = 'appr'">Approved</xsl:if>
                                    <xsl:if test="Action = 'auto'">Auto-Approved</xsl:if>
                                    <xsl:if test="Action = 'mapd'">Mapped</xsl:if>
                                    <xsl:if test="Action = 'undo'">Undone</xsl:if>
                                </xsl:variable>
                                <tr>
                                    <td>
                                        <xsl:value-of select="$action" /> by <xsl:value-of select="UserName" /><xsl:if test="not(UserName)">None</xsl:if> at <xsl:value-of select="Date" />
                                    </td>
                                </tr>
                            </xsl:for-each>
                        </table>
                        <div id="showMoreHistory"><a href="javascript:showMoreHistory()">More...</a></div>
                    </div>
                </xsl:if>
                <xsl:call-template name="buttons" />
            </form>
        </fieldset>
    </xsl:template>

    <xsl:template name="submitButton">
        <xsl:call-template name="uiButton">
            <xsl:with-param name="content" select="'Undo'" />
            <xsl:with-param name="type" select="'default'" />
            <xsl:with-param name="id" select="'undoButton'" />
            <xsl:with-param name="className" select="'Form-button'" />
            <xsl:with-param name="onClick">location.href='/rps/mapface?c=undo&amp;mapID=<xsl:value-of select="Form/MapFaceTempMapping/MapFaceTempMappingID" />'</xsl:with-param>
        </xsl:call-template>
        <xsl:call-template name="uiButton">
            <xsl:with-param name="content" select="'Confirm Mapping'" />
            <xsl:with-param name="type" select="'primary'" />
            <xsl:with-param name="id" select="'submitButton'" />
            <xsl:with-param name="elemType" select="'submit'" />
            <xsl:with-param name="className" select="'Form-button'" />
            <xsl:with-param name="onClick">
                <xsl:if test="Form/MapFaceFile/ResolvingUserID != 0 and Form/MapFaceFile/ResolvingUserID != User/UserID">confirmNewResolvingUser(); return false;</xsl:if>
            </xsl:with-param>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="cancelButton">
        <xsl:call-template name="uiButton">
            <xsl:with-param name="content" select="'Back to Summary'" />
            <xsl:with-param name="type" select="'default'" />
            <xsl:with-param name="name" select="'Back'" />
            <xsl:with-param name="className" select="'Form-button'" />
            <xsl:with-param name="onClick">location.href='/rps/mapface'</xsl:with-param>
        </xsl:call-template>

    </xsl:template>

    <xsl:template name="pagePrepJavascript">
        <script type="text/javascript">
            <xsl:choose>
                <xsl:when test="$allMapped = 1">
                    confirmButton.hide();
                </xsl:when>
                <xsl:otherwise>
                    undoButton.hide();
                </xsl:otherwise>
            </xsl:choose>
            requireField("Form_MapFaceTempMapping_ProductType","Product Type must be selected.<br />");
            <xsl:if test="$isPhysicalProduct != 1">
                requireField("Form_MapFaceTempMapping_FormatType","Format Type must be selected.<br />");
            </xsl:if>
            requireField("Form_MapFaceTempMapping_MediaType","Media Type must be selected.<br />");
            requireField("Form_MapFaceTempMapping_CountryCode","Country must be selected.<br />");
            validationSet["Form_MapFaceTempMapping_ServiceName"] = {
                'banned': 'SoundExchange',
                'error': 'Service cannot be mapped to SoundExchange.<br />',
                'errorBlank': 'Service must be entered.<br />'
            };
        </script>
    </xsl:template>

</xsl:stylesheet>
