$(document).ready(function() {
$("#sidebar-tabs").show();
   // first, we select the sidebar
   $('#sidebar-tabs .tabs-are-here').each(function() {
      // each child of the sidebar element will be a widget, and will become a tab
      var widgets = $(this).children();
 
      // we'll build the list of titles, starting with the opening tag
      var titleList = '<ul id="tab-names">';
 
      //for each widget in the sidebar:
      widgets.each(function() {
 
         // save the title of the widget
         var widgetTitle = $(this).children(".widget-body").children('h2').text();
         //var widgetSubTitle = $(this).find('.post-title').text();

         // then hide it since it will be displayed in the tab
         if($(this).is(".widget_gigpress")) {
         $(this).children(".widget-body").children('h2').replaceWith('<a class="post-title">See the Boys Live!</a>');
         }
         else{
         	$(this).children(".widget-body").children('h2').hide();
 		 }
         // create a new list item for the tab, linking to this widget's id
         var listItem = '<li><a class="tab-title" href="#'+$(this).attr('id')+'">'+widgetTitle+'</a></li>';
         //<span class="tab-subtitle">'+widgetSubTitle+'</span>
         // add the list item to the list we're building
         titleList += listItem;
      });
      // close the list now that we're done going through each widget
      titleList += '</ul>';
 
      // add the title list to the beginning of the sidebar
      $(this).before(titleList);
   });
 
   // apply the tabs plugin
   $('#sidebar-tabs').tabs({ fx: { opacity: 'toggle' } }).tabs('rotate', 5000);
});


