$('.hornet.dialog div.tabs').concrete({
  onmatch: function() {
    var $tabs = $(this).tabs({
      cache: true,
      add: function(event, ui) {
          $tabs.tabs('select', '#' + ui.panel.id);
      },
      tabTemplate: '<li><a href="#{href}"><span>#{label}</span></a><a href="#" class="close">x</a></li>'
    });
  }
});

$('.hornet.dialog div.tabs a.close').concrete({
  onclick: function() {
    // Get the index for the tab being closed
    index = $('div.tabs ul li').index($(this).parent('li'));
    // Select the first tab
    $('.hornet.dialog div.tabs').tabs('select', 0);
    // Remove the tab
    $('.hornet.dialog div.tabs').tabs('remove', index);
    return false;
  }
});