advagg drupal module breaking my js file
You do not need to add document.ready to a behavior.
Read about drupal behaviors HERE or at a good blog post HERE.
Basically I think Drupal adds a document.ready which calls all the behaviors. The behaviors are also called after an ajax call is returned (sending the new content returned by the ajax to the behaviors via the context variable). Which is why we use the context variable in the jquery selector.
Your javascript should probably look like this.  

(function ($) {
  Drupal.behaviors.myfunction = {
    attach: function (context, settings) {
      $('#gl_img_datepicker', context).datepicker({
        onSelect: function(dateText, inst) {
          alert(dateText);
        }
      });
    }
  };
})(jQuery);