IE 7 and dialog tab/focus handling

IE 7 and dialog tab/focus handling

I believe there is a bug in how ui dialog keeps focus in the dialog. This version 1.7.2.
I have not checked if it is fixed in newer versions. I need the most stable release at this point.

It uses keypress to handle the tab key but IE7 doesn't give tab to keypress.
I changed it to use keydown as so:

  // prevent tabbing out of modal dialogs
  (options.modal && uiDialog.bind('keypress.ui-dialog', function(event) {

and a corresponding change in the close method.

I made two other minor changes.

When tab on the first or last focusable is detected the focus call is wrapped in a setTimeout.
However initial dialog focus is not set in a setTimeout. In addition the normal behavior for
a text input when it receives focus is to select the contents of the text. I changed the
code as follows:

  // set focus to the first tabbable element in the content area or the first button
  // if there are no tabbable elements, set focus on the dialog itself
    .add(uiDialog.find('.ui-dialog-content :tabbable:first'))
    .add(uiDialog.find('.ui-dialog-buttonpane :tabbable:first'))
    .each(function() {
      var self = this;
      setTimeout(function() {
        if (self.nodeName == "INPUT" && self.type == "text") {
      }, 1);