Fixed errant if in liquid tag.
Segregated insane clusterfuck of javascript to appropriate file.