<form method="POST" id="add-form">
<p>{"Name"}:<br /><input type="text" name="name" size="40" value="{{ name }}" />
<span class="notice" id="name-notice">{"You must enter a name."}</span></p>
<p>{"Email"}:<br /><input type="text" name="email" size="40" value="{{ email }}" />
<span class="notice" id="email-notice">{"You must enter an email address."}</span></p>
<p>{"Password"}:<br /><input type="password" name="password" size="20" value="{{ password }}" />
<span class="notice" id="password-notice">{"You must enter a password."}</span></p>
<p>{"Verify password"}:<br /><input type="password" name="verify_pass" size="20" value="{{ verify_pass }}" />
<span class="notice" id="verify_pass-notice">{"Your password doesn't match."}</span></p>
<p>{"User type"}:<br />
<select name="type">
	<option value="admin"{% if type == 'admin' %} selected{% end %}>{"Admin"}</option>
	<option value="member"{% if type == 'member' %} selected{% end %}>{"Member"}</option>
</select></p>
<p>
	<input type="submit" value="Add User"}" />&nbsp;
	<a href="javascript:history.go(-1)" onclick="return $.cancel_autosave ('{"Are you sure you want to cancel and lose any changes?"}')">{"Cancel"}</a>
</p>
</form>

<script type="text/javascript" src="/js/jquery.verify_values.js"></script>
<script type="text/javascript">
$(function () {
	$('#add-form').verify_values ({
		handler: 'user/add',
		callback: function (failed) {
			// highlight the failed elements
			for (var i = 0; i < failed.length; i++) {
				$('#' + failed[i] + '-notice').show ();
			}
		},
		reset: function (fields) {
			for (var i = 0; i < fields.length; i++) {
				$('#' + fields[i] + '-notice').hide ();
			}
		}
	});
	{% foreach failed %}
	$('#{{ loop_value }}-notice').show ();
	{% end %}
});
</script>
