{% extends "ldt/user/user_change.html" %}
{# form of password change #}
{% load i18n %}

{% block css_import %}
{{ block.super }}
    
    <script type="text/javascript">
	$(document).ready(function () {
		$("input").keyup(function () {
			if (display_error_if_different("#id_new_password1", "#id_new_password2", "#passwordsdontmatch")) {
				$("input[type=submit]").removeAttr('disabled');
			} else {
				$("input[type=submit]").attr('disabled', 'disabled');
			}			
		});			
	});
	</script>
{% endblock %}

{% block content %}
{{ block.super }}
{% if form %}
	<form method="post" id="my_form"
		action=""
		accept-charset="utf-8">
	{% csrf_token %}
	<table>
		<tr>
			<td class="leftcolumn">
				<label for="id_old_password">{% trans "Old password" %}</label>
			</td>
			<td>
				<input type="password" name="old_password" id="id_old_password" />
			</td>
			<td></td>
		</tr>
		<tr>
			<td class="leftcolumn">
				<label for="id_new_password1">{% trans "New password" %}</label>
			</td>
			<td>
				<input type="password" name="new_password1" id="id_new_password1" />
				<span id="passwordsdontmatch" class="error">{% trans "passwords don't match" %}</span>
			</td>
			<td></td>
		</tr>
		<tr>
			<td class="leftcolumn">
				<label for="id_new_password2">{% trans "New password confirmation" %}</label>
			</td>
			<td>
				<input type="password" name="new_password2" id="id_new_password2" />
			</td>
			<td></td>
		</tr>
        <tr><td></td><td><input type="submit" class="button" name="submit_password" value="{% trans "Password change" %}" /></td></tr>
	</table>
	</form>
{% else %}
<p>{% trans "Your new password has been saved." %}</p>
{% endif %}
{% endblock%}
