<!--                                                                  -->
<!--  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="labelEditLayout" />
      </xsl:when>
      <xsl:when test="$cmd = 'show'">
        <xsl:call-template name="labelViewLayout" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="labelListLayout" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="submitButton">
    <xsl:choose>
      <xsl:when test="$cmd = 'edit'">
        <input name="submit" type="submit" id="submitButton" onClick="selectAllMulti('Form_Label_UserID');">
          <xsl:attribute name="value">
						<xsl:choose>
	            <xsl:when test="normalize-space(Form/Label/LabelID)">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='label?LabelID={Form/Label/LabelID}&amp;c=edit'" />
      </xsl:when>
			<xsl:otherwise>
        <input type="button" value="Add New Label" onClick="javascript:location.href='label?c=edit'" />
			</xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="cancelButton">
    <xsl:choose>
      <xsl:when test="$cmd = 'edit' and normalize-space(Form/Label/LabelID)">
        <input type="button" value="Return to Label" onClick="location.href='label?LabelID={Params/LabelID}&amp;c=show'" />
      </xsl:when>
      <xsl:when test="$cmd = 'edit' and not(normalize-space(Form/Label/LabelID))">
        <input name="submitButton" id="addAnotherButton" type="submit" value="Create and Add Another" onClick="modifyFieldValue('ReturnTo','/rps/label?c=edit&amp;msg=success|form_submit_success');" />
  	    <input type="button" value="Back to Labels" onClick="location.href='/rps/label'" />
      </xsl:when>
      <xsl:when test="$cmd = 'show'">
        <input type="button" name="Back" value="Back to Labels" onClick="location.href='/rps/label'" />
      </xsl:when>
			<xsl:otherwise>
				<input type="button" name="Back" value="Back to Admin" onClick="location.href='/rps/display?d=config'" />
			</xsl:otherwise>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>
