added a condition to reinitialize timepicker if there is no mainDiv on the page. Timepicker should reinitialize if
dpDiv is removed. Otherwise it does not function correctly with for
example Rails applications with TurboLinks.