(function ($) {
  var t;
  var hoverintent;
  var $hoveredon;
  
  Drupal.behaviors.u_business = {
    attach: function(context) {
      $('#block-system-main-menu li.level-1').hover(function() {
        clearTimeout(t);
        $hoveredon = $(this);
        hoverintent = setTimeout(function() {
          if (!$hoveredon.hasClass('leaf')) {
            $('#animation-spacer').animate({"height":"33px"}, 100);
            $hoveredon.find('ul.menu').show(100);
          }
          if (!$hoveredon.hasClass('leaf')) {
            clearTimeout(t);
          }        
        }, 200);
      }, function() {
        clearTimeout(hoverintent);
        $(this).find('ul.menu').hide();
        t=setTimeout("jQuery('#animation-spacer').animate({'height': 0}, 200);",300);
      });
    
      // convert topic hub stuff to tabs...
      $i = 0;
      $('#topic-hub .panel-panel .inside').each(function () {
        // for each .inside we find, go look for an h2.pane-title
        $col = $(this).find('h2.pane-title');
        if ($col.size() > 1) {
          $i = $i + 1;
          // we have a collection inside a single pane
          // that we need to convert to tabs
          $(this).prepend('<ul class="tabrow"></ul>');
          $(this).parent().attr('id', 'tabs-pane-'+$i);
          $j = 0;
          $col.each(function() {
            // put id's onto the inner panes
            $j = $j + 1;
            $(this).parent().attr('id', 'tab-region-'+$i+'-'+$j);
            // copy the title into the top tab
            $('#tabs-pane-'+$i+ ' ul.tabrow').append('<li><a href="#tab-region-'+$i+'-'+$j+'">'+$(this).html()+'</a></li>');
            // hide the h2 that's normally there
            $(this).hide();
          });
        
        
          // make it into tabs, baby!
          $('#tabs-pane-'+$i).tabs();
        }
      });
      
      $('#user-register-form #edit-submit').click(function () {
        if($("input[name=subscribe_print]:checked").val()) {
          return true;  // go ahead and let them submit
        }
        else {
          alert('Please choose a magazine subscription option from the upper right area of this form before submitting.');
          return false;
        }
      });
    }
  };
}(jQuery));
;

