Index: main/trunk/greenstone3/web/interfaces/oran/style/berry.css
===================================================================
--- main/trunk/greenstone3/web/interfaces/oran/style/berry.css	(revision 23972)
+++ main/trunk/greenstone3/web/interfaces/oran/style/berry.css	(revision 23989)
@@ -11,4 +11,20 @@
 }
 
+#berrybasket_new {
+	min-height: 22px;
+	padding: 5px;
+	/* background: #E0F0E0 url("../images/berrybasket.png") scroll no-repeat 0 0; */
+	background: transparent url("../images/kete2.png") scroll repeat 0 0;
+	z-index:10;
+	/*cursor: pointer;*/
+	font-size: 80%;
+	min-height: 2em;
+	top:120px;
+	right:0;
+	position:fixed;
+	height:500px;
+	width:9.5%;
+}
+
 #baskethandle {
 	cursor: move;
Index: main/trunk/greenstone3/web/interfaces/oran/style/core.css
===================================================================
--- main/trunk/greenstone3/web/interfaces/oran/style/core.css	(revision 23972)
+++ main/trunk/greenstone3/web/interfaces/oran/style/core.css	(revision 23989)
@@ -11,4 +11,105 @@
 }
 
+h3 {
+	margin-top:2px;
+	margin-bottom:2px;
+}
+
+p {
+	margin-top:0px;
+	margin-bottom:0.75em;
+}
+
+.sectionHeader {
+	margin-top:0px;
+	margin-bottom:0px;
+}
+
+.headerTD {
+	vertical-align: middle;
+}
+
+/* Styles for the different depths */
+.sectionHeaderDepthTitle{
+	font-size:1.8em;
+	line-height:1em;
+	font-weight:bold;
+}
+
+.sectionHeaderDepth1{
+	font-size:1.6em;
+	line-height:1em;
+	font-weight:bold;
+}
+
+.sectionHeaderDepth2{
+	font-size:1.4em;
+	line-height:1em;
+	font-weight:bold;
+	font-style:italic;
+}
+
+.sectionHeaderDepth3{
+	font-size:1.2em;
+	line-height:1em;
+	font-style:italic;
+}
+
+.sectionHeaderDepth4{
+	font-size:1em;
+	line-height:1em;
+	font-weight:italic;
+}
+
+.sectionNumberSpan{
+	/*Uncomment this line to disable automatic section numbering*/
+	/*display:none;*/
+}
+
+.sectionContainer{
+	padding-top:1em;
+	padding-bottom:1em;
+	padding-left:1.5em;
+}
+
+.icon{
+	background-repeat: no-repeat;
+	height:16px;
+	width:16px;
+	cursor:pointer;
+}
+
+.toggleImageExpand {
+	background-image: url('../images/expand.png');
+	background-position: 2px 2px;
+}
+
+.toggleImageCollapse {
+	background-image: url('../images/collapse.png');
+	background-position: 2px 2px;
+}
+
+.toggleImagePage {
+	background-image: url('../images/page.png');
+	background-position: 2px 2px;
+}
+
+.toggleImageChapter {
+	background-image: url('../images/chapter.png');
+}
+
+.realisticBookIcon {
+	background-repeat: no-repeat;
+	background-image: url('../images/rbook.png');
+	height: 32px;
+	width: 32px;
+}
+
+.backToTop {
+	font-size:0.7em;
+	padding-left: 2em;
+	text-align:center;
+}
+
 #container {
 	position: relative;
@@ -16,5 +117,5 @@
 	max-width: 1000px;
 	padding: 0;
-	line-height: 160%;
+	line-height: 120%;
 	background-color: #fff;
 	border: 1px solid #c8c3b9;
@@ -31,11 +132,40 @@
 #gs_content {
 	padding: 1em;
+	padding-right: 2em;
 	min-height: 300px;
 	/* background-color: #ff0; */
 }
 
+.termList {
+	font-size:12px;
+	line-height:14px;
+}
+
+.noTermHighlight{
+
+}
+
+.termHighlight{
+	background:yellow;
+}
+
+.viewOptions {
+	width: 100%;
+	text-align:center;
+	background:#008800;
+}
+
+.viewOptions td {
+	padding-top:4px;
+	padding-bottom:4px;
+}
+
+.viewOptions a:link, .viewOptions a:hover, .viewOptions a:active, .viewOptions a:visited {
+	color:white;
+	text-decoration:none;
+}
+
 #rightSidebar {
 	border: 1px solid #cdc;
-	padding: 10px;
 	width: 25%;
 	min-width: 180px;
@@ -45,4 +175,8 @@
 }
 
+#contentsArea {
+	padding:10px;
+}
+
 #quickSearch {
 }
@@ -55,6 +189,4 @@
 .collectionLink {
 	display: block;
-	width: 140px;
-	height: 100px;
 	float: left;
 	border: 1px solid #888;
@@ -114,5 +246,5 @@
 	width:60%;
 	text-align:right;
-	padding: 5px;
+	padding: 0.4em;
 	color:white;
 	background-color:#007200;
@@ -130,9 +262,4 @@
 	text-transform:lowercase;
 	padding-left:10px; 
-}
-
-#expandqueryboxbutton {
-	color:white;
-	text-decoration:none;
 }
 
@@ -164,5 +291,5 @@
 }
 
-#nav a {
+#nav a{
 
 	display: block;
@@ -263,4 +390,5 @@
 /* style the search and classifier results */
 #results {
+	line-height: 160%;
 	margin: 0;
 	padding: 0;
@@ -677,5 +805,5 @@
 	margin: 0;
 	padding: 0;
-	font-size: 80%;
+	font-size: 70%;
 }
 
@@ -707,5 +835,13 @@
 
 #tableOfContents ul {
-	padding: 0 0 0 20px;
+	padding: 0 0 0 0;
+}
+
+#tableOfContents ul ul{
+	padding: 0 0 0 0;
+}
+
+#tableOfContents ul ul ul{
+	padding: 0 0 0 16px;
 }
 
@@ -721,5 +857,6 @@
 
 table{
-	border-collapse:collapse;border-spacing:0;
-}
-
+	border-collapse:collapse;
+	border-spacing:0;
+}
+
Index: main/trunk/greenstone3/web/interfaces/oran/transform/document-scripts.xsl
===================================================================
--- main/trunk/greenstone3/web/interfaces/oran/transform/document-scripts.xsl	(revision 23989)
+++ main/trunk/greenstone3/web/interfaces/oran/transform/document-scripts.xsl	(revision 23989)
@@ -0,0 +1,219 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:java="http://xml.apache.org/xslt/java"
+  xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
+  xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
+  extension-element-prefixes="java util"
+  exclude-result-prefixes="java util gsf">
+
+	<xsl:template name="expansionScript">
+		<script type="text/javascript">
+			<xsl:text disable-output-escaping="yes">
+				function toggleSection(sectionID)
+				{
+					var docElem = document.getElementById("doc" + sectionID);
+					var tocElem = document.getElementById("toc" + sectionID);
+					
+					var tocToggleElem = document.getElementById("ttoggle" + sectionID);
+					var docToggleElem = document.getElementById("dtoggle" + sectionID);
+					
+					if(docElem.style.display == "none")
+					{
+						var imageClass = (docToggleElem.getAttribute("class").indexOf("leafNode") != -1) ? "icon toggleImageCollapse leafNode" : "icon toggleImageCollapse";
+						
+						docElem.style.display = "block";
+						docToggleElem.setAttribute("class", imageClass);
+						
+						if(tocToggleElem)
+						{
+							tocToggleElem.setAttribute("class", imageClass);
+						}
+						
+						if(tocElem)
+						{
+							tocElem.style.display = "block";
+						}
+					}
+					else
+					{
+						docElem.style.display = "none";
+						
+						//Use the page image if this is a leaf node and the chapter image if it not
+						//var imageClass = (docToggleElem.getAttribute("class").indexOf("leafNode") != -1) ? "icon toggleImagePage leafNode" : "icon toggleImageChapter";
+						var imageClass = (docToggleElem.getAttribute("class").indexOf("leafNode") != -1) ? "icon toggleImageExpand leafNode" : "icon toggleImageExpand";
+						docToggleElem.setAttribute("class", imageClass);
+						
+						if(tocToggleElem)
+						{
+							tocToggleElem.setAttribute("class", imageClass);
+						}
+						
+						if(tocElem)
+						{
+							tocElem.style.display = "none";
+						}
+					}
+				}
+				
+				function isExpanded(sectionID)
+				{
+					var docElem = document.getElementById("doc" + sectionID);
+					if(docElem.style.display == "block")
+					{
+						return true;
+					}
+					return false;
+				}
+				
+				function isParentOf(parent, child)
+				{
+					if(child.indexOf(parent) != -1 &amp;&amp; child.length > parent.length &amp;&amp; child[parent.length] == '.')
+					{
+						return true;
+					}
+					return false;
+				}
+				
+				function focusSection(sectionID)
+				{
+					var tableOfContentsDiv = document.getElementById("tableOfContents");
+					var images = tableOfContentsDiv.getElementsByTagName("img");
+					var nodeArray = new Array();
+					
+					for(var i = 0; i &lt; images.length; i++)
+					{	
+						nodeArray[i] = images[i].getAttribute("id").substring(7);
+					}
+					
+					for(var j = 0; j &lt; nodeArray.length; j++)
+					{
+						//If this is the node that was clicked and it is not expanded then expand it
+						if(nodeArray[j] == sectionID)
+						{
+							if(!isExpanded(nodeArray[j]))
+							{
+								toggleSection(nodeArray[j]);
+							}
+							
+							continue;
+						}
+						
+						//If the node is a parent or child of the node that is clicked and is not expanded then expand it
+						if((isParentOf(nodeArray[j], sectionID) || isParentOf(sectionID, nodeArray[j])) &amp;&amp; !isExpanded(nodeArray[j]))
+						{
+							toggleSection(nodeArray[j]);
+						}
+						//If the node is not a parent or child and is expanded then collapse it
+						else if(!(isParentOf(nodeArray[j], sectionID) || isParentOf(sectionID, nodeArray[j])) &amp;&amp; isExpanded(nodeArray[j]))
+						{
+							toggleSection(nodeArray[j]);
+						}
+					}
+				}
+			</xsl:text>
+		</script>
+	</xsl:template>
+	
+	<xsl:template name="highlightingScript">
+		<script type="text/javascript">
+			<xsl:text disable-output-escaping="yes">
+				function addHighlight()
+				{
+					var spans = document.getElementsByTagName("span");
+					for(var i = 0; i &lt; spans.length; i++)
+					{
+						var currentSpan = spans[i];
+						if(currentSpan.getAttribute("class") == "noTermHighlight")
+						{
+							currentSpan.setAttribute("class", "termHighlight");
+						}
+					}
+					
+					var option = document.getElementById("highlightOption");
+					option.innerHTML = "No Highlighting";
+					option.setAttribute("href", "javascript:removeHighlight();");
+				}
+				
+				function removeHighlight()
+				{
+					var spans = document.getElementsByTagName("span");
+					for(var i = 0; i &lt; spans.length; i++)
+					{
+						var currentSpan = spans[i];
+						if(currentSpan.getAttribute("class") == "termHighlight")
+						{
+							currentSpan.setAttribute("class", "noTermHighlight");
+						}
+					}
+					
+					var option = document.getElementById("highlightOption");
+					option.innerHTML = "Highlighting";
+					option.setAttribute("href", "javascript:addHighlight();");
+				}
+			</xsl:text>
+		</script>
+	</xsl:template>
+	
+	<xsl:template name="realisticBooksScript">
+		<div id="bookdiv"/>
+		<script type="text/javascript">
+			<xsl:text disable-output-escaping="yes">
+				
+				//Helper function to create param elements
+				function createParam(name, value)
+				{
+					var param = document.createElement("PARAM");
+					param.setAttribute("name", name);
+					param.setAttribute("value", value);
+					return param;
+				}
+				
+				//Work out the URL to the cover image and the document
+				var img_cover = '</xsl:text><xsl:value-of select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']"/>/index/assoc/<xsl:value-of select="metadataList/metadata[@name='assocfilepath']"/>/cover.jpg<xsl:text disable-output-escaping="yes">';
+				var doc_url = document.URL; 
+				doc_url = doc_url.replace(/(&amp;|\?)book=[a-z]+/gi,'');
+				doc_url += '&amp;book=flashxml';	
+				
+				//The outer OBJECT element
+				var objectElem = document.createElement("OBJECT");
+				objectElem.setAttribute("align", "middle");
+				objectElem.setAttribute("classid", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000");
+				objectElem.setAttribute("codebase", "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0");
+				objectElem.setAttribute("height", "600px");
+				objectElem.setAttribute("width", "100%");
+				
+				//Parameter list
+				var params = new Array();
+				params[0] = createParam("allowScriptAccess", "always");
+				params[1] = createParam("movie", "Book.swf?src_image=" + escape(img_cover) + "&amp;doc_url=" + escape(doc_url));
+				params[2] = createParam("quality", "high");
+				params[3] = createParam("bgcolor", "#FFFFFF");
+				
+				//The embed element that goes into the object element
+				var embedElem = document.createElement("EMBED");
+				embedElem.setAttribute("allowScriptAccess", "always");
+				embedElem.setAttribute("swLiveConnect", "true");
+				embedElem.setAttribute("bgcolor", "#FFFFFF");
+				embedElem.setAttribute("height", "600px");
+				embedElem.setAttribute("name", "Book");
+				embedElem.setAttribute("pluginspage", "http://www.macromedia.com/go/getflashplayer");
+				embedElem.setAttribute("quality", "high");
+				embedElem.setAttribute("src", "Book.swf?src_image=" + escape(img_cover) + "&amp;doc_url=" + escape(doc_url));
+				embedElem.setAttribute("type", "application/x-shockwave-flash");
+				embedElem.setAttribute("width", "100%");
+				
+				//Append the param and embed elements to the object element
+				for(var i = 0; i &lt; params.length; i++)
+				{
+					objectElem.appendChild(params[i]);
+				}
+				objectElem.appendChild(embedElem);
+				
+				//Append the object element to the page
+				var flashDiv = document.getElementById("bookdiv");
+				flashDiv.appendChild(objectElem);
+			</xsl:text>
+		</script>
+	</xsl:template>
+</xsl:stylesheet>
Index: main/trunk/greenstone3/web/interfaces/oran/transform/formatmanager.xsl
===================================================================
--- main/trunk/greenstone3/web/interfaces/oran/transform/formatmanager.xsl	(revision 23989)
+++ main/trunk/greenstone3/web/interfaces/oran/transform/formatmanager.xsl	(revision 23989)
@@ -0,0 +1,151 @@
+<xsl:stylesheet version="1.0"
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+	xmlns:java="http://xml.apache.org/xslt/java"
+	xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
+	xmlns:gslib="http://www.greenstone.org/skinning"
+	extension-element-prefixes="java util"
+	exclude-result-prefixes="java util">
+
+	<xsl:template name="formatmanagerpre">
+	
+    <!-- <xsl:variable name="foo"> -->
+    <!-- <xsl:value-of select="/page/pageRequest/paramList[@name='formatedit']"/> -->
+
+    <xsl:if test="/page/pageRequest/paramList/param[(@name='formatedit') and (@value='1')]">
+
+	<!-- Sam2's div code -->
+
+		<script type="text/javascript" src="interfaces/oran/js/innerxhtml.js"><xsl:text> </xsl:text></script>
+		<script type="text/javascript" src="interfaces/oran/js/gui_div.js"><xsl:text> </xsl:text></script>
+	   
+		<xsl:call-template name="xml-to-gui-templates">
+			<xsl:with-param name="node-set" select="test"/>
+			<xsl:with-param name="metadataSets" select="//metadataSetList"/>
+		</xsl:call-template>
+
+		<xsl:variable name="fmt1">
+			<xsl:call-template name="xml-to-string">
+				<xsl:with-param name="node-set" select="//format[@type='browse']"/>
+			  </xsl:call-template>
+		</xsl:variable>
+
+		<xsl:variable name="meta">
+			<xsl:call-template name="xml-to-string">
+				<xsl:with-param name="node-set" select="//metadataSetList"/>
+			  </xsl:call-template>
+		</xsl:variable>
+
+		<style type="text/css">
+			.placeholder{margin-left: 10px; border: dashed 1px #ccc; background-color:#FFFFCC; height:20px; }
+
+			.placeholder_td{margin-left: 10px; border: dashed 1px #ccc; background-color:#FFFFCC; width:20px; }
+
+			.header { background-color: #AFCCAF; border: solid 1px #117711; padding: 5px; padding-left: 10px;}
+
+			.resizable { width: 150px; height: 150px; padding: 0.5em; } 
+			
+			.block { margin-left: 15px; border-left: dashed 1px black;}
+
+			.droppable { background-color: #99dd99;}
+			.droppable_hl { border: dashed 1px #ccc; background-color:#FFFFCC; }
+
+			<!-- .gsf_metadata { border: solid 2px #0000BB; background-color: #440077; } -->
+
+			<!-- .gsf_choose_metadata { border: solid 1px #000000; background-color: #223344; } -->
+		</style>
+
+		<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/base/jquery-ui.css"/> 
+
+		<table width="100%" border="1"> 
+
+		<td width="75%">
+
+		<button id="updateFormatStatement" type="button" onclick="updateFormatStatement()">Update Format Statement</button>
+		<button id="saveFormatStatement" type="button" onclick="saveFormatStatement()">Save Format Statement</button>
+
+		<div id="formatStatement">
+			<div id="formatRoot">
+		
+		<xsl:call-template name="xml-to-gui">
+			<xsl:with-param name="node-set" select="//format"/> <!-- [@type='browse']"/>  -->
+			<xsl:with-param name="metadataSets" select="//metadataSetList"/> 
+		</xsl:call-template> 
+			</div>
+		</div>
+		</td>    
+
+
+		<td width="25%" valign="top">
+			<h2> Elements to add </h2>
+			<!-- <div class="header element_type_gsf_template css_gsf_template" title="gsf:template">TEMPLATE</div> -->
+			<div class="draggable_gsf_template css_gsf_template block" title="gsf:template"><table class="header"><tbody><tr><td class="header">MATCH=<input type="text" name="rawtextinput" size="10"/></td><td><a href="#" class="minmax ui-icon ui-icon-minusthick">[-]</a></td><td><a href="#" class="remove ui-icon ui-icon-closethick">[x]</a></td></tr></tbody></table><table border="1"><tr class="tr"><td class="droppable" width="10px"></td></tr></table></div><br/>
+
+			<div class="draggable_gsf_choose_metadata css_gsf_choose_metadata block" title="gsf:choose-metadata"><table class="header"><tbody><tr><td class="header">CHOOSE</td><td class="header"><a href="#" class="minmax ui-icon ui-icon-minusthick" title="Click me to expand">[-]</a></td><td class="header"><a href="#" class="remove ui-icon ui-icon-closethick" title="Click me to remove"/></td></tr></tbody></table></div>
+
+			<div class="draggable_gsf_metadata css_gsf_metadata block" title="gsf:metadata"><table class="header"><tbody><tr><td class="header"><xsl:call-template name="meta-to-combo">
+							<xsl:with-param name="metadataSets" select="//metadataSetList"/>
+							<xsl:with-param name="current" select="ex.Title"/>
+						 </xsl:call-template></td><td class="header"><a href="#" class="remove ui-icon ui-icon-closethick" title="Click me to remove"/></td></tr></tbody></table></div>
+
+			<div class="draggable_gsf_link css_gsf_link block" title="gsf:link"><table class="header"><tbody><tr><td class="header">LINK<select>
+								<option value = "document" selected = "document">Document</option>
+								<option value = "classifier">Classifier</option>
+								<option value = "source">Source</option>
+								<option value = "horizontal">Horizontal</option>
+					</select></td><td><a href="#" class="minmax ui-icon ui-icon-minusthick">[-]</a></td><td><a href="#" class="remove ui-icon ui-icon-closethick">[x]</a></td></tr></tbody></table></div>
+
+			<div class="draggable_gsf_switch css_gsf_switch block" title="gsf:switch"><table class="header"><tbody><tr><td class="header">SWITCH</td><td><a href="#" class="minmax ui-icon ui-icon-minusthick">[-]</a></td><td><a href="#" class="remove ui-icon ui-icon-closethick">[x]</a></td></tr></tbody></table></div>
+
+			<div class="draggable_gsf_when css_gsf_when block" title="gsf:when"><table class="header"><tbody><tr><td class="header">WHEN<xsl:value-of select="@test"/></td><td class="header"><a href="#" class="minmax ui-icon ui-icon-minusthick">[-]</a></td><td class="header"><a href="[myhref]" class="ui-icon ui-icon-closethick"/></td></tr></tbody></table></div>
+
+			<div class="draggable_gsf_otherwise css_gsf_otherwise block" title="gsf:otherwise"><table class="header"><tbody><tr><td class="header">OTHERWISE</td><td class="header"><a href="#" class="minmax ui-icon ui-icon-minusthick">[-]</a></td><td><a href="#" class="ui-icon ui-icon-closethick"/></td></tr></tbody></table></div>
+
+			<div class="draggable_gsf_icon css_gsf_icon block" title="gsf:icon"><table class="header"><tbody><tr><td class="header">ICON<select><option value = "document" selected = "document">Document</option><option value = "classifier">Classifier</option><option value = "source">Source</option></select></td><td><a href="#" class="remove ui-icon ui-icon-closethick">[x]</a></td></tr></tbody></table></div>
+			<br/>
+			<div class="draggable_gsf_text css_text" title="text"><table class="header"><tbody><tr><td class="header"><input type="text" name="rawtextinput" size="10" value=""/></td><td class="header"><a href="[myhref]" class="ui-icon ui-icon-closethick"/></td></tr></tbody></table></div>
+			<div class="draggable_table css_table" title="gsf:table">NEW TABLE</div>
+			<div class="draggable_tr css_tr" title="gsf:row">NEW TABLE ROW</div>
+			<div class="draggable_td css_td" title="gsf:column">NEW TABLE COLUMN</div>
+
+		</td>
+		</table>
+
+		<!--
+		<div id="format">
+			<p>
+			  <b>Format string here</b>
+			  <i>
+				  <xsl:value-of select="$fmt1"/>
+			  </i>
+			</p>
+		</div> -->
+		<!--    <p>
+			  <i>
+				  <xsl:value-of select="$meta"/>
+			  </i>
+			</p>
+		  </div> -->
+      </xsl:if>
+
+<!--<H2>Preview</H2>
+
+                    <div id="my_categories"><xsl:text> </xsl:text></div>
+
+                    <iframe name="preview" id="iframe" width="98%" height="300">Your browser does not support iframes</iframe> 
+
+                    <xsl:variable name="preview"> -->
+                    <!-- <button type="button" onclick="loadXMLDoc()">Change Content</button> -->
+	</xsl:template>
+	
+	<xsl:template name="formatmanagerpost">
+		   <!--                 </xsl:variable>
+
+                    <script type="text/javascript">
+                        preview_html = <xsl:text disable-output-escaping="yes">'</xsl:text><xsl:copy-of select="$preview"/><xsl:text disable-output-escaping="yes">';</xsl:text>
+                    </script>
+
+                    <div id="result">
+                    Here
+                    </div>-->
+	</xsl:template>
+</xsl:stylesheet>
Index: main/trunk/greenstone3/web/interfaces/oran/transform/layouts/header.xsl
===================================================================
--- main/trunk/greenstone3/web/interfaces/oran/transform/layouts/header.xsl	(revision 23989)
+++ main/trunk/greenstone3/web/interfaces/oran/transform/layouts/header.xsl	(revision 23989)
@@ -0,0 +1,228 @@
+<xsl:stylesheet version="1.0"
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+	xmlns:java="http://xml.apache.org/xslt/java"
+	xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
+	xmlns:gslib="http://www.greenstone.org/skinning"
+	extension-element-prefixes="java util"
+	exclude-result-prefixes="java util">
+		
+	<xsl:include href="../query-common.xsl"/>
+	
+	<!-- If the c parameter is empty then use the p.c parameter for the collection name-->
+	<xsl:variable name="collNameChecked">
+		<xsl:choose>
+		<xsl:when test="$collName = '' and /page/pageRequest/paramList/param[@name='p.c']/@value">
+			<xsl:value-of select="/page/pageRequest/paramList/param[@name='p.c']/@value"/>
+		</xsl:when>
+		<xsl:otherwise>
+			<xsl:value-of select="$collName"/>
+		</xsl:otherwise>
+		</xsl:choose>
+	</xsl:variable>
+	
+	<!-- Creates a header for -->
+	<xsl:template name="create-html-header">
+		<title><xsl:call-template name="pageTitle"/> :: <xsl:call-template name="siteName"/></title>
+		<link rel="stylesheet" href="interfaces/{$interface_name}/style/core.css" type="text/css"/>
+		<link rel="shortcut icon" href="favicon.ico"/> 
+	</xsl:template>
+		
+	<!-- ***** HEADER LAYOUT TEMPLATE ***** -->
+	<xsl:template name="create-banner">
+		<div id="breadcrumbs"><xsl:call-template name="breadcrumbs"/><xsl:text> </xsl:text></div>
+		<table id="titlesearchcontainer">
+			<tr>
+				<xsl:call-template name="page-title-area"/>
+				<xsl:call-template name="quick-search-area"/>
+			</tr>
+		</table>
+		<xsl:call-template name="home-help-preferences"/>
+		<xsl:call-template name="browsing-tabs"/>
+	</xsl:template>
+	
+	<!-- ***** BROWSING TABS ***** -->
+	<xsl:template name="browsing-tabs">
+		<xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service">
+			<ul id="nav">
+				<!-- If this collection has a ClassifierBrowse service then add a tab for each classifier-->
+				<xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@type='browse' and @name='ClassifierBrowse']">
+					<!-- Loop through each classifier -->
+					<xsl:for-each select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier">
+						<xsl:element name="li">
+							<!-- If this tab is selected then colour it differently (right part) -->
+							<xsl:if test="@name = /page/pageRequest/paramList/param[@name = 'cl' and /page/pageRequest/@action = 'b']/@value">
+								<xsl:attribute name='style'>background: transparent url('interfaces/oran/images/tab-right-selected.png') scroll no-repeat 100% -100px;</xsl:attribute>
+							</xsl:if>
+							
+							<xsl:element name="a">
+								<!-- If this tab is selected then colour it differently (left part) -->
+								<xsl:if test="@name = /page/pageRequest/paramList/param[@name = 'cl' and /page/pageRequest/@action = 'b']/@value">
+									<xsl:attribute name='style'>background: transparent url('interfaces/oran/images/tab-left-selected.png') no-repeat scroll 0 -100px;</xsl:attribute>
+								</xsl:if>
+								
+								<!-- Add a title element to the <a> tag if a description exists for this classifier -->
+								<xsl:if test="displayItem[@name='description']">
+									<xsl:attribute name='title'><xsl:value-of select="displayItem[@name='description']"/></xsl:attribute>
+								</xsl:if>
+								
+								<!-- Add the href element to the <a> tag -->
+								<xsl:choose>
+									<xsl:when test="@name">
+										<xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=b&amp;rt=s&amp;s=ClassifierBrowse&amp;c=<xsl:value-of select="/page/pageResponse/collection[@name=$collNameChecked]/@name"/>&amp;cl=<xsl:value-of select="@name"/></xsl:attribute>
+									</xsl:when>
+									<xsl:otherwise>
+										<xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=b&amp;rt=d&amp;s=ClassifierBrowse&amp;c=<xsl:value-of select="/page/pageResponse/collection[@name=$collNameChecked]/@name"/></xsl:attribute>
+									</xsl:otherwise>
+								</xsl:choose>
+								
+								<!-- Add the actual text of the <a> tag -->
+								<xsl:value-of select="displayItem[@name='name']"/>
+							</xsl:element>
+						</xsl:element>
+					</xsl:for-each>
+				</xsl:if>
+
+				<!-- all other services -->
+				<xsl:for-each select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[not(@type='query') and not(@type='browse')]">
+					<xsl:call-template name="navigationTab"/>
+				</xsl:for-each>
+			</ul>
+		</xsl:if>
+	</xsl:template>
+	
+	<!-- ***** HOME HELP PREFERENCES ***** -->
+	<xsl:template name="home-help-preferences">
+		<xsl:if test="/page/pageResponse/collection">
+			<ul id="bannerLinks">
+
+				<!-- preferences -->
+				<li>
+					<a href="{$library_name}?a=p&amp;amp;sa=pref&amp;amp;c={$collNameChecked}">
+						<xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref_tip')"/></xsl:attribute>
+						<xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref_b')"/>
+					</a>
+				</li>
+
+				<!-- help -->
+				<li>
+					<a href="{$library_name}?a=p&amp;amp;sa=help&amp;amp;c={$collNameChecked}">
+						<xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'help_tip')"/></xsl:attribute>
+						<xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'help_b')"/>
+					</a>
+				</li>
+
+				<!-- home -->
+				<li>
+					<a href="{$library_name}?a=p&amp;amp;sa=home">
+						<xsl:attribute name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'home_tip')"/></xsl:attribute>
+						<xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'home_b')"/>
+					</a>
+				</li>
+			</ul>
+		</xsl:if>
+	</xsl:template>
+	
+	<!-- ***** PAGE TITLE ***** -->
+	<xsl:template name="page-title-area">
+		<xsl:variable name="pageTitleVar"><xsl:call-template name="pageTitle"/></xsl:variable>
+		<td id="titlearea">
+			<h2>
+				<!-- Resize the title based on how long it is -->
+				<xsl:attribute name="style">
+					<xsl:choose>
+						<xsl:when test="string-length($pageTitleVar) &lt; 20">
+							font-size: 24px; line-height: 26px;
+						</xsl:when>
+						<xsl:when test="string-length($pageTitleVar) &lt; 30">
+							font-size: 22px; line-height: 24px;
+						</xsl:when>
+						<xsl:when test="string-length($pageTitleVar) &lt; 40">
+							font-size: 20px; line-height: 22px;
+						</xsl:when>
+						<xsl:when test="string-length($pageTitleVar) &lt; 50">
+							font-size: 18px; line-height: 20px;
+						</xsl:when>
+						<xsl:when test="string-length($pageTitleVar) &lt; 60">
+							font-size: 16px; line-height: 18px;
+						</xsl:when>
+						<xsl:when test="string-length($pageTitleVar) &lt; 70">
+							font-size: 15px; line-height: 17px;
+						</xsl:when>
+						<xsl:when test="string-length($pageTitleVar) &lt; 80">
+							font-size: 14px; line-height: 16px;
+						</xsl:when>
+						<xsl:when test="string-length($pageTitleVar) &lt; 90">
+							font-size: 13px; line-height: 15px;
+						</xsl:when>
+						<xsl:otherwise>
+							font-size: 12px; line-height: 14px;
+						</xsl:otherwise>
+					</xsl:choose>
+				</xsl:attribute>
+				<!--<xsl:value-of select="string-length($pageTitleVar)" />-->
+				<xsl:value-of select="$pageTitleVar" />
+			</h2>
+		</td>
+	</xsl:template>
+	
+	
+	<!-- ***** QUICK SEARCH AREA ***** -->
+	<xsl:template name="quick-search-area">
+		<xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']">
+			<xsl:variable name="subaction" select="/page/pageRequest/@subaction"/>
+			<td id="quicksearcharea">
+				<form>
+					<input type="hidden" name="a" value="q"/>
+					<input type="hidden" name="sa" value="{$subaction}"/>
+					<input type="hidden" name="rt" value="rd"/>
+					<input type="hidden" name="s" value="TextQuery"/>
+					<input type="hidden" name="c" value="{$collNameChecked}"/>
+					<input type="hidden" name="startPage" value="1"/>
+					<!-- The query text box -->
+					<span class="querybox">
+						<xsl:variable name="qs">
+							<xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='query']" mode="calculate-default"/>
+						</xsl:variable>
+						<nobr>
+							<xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='query']">
+								<xsl:with-param name="default" select="java:org.greenstone.gsdl3.util.XSLTUtil.tidyWhitespace($qs)"/>
+							</xsl:apply-templates>
+						</nobr>
+					</span>
+					<!-- The index selection list -->
+					<xsl:if test="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']/@type = 'enum_single'">
+						<span class="textselect">
+							<xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']">
+								<xsl:with-param name="default">
+									<xsl:apply-templates select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/paramList/param[@name='index']" mode="calculate-default"/>
+								</xsl:with-param>
+							</xsl:apply-templates>
+						</span>
+					</xsl:if>
+					<!-- The submit button -->
+					<input type="submit">
+						<xsl:attribute name="value">
+							<xsl:value-of select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@name='TextQuery']/displayItem[@name='submit']"/>
+						</xsl:attribute>
+					</input>
+					<br/>
+					<!-- The list of other search types -->
+					<table>
+						<tr>
+							<xsl:for-each select="/page/pageResponse/collection[@name=$collNameChecked]/serviceList/service[@type='query']">
+								<td>
+									<a>
+										<xsl:attribute name="href">
+											?a=q&amp;rt=d&amp;c=<xsl:value-of select="$collNameChecked"/>&amp;s=<xsl:value-of select="@name"/>
+										</xsl:attribute>
+										<xsl:value-of select="displayItem[@name='name']"/>
+									</a>
+								</td>
+							</xsl:for-each>
+						</tr>
+					</table>
+				</form>
+			</td>
+		</xsl:if>
+	</xsl:template>
+</xsl:stylesheet>
Index: main/trunk/greenstone3/web/interfaces/oran/transform/layouts/main.xsl
===================================================================
--- main/trunk/greenstone3/web/interfaces/oran/transform/layouts/main.xsl	(revision 23972)
+++ main/trunk/greenstone3/web/interfaces/oran/transform/layouts/main.xsl	(revision 23989)
@@ -42,7 +42,7 @@
 			
 			<body><xsl:call-template name="textDirectionAttribute"/><xsl:call-template name="actionClass"/>
-
+				
 				<xsl:call-template name="displayErrorsIfAny"/>
-
+				<a name="top"><xsl:text> </xsl:text></a>
 				<div id="container">
 
Index: main/trunk/greenstone3/web/interfaces/oran/transform/pages/classifier.xsl
===================================================================
--- main/trunk/greenstone3/web/interfaces/oran/transform/pages/classifier.xsl	(revision 23972)
+++ main/trunk/greenstone3/web/interfaces/oran/transform/pages/classifier.xsl	(revision 23989)
@@ -63,5 +63,5 @@
 
 			<a>
-				<xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=d&amp;c=<xsl:value-of select="/page/pageResponse/collection/@name"/>&amp;d=<xsl:value-of select="@nodeID"/>&amp;dt=<xsl:value-of select="@docType"/>&amp;p.a=b&amp;p.s=<xsl:value-of select="/page/pageResponse/service/@name"/></xsl:attribute>
+				<xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=d&amp;c=<xsl:value-of select="/page/pageResponse/collection/@name"/>&amp;d=<xsl:value-of select="@nodeID"/>&amp;dt=<xsl:value-of select="@docType"/>&amp;p.a=b&amp;p.s=<xsl:value-of select="/page/pageResponse/service/@name"/>&amp;ed=1</xsl:attribute>
 				<xsl:value-of disable-output-escaping="yes"  select="metadataList/metadata[@name='Title']"/>
 			</a>
Index: main/trunk/greenstone3/web/interfaces/oran/transform/pages/document.xsl
===================================================================
--- main/trunk/greenstone3/web/interfaces/oran/transform/pages/document.xsl	(revision 23972)
+++ main/trunk/greenstone3/web/interfaces/oran/transform/pages/document.xsl	(revision 23989)
@@ -9,9 +9,19 @@
 	exclude-result-prefixes="java util gsf">
 
+	<!-- use the 'main' layout -->
+	<xsl:import href="layouts/main.xsl"/>
+	
 	<!-- style includes global params interface_name, library_name -->
 	<xsl:include href=".old/berrytools.xsl"/>
-
-	<!-- use the 'main' layout -->
-	<xsl:include href="layouts/main.xsl"/>
+	<xsl:include href="document-scripts.xsl"/>
+	
+	<xsl:variable name="bookswitch">
+		<xsl:choose>
+			<xsl:when test="/page/pageRequest/paramList/param[@name='book']/@value">
+				<xsl:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/>
+			</xsl:when>
+			<xsl:otherwise>off</xsl:otherwise>
+		</xsl:choose>
+	</xsl:variable>
 
 	<!-- set page title -->
@@ -32,28 +42,56 @@
 		</a>
 	</xsl:template>
+	
+	<xsl:template match="/">
+		<xsl:choose>
+			<!-- if this is the realistic books version of the page -->
+			<xsl:when test="$bookswitch = 'flashxml'">
+				<html>
+					<body>
+						<xsl:apply-templates select="/page/pageResponse/document"/>
+					</body>
+				</html>
+			</xsl:when>
+			<!-- if this is the regular version of the page -->
+			<xsl:otherwise>
+				<xsl:apply-imports/>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
 
 	<!-- the page content -->
 	<xsl:template match="/page/pageResponse/document">
-
-		<!-- show the little berries for this document -->
-		<xsl:call-template name="documentBerryForDocumentPage"/>
-
-		<!-- the sidebar -->
-		<div id="rightSidebar">
-
-			<!-- show the berry basket if it's turned on -->
-			<gslib:berryBasket/>
-
-			<!-- the book's cover image -->
-			<div id="coverImage"><gslib:coverImage/></div>
-			<br/>
-
-			<!-- the contents -->
-			<ul id="tableOfContents">
-				<xsl:apply-templates select="documentNode/documentNode"/>
-			</ul>
-
-		</div>
-
+		<xsl:if test="$bookswitch = 'off'">
+			<!-- Add the Javascript that adds and removes highlighting ( *** in document-scripts.xsl *** ) -->
+			<xsl:call-template name="highlightingScript"/>
+			
+			<!-- Add the Javascript that expands and collapses sections ( *** in document-scripts.xsl *** ) -->
+			<xsl:call-template name="expansionScript"/>
+		
+			<!-- show the little berries for this document -->
+			<xsl:call-template name="documentBerryForDocumentPage"/>
+
+			<table id="rightSidebar"> 
+				<tr><td>
+					<xsl:call-template name="viewOptions"/>
+				</td></tr>
+				<tr><td>
+					<!-- the sidebar -->
+					<div id="contentsArea">				
+						<!-- show the berry basket if it's turned on -->
+						<gslib:berryBasket/>
+
+						<!-- the book's cover image -->
+						<div id="coverImage"><gslib:coverImage/></div>
+
+						<!-- the contents -->
+						<div id="tableOfContents">
+							<xsl:apply-templates select="documentNode" mode="TOC"/>
+						</div>
+					</div>
+				</td></tr>
+			</table>
+		</xsl:if>
+		
 		<!-- display the document -->
 		<xsl:choose>
@@ -63,83 +101,186 @@
 				</xsl:call-template>
 			</xsl:when>
-
+			<xsl:when test="$bookswitch = 'flashxml'">
+				<xsl:apply-templates mode="flashxml"/>
+			</xsl:when>
+			<xsl:when test="$bookswitch = 'on'">
+				<!-- *** in document-scripts.xsl *** -->
+				<xsl:call-template name="realisticBooksScript"/>
+			</xsl:when>
 			<xsl:otherwise>
-				<!-- document heading -->
-				<xsl:variable name="doCoverImage" select="/page/pageResponse/format/gsf:option[@name='coverImages']/@value"/>
-				<xsl:variable name="doTOC" select="/page/pageResponse/format/gsf:option[@name='documentTOC']/@value"/>
-				<xsl:variable name="p.a" select="/page/pageRequest/paramList/param[@name='p.a']/@value"/>
-				<xsl:variable name="p.sa" select="/page/pageRequest/paramList/param[@name='p.sa']/@value"/>
-				<xsl:variable name="p.s" select="/page/pageRequest/paramList/param[@name='p.s']/@value"/>
-				<xsl:variable name="p.c"><xsl:choose><xsl:when test="/page/pageRequest/paramList/param[@name='p.c']"><xsl:value-of select="/page/pageRequest/paramList/param[@name='p.c']/@value"/></xsl:when><xsl:otherwise><xsl:value-of select="$collName"/></xsl:otherwise></xsl:choose></xsl:variable>
-
-				<!--
-				<div id="documentheading">
-
-					<!- -<a href="{$library_name}?a={$p.a}&amp;sa={$p.sa}&amp;s={$p.s}&amp;c={$p.c}&amp;rt=rd"><xsl:call-template name="openbookimg"><xsl:with-param name="title"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'close_book')"/></xsl:with-param></xsl:call-template></a>- ->
-
+				<div id="gs-document-text" class="documenttext"> 
+					<xsl:apply-templates select="documentNode" mode="document"/>
+				</div>
+			</xsl:otherwise>
+		</xsl:choose>
+
+		<div class="clear"><xsl:text> </xsl:text></div>
+	</xsl:template>
+	
+	<!-- Highlight annotations if requested -->
+	<xsl:template match="annotation">
+		<xsl:choose>
+			<xsl:when test="/page/pageRequest/paramList/param[@name='hl' and @value='on']">
+				<span class="termHighlight"><xsl:value-of select="."/></span>
+			</xsl:when>
+			<xsl:otherwise>
+				<span class="noTermHighlight"><xsl:value-of select="."/></span>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+	
+	<!-- This template is used to display the document content -->
+	<xsl:template match="documentNode" mode="document">
+		<a name="{@nodeID}"><xsl:text> </xsl:text></a>
+		<!-- Section header -->
+		<table><tr>
+			<!-- Expand/collapse button -->
+			<td class="headerTD">
+				<div id="dtoggle{@nodeID}" onclick="toggleSection('{@nodeID}');">			
+					<xsl:attribute name="class">
 					<xsl:choose>
-						<xsl:when test="@docType='simple'"><xsl:value-of select="metadataList/metadata[@name='Title']" disable-output-escaping="yes"/></xsl:when>
-						<xsl:otherwise><xsl:value-of select="documentNode/metadataList/metadata[@name='Title']" disable-output-escaping="yes"/></xsl:otherwise>
+						<xsl:when test="nodeContent and not(documentNode)">icon leafNode toggleImageCollapse</xsl:when>
+						<xsl:otherwise>icon toggleImageCollapse</xsl:otherwise>
 					</xsl:choose>
-
+					</xsl:attribute>
 				</div>
-				-->
-
-				<div id="gs-document-text" class="documenttext"> 
-					<xsl:for-each select="descendant-or-self::node()/nodeContent">
-						<h3><xsl:value-of disable-output-escaping="yes" select="../metadataList/metadata[@name='Title']"/></h3>
-						<xsl:for-each select="node()">
+			</td>
+			
+			<!-- Automatic section number -->
+			<td class="headerTD">
+				<p>
+					<xsl:attribute name="class"><xsl:value-of select="util:hashToDepthClass(@nodeID)"/> sectionHeader</xsl:attribute>
+					
+					<xsl:if test="util:hashToSectionId(@nodeID)">
+						<span class="sectionNumberSpan">
+							<xsl:value-of select="util:hashToSectionId(@nodeID)"/>
+							<xsl:text> </xsl:text>
+						</span>
+					</xsl:if>
+					<xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/> 
+				</p>
+			</td>
+			
+			<!-- "back to top" link -->
+			<xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle'">
+				<td class="backToTop headerTD">
+					<a href="#top">
+						<xsl:text disable-output-escaping="yes">&#9650;back to top</xsl:text>
+					</a>
+				</td>
+			</xsl:if>
+		</tr></table>
+		
+		<!-- Section text -->
+		<div id="doc{@nodeID}" class="sectionContainer" style="display:block;">		
+			<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:otherwise>
+							<xsl:apply-templates select="."/>
+						</xsl:otherwise>
+					</xsl:choose>
+				</xsl:for-each>
+			</xsl:for-each>
+			<xsl:if test="documentNode">
+				<xsl:apply-templates select="documentNode" mode="document"/>
+			</xsl:if>
+		</div>	
+
+	</xsl:template>
+
+	<!-- This template is used to display the table of contents -->
+	<xsl:template match="documentNode" mode="TOC">
+
+		<!-- check if this is the currently selected table of contents item -->
+		<xsl:variable name="isCurrent" select="nodeContent"/>
+
+		<!-- formulate the link -->
+		<xsl:variable name="contentsLink">
+			<xsl:value-of select='$library_name'/>?a=d&amp;c=<gslib:collectionNameShort/>&amp;d=<xsl:value-of select='@nodeID'/><xsl:if test="documentNode">.pr</xsl:if>&amp;sib=1
+		</xsl:variable>
+
+		<ul>
+			<table><tr>
+				<!-- The expand/collapse button (not displayed for the top level node) -->
+				<xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle'">
+					<td>
+						<xsl:choose>
+							<xsl:when test="not(nodeContent and not(documentNode))">
+								<div id="ttoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon toggleImageCollapse"/>
+							</xsl:when>
+							<xsl:otherwise>
+								<div class="icon"/>
+							</xsl:otherwise>
+						</xsl:choose>
+					</td>
+				</xsl:if>
+				
+				<!-- The chapter/page icon -->
+				<td>
+					<div>
+						<xsl:attribute name="class">
 							<xsl:choose>
-								<xsl:when test="not(name())">
-									<xsl:value-of select="." disable-output-escaping="yes"/>
+								<xsl:when test="nodeContent and not(documentNode)">
+									icon leafNode toggleImagePage
 								</xsl:when>
 								<xsl:otherwise>
-									<xsl:apply-templates select="."/>
+									icon toggleImageChapter
 								</xsl:otherwise>
 							</xsl:choose>
-						</xsl:for-each>
-					</xsl:for-each>
-				</div>
-
-				<gslib:previousNextButtons/>
-
-			</xsl:otherwise>
-		</xsl:choose>
-
-		<div class="clear"><xsl:text> </xsl:text></div>
-
-	</xsl:template>
-
-	<xsl:template match="documentNode">
-
-		<!-- check if this is the currently selected table of contents item -->
-		<xsl:variable name="isCurrent" select="nodeContent"/>
-
-		<!-- formulate the link -->
-		<xsl:variable name="contentsLink">
-			<xsl:value-of select='$library_name'/>?a=d&amp;c=<gslib:collectionNameShort/>&amp;d=<xsl:value-of select='@nodeID'/><xsl:if test="documentNode">.pr</xsl:if>&amp;sib=1<!--&amp;<xsl:if test="string($ec) = '1'">ec=1&amp;</xsl:if>
-			p.a=<xsl:value-of select="$p.a"/>&amp;
-			p.sa=<xsl:value-of select="$p.sa"/>&amp;
-			p.s=<xsl:value-of select="$p.s"/>&amp;
-			p.c=<xsl:value-of select="$p.c"/>-->
-		</xsl:variable>
-
-		<li>
-			<!-- display this item from the table of contents -->
-			<xsl:if test="$isCurrent"><xsl:attribute name="class">current</xsl:attribute></xsl:if>
-			<a>
-				<xsl:attribute name="href"><xsl:value-of select="translate( $contentsLink , ' ', '' )"/></xsl:attribute>
-				<xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/>
-			</a>
-
-			<!-- display any child items -->			
+						</xsl:attribute>
+					</div>
+				</td>
+				
+				<!-- The section name, links to the section in the document -->
+				<td>				
+					<!-- display this item from the table of contents -->
+					<xsl:if test="$isCurrent"><xsl:attribute name="class">current</xsl:attribute></xsl:if>
+					<a>
+						<xsl:attribute name="href">#<xsl:value-of select="@nodeID"/></xsl:attribute>
+						<xsl:if test="util:hashToSectionId(@nodeID)">
+							<xsl:value-of select="util:hashToSectionId(@nodeID)"/>
+							<xsl:text> </xsl:text>
+						</xsl:if>
+						<xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/>
+					</a>
+				</td>
+			</tr></table>
+		
+			<!-- display any child items -->		
 			<xsl:if test="documentNode">
-				<ul>
-					<xsl:apply-templates select="documentNode"/>
-				</ul>
-			</xsl:if>
-
-		</li>
-
+				<li id="toc{@nodeID}" style="display:block;">
+					<xsl:apply-templates select="documentNode" mode="TOC"/>
+				</li>
+			</xsl:if>
+			
+		</ul>
+	</xsl:template>
+	
+	<!-- Used to produce a version of the page in a format that can be read by the realistic books plugin -->
+	<xsl:template match="documentNode" mode="flashxml">
+		<xsl:text disable-output-escaping="yes">
+			&lt;Section&gt;
+			&lt;Description&gt;
+			&lt;Metadata name="Title"&gt;
+		</xsl:text>
+		<xsl:value-of select="normalize-space(metadataList/metadata[@name = 'Title'])"/>
+		<xsl:text disable-output-escaping="yes">
+			&lt;/Metadata&gt;
+			&lt;/Description&gt;
+		</xsl:text>
+		
+		<xsl:value-of select="normalize-space(nodeContent)" disable-output-escaping="yes"/>
+				
+		<xsl:if test="documentNode">
+			<xsl:apply-templates select="documentNode" mode="flashxml"/>
+		</xsl:if>
+				
+		<xsl:text disable-output-escaping="yes">
+			&lt;/Section&gt;
+		</xsl:text>
 	</xsl:template>
 	
@@ -159,5 +300,39 @@
 
 	<xsl:template match="/page"><xsl:apply-templates select="/page/pageResponse/document"/></xsl:template> <!-- this to be deleted eventually -->
-
+	
+	<xsl:template name="viewOptions">
+		<table class="viewOptions"><tr>
+			<!-- Highlight on/off button -->
+			<xsl:if test="/page/pageRequest/paramList/param[@name = 'p.a']/@value = 'q'">
+				<td>
+					<a id="highlightOption">
+						<xsl:choose>
+							<xsl:when test="/page/pageRequest/paramList/param[@name = 'hl']/@value = 'on'">
+								<xsl:attribute name="href">
+									<xsl:text>javascript:removeHighlight();</xsl:text>
+								</xsl:attribute>
+								<xsl:text>No Highlighting</xsl:text>
+							</xsl:when>
+							<xsl:otherwise>
+								<xsl:attribute name="href">
+									<xsl:text>javascript:addHighlight();</xsl:text>
+								</xsl:attribute>
+								<xsl:text>Highlighting</xsl:text>
+							</xsl:otherwise>
+						</xsl:choose>
+					</a>
+				</td>
+			</xsl:if>
+			
+			<!-- Realistic books link -->
+			<xsl:if test="/page/pageResponse/collection[@name = $collName]/metadataList/metadata[@name = 'tidyoption'] = 'tidy'">
+				<td>
+					<a title="Realistic book view" href="{$library_name}?a=d&amp;c={$collName}&amp;d={/page/pageResponse/document/documentNode[1]/@nodeID}&amp;dt={/page/pageResponse/document/documentNode/@docType}&amp;p.a=b&amp;p.s={/page/pageResponse/service/@name}&amp;book=on&amp;ed=1">
+						<img src="interfaces/oran/images/rbook.png"/>
+					</a>
+				</td>
+			</xsl:if>
+		</tr></table>	
+	</xsl:template>
 </xsl:stylesheet>
 
Index: main/trunk/greenstone3/web/interfaces/oran/transform/pages/pref.xsl
===================================================================
--- main/trunk/greenstone3/web/interfaces/oran/transform/pages/pref.xsl	(revision 23972)
+++ main/trunk/greenstone3/web/interfaces/oran/transform/pages/pref.xsl	(revision 23989)
@@ -28,4 +28,5 @@
 		<script type="text/javascript"><xsl:text disable-output-escaping="yes">
 			var modified = false;
+			var bypass = false;
 					
 			function assembleURLFromForm(formElem)
@@ -58,5 +59,5 @@
 			function checkModified(e)
 			{
-				if (modified)
+				if (modified &amp;&amp; !bypass)
 				{
 					var ok = confirm("Would you like to save your preferences?");
@@ -75,5 +76,5 @@
 							xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
 						}
-						//assembleURLFromForm(formElem);
+
 						xmlhttp.open("GET",assembleURLFromForm(formElem),false);
 						xmlhttp.send();
@@ -85,4 +86,5 @@
 			{
 				modified = true;
+				bypass = false;
 			}
 			
@@ -243,5 +245,5 @@
 				<br/>
 
-				<input type='submit'><xsl:attribute name="value"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.set_prefs')"/></xsl:attribute></input>
+				<input type='submit' onclick="bypass=true;"><xsl:attribute name="value"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.set_prefs')"/></xsl:attribute></input>
 
 			</form>
Index: main/trunk/greenstone3/web/interfaces/oran/transform/pages/query.xsl
===================================================================
--- main/trunk/greenstone3/web/interfaces/oran/transform/pages/query.xsl	(revision 23972)
+++ main/trunk/greenstone3/web/interfaces/oran/transform/pages/query.xsl	(revision 23989)
@@ -67,4 +67,18 @@
 
 			<xsl:otherwise>
+				<p class="termList">
+					<xsl:choose>
+						<xsl:when test="count(/page/pageResponse/termList/term) &lt; 3">
+							<xsl:for-each select="/page/pageResponse/termList/term">
+								<span style="font-style:italic;"><xsl:value-of select="@name"/></span> occurs <xsl:value-of select="@freq"/> times in <xsl:value-of select="@numDocsMatch"/> document(s) <br />
+							</xsl:for-each>
+						</xsl:when>
+						<xsl:otherwise>
+							<xsl:for-each select="/page/pageResponse/termList/term">
+								<span style="font-style:italic;"><xsl:value-of select="@name"/></span> (<xsl:value-of select="@freq"/>);
+							</xsl:for-each>
+						</xsl:otherwise>
+					</xsl:choose>
+				</p>
 				
 				<ul id="results">
@@ -72,7 +86,25 @@
 						<li class="document">
 							<a>
-								<xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=d&amp;c=<xsl:value-of select="/page/pageResponse/collection/@name"/>&amp;d=<xsl:value-of select="@nodeID"/>&amp;dt=<xsl:value-of select="@docType"/>&amp;p.a=b&amp;p.s=<xsl:value-of select="/page/pageResponse/service/@name"/></xsl:attribute>
-								<xsl:value-of disable-output-escaping="yes"  select="metadataList/metadata[@name='Title']"/>
+								<xsl:choose>
+									<xsl:when test="/page/pageResponse/collection/@name">
+										<xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=d&amp;c=<xsl:value-of select="/page/pageResponse/collection/@name"/>&amp;d=<xsl:value-of select="@nodeID"/>&amp;dt=<xsl:value-of select="@docType"/>&amp;p.a=q&amp;p.s=<xsl:value-of select="/page/pageResponse/service/@name"/>&amp;hl=on&amp;ed=1#<xsl:value-of select="@nodeID"/></xsl:attribute>
+									</xsl:when>
+									<xsl:when test="@collection">
+										<xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=d&amp;c=<xsl:value-of select="@collection"/>&amp;d=<xsl:value-of select="@nodeID"/>&amp;dt=<xsl:value-of select="@docType"/>&amp;p.a=q&amp;p.s=<xsl:value-of select="/page/pageResponse/service/@name"/>&amp;hl=on&amp;ed=1#<xsl:value-of select="@nodeID"/></xsl:attribute>
+									</xsl:when>
+								</xsl:choose>
+								
+								<xsl:value-of disable-output-escaping="yes"  select="metadataList/metadata[@name='Title']"/> 
 							</a>
+							
+							<!-- If this is results from a cross collection search then add a link to the collection that it is from -->
+							<xsl:if test="@collection">
+								(<a style="background-image:none; padding:3px;">
+									<xsl:attribute name="href">
+										<xsl:value-of select="$library_name"/>?a=p&amp;sa=about&amp;c=<xsl:value-of select="@collection"/>
+									</xsl:attribute>
+									<xsl:value-of select="@collection"/>
+								</a>)
+							</xsl:if>
 							<xsl:call-template name="documentBerryForClassifierOrSearchPage"/>
 						</li>
Index: main/trunk/greenstone3/web/interfaces/oran/transform/query-common.xsl
===================================================================
--- main/trunk/greenstone3/web/interfaces/oran/transform/query-common.xsl	(revision 23989)
+++ main/trunk/greenstone3/web/interfaces/oran/transform/query-common.xsl	(revision 23989)
@@ -0,0 +1,55 @@
+<xsl:stylesheet version="1.0"
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+	xmlns:java="http://xml.apache.org/xslt/java"
+	xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
+	xmlns:gslib="http://www.greenstone.org/skinning"
+	extension-element-prefixes="java util"
+	exclude-result-prefixes="java util">
+	
+	<xsl:template match="param" mode="calculate-default">
+		<xsl:param name="ns">s1.</xsl:param>
+		<xsl:variable name="pname"><xsl:value-of select="$ns"/><xsl:value-of select="@name"/></xsl:variable>
+		<xsl:choose>
+			<xsl:when test="/page/pageRequest/paramList/param[@name=$pname]">
+				<xsl:choose>
+					<xsl:when test="@type='enum_multi'"><xsl:text>,</xsl:text>
+						<xsl:for-each select="/page/pageRequest/paramList/param[@name=$pname]">
+							<xsl:value-of select="@value"/>,
+						</xsl:for-each>
+					</xsl:when>
+					<xsl:otherwise>
+						<xsl:value-of select="/page/pageRequest/paramList/param[@name=$pname]/@value"/>
+					</xsl:otherwise>
+				</xsl:choose>
+			</xsl:when>
+			<xsl:otherwise>
+				<xsl:value-of select="@default"/>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+	
+	<!-- single selection enum params -->
+	<xsl:template match="param[@type='enum_single']">
+		<xsl:param name="ns">s1.</xsl:param>
+		<xsl:param name="default"/>
+		<xsl:choose>
+			<xsl:when test="count(option) = 1">
+				<xsl:value-of select="option/displayItem[@name='name']"/>
+				<input type='hidden' name='{$ns}{@name}'><xsl:attribute name='value'><xsl:value-of  select='option/@name'/></xsl:attribute></input>
+			</xsl:when>
+			<xsl:otherwise>
+				<select name="{$ns}{@name}">
+					<xsl:for-each select="option">
+						<option value="{@name}"><xsl:if test="@name=$default"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="displayItem[@name='name']"/></option>
+					</xsl:for-each>
+				</select>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+	
+	<xsl:template match="param[@type='string']">
+		<xsl:param name="ns">s1.</xsl:param>
+		<xsl:param name="default"/>
+		<input type="text" name="{$ns}{@name}" size="30" value="{$default}"/>
+	</xsl:template>
+</xsl:stylesheet>
Index: main/trunk/greenstone3/web/interfaces/oran/transform/util.xsl
===================================================================
--- main/trunk/greenstone3/web/interfaces/oran/transform/util.xsl	(revision 23972)
+++ main/trunk/greenstone3/web/interfaces/oran/transform/util.xsl	(revision 23989)
@@ -536,8 +536,8 @@
         <img class="pick" id="{/page/pageResponse/collection/@name}:{$rootNode}" src="interfaces/{$interface_name}/images/berry.png" alt="in basket" width="15" height="15" border="0"/>
         <span id="{/page/pageResponse/collection/@name}:{$rootNode}:root" class="documentberry">the whole document</span>
-        <xsl:if test="$selectedNode != $rootNode">
+        <!--<xsl:if test="$selectedNode != $rootNode">
           <img class="pick" id="{/page/pageResponse/collection/@name}:{$selectedNode}" src="interfaces/{$interface_name}/images/berry.png" alt="in basket" width="15" height="15" border="0"/>
           <span id="{/page/pageResponse/collection/@name}:{$selectedNode}:section" class="documentberry">the current section</span>
-        </xsl:if>
+        </xsl:if>-->
       </div>
     </xsl:if>
@@ -549,5 +549,5 @@
   <xsl:template name="coverImage">
     <img>
-      <xsl:attribute name="src"><xsl:value-of select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']"/>/index/assoc/<xsl:value-of select="metadataList/metadata[@name='archivedir']"/>/cover.jpg</xsl:attribute>
+      <xsl:attribute name="src"><xsl:value-of select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']"/>/index/assoc/<xsl:value-of select="metadataList/metadata[@name='assocfilepath']"/>/cover.jpg</xsl:attribute>
     </img>
   </xsl:template>
