function trim(string) 
{ 
  return string.replace(/(^\s+)|(\s+$)/g, "");
} 

function do__search(submit, baseUrl) {

  var searchText = document.getElementById('search_text');
  var searchForm = document.getElementById('search_form');

  if (searchText.value == "") {
    searchText.focus();
    alert('Please enter search text');
    if (submit)
      return false;
  } else {
    var searchValue = trim(searchText.value.replace(/[^A-Za-z0-9 +-]/g, ""));
    searchValue = searchValue.replace(/[\s]+/g, " ");
    searchText.value = searchValue;
    searchValue = searchValue.replace(/[\s]/g, "/");
    searchValue = searchValue.toLowerCase();
    window.location.href = baseUrl + "results/"+searchValue;
    return false;
    /*if (submit)
	return true;
    else
	searchForm.submit();
    */
  }

}


function addBookmark(url, title) {
 if (!url) url = location.href;
 if (!title) title = document.title;

 //Gecko
 if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) window.sidebar.addPanel (title, url, "");
 //IE4+
 else if (typeof window.external == "object") window.external.AddFavorite(url, title);
 //Opera7+
 else if (window.opera && document.createElement)
 {
 var a = document.createElement('A');
 if (!a) return false; //IF Opera 6
 a.setAttribute('rel','sidebar');
 a.setAttribute('href',url);
 a.setAttribute('title',title);
 a.click();
 }
 else return false;

 return true;
}
