Get dinamically the document to attach the datepicker to.

...when possible).

Added faster way to get the left and top positions to show the calendar. (Solves problem when the field is inside a div with vertical scroll)