Refactored trim() to adhere with standards
IE6 doesn't have a short syntax for string indexing
Test indexOf on null, not undefined.