Adapted the code to support jquery >= 1.9

$.browser is deprecated.