

/* Helper functions to extend string handling */

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}


/*
 * process and validate the basicSearchForm.
 *
 * This  basicSearchForm is located in the g_basicSearchBox.pbo macro -
 *
 *  This is a stripped down version of the code that converts
 *  the user supplied keyword which is in a field called "txtSearch"
 *   to the FAST format, and then puts this into a hidden field called
 *   "txtSearchFastFormatted"
 */ 
function validateBasicSearch(response)  {
 
  var arrSearchTerms = [];


  // code to strip leading and trailing spaces before split
  
  var srch = document.basicSearchForm.txtSearch.value.trim();
  if (srch)	
  {
    srch = srch.replace(/\s+/g,' ');
    arrSearchTerms = srch.split(' ');
	
    //Can do And or Or searches.  We'll default to And.
    document.basicSearchForm.txtSearchFastFormatted.value ="xml#"+arrSearchTerms.join(' and xml#');
  }
  else
  {
  alert("???? no search term supplied");
  return false;
  }
	
return true;
	
}

