What a fucking mess that JS is, but it works!

Will need serious refactoring to allow a template-driven site, but it is
beginning to function very well.