Reduce size/complexity by 100 lines

I've reduce complexity of event detection.
- Removes global variables such as isValid and queuedTag
- pushTag() function now just has one parameter, i.e. "the tag to push"
- Typeahead detection refactored into methods
- Add some utility methods to reduce duplicate code
- Fixes a bug in Chrome when Typeahead is active, "Enter" key did a double push of the typed value and the typeahead value.

This should make the code much more streamlined/maintainable.

I have tested this change on recent versions of Firefox, Chrome, Safari, MSIE 9 with Bootstrap 2.3.1 and Jquery 1.9.0. I tried to preserve as many of the legacy hacks as made sense, but found I could safely remove the "onBlur" method.

Due to the nature of this change, I've bundled it with several other pull requests.