<html>
<%@ page errorPage="Error.jsp" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html-1.0.2" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean-1.0.2" prefix="bean" %>
<%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/utiltaglib.tld" prefix="util" %>

<%-- Include common page header with navigation bar and "select" FAQ tab --%>
<c:set var="tab" value="faq"/>
<%@ include file="header.jsp" %>

<%-- Struts form using Sruts HTML tags --%>
<html:form action="/faq.do?action=save">
<%-- Only display ID if ID is not 0 (meaning object does exist) --%>
<c:if test="${FAQForm.id != 0}">
   <b><bean:message key="faq.id"/> </b><bean:write name="FAQForm" property="id"/>
   <html:hidden property="id"/>
</c:if>

<br><br><bean:message key="faq.selectAreasAndTopics"/>
<br><br>
<table>
   <tr>
      <td><b><bean:message key="faq.areas"/></b></td>
      <td><b><bean:message key="faq.topics"/></b></td>
   </tr>

<%int i=0;%>
<%-- Use JSTL to loop through all Areas stored in Struts form --%>
<c:forEach items="${FAQForm.areas}" var="area" varStatus="status">
   <tr>
      <td>
         <html:checkbox property="<%=\"areaFlag[\"+i+\"]\"%>" value="true"/>
         <bean:write name="FAQForm" property="<%=\"areas[\"+i+\"].areaDesc\"%>"/>
      </td>
      <td>
         <bean:define name="FAQForm" id="areaTopics" property="<%=\"topics[\"+i+\"]\"%>"/>
         <html:select property="<%=\"topicID[\"+i+\"]\"%>">
            <html:options collection="areaTopics" property="topicID" labelProperty="topicDesc"/>
         </html:select>
      </td>
   </tr>
<%i++;%>
</c:forEach>
</table>

<br>
<table>
   <tr valign=TOP>
      <td align=LEFT><b><bean:message key="faq.internalFlag"/></b></td>
      <td align=LEFT><html:checkbox property="internalFlag" value="true"/></td>
   </tr>
   <tr valign=TOP>
      <td align=LEFT><b><bean:message key="faq.productVersion"/></b></td>
      <td align=LEFT><html:text property="productVersion" size="10" maxlength="10"/></td>
   </tr>
</table>

<br>
<b><bean:message key="faq.question"/></b>
<%-- Include editor page in "question" mode for FAQ question --%>
<c:set var="editor" value="question"/>
<%@ include file="editor.jsp" %>

<br>
<b><bean:message key="faq.answer"/></b>
<%-- Include editor page in "answer" mode for FAQ answer --%>
<c:set var="editor" value="answer"/>
<%@ include file="editor.jsp" %>

<%--
   Use JSTL to determine if client browser is MSFT IE.
   In case of MSFT IE use MS-HTML Rich-Text editor results triggered by onclick event.
   See editor.jsp for more details.
--%>
<c:choose>
   <c:when test="${IE}">
      <c:set var="onclick" value="question.value=div_question.innerHTML; answer.value=div_answer.innerHTML;"/>
   </c:when>
   <c:otherwise>
      <c:set var="onclick" value=""/>
   </c:otherwise>
</c:choose>
<html:submit onclick="<%=pageContext.getAttribute(\"onclick\")%>"><bean:message key="button.save"/></html:submit>
<html:reset><bean:message key="button.reset"/></html:reset>
</html:form>

<br>
<b><a href="<bean:message key="navigation.faq.query.list"/>">
   <bean:message key="faq.link.query.list"/></a></b>

<%-- Include common page footer with Last Modified timestamp --%>
<%@ include file="footer.jsp" %>
</html>

