<%@ include file="/includes.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib prefix="smvc" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<html>
<script src="../js/webapp.js" type="text/javascript"></script>
<script src="../js/pswdStrength.js" type="text/javascript"></script>
<script src="../js/AJAXSupport.js" type="text/javascript"></script>

<body>
<smvc:form modelAttribute="userForm" id="form" action="userPassword.form" onsubmit="return checkStrongPassword();">
	<c:set var="passwordStrengthMessage" value="Password must be at least ${passwordMinimumLength} characters"/>
	<c:if test="${passwordIncludeUpperCase or passwordIncludeNumeric or passwordIncludeSpecialChar }">
		<c:set var="passwordStrengthMessage" value="${passwordStrengthMessage} and must contain at least"/>
		<c:if test="${passwordIncludeUpperCase}">
			<c:set var="passwordStrengthMessage" value="${passwordStrengthMessage} one upper case"/>
		</c:if>
		<c:if test="${passwordIncludeNumeric}">
			<c:if test="${passwordIncludeUpperCase}">
				<c:set var="passwordStrengthMessage" value="${passwordStrengthMessage} and"/>
			</c:if>
			<c:set var="passwordStrengthMessage" value="${passwordStrengthMessage} one numeric"/>
			<c:set var="passwordStrengthMessageAdded" value="true"/>
		</c:if>
		<c:if test="${passwordIncludeSpecialChar}">
			<c:if test="${passwordIncludeNumeric or(!passwordIncludeNumeric and  passwordIncludeUpperCase)}">
				<c:set var="passwordStrengthMessage" value="${passwordStrengthMessage} and"/>
			</c:if>
			<c:set var="passwordStrengthMessage" value="${passwordStrengthMessage} one punctuation or special"/>
		</c:if>
		<c:set var="passwordStrengthMessage" value="${passwordStrengthMessage} character"/>
	</c:if>
	<input type="hidden" id="passwordMinimumLength" name="passwordMinimumLength" value="<c:out value="${passwordMinimumLength}" />" />
	<input type="hidden" id="passwordIncludeNumeric" name="passwordIncludeNumeric" value="<c:out value="${passwordIncludeNumeric}" />" />
	<input type="hidden" id="passwordIncludeUpperCase" name="passwordIncludeUpperCase" value="<c:out value="${passwordIncludeUpperCase}" />" />
	<input type="hidden" id="passwordIncludeSpecialChar" name="passwordIncludeSpecialChar" value="<c:out value="${passwordIncludeSpecialChar}" />" />
	<smvc:errors />
	<br />&nbsp;

	<table align="center" width="750px">
		<tr>
			<td>
			<fieldset class="nobg"><legend>Change Password</legend>

				<c:if test="${msg ne null}">
					<span class="info"><c:out value="${msg}"/></span>
				</c:if>
				<c:if test="${errors ne null}">
					<span class="error"><c:out value="${errors}"/></span>
				</c:if>
				<c:if test="${userForm.errors ne null}">
					<span class="error"><c:out value="${userForm.errors}"/></span>
				</c:if>


				<table cellspacing="10" width="100%">
				<tr>
					<td valign="top"   >
					<fieldset>

						<table>
						<c:if test="${userForm.loginUserIsEditingUser eq 'yes'}">
							<tr>
								<td class="label">Current Password&nbsp;<span class="mandatory">*</span></td>
								<td class="input">
									<smvc:password path="currentPass" id="currentPass" autocomplete="false"/>
								</td>
							</tr>
							</c:if>
						<tr id="noStrngPwdId">
							<td class="label">Enter New Password&nbsp;<span class="mandatory">*</span></td>
							<td class="input"><smvc:password cssStyle="password" title="${passwordStrengthMessage}"
								path="pass1" id="password1" onkeyup="passwordStrength(this.value);" onkeydown="passwordStrength(this.value);"  autocomplete="false" /><br/>
							</td>
						</tr>
						<tr>
							<td class="label">Confirm Password&nbsp;<span class="mandatory">*</span> </td>
							<td class="input">
							<smvc:password cssStyle="password" path="pass2"  autocomplete="false" />
							</td>
						</tr>
						<tr id="pwdStrength">
							<td class="label"></td>
							<td class="input"> <span style="color: red; font-weight: bold;" id="passwordDescription"></span>
							</td>
						</tr>
					</table>
					</fieldset>
					</td>
				</tr>
			</table>
			<fieldset class="buttonFieldset">
				<input type="button" id="back" value="Back" onclick="document.location.href ='userform.form?userId=<c:out value="${userForm.user.guid}"/>'" /> 
				<input type="Submit" id="Save" value="Save Password"  />
			</fieldset>
			</fieldset>

			</td>
		</tr>
	</table>
</smvc:form>
<div id="backgroundPopup" class="backgroundPopup"></div>
<script type="text/javascript">

</script>
</body>
</html>