<script>
function changePasswordSubmit() {
	var currentPassword = dojo.byId("user-current-password").value;
	var newPassword = dojo.byId("user-new-password").value;
	var confirmNewPassword = dojo.byId("user-confirm-new-password").value;
	if (newPassword != confirmNewPassword) {
		alert("<?=__('New password does not match confirmed password.')?>");
		return;
	}
	dojo.xhrPost ({
		url: "<?=$this->baseUrl?>/admin-users.raw/process-change-password",
		handleAs: "json",
		content: {
			"user[currentPassword]": currentPassword,
			"user[newPassword]": newPassword,
			"user[confirmNewPassword]": confirmNewPassword,
		},
		load: function (data) {
			if (data == true) {
				alert("<?=('Password sucessfully changed')?>");
				dhxWins.window("winChangePasswordId").close();
			}
			else {
				alert(data);
			}
		},
		error: function (error) {
			alert(error);
			console.error ('Error: ', error);
		}
	});
}
</script>
<div style="float:left;">
	<form id="changePasswordForm" method="post" action="<?=$this->baseUrl?>/admin-users.raw/process-change-password">

	<div class="formRow">
		<dt><label for="user-current-password" class="optional"><?=__('Current Password')?></label></dt>
		<input type="password" name="user[currentPassword]" id="user-current-password" size="16" helper="formText" value=""/>
	</div>
	<br style="clear:left"/>
	<div class="formRow">
		<dt><label for="user-new-password" class="optional"><?=__('New Password')?></label></dt>
		<input type="password" name="user[newPassword]" id="user-new-password" size="16" helper="formText" value=""/>
	</div>
	<br style="clear:left"/>
	<div class="formRow">
		<dt><label for="user-old-password" class="optional"><?=__('Confirm New Password')?></label></dt>
		<input type="password" name="user[confirmNewPassword]" id="user-confirm-new-password" size="16" helper="formText" value=""/>
	</div>
	<br style="clear:left"/>
	<div style="text-align:center;margin-top:10px;">
		<input type="button" value="<?=__('OK')?>" onClick="changePasswordSubmit()" />
		<input type="button" value="<?=__('Cancel')?>" onClick="dhxWins.window('winChangePasswordId').close()"/>
	</div>

	</form>
</div>
