<!--                                                                  -->
<!--  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" />

  <!-- This is really an RPS page: Use that global template -->
  <xsl:include href="/app/tools/bookpub/templates/global.xsl" />

	<xsl:include href="list.xsl" />
  <xsl:include href="edit.xsl" />
	<xsl:include href="show.xsl" />
	<xsl:include href="changepw.xsl" />
  <xsl:include href="import.xsl" />
  <xsl:include href="terms.xsl" />
  <xsl:include href="view_terms.xsl" />  

	<xsl:template name="pickLayout">
		<xsl:choose>
			<xsl:when test="$cmd = 'edit' or $cmd = 'profile'">
        <xsl:call-template name="userEntryLayout" />
			</xsl:when>
      <xsl:when test="$cmd = 'show'">
        <xsl:call-template name="userShowLayout" />
      </xsl:when>
      <xsl:when test="$cmd = 'changepw'">
        <xsl:call-template name="changePWLayout" />
      </xsl:when>
      <xsl:when test="$cmd = 'import'">
        <xsl:call-template name="userImportLayout" />
      </xsl:when>
      <xsl:when test="$cmd = 'terms'">
        <xsl:call-template name="termsLayout" />
      </xsl:when>
      <xsl:when test="$cmd = 'view_terms'">
        <xsl:call-template name="viewTermsLayout" />
      </xsl:when>      
			<xsl:otherwise>
				<xsl:call-template name="userSummaryLayout" />
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

  <xsl:template name="submitButton">
    <xsl:choose>
      <xsl:when test="$cmd = 'edit' or $cmd = 'profile'">
        <input name="submit" type="submit" id="submitButton" onClick="selectAllMulti('Form_AppUser_UserAccess_LabelID');">
          <xsl:attribute name="value">
            <xsl:if test="normalize-space(Form/AppUser/UserID)">Update</xsl:if>
            <xsl:if test="not(normalize-space(Form/AppUser/UserID))">Create</xsl:if>
          </xsl:attribute>
        </input>
      </xsl:when>
      <xsl:when test="$cmd = 'changepw'">
        <input name="submit" type="submit" id="submitButton" value="Update" />
      </xsl:when>
			<xsl:when test="$cmd = 'show' and Access/rps/user/edit = 1 and Form/AccessLevelList/AccessLevel[AccessLevelID = /Root/User/AccessLevel]/CanEditList/CanEdit[@id = /Root/Form/AppUser/AccessLevel] = 1">
				<input type="button" name="editButton" value="Edit" onClick="location.href='user?UserID={Form/AppUser/UserID}&amp;c=edit'" />
			</xsl:when>
      <xsl:when test="Messages/Message/Code = 'import_success'">
        <xsl:attribute name="class" />
      </xsl:when>
      <xsl:when test="$cmd = 'import'">
        <input name="submit" type="submit" id="submitButton" value="Import" onClick="selectAllMulti('Form_UserAccess_LabelID');" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:attribute name="class" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="cancelButton">
    <xsl:choose>
      <xsl:when test="$cmd = 'profile'">
				<input type="button" name="Cancel" value="Cancel" onClick="location.href='/'" />
			</xsl:when>
			<xsl:when test="$cmd = 'edit' and normalize-space(Form/AppUser/UserID)">
        <input type="button" name="Cancel" value="Return to User" onClick="location.href='user?UserID={Form/AppUser/UserID}&amp;c=show'" />
      </xsl:when>
      <xsl:when test="$cmd = 'changepw' or $cmd = 'view_terms'">
        <input type="button" value="Back to Profile" onClick="location.href='user?c=profile'" />
      </xsl:when>
      <xsl:when test="$cmd = 'import' and Messages/Message/Code = 'email_found'">
        <input type="button" value="Back to Import User" onClick="location.href='user?c=import'" />
      </xsl:when>
      <xsl:otherwise>
        <input type="button" value="Back to User List" onClick="location.href='user'" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>

