<%@ include file="/includes.jsp" %>
<style>
.inputstyle {
border-top:0px solid #dadada;
border-right:2px solid #000000;
border-left:2px solid #000000;
border-bottom: 2px solid #000000;
}
</style>
<script>
function submitForm(){
	var result=validate();
	if(result)
	document.getElementById('loginapplication').submit();
}
function validate(){
	if(document.getElementById('email').value.length<=0){
		alert('Please enter a valid email address.');
		document.getElementById('email').focus();
		return false;
	}else{
		var validemail=validateEmailId(document.getElementById('email').value);
		if(!validemail){
			alert('Please enter a valid email address.');
			document.getElementById('email').focus();
			return false;
		}
	}
	return true;
}
 function validateEmailId(str) {
        var at="@"
        var dot="."
        var lat=str.indexOf(at)
        var lstr=str.length
        var ldot=str.indexOf(dot)
        if (str.indexOf(at)==-1){
           return false
        }
        if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
           return false
        }
        if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
            return false
        }
        if (str.indexOf(at,(lat+1))!=-1){
            return false
        }
        if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
            return false
        }
        if (str.indexOf(dot,(lat+2))==-1){
            return false
        }
        if (str.indexOf(" ")!=-1){
            return false
        }
        return true                    
    }
</script>

<form action="loginapplication.form" id="loginapplication" method="post">
	<table class="dialogBox" width="50%">
		<tr>
			<td colspan="2" class="dialogTitle">Request Ardeo eMDT Login Account</td>
		</tr>
		<tr height="25px"  valign="bottom">
			<td  colspan="2"><b><font size="3">&nbsp;Apply for login...</font></b></td>
		</tr>
	    <c:choose>
	    <c:when test="${message ne null and  message eq 'success'}">
		    <tr>
				<td colspan="2"><br/><b>&nbsp;&nbsp;An email with link to request a Login Account has been sent to the address provided. <br/>
				&nbsp;&nbsp;If an email doesn't arrive shortly, 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 style="padding-left: 10px;"><font size="2">To continue, please enter your name  and email address and click the 'Apply'<br/>&nbsp; button to receive a confirmation email with the link to Create a login Account.</font></td>
			</tr>
			<tr height="60px" valign="top" >
				<td style="padding-left: 30px;">
					<div style="vertical-align: text-top;">
					<font size="2"><b>Enter your name &nbsp;&nbsp;</b></font>
					<input type="text" id="name" name="name" size="20">&nbsp;<br/><br/>
					<font size="2"><b>Enter your email address &nbsp;&nbsp;</b></font>
					<input type="text" id="email" name="email" size="40">&nbsp;
					<button onclick="submitForm();">Apply</button>
					<br/><br/>
					</div>
				</td>
			</tr>	
		 </c:otherwise>
	   </c:choose>
	</table>
</form>