Converting tabs to spaces
Performing indentation so that I could follow the codebase (thats a massive if block!)
Placing { on their own lines.
Using __DIR__ instead of .
1. BUGFIX - Adding <?php to wrap the final bracket! for the last else
2. various formatting changes
Formatting
 - placing braces on newlines
 - giving case statments braces just so easier to read
formatting changes
Changed the ajax call such that we pass in anonymous functions for readability.
yet more formatting changes