<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>

<html>

<head>
	<title>Cronos</title>
	<link rel='stylesheet' href='./css/cronos.css' type='text/css'>
	<link type="image/x-icon" href="./images/favicon.ico"
		rel="shortcut icon">
</head>

<body onLoad="cargarBotones()" vertical-align:
	center; padding: 0px;"
	background="images/fondo-v3.jpg">

	<html:form action='/login?method=login'>

		<table height="100%" width="100%" border="0" cellpadding="0"
			cellspacing="0">
			<tr>
				<td><logic:messagesPresent message="false">
						<jsp:include page="layoutMensajes.jsp" />
					</logic:messagesPresent>
					<div align="center" valign="center">
						<table style="background-color: #00adef;" border="0"
							cellpadding="0" cellspacing="0" width="50%">
							<tr height="100px">
								<td colspan="3" style="background-color: #415B6C;"
									align="center"><img src="images/logo-login.jpg" border=0></td>
							</tr>
							<tr>
								<td><table border="0"
										cellpadding="0" cellspacing="0" width="100%">
										<tr>
											<td align="right" width="25%">&nbsp;</td>
											<td>
												<table
													style="background-position: center; width: 100%;"
													border="0" cellpadding="0" cellspacing="0">
													<tr>
														<td></td>
														<td><table class="its mitad" width="80%" border="0"
																border="0" cellpadding="0" cellspacing="4">

																<html:hidden property="method" value="login" />

																<tr height="50px">
																	<td style="font-size: 4px" colspan="3" valign="top"
																		align="center">&nbsp;</td>
																</tr>

																<tr class="even">
																	<td align="right" class="mitad"
																		style="text-transform: uppercase"><b><bean:message
																				key="login.nombre_usuario" /></b></td>
																	<td>&nbsp;</td>
																	<td align="center"><html:text
																			style="width: 110px;" property="login"
																			onkeypress="checkEnter(event, 1)" /></td>
																</tr>

																<tr class="even">
																	<td align="right" class="mitad"
																		style="text-transform: uppercase"><b><bean:message
																				key="login.clave" /></b></td>
																	<td>&nbsp;</td>
																	<td align="center"><html:password
																			style="width: 110px;" property="clave"
																			onkeypress="checkEnter(event, 2)" /></td>
																</tr>
															</table></td>
														<td></td>
													</tr>
												</table>
											</td>
											<td align="left" width="25%">&nbsp;</td>
										</tr>
										<tr>
											<td valign="bottom" style="font-size: 6px;">&nbsp;</td>
											<td valign="middle" align="center"></td>
											<td valign="bottom"></td>
										</tr>
										<tr>
											<td valign="bottom">&nbsp;</td>
											<td valign="bottom" align="center"><div id="botones"></div></td>
											<td valign="bottom">&nbsp;</td>
										</tr>
										<tr>
											<td valign="bottom" align="center"><img
												src="images/logo-cronos-pie-izq.jpg" /></td>
											<td valign="middle" align="center"></td>
											<td valign="bottom" class="mitad"
												style="text-transform: uppercase" align="center">&nbsp;</td>
										</tr>
										<tr height="10px">
											<td style="font-size: 4px" colspan="3" valign="top"
												align="center">&nbsp;</td>
										</tr>
									</table></td>
							</tr>
						</table>
					</div></td>
			</tr>
		</table>
	</html:form>
</body>
</html>

<script>
	function formSubmit() {
		this.document.forms[0].submit();
	}

	function cargarBotones() {
		bot = document.getElementById('botones');
		bot.innerHTML = '<input class=\'estiloBoton\' type=\'button\' name=\'aceptar\' value=\'<bean:message key="form.enviar"/>\' onclick="formSubmit()">';
		document.forms[0].login.focus();
	}

	function checkEnter(evt, pos) {

		if (evt) {
			var charCode = (evt.charCode) ? evt.charCode : evt.keyCode;
			if (charCode == 13) {
				if (pos == '1' && document.forms[0].clave.value == "")
					document.forms[0].clave.focus();
				else {
					if (document.forms[0].login.value != "" && document.forms[0].clave.value != "")
						formSubmit();
				}
			}
		}
	}
</script>

<%
request.getSession().invalidate();
request.getSession(false);
%>