<div id="primary_header">
  <h1><?php print $this->translate('Change Password')?></h1>
	<div id="back_button">
		<a href="#">
			<span class="stronglastword"><?php echo $this->translate('Save Settings') ?></span>
		</a>
	</div>
</div>

<div id="back_button" class="savecontact">
<a href="#">
<span>
<?php print $this->translate('Save Password')?>
</span>
</a>
</div>


<div id="primary_content">
  <div id="primary_content_inner">
  <div id="Flash" class="flash_notice"><?php echo $this->translate('Your password has been updated. Please change your mail-client settings to authenticate with the new password to regain access.') ?></div>

  <form id="settingsForm" method="post" action="<?php echo $this->moduleBaseUrl ?>/settings/passwordsave">
    <input type="hidden" name="save" value="1" />
    <table class="settings">

      <tr>
        <td class="label"><label for="replyTo"><?php print $this->translate('Current Password')?></label></td>
        <td>
          <input type="password" class="medium" value="" name="currentPassword" id="currentPassword" />
          <small><?php print $this->translate('Specify your existing password')?></small>
        </td>
      </tr>

	</table>
	
	<div class="divider"></div>
		
    <table class="settings">
      <tr>
        <td class="label"><label for="signature"><?php print $this->translate('New Password')?></label></td>
        <td>
          <input type="password" class="medium" value="" name="newPassword" id="newPassword" />
			<small><?php print $this->translate('Specify the new password for your account')?></small>
        </td>
      </tr>

      <tr>
        <td class="label"><label for="signature"><?php print $this->translate('Confirm Password')?></label></td>
        <td>
          <input type="password" class="medium" value="" name="newPassword2" id="newPassword2" />
			<small><?php print $this->translate('Confirm the new password')?></small>
        </td>
      </tr>

    </table>
    <div class="bottomFormMainButtonArea" style="display:none;">
		<div id="back_button"><a href="#"><span class="stronglastword"><?php echo $this->translate('Save Settings') ?></span></a></div>
	</div>
	<br />
	<br />
	<br />
	
  </div>
  </form>


</div>

<script type="text/javascript">
$(function() {

    // bind to the form's submit event and cancel legacy submit 
    $('#settingsForm', "#password").submit(function() {   
	    $("#Flash", "#password").hide();

        $('#back_button a', '#password').fadeTo("slow", 0.5);
        $('#back_button a', '#password').addClass("disabled");
        $('#back_button a', '#password').removeClass("enabled");

        if(!$("#currentPassword").attr('value')) {
			alert('<?php print addslashes($this->translate('Please specify the current password'))?>');
            $('#back_button a', '#password').fadeTo("slow", 1);
            $('#back_button a', '#password').addClass("enabled");
            $('#back_button a', '#password').removeClass("disabled");
			$("#currentPassword").focus();
		}

		else if(!$("#newPassword").attr('value')) {
			alert('<?php print addslashes($this->translate('Please specify the new password'))?>');
            $('#back_button a', '#password').fadeTo("slow", 1);
            $('#back_button a', '#password').addClass("enabled");
            $('#back_button a', '#password').removeClass("disabled");
			$("#newPassword").focus();
		}

		//else if($("#newPassword").attr('value').length<6) {
		//	alert('<?php //print addslashes($this->translate('Password is too short. Must more than 6 characters/digits.'))?>');
		//	$("#newPassword").focus();
		//}

		else if(!$("#newPassword2").attr('value')) {
			alert('<?php print addslashes($this->translate('Please type the password confirmation'))?>');
            $('#back_button a', '#password').fadeTo("slow", 1);
            $('#back_button a', '#password').addClass("enabled");
            $('#back_button a', '#password').removeClass("disabled");
			$("#newPassword").focus();
		}

		else if($("#newPassword").attr('value') != $("#newPassword2").attr('value')) {
			alert('<?php print addslashes($this->translate('New passwords do not match, please verify'))?>');
            $('#back_button a', '#password').fadeTo("slow", 1);
            $('#back_button a', '#password').addClass("enabled");
            $('#back_button a', '#password').removeClass("disabled");
			$("#newPassword").focus();
		}
		
		else {		
		$.php($("#settingsForm", '#password').attr("action"),$("#settingsForm", "#password").serializeArray());
		}
        $('#currentPassword').attr('value','');
        $('#newPassword').attr('value','');
        $('#newPassword2').attr('value','');
        $('#back_button a', '#password').fadeTo("slow", 1);
        $('#back_button a', '#password').addClass("enabled");
        $('#back_button a', '#password').removeClass("disabled");
		return false;
    });

    $('#back_button a', '#password').bind("click", function() { return $('#settingsForm', "#password").submit()})

	$('.stronglastword').each( function() { $(this).stronglastword() });

});
</script>
