Convert script to jQuery