I19: Restrict to delete category if any post attached to it

JS in template should be moved to a separate file.