Javascript Rework

Modified the javascript to use a closed namespace for all functions on
the main page; variables and functions are now primarily cached.