function trim(str) {
//Remove all spaces from a string and return a new string
  var newstr;
  newstr = str.replace(/^\s*/, "").replace(/\s*$/, ""); 
  newstr = newstr.replace(/\s{2,}/, " "); 
  return newstr;
} 

function setQueryMethod(frm) {

//The form on the front page could be done by mlsNumber or address
//Set the search type appropriately

//First, clean up the listing number
frm.listingNumber.value = trim(frm.listingNumber.value);

if (frm.listingNumber.value.length > 0) {
    frm.method.value = "searchByMLSNum";
    }
else {
    frm.method.value = "searchByAddress";
    }
return true;
}
