Index: main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl
===================================================================
--- main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl	(revision 32503)
+++ main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl	(revision 32504)
@@ -444,4 +444,7 @@
 							var docID = sectionID.replace(/([^.]*)\..*/, "$1");
 							var url = gs.xsltParams.library_name + "?a=d&amp;c=" + gs.cgiParams.c + "&amp;excerptid=gs-document&amp;dt=hierarchy&amp;d=" + docID;
+							if(gs.cgiParams.p_s) { 
+							url += "&amp;p.s="+gs.cgiParams.p_s;
+							}
 							loadTopLevelPage(callbackFunction, url);
 						});
@@ -530,16 +533,5 @@
 	</xsl:template>
 	
-	<!-- Highlight annotations if requested -->
-	<xsl:template name="displayAnnotation">
-		<xsl:choose>
-			<xsl:when test="/page/pageRequest/paramList/param[@name = 'hl']/@value = 'off' or /page/pageResponse/format[@type='display']/gsf:option[@name='disableSearchTermHighlighting']/@value='true'">
-				<span class="noTermHighlight"><xsl:value-of select="."/></span>
-			</xsl:when>
-			<xsl:otherwise>
-				<span class="termHighlight"><xsl:value-of select="."/></span>
-			</xsl:otherwise>
-		</xsl:choose>
-	</xsl:template>
-		
+	
 	<!-- The default template for displaying section titles -->
 	<xsl:template name="sectionTitle">
@@ -555,8 +547,7 @@
 		<xsl:choose>
 			<xsl:when test="metadataList/metadata[@name = 'Screen'] and metadataList/metadata[@name = 'SourceFile'] and ($imageWidth div $screenImageWidth > 1.2) and (not(/page/pageResponse/format[@type='display']/gsf:option[@name='disableZoom']) or /page/pageResponse/format[@type='display']/gsf:option[@name='disableZoom']/@value='false')">
-				
 				<div id="image{@nodeID}">
-				  <!-- when we ask for an individual section content we set ed=1. putting this test here prevents downloading all the screen and full images for each section of the document when we are just looking at teh contents list -->
-				  <xsl:if test="/page/pageRequest/paramList/param[@name = 'ed']/@value='1'">
+				  <!-- when we ask for an individual section content we set ed=1. putting this test here prevents downloading all the screen and full images for each section of the document when we are just looking at the contents list. ed is not set for simple docs, so do this if doctype is simple -->
+				  <xsl:if test="/page/pageResponse/document[@docType='simple'] or /document/page/pageRequest/paramList/param[@name = 'ed']/@value='1'">
 				
 					<div id="wrap{util:replace(@nodeID, '.', '_')}" class="zoomImage" style="position:relative; width: {$screenImageWidth}px; height: {$screenImageHeight}px;">
@@ -622,27 +613,16 @@
 	<!-- equivalent to gsf:text -->
 	<xsl:template name="documentNodeText">
+	  <xsl:param name="force">1</xsl:param>
 		<!-- Hides the "This document has no text." message -->
 		<xsl:variable name="noText"><gsf:metadata name="NoText"/></xsl:variable>
 		<xsl:choose>
-		<xsl:when test="not($noText = '1')">
+		<xsl:when test="$force = '1' or not($noText = '1')">
 
 			<!-- Section text -->
 			<xsl:for-each select="nodeContent">
-				<xsl:for-each select="node()">
-					<xsl:choose>
-						<xsl:when test="not(name())">
-						  <xsl:value-of select="." disable-output-escaping="yes"/>
-						</xsl:when>
-						<xsl:when test="name() = 'annotation'">
-							<xsl:call-template name="displayAnnotation"/>
-						</xsl:when>
-						<xsl:otherwise>
-							<xsl:apply-templates/>
-						</xsl:otherwise>
-					</xsl:choose>
-				</xsl:for-each>
+			  <xsl:call-template name="displayMarkedUpTextAndAnnotations"/>
 			</xsl:for-each>
 		</xsl:when>
-		<xsl:when test="$noText = '1' and not(metadataList/metadata[@name='Image'])">
+		<xsl:when test="$noText = '1' and not(metadataList/metadata[@name='ImageType'])">
 			<gsf:link type="source"><gsf:metadata name="Source"/></gsf:link>
 		</xsl:when>
@@ -651,4 +631,28 @@
 	</xsl:template>
 
+	<!-- display the text content of a node (content node or metadata node), marking up the annotations -->
+	<xsl:template name="displayMarkedUpTextAndAnnotations">
+	  <xsl:variable name="annotation_class">
+	    <xsl:choose>
+	      <xsl:when test="/page/pageRequest/paramList/param[@name = 'hl']/@value = 'off' or /page/pageResponse/format[@type='display']/gsf:option[@name='disableSearchTermHighlighting']/@value='true'">noTermHighlight</xsl:when>
+	      <xsl:otherwise>termHighlight</xsl:otherwise>
+	    </xsl:choose>
+	  </xsl:variable>
+	  <xsl:for-each select="node()">
+	    <xsl:choose>
+	      <xsl:when test="not(name())">
+		<xsl:value-of select="." disable-output-escaping="yes"/>
+	      </xsl:when>
+	      <xsl:when test="name() = 'annotation'">
+		<span class="{$annotation_class}"><xsl:value-of select="."/></span>
+	      </xsl:when>
+	      <xsl:otherwise>
+		<xsl:apply-templates/>
+	      </xsl:otherwise>
+	    </xsl:choose>
+	  </xsl:for-each>
+	</xsl:template>
+
+	
 	<!-- The default template for displaying the document node text in
 	editing mode -->
