converting the js to work with jquery 1.9