first pass at moving all JS/ajax stuff out of core into templates
basic legacy JS-based template functionality