Index: /main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js
===================================================================
--- /main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js	(revision 23275)
+++ /main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js	(revision 23276)
@@ -2,4 +2,47 @@
 console.log("Loading gui_div.js\n");
 
+var initialised_iframe = "false";
+/*
+$("#iframe").ready(function(){
+        console.log("iframe is ready ...");
+        var iframe = document.getElementById('iframe');
+        var iframe_document = iframe.document;
+
+        if(iframe.contentDocument)
+        {
+            iframe_document = iframe.contentDocument; // For NS6
+            console.log("Chose content document");
+        }
+        else if(iframe.contentWindow)
+        {
+            iframe_document = iframe.contentWindow.document; // For IE5.5 and IE6
+            console.log("Chose content window");
+        }
+
+        console.log(iframe_document.documentElement.innerHTML); //document.documentElement.outerHTML
+
+        $(iframe_document.documentElement.innerHTML).find('a').each(function() {
+            console.log("data "+$(this).data('href'));
+            console.log("getAttribute "+$(this).getAttribute('href'));
+            console.log("attr "+$(this).attr('href'));
+            console.log("this.href "+this.href);
+            var original = this.href; //$(this).attr('href');
+            // check if greenstone link ie. starts with format
+            //var original = $(this).data('href');
+            var modified = original.toString().concat("&excerptid=gs_content");
+            console.log(modified);
+            this.href = modified;
+            //$(this).attr('href',modified);
+            //$(this).data('href', modified);
+            //console.log($(this).attr('href'));
+            console.log("data "+$(this).data('href'));
+            console.log("getAttribute "+$(this).getAttribute('href'));
+            console.log("attr "+$(this).attr('href'));
+            console.log("this.href "+this.href);
+            console.log("**********");
+
+        });
+}); */
+
 $(document).ready(function(){
 
@@ -7,4 +50,53 @@
 
     var CURRENT_SELECT_VALUE = "";
+
+    /*
+    var iframe = document.getElementById('iframe');
+    var iframe_document = iframe.document;
+   
+    if(iframe.contentDocument)
+    {
+        iframe_document = iframe.contentDocument; // For NS6
+        console.log("Chose content document");
+    }
+    else if(iframe.contentWindow)
+    {
+        iframe_document = iframe.contentWindow.document; // For IE5.5 and IE6
+        console.log("Chose content window");
+    }
+    // Put the content in the iframe
+    if(initialised_iframe == "false")
+    {
+        console.log("Initialised iframe with preview html");
+        iframe_document.open();
+        iframe_document.writeln(preview_html); //.concat("&excerptid=gs_content"));
+        iframe_document.close(); 
+        initialised_iframe = "true";
+    }
+    
+    $(iframe_document.documentElement.innerHTML).find('a').each(function() {
+            console.log("data "+$(this).data('href'));
+            console.log("getAttribute "+this.getAttribute('href'));
+            console.log("attr "+$(this).attr('href'));
+            console.log("this.href "+this.href);
+            var original = this.href; //$(this).attr('href');
+            // check if greenstone link ie. starts with format
+            //var original = $(this).data('href');
+            var modified = original.toString().concat("&excerptid=gs_content");
+            console.log("*                      *");
+            console.log(modified);
+            console.log("*                      *");
+            //this.href = modified;
+            //$(this).attr('href',modified);
+            //$(this).data('href', modified);
+            $(this).attr({ 'href': modified });
+            //console.log($(this).attr('href'));
+            console.log("data "+$(this).data('href'));
+            console.log("getAttribute "+this.getAttribute('href'));
+            console.log("attr "+$(this).attr('href'));
+            console.log("this.href "+this.href);
+            console.log("***********************");
+    });
+    */
 
     /******************************************/
@@ -12,5 +104,5 @@
     /******************************************/
 
-    $(".element_type_gsf_template").draggable({
+    $(".draggable_gsf_template").draggable({
             cursor: 'crosshair',
             connectToSortable: '#formatStatement',
@@ -19,5 +111,5 @@
     });
 
-    $(".element_type_table").draggable({
+    $(".draggable_table").draggable({
             cursor: 'crosshair',
             connectToSortable: '.gsf_template',
@@ -26,5 +118,5 @@
     });
 
-    $(".element_type_tr").draggable({
+    $(".draggable_tr").draggable({
             cursor: 'crosshair',
             connectToSortable: '.gsf_table',
@@ -33,5 +125,5 @@
     })
 
-    $(".element_type_td").draggable({
+    $(".draggable_td").draggable({
             cursor: 'crosshair',
             //connectToSortable: '.td',
@@ -40,7 +132,7 @@
     })
 
-    $(".element_type_text").draggable({
-            cursor: 'crosshair',
-            connectToSortable: '.gsf_otherwise, .gsf_link',
+    $(".draggable_text").draggable({
+            cursor: 'crosshair',
+            connectToSortable: '.gsf_otherwise, .gsf_link, .gsf_choose, .gsf_when',
             helper: 'clone',
             revert: 'invalid'
@@ -49,5 +141,5 @@
     $(".draggable_gsf_choose_metadata").draggable({
             cursor: 'crosshair',
-            connectToSortable: '.td-div',
+            connectToSortable: '.td-div, .gsf_link, .gsf_when, .gsf_otherwise',
             helper: 'clone',
             revert: 'invalid'
@@ -57,5 +149,5 @@
     $(".draggable_gsf_metadata").draggable({
             cursor: 'crosshair',
-            connectToSortable: '.gsf_choose_metadata, .gsf_when, .gsf_otherwise, .td-div',
+            connectToSortable: '.gsf_choose_metadata, .gsf_when, .gsf_otherwise, .gsf_link, .td-div',
             helper: 'clone',
             revert: 'invalid'
@@ -64,5 +156,5 @@
     $(".draggable_gsf_link").draggable({
             cursor: 'crosshair',
-            connectToSortable: '.td-div',
+            connectToSortable: '.td-div, .gsf_when, .gsf_otherwise, .gsf_link',
             helper: 'clone',
             revert: 'invalid'
@@ -72,5 +164,5 @@
     $(".draggable_gsf_switch").draggable({
             cursor: 'crosshair',
-            connectToSortable: '.td-div',
+            connectToSortable: '.td-div, .gsf_link',
             helper: 'clone',
             revert: 'invalid'
@@ -285,9 +377,9 @@
             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('element_type_table')) { replace_with(ui.item, "<table class=\"table\" border=\"2\"></table>"); }
-                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('element_type_gsf_choose_metadata')) { replace_with(ui.item, gsf_choose_metadata_element); }
-                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_gsf_link')) { replace_with(ui.item, gsf_link_element); }
-                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('element_type_gsf_switch')) { replace_with(ui.item, gsf_switch_element); }
+                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); }
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_link')) { replace_with(ui.item, gsf_link_element); }
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_switch')) { replace_with(ui.item, gsf_switch_element); }
             }
     });
@@ -340,5 +432,12 @@
             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); }
+                // gsf metadata
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
+                // gsf choose metadata
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose_metadata')) { replace_with(ui.item, gsf_choose_metadata_element); }
+                // gsf link
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_link')) { replace_with(ui.item, gsf_link_element); }
+                // gsf switch
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_switch')) { replace_with(ui.item, gsf_switch_element); }
                 
             }
@@ -362,19 +461,16 @@
             'cursor':'pointer',
             'tolerance': 'pointer',
-            'items':'.gsf_metadata, .gsf_default',
+            'items':'.gsf_metadata, .gsf_text, .gsf_default',
             'placeholder':'placeholder',
             'connectWith':'.gsf_choose_metadata',
             //'nested':'.gsf:metadata'
             stop: function(event, ui) {
-                //alert("STOP");
-                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { 
-                    console.log("Current select value = "+CURRENT_SELECT_VALUE);
-                    var select = $(ui.item).find('select');
-                    var value = select.attr("value");
-                    console.log("We want this:"+value);
-
-                    replace_with(ui.item, gsf_metadata_element); 
-                    
-                }
+                // gsf metadata
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); } 
+                // gsf text
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_text')) { replace_with(ui.item, gsf_text_element); } 
+                // gsf default
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_default')) { replace_with(ui.item, gsf_default_element); } 
+
                 bind_all_sortables();
             }
@@ -388,11 +484,21 @@
             'cursor':'pointer',
             'tolerance': 'pointer',
-            'items':'.gsf_icon, .gsf_text',
+            'items':'.leaf, .gsf_link, .gsf_switch, .gsf_choose',
             'placeholder':'placeholder',
             'connectWith':'.gsf_link',
             //'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); }
-                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('element_type_text')) { replace_with(ui.item, "<input type=\"text\" name=\"rawtextinput\" size=\"10\"/>"); }
+                // gsf icon
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_icon')) { replace_with(ui.item, gsf_icon_element); }
+                // gsf text
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_text')) { replace_with(ui.item, "<input type=\"text\" name=\"rawtextinput\" size=\"10\"/>"); }
+                // gsf metadata
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); } 
+                // gsf link
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_link')) { replace_with(ui.item, gsf_link_element); }
+                // gsf switch
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_switch')) { replace_with(ui.item, gsf_switch_element); }
+                // gsf choose
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose_metadata')) { replace_with(ui.item, gsf_choose_metadata_element); }
             }
     });
@@ -405,11 +511,17 @@
             'cursor':'pointer',
             'tolerance': 'pointer',
-            'items':'.gsf_metadata, .gsf_when, .gsf_otherwise',
+            'items':'.gsf_metadata, .gsf_when, .gsf_otherwise, .gsf_text',
             'placeholder':'placeholder',
             'connectWith':'.gsf_switch',
             //'nested':'.gsf:metadata'
             stop: function(event, ui) {
-                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('element_type_gsf_when')) { replace_with(ui.item, gsf_when_element); }
-                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('element_type_gsf_otherwise')) { replace_with(ui.item, gsf_otherwise_element); }
+                // gsf when
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_when')) { replace_with(ui.item, gsf_when_element); }
+                // gsf otherwise
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_otherwise')) { replace_with(ui.item, gsf_otherwise_element); }
+                // gsf metadata
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); } 
+                // gsf text
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_text')) { replace_with(ui.item, gsf_text_element); } 
             }
     });
@@ -422,9 +534,18 @@
             'cursor':'pointer',
             'tolerance': 'pointer',
-            'items':'.leaf',
+            'items':'.leaf, .gsf_link, .gsf_choose',
             'placeholder':'placeholder',
             //'nested':'.gsf:metadata'
             stop: function(event, ui) {
-                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('element_type_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
+                // gsf metadata
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
+                // gsf icon
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_icon')) { replace_with(ui.item, gsf_icon_element); } 
+                // gsf text
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_text')) { replace_with(ui.item, gsf_text_element); } 
+                // gsf link
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_link')) { replace_with(ui.item, gsf_link_element); } 
+                // gsf choose
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose')) { replace_with(ui.item, gsf_choose_element); } 
             }
     });
@@ -437,10 +558,18 @@
             'cursor':'pointer',
             'tolerance': 'pointer',
-            'items':'.leaf',
+            'items':'.leaf, .gsf_link, .gsf_choose',
             'placeholder':'placeholder',
             //'nested':'.gsf:metadata'
             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_text')) { replace_with(ui.item, "<input type=\"text\" name=\"rawtextinput\" size=\"10\"/>"); }
+                // gsf metadata
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
+                // gsf text
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_text')) { replace_with(ui.item, "<input type=\"text\" name=\"rawtextinput\" size=\"10\"/>"); }
+                // gsf icon
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_icon')) { replace_with(ui.item, gsf_icon_element); } 
+                // gsf link
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_link')) { replace_with(ui.item, gsf_link_element); } 
+                // gsf choose
+                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_choose')) { replace_with(ui.item, gsf_choose_element); } 
             }
     });
Index: /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/main.xsl
===================================================================
--- /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/main.xsl	(revision 23275)
+++ /main/trunk/greenstone3/web/interfaces/oran/transform/layouts/main.xsl	(revision 23276)
@@ -23,5 +23,5 @@
 
 	<!-- the output format for this layout is html -->
-	<xsl:output method="html"/>  
+	<xsl:output method="html" omit-xml-declaration="yes"/>  
 
 	<!-- the main layout is defined here -->
@@ -190,5 +190,5 @@
         <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 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_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">
@@ -212,12 +212,13 @@
         <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="element_type_text css_text" title="text">TEXT</div>
-        <div class="element_type_table css_table" title="gsf:table">NEW TABLE</div>
-        <div class="element_type_tr css_tr" title="gsf:row">NEW TABLE ROW</div>
-        <div class="element_type_td css_td" title="gsf:column">NEW TABLE COLUMN</div>
+        <div class="draggable_gsf_text css_text" title="text">TEXT</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>
@@ -227,5 +228,5 @@
           </i>
         </p>
-    </div>
+    </div> -->
     <!--    <p>
           <i>
@@ -237,5 +238,8 @@
 
 <!-- *************************************************************************************** -->
-
+<H2>Preview</H2>
+                    <!-- <iframe name="preview" id="iframe" width="98%" height="300">Your browser does not support iframes</iframe> -->
+
+                    <!-- <xsl:variable name="preview"> -->
 					<div id="gs_content">
 						<!--
@@ -246,4 +250,9 @@
 
 					</div>
+                    <!-- </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="gs_footer">
