			function DontClearOut(NotThisOne)
			{
				if (NotThisOne != "filterRef")
				{
					var tr = document.getElementById("filterRef");
					if (tr.value)
					{
						tr.value = "";
					}
				}
				if (NotThisOne != "filterTitle")
				{
					var tf = document.getElementById("filterTitle");
					if (tf.value)
					{
						tf.value = "";
					}
				}
				if (NotThisOne != "stateSelect")
				{
					var tt = document.getElementById("stateSelect");
					if (tt.value)
					{
						tt.value = "";
					}
				}
				if (NotThisOne != "filterArtist")
				{
					var ta = document.getElementById("filterArtist");
					if (ta.value)
					{
						ta.value = "";
					}
				}
			}

			function FilterTitle()
			{
				DontClearOut("filterTitle");
				
				var tf = document.getElementById("filterTitle");
				if (!tf.value)
				{
					// If the text field is empty, remove any filter
					// that is set on the data set.
			
					dsSurveys.filter(null);
					return;
				}
			
				// Set a filter on the data set that matches any row
				// that begins with the string in the text field.
			
				var regExpStr = tf.value;
				
				if (!document.getElementById("inTitle").checked)
					regExpStr = "^" + regExpStr;
			
				var regExp = new RegExp(regExpStr, "i");
				
				var filterFunc = function(ds, row, rowNumber)
				{
					var str = row["title"];
					if (str && str.search(regExp) != -1)
						return row;
					return null;
				};
			
				dsSurveys.filter(filterFunc);
			}
			
			function StartFilterTimer()
			{
				if (StartFilterTimer.timerID)
					clearTimeout(StartFilterTimer.timerID);
				StartFilterTimer.timerID = setTimeout(function() { StartFilterTimer.timerID = null; FilterTitle(); }, 100);
			}

			function FilterArtist()
			{
				DontClearOut("filterArtist");
				
				var ta = document.getElementById("filterArtist");
				if (!ta.value)
				{
					// If the text field is empty, remove any filter
					// that is set on the data set.
			
					dsSurveys.filter(null);
					return;
				}
			
				// Set a filter on the data set that matches any row
				// that begins with the string in the text field.
			
				var regExpStr = ta.value;
				
				if (!document.getElementById("inArtist").checked)
					regExpStr = "^" + regExpStr;
			
				var regExp = new RegExp(regExpStr, "i");
				
				var filterFunc = function(ds, row, rowNumber)
				{
					var str = row["artist"];
					if (str && str.search(regExp) != -1)
						return row;
					return null;
				};
			
				dsSurveys.filter(filterFunc);
			}
			
			function StartFilterTimerArtist()
			{
				if (StartFilterTimerArtist.timerID)
					clearTimeout(StartFilterTimerArtist.timerID);
				StartFilterTimerArtist.timerID = setTimeout(function() { StartFilterTimerArtist.timerID = null; FilterArtist(); }, 100);
			}

			function FilterRef()
			{
				DontClearOut("filterRef");
				
				var tr = document.getElementById("filterRef");
				if (!tr.value)
				{
					// If the text field is empty, remove any filter
					// that is set on the data set.
			
					dsSurveys.filter(null);
					return;
				}
			
				// Set a filter on the data set that matches any row
				// that begins with the string in the text field.
			
				var regExpStr = tr.value;
				regExpStr = "^" + regExpStr;
				
				var regExp = new RegExp(regExpStr, "i");
				
				var filterFunc = function(ds, row, rowNumber)
				{
					var str = row["ref"];
					if (str && str.search(regExp) != -1)
						return row;
					return null;
				};
			
				dsSurveys.filter(filterFunc);
			}
			
			function StartFilterTimerRef()
			{
				if (StartFilterTimerRef.timerID)
					clearTimeout(StartFilterTimerRef.timerID);
				StartFilterTimerRef.timerID = setTimeout(function() { StartFilterTimerRef.timerID = null; FilterRef(); }, 100);
			}

			function FilterTown()
			{
				DontClearOut("stateSelect");
				
				var tt = document.getElementById("stateSelect");

				var regExpStr = tt.value;
				
				var regExp = new RegExp(regExpStr, "i");
				
				var filterFunc = function(ds, row, rowNumber)
				{
					var str = row["town"];
					if (str && str.search(regExp) != -1)
						return row;
					return null;
				};
			
				dsSurveys.filter(filterFunc);
			}
			
			function NewSurvey()
			{
				document.frmNew.submit();
			}
			
			function ShowAll()
			{
				document.frmShowAll.submit();
			}
