;( function( $ ) {

	$.fn.extend( {
		collapse: function()
		{
			return $( this ).each( function()
			{
				// Link mit Toggle ausstatten
				$( this ).find( 'a' ).eq( 0 ).bind( 'click', toggle ).click();
			} );
		}
	} );
	
	function toggle( event )
	{
		event.preventDefault();
		// Toggle für die 'active' Eigenschaft des Buttons und des Feldes
		var $img = $( this ).find( 'img' ).eq( 0 );
		var $sectionBody = $( this ).parent().next();
		if ( $img.attr( 'class' ).indexOf( 'active' ) > 0 )
		{
			$img.removeClass( 'active' );
			$sectionBody.css( 'display', 'block' );
		}
		else
		{
			$img.addClass( 'active' );
			$sectionBody.css( 'display', 'none' );
		}
	}
	
} )( jQuery );
