<?xml version="1.0" encoding="UTF-8"?>
<?page contentType="text/html;charset=UTF-8"?>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="winLogin"?>
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>

<zk xmlns="http://www.zkoss.org/2005/zul"
	xmlns:h="http://www.w3.org/1999/xhtml"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:w="http://www.zkoss.org/2005/zk/client"
	xsi:schemaLocation="http://www.zkoss.org/2005/zul">

	<window id="winLogin" title="${c:l('winLogin.title')}" apply="${loginController}"
		border="normal" width="400px" closable="false" position="center"
		mode="overlapped" onCreate="u.focus()">

		<h:form id="f" name="f" action="j_spring_security_check"
			method="POST" xmlns:h="http://www.w3.org/1999/xhtml">
			<grid w:onOK="validate()">
				<rows>
					<row align="left">
						<label value="${c:l('winLogin.lblUsuario')}" />
						<hbox align="center">
							<image src="/gui/img/user24.png" />
							<textbox id="u" name="j_username"
								constraint="no empty"
								use="com.rjconsultores.ventaboletos.web.utilerias.MyTextbox" />
						</hbox>
					</row>
					<row align="left">
						<label value="${c:l('winLogin.lblSenha')}" />
						<hbox align="center">
							<image src="/gui/img/pass24_4.png" />
							<textbox id="p" type="password"
								name="j_password"  />
						</hbox>
					</row>
					<row spans="2" align="center">
						<hbox align="center">
							<h:input type="button" name="btnAcessar"
								value="${c:l('winLogin.btnAcessar')}" w:onClick="validate()" />
								
							<button id="btnRecuperarSenha" label="Recuperar Senha" />
						</hbox>
					</row>
				</rows>
			</grid>
		</h:form>
		<script type="text/javascript">
			function validate() { var pwd = jq('$p').val() == ''; var
			name = jq('$u').val() == '';


			var ok = 1;

			if (name == true){ ok = 0; } if (pwd == true){ ok = 0; }

			if(ok == 1){ jq('$f').submit(); } }
		</script>
		<zscript>
		
	Exception exep = Executions.getCurrent().getSession().getAttribute(org.springframework.security.web.authentication.AbstractProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY);
	if (exep != null) {
		if (exep instanceof org.springframework.security.authentication.CredentialsExpiredException) {
				com.rjconsultores.ventaboletos.web.utilerias.PantallaUtileria.openWindow("/gui/seguridad/cambiaContrasena.zul", 
						org.zkoss.util.resource.Labels.getLabel("winCambiaContrasena.title"), new HashMap(), 2);
				
		} else {
			Clients.alert(org.zkoss.util.resource.Labels.getLabel("winLogin.lblloginIncorreto"),
					org.zkoss.util.resource.Labels.getLabel("winLogin.title"), Messagebox.INFORMATION);
		}

	}
</zscript>
	</window>
</zk>