Added trim() method to support IE (which doesn't have string.trim())