<div class="BodyContainer">

	<form action="index.php?ToDo=%%GLOBAL_FormAction%%" onsubmit="return CheckForm(this);" name="frmAddUser" id="frmAddUser" method="post">
	%%GLOBAL_hiddenFields%%
	<table class="OuterPanel" cellspacing="0" cellpadding="0" border="0">
	<tr>
		<td class="Heading1" colspan="2">%%GLOBAL_UserTitle%%</td>
	</tr>
	<tr>
		<td class="Intro" colspan="2">
			<div>%%GLOBAL_UserIntro%%</div>
			<div>
				<input type="submit" name="SubmitButton1" value="%%LNG_Save%%" class="FormButton">
				<input type="button" name="CancelButton1" value="%%LNG_Cancel%%" class="FormButton" onClick="ConfirmCancel()">
			</div>
		</td>
	</tr>
	<tr>
		<td colspan="2">
		%%GLOBAL_Message%%
		</td>
	</tr>
	<tr>
		<td>
			<table class="Panel">
			<tr>
				<td class="Heading2" colspan="2">%%LNG_AddUserDetails%%</td>
			</tr>
			%%GLOBAL_UsernamePanel%%
			%%GLOBAL_PasswordPanel%%
			<tr>
				<td class="FieldLabel">
					<span class="Required">*</span>&nbsp;%%LNG_UserFirstName%%:
				</td>
				<td>
					<input type="text" name="firstname" class="Field250" value="%%GLOBAL_UserFirstName%%" />
				</td>
			</tr>
			<tr>
				<td class="FieldLabel">
					<span class="Required">*</span>&nbsp;%%LNG_UserLastName%%:
				</td>
				<td>
					<input type="text" name="lastname" class="Field250" value="%%GLOBAL_UserLastName%%" />
				</td>
			</tr>
			<tr>
				<td class="FieldLabel">
					<span class="Required">*</span>&nbsp;%%LNG_UserEmail%%:
				</td>
				<td>
					<input type="text" name="email" class="Field250" value="%%GLOBAL_UserEmail%%">
				</td>
			</tr>
			%%Panel.UserStatus%%
			%%Panel.UserGroups%%
			<tr>
				<td class="Gap" colspan="2">&nbsp;</td>
			</tr>
			<tr class="ClearGap">
				<td class="FieldLabel">&nbsp;</td>
				<td>
					<br />
					<input type="submit" name="SubmitButton2" value="%%LNG_Save%%" class="FormButton">
					<input type="button" name="CancelButton2" value="%%LNG_Cancel%%" class="FormButton" onClick="ConfirmCancel()">
				</td>
			</tr>
			</table>
		</td>
	</tr>
	</table>
	</form>

	<script defer language="JavaScript" type="text/javascript">

		function ConfirmCancel()
		{
			if(confirm('%%LNG_CancelMessage%%'))
			{
				document.location.href='index.php?ToDo=viewUsers';
			}
			else
			{
				return false;
			}
		}

		function CheckForm(f)
		{
			if(f.login.value == "")
			{
				alert("%%LNG_UserNoUser%%");
				f.login.focus();
				f.login.select();
				return false;
			}

			if(f.firstname.value == "")
			{
				alert("%%LNG_UserNoFirstname%%");
				f.firstname.focus();
				f.firstname.select();
				return false;
			}

			if(f.lastname.value == "")
			{
				alert("%%LNG_UserNoLastname%%");
				f.lastname.focus();
				f.lastname.select();
				return false;
			}

			if(f.email.value == "")
			{
				alert("%%LNG_LocalUserNoEmail%%");
				f.email.focus();
				f.email.select();
				return false;
			}

			if(f.login.value.length < 4)
			{
				alert("%%LNG_UserShortUser%%");
				f.login.focus();
				f.login.select();
				return false;
			}

			if("%%GLOBAL_AddingUser%%" == "1")
			{
				if (f.password1.value == "")
				{
					alert("%%LNG_UserNoPass%%");
					f.password1.focus();
					f.password1.select();
					return false;
				}

				if(f.password1.value.length < 5)
				{
					alert("%%LNG_UserShortPass%%");
					f.password1.focus();
					f.password1.select();
					return false;
				}

				if(f.password1.value != f.password2.value)
				{
					alert("%%LNG_UserMismatchPass%%");
					f.password1.focus();
					f.password1.select();
					return false;
				}
			}
			else
			{
				if(f.password1.value.length > 0 && f.password1.value.length < 5)
				{
					alert("%%LNG_UserShortPass%%");
					f.password1.focus();
					f.password1.select();
					return false;
				}

				if(f.password1.value.length > 0 && (f.password1.value != f.password2.value))
				{
					alert("%%LNG_UserMismatchPass%%");
					f.password2.focus();
					f.password2.select();
					return false;
				}
			}
			if (window.CheckGroups) {
				CheckGroups(f);
			}

			// Everything is OK, return true
			return true;
		}

	</script>

</div>