<%@ include file="/includes.jsp" %>
<script>
function setRadio(){
	var email = document.getElementById('radio1').checked; 
	var username = document.getElementById('radio2').checked; 
	if(email){
		document.getElementById('forgotusernameInput').style.display='none';
		document.getElementById('forgotemailInput').style.display='block';
	}else if(username){
		document.getElementById('forgotemailInput').style.display='none';
		document.getElementById('forgotusernameInput').style.display='block';
	}
}
window.onload = function(){
	setRadio();
}
function submitForm(){
	var result=validate();
	if(result)
	document.getElementById('requestpasswordform').submit();
}
function validate(){
	var email = document.getElementById('radio1').checked; 
	var username = document.getElementById('radio2').checked; 
	if(email){
		if(document.getElementById('forgotemail').value.length<=0){
			alert('email Id cannot be empty');
			document.getElementById('forgotemail').focus();
			return false;
		}
	}else if(username){
		if(document.getElementById('forgotusername').value.length<=0){
			alert('user name cannot be empty');
			document.getElementById('forgotusername').focus();
			return false;
		}
	}
	return true;
}
</script>

<form action="requestpassword.form" id="requestpasswordform" method="post">
	<table class="dialogBox" >
		<tr>
			<td colspan="2" class="dialogTitle">Ardeo eMDT Password Assistance</td>
		</tr>
		<tr height="25px"  valign="bottom">
			<td  colspan="2"><b><font size="3">&nbsp; Forgot Your Password...</font></b></td>
		</tr>
	    <c:choose>
	    <c:when test="${message ne null and  message eq 'success'}">
		    <tr>
				<td colspan="2"><br/><b>&nbsp;&nbsp;A password request email has been sent to the address provided. If an email doesn't  arrive shortly,<br/>&nbsp;&nbsp; please check your spam folder.</b><br/><br/><br/></td>
			</tr>
	    </c:when>
	    <c:otherwise>
	         <c:if test="${errorMsg ne null}">
				<td colspan="2"><div class="error"><img src="images/16x16/error.png" alt="!" border="0"/>&nbsp;&nbsp;<c:out value="${errorMsg}"/></div></td>
			</c:if>
			<tr height="60px">
				<td colspan="2"><font size="2">&nbsp; Enter Username or email address associated with your account, and click Continue to receive an email <br/>&nbsp; with the link to reset your password.</font></td>
			</tr>
				<tr height="30px">
				<td width="40%">
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input type="radio" name="checkBy"  id="radio2" value="username" checked="checked" onchange="setRadio();" /> 
					<label for="forgotusername"><strong>I remember my Username:</strong></label> 
				</td>
				<td id="forgotusernameInput" style=":display: none;"><input type="text" size="35" name="username" id="forgotusername" /></td>
			</tr>
			<tr height="30px">
				<td width="40%">
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<input type="radio" value="email" name="checkBy" id="radio1" onchange="setRadio();" /> 
					<label for="forgotemail"><strong>I remember my email address:</strong></label>
				</td>
				<td id="forgotemailInput" style=":display: none;" ><input type="text" name="email" size="35" id="forgotemail" /></td>
			</tr>
			<tr height="30px">
				<td colspan="2" class="input" align="right">
					<img src="images/16x16/continue.png" onclick="submitForm();"/>
					&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;
				</td> 
			</tr>
		 </c:otherwise>
	   </c:choose>
	</table>
</form>