<%@ page language="java" buffer="64kb" %>

<%@ taglib uri="struts-html"     prefix="html"  %>
<%@ taglib uri="struts-bean"     prefix="bean"  %>
<%@ taglib uri="struts-logic"    prefix="logic" %>
<%@ taglib uri="vkc-taglib"      prefix="vkc"   %>

<%@ page import="org.apache.struts.Globals" %>

<script type="text/javascript">
function showQueryHelpText() {
	var text = '<vkc:message javascript="true" filter="false" key="vkc.search.help"/>';
    
    return overlib( text, STICKY, SCROLLBARS, MOUSEOFF, HEIGHT, 250, WIDTH, 600, OFFSETX, 0, OFFSETY, 20, CENTER );
}
</script>

<table width="100%" cellpadding="0" cellspacing="0" border="0">

  <bean:define id="form"  name="form" scope="request"/>
  
  <html:hidden property="query.queryId"/>
  <html:hidden property="query.selectedCategoryId"/>

  <tr>
    <td align="left" nowrap="nowrap">
      <table cellspacing="0" cellpadding="2" border="0">
        <tr>
          <td align="left"> 
           <b><vkc:message key="vkc.searchquery.define" /></b>
          </td>
          <td align="rigth">
            <vkc:img page="/templates/${template.name}/gfx/help.bmp" onmouseover='return showQueryHelpText();' onmouseout="return nd();" width="16" height="16" border="0"/>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <vkc:hline bottomSpace="0" topSpace="0" colspan="2" lineClass="hline" lineHeight="1"/>
  <tr>
    <td nowrap="nowrap">
      <table width="100%" cellspacing="0" cellpadding="2" border="0">
	    <tr>
          <td nowrap="nowrap">
	        <table cellspacing="0" cellpadding="2" border="0">
	          <logic:present name="<%=Globals.ERROR_KEY%>">
	          <tr><td align="left" nowrap="nowrap" colspan="5"><font color="red"><b><vkc:errors/></b></font></td></tr>
	          </logic:present>
              <tr>
                <td nowrap="nowrap"><vkc:message key="vkc.search.searchFor"/></td>
                <td nowrap="nowrap"><b><vkc:message key="vkc.search.searchInAnyField"/></b></td>
	            <td width="100%"><vkc:text name="form" property="query.searchInAnyField" style="width:99%;"/></td>
	            <td nowrap="nowrap">&nbsp;</td>
		      </tr>
	          <tr>
       	        <td nowrap="nowrap">&nbsp;</td>
 		        <td nowrap="nowrap"><b><vkc:message key="vkc.search.searchInFullText"/></b></td>
		        <td width="100%"><vkc:text name="form" property="query.searchInFullText" style="width:99%;"/></td>
 		        <td nowrap="nowrap">&nbsp;</td>
              </tr>
	          <tr>
       	        <td nowrap="nowrap">&nbsp;</td>
 		        <td nowrap="nowrap"><b><vkc:message key="vkc.search.searchForDynaAttributeNames"/></b></td>
		        <td width="100%"><vkc:text name="form" property="query.searchForDynaAttributeNames" style="width:99%;"/></td>
 		        <td nowrap="nowrap">&nbsp;</td>
              </tr>
    	      <tr>
                <td nowrap="nowrap">&nbsp;</td>
     	        <td nowrap="nowrap"><b><vkc:message key="vkc.search.searchForDynaAttributeValues"/></b></td>
    		    <td width="100%"><vkc:text name="form" property="query.searchForDynaAttributeValues" style="width:99%;"/></td>
     		    <td nowrap="nowrap">&nbsp;</td>
	          </tr>
    	      <tr>
                <td nowrap="nowrap">&nbsp;</td>
     		    <td nowrap="nowrap"><b><vkc:message key="vkc.search.searchForFilename"/></b></td>
    		    <td width="100%"><vkc:text name="form" property="query.searchForFilename" style="width:99%;"/></td>
     		    <td nowrap="nowrap">&nbsp;</td>
	          </tr>
    	      <tr>
                <td nowrap="nowrap">&nbsp;</td>
     		    <td nowrap="nowrap"><b><vkc:message key="vkc.search.searchForTitle"/></b></td>
    		    <td width="100%"><vkc:text name="form" property="query.searchForTitle" style="width:99%;"/></td>
     		    <td nowrap="nowrap">&nbsp;</td>
	          </tr>
	          <tr>
	            <td nowrap="nowrap">&nbsp;</td>
	            <td nowrap="nowrap"><b><vkc:message key="vkc.search.searchForKeywords"/></b></td>
	            <td width="100%"><vkc:text name="form" property="query.searchForKeywords" style="width:99%;"/></td>
	            <td nowrap="nowrap">&nbsp;</td>
	          </tr>
	          <tr>
	            <td nowrap="nowrap">&nbsp;</td>
	            <td nowrap="nowrap"><b><vkc:message key="vkc.search.searchForDescription"/></b></td>
	            <td width="100%"><vkc:text name="form" property="query.searchForDescription" style="width:99%;"/></td>
	            <td nowrap="nowrap">&nbsp;</td>
	          </tr>
	          <tr>
	            <td nowrap="nowrap">&nbsp;</td>
	            <td nowrap="nowrap"><b><vkc:message key="vkc.search.searchForAuthor"/></b></td>
	            <td width="100%"><vkc:text name="form" property="query.searchForAuthor" style="width:99%;"/></td>
	            <td nowrap="nowrap">&nbsp;</td>
	          </tr>
	          <tr>
	            <td nowrap="nowrap">&nbsp;</td>
	            <td nowrap="nowrap"><b><vkc:message key="vkc.search.searchForPublisher"/></b></td>
	            <td width="100%"><vkc:text name="form" property="query.searchForPublisher" style="width:99%;"/></td>
	            <td nowrap="nowrap">&nbsp;</td>
	          </tr>
	      
	          <logic:notEmpty name="form" property="query.addDocAttributes">
              <logic:iterate id="fieldName" indexId="fieldCtr" name="form" property="query.addDocAttributeKeys" type="java.lang.String">
	          <tr>
	            <td nowrap="nowrap">&nbsp;</td>
	            <td nowrap="nowrap"><b><vkc:message key="vkc.search.for"/>&nbsp;<vkc:write name="form" property='<%= String.valueOf( "query.attributeKeyName(" + fieldName + ")" ) %>'/></b></td>
	            <td width="100%"><vkc:text name="form" property='<%= String.valueOf( "query.addDocAttrValue(" + fieldName + ")" ) %>' style="width:99%;"/></td>
	            <td nowrap="nowrap">&nbsp;</td>
	          </tr>
	          </logic:iterate>
              </logic:notEmpty>
          
              <logic:equal name="categorySettings" property="showCreationDate" value="true">
              <tr>
                <td nowrap="nowrap">&nbsp;</td>
                <td nowrap="nowrap"><b><vkc:message key="vkc.search.for"/>&nbsp;<vkc:message key="vkc.search.creationdate"/>&nbsp;<vkc:message key="vkc.search.from"/></b></td>
                <td width="100%">
                  <table cellpadding="0" cellspacing="0" border="0">
                    <tr>
                      <td nowrap="nowrap"><html:text property="query.searchForCreationDateFrom" maxlength="10" size="10" styleClass="dateField"/></td>
                      <td nowrap="nowrap"><vkc:calendarbutton buttonName="btn_query.searchForCreationDateFrom" /></td>
                      <td nowrap="nowrap">&nbsp;[<vkc:message key="vkc.profile.date_format"/>]</td>
                      <td nowrap="nowrap">&nbsp;&nbsp;&nbsp;</td>
                      <td nowrap="nowrap"><b><vkc:message key="vkc.search.until"/></b></td>
                      <td nowrap="nowrap">&nbsp;</td>
                      <td nowrap="nowrap"><html:text property="query.searchForCreationDateUntil" maxlength="10" size="10" styleClass="dateField"/></td>
                      <td nowrap="nowrap"><vkc:calendarbutton buttonName="btn_query.searchForCreationDateUntil" /></td>
                      <td nowrap="nowrap">&nbsp;[<vkc:message key="vkc.profile.date_format"/>]</td>
                    </tr>
                  </table>
                </td>
                <td nowrap="nowrap">&nbsp;</td>
              </tr>
              </logic:equal>

              <logic:equal name="categorySettings" property="showDocumentClass" value="true">
	          <tr>
	            <td nowrap="nowrap">&nbsp;</td>
	            <td nowrap="nowrap"><b><vkc:message key="vkc.search.for"/>&nbsp;<vkc:message key="vkc.search.document.class"/></b></td>
	            <td width="100%">
	              <html:select name="form" property="query.selectedDocClassId">
		            <html:option value="-1">&nbsp;</html:option>
		            <html:option value="*"><vkc:message key="vkc.search.docClassId.all" /></html:option>
	                <logic:iterate id="documentClass" name="form" property="query.documentClasses" type="vkc.db.entities.VKCDocumentClass">
	                <html:option value="<%=String.valueOf( documentClass.getDocClassId() )%>"><vkc:message name="documentClass" property="nameKey"/></html:option>
	                </logic:iterate>
	              </html:select>
	            </td>
	            <td nowrap="nowrap">&nbsp;</td>
	          </tr>
              </logic:equal>
	      
	          <logic:equal name="categorySettings" property="showDocumentStatus" value="true">
	          <tr>
	            <td nowrap="nowrap">&nbsp;</td>
	            <td nowrap="nowrap"><b><vkc:message key="vkc.search.for"/>&nbsp;<vkc:message key="vkc.search.document.status"/></b></td>
	            <td width="100%">
	              <html:select name="form" property="query.selectedDocStatusId">
		            <html:option value="-1">&nbsp;</html:option>
		            <html:option value="*"><vkc:message key="vkc.search.docStatusId.all" /></html:option>
	                <logic:iterate id="documentStatus" name="form" property="query.documentStatus" type="vkc.db.entities.VKCDocumentStatus">
	                <html:option value="<%=String.valueOf( documentStatus.getStatus() )%>"><vkc:message name="documentStatus" property="descriptionKey"/></html:option>
	                </logic:iterate>
	              </html:select>
	            </td>
	            <td nowrap="nowrap">&nbsp;</td>
	          </tr>
              </logic:equal>
	      
	          <tr>
	            <td nowrap="nowrap">&nbsp;</td>
	            <td nowrap="nowrap">&nbsp;</td>
	            <td align="left" colspan="2"><vkc:message key="vkc.search.keyconnection"/></td>
	          </tr>
	          <tr>
		        <td colspan="4">&nbsp;</td>
		      </tr>

	          <logic:notPresent parameter="hidePubDate">
	          <tr>
                <td nowrap="nowrap"><vkc:message key="vkc.search.restrict"/></td>
                <td nowrap="nowrap"><b><vkc:message key="vkc.search.for"/>&nbsp;<vkc:message key="vkc.search.publication"/>&nbsp;<vkc:message key="vkc.search.from"/></b></td>
	            <td width="100%">
	              <table cellpadding="0" cellspacing="0" border="0">
	                <tr>
	                  <td nowrap="nowrap"><html:text property="query.validFrom" maxlength="10" size="10" styleClass="dateField"/></td>
                      <td nowrap="nowrap"><vkc:calendarbutton buttonName="btn_query.validFrom" /></td>
	                  <td nowrap="nowrap">&nbsp;[<vkc:message key="vkc.profile.date_format"/>]</td>
	                  <td nowrap="nowrap">&nbsp;&nbsp;&nbsp;</td>
	                  <td nowrap="nowrap"><b><vkc:message key="vkc.search.until"/></b></td>
	                  <td nowrap="nowrap">&nbsp;</td>
	                  <td nowrap="nowrap"><html:text property="query.validUntil" maxlength="10" size="10" styleClass="dateField"/></td>
                      <td nowrap="nowrap"><vkc:calendarbutton buttonName="btn_query.validUntil" /></td>
	                  <td nowrap="nowrap">&nbsp;[<vkc:message key="vkc.profile.date_format"/>]</td>
	                </tr>  
	              </table>
	            </td>
	            <td nowrap="nowrap">&nbsp;</td>
		      </tr>
              <tr>
                <td nowrap="nowrap">&nbsp;</td>
                <td nowrap="nowrap"><b><vkc:message key="vkc.search.to"/>&nbsp;<vkc:message key="vkc.search.categorypath"/></b></td>
	            <td width="100%">
	              <table width="100%" cellpadding="0" cellspacing="0" border="0">
	                <tr>
	                  <td nowrap="nowrap"><vkc:image page="/templates/${template.name}/gfx/navigator.gif" property="btn_explorer" onclick="this.blur();return showExplorer();" titleKey="vkc.string.show.explorer"/></td>
	                  <td nowrap="nowrap">&nbsp;</td>
	                  <td width="100%"><vkc:write name="form" property="query.categoryPath"/></td>
	                </tr>  
	              </table>
	            </td>
	            <td nowrap="nowrap">&nbsp;</td>
		      </tr>
	          <tr>
	            <td nowrap="nowrap">&nbsp;</td>
	            <td nowrap="nowrap"><b><vkc:message key="vkc.search.for"/>&nbsp;<vkc:message key="vkc.search.searchResultLimitation"/></b></td>
	            <td width="100%">
          	      <bean:define id="documentTypes" name="form" property="query.documentTypes"/>
	              <html:select property="query.selectedResultLimitation" size="1">
		            <html:option value="*"><vkc:message key="vkc.search.searchResultLimitation.noLimitation" /></html:option>
          		    <vkc:options collection="documentTypes" property="extension" labelProperty="extensionLabel"/>
		          </html:select>
	            </td>
	            <td nowrap="nowrap">&nbsp;</td>
	          </tr>
		      </logic:notPresent>
	      
	          <logic:present parameter="hidePubDate">
              <tr>
                <td nowrap="nowrap"><vkc:message key="vkc.search.restrict"/></td>
                <td nowrap="nowrap"><b><vkc:message key="vkc.search.to"/>&nbsp;<vkc:message key="vkc.search.categorypath"/></b></td>
	            <td width="100%">
	              <table width="100%" cellpadding="0" cellspacing="0" border="0">
	                <tr>
	                  <td nowrap="nowrap"><vkc:image page="/templates/${template.name}/gfx/navigator.gif" property="btn_explorer" onclick="this.blur();return showExplorer();" titleKey="vkc.string.show.explorer"/></td>
	                  <td nowrap="nowrap">&nbsp;</td>
	                  <td width="100%"><vkc:write name="form" property="query.categoryPath"/></td>
	                </tr>  
	              </table>
	            </td>
	            <td nowrap="nowrap">&nbsp;</td>
		      </tr>
	          <tr>
	            <td nowrap="nowrap">&nbsp;</td>
	            <td nowrap="nowrap"><b><vkc:message key="vkc.search.for"/>&nbsp;<vkc:message key="vkc.search.searchResultLimitation"/></b></td>
	            <td width="100%">
          	      <bean:define id="documentTypes" name="form" property="query.documentTypes"/>
	              <html:select property="query.selectedResultLimitation" size="1">
		            <html:option value="*"><vkc:message key="vkc.search.searchResultLimitation.noLimitation" /></html:option>
          		    <vkc:options collection="documentTypes" property="extension" labelProperty="extensionLabel"/>
		          </html:select>
	            </td>
	            <td nowrap="nowrap">&nbsp;</td>
	          </tr>
		      </logic:present>

	          <logic:notPresent parameter="hideDisplayOptions">
              <tr>
                <td colspan="4">&nbsp;</tr>
              </tr>
	          <tr>
	            <td nowrap="nowrap"><vkc:message key="vkc.search.display"/></td>
	            <td nowrap="nowrap"><b><vkc:message key="vkc.search.for"/>&nbsp;<vkc:message key="vkc.search.sortResults"/></b></td>
	            <td width="100%">
	              <html:select property="query.selectedSortResults" size="1">
	                <html:option value="1"><vkc:message key="vkc.search.sortResults.descendingByScore" /></html:option>
		            <html:option value="0"><vkc:message key="vkc.search.sortResults.ascendingByScore" /></html:option>
		            <html:option value="7"><vkc:message key="vkc.search.sortResults.descendingByCreationDate" /></html:option>
		            <html:option value="6"><vkc:message key="vkc.search.sortResults.ascendingByCreationDate" /></html:option>
		            <html:option value="3"><vkc:message key="vkc.search.sortResults.descendingByPublishingDate" /></html:option>
		            <html:option value="2"><vkc:message key="vkc.search.sortResults.ascendingByPublishingDate" /></html:option>
		            <html:option value="5"><vkc:message key="vkc.search.sortResults.descendingByAuthor" /></html:option>
		            <html:option value="4"><vkc:message key="vkc.search.sortResults.ascendingByAuthor" /></html:option>
                    <html:option value="9"><vkc:message key="vkc.search.sortResults.descendingByPublisher" /></html:option>
                    <html:option value="8"><vkc:message key="vkc.search.sortResults.ascendingByPublisher" /></html:option>
		          </html:select>
	            </td>
	            <td nowrap="nowrap">&nbsp;</td>
	          </tr>
	          </logic:notPresent>
	        </table>
	      </td>
	    </tr>
	  </table>
    </td>
  </tr>
  <vkc:hline bottomSpace="5" topSpace="0" colspan="2" lineClass="hline" lineHeight="1"/>
  <tr>
    <td align="center" nowrap="nowrap" colspan="2">
      <vkc:button property="action.save.searchquery" onclick="javascript:disableAllButtonsAndSubmit(this);"><vkc:message key="button.apply"/></vkc:button>
      <vkc:button property="action.back.searchquery" onclick="javascript:disableAllButtonsAndSubmit(this);"><vkc:message key="button.back"/></vkc:button>
    </td>
  </tr>
</table>