Refactored the JavaScript to be mostly external, no longer inline. There is still some inline javascript where appropriate (eg, for individual panels)
Small refactor to better conform to coding convention