// tabs - jQuery plugin for accessible, unobtrusive tabs by Klaus Hartl

// http://stilbuero.de/tabs/
$.tabs = function(containerId, start) {
  var ON_CLASS = 'active';
  var id = '#' + containerId;
  
  var i = (typeof start == "number") ? start - 1 : 0;
  // $(".left_bar").append("i:"+ i +" ");

  $(id + '>table').addClass('passive');
  
  // $(id + '>table:nth-of-type('+ i +')').removeClass('passive');
  $(id + '>table:eq('+ i +')').removeClass('passive');
  
  // $(id + '>.tabs>a:nth-of-type(' + i + ')').addClass(ON_CLASS);
  $(id + ' .tabs a:eq('+ i +')').addClass(ON_CLASS);
      
  $(id + '>.tabs>a').click(function() {
    if (!$(this).is('.' + ON_CLASS)) {
      var re = /([_\-\w]+$)/i;
      var target = $('#' + re.exec(this.href)[1]);
      if (target.size() > 0) {
        $(id + '>table:visible').addClass('passive');
        target.removeClass('passive');
        $(id + '>.tabs>a').removeClass(ON_CLASS);
        $(this).addClass(ON_CLASS);
      } else {
      }
    }
    return false;
  });
};

