Index: documentViewer.py
===================================================================
--- documentViewer.py	(revision 590)
+++ documentViewer.py	(revision 591)
@@ -63,4 +63,12 @@
                 pn = default
                 
+        return pn
+    
+    return default
+
+def getPfForPn(docinfo, pn, default=None):
+    """returns image file name for image number or default"""
+    if 'imgFileIndexes' in docinfo:
+        pn = docinfo['imgFileIndexes'].get(pn, default)
         return pn
     
@@ -105,4 +113,5 @@
     layer_text_pundit = PageTemplateFile('zpt/layer_text_pundit', globals())
     layer_image_annotator = PageTemplateFile('zpt/layer_image_annotator', globals())
+    layer_image_ocrsearch = PageTemplateFile('zpt/layer_image_ocrsearch', globals())
     layer_index_extended = PageTemplateFile('zpt/layer_index_extended', globals())
     # toc templates
@@ -778,10 +787,13 @@
         # save list of image names and numbers
         imgNames = {}
+        imgIndexes = {}
         for f in dir:
             fn = f.findtext('name')
-            pn = f.findtext('index')
-            imgNames[fn] = getInt(pn)
+            pn = getInt(f.findtext('index'))
+            imgNames[fn] = pn
+            imgIndexes[pn] = fn
             
         docinfo['imgFileNames'] = imgNames
+        docinfo['imgFileIndexes'] = imgIndexes
         return docinfo
             
@@ -849,4 +861,6 @@
         else:
             pn = getInt(pn, 1)
+            pf = getPfForPn(docinfo, pn)
+            pageinfo['pf'] = pf
             
         pageinfo['pn'] = pn
@@ -891,8 +905,8 @@
         
         # cache search results
-        pageinfo['resultPageSize'] = getInt(self.REQUEST.get('resultPageSize', 10))
         query = self.REQUEST.get('query',None)
         pageinfo['query'] = query
-        if query:
+        if query and viewMode == 'text':
+            pageinfo['resultPageSize'] = getInt(self.REQUEST.get('resultPageSize', 10))
             queryType = self.REQUEST.get('queryType', 'fulltextMorph')
             pageinfo['queryType'] = queryType
@@ -911,5 +925,5 @@
 
     def getPageBatch(self, start=1, rows=10, cols=2, pageFlowLtr=True, pageZero=False, minIdx=1, maxIdx=0):
-        """returns dict with array of page informations for one screenfull of thumbnails"""
+        """returns dict with array of page information for one screenfull of thumbnails"""
         batch = {}
         grpsize = rows * cols
Index: version.txt
===================================================================
--- version.txt	(revision 587)
+++ version.txt	(revision 591)
@@ -1,1 +1,1 @@
-DocumentViewer 2.2.8
+DocumentViewer 2.2.9
Index: zpt/layer_image_ocrsearch.zpt
===================================================================
--- zpt/layer_image_ocrsearch.zpt	(revision 591)
+++ zpt/layer_image_ocrsearch.zpt	(revision 591)
@@ -0,0 +1,52 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<metal:block metal:define-macro="html_head" tal:condition="python:'ocrsearch' in viewLayers">
+  <!--  ocrsearch for digilib -->
+  <script type="text/javascript" tal:attributes="src string:$dlBaseUrl/jquery/showdown.js"></script>
+  <script type="text/javascript" tal:attributes="src string:$dlBaseUrl/jquery/annotator-dl.js"></script>
+  <script type="text/javascript" tal:attributes="src string:$dlBaseUrl/jquery/jquery.digilib.annotator.js"></script>
+  <link rel="stylesheet" type="text/css" tal:attributes="href string:$dlBaseUrl/jquery/annotator.min.css"/>
+
+  <script type="text/javascript" 
+    tal:define="global annServerUrl string:http://tuxserve03.mpiwg-berlin.mpg.de/AnnotationManager;
+    global query pageinfo/query | nothing;
+    annUri docinfo/documentPath;
+    annPf pageinfo/pf | nothing;"
+    tal:content="structure string:
+    dlOpts.digilibFrontendPath='/jquery/digilib-ann.html';
+    dlOpts.annotationServerUrl='$annServerUrl/annotator';
+    dlOpts.annotationsReadOnly=true;
+    dlOpts.annotatorPlugins=['Store','Markdown','DigilibIntegrator'];
+    dlOpts.annotatorPluginSettings={'Store':{'loadFromSearch':{'uri':'$annUri','pf':'$annPf','query':'$query'}}};
+    "></script>
+</metal:block>
+
+</head>
+<body>
+  <!-- right-side options -->
+  <div class="col buttons">
+    <!-- LAYER DISPLAY OPTION  -->
+    <ul>
+      <li metal:define-macro="layer_select_li">
+        <input type="checkbox" class="autosubmit" name="viewLayer" value="ocrsearch"
+          tal:attributes="checked python:'ocrsearch' in viewLayers" /> Search results
+      </li>
+    </ul>
+  </div>
+
+  <metal:block metal:define-macro="options_box" tal:condition="python:'ocrsearch' in viewLayers">
+    <!-- BEGIN OCRSEARCH -->
+    <div class="options">
+      <h4>OCR Search</h4>
+      <p>
+        Query: "<span tal:replace="query"/>".
+      </p>
+    </div>
+    <!-- END OCRSEARCH -->
+  </metal:block>
+
+</body>
+
+</html>
