Moves javascript out of HTML.
Updates category tree with category ids.