Index: main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js
===================================================================
--- main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js	(revision 26019)
+++ main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js	(revision 26020)
@@ -18,8 +18,5 @@
 	template +=   '<text>';
 	template +=     '<xsl:for-each select="/page/pageResponse/document//documentNode[@nodeID = \'' + sectionID + '\']">';
-	template +=       '<xsl:call-template name="sectionImage"/>';
-	template +=       '<div id="text' + sectionID + '">';
-	template +=         '<xsl:call-template name="documentNodeText"/>';
-	template +=       '</div>';
+	template +=       '<xsl:call-template name="sectionContent"/>';
 	template +=     '</xsl:for-each>';
 	template +=   '</text>';
Index: main/trunk/greenstone3/web/interfaces/default/transform/config_format.xsl
===================================================================
--- main/trunk/greenstone3/web/interfaces/default/transform/config_format.xsl	(revision 26019)
+++ main/trunk/greenstone3/web/interfaces/default/transform/config_format.xsl	(revision 26020)
@@ -46,23 +46,32 @@
 
 	<xsl:template match="gsf:image">
-		<img>
-			<xslt:attribute name='src'>
-				<xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name = 'httpPath']"/>
-				<xsl:text>/index/assoc/</xsl:text>
-				<xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/document/metadataList/metadata[@name = 'assocfilepath']"/>
-				<xsl:text>/</xsl:text>
-				<xsl:choose>
-					<xsl:when test="@type = 'thumb'">
-						<xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name = 'Thumb']"/>
-					</xsl:when>
-					<xsl:when test="@type = 'screen'">
-						<xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name = 'Screen']"/>
-					</xsl:when>
-					<xsl:when test="@type = 'source'">
-						<xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name = 'SourceFile']"/>
-					</xsl:when>
-				</xsl:choose>
-			</xslt:attribute>
-		</img>
+		<xsl:variable name="metaName">
+			<xsl:choose>
+				<xsl:when test="@type = 'thumb'">Thumb</xsl:when>
+				<xsl:when test="@type = 'screen'">Screen</xsl:when>
+				<xsl:when test="@type = 'source'">SourceFile</xsl:when>
+			</xsl:choose>
+		</xsl:variable>
+		<xsl:if test="(.//metadataList)[last()]/metadata[@name = $metaName]">
+			<img>
+				<xslt:attribute name='src'>
+					<xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name = 'httpPath']"/>
+					<xsl:text>/index/assoc/</xsl:text>
+					<xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/document/metadataList/metadata[@name = 'assocfilepath']"/>
+					<xsl:text>/</xsl:text>
+					<xsl:choose>
+						<xsl:when test="@type = 'thumb'">
+							<xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name = 'Thumb']"/>
+						</xsl:when>
+						<xsl:when test="@type = 'screen'">
+							<xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name = 'Screen']"/>
+						</xsl:when>
+						<xsl:when test="@type = 'source'">
+							<xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name = 'SourceFile']"/>
+						</xsl:when>
+					</xsl:choose>
+				</xslt:attribute>
+			</img>
+		</xsl:if>
 	</xsl:template>
 
@@ -267,5 +276,5 @@
   
 	<xsl:template match="gsf:text">
-    <xslt:call-template name="documentNodeText"/>
+		<xslt:call-template name="documentNodeText"/>
 	</xsl:template>
   
Index: main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl
===================================================================
--- main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl	(revision 26019)
+++ main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl	(revision 26020)
@@ -57,6 +57,57 @@
 	</xsl:template>
 	
+	<xsl:template name="documentHeading">
+		<b><gsf:metadata name="Title"/></b><br/>
+	</xsl:template>
+	
+	<xsl:template name="documentContent">
+		<xsl:choose>
+			<xsl:when test="@docType='simple'">
+				<div id="gs-document">
+					<xsl:call-template name="wrappedSectionImage"/>
+					<div id="gs-document-text">
+						<xsl:call-template name="documentNodeText"/>
+					</div>
+				</div>
+			</xsl:when>
+			<xsl:otherwise> 
+				<xsl:call-template name="wrappedDocument"/>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+	
 	<xsl:template name="sectionHeader">
 		<xsl:call-template name="sectionTitle"/>
+	</xsl:template>
+	
+	<xsl:template name="topLevelSectionContent">
+		<xsl:call-template name="wrappedSectionImage"/>
+		<xsl:call-template name="wrappedSectionText"/>
+	</xsl:template>
+	
+	<xsl:template name="sectionContent">
+		<xsl:call-template name="wrappedSectionImage"/>
+		<xsl:call-template name="wrappedSectionText"/>
+	</xsl:template>
+	
+	<xsl:template name="wrappedSectionText">
+		<div id="text{@nodeID}" class="sectionText"><!-- *** -->
+			<xsl:attribute name="style">
+				<xsl:choose>
+					<xsl:when test="/page/pageRequest/paramList/param[@name = 'view']/@value = 'image'">
+						<xsl:text>display:none;</xsl:text>
+					</xsl:when>
+					<xsl:otherwise>
+						<xsl:text>display:block;</xsl:text>
+					</xsl:otherwise>
+				</xsl:choose>
+			</xsl:attribute>
+
+			<xsl:call-template name="documentNodeText"/>
+		</div>
+	</xsl:template>
+	
+	<xsl:template name="sectionImage">
+		<gsf:image type="screen"/>
 	</xsl:template>
 	
@@ -166,20 +217,13 @@
 			</xsl:if>
 			
-			<xsl:call-template name="sectionImage"/>
+			<xsl:choose>
+				<xsl:when test="../../document">
+					<xsl:call-template name="topLevelSectionContent"/>
+				</xsl:when>
+				<xsl:otherwise>
+					<xsl:call-template name="sectionContent"/>
+				</xsl:otherwise>
+			</xsl:choose>
 			
-			<div id="text{@nodeID}" class="sectionText"><!-- *** -->
-				<xsl:attribute name="style">
-					<xsl:choose>
-						<xsl:when test="/page/pageRequest/paramList/param[@name = 'view']/@value = 'image'">
-							<xsl:text>display:none;</xsl:text>
-						</xsl:when>
-						<xsl:otherwise>
-							<xsl:text>display:block;</xsl:text>
-						</xsl:otherwise>
-					</xsl:choose>
-				</xsl:attribute>
-				<!-- Get the section content from the document template -->
-				<xsl:call-template name="documentNodeText"/>
-			</div>
 			<xsl:if test="documentNode">
 				<xsl:for-each select="documentNode">
@@ -262,19 +306,4 @@
 			<xsl:otherwise> <!-- display the standard greenstone document -->
 				<xsl:call-template name="documentContent"/>
-			</xsl:otherwise>
-		</xsl:choose>
-	</xsl:template>
-	<xsl:template name="documentContent">
-		<xsl:choose>
-			<xsl:when test="@docType='simple'">
-			  <div id="gs-document">							
-			    <div id="gs-document-text">
-			      <xsl:call-template name="documentNodeText"/>
-			    </div>
-			  </div>
-
-			</xsl:when>
-			<xsl:otherwise> 
-				<xsl:call-template name="wrappedDocument"/>
 			</xsl:otherwise>
 		</xsl:choose>
@@ -398,5 +427,5 @@
 	</xsl:template>
 	
-	<xsl:template name="sectionImage">
+	<xsl:template name="wrappedSectionImage">
 		<gsf:variable name="screenImageWidth"><gsf:metadata name="ScreenWidth"/></gsf:variable>
 		<gsf:variable name="screenImageHeight"><gsf:metadata name="ScreenHeight"/></gsf:variable>
@@ -446,5 +475,5 @@
 				</div>
 			</xsl:when>
-			<xsl:when test="metadataList/metadata[@name = 'Screen']">
+			<xsl:otherwise>
 				<div id="image{@nodeID}">
 					<xsl:attribute name="style">
@@ -458,12 +487,8 @@
 						</xsl:choose>
 					</xsl:attribute>
-					<gsf:image type="screen"/>
-				</div>
-			</xsl:when>
+					<xsl:call-template name="sectionImage"/><xsl:text> </xsl:text>
+				</div>
+			</xsl:otherwise>
 		</xsl:choose>
-	</xsl:template>
-	
-	<xsl:template name="documentHeading">
-		<b><gsf:metadata name="Title"/></b><br/>
 	</xsl:template>
 	
