Index: zpt/viewer_text.zpt
===================================================================
--- zpt/viewer_text.zpt	(revision 506)
+++ zpt/viewer_text.zpt	(revision 508)
@@ -3,5 +3,6 @@
 <html xmlns="http://www.w3.org/1999/xhtml"
   tal:define="docinfo options/docinfo; pageinfo options/pageinfo; viewMode pageinfo/viewMode;
-              tocMode pageinfo/tocMode; viewLayer pageinfo/viewLayer; viewerUrl docinfo/viewerUrl;
+              tocMode pageinfo/tocMode; viewLayer pageinfo/viewLayer; viewLayers pageinfo/viewLayers;
+              viewerUrl docinfo/viewerUrl;
               rootUrl here/getDocumentViewerURL;
               numPages docinfo/numPages | nothing;">
@@ -29,4 +30,6 @@
                 pn pageinfo/pn; 
                 flowLtr python:pageinfo.get('pageFlow','ltr')!='rtl';
+                query python:request.get('query', None); 
+                queryType python:request.get('queryType','fulltextMorph');
                 textPage python:here.getTextPage(mode=viewLayer, pn=pn, docinfo=docinfo, pageinfo=pageinfo) or '[no text here]';">
     <!-- header -->
@@ -58,5 +61,5 @@
         </div>
       </div>
-      <!-- col-main -->
+      <!-- end of col-main -->
 
       <!-- right-side options -->
@@ -65,40 +68,108 @@
         <div class="options">
           <h4>Text display</h4>
+          <pre tal:content="python:repr(viewLayers)" />
           <form tal:attributes="action viewerUrl" class="autosubmit">
             <input type="hidden"
               tal:define="params python:here.getParams(params={'viewLayer':None,'viewMode':None})"
               tal:repeat="param params"
-              tal:attributes="name param; value python:params[param]" /> <input
-              class="autosubmit" type="radio" name="viewMode" value="text"
-              tal:attributes="checked python:viewMode=='text'" /> Text<br /> <span
-              class="optionsText"> &nbsp;&nbsp;<input type="checkbox"
-              class="autosubmit" name="viewLayer" value="dict"
-              tal:attributes="checked python:viewLayer=='dict'" /> Dictionary<br />
-            </span> <span class="optionsText" tal:condition="python:docinfo.get('numPlaces',0)">
-              &nbsp;&nbsp;<input type="checkbox" class="autosubmit" name="viewLayer"
-              value="gis" tal:attributes="checked python:viewLayer=='gis'" /> Places<br />
-            </span> <input type="radio" class="autosubmit" name="viewMode" value="xml"
-              tal:attributes="checked python:viewMode=='xml'" /> XML<br /> <input
-              type="submit" value="Go!" />
+              tal:attributes="name param; value python:params[param]" />
+            <ul>
+              <li>
+                <input class="autosubmit" type="radio" name="viewMode" value="text"
+                  tal:attributes="checked python:viewMode=='text'" /> Text
+                <ul>
+                  <li>
+                    <input type="checkbox" class="autosubmit" name="viewLayer"
+                      value="dict" tal:attributes="checked python:'dict' in viewLayers" />
+                    Dictionary
+                  </li>
+                  <li tal:condition="query">
+                    <input type="checkbox" class="autosubmit" name="viewLayer"
+                      value="search"
+                      tal:attributes="checked python:'search' in viewLayers" /> Search hits
+                  </li>
+                  <li tal:condition="python:docinfo.get('numPlaces',0)">
+                    <input type="checkbox" class="autosubmit" name="viewLayer" value="gis"
+                      tal:attributes="checked python:'gis' in viewLayers" /> Places<br />
+                  </li>
+                </ul>
+              </li>
+              <li>
+                <input type="radio" class="autosubmit" name="viewMode" value="xml"
+                  tal:attributes="checked python:viewMode=='xml'" /> XML<br /> <input
+                  type="submit" value="Go!" />
+              </li>
+            </ul>
           </form>
         </div>
         <!--"END TEXT DISPLAY"-->
 
+        <!--"BEGIN SEARCH"-->
+        <div class="options">
+          <h4>Search</h4>
+          <form tal:attributes="action viewerUrl">
+            <input type="hidden"
+              tal:define="params python:here.getParams(params={'query':None,'queryType':None,'viewLayer':None})"
+              tal:repeat="param params"
+              tal:attributes="name param; value python:params[param]" />
+            <!-- make sure we have one viewLayer=search -->
+            <tal:block tal:repeat="vl viewLayers">
+                <input type="hidden" name="viewLayer" tal:attributes="value vl" tal:condition="python:vl != 'search'"/>
+            </tal:block>
+            <input type="hidden" name="viewLayer" value="search"/>
+            <!-- query text -->
+            <input type="text" name="query" tal:attributes="value query"/>
+            <input type="submit" value="Search"/>
+            <ul>
+                <li>
+                  <input type="radio" name="queryType" value="fulltext" 
+                    tal:attributes="checked python:queryType=='fulltext'"/> Exact
+                </li>
+                <li>
+                  <input type="radio" name="queryType" value="fulltextMorph" 
+                    tal:attributes="checked python:queryType=='fulltextMorph'"/> All forms
+                </li>
+                <li>
+                  <input type="radio" name="queryType" value="ftIndex" 
+                    tal:attributes="checked python:queryType=='ftIndex'"/> Fulltext index
+                </li>
+                <li>
+                  <input type="radio" name="queryType" value="ftIndexMorph" 
+                    tal:attributes="checked python:queryType=='ftIndexMorph'"/> Morphological index
+                </li>
+            </ul>
+          </form>
+        </div>
+        <!--"END SEARCH"-->
+
         <!--"BEGIN TEXT SIZE"-->
         <div class="options">
           <h4>Text size</h4>
-          <div class="fsizer">
-            &nbsp; <a href="javascript:fontSize(12);" class="fs_sml">S</a> <a
-              href="javascript:fontSize(14);" class="fs_med">M</a> <a
-              href="javascript:fontSize(16);" class="fs_lrg">L</a>
-          </div>
+          <ul class="fsizer">
+            <li>
+              <a href="javascript:fontSize(12);" class="fs_sml">S</a>
+            </li>
+            <li>
+              <a href="javascript:fontSize(14);" class="fs_med">M</a>
+            </li>
+            <li>
+              <a href="javascript:fontSize(16);" class="fs_lrg">L</a>
+            </li>
+          </ul>
         </div>
         <!--"END TEXT SIZE"-->
 
         <!--"BEGIN DICTIONARY OVERVIEW"-->
-        <div class="options" tal:condition="python:viewLayer=='dict'">
+        <div class="options" tal:condition="python:'dict' in viewLayers">
           <h4>Dictionary view</h4>
           <form name="f3" action="">
-            <input type="radio" name="r3" />Tab<br /> <input type="radio" name="r3" />Window<br />
+            <ul>
+              <li>
+                <input type="radio" name="r3" /> Tab
+              </li>
+              <li>
+                <input type="radio" name="r3" /> Window
+              </li>
+            </ul>
           </form>
         </div>
@@ -106,5 +177,5 @@
 
         <!--"BEGIN TEXT NORMALIZATION"-->
-        <div class="options" tal:condition="python:viewLayer!='xml'">
+        <div class="options">
           <h4>Text normalization</h4>
           <form tal:attributes="action viewerUrl" class="autosubmit"
@@ -113,12 +184,21 @@
               tal:define="params python:here.getParams('characterNormalization',None)"
               tal:repeat="param params"
-              tal:attributes="name param; value python:params[param]" /> <input
-              type="radio" class="autosubmit" name="characterNormalization" value="orig"
-              tal:attributes="checked python:norm=='orig'" /> Original<br /> <input
-              type="radio" class="autosubmit" name="characterNormalization" value="reg"
-              tal:attributes="checked python:norm=='reg'" /> Regularized<br /> <input
-              type="radio" class="autosubmit" name="characterNormalization"
-              value="regPlusNorm" tal:attributes="checked python:norm=='regPlusNorm'" />
-            Normalized<br /> <input type="submit" value="Go!" />
+              tal:attributes="name param; value python:params[param]" />
+            <ul>
+              <li>
+                <input type="radio" class="autosubmit" name="characterNormalization"
+                  value="orig" tal:attributes="checked python:norm=='orig'" /> Original
+              </li>
+              <li>
+                <input type="radio" class="autosubmit" name="characterNormalization"
+                  value="reg" tal:attributes="checked python:norm=='reg'" /> Regularized
+              </li>
+              <li>
+                <input type="radio" class="autosubmit" name="characterNormalization"
+                  value="regPlusNorm" tal:attributes="checked python:norm=='regPlusNorm'" />
+                Normalized
+              </li>
+            </ul>
+            <input type="submit" value="Go!" />
           </form>
         </div>
@@ -126,5 +206,5 @@
 
         <!--"BEGIN PLACES"-->
-        <div class="options" tal:condition="python:viewLayer=='gis'">
+        <div class="options" tal:condition="python:'gis' in viewLayers">
           <tal:block tal:define="
             name docinfo/documentName;
@@ -148,4 +228,13 @@
       </div>
       <!-- /col-right -->
+
+      <!-- right-side options -->
+      <div class="col-veryright" tal:condition="query">
+        <!--"BEGIN SEARCH RESULTS"  -->
+        <div class="options">
+          <h4>Search results</h4>
+          <div tal:content="structure python:here.getResultsPage(mode=queryType,query=query,pn=1,pageinfo=pageinfo,docinfo=docinfo)"/>
+        </div>
+      </div>
 
     </div>
