Better javascript in plan.js and fixed some bugs.

- Removed global variables
- Restricting of date ranges didn't take years into account (choosing a
  different year wasn't reflected).
- There was no event listener for changes on a day.
- TypeError: Object has no method 'contains'
Style/formatting fix. Move error message after legend
Remove type="number" from datepicker inputs.

There is a bug in patters which causes an event listener on an input of
type="number" to be called repeatedly (and somewhere, on each iteration the
value of that input is incremented by one).

We need listeners on those inputs in order to update the restricted date ranges
when one date changes.