<%@ page import="com.fenalco.entities.User" %>
<%@ page import="com.fenalco.entities.DataAccess"%>
<%@ page import="java.util.Hashtable"%>
<%@ page import="java.util.Enumeration"%>
<%@ page import="com.fenalco.entities.Section" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel='stylesheet' style='text/css' href='../css/tablas.css'>
<title>Modificar secci&oacute;n</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#ffffff" background="../images/sysmanager/general/fondo.jpg" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<script language='javascript' type='text/javascript' src='../js/library.js'></script>
<script>
    
    function validateForm(formName){
    
        var message = "Han ocurrido los siguientes errores:\n";
        var flag = true;
        var flag2 = true;

                                    
        
        if(isEmpty(formName.name)){
            message = message + "- El campo nombre está vacío.\n";
            flag = false;
        }
        
        
        if(isEmpty(formName.email)){
                message = message + "- El campo de email está vacío.\n";
                flag = false;
        }
        else{

            if( !validEmail(formName.email.value)){
                    message = message + "- La dirección de email no es válida.\n";
                    flag = false;
            }
       }
        
        if(!flag){
                    window.alert(message);
        }
       
        
        
        return flag;
    }
  
     function submitCombo(comboName){
                document.updateSection.action = "administrarsecciones";
                document.updateSection.submit();
                return true;
        }
</script>

<table border="0" cellpadding="0" cellspacing="0" width="780">
        <%
            String helpId = "23";
        %>
        <%@ include file="encabezado.jsp" %>
</table>

<table width="760">
	<tr>
		<td width="152" valign='top'>
			<%@ include file="menuadministrador.jsp" %>
		</td>
		<td valign='top'>
            <%
                String tittle = "Modificar Secci&oacute;n";
            %>
            <%@ include file="/titulo.jsp" %>

			<table width="603">
			<tr><td align="center"><%= request.getAttribute("message")%></td></tr>
			<% Section section = (Section)request.getAttribute("section"); %>
			<% request.getSession().setAttribute("sectionId",Integer.toString(section.getId())); %>			
			<tr>
			<form name="updateSection" method="post" action="/administrador/administrarsecciones" onSubmit='return validateForm(document.newSection)';>
				<table align="center">
					<tr><td height='10'></td></tr>
			<tr>
				<td>Nombre</td>
				<td><input type="text" name="name" maxlength="50" value="<%=section.getName()%>"></td>
				<!-- JS: Verificación de campo vacío, Campo Obligatorio-->	
			</tr>
			<tr>
				<td>Contenido</td>
				<td><textarea name="content" cols='30' rows='10'><%=section.getContent()%></textarea></td>
				<!-- JS: Verificación de campo vacío, Campo Obligatorio-->	
			</tr>
			<tr>
				<td>Email</td>
				<td><input type="text" name="email" maxlength="30" value="<%=section.getEmail()%>"></td>
				<!-- JS: Verificación de campo vacío, Campo Obligatorio, Correo Eléctrónico-->	
			</tr>
			<tr><td height='10'></td></tr>
                        </table>
				<table align="center">
					<tr>
						<td colspan="2" align="center"><input type="submit" name="enviar" value="Aceptar"></td>
						<!-- 
						El evento onClick inicia la verificación del formulario llamando a la función
						validateForm().
						-->
					</tr>
				</table>
                                <input name="operationType" type="hidden" value="update">
                                <input name="key" type="hidden" value="<%=section.getId()%>">
			</form>			
				</tr>
			<tr>
                        <form method='post' action="/administrador/cargarimagenseccion" enctype='multipart/form-data'> 
                            <table align="center">
                            <tr><td colspan='3'><hr></td></tr>
                            <tr><td height='10'></td></tr>
                            <tr>
                                <td><strong>Url Imagen</td>
                                <td><input type="file" name="image" value='<%=section.getImage()%>'></td>
                            </tr>
                            <tr><td height='10'></td></tr>
                            <tr>
                                <td colspan='3' align="center"><input type='submit' value='Cargar imagen'></td>
                                 <!-- JS: Verificación de campo vacío, Campo Obligatorio-->	
                             </tr>
                            </table>
                        </form>
			</tr>	
			</table>
		</td>
	</tr>
	
</table>
<table width="760">
	<tr>
		<td><%@ include file="/piepagina.jsp" %></td>
	</tr>
</table>

</body>
</html>