<!--                                                                  -->
<!--  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="payeeSearchLayout">
    <xsl:choose>
      <xsl:when test="Params/_inline">
        <xsl:call-template name="searchFormInline" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="searchResultsFull" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="resultsHeader">
    <table class="textChart" id="resultsHeader">
      <tr class="textChartTop">
        <th class="selectCol">Select</th>
        <th class="payeeNameCol">Name</th>
				<th class="clientAccountCol">Client Account #</th>
        <xsl:if test="count(LabelPayee) &gt; 9">
          <th class="scrollCol"></th>
        </xsl:if>
      </tr>
    </table>
  </xsl:template>

  <xsl:template name="searchResults">
    <div class="section" id="payeeSearchInline">
      <xsl:if test="not(Params/Query) and count(LabelPayee) = 0">
        <p>No payees have been created.</p>
      </xsl:if>
      <h2>Search Results</h2>
      <xsl:call-template name="searchNav" >
		<xsl:with-param name="form">label_payeeSearch</xsl:with-param>
		<xsl:with-param name="area">label_payee</xsl:with-param>
	  </xsl:call-template>
      <xsl:call-template name="searchText" />
      <xsl:if test="count(LabelPayee) != 0">
      	<xsl:call-template name="resultsHeader" />
     		<div>
     		  <xsl:if test="count(LabelPayee) &gt; 9">
 		        <xsl:attribute name="class">scrollPop</xsl:attribute>
     		  </xsl:if>
					<table class="textChart textChartBottom textChartResults">
   		      <xsl:for-each select="LabelPayee">
       		    <tr class="row{position() mod 2}">
           		  <td class="selectCol">
	                <input type="radio" name="label_payeeMatch" value="{position()}" 		onClick="modifyField('selectMatch','enable');" />
								</td>
	             	<script type="text/javascript">
       		        match<xsl:value-of select="position()" /> = new Object();
									match<xsl:value-of select="position()" />['LabelPayeeID'] = '<xsl:value-of select="LabelPayeeID" />';
									match<xsl:value-of select="position()" />['Name'] = '<xsl:call-template name="escapeJavascript"><xsl:with-param name="string" select="Name" /></xsl:call-template>';
               		matchCollection['position<xsl:value-of select="position()" />'] = match<xsl:value-of select="position()" />;
             		</script>
             		<td class="payeeNameCol"><xsl:value-of select="Name" /></td>
             		<td class="clientAccountCol"><xsl:value-of select="ClientAccountID" /></td>
							</tr>
						</xsl:for-each>
        	</table>
        </div>
        <script type="text/javascript">
          window.matchCollection = matchCollection;
        </script>
      </xsl:if>
    </div>
    <xsl:if test="count(LabelPayee) != 0">
      <xsl:call-template name="buttons" />
    </xsl:if>
  </xsl:template>

	<xsl:template name="searchResultsFull">
		<div class="section">
			<xsl:choose>
				<xsl:when test="not(Params/Query) and count(LabelPayee) = 0">
        	<p>No payees have been created.</p>
				</xsl:when>
				<xsl:otherwise>
					<xsl:if test="Params/Query">
      	  	<h2>Search Results</h2>
      		</xsl:if>
		      <xsl:call-template name="searchNav" />
    		  <xsl:call-template name="searchText" />
		      <xsl:if test="count(LabelPayee) != 0">
    		   <table class="textChart hiOn">
        		  <tr>
            		<th class="rowLeft">Name</th>
		            <th>Client Account #</th>
    		        <th class="editCol">Edit</th>
        		  </tr>
		          <xsl:for-each select="LabelPayee">
    		        <tr class="row{position() mod 2}">
        		      <td class="rowLeft">
            		    <a href="label_payee?LabelPayeeID={LabelPayeeID}&amp;c=show"><xsl:value-of select="Name" /></a>
		              </td>
    		          <td>
        		        <xsl:value-of select="ClientAccountID" />
		              </td>
    		          <td class="icon">
        		        <a href="label_payee?c=edit&amp;LabelPayeeID={LabelPayeeID}" title="Edit">
            		      <img src="/production/images/icons/office/Edit-(16x16).gif" />
                		</a>
		              </td>
    		        </tr>
        		  </xsl:for-each>
		        </table>
    		  </xsl:if>
		      <xsl:call-template name="searchNav" />
					<xsl:if test="normalize-space(Pagination/Previous) or normalize-space(Pagination/Next)">
  				  <br class="superBreak" />
				    <br />
					</xsl:if>
				</xsl:otherwise>
			</xsl:choose>
    </div>
  </xsl:template>

</xsl:stylesheet>
