Reformatted all templates, externalised most javascript

Made minor changes and corrections in the markup, but most changes are whitespace.
Added warning when deleting directories with files