More clever use of resampling. Add jQuery for simplicity.
Factor out client JS code.