Index: /trunk/gsdl3/web/interfaces/default/transform/config_format.xsl
===================================================================
--- /trunk/gsdl3/web/interfaces/default/transform/config_format.xsl	(revision 13995)
+++ /trunk/gsdl3/web/interfaces/default/transform/config_format.xsl	(revision 13996)
@@ -37,5 +37,13 @@
       </xsl:when>
       <xsl:otherwise> <!-- a document link -->
-	<a><xslt:attribute name="href"><xslt:value-of select='$library_name'/>?a=d&amp;c=<xslt:value-of select='$collName'/>&amp;d=<xslt:value-of select='@nodeID'/>&amp;dt=<xslt:value-of select='@docType'/><xslt:if test="@nodeType='leaf'">&amp;sib=1</xslt:if>&amp;p.a=<xslt:value-of select="/page/pageRequest/@action"/>&amp;p.sa=<xsl:value-of select="/page/pageRequest/@subaction"/>&amp;p.s=<xslt:value-of select="$serviceName"/></xslt:attribute><xsl:apply-templates/></a>
+	<xslt:variable name="bookswitch"><xslt:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/></xslt:variable>
+	<xslt:choose>
+    		<xslt:when test="$bookswitch = 'on' or $bookswitch = 'flashxml'">
+		        <a><xslt:attribute name="href"><xslt:value-of select='$library_name'/>?a=d&amp;ed=1&amp;book=on&amp;c=<xslt:value-of select='$collName'/>&amp;d=<xslt:value-of select='@nodeID'/>&amp;dt=<xslt:value-of select='@docType'/><xslt:if test="@nodeType='leaf'">&amp;sib=1</xslt:if>&amp;p.a=<xslt:value-of select="/page/pageRequest/@action"/>&amp;p.sa=<xsl:value-of select="/page/pageRequest/@subaction"/>&amp;p.s=<xslt:value-of select="$serviceName"/></xslt:attribute><xsl:apply-templates/></a>
+		</xslt:when>
+		<xslt:otherwise>
+		       <a><xslt:attribute name="href"><xslt:value-of select='$library_name'/>?a=d&amp;book=off&amp;c=<xslt:value-of select='$collName'/>&amp;d=<xslt:value-of select='@nodeID'/>&amp;dt=<xslt:value-of select='@docType'/><xslt:if test="@nodeType='leaf'">&amp;sib=1</xslt:if>&amp;p.a=<xslt:value-of select="/page/pageRequest/@action"/>&amp;p.sa=<xsl:value-of select="/page/pageRequest/@subaction"/>&amp;p.s=<xslt:value-of select="$serviceName"/></xslt:attribute><xsl:apply-templates/></a>
+		</xslt:otherwise>
+	</xslt:choose>
       </xsl:otherwise>
     </xsl:choose>
Index: /trunk/gsdl3/web/interfaces/default/transform/document.xsl
===================================================================
--- /trunk/gsdl3/web/interfaces/default/transform/document.xsl	(revision 13995)
+++ /trunk/gsdl3/web/interfaces/default/transform/document.xsl	(revision 13996)
@@ -14,4 +14,5 @@
   <xsl:output method="html"/>
    <xsl:variable name="berrybasketswitch"><xsl:value-of select="/page/pageRequest/paramList/param[@name='berrybasket']/@value"/></xsl:variable> 
+   <xsl:variable name="bookswitch"><xsl:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/></xsl:variable>
   
   <xsl:template name="pageTitle">
@@ -41,27 +42,35 @@
   <xsl:template match="pageResponse">
     <xsl:variable name="collName"><xsl:value-of select="/page/pageRequest/paramList/param[@name='c']/@value"/></xsl:variable>
-    <xsl:call-template name="standardPageBanner">
-      <xsl:with-param name="collName" select="$collName"/>
-    </xsl:call-template>
-    <xsl:call-template name="navigationBar">
-      <xsl:with-param name="collName" select="$collName"/>
-    </xsl:call-template>
-  
-  <!--<xsl:if test="$berryBaskets = 'true'">-->
-    <xsl:if test="$berrybasketswitch = 'on'">
-    <xsl:call-template name="documentBerryBasket">
-      <xsl:with-param name="collName" select="$collName"/>
-      <xsl:with-param name="selectedNode" select="/page/pageResponse/document/@selectedNode"/>
-      <xsl:with-param name="rootNode" select="/page/pageResponse/document/documentNode[@nodeType='root']/@nodeID"/>
-      <xsl:with-param name="docType" select="/page/pageResponse/document/@docType"/>
-    </xsl:call-template>
-   </xsl:if>
+    <xsl:choose>
+      <xsl:when test="$bookswitch = 'on' or $bookswitch = 'off'">
+        <xsl:call-template name="standardPageBanner">
+           <xsl:with-param name="collName" select="$collName"/>
+        </xsl:call-template>
+        <xsl:call-template name="navigationBar">
+           <xsl:with-param name="collName" select="$collName"/>
+        </xsl:call-template>
+  
+        <!--<xsl:if test="$berryBaskets = 'true'">-->
+        <xsl:if test="$berrybasketswitch = 'on'">
+          <xsl:call-template name="documentBerryBasket">
+             <xsl:with-param name="collName" select="$collName"/>
+             <xsl:with-param name="selectedNode" select="/page/pageResponse/document/@selectedNode"/>
+             <xsl:with-param name="rootNode" select="/page/pageResponse/document/documentNode[@nodeType='root']/@nodeID"/>
+             <xsl:with-param name="docType" select="/page/pageResponse/document/@docType"/>
+          </xsl:call-template>
+        </xsl:if>
+      </xsl:when>
+   </xsl:choose>	
 
   <!-- display the document -->
-  <div id="content">
+    <xsl:if test="$bookswitch != 'flashxml'">
+       <xsl:text disable-output-escaping="yes">&lt;div id="content"&gt;</xsl:text>
+    </xsl:if>
     <xsl:apply-templates select="document">
       <xsl:with-param name="collName" select="$collName"/>
     </xsl:apply-templates>
-    </div>
+    <xsl:if test="$bookswitch != 'flashxml'">
+	<xsl:text disable-output-escaping="yes">&lt;/div&gt;</xsl:text>
+    </xsl:if>
   </xsl:template>
 	
@@ -69,4 +78,11 @@
    <xsl:param name="collName"/>
   
+   <xsl:if test="$bookswitch = 'flashxml'">
+			<xsl:call-template name="xmldocumentContentPeeling">
+				<xsl:with-param name="collName" select="$collName"/>
+			</xsl:call-template>
+		</xsl:if>
+   
+   <xsl:if test="$bookswitch = 'off'">
     <xsl:call-template name="documentHeading">
       <xsl:with-param name="collName" select="$collName"/>
@@ -81,5 +97,48 @@
     <xsl:call-template name="documentArrows">
       <xsl:with-param name="collName" select="$collName"/>
-    </xsl:call-template>      
+    </xsl:call-template>   
+   </xsl:if>
+   <xsl:if test="$bookswitch = 'on'">
+			<xsl:call-template name="documentHeading">
+				<xsl:with-param name="collName" select="$collName"/>
+			</xsl:call-template>
+			<div id="bookdiv"></div>
+			<script type="text/javascript">
+				<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';
+
+					// var src_image = "http://kia.cs.waikato.ac.nz:8080/greenstone3/sites/localsite/collect/gs2mgdemo/index/assoc/HASH49aa.dir/cover.jpg"
+					//var doc_url = "/greenstone3/library?a=d&amp;c=gs2mgdemo&amp;d=HASH49aab56062938fbe2ff7f1&amp;dt=hierarchy&amp;p.a=b&amp;p.s=ClassifierBrowse&amp;ed=1";
+
+					var flash_plug_html = ""
+					flash_plug_html += '&lt;OBJECT align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" \n';
+					flash_plug_html += '  codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" \n';
+					flash_plug_html += '  height="100%" id="Book" swLiveConnect="true" \n';
+					flash_plug_html += '  width="100%"&gt;\n';
+					flash_plug_html += '    &lt;PARAM name="allowScriptAccess" value="always" /&gt;\n';
+					flash_plug_html += '    &lt;PARAM name="movie" value="Book.swf';
+					flash_plug_html += '?src_image=' + escape(img_cover);
+					flash_plug_html += '&amp;doc_url=' + escape(doc_url)
+					flash_plug_html += '" /&gt;\n';
+					flash_plug_html += '    &lt;PARAM name="quality" value="high" /&gt;\n';
+					flash_plug_html += '    &lt;PARAM name="bgcolor" value="#FFFFFF" /&gt;\n';
+					flash_plug_html += '    &lt;EMBED align="middle" \n';
+					flash_plug_html += '      allowScriptAccess="always" swLiveConnect="true" \n';
+					flash_plug_html += '      bgcolor="#FFFFFF" height="100%" name="Book" \n';
+					flash_plug_html += '      pluginspage="http://www.macromedia.com/go/getflashplayer" \n';
+					flash_plug_html += '      quality="high" \n';
+					flash_plug_html += '      src="Book.swf';
+					flash_plug_html += '?src_image=' + escape(img_cover);
+					flash_plug_html += '&amp;doc_url=' + escape(doc_url);
+					flash_plug_html += '"\n'; 
+					flash_plug_html += '      type="application/x-shockwave-flash" width="100%" /&gt;\n';
+					flash_plug_html += '&lt;/OBJECT&gt;\n';
+					var flash_div = document.getElementById("bookdiv");
+					flash_div.innerHTML = flash_plug_html;
+				</xsl:text>
+			</script>
+		</xsl:if>    
  </xsl:template>
 
@@ -100,32 +159,54 @@
  <div id="docheadwrapper">
   <div id="documentinfo">
-    <xsl:if test="string($doCoverImage) != 'false' and (@docType='paged' or @docType='hierarchy')">
-       <div id="headingimage">
-         <xsl:call-template name="coverImage"/> 
-       </div>
-    </xsl:if>
+    
+  <xsl:choose>
+    <xsl:when test="$bookswitch = 'on'">
+    	<xsl:if test="string($doCoverImage) != 'false' and (@docType='paged' or @docType='hierarchy')">
+         <div id="headingimage">
+          <xsl:call-template name="coverImage"/> 
+         </div>
+        </xsl:if>
+    </xsl:when>
+    <xsl:otherwise>
+    	<xsl:if test="string($doCoverImage) != 'false' and (@docType='paged' or @docType='hierarchy')">
+       	  <div id="headingimage">
+             <xsl:call-template name="coverImage"/> 
+          </div>
+        </xsl:if>
      
-     <ul id="docbuttons" >
-       <xsl:call-template name="documentButtons">
-	  <xsl:with-param name="collName" select="$collName"/>
-       </xsl:call-template>
-     </ul>
+        <ul id="docbuttons" >
+         <xsl:call-template name="documentButtons">
+	   <xsl:with-param name="collName" select="$collName"/>
+         </xsl:call-template>
+       </ul>
+     </xsl:otherwise>
+  </xsl:choose>     
   </div>
     <!--<div><xsl:call-template name="enrichServices">
 	   <xsl:with-param name="collName" select="$collName"/>
 	  </xsl:call-template></div>-->
-     <xsl:if test="string($doTOC) != 'false'">
+   <xsl:if test="$bookswitch = 'off'">
+    <xsl:if test="string($doTOC) != 'false'">
        <div id="toc">
 	 <xsl:call-template name="TOC">
 	   <xsl:with-param name="collName" select="$collName"/>
 	 </xsl:call-template>
-       </div>
-      </xsl:if>
-      
       </div>
-    </xsl:template>
+    </xsl:if>
+  </xsl:if>  
+ </div>
+ </xsl:template>
 
   <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></img>
+  <xsl:choose>
+			<xsl:when test="$bookswitch = 'on'">
+				<script type="text/javascript">
+					<xsl:text disable-output-escaping="yes">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='archivedir']"/>/cover.jpg<xsl:text disable-output-escaping="yes">';</xsl:text>
+				</script>
+			</xsl:when>
+			<xsl:otherwise>
+    				<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></img>
+			</xsl:otherwise>
+		</xsl:choose>
   </xsl:template>
 
@@ -266,7 +347,5 @@
    <div class="documenttext"> 
     <xsl:choose>
-      <xsl:when test="@docType='simple'">
-	<xsl:apply-templates select="nodeContent"/>
-      </xsl:when>
+      <xsl:when test="@docType='simple'"><xsl:apply-templates select="nodeContent"/></xsl:when>
       <xsl:otherwise>
 	<xsl:apply-templates select="descendant-or-self::node()/documentNode" mode="content"/>
@@ -290,9 +369,58 @@
     <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="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:template>
+  
+  <xsl:template name="xmldocumentContentPeeling">
+		<xsl:choose>
+			<xsl:when test="@docType='simple'">
+				<xsl:apply-templates select="nodeContent"/>
+			</xsl:when>
+			<xsl:otherwise>
+				<xsl:call-template name="xmlpeelingContents" />
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+	
+  <xsl:template name="xmlpeelingContents">
+		<xsl:if test="documentNode">
+			<xsl:apply-templates select="documentNode" mode="xmlpeeling" />
+		</xsl:if>
+	</xsl:template>
+
+	<xsl:template match="documentNode" mode="xmlpeeling">
+		<!-- get title -->
+		<xsl:choose>
+			<xsl:when test="nodeContent">
+				<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:text disable-output-escaping="yes">&lt;/Sec&gt;</xsl:text>
+			</xsl:when>
+		</xsl:choose>
+
+		<!-- recurse to the children -->
+		<xsl:if test="documentNode">
+			<xsl:apply-templates select="documentNode" mode="xmlpeeling" />
+		</xsl:if>
+
+		<!-- end the section -->
+		<xsl:text disable-output-escaping="yes">
+			&lt;/Section&gt;
+		</xsl:text>
+	</xsl:template>
   
   <!-- match any file nodes -->
Index: /trunk/gsdl3/web/interfaces/default/transform/pref.xsl
===================================================================
--- /trunk/gsdl3/web/interfaces/default/transform/pref.xsl	(revision 13995)
+++ /trunk/gsdl3/web/interfaces/default/transform/pref.xsl	(revision 13996)
@@ -22,4 +22,7 @@
   <xsl:template match="pageResponse">
     <xsl:variable name="collName" select="/page/pageRequest/paramList/param[@name='c']/@value"/>
+    
+   <xsl:variable name="tidyoption"><xsl:value-of select="/page/pageResponse/collection/metadataList/metadata[@name='tidyoption']"/></xsl:variable>
+      
     <xsl:call-template name="standardPageBanner">
       <xsl:with-param name="collName" select="$collName"/>
@@ -38,4 +41,9 @@
       <ul id="presprefs"><xsl:call-template name="pres-prefs"/></ul>
       <ul id="berrybasketprefs" ><xsl:call-template name="berrybasket-prefs"/></ul>
+      
+      <xsl:if test="$tidyoption='tidy'">
+      	<ul id="bookprefs"><xsl:call-template name="book-prefs"/></ul>
+      </xsl:if>
+      
       <div class="formheading"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.searchpref')"/></div>
       <ul id="searchprefs"><xsl:call-template name="search-prefs"/></ul>
@@ -81,4 +89,12 @@
   </xsl:template>
 
-
+<xsl:template name="book-prefs">
+      <xsl:variable name="book"><xsl:choose><xsl:when test="/page/pageRequest/paramList/param[@name='book']"><xsl:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/></xsl:when><xsl:otherwise>off</xsl:otherwise></xsl:choose></xsl:variable>
+      
+    <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.book')"/> <select name="book">
+        <option value="on"><xsl:if test="$book='on'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.berrybasket.on')"/></option> 
+	<option value="off"><xsl:if test="$book='off'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.berrybasket.off')"/></option>
+      </select>
+    
+  </xsl:template>
 </xsl:stylesheet>
Index: /trunk/gsdl3/web/interfaces/default/transform/style.xsl
===================================================================
--- /trunk/gsdl3/web/interfaces/default/transform/style.xsl	(revision 13995)
+++ /trunk/gsdl3/web/interfaces/default/transform/style.xsl	(revision 13996)
@@ -17,9 +17,29 @@
   <!-- the main page layout template is here -->
   <xsl:template match="page">
-    <html>
+    <xsl:variable name="bookswitch"><xsl:value-of select="/page/pageRequest/paramList/param[@name='book']/@value"/></xsl:variable>
+    <xsl:variable name="a"><xsl:value-of select="/page/pageRequest/paramList/param[@name='a']/@value"/></xsl:variable>
+
+    <xsl:choose> 
+      <xsl:when test="$bookswitch = 'flashxml' and $a = 'd'">
+         <html>
+   		  <xsl:call-template name="response" />
+        </html>
+      </xsl:when>
+
+      <xsl:otherwise>    
+        <html>
      	 <xsl:call-template name="pageHead"/>
-	 
-   <body>
-      <div id="globalwrapper">
+          <body>
+           <div id="globalwrapper">
+   		  <xsl:call-template name="response" />
+		  <xsl:call-template name="greenstoneFooter"/>
+	   </div>
+          </body>
+        </html>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+ <xsl:template name="response">
 	  <xsl:apply-templates select="pageResponse"/>
 		  <xsl:if test="descendant::error">
@@ -53,9 +73,5 @@
 		    </div>
 		  </xsl:if>
-		  <xsl:call-template name="greenstoneFooter"/>
-	 </div>
-      </body>
-    </html>
-  </xsl:template>
+ </xsl:template>
 
   <!-- put a space in the title in case the actual value is missing - mozilla will not display a page with no title-->
