Add MIT license header.
Fix code path for selectionStart == 0.
Merge pull request #5 from schulzch/master

Fix bad browser switch + License header