<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--  $Id$  -->
<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" indent="no" doctype-system="http://www.w3.org/TR/html4/strict.dtd" doctype-public="-//W3C//DTD HTML 4.01//EN" encoding="utf-8" />

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


    <xsl:template name="pickLayout">
        <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="publisherNameCol">Name</th>
				<th class="typeCol">Type</th>
                <th class="adminCol">Admin</th>
                <th class="agentCol">Agent</th>
                <xsl:if test="count(Publisher) &gt; 9">
                    <th class="scrollCol"></th>
                </xsl:if>
            </tr>
        </table>
    </xsl:template>

    <xsl:template name="searchResults">
        <div class="section" id="publisherSearchInline">
            <xsl:if test="not(Params/Query) and not(Params/AdminID) and not(Params/AgentID) and count(Publisher) = 0">
                <p>No publishers have been created.</p>
            </xsl:if>
            <h2>Search Results</h2>
            <xsl:call-template name="searchNav" >
				<xsl:with-param name="form"><xsl:value-of select="$area" />Search</xsl:with-param>
				<xsl:with-param name="area"><xsl:value-of select="$area" /></xsl:with-param>
			</xsl:call-template>
            <xsl:call-template name="searchText" />
            <xsl:if test="count(Publisher) != 0">
      	        <xsl:call-template name="resultsHeader" />
     		    <div>
     		        <xsl:if test="count(Publisher) &gt; 9">
 		                <xsl:attribute name="class">scrollPop</xsl:attribute>
     		        </xsl:if>
					<table class="textChart textChartBottom textChartResults">
   		                <xsl:for-each select="Publisher">
       		                <tr class="row{position() mod 2}">
           		                <td class="selectCol">
	                                <input type="radio" name="{$area}Match" 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()" />['PublisherID'] = '<xsl:value-of select="PublisherID" />';
									match<xsl:value-of select="position()" />['PublisherName'] = '<xsl:call-template name="escapeJavascript"><xsl:with-param name="string" select="PublisherName" /></xsl:call-template>';
									<xsl:if test="normalize-space(AdminName)">
										match<xsl:value-of select="position()" />['AdminName'] = '<xsl:call-template name="escapeJavascript"><xsl:with-param name="string" select="AdminName" /></xsl:call-template>';
									</xsl:if>
									<xsl:if test="normalize-space(AgentName)">
										match<xsl:value-of select="position()" />['AgentName'] = '<xsl:call-template name="escapeJavascript"><xsl:with-param name="string" select="AgentName" /></xsl:call-template>';
									</xsl:if>
               		                matchCollection['position<xsl:value-of select="position()" />'] = match<xsl:value-of select="position()" />;
             		            </script>
             		            <td class="publisherNameCol"><xsl:value-of select="PublisherName" /></td>
		                        <td class="typeCol">
     			                    <xsl:choose>
               	  	                    <xsl:when test="IsAgency = 1">Agency</xsl:when>
                 	  	                <xsl:when test="IsAdmin = 1">Administrator</xsl:when>
    	                                <xsl:otherwise>Standard</xsl:otherwise>
       		                        </xsl:choose>
           		                </td>
    						    <td class="adminCol"><xsl:value-of select="AdminName" /></td>
                 		        <td class="agentCol"><xsl:value-of select="AgentName" /></td>
    				        </tr>
    				    </xsl:for-each>
            	    </table>
                </div>
                <script type="text/javascript">
                    window.matchCollection = matchCollection;
                </script>
            </xsl:if>
        </div>
        <xsl:if test="count(Publisher) != 0">
            <xsl:call-template name="buttons" />
        </xsl:if>
    </xsl:template>

    <xsl:template name="searchResultsFull">
        <div class="section">
            <xsl:if test="not(Params/Query) and not(Params/AdminID) and not(Params/AgentID) and count(Publisher) = 0">
                <p>No publishers have been created.</p>
            </xsl:if>
            <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(Publisher) != 0">
                <table class="textChart hiOn">
                    <tr>
                        <th>Name</th>
                        <th class="publisherTypeCol">Type</th>
                        <th>Admin</th>
                        <th>Agent</th>
                        <th class="editCol">Edit</th>
                    </tr>
                    <xsl:for-each select="Publisher">
                        <tr class="row{position() mod 2}">
                            <td>
                                <a href="?PublisherID={PublisherID}&amp;c=show">
                                    <xsl:value-of select="PublisherName" />
                                </a>
                            </td>
                            <td>
                                <xsl:choose>
                                    <xsl:when test="IsAgency = 1">Agency</xsl:when>
                                    <xsl:when test="IsAdmin = 1">Administrator</xsl:when>
                                    <xsl:otherwise>Standard</xsl:otherwise>
                                </xsl:choose>
                            </td>
							<td><xsl:value-of select="AdminName" /></td>
                            <td><xsl:value-of select="AgentName" /></td>
                            <td class="icon">
                                <a href="?c=edit&amp;PublisherID={PublisherID}" 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>
        </div>
    </xsl:template>


    <xsl:template name="submitButton">
        <input type="button" name="selectMatch" id="selectMatch" value="Use this Publisher" disabled="true" onClick="useMatch('{$area}')" />
    </xsl:template>


    <xsl:template name="cancelButton">
        <input type="button" name="Cancel" value="Cancel" onClick="hideInlinePop()" />
    </xsl:template>


</xsl:stylesheet>
