From http://stackoverflow.com/questions/498970/how-do-i-trim-a-string-in-javascript