Use jQuery's trim and inArray so it works in IE8. Fixes #226