Restructures scripts

Structures script to be attached to a controller and enables jQuery for
use in Ajax.