<!--                                                                  -->
<!--  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="labelContractMain">
			<div class="section">
			    <table class="landingPage">
			        <tr>
        				<xsl:call-template name="addSection" />
        				<xsl:call-template name="viewSection" />
        		    </tr>
        		</table>
			</div>
			<xsl:call-template name="searchSection" />
			<xsl:call-template name="recentList" />
		</div>
	</xsl:template>

	<xsl:template name="addSection">
		<td class="landingAdd">
			<h2>Add Contract</h2>
			<table>
			    <tr>
			        <td>
			            <a href="/rps/label_contract?c=edit" title="Add New Label Contract"><img src="/production/images/icons/office/Add-(16x16).gif" height="16" width="16" /></a> <a href="/rps/label_contract?c=edit">Add New Label Contract</a>
			        </td>
			    </tr>
			</table>
		</td>
	</xsl:template>

	<xsl:template name="viewSection">
		<td class="landingView">
			<h2>View Contracts</h2>
			<table>
				<tr>
					<td>
						<form action="/rps/label_contract" method="get">
							<input type="hidden" name="c" value="list" />
							 
							<xsl:choose>
								<xsl:when test="count(PayorList/Payor) &gt; 1">
									<label for="payorView">Label 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/label_contract?c=list">Label Contracts</a>
								</xsl:otherwise>	
							</xsl:choose>
							
							<br />
							<span class="subtle">View all label contracts<xsl:if test="count(PayorList/Payor) &gt; 1"> or contracts for a specific payor</xsl:if>.</span>
						</form>
					</td>
				</tr>
			</table>
		</td>
	</xsl:template>

	<xsl:template name="searchSection">
		<div class="section landingSearch">
			<table>
				<tr>
					<td>
						<form action="/rps/label_contract" method="get">
							<input type="hidden" name="c" value="search" />
							<label for="contractSearch">Search Label 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 Label Contracts</h2>
			
			<xsl:if test="RecentlyViewed/Item">
				<xsl:call-template name="contractTable">
					<xsl:with-param name="contract" select="RecentlyViewed/Item/LabelContract" />
				</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>
