Need this for another fix and there is no such jQuery function. As this
seems to also be inconsistant across browsers I thought this would
definitively be worth a custom jQuery plugin.
It's quite tricky to get this working. Still not perfect, but works
as expected. Also added Function.bind and Array.indexOf - absence of
both used to cause JS errors.
refs #6417