Changing String#trim calls to jQuery#trim so that it can works on IE 8
merge with IE 8 compliant code