Index: /main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js	(revision 25719)
+++ /main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js	(revision 25720)
@@ -26,6 +26,21 @@
 	template += '</xsl:template>';
 
+	var hlCheckBox = document.getElementById("highlightOption");
+	
+	var hl = "";
+	if(hlCheckBox)
+	{
+		if(hlCheckBox.checked)
+		{
+			hl = "on";
+		}
+		else
+		{
+			hl = "off";
+		}
+	}
+	
 	var ajax = gs.functions.ajaxRequest();
-	ajax.open("GET", gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "/document/" + sectionID + "?p.s=TextQuery&ilt=" + template.replace(" ", "%20"), true);
+	ajax.open("GET", gs.xsltParams.library_name + "/collection/" + gs.cgiParams.c + "/document/" + sectionID + "?hl=" + hl + "&p.s=TextQuery&ilt=" + template.replace(" ", "%20"), true);
 	ajax.onreadystatechange = function()
 	{
@@ -911,34 +926,30 @@
 * HIGHLIGHTING SCRIPTS *
 ***********************/
-function addHighlight()
-{
+function swapHighlight()
+{
+	var hlCheckbox = document.getElementById("highlightOption");
+	
+	var from;
+	var to;
+	if(hlCheckbox.checked)
+	{
+		from = "noTermHighlight";
+		to = "termHighlight";
+	}
+	else
+	{
+		from = "termHighlight";
+		to = "noTermHighlight";
+	}
+	
 	var spans = document.getElementsByTagName("span");
 	for(var i = 0; i < spans.length; i++)
 	{
 		var currentSpan = spans[i];
-		if(currentSpan.getAttribute("class") == "noTermHighlight")
-		{
-			currentSpan.setAttribute("class", "termHighlight");
-		}
-	}
-	
-	var option = document.getElementById("highlightOption");
-	option.setAttribute("onclick", "removeHighlight();");
-}
-
-function removeHighlight()
-{
-	var spans = document.getElementsByTagName("span");
-	for(var i = 0; i < spans.length; i++)
-	{
-		var currentSpan = spans[i];
-		if(currentSpan.getAttribute("class") == "termHighlight")
-		{
-			currentSpan.setAttribute("class", "noTermHighlight");
-		}
-	}
-	
-	var option = document.getElementById("highlightOption");
-	option.setAttribute("onclick", "addHighlight();");
+		if(currentSpan.getAttribute("class") == from)
+		{
+			currentSpan.setAttribute("class", to);
+		}
+	}
 }
 
Index: /main/trunk/greenstone3/web/interfaces/default/transform/layouts/toc.xsl
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/transform/layouts/toc.xsl	(revision 25719)
+++ /main/trunk/greenstone3/web/interfaces/default/transform/layouts/toc.xsl	(revision 25720)
@@ -80,5 +80,5 @@
 									</xsl:choose>
 								</xsl:attribute>
-								<xsl:for-each select="documentNode"><!--xxx<xsl:apply-templates select="documentNode" mode="TOC"/>-->
+								<xsl:for-each select="documentNode">
 									<xsl:call-template name="documentNodeTOC"/>
 								</xsl:for-each>
@@ -92,5 +92,5 @@
 	
 	<!-- This template is used to display the table of contents -->
-	<xsl:template name="documentNodeTOC"><!--xxx<xsl:template match="documentNode" mode="TOC">-->
+	<xsl:template name="documentNodeTOC">
 
 		<!-- check if this is the currently selected table of contents item -->
@@ -164,5 +164,5 @@
 							<xsl:text> </xsl:text>
 						</xsl:if>
-						<xsl:call-template name="sectionTitle"/><!--xxx<xsl:apply-templates select="." mode="sectionTitle"/>-->
+						<xsl:call-template name="sectionTitle"/>
 					</a>
 				</td>
@@ -182,5 +182,5 @@
 						</xsl:choose>
 					</xsl:attribute>
-					<xsl:for-each select="documentNode"><!--xxx<xsl:apply-templates select="documentNode" mode="TOC"/>-->
+					<xsl:for-each select="documentNode">
 						<xsl:call-template name="documentNodeTOC"/>
 					</xsl:for-each>
@@ -235,18 +235,8 @@
 						<xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'highlight_image')"/></xsl:attribute>
 					</img>
-					<input id="highlightOption" type="checkbox" class="optionCheckBox">
-						<xsl:choose>
-							<xsl:when test="/page/pageRequest/paramList/param[@name = 'hl']/@value = 'on'">
-								<xsl:attribute name="onclick">
-									<xsl:text>removeHighlight();</xsl:text>
-								</xsl:attribute>
-								<xsl:attribute name="checked">true</xsl:attribute>
-							</xsl:when>
-							<xsl:otherwise>
-								<xsl:attribute name="onclick">
-									<xsl:text>addHighlight();</xsl:text>
-								</xsl:attribute>
-							</xsl:otherwise>
-						</xsl:choose>
+					<input id="highlightOption" type="checkbox" class="optionCheckBox" onclick="swapHighlight();">
+						<xsl:if test="/page/pageRequest/paramList/param[@name = 'hl']/@value = 'on'">
+							<xsl:attribute name="checked">true</xsl:attribute>
+						</xsl:if>
 					</input>
 				</td>
Index: /main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl	(revision 25719)
+++ /main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl	(revision 25720)
@@ -90,8 +90,8 @@
 				<xsl:choose>
 					<xsl:when test="not(/page/pageRequest/paramList/param[@name = 'dmd']) or /page/pageRequest/paramList/param[@name = 'dmd']/@value = 'false'">
-						<xsl:call-template name="sectionTitleFormat"/><!--<xsl:apply-templates select="." mode="sectionTitleFormat"/>-->
+						<xsl:call-template name="sectionTitleFormat"/>
 					</xsl:when>
 					<xsl:otherwise>
-						<xsl:call-template name="sectionTitle"/><!--<xsl:apply-templates select="." mode="sectionTitle"/>-->
+						<xsl:call-template name="sectionTitle"/>
 					</xsl:otherwise>
 				</xsl:choose>
@@ -177,5 +177,5 @@
 				</xsl:attribute>
 				<!-- Get the section content from the document template -->
-				<xsl:call-template name="documentNodeContent"/><!--xxx<xsl:apply-templates select="." mode="document"/>-->
+				<xsl:call-template name="documentNodeContent"/>
 			</div>
 			<xsl:if test="documentNode">
@@ -242,5 +242,5 @@
 			</xsl:when>
 			<xsl:when test="$bookswitch = 'flashxml'">
-				<xsl:call-template name="documentNodeFlashXML"/><!--xxx<xsl:apply-templates mode="flashxml"/>-->
+				<xsl:call-template name="documentNodeFlashXML"/>
 			</xsl:when>
 			<xsl:when test="$bookswitch = 'on'">
@@ -338,11 +338,11 @@
 			</td>
 		</tr></table>
-		<gslib:langfrag name="dse"/><!--<xsl:call-template name="document-editor-language-fragments"/>-->
+		<gslib:langfrag name="dse"/>
 	</xsl:template>
 	
 	<!-- Highlight annotations if requested -->
-	<xsl:template match="annotation">
+	<xsl:template name="displayAnnotation">
 		<xsl:choose>
-			<xsl:when test="/page/pageRequest/paramList/param[@name='hl' and @value='on']">
+			<xsl:when test="/page/pageRequest/paramList/param[@name = 'hl']/@value = 'on'">
 				<span class="termHighlight"><xsl:value-of select="."/></span>
 			</xsl:when>
@@ -353,5 +353,5 @@
 	</xsl:template>
 	
-	<xsl:template name="sectionTitleFormat"><!--xxx<xsl:template match="documentNode" mode="sectionTitleFormat">-->
+	<xsl:template name="sectionTitleFormat">
 		<p>
 			<xsl:attribute name="class"><xsl:value-of select="util:hashToDepthClass(@nodeID)"/> sectionHeader</xsl:attribute>
@@ -364,5 +364,5 @@
 			</xsl:if>
 			<!-- Display the title for the section regardless of whether automatic section numbering is turned on -->
-			<span><xsl:call-template name="sectionTitle"/><!--xxx<xsl:apply-templates select="." mode="sectionTitle"/>--></span>
+			<span><xsl:call-template name="sectionTitle"/></span>
 		</p>
 	</xsl:template>
@@ -370,5 +370,5 @@
 		
 	<!-- The default template for displaying section titles -->
-	<xsl:template name="sectionTitle"><!--xxx<xsl:template match="documentNode" mode="sectionTitle">-->
+	<xsl:template name="sectionTitle">
 		<xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/>
 	</xsl:template>
@@ -439,5 +439,5 @@
 	
 	<!-- The default template for displaying the document content -->
-	<xsl:template name="documentNodeContent"><!--xxx<xsl:template match="documentNode" mode="document">-->
+	<xsl:template name="documentNodeContent">
 		<!-- Hides the "This document has no text." message -->
 		<xsl:variable name="noText"><gsf:metadata name="NoText"/></xsl:variable>
@@ -452,8 +452,12 @@
 						</xsl:if>
 					</xsl:when>
+					<xsl:when test="name() = 'annotation'">
+						<xsl:call-template name="displayAnnotation"/>
+					</xsl:when>
+					<xsl:when test="name() = 'nodeContent'">
+						<xsl:call-template name="documentNodeContent"/>
+					</xsl:when>
 					<xsl:otherwise>
-						<xsl:for-each select="nodeContent"><!--xxx<xsl:apply-templates select="."/>-->
-							<xsl:call-template name="documentNodeContent"/>
-						</xsl:for-each>
+						<xsl:apply-templates/>
 					</xsl:otherwise>
 				</xsl:choose>
@@ -463,5 +467,5 @@
 	
 	<!-- Used to produce a version of the page in a format that can be read by the realistic books plugin -->
-	<xsl:template name="documentNodeFlashXML"><!--xxx<xsl:template match="documentNode" mode="flashxml">-->
+	<xsl:template name="documentNodeFlashXML">
 		<xsl:text disable-output-escaping="yes">
 			&lt;Section&gt;
@@ -478,5 +482,5 @@
 				
 		<xsl:for-each select="documentNode">
-			<xsl:call-template name="documentNodeFlashXML"/><!--<xsl:apply-templates select="documentNode" mode="flashxml"/>-->
+			<xsl:call-template name="documentNodeFlashXML"/>
 		</xsl:for-each>
 				
