fix ie8
Merge pull request #1 from tokki/master

Port JS to IE8.