JS 'date is undefined' exception happens when you change the date on the calendar (i.e. click 'Prev' or 'Next'). I think it's just legacy code that is causing the exception, so I removed it.