Rejig `graph.php` into functions rather than within case statement
and replace multiple print commands with raw HTML output instead as
well as fixed up some HTML formatting and errors
Also fix issues with layout.js and bottom_footer.php to remove extra
footer info that shouldn't be output during ajax calls.