JS cleanup (replace document.all and declare variables in timeline.php)

* Feature detection allows modern browsers to take a common code path instead of assuming that all IE doesn't support certain features.
* Declaring variables inside functions prevents them from being declared on the global (window) and polluting that space.