<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="OBJECT[@TYPE='USER']">
	<style>
		.sb-pagetitle { border-bottom: solid 1px #776655; }
	</style>
<script type="text/javascript" src="/js/Admin/Users.js?{$version}.{$build}"/>
<form name="objectForm" method="post" action="{$baseUrl}" onsubmit="submitForm(); return false;">
<input type="hidden" id="action" name="action" value="/Admin/User/Save"/>
<input type="hidden" name="userId">
	<xsl:attribute name="value"><xsl:value-of select="CONTROL[@NAME='id']"/></xsl:attribute>
</input>

<fieldset class="sb-form-fieldset">
	<legend>
        <b class="sb-text sb-page"><xsl:value-of select="@TITLE"/></b>
    </legend>
	
	<table cellpadding="0" cellspacing="0" border="0" class="control-title-input">
		<xsl:call-template name="EDIT-USER-FORM-ROW">
			<xsl:with-param name="name">firstName</xsl:with-param>
			<xsl:with-param name="require">true</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="EDIT-USER-FORM-ROW">
			<xsl:with-param name="name">lastName</xsl:with-param>
			<xsl:with-param name="require">true</xsl:with-param>
		</xsl:call-template>
		<xsl:call-template name="EDIT-USER-FORM-ROW">
			<xsl:with-param name="disabled">true</xsl:with-param>
			<xsl:with-param name="name">userName</xsl:with-param>
		</xsl:call-template>
		<tr id="rowSetPassword">
			<xsl:if test="@IS-CHANGE-PASSWORD-ALLOWED != 1">
				<xsl:attribute name="style">display: none;</xsl:attribute>
			</xsl:if>
			<td class="title-block"></td>
			<td class="input-block">
				<xsl:call-template name="BUTTON-CONTROL">
					<xsl:with-param name="class">sb-login-control-button</xsl:with-param>
					<xsl:with-param name="title"><xsl:value-of select="/SITEBUILDER-PAGE/LOCALE/CHANGE-PASSWORD"/></xsl:with-param>
					<xsl:with-param name="action">showPassword();</xsl:with-param>
				</xsl:call-template>
			</td>
		</tr>
		<tr id="rowPassword" style="display: none;">
			<td class="title-block">
				<xsl:call-template name="LABEL" mode="label">
					<xsl:with-param name="id">password</xsl:with-param>
					<xsl:with-param name="require">true</xsl:with-param>
					<xsl:with-param name="title" select="/SITEBUILDER-PAGE/LOCALE/PASSWORD"/>
					<xsl:with-param name="value" select="CONTROL[@NAME='userPassword']"/>
				</xsl:call-template>
			</td>
			<td class="input-block">
				<xsl:apply-templates select="CONTROL[@NAME='userPassword']" mode="control">
					<xsl:with-param name="id">password</xsl:with-param>
					<xsl:with-param name="name">password</xsl:with-param>
					<xsl:with-param name="onchange">self.sbApplyChangesObject.registerChange();</xsl:with-param>
					<xsl:with-param name="require">true</xsl:with-param>
					<xsl:with-param name="type">password</xsl:with-param>
				</xsl:apply-templates>
			</td>
		</tr>
		<tr id="rowPasswordConfirm" style="display: none;">
			<td class="title-block">
				<xsl:call-template name="LABEL" mode="label">
					<xsl:with-param name="id">confirmPassword</xsl:with-param>
					<xsl:with-param name="require">true</xsl:with-param>
					<xsl:with-param name="title" select="/SITEBUILDER-PAGE/LOCALE/CONFIRM-PASSWORD"/>
					<xsl:with-param name="value" select="CONTROL[@NAME='userPassword']"/>
				</xsl:call-template>
			</td>
			<td class="input-block">
				<xsl:apply-templates select="CONTROL[@NAME='userPassword']" mode="control">
					<xsl:with-param name="id">confirmPassword</xsl:with-param>
					<xsl:with-param name="name">confirmPassword</xsl:with-param>
					<xsl:with-param name="onchange">self.sbApplyChangesObject.registerChange();</xsl:with-param>
					<xsl:with-param name="require">true</xsl:with-param>
					<xsl:with-param name="type">password</xsl:with-param>
				</xsl:apply-templates>
			</td>
		</tr>
		<xsl:call-template name="EDIT-USER-FORM-ROW">
			<xsl:with-param name="name">email</xsl:with-param>
			<xsl:with-param name="require">true</xsl:with-param>
		</xsl:call-template>
		<tr>
			<td class="title-block">
				<xsl:apply-templates select="CONTROL[@NAME='planId' and @TYPE='COMBO-BOX']" mode="label"/>
			</td>
			<td class="input-block">
				<xsl:apply-templates select="CONTROL[@NAME='planId' and @TYPE='COMBO-BOX']" mode="control">
					<xsl:with-param name="onChange">self.sbApplyChangesObject.registerChange();</xsl:with-param>
				</xsl:apply-templates>
			</td>
		</tr>
	</table>
</fieldset>
<!-- input image needed for work default submit via Enter -->
<input type="image" style="border-width: 0px; height: 0px; width: 0px;"/>
</form>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<tr>
		<td align="left" style="padding-left: 5px"><xsl:call-template name="REQUIRED-FIELDS"/></td>
		<td>
			<xsl:call-template name="OK-CANCEL-BUTTONS">
				<xsl:with-param name="okAction">submitForm();</xsl:with-param>
				<xsl:with-param name="cancelAction">document.location.href="<xsl:value-of select="$baseUrl"/>/Admin/User/List";</xsl:with-param>
			</xsl:call-template>
		</td>
	</tr>
</table>



<script type="text/javascript">
function showPassword() {
	showElement(document.getElementById("rowPassword"), true);
	showElement(document.getElementById("rowPasswordConfirm"), true);
	showElement(document.getElementById("rowSetPassword"), false);
	return false;
}
</script>
</xsl:template>


	
<xsl:template name="EDIT-USER-FORM-ROW">
	<xsl:param name="disabled"/>
	<xsl:param name="name"/>
	<xsl:param name="onchange">self.sbApplyChangesObject.registerChange();</xsl:param>
	<xsl:param name="require"/>
	<xsl:param name="title" select="CONTROL[@NAME=$name]/@TITLE"/>
	<xsl:param name="type"/>

	<xsl:variable name="node" select="CONTROL[@NAME=$name]"/>      
				   
	<tr>		
		<td class="title-block">
			<xsl:apply-templates select="$node" mode="label">
				<xsl:with-param name="require" select="$require"/>
			</xsl:apply-templates>
		</td>
		<td class="input-block">
			<xsl:apply-templates select="CONTROL[@NAME=$name]" mode="control">
				<xsl:with-param name="disabled" select="$disabled"/>
				<xsl:with-param name="id" select="$name"/>
				<xsl:with-param name="name" select="$name"/>
				<xsl:with-param name="onchange" select="$onchange"/>
				<xsl:with-param name="require" select="$require"/>
				<xsl:with-param name="type" select="$type"/>
				<xsl:with-param name="value" select="$node"/>
			</xsl:apply-templates>
		</td>
	</tr>
</xsl:template>

</xsl:stylesheet>
