Use native javascript trim() when available

Instead of always using a regex replace, it will use the native trim
function when available. This results in increased performance on every
system with trim() implemented (Firefox 3.5+, Opera 11+, Safari 5+, Chrome
10+, Internet Explorer 9+).

Benchmarks: http://jsperf.com/wds1/10