{% extends 'dashboard/dashboard_base.html' %}
{% block stage %}
<div class="content">
	<div class="new">
	 <div class="new-header">
	    <label>Change Password</label>
	  </div>
	  <div class="new-user">
	    <form class="form-horizontal" name="categoryform" id="categoryform" method='post'>
	      <div class="form-group">
	        <label class="control-label col-sm-2" for="email">Current Password: </label>
	        <div class="col-sm-10">
	            <input type="password" class="form-control" placeholder="Enter current password" name="oldpassword" id="oldpassword">
	        </div>
	      </div>
	      <div class="form-group">
	        <label class="control-label col-sm-2" for="email">New Password: </label>
	        <div class="col-sm-10">
	          <input type="password" class="form-control" placeholder="Enter new password" name="newpassword" id="newpassword">
	        </div>
	      </div>
	      <div class="form-group">
	        <label class="control-label col-sm-2" for="email">Confirm Password</label>
	        <div class="col-sm-10">
	          <input type="password" class="form-control" placeholder="Confirm new password" name="retypepassword" id="retypepassword">
	        </div>
	      </div>
	      <div class="form-group">
	        <div class="col-sm-offset-2 col-sm-10 save_buttons">
	          <button type="submit" class="btn btn-default submit">Submit</button>
	          <button type="button" class="btn btn-default cancel">Cancel</button>
	        </div>
	      </div>
	    </form>
	  </div>
	</div>
</div>
{% endblock %}
{% block extra_js %}
<script type="text/javascript">
$('form#categoryform').submit(function(e){
	e.preventDefault();
	$.post('.', $('form#categoryform').serialize(), function(data){
	    if (data.error == false) {
	      alert(data.message);
	      window.location = "{% url 'django_simple_forum:dashboard' %}";
	    } else {
	      $('div.error').remove();
	      for (var key in data.response) {
	        $('#' + key).after('<div class="error">' + data.response[key] + '</div>');
	      }
	    }
	}, 'json');
});
$('.cancel').click(function(e){
	window.location = "{% url "django_simple_forum:dashboard" %}";
});
</script>
{% endblock %}