replaced indexOf with jQuery.inArray, as indexof is not compatible with IE < 9