I wrote a datepicker in Javascript, but it is not working properly, as I lose the reference to the Calendar object.