function formatSearchString(searchString) {
  // Remove all the non-alphanum char
  //nonAlphanumChars = /[^a-zA-Z0-9??????????????????'"]/ig;
  nonAlphanumChars = /[^a-zA-Z0-9"]/ig;
  searchString= searchString.replace(nonAlphanumChars ," ");

  // Remove accents
  searchString= removeAccents(searchString);

  // Just 1 space between words
  spaces = /[ ]+/ig;
  searchString= searchString.replace(spaces ," ");

  // Trim the string
  searchString = jQuery.trim(searchString);

  // Encode it so it can be use in the URL
  searchString = encodeURIComponent(searchString );

  return searchString;
}

function runSearch(searchFieldId, searchFormId) {
  var srchStr = formatSearchString($('#'+searchFieldId).val());

  if(srchStr=='')
    $('#'+searchFormId).attr('action', '/bourse/ebtv/recherche/');
  else
    $('#'+searchFormId).attr('action', '/bourse/ebtv/recherche/'+srchStr+'/1/');

  $('#'+searchFormId).submit();
}

function removeAccents(str) {
   temp = str.replace(/[???]/gi,"a")
   temp = temp.replace(/[????]/gi,"e")
   temp = temp.replace(/[??]/gi,"i")
   temp = temp.replace(/[??]/gi,"o")
   temp = temp.replace(/[???]/gi,"u")

   return temp
}
