Moving JS to a template.

Also moved viewing of alerts to alerts.php.