<%@include file="include/xop,header.jsp"%>
<%
response.setDateHeader("Expires", -1);
response.setHeader("Pragma","no-cache");
response.setHeader("Cache-Control","no-cache");
%>
<%
// Create data access object.
AdminLoginDao dao = new AdminLoginDao(request);

// Action.
String actionFlag = paramString("actionFlag");
if(actionFlag.equals("logout")){
	dao.logout();
}
if(actionFlag.equals("login")){
	if(dao.login(paramString("uname"), paramString("passwd"))){

		if(isAdmin()){
			// Start page for admin.
			response.sendRedirect("dashboard.jsp");
		}
		else{
			// Start page for operator.
			response.sendRedirect("zop,dashboard.jsp");
		}

		return;
	}
}
%>

<div class="login-page">
<form method="post" action="<%= getPageName()%>">
<input type="hidden" name="actionFlag" value="login">

<table cellspacing="0" cellpadding="4" bgcolor="#FFFFFF" width="320">

	<tr height="25">
		<td colspan="2" style="background-color: #A64D79; color: #FFFFFF; font-size: 9pt;">ADMIN LOGIN</td>
	</tr>

	<tr height="5">
		<td colspan="2"></td>
	</tr>

	<tr>
		<td width="100">&nbsp;Username</td>
		<td><input type="text" name="uname"></td>
	</tr>

	<tr>
		<td>&nbsp;Password</td>
		<td><input type="password" name="passwd" onkeypress="javascript:if(event.keyCode == 13){this.form.submit(); return;}"></td>
	</tr>

<%if(dao.isFirstLogin()){%>
	<tr>
		<td colspan="2">
			&nbsp;&nbsp;<span class="warning">Initial username and password : admin/admin</span>
		</td>
	</tr>
<%}%>

	<tr>
		<td></td>
		<td>
			<input type="button" value="LOGIN" onclick="javascript:this.form.submit();">
			<input type="button" value="SIGNUP" onclick="javascript:location.href='signup.jsp';"><br>
		</td>
	</tr>

	<tr height="5">
		<td colspan="2"></td>
	</tr>

</table>
</div>

<%@include file="include/xop,footer.jsp"%>
