<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--  $Id$  -->
<!--                                                                  -->
<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="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:include href="show.xsl" />
  <xsl:include href="search.xsl" />
  <xsl:include href="edit.xsl" />

  <xsl:template name="pickLayout">
    <xsl:choose>
      <xsl:when test="$cmd = 'edit'">
        <xsl:call-template name="payorEditLayout" />
      </xsl:when>
      <xsl:when test="$cmd = 'show'">
        <xsl:call-template name="payorViewLayout" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="payorSearchLayout" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="submitButton">
    <xsl:choose>
      <xsl:when test="$cmd = 'edit'">
        <input name="submit" type="submit" id="submitButton">
          <xsl:attribute name="value">
						<xsl:choose>
	            <xsl:when test="normalize-space(Form/Payor/PayorID)">Update</xsl:when>
							<xsl:otherwise>Create</xsl:otherwise>
						</xsl:choose>
          </xsl:attribute>
          <xsl:if test="$openRuns = 1">
            <xsl:attribute name="disabled">disabled</xsl:attribute>
          </xsl:if>
        </input>
      </xsl:when>
      <xsl:when test="$cmd = 'show'">
        <input type="button" value="Edit" onClick="javascript:location.href='payor?PayorID={Form/Payor/PayorID}&amp;c=edit'" />
      </xsl:when>
			<xsl:otherwise>
        <input type="button" value="Add New Payor" onClick="javascript:location.href='payor?c=edit'" />
			</xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="cancelButton">
    <xsl:choose>
      <xsl:when test="$cmd = 'edit' and normalize-space(Form/Payor/PayorID)">
        <input name="deleteButton" type="button" value="Delete" onClick="confirmDeletePayor({Form/Payor/PayorID})">
          <xsl:if test="Form/Payor/IsLinked &gt; 0">
            <xsl:attribute name="disabled">disabled</xsl:attribute>
          </xsl:if>
          <xsl:if test="$openRuns = 1">
            <xsl:attribute name="disabled">disabled</xsl:attribute>
          </xsl:if>
        </input>
        <xsl:if test="Form/Payor/IsLinked &gt; 0">
          <xsl:call-template name="helpIcon">
            <xsl:with-param name="tip">This payor has been associated with a contract&lt;br&gt; and/or license and cannot be deleted.</xsl:with-param>
          </xsl:call-template>
        </xsl:if>
        <input type="button" value="Return to Payor" onClick="location.href='payor?PayorID={Params/PayorID}&amp;c=show'" />
      </xsl:when>
      <xsl:when test="$cmd = 'edit' and not(normalize-space(Form/Payor/PayorID))">
        <input name="submitButton" id="addAnotherButton" type="submit" value="Create and Add Another" onClick="modifyFieldValue('ReturnTo','/rps/payor?c=edit&amp;msg=success|form_submit_success');" />
  	    <input type="button" value="Back to Payors" onClick="location.href='/rps/payor'" />
      </xsl:when>
      <xsl:when test="$cmd = 'show'">
        <input type="button" name="Back" value="Back to Payors" onClick="location.href='/rps/payor'" />
      </xsl:when>
			<xsl:when test="$cmd = 'search'">
				<input type="button" name="Back" value="Back to Admin" onClick="location.href='/rps/display?d=config'" />
			</xsl:when>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>
