Index: /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/FormatReceptionist.java
===================================================================
--- /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/FormatReceptionist.java	(revision 22675)
+++ /main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/FormatReceptionist.java	(revision 22676)
@@ -174,6 +174,9 @@
     Element coverage_metadata = (Element)GSXML.getNodeByPath(info_response, "response/metadataSetList");
     logger.error("************ This should be metadata set list="+this.converter.getString(coverage_metadata));
-    coverage_metadata = (Element)this.doc.importNode(coverage_metadata, true);
-    coll_description.appendChild(coverage_metadata);
+    if(coverage_metadata != null)
+    {
+        coverage_metadata = (Element)this.doc.importNode(coverage_metadata, true);
+        coll_description.appendChild(coverage_metadata);
+    }
 	
     }
Index: /main/trunk/greenstone3/web/WEB-INF/web.xml
===================================================================
--- /main/trunk/greenstone3/web/WEB-INF/web.xml	(revision 22675)
+++ /main/trunk/greenstone3/web/WEB-INF/web.xml	(revision 22676)
@@ -162,4 +162,34 @@
   
   <servlet>
+    <servlet-name>nzdl-library</servlet-name>
+    <description>gsdl3 library program</description>
+    <servlet-class>org.greenstone.gsdl3.LibraryServlet</servlet-class>
+    <init-param>
+      <param-name>library_name</param-name>
+      <param-value>nzdl</param-value>
+    </init-param>
+    <init-param>
+      <param-name>site_name</param-name>
+      <param-value>nzdl</param-value>
+    </init-param>
+    <init-param>
+      <param-name>interface_name</param-name>
+      <param-value>nzdl</param-value>
+    </init-param>
+    <init-param>
+      <param-name>default_lang</param-name>
+      <param-value>en</param-value>
+    </init-param>
+    <init-param>
+      <param-name>params_class</param-name>
+      <param-value>NZDLParams</param-value>
+    </init-param>
+    <init-param>
+      <param-name>session_expiration</param-name>
+      <param-value>600</param-value>
+    </init-param>
+  </servlet>
+
+  <servlet>
     <servlet-name>gateway</servlet-name>
     <description>gsdl3 library based on gateway site and default interface. It uses SOAP to talk to localsite</description>
@@ -301,4 +331,8 @@
 </servlet-mapping>
 
+    <servlet-mapping>
+      <servlet-name>nzdl-library</servlet-name>
+      <url-pattern>/nzdl</url-pattern>
+    </servlet-mapping>
   <servlet-mapping>
     <servlet-name>tester</servlet-name>
Index: /main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js
===================================================================
--- /main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js	(revision 22675)
+++ /main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js	(revision 22676)
@@ -36,5 +36,5 @@
 
     $(".element_type_td").draggable({
-            connectToSortable: '.gsf_table',
+            //connectToSortable: '.td',
             helper: 'clone',
             revert: 'invalid'
@@ -107,17 +107,34 @@
             }
     });
-    
+ 
+    $('div.gsf_template').children(".block,.table").slideUp(300); 
+    //$('div.gsf_template .table').hide();  
+    //$('div.block').click(function() {    
+        //alert("I was clicked!");
+    //    $(this).children(".block").slideToggle('fast');
+    //    return false;
+    //});
+
+ 
+    //hide the all of the element with class msg_body
+  //$(".gsf_template > table").hide();
+  //toggle the componenet with class msg_body
+  //$(".gsf_template").click(function()
+  //{
+    //alert("You clicked? " + $("this > .table"));
+    //$(this).getElementsByTagName("table")[0].slideToggle(600);
+  //});
 
     //$(".resizable").resizable({containment: 'parent', alsoResize:'parent'});
 
-    $('.tr').equalHeights();
-
-    $(".td").resizable({
-                alsoResize: 'parent',
+    //$('.tr').equalHeights();
+
+    //$(".td").resizable({
+    //            alsoResize: 'parent',
                 //containment: 'parent',
-                handles: 'e,s',
-                stop: function(event, ui) {
-                        $(this).parent().parent().equalHeights();
-                }, });
+    //            handles: 'e,s',
+    //            stop: function(event, ui) {
+    //                    $(this).parent().parent().equalHeights();
+    //            }, });
 
 }); 
@@ -125,10 +142,21 @@
 /*******************************************************************************/
 
+function minimize_templates()
+{
+    //$(".msg_body").hide();
+    //var targetContent = $('.table');
+    //targetContent.hide();
+    //targetContent.parent().css('display','none');
+    //targetContent.slideUp(300);
+    //targetContent.parent().html('[+]');
+
+}
+
 function bind_all_sortables()
 {
     bind_template_sortable();
-    bind_table_sortable();
-    bind_tr_sortable();
-    bind_td_sortable();
+    //bind_table_sortable();
+    //bind_tr_sortable();
+    //bind_td_sortable();
     bind_choose_metadata_sortable();
     bind_link_sortable();
@@ -137,11 +165,94 @@
     bind_otherwise_sortable();
 
+    bind_tables();
+
     bind_block_mouseover();
     bind_minmax_remove();    
 }
 
+function bind_tables()
+{
+    $('.tr').equalHeights();
+
+    $(".td").resizable({
+                alsoResize: 'parent',
+                //containment: 'parent',
+                handles: 'w,e',
+                stop: function(event, ui) {
+                        $(this).parent().parent().equalHeights();
+                }, });
+
+    $(".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")},
+            drop: function(event, ui) {
+                //alert("Something has been dropped on me!!");
+                //$(this).addClass('ui-state-highlight').find('p').html('Dropped!');
+                 //var tr = this.parentNode.parentNode; //$(this).getElementsByTagName("tr")[0];
+                 var td = document.createElement("td");
+                 var div = document.createElement("div"); // class=\"td block\" title=\"td-div\"");
+                 div.setAttribute("title","td-div");
+                 div.setAttribute("class","td block");
+                 div.setAttribute("width","25px");
+                 td.appendChild(div);
+                 var sep = document.createElement("td");
+                 sep.setAttribute("class","droppable");
+                 sep.setAttribute("width","10px"); 
+                 $(this).after(sep);                
+                 $(this).after(td);                
+                 bind_tables();
+                 //bind_td_sortable();
+                 //bind_all_sortables();
+            }
+        });
+
+}
+
 function replace_with(item, me)
 {
+/*
+    (item.parents('.table')).each(function(index) { 
+        $(this).children().children().children('td').each(function() {
+            var sum = 0;
+            $(this).children('.block').each(function() { sum = sum + $(this).height(); } );
+            console.log("My height is " + $(this).height() + ", sum height is " + sum);
+        });
+    });
+*/
+    /*
+    alert(item.parents('.td').length);
+
+    (item.parents('.td')).each(function(index) { 
+        $(this).children.each(function()
+        alert(index + " height is " + $(this).height()); // + $(this).style('height') + $(this).offsetHeight); 
+        var h = $(this).height(); 
+        var a = 0;
+        // if we are now the maximum then set to h otherwise ignore?
+        $(this).parents('.table').each(function() {$(this).children().children().children().each(function() { if($(this).height() > a) a = $(this).height(); } ) } );
+        alert("A is " + a);
+        if( h > a)
+        {
+            h = h + 25; 
+            alert("Increasing height to " + h);
+            $(this).height(h);
+            alert("height is now " + $(this).height());
+        }
+        else
+            alert("height did not need increasing (h=" + h + ",a=" + a + ")");
+    }); //forEach().css('height'));
+    */
+    
     item.replaceWith(me); //'<div class="element element-txt">This text box has been added!</div>');
+
+    (item.parents('.table')).each(function(index) {
+        $(this).children().children().children().each(function() {
+            var sum = 0;
+            $(this).children('.block').each(function() { sum = sum + $(this).height(); } );
+            console.log("My height is " + $(this).height() + ", sum height is " + sum);
+        });
+    });
+
     bind_all_sortables();
 }
@@ -167,4 +278,5 @@
 }
 
+/*
 function bind_table_sortable()
 {
@@ -197,14 +309,37 @@
 }
 
+*/
+
 function bind_td_sortable()
 {
     $('.td').sortable({
             'cursor':'pointer',
-            'tolerance': 'pointer',
-            'items':'.gsf_metadata, .gsf_choose_metadata, .gsf_link, .gsf_switch',
-            'placeholder':'placeholder',
-            //'nested':'.gsf:metadata'
+            'containment':'parent',
+            'tolerance': 'pointer',
+            'items':'.gsf_metadata, .gsf_choose_metadata, .gsf_link, .gsf_switch, .td',
+            'placeholder':'placeholder',
+            //'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); }
+                /*if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('element_type_td')) { 
+                    alert("Inserting td " + this.parentNode.parentNode + " " + $('.td').sortable( "widget" )); 
+                    var tr = this.parentNode.parentNode; //$(this).getElementsByTagName("tr")[0];
+                    var td = document.createElement("td"); 
+                    var div = document.createElement("div"); // class=\"td block\" title=\"td-div\"");
+                    //var cls = document.createAttribute("class");
+                    div.setAttribute("title","td-div");
+                    div.setAttribute("class","td block");
+                    var span = document.createElement("div");
+                    span.setAttribute("class", "block gsf_metadata");
+                    span.setAttribute("style","height:50px");
+                    //div.setAttribute(cls,"block");
+                    div.appendChild(span);
+                    td.appendChild(div);
+                    tr.appendChild(td); 
+                    ui.item.remove(); 
+                    bind_all_sortables();
+                }*/
+                
             }
 
@@ -233,6 +368,9 @@
             'tolerance': 'pointer',
             'items':'.gsf_icon',
-            'placeholder':'placeholder'
-            //'nested':'.gsf:metadata'
+            'placeholder':'placeholder',
+            //'nested':'.gsf:metadata'
+            stop: function(event, ui) {
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('element_type_gsf_icon')) { replace_with(ui.item, gsf_icon_element); }
+            }
     });
 }
@@ -311,12 +449,26 @@
 var toggleContent = function(e)
 {
-    var targetContent = $('div.block', this.parentNode);
-    if (targetContent.css('display') == 'none') {
-        targetContent.slideDown(300);
+    //var targetContent = $('div.block', this.parentNode);
+    //$(".msg_head").click(function()
+  //{
+    //$(this).next(".block").slideToggle(600);
+  //});
+    //alert($(this).html() + " " + $(this).css('display') + " " + targetContent.css('display'));
+    if ($(this).html() == '[+]'){ //targetContent.css('display') == 'none') {
+    //if ($(this).css('display') == 'none') {
+   //     var targetContent2 = $('.table');
+   //     targetContent2.show();
+
+   //     targetContent.show();
+   //     targetContent.slideDown(300);
+   //     alert("I should be sliding down! " + $(this).parent());
+        $(this).parent().children(".block,.table").slideDown(300);
         $(this).html('[-]');
     } else {
-        targetContent.slideUp(300);
+    //    targetContent.slideUp(300);
+        $(this).parent().children(".block,.table").slideUp(300);
         $(this).html('[+]');
     }
+    //$(this).children(".block, .table").slideToggle('fast');
     return false;
 };
@@ -348,9 +500,9 @@
 
 $.fn.equalHeights = function(px) {
-    console.log("EQUAL HEIGHTS");
+    //console.log("EQUAL HEIGHTS");
     $(this).each(function(){
         var currentTallest = 0;
-        console.log($(this).children());
-        console.log($(this).children().children());
+        //console.log($(this).children());
+        //console.log($(this).children().children());
         //$(this).children().children().each(function(i){
         //    console.log($(this));
Index: /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/main.xsl
===================================================================
--- /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/main.xsl	(revision 22675)
+++ /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/main.xsl	(revision 22676)
@@ -34,5 +34,5 @@
 				<link rel="stylesheet" href="interfaces/{$interface_name}/style/core.css" type="text/css"/>
 				<!-- <script type="text/javascript" src="interfaces/oran/js/jquery.js"><xsl:text> </xsl:text></script> --> 
-                <script type="text/javascript" src="interfaces/oran/js/jquery-1.4.2.min.js"><xsl:text> </xsl:text></script>
+                <script type="text/javascript" src="interfaces/oran/js/jquery-1.4.2.js"><xsl:text> </xsl:text></script>
                 <script type="text/javascript" src="interfaces/oran/js/jquery-ui-1.8.2.custom.min.js"><xsl:text> </xsl:text></script>
                 <!-- <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"><xsl:text> </xsl:text></script> -->
@@ -152,4 +152,7 @@
         .block { margin-left: 10px; 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; } -->
 
@@ -176,5 +179,5 @@
     <td width="25%" valign="top">
         <h2> Elements to add </h2>
-        <div class="element_type_gsf_template css_gsf_template" title="gsf:template">NEW GSF:TEMPLATE</div>
+        <div class="element_type_gsf_template css_gsf_template" title="gsf:template">NEW GSF:TEMPLATE MATCH</div>
         <div class="element_type_gsf_choose_metadata css_gsf_choose_metadata" title="gsf:choose-metadata">NEW GSF:CHOOSE-METADATA</div>
         <div class="element_type_gsf_metadata css_gsf_metadata" title="gsf:metadata">NEW GSF:METADATA</div>
Index: /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui-templates.xsl
===================================================================
--- /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui-templates.xsl	(revision 22675)
+++ /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui-templates.xsl	(revision 22676)
@@ -46,8 +46,8 @@
     <!-- ********** GSF:METADATA ********** -->
         <xsl:variable name="metadata">
-        <div class="gsf_metadata css_gsf_metadata block leaf" title="gsf:metadata">METADATA <xsl:call-template name="meta-to-combo">
+        <div class="gsf_metadata css_gsf_metadata block leaf" title="gsf:metadata"><xsl:call-template name="meta-to-combo">
                         <xsl:with-param name="metadataSets" select="$metadataSets"/>
                         <xsl:with-param name="current" select="ex.title"/>
-                     </xsl:call-template> <a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a></div>
+                     </xsl:call-template><a href="#" class="remove">[x]</a></div>
         </xsl:variable>
 
@@ -75,5 +75,5 @@
 
         <xsl:variable name="template">
-        <div class="gsf_template block" title="gsf:template">TEMPLATE[match=<input type="text" name="rawtextinput" size="10"/>]<a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a><table border="1"><tr class="tr"></tr></table></div><br/>
+        <div class="gsf_template block" title="gsf:template">MATCH=<input type="text" name="rawtextinput" size="10"/><a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a><table border="1"><tr class="tr"></tr></table></div><br/>
         </xsl:variable>
 
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 22675)
+++ /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui.xsl	(revision 22676)
@@ -133,8 +133,8 @@
         <xsl:param name="metadataSets"/>
 
-        <div class="gsf_metadata css_gsf_metadata block leaf" title="gsf:metadata">METADATA <xsl:call-template name="meta-to-combo">
+        <div class="gsf_metadata css_gsf_metadata block leaf" title="gsf:metadata"><xsl:call-template name="meta-to-combo">
                         <xsl:with-param name="metadataSets" select="$metadataSets"/>
                         <xsl:with-param name="current" select="@name"/>
-                     </xsl:call-template> <a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
+                     </xsl:call-template><a href="#" class="remove">[x]</a>
         </div>
     </xsl:template>
@@ -196,7 +196,13 @@
 
         <div class="gsf_template css_gsf_template block" title="gsf:template">
-                TEMPLATE[match=<input type="text" name="rawtextinput" size="10" value="{@match}"/>]<a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
-                <table border="1">
+                MATCH=<input type="text" name="rawtextinput" size="10" value="{@match}"/><xsl:choose>
+                    <xsl:when test="not(@mode)"> <!-- parameter has not been supplied -->
+                    </xsl:when>
+                    <xsl:otherwise>MODE=<input type="text" name="rawtextinput" size="10" value="{@mode}"/></xsl:otherwise>
+                    </xsl:choose><a href="#" class="minmax">[+]</a><a href="#" class="remove">[x]</a>
+                <table class="table" border="1">
+                <tbody>
                 <tr class="tr">
+                <td class="droppable" width="10px"/>
                 <xsl:apply-templates mode="xml-to-gui">
                     <xsl:with-param name="depth" select="$depth"/>
@@ -204,4 +210,5 @@
                 </xsl:apply-templates>
                 </tr>
+                </tbody>
                 </table>
         </div><br/>
@@ -229,5 +236,5 @@
 
         <div class="gsf_when css_gsf_when block" title="gsf:when"> 
-                WHEN[test=<xsl:value-of select="@test"/>] <br/><a href="#" class="minmax">[-]</a><a href="#" class="remove">[x]</a>
+                WHEN[test=<xsl:value-of select="@test"/>]<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"/>
@@ -327,4 +334,5 @@
             </div>
         </td>
+        <td class="droppable" width="10px"/>
     </xsl:template>
 
