Replace indexOf polyfill with a simpler version which does not crash IE7/8

cc @tobscher @asmega