code cleanup and tidying

all php database functions are now query_.
all javascript charting is years, months, days, full_day.
marked use of globals in most places i could find them.
moved jquery “ready” function into each page instead of in global js.