Index: /main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js	(revision 30168)
+++ /main/trunk/greenstone3/web/interfaces/default/js/document_scripts.js	(revision 30169)
@@ -1,3 +1,11 @@
 var _imageZoomEnabled = false;
+// Choose which types of filtering you want: sectionnum, or sectiontitle.
+var _filter_on_types = ["sectiontitle", "sectionnum"];
+// the text strings for the two radio buttons
+var _filter_on_num_text = "pagenum";
+var _filter_on_title_text = "title";
+// are titles numeric match?
+var _filter_title_numeric = false;
+
 var _linkCellMap = new Array();
 var _onCells = new Array();
@@ -674,4 +682,5 @@
 }
 
+
 function SliderWidget(_links)
 {
@@ -711,73 +720,114 @@
 	//PRIVATE FUNCTIONS
 	//*****************
-	
-	var setUpFilterBox = function()
-	{
-		var filter = $("#filterText");
-		filter.keyup(function()
-		{
-			var fullValue = filter.val();
-			var values = fullValue.split(",");
+
+	//  _filter_on_types can be "sectionnum", "sectiontitle"
+ var setUpFilterButtons = function() {
+
+  var button_div = $("#filterOnButtons");
+  button_div.onclick = doFiltering;
+  button_div.html("radio");
+  if (_filter_on_types.length == 0) {
+    _filter_on_types = ["sectionnum", "sectiontitle"];
+  }
+  else if (_filter_on_types.length == 1) {
+    if (_filter_on_types[0] == "sectionnum") {
+      button_div.html("(<input type='radio' name='filterOn' value='num' checked>"+_filter_on_num_text+"</input>)");
+    } else {
+      button_div.html("(<input type='radio' name='filterOn' value='title' checked>"+_filter_on_title_text+"</input>)");
+    }
+  } else {
+    // should be both options
+    button_div.html("<input type='radio' name='filterOn' value='num' checked>"+_filter_on_num_text+"</input><input type='radio' name='filterOn' value='title'>"+_filter_on_title_text+"</input>");
+  }
+}
+
+	var doFiltering = function () {
+  if (typeof _titles == "undefined") {
+    return;
+  }
+
+  var filter_string = $("#filterText").val();
+  var filter_type = $('input[name="filterOn"]:checked').val();
+  
+  var index = 2; // section num
+  var numeric_match = true;
+  if (filter_type == "title") {
+    index = 3;
+    if (_filter_title_numeric != true) {
+      numeric_match = false;
+    }
+      
+  }
+  var values = filter_string.split(",");
 			
-			var matchingTitles = new Array();
-			
-			for (var l = 0; l < values.length; l++)
-			{
-				var currentValue = values[l].replace(/^ +/g, "").replace(/ +$/g, "");
-				var isRange = (currentValue.search(/\d+-\d+/) != -1)
-				
-				var found = false;
-				for(var i = 0; i < _titles.length; i++)
-				{
-					if(_titles[i][0] == currentValue)
-					{
-						found = true;
-					}
-				}
-				
-				if(!found && isRange)
-				{
-					var firstNumber = currentValue.replace(/(\d+)-\d+/, "$1");
-					var secondNumber = currentValue.replace(/\d+-(\d+)/, "$1");
-					
-					if(firstNumber <= secondNumber)
-					{
-						for(var i = firstNumber; i <= secondNumber; i++)
-						{
-							var numString = i + "";
-							for(var j = 0; j < _titles.length; j++)
-							{
-								var currentTitle = _titles[j];
-								if(currentTitle[0].search(numString) != -1)
-								{
-									matchingTitles.push(currentTitle);
-								}
-							}
-						}
-					}
-				}
-				else
-				{
-					for(var i = 0; i < _titles.length; i++)
-					{
-						var currentTitle = _titles[i];
-						if(currentTitle[0].search(currentValue.replace(/\./g, "\\.")) != -1)
-						{
-							matchingTitles.push(currentTitle);
-						}
-					}
-				}
-			}
-			
-			for(var i = 0; i < _titles.length; i++)
-			{
-				$(_titles[i][1].cell).css("display", "none");
-			}
-			
-			for(var i = 0; i < matchingTitles.length; i++)
-			{
-				$(matchingTitles[i][1].cell).css("display", "table-cell");
-			}
-		});
+  var matchingTitles = new Array();
+  
+  for (var l = 0; l < values.length; l++)
+    {
+      var currentValue = values[l].replace(/^ +/g, "").replace(/ +$/g, "");
+      if (numeric_match) {
+	var isRange = (currentValue.search(/\d+-\d+/) != -1);
+	if (isRange) {
+	  var firstNumber = currentValue.replace(/(\d+)-\d+/, "$1");
+	  var secondNumber = currentValue.replace(/\d+-(\d+)/, "$1");
+	  
+	  if(firstNumber <= secondNumber)
+	    {
+	      for(var i = firstNumber; i <= secondNumber; i++)
+		{
+		  var numString = i + "";
+		  for(var j = 0; j < _titles.length; j++) {
+		    
+		    var currentTitle = _titles[j];
+		    if(currentTitle[index] == numString) {
+		      matchingTitles.push(currentTitle);
+		    }
+		  }
+		}
+	    }
+	} // if isRange
+	else {
+	  for(var j = 0; j < _titles.length; j++) {
+	    if (_titles[j][index]==currentValue) {
+	      matchingTitles.push(_titles[j]);
+	    }
+	  }
+
+	}
+	
+      } else { // not numeric match.
+	// need to do a search
+	  for(var i = 0; i < _titles.length; i++)
+	    {
+	      var currentTitle = _titles[i];
+	      if(currentTitle[index].toLowerCase().search(currentValue.toLowerCase().replace(/\./g, "\\.")) != -1)
+		{
+		  matchingTitles.push(currentTitle);
+		}
+	    }
+      }
+    } // for each value from filter string
+  
+  // set all to hide...
+  for(var i = 0; i < _titles.length; i++)
+    {
+      $(_titles[i][1].cell).css("display", "none");
+    }
+  
+  // .. then display the matching ones
+  for(var i = 0; i < matchingTitles.length; i++)
+    {
+      $(matchingTitles[i][1].cell).css("display", "table-cell");
+    }
+}
+
+	var setUpFilterBox = function() 
+	{
+	  var filter = $("#filterText");
+	  
+	 filter.keyup(function() 
+	{
+	  doFiltering();
+	});
 	}
 	
@@ -946,14 +996,17 @@
 
 		var title = $(_links[i]).html();
-		if(title.search(/^[^ ]+ [^ ]+$/) != -1)
-		{
-			var section = title.replace(/^([^ ]+) [^ ]+$/, "$1");
-			var page = title.replace(/^[^ ]+ ([^ ]+)$/, "$1");
-			if(page.search(/^[0-9]+$/) != -1)
-			{
-				title = page;
-			}
-		}
-		_titles.push([title, _links[i]]);
+		var t_section = "";
+		var t_title = "";
+		if (title.search(/tocSectionNumber/) != -1)
+		  {
+		    var matching_regex = /<span class=\"tocSectionNumber\">([0-9]+)<\/span>\s*(.+)$/; 
+		    var matches_array = matching_regex.exec(title);
+		    if (matches_array.length == 3) {
+		      t_section = matches_array[1];
+		      t_title = matches_array[2];
+		      }
+		  }
+		
+		_titles.push([title, _links[i], t_section, t_title]);
 
 		col.append($("<br>"));
@@ -962,6 +1015,7 @@
 
 	setUpFilterBox();
+	setUpFilterButtons();
 	startCheckFunction();
-}
+	}
 
 /***********************
Index: /main/trunk/greenstone3/web/interfaces/default/transform/layouts/toc.xsl
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/transform/layouts/toc.xsl	(revision 30168)
+++ /main/trunk/greenstone3/web/interfaces/default/transform/layouts/toc.xsl	(revision 30169)
@@ -89,4 +89,5 @@
 										{
 											retrieveTableOfContentsAndTitles();
+										        <!--setUpFilterButtons();-->
 										});
 									</xsl:text>
@@ -96,11 +97,16 @@
 									<img src="{util:getInterfaceText($interface_name, /page/@lang, 'loading_image')}"/><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.loading')"/><xsl:text>...</xsl:text>
 								</div>
-								<table style="width:100%;"><tbody><tr>
-									<td><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.filter_pages')"/><xsl:text>: </xsl:text><input id="filterText" type="text" size="27"/></td>
+								<label for="filterText"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.filter_pages')"/><xsl:text>: </xsl:text></label><span id="filterOnButtons" style="float: right;">xx</span><input id="filterText" type="text" style="width: 100%;"/>
+								<xsl:if test="/page/pageRequest/userInformation and /page/pageRequest/userInformation/@editEnabled = 'true'">
+								  <a href="javascript:extractFilteredPagesToOwnDocument();"><button id="extractDocButton">Extract these pages to document</button></a>
+								</xsl:if>
+								  
+							<!--	<table style="width:100%;"><tbody><tr>
+									<td><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.filter_pages')"/><xsl:text>: </xsl:text><input id="filterText" type="text"/></td>
 								</tr>
 								<xsl:if test="/page/pageRequest/userInformation and /page/pageRequest/userInformation/@editEnabled = 'true'">
 									<tr><td><a href="javascript:extractFilteredPagesToOwnDocument();"><button id="extractDocButton">Extract these pages to document</button></a></td></tr>
 								</xsl:if>
-								</tbody></table>
+								</tbody></table>-->
 							</xsl:when>
 							<xsl:when test="not(/page/pageRequest/paramList/param[@name = 'ed']/@value = '1')">
@@ -202,8 +208,5 @@
 					<a id="toclink{@nodeID}" href="javascript:focusSection('{@nodeID}');">
 						<xsl:if test="util:hashToSectionId(@nodeID)">
-							<xsl:value-of select="util:hashToSectionId(@nodeID)"/>
-							<xsl:text> </xsl:text>
-						</xsl:if>
-						<xsl:call-template name="sectionHeading"/>
+						  <span class="tocSectionNumber"><xsl:value-of select="util:hashToSectionId(@nodeID)"/><!--<xsl:text> </xsl:text>--></span></xsl:if><xsl:call-template name="sectionHeading"/>
 					</a>
 				</td>
