/*
Removes leading and trailing spaces from the passed string.
Also removes consecutive spaces and replaces it with one space.
*/
function Trim(s)
{
    var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
    return (m == null) ? "" : m[1];
}