Jshint compliance 9927

This branch is simply javascript refactoring (no new functionality). 

A couple more files are now jsHint-compliant.
But lots of our js code is not validated by jsHint since it's within html pages.

I've also tried to remove all global variables, putting them under the 'OME' namespace. 
There's some testing code at the bottom of ome.popup.js which prints all global variables to console.log. This is commented out by default.

**Best to have console visible - E.g. via Firebug**

To test, basically check that all javascript works:
 - webadmin: change group permissions to 'private' & confirm (group owner edit and Admin edit)
 - webclient: multi-select in tree (shift/ctrl clicks). 
 - Selection changes update right & center panels (for P/D/I, Tags & Public pages).
 - Delete image - center panel & tree updates as expected. Activities notification.
 - Add to basket. Visit basket - check table selection (click or drag). Create share, edit share.
 - Selection changes in wells, open Image by double-click
 - Pagination controls (in Datasets > 200 images)
 - Double-click to open Image, open from Preview panel etc.
 - Run script (E.g. Channel Offsets). Check script progress & result panel, open new image from there etc. View 'info'
 - Create new P/D, remove D/I.
 - Check selection in center table of History page by click/drag (choose a day of activity in calendar first)
 - Same for Search page (with search results in center panel)
 - Drag to change size of left and right main panels, expand & collapse
 - Add & remove Tag