anchor.diff:  
       </div>
   
  -	<div class="clear"></div>
  -
  -	<div class="grid_8">
  -	
  -	    <%-- preview table will be populated by JS here --%>
  -		<div id="preview-table" class="box grid_12 last collection-table nowrap nomargin results">
  -		  <script type="text/javascript">if (showTable) jQuery("#preview-table").hide();</script>
  -		  <div class="gradient-wrap">
  -		      <table>
  -		        <tbody></tbody>
  -		      </table>
  -		      <div class="gradient"></div>
  -	      </div>
  -	      <div class="toggle">
  -	      	<a class="more" title="Show the results list">Show the list</a>
  -	      </div>
  -	    </div>	
  -	
  -	      <script type="text/javascript">
  -	      	(function() {
  -	      		<%-- give me the columns in the table in order --%>
  -	      		var columns = Array();
  -	      		jQuery("#list-table table thead th").each(function(index) {
  -	      			columns.push(jQuery(this).attr('title'));
  -	      		});
  -	      		
  -	      		<%-- only valid columns --%>
  -	      		var previewColumns = Array();
  -	      		jQuery.each('${showInPreviewTable}'.replace(/\[|\]/g, '').split(', '), function(index, value) { 
  -	      		  if (jQuery("#list-table table thead th[title='"+value+"']").exists()) {
  -	      			previewColumns.push(value);
  -	      		  }
  -	      		});
  -	      		
  -	      		<%-- no config, add the "first" two columns --%>
  -	      		if (previewColumns.length == 0) {
  -	      			previewColumns.push(columns[1]);
  -	      			if (columns.length > 2) {
  -	      				previewColumns.push(columns[2]);
  -	      			}
  -	      		}
  -	      		
  -      			var limit = 3;
  -      			jQuery("#list-table table tbody tr").each(function(index) {
  -      				limit--;
  -      				var sourceTr = this;
  -      				<%-- copy over the relevant row columns --%>
  -      				jQuery('<tr/>', {
  -      					'html': function() {
  -      						var tr = this;
  -      	      				jQuery.each(previewColumns, function(index, value) {
  -      	      					jQuery('<td/>', {
  -      	      						'text': function() {
  -      	      							return jQuery(sourceTr).find("td:nth-child("+(columns.indexOf(value)+1)+")").text();
  -      	      						}
  -      	      					}).appendTo(tr);
  -      	      				});
  -      					}
  -      				}).appendTo("#preview-table table tbody");
  -      				
  -      				if (limit <= 0) return false;
  -      			});
  -	      		
  -		      // will show/hide the results table and toolbox & change the link appropriately (text, ico)
  -		      function toggleResults() {
  -		    	if (jQuery('#preview-table:visible').length > 0) {
  -		    		// show the full list, hide preview table
  -			    	jQuery('#preview-table').hide();
  -			        jQuery('#ListArea').slideDown().scrollTo('slow', 'linear', -25);
  -		    	} else {
  -		    		// hide the full list, show preview table
  -		    		jQuery('#ListArea').slideUp();
  -		    		jQuery('#preview-table').show();
  -		    		jQuery('#ListCategory').scrollTo('slow', 'linear', -15);
  -		    	}
  -		      }
  -
  -		      // shuffle "selected" around:
  -		      jQuery("#results b").not("table.results b").remove();
  -		      var s = jQuery.trim(jQuery("#results span#selectedIdFields").first().html());
  -		      jQuery("#results span#selectedIdFields").first().remove();
  -		      jQuery("#results span#selectedIdFields").html(s);
  -
  -		      if (s.length == 0) { // hide when we have not selected anything before reload
  -		        jQuery('#results div.selected span.desc').hide();
  -		      }
  -
  -		      // monitor checkboxes for changes
  -		      jQuery('#results input').each(function(index) {
  -		        jQuery(this).click(function() {
  -		          if (jQuery('#results div.selected span.desc').is(':visible')) {
  -		            if (jQuery('#results div.selected #selectedIdFields').html().length == 0) {
  -		                jQuery('#results div.selected span.desc').hide();
  -		                window.location.hash = '';
  -		            }
  -		          } else {
  -		            if (jQuery('#results div.selected #selectedIdFields').html().length > 0) {
  -		                jQuery('#results div.selected span.desc').show();
  -		            }
  -		            // append a param so that we keep table expanded upon reload
  -		            window.location.hash = 'hasHighlighted';
  -		          }
  -		        });
  -		      });
  -
  -		      // apply highlight class to rows that were selected before reload
  -		      jQuery('#results input:checked').each(function(index) {
  -		        jQuery(this).parent().parent().find('td').not('th td').addClass('highlightCell');
  -		      });
  -
  -		      // toggler events
  -		      jQuery('#preview-table').click(function() {
  -		        toggleResults();
  -		      });
  -		      jQuery('#list-table div.toggle a.less').click(function() {
  -			    toggleResults();
  -			  });
  -	      	})();
  -	      </script>	
  -	
  -	    <%-- convert to a different type & orthologues --%>
  -	    <div class="box grid_6" id="convertList">
  -	      <div class="feature convert">
  -	        <html:form action="/modifyBagDetailsAction" styleId="bagDetailsForm">
  -	        <html:hidden property="bagName" value="${bag.name}"/>
  -	          <tiles:insert name="convertBag.tile">
  -	            <tiles:put name="bag" beanName="bag" />
  -	            <tiles:put name="idname" value="cp" />
  -	            <tiles:put name="orientation" value="h" />
  -	          </tiles:insert>
  -	        </html:form>
  -	      </div>
  -	    </div>
  -	
  -	    <%-- download list --%>
  -	    <div class="box grid_6" id="download">
  -	      <div class="feature">
  -	        <h3 class="goog">Download</h3>
  -	        <c:set var="tableName" value="bag.${bag.name}" scope="request"/>
  -	        <c:set var="pagedTable" value="${pagedResults}" scope="request"/>
  -	        <tiles:get name="export.tile"/>
  -	      </div>
  -	    </div>
  +  <div class="clear"></div>
  +
  +  <div class="grid_8">
  +
  +      <%-- preview table will be populated by JS here --%>
  +    <div id="preview-table" class="box grid_12 last collection-table nowrap nomargin results">
  +      <script type="text/javascript">if (showTable) jQuery("#preview-table").hide();</script>
  +      <div class="gradient-wrap">
  +          <table>
  +            <tbody></tbody>
  +          </table>
  +          <div class="gradient"></div>
  +        </div>
  +        <div class="toggle">
  +          <a class="more" title="Show the results list">Show the list</a>
  +        </div>
  +      </div>
  +
  +        <script type="text/javascript">
  +          (function() {
  +            <%-- give me the columns in the table in order --%>
  +            var columns = Array();
  +            jQuery("#list-table table thead th").each(function(index) {
  +              columns.push(jQuery(this).attr('title'));
  +            });
  +
  +            <%-- only valid columns --%>
  +            var previewColumns = Array();
  +            jQuery.each('${showInPreviewTable}'.replace(/\[|\]/g, '').split(', '), function(index, value) {
  +              if (jQuery("#list-table table thead th[title='"+value+"']").exists()) {
  +              previewColumns.push(value);
  +              }
  +            });
  +
  +            <%-- no config, add the "first" two columns --%>
  +            if (previewColumns.length == 0) {
  +              previewColumns.push(columns[1]);
  +              if (columns.length > 2) {
  +                previewColumns.push(columns[2]);
  +              }
  +            }
  +
  +            var limit = 3;
  +            jQuery("#list-table table tbody tr").each(function(index) {
  +              limit--;
  +              var sourceTr = this;
  +              <%-- copy over the relevant row columns --%>
  +              jQuery('<tr/>', {
  +                'html': function() {
  +                  var tr = this;
  +                      jQuery.each(previewColumns, function(index, value) {
  +                        jQuery('<td/>', {
  +                          'text': function() {
  +                            return jQuery(sourceTr).find("td:nth-child("+(columns.indexOf(value)+1)+")").text();
  +                          }
  +                        }).appendTo(tr);
  +                      });
  +                }
  +              }).appendTo("#preview-table table tbody");
  +
  +              if (limit <= 0) return false;
  +            });
  +
  +          // will show/hide the results table and toolbox & change the link appropriately (text, ico)
  +          function toggleResults() {
  +          if (jQuery('#preview-table:visible').length > 0) {
  +            // show the full list, hide preview table
  +            jQuery('#preview-table').hide();
  +              jQuery('#ListArea').slideDown().scrollTo('slow', 'linear', -25);
  +          } else {
  +            // hide the full list, show preview table
  +            jQuery('#ListArea').slideUp();
  +            jQuery('#preview-table').show();
  +            jQuery('#ListCategory').scrollTo('slow', 'linear', -15);
  +          }
  +          }
  +
  +          // shuffle "selected" around:
  +          jQuery("#results b").not("table.results b").remove();
  +          var s = jQuery.trim(jQuery("#results span#selectedIdFields").first().html());
  +          jQuery("#results span#selectedIdFields").first().remove();
  +          jQuery("#results span#selectedIdFields").html(s);
  +
  +          if (s.length == 0) { // hide when we have not selected anything before reload
  +            jQuery('#results div.selected span.desc').hide();
  +          }
  +
  +          // monitor checkboxes for changes
  +          jQuery('#results input').each(function(index) {
  +            jQuery(this).click(function() {
  +              if (jQuery('#results div.selected span.desc').is(':visible')) {
  +                if (jQuery('#results div.selected #selectedIdFields').html().length == 0) {
  +                    jQuery('#results div.selected span.desc').hide();
  +                    window.location.hash = '';
  +                }
  +              } else {
  +                if (jQuery('#results div.selected #selectedIdFields').html().length > 0) {
  +                    jQuery('#results div.selected span.desc').show();
  +                }
  +                // append a param so that we keep table expanded upon reload
  +                window.location.hash = 'hasHighlighted';
  +              }
  +            });
  +          });
  +
  +          // apply highlight class to rows that were selected before reload
  +          jQuery('#results input:checked').each(function(index) {
  +            jQuery(this).parent().parent().find('td').not('th td').addClass('highlightCell');
  +          });
  +
  +          // toggler events
  +          jQuery('#preview-table').click(function() {
  +            toggleResults();
  +          });
  +          jQuery('#list-table div.toggle a.less').click(function() {
  +          toggleResults();
  +        });
  +          })();
  +        </script>
  +
  +      <%-- convert to a different type & orthologues --%>
  +      <div class="box grid_6" id="convertList">
  +        <div class="feature convert">
  +          <html:form action="/modifyBagDetailsAction" styleId="bagDetailsForm">
  +          <html:hidden property="bagName" value="${bag.name}"/>
  +            <tiles:insert name="convertBag.tile">
  +              <tiles:put name="bag" beanName="bag" />
  +              <tiles:put name="idname" value="cp" />
  +              <tiles:put name="orientation" value="h" />
  +            </tiles:insert>
  +          </html:form>
  +        </div>
  +      </div>
  +
  +      <%-- download list --%>
  +      <div class="box grid_6" id="download">
  +        <div class="feature">
  +          <h3 class="goog">Download</h3>
  +          <c:set var="tableName" value="bag.${bag.name}" scope="request"/>
  +          <c:set var="pagedTable" value="${pagedResults}" scope="request"/>
  +          <tiles:get name="export.tile"/>
  +        </div>
  +      </div>
       </div>
   
       <%-- external links --%>
  
positive.code: 
  </c:when>
  <c:otherwise>
    <script type="text/javascript">
    	(function() {
  	    jQuery(document).ready(function() {
  	      // parse the message because the messaging is eeeu
  	      var m = jQuery(jQuery('#error_msg.topBar.errors').html()).text().replace('Hide', '').trim();
  	      // append link to all lists
  	      var l = ', <html:link styleClass="inline" action="/bag?subtab=view">view all lists</html:link> instead.';
  	      jQuery('#error_msg.topBar.errors').html(jQuery('#error_msg.topBar.errors').html().replace(m, m+l));
  	    });
    	})();
    </script>
  </c:otherwise>
  </c:choose>
  
  
negative.code:     <script type="text/javascript">
        <%-- show form --%>
        (function() {
          jQuery('div.title a').click(function() {
            jQuery('div.title div.form').show();
            jQuery('div.title h1').hide();
          });
  
          <%-- current name --%>
          var currentName = '${bag.name}';
  
          <%-- save name --%>
          function saveName() {
            var newName = jQuery('div.title input.text').attr('value').replace(/^\s*|\s*$/g,"");
            AjaxServices.rename(currentName, 'bag', newName, function(result) {
                if (result.indexOf("Invalid name") == 0) {
                    // invalid name
                    jQuery('#error_msg.errors').prepend(result).show();
                    jQuery('div.title div.form').hide();
                    jQuery('div.title h1').show();
                } else  if (result.indexOf("already exists") > -1 && result.indexOf("<i>") == 0) {
                    // name already exists
                    jQuery('#error_msg.errors').prepend(result.replace(/<\/?[^>]+>/gi, "")).show();
                    jQuery('div.title div.form').hide();
                    jQuery('div.title h1').show();
                } else {
                    // OK
                    if (currentName != result) { // we will need to redirect
                      var urlObj = jQuery(location);
                      var url = jQuery(location).attr('href');
                      // replace the list name in "bagName/name=" before next "&"
                      var a = url.indexOf("name=");
                      if (a > -1) {
                        var z = url.substring(a, url.length).indexOf("&");
                        // redirect
                        urlObj.attr('href', url.substring(0, a + 5) + result.replace(/ /g,"+") + url.substring(a + z, url.length));
                      } else {
                        a = url.indexOf("bagName=");
                        // redirect
                        urlObj.attr('href', url.substring(0, a + 8) + result.replace(/ /g,"+"));
                      }
                    } else { // no name change
                      jQuery('div.title div.form').hide();
                      jQuery('div.title h1').show();
                    }
                }
            });
          }
          jQuery('div.title input.save').click(function() {
            saveName();
          });
          jQuery('div.title input.text').bind('keyup', function(e) {
            if((e.keyCode ? e.keyCode : e.which) == 13) {
              saveName();
            }
          });
        })();
      </script>
  
  