Refactored client javascript, now working with jQuery