tidy a horrid javascript frame