<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--  $Id$  -->
<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:template name="contractMainLayout">
        <div id="distributorContractMain">
            <div class="twoSections">
                <xsl:call-template name="addSection" />
                <xsl:call-template name="viewSection" />
            </div>
            <xsl:call-template name="searchSection" />
            <xsl:call-template name="recentList" />
        </div>
    </xsl:template>

    <xsl:template name="addSection">
        <div class="sectionLeft landingAdd">
            <div class="landingWrapper">
                <h2>Add Contract</h2>
                <a href="/rps/distributor_contract?c=edit" title="Add New Distributor Contract"><img src="/production/images/icons/office/Add-(16x16).gif" height="16" width="16" /></a> <a href="/rps/distributor_contract?c=edit">Add New Distributor Contract</a>
            </div>
        </div>
    </xsl:template>

    <xsl:template name="viewSection">
        <div class="sectionRight landingView">
            <div class="landingWrapper">
                <h2>View Contracts</h2>
                <table>
                    <tr>
                        <td>
                            <form action="/rps/distributor_contract" method="get">
                                <input type="hidden" name="c" value="list" />

                                <xsl:choose>
                                    <xsl:when test="count(PayorList/Payor) &gt; 1">
                                        <label for="payorView">Distributor Contracts: </label>
                                        <select name="payor" id="payorView">
                                            <option value="">All Payors</option>
                                            <xsl:for-each select="PayorList/Payor">
                                                <option value="{PayorID}"><xsl:value-of select="substring(Name,1,25)" /><xsl:if test="substring(Name,26,1)">...</xsl:if></option>
                                            </xsl:for-each>
                                        </select>
                                        <input type="submit" name="go" value="Go" />
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <a href="/rps/distributor_contract?c=list">Distributor Contracts</a>
                                    </xsl:otherwise>
                                </xsl:choose>

                                <br />
                                <span class="subtle">View all distributor contracts<xsl:if test="count(PayorList/Payor) &gt; 1"> or contracts for a specific payor</xsl:if>.</span>
                            </form>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </xsl:template>

    <xsl:template name="searchSection">
        <div class="section landingSearch">
            <table>
                <tr>
                    <td>
                        <form action="/rps/distributor_contract" method="get">
                            <input type="hidden" name="c" value="search" />
                            <label for="contractSearch">Search Distributor Contracts: </label><input type="text" name="Query" id="contractSearch" class="searchField" />
                            <input type="submit" name="go" value="Go" />
                            <br />
                            <span class="subtle">Search by contract name, contract ID, or payee name.</span>
                        </form>
                    </td>
                </tr>
            </table>
        </div>
    </xsl:template>

    <xsl:template name="recentList">
        <div class="section">
            <h2>Most Recently Accessed Distributor Contracts</h2>

            <xsl:if test="RecentlyViewed/Item">
                <xsl:call-template name="contractTable">
                    <xsl:with-param name="contract" select="RecentlyViewed/Item/DistributorContract" />
                </xsl:call-template>
            </xsl:if>

            <xsl:if test="not(RecentlyViewed/Item)">
                <p>No contracts exist in your viewing history.</p>
            </xsl:if>

        </div>
    </xsl:template>

</xsl:stylesheet>
