Index: /main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js
===================================================================
--- /main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js	(revision 24242)
+++ /main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js	(revision 24243)
@@ -58,5 +58,4 @@
 }
 
-
 function checkDocumentRadio()
 {
@@ -74,7 +73,24 @@
 {
     console.log("Saving changes to "+checkDocumentRadio());
-}
-
-
+    console.log("TOC="+$('input[name="TOC"]').attr('checked'));
+    console.log("Cover Image="+$('input[name="bookCover"]').attr('checked'));
+
+    var myurl = document.URL;
+
+    var collection_name = getSubstring(myurl, "&c", "&");
+    var document_id = getSubstring(myurl, "&d", "&");
+    var document_type = getSubstring(myurl, "&dt", "&");
+    var prev_action = getSubstring(myurl, "&p.a", "&");
+    var prev_service = getSubstring(myurl, "&p.s", "&");
+
+    var post_url = "http://localhost:8989/greenstone3/format?a=f&sa=saveDocument&c=" + collection_name + "&d=" + document_id + "&dt=" + document_type + "&p.a=" + prev_action + "&p.s=" + prev_service;
+
+    // XML will be automatically wrapped in <display><format> tags when saved to collection config
+    var xml = '<format><gsf:option name="TOC" value="'+$('input[name="TOC"]').attr('checked')+'"/><gsf:option name="coverImage" value="'+$('input[name="bookCover"]').attr('checked')+'"/></format>';
+
+    $.post(post_url, {data: xml}, function(data) {
+            console.log("Success, we have received data");
+    }, 'xml');
+}
 
 /* FUNCTIONS FOR FORMAT EDITING */                                                                    
@@ -100,48 +116,11 @@
 }
 
-//function createFormatStatement()
-//{
-
-    //var formatDiv = document.getElementById('formatStatement');
-    //var formatStatement = innerXHTML(formatDiv);
-    //console.log(formatStatement);
-
-    // find collection name
-
-    //var myurl = document.URL;
-    //console.log(myurl);
-    //var first = myurl.indexOf("&c")+3;
-    //var last = myurl.indexOf("&", first);
-    
-    //var collection_name = getSubstring(myurl, "&c", "&"); //myurl.substring(first,last); ///&c=(.*)&/.exec(myurl);
-    //console.log(collection_name);
-
-    //first = myurl.indexOf("&s")+3;
-    //last = myurl.indexOf("&", first);
-
-    //var service_name = myurl.substring(first,last);
-    //console.log(service_name);
-
-    //var classifier_name = null;
-
-    //if(service_name == "ClassifierBrowse")
-    //{
-    //    first = myurl.indexOf("&cl")+4;
-    //    last = myurl.indexOf("&", first);
-
-    //    classifier_name = myurl.substring(first,last);
-    //    console.log(classifier_name);
-    //}
-
-    //var myurl = 'http://localhost:8080/greenstone3/format?a=s&sa=s&t='+formatStatement;
-
-    //jQuery.post( url, [ data ], [ success(data, textStatus, XMLHttpRequest) ], [ dataType ] )
-
-    // How do I find out my collection name?
-
 function getSubstring(str, first, last)
 {
     var first_index = str.indexOf(first)+first.length+1;
     var last_index = str.indexOf(last, first_index);
+
+    if(last_index == -1)
+        last_index = str.length;
 
     var substring = str.substring(first_index, last_index);
@@ -228,9 +207,6 @@
 
     $.post(post_url, {data: formatStatement}, function(data) {
-        //$('.result').innerHTML = data; //html(data);
-        
         // An error is returned because there is no valid XSLT for a format update action, there probably shouldn't be one so we ignore what the post returns.    
         console.log("Successfully saved");
-        //console.log(data);
         }, 'html');
 }
@@ -245,22 +221,11 @@
     var prev_action = getSubstring(myurl, "&p.a", "&");
     var prev_service = getSubstring(myurl, "&p.s", "&");
-    //var classifier_name = null;
-
-    //if(service_name == "ClassifierBrowse")
-    //    classifier_name = getSubstring(myurl, "&cl", "&");
-
-
-    //var post_url = "http://localhost:8989/greenstone3/format?a=f&sa=getXSLT&c=" + collection_name +"&s=" + service_name+"&d=" + document_id + "&o=skinandlib";
+
     var post_url = "http://localhost:8989/greenstone3/format?a=d&c=" + collection_name + "&d=" + document_id + "&dt=" + document_type + "&p.a=" + prev_action + "&p.s=" + prev_service + "&o=skinandlib";
 
-    //if(classifier_name != null)
-    //    post_url = post_url + "&cl=" + classifier_name;
-
     $.post(post_url, {data: classname}, function(data) {
-            //$('.result').innerHTML = data; //html(data);
             console.log("Success, we have received data");
-            //console.log(data);
             classname = "." + classname;
-            console.log(classname); //data.getElementsByTagName("div"));
+            console.log(classname); 
             var content = $( data ).find(classname);
             console.log(content.xml());
@@ -269,59 +234,6 @@
 }
 
-/*
-    $.ajax({
-        type: "POST",
-        url: "http://localhost:8080/greenstone3/format?a=s&sa=s",
-        data: formatStatement,
-        processData: false,
-        success: function(data) {
-            //$('.result').html(data);
-            console.log("Success, we have received data");
-            //console.log(data);
-        }
-     });
-*/
-    /*
-    $.ajax({
-        url: myurl,
-        success: function(data) {
-            //$('.result').html(data);
-            console.log("Success, we have received data");
-            console.log(data);
-        }
-    });
-    */
-    //if(formatStatement.hasChildNodes())
-    //{
-        //var formatstring = traverse(formatStatement, "");
-        //console.log(formatstring);
-
-        // var children = $(formatStatement).children('div');
-        // for(var i=0; i < children.length; i++)
-        //    traverse(children[i], formatstring)
-     
-        /*
-        var children = formatStatement.childNodes; //[]getChildNodes();
-        var current;
-        for(var i = 0; i < formatStatement.childNodes.length; i++)
-        {
-            current = formatStatement.childNodes[i];
-            //console.log(current.nodeName);
-            //console.log(current.nodeType);
-            if(current.nodeName=='DIV')
-            {
-                //console.log(current);
-                //console.log(current.className);
-                var gsf = find_class(current);
-                console.log(gsf);
-            }
-        }
-        */
-    //}
-//}
-
 function traverse(node, formatstring)
   {
-    //console.log("node=("+node.nodeName+","+node.nodeType+")");
 
     if(node.nodeName=='DIV')
@@ -339,28 +251,4 @@
   }
         
-
-/*
-    console.log("node=("+node.nodeName+","+node.nodeType+")");
-
-    if(node.children.length == 0) //hasChildNodes()) 
-    {
-        console.log("No children so return");
-        return "";
-    }
-
-    if(node.nodeName=='DIV')
-    {
-        console.log("Found a div");
-        formatstring = formatstring + find_class(node);
-    }        
-    
-    for(var i = 0; i < node.children.length; i++)
-        return recursiveTraverse(node.children[i], formatstring);
-    
-
-    return formatstring;
-  }
-*/
-
 function find_class(current)
 {
@@ -696,7 +584,4 @@
     console.log('function bind_all_sortables()');
     bind_template_sortable();
-    //bind_table_sortable();
-    //bind_tr_sortable();
-    //bind_td_sortable();
     bind_choose_metadata_sortable();
     bind_link_sortable();
@@ -714,5 +599,4 @@
 {
     console.log('function bind_tables()');
-    //$('.tr').resize_tables($(this)); //equalHeights();
 
     $('#sectionHeader').click(function () {
@@ -728,28 +612,16 @@
     $(".td-div").resizable({
                 alsoResize: 'parent',
-                //containment: 'parent',
                 handles: 'w,e',
                 stop: function(event, ui) {
                         console.log('Resize table on stop');
                         resize_tables($(this));
-                        //$(this).parent().parent().equalHeights();
                 }, });
-
-    //$(".droppable").sortable({
-    //        'cursor':'pointer',
-    //        'tolerance': 'pointer',
-    //        'items':'.column, .td-div',
-    //        'placeholder':'placeholder'
-    //});
 
     $(".droppable").droppable({
             accept: '.element_type_td',
             tolerance: 'pointer', 
-            activate: function(event, ui) { $(this).addClass("droppable_hl");}, // console.log("droppable activated")},
-            deactivate: function(event, ui) { $(this).removeClass("droppable_hl"); }, // console.log("droppable deactivated")},
+            activate: function(event, ui) { $(this).addClass("droppable_hl");}, 
+            deactivate: function(event, ui) { $(this).removeClass("droppable_hl"); },
             drop: function(event, ui) {
-                //if ($(this).hasClass("ui-draggable"))
-                //if (ui.helper.hasClass("ui-draggable"))
-                //{
                  var neverempty = document.createElement("div");
                  neverempty.setAttribute("class","neverempty block");
@@ -759,5 +631,5 @@
                  neverempty.appendChild(text);
                  var td = document.createElement("td");
-                 var div = document.createElement("div"); // class=\"td block\" title=\"td-div\"");
+                 var div = document.createElement("div"); 
                  div.setAttribute("title","td-div");
                  div.setAttribute("class","td-div block");
@@ -775,13 +647,4 @@
                  bind_td_sortable();
                  bind_block_mouseover();
-                 //bind_all_sortables();
-                //}
-                //else
-                //{
-                //    console.log("Attempting to add");
-                    //$(this).appendTo(ui.draggable[0]);
-                //    $(this).prepend(ui.draggable[0]);
-                    //$(ui.draggable[0]).appendTo($(this));
-                //}
             }
         });
@@ -807,19 +670,5 @@
     }
 
-    //console.log('function replace_with(item, me)');
     item.replaceWith(me); //'<div class="element element-txt">This text box has been added!</div>');
-    //item.find('select').attr("value", CURRENT_SELECT_VALUE);
-
-
-    //if(select != null){
-    //    console.log("Attempting to select " + CURRENT_SELECT_VALUE);
-    //    console.log("length = "+select.length);
-    //    for(index = 0; index < select.length; index++) {
-    //          console.log(select[index].value);  
-    //       if(select[index].value == CURRENT_SELECT_VALUE)
-    //          console.log("Found "+CURRENT_SELECT_VALUE+" at index " + index);
-    //          select.selectedIndex = index;
-    //    }
-    // }
 
     resize_tables(item);
@@ -830,5 +679,4 @@
 function resize_tables(item)
 {
-    //console.log('function resize_tables(item)');
     var max_height = 0;
     (item.parents('.table')).each(function(index) {
@@ -858,5 +706,4 @@
             //'nested':'.gsf:metadata'
             stop: function(event, ui) {
-                //if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('css_table')) { replace_with(ui.item, "<table border=\"1\" width=\"100%\" height=\"50px\"><tr><td><div class=\"td block\" title=\"td-div\">XXXXXXXXXXXXXXXXXXXXXXXX</div></td></tr></table>"); }
                 if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_table')) { replace_with(ui.item, "<table class=\"table\" border=\"2\"></table>"); }
                 if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose_metadata')) { replace_with(ui.item, gsf_choose_metadata_element); }
@@ -884,25 +731,4 @@
             'connectWith':'column'});
 
-    //$('.column').sortable({
-    //    connectWith:['.column'],
-    //    placeholder: 'placeholder',
-    //    items:'td-div'
-    //});
-
-
-    //$('.column').sortable({
-    //        'cursor':'pointer',
-    //        'tolerance': 'pointer',
-    //        'items':'.td-div',
-    //        'placeholder':'placeholder',
-    //        'connectWith':'.column'
-            //'nested':'.gsf:metadata'
-            //receive: function(event, ui) { alert("Attempted to receive"); },
-            //stop: function(event, ui) {
-            //    if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('element_type_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
-
-    //});
-
-    //console.log('function bind_td_sortable()');
     $('.td-div').sortable({
             'cursor':'pointer',
@@ -910,6 +736,4 @@
             'items':'.gsf_metadata, .gsf_choose_metadata, .gsf_link, .gsf_switch',
             'placeholder':'placeholder',
-            //'connectWith':'.td-div',
-            //'nested':'.gsf:metadata'
             receive: function(event, ui) { alert("Attempted to receive"); },
             stop: function(event, ui) {
@@ -1089,12 +913,6 @@
 var toggleContent = function(e)
 {
-    //console.log('var toggleContent = function(e)');
     console.log('parent: ' + $(this).html());
     if ($(this).html() == '[+]'){ //targetContent.css('display') == 'none') {
-        //$(this).parent().parent().parent().parent().parent().children(".block,.table").slideDown(300);
-        //$(this).parents().children(".block,.table").stopPropagation().slideDown(300);
-        //var x = $(this).parent().parent().parent().parent().parent();
-        //var y = $(this).parent().parent().parent().parent().parent().children(".block,.table");
-        //var z = $(this).closest(".block").children(".table, .block");
         $(this).closest(".block").children(".table, .block").slideDown(300);
         $(this).html('[-]');
@@ -1102,6 +920,4 @@
         $(this).addClass("ui-icon-minusthick");
     } else {
-        //$(this).parent().parent().parent().parent().parent().children(".block,.table").slideUp(300);
-        //$(this).parents().children(".block,.table").slideUp(300);
         $(this).closest(".block").children(".table, .block").slideUp(300);
         $(this).html('[+]');
Index: /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/formatmanager.xsl
===================================================================
--- /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/formatmanager.xsl	(revision 24242)
+++ /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/formatmanager.xsl	(revision 24243)
@@ -4,4 +4,5 @@
     xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
     xmlns:gslib="http://www.greenstone.org/skinning"
+    xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
     extension-element-prefixes="java util"
     exclude-result-prefixes="java util">
@@ -61,4 +62,6 @@
             .elementToolBox {position: fixed; top: 25%; right: 0px; background: none repeat scroll 0% 0% white; width: 250px; }
 
+            .visible {display: block;}
+            .hidden {display: none;}
             <!-- .gsf_metadata { border: solid 2px #0000BB; background-color: #440077; } -->
 
@@ -77,5 +80,5 @@
                         <!-- TOC on or off -->
                         <xsl:choose>
-                            <xsl:when test="/page/pageResponse/format[@type='display']/gsf:option[(@name='TOC') and (@value='true')]">
+                            <xsl:when test="/page/pageResponse/format[@type='display']/gsf:option[@name='TOC']/@value='true'">
                                 <input type="checkbox" name="TOC" checked="checked" onclick="displayTOC(this)">Display Table of Contents (set to true)</input>
                             </xsl:when>
@@ -87,5 +90,5 @@
                         <!-- book cover image on or off -->
                         <xsl:choose>
-                            <xsl:when test="/page/pageResponse/format[@type='display']/gsf:option[(@name='coverImage') and (@value='true')]">
+                            <xsl:when test="/page/pageResponse/format[@type='display']/gsf:option[@name='coverImage']/@value='true'">
                                 <input type="checkbox" name="bookCover" checked="checked" onclick="displayBookCover(this)">Display Book Cover Image (set to true)</input>
                             </xsl:when>
Index: /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/main.xsl
===================================================================
--- /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/main.xsl	(revision 24242)
+++ /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/main.xsl	(revision 24243)
@@ -18,6 +18,4 @@
 	<xsl:include href="formatmanager.xsl"/>
 	
-	<!--<xsl:include href="xml-to-gui.xsl"/>-->
-	<!--<xsl:include href="xml-to-gui-templates.xsl"/>-->
 
 	<!-- put the URL or path of your site here site -->
@@ -52,5 +50,5 @@
 					</div>
 					
-					<xsl:if test="/page/pageRequest/paramList/param[(@name='formatedit') and (@value='1')]">
+					<xsl:if test="/page/pageRequest/paramList/param[(@name='formatedit') and (@value='on')]">
 						<xsl:call-template name="formatmanagerpre"/>
 					</xsl:if>
Index: /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui.xsl
===================================================================
--- /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui.xsl	(revision 24242)
+++ /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui.xsl	(revision 24243)
@@ -381,15 +381,12 @@
         
 
-        <!-- <td class="td block resizable" title="td" valign="{@valign}" style='overflow: hidden;'> -->
         <td class="column" valign="{@valign}" title="td">
             <div class="td-div block" title="td-div">
             <div class="neverempty block" style="height:50px">NEVER EMPTY</div>
 
-            <!-- <xsl:text>&lt;td</xsl:text>valign=<xsl:value-of select="@valign"/><xsl:text>&gt;</xsl:text><a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a> -->
                 <xsl:apply-templates mode="xml-to-gui">
                     <xsl:with-param name="depth" select="$depth"/>
                     <xsl:with-param name="metadataSets" select="$metadataSets"/> 
                 </xsl:apply-templates>
-                <!-- <xsl:text>&lt;/td&gt;</xsl:text><br/><br/> -->
             </div>
         </td>
@@ -403,7 +400,5 @@
         <xsl:param name="metadataSets"/>
 
-        <!-- <xsl:text>&lt;br/&gt;</xsl:text> <br/> -->
         <div class="block leaf gsf_text" title="gsf:text">
-                <!-- <xsl:variable name="rawtext"><xsl:text disable-output-escaping='no'>br/</xsl:text></xsl:variable> -->
                 <table class="header"><tbody><tr><td class="header">&lt;<input class="text" type="text" name="rawtextinput" size="10" value="br/"></input>&gt;</td><td class="header"><a href="[myhref]" class="ui-icon ui-icon-closethick"/></td></tr></tbody></table>
         </div>
@@ -420,7 +415,5 @@
         <xsl:param name="metadataSets"/>
 
-        <!-- <xsl:text>&lt;br/&gt;</xsl:text> <br/> -->
         <div class="block leaf gsf_text" title="gsf:text">
-                <!-- <xsl:variable name="rawtext"><xsl:text disable-output-escaping='no'>i</xsl:text></xsl:variable> -->
                 <table class="header"><tbody><tr><td class="header">&lt;<input class="text" type="text" name="rawtextinput" size="10" value="i"></input>&gt;</td><td class="header"><a href="[myhref]" class="ui-icon ui-icon-closethick"/></td></tr></tbody></table>
         </div>
Index: /main/trunk/greenstone3/web/interfaces/oran/transform/pages/document.xsl
===================================================================
--- /main/trunk/greenstone3/web/interfaces/oran/transform/pages/document.xsl	(revision 24242)
+++ /main/trunk/greenstone3/web/interfaces/oran/transform/pages/document.xsl	(revision 24243)
@@ -90,17 +90,26 @@
 
 						<!-- the book's cover image -->
-                        <!-- COULD BE WORTH SETTING THE STYLE TO DISPLAY:BLOCK OR DISPLAY:NONE BASED ON WHETHER FLAG IS TRUE OR FALSE -->
-                        <!-- OTHERWISE, IF FLAG IS FALSE AND WE WANT TO TURN BOOK COVER ON, NEED TO REQUEST THE NEW PAGE WITH FLAG SET -->
-                        <xsl:if test="/page/pageResponse/format[@type='display']/gsf:option[@name='coverImage']/@value='true'">
-    						<div id="coverImage"><gslib:coverImage/></div>
-                        </xsl:if>
+                        <xsl:choose>
+                            <xsl:when test="/page/pageResponse/format[@type='display']/gsf:option[@name='coverImage']/@value='true'">
+        						<div id="coverImage" class="visible"><gslib:coverImage/></div>
+                            </xsl:when>
+                            <xsl:otherwise>
+        						<div id="coverImage" class="hidden"><gslib:coverImage/></div>
+                            </xsl:otherwise>    
+                        </xsl:choose>
 
 						<!-- the contents (if enabled) -->
-                        <!-- VALUE=<xsl:value-of select="/page/pageResponse/format[@type='display']/gsf:option[@name='TOC']/@value"/> -->
-                        <xsl:if test="/page/pageResponse/format[@type='display']/gsf:option[@name='TOC']/@value='true'">
-						    <div id="tableOfContents">
-							    <xsl:apply-templates select="documentNode" mode="TOC"/>
-						    </div>
-                        </xsl:if>
+                        <xsl:choose>
+                            <xsl:when test="/page/pageResponse/format[@type='display']/gsf:option[@name='TOC']/@value='true'">
+    						    <div id="tableOfContents" class="visible">
+							        <xsl:apply-templates select="documentNode" mode="TOC"/>
+                                </div>
+                            </xsl:when>    
+                            <xsl:otherwise>
+                                <div id="tableOfContents" class="hidden">
+                                    <xsl:apply-templates select="documentNode" mode="TOC"/>
+                                </div>
+                            </xsl:otherwise>    
+                        </xsl:choose>
 					</div>
 				</td></tr>
