Cleaned up the test page a bit, and added some basic styles to make this start to look like a slide deck.
The javascript code looks like a "sieve"

I sincerely prefer this coding style. You just sieve out invalid
inputs, then do the code assuming it is valid.

We avoid nested if loops, and it is easier to put a new condition
check on the input.
Merging updated upstream by Pat with my changes