Get the document to attach the datepicker dinamically.

...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)