/* John Resig - http://john.jquery.com */
$.fn.nextUntil = function(expr) {
   var match = [];

   // We need to figure out which elements to push onto the array
   this.each(function(){
       // Traverse through the sibling nodes
       for( var i = this.nextSibling; i; i = i.nextSibling ) {
           // Make sure that we're only dealing with elements
           if ( i.nodeType != 1 ) continue;

           // If we find a match then we need to stop
           if ( jQuery.filter( expr, [i] ).r.length ) break;

           // Otherwise, add it on to the stack
           match.push( i );
       }
   });

   return this.pushStack( match, arguments );
};
$.fn.wrapAll = function() {
   // There needs to be at least one matched element for this to work
   if ( !this.length ) return this;

   // Find the element that we're wrapping with
   var b = jQuery.clean(arguments)[0];

   // Make sure that its in the right position in the DOM
   this[0].parentNode.insertBefore( b, this[0] );

   // Find its lowest point
   while ( b.firstChild ) b = b.firstChild;

   // And add all the elements there
   return this.appendTo(b);
};



$(function(){
	var bulletinFilter = $('.mod-bulletinfilter');
	$('.outer',bulletinFilter).addClass("byissue");
	$('.tabs a',bulletinFilter).click(function(){
		$(this).parents("fieldset").removeClass("byissue").removeClass("bycategory").addClass($(this).attr("href").split('#')[1]);
		return false;
	});
	bulletinFilter.addClass("filter-js");
	
	var bulletinItem = $('.mod-bulletinitem');
	
	$('h3',bulletinItem).after('<p class="summarylink"><a href="#">Summary</a></p>');
	
	$('.summarylink',bulletinItem)
	.click(function(){
		$(this).parent('div').toggleClass('hidesummary');
		return false;
	});
	
	bulletinItem.addClass('hidesummary');
	
});

