(function($) {
  $.fn.myaccordion = function() {
    return this.each(function(n) {
    	// this is a dt -DN
    	// Set the id in the rel attribute on the dd -DN
    	$(this).next('.item').attr('rel', n);
    	// Open any panels (dd) that are marked as open -DN
    	/*$(this).next('.item.open').show();*/
    	// <dt> click function -DN
    	$(this).click(function() {
    		// Set background image on open dt to closed -DN
    		$('dt.open').removeClass('open');    		
    		// Set background image on dt to open -DN
    		$(this).addClass('open');
    		// Slide up the current open item -DN
    		if($('.item[rel="'+n+'"]').hasClass('open')) {
    			// If the clicked pane is already open, close it -DN
    			$('dt.open').removeClass('open');
    			$('dd.open').removeClass('open');
    			$('.item[rel="'+n+'"]').slideUp();
    			
    		}
    		else {
    			$('.item.open').slideUp().removeClass('open');
    			$('.item[rel="'+n+'"]').addClass('open').slideDown();	
    		}			
    	});
    });
  }
})(jQuery);
