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

{% load i18n %}
{% block css_import %}

{{ block.super }}

<script type="text/javascript">
	function isValidForm () {
		var display = display_error_if_different("#id_email1", "#id_email2", "#emailsdontmatch");
		var first_name = is_valid_name ("#id_first_name", "#firstnameincorrect");
		var last_name = is_valid_name ("#id_last_name", "#lastnameincorrect");
		var email1 = is_valid_email ("#id_email1", "#incorrectemail1");
		var email2 = is_valid_email ("#id_email2", "#incorrectemail2");
		
		return display && first_name && last_name && email1 && email2;
	}

	$(document).ready(function () {
			$(".responseerror").show();
		
			$("input").keyup(function () {
				if (isValidForm()) {
					$("input[type=submit]").removeAttr('disabled');
				} else {
					$("input[type=submit]").attr('disabled', 'disabled');
				}				
			});
	});
</script>

{% endblock %}
{% block content %}

{{ block.super }}

{% if not form %}
{%trans "Your profile has been updated" %}
{% endif %}
<form method="post" action="">
{% csrf_token %}
	<table>
		<tr>
            <td class="leftcolumn">
                <label for="id_username">{% trans "user name" %}</label>
            </td>
            <td>
                <input id="id_username" type="text" maxlength="30" name="username" value="{{ user.username }}"/>
            	{% for error in form.username.errors %}
            	<span class="error responseerror">
            		{{ error }}            		
            	</span>
            	{% endfor %}
            </td>
        </tr>
		<tr>
            <td class="leftcolumn"> 
                <label for="id_first_name">{% trans "first name" %}</label>
            </td>
            <td>
                <input id="id_first_name" type="text" maxlength="30" name="first_name" value="{{ user.first_name }}"/>
            	<span id="firstnameincorrect" class="error">{% trans "Please use only letters, blanks or dashes" %}</span>
            	{% for error in form.first_name.errors %}
            	<span class="error">
            		{{ error }}            		
            	</span>
            	{% endfor %}
            </td>
        </tr>
        <tr>
            <td class="leftcolumn">
                <label for="id_last_name">{% trans "name" %}</label>
            </td> 
            <td>
                <input id="id_last_name" type="text" maxlength="30" name="last_name" value="{{ user.last_name }}"/>
            	<span id="lastnameincorrect" class="error">{% trans "Please use only letters, blanks or dashes" %}</span>
           		{% for error in form.last_name.errors %}
            	<span class="error">
            		{{ error }}            		
            	</span>
            	{% endfor %}
            </td>
        </tr>
        <tr>
            <td class="leftcolumn">
                <label for="id_email1">{% trans "email" %}</label>
            </td>
            <td>
                <input id="id_email1" type="text" maxlength="75" name="email1" class="required email" value="{{ user.email }}"/>
            	<span id="emailsdontmatch" class="error">{% trans "emails don't match" %}</span>
            	<span id="incorrectemail1" class="error">{% trans "incorrect email" %}</span>
            	{% for error in form.email1.errors %}
            	<span class="error">
            		{{ error }}            		
            	</span>
            	{% endfor %}
            </td>
        </tr>
        <tr>
            <td class="leftcolumn">
                <label for="id_email2">{% trans "Confirmation de l'adresse émail" %}</label>
            </td>
            <td>
                <input id="id_email2" type="text" maxlength="75" name="email2" class="required email"  value="{{ user.email }}"/>
            	<span id="incorrectemail2" class="error">{% trans "incorrect email" %}</span>
            	{% for error in form.email2.errors %}
            	<span class="error">
            		{{ error }}            		
            	</span>
            	{% endfor %}
            </td>
        </tr>
        <tr><td></td><td><input type="submit" name="submit_profile" value="{% trans "Profile change" %}" /></td></tr>
         
    </table>
</form>

{% endblock%}

