$(document).ready(function(){
	$('.accordion').each(function(){
		$(this).addClass('accordion_border');
		$header = $(':header:first', this);	
		$header.addClass('accordion_handle').addClass('accordion_handle_closed');
		
		followingContentWidth = $('.accordion_handle', this).siblings().width();
		$('.accordion_handle', this).siblings().wrapAll('<div class="accordion_content" style="width:'+followingContentWidth+'px;"></div>');	
		
		if($(this).find('.accordion_content').length<1){
			$header.removeClass('accordion_handle_opened').removeClass('accordion_handle_closed');
		}
		else{
			$(this).find('.accordion_handle').toggle(function(){
			$(this).parent().find('.accordion_content').slideDown('slow');
			$(this).removeClass('accordion_handle_closed').addClass('accordion_handle_opened');
			
			},function(){
				$(this).parent().find('.accordion_content').slideUp('slow');
				$(this).removeClass('accordion_handle_opened').addClass('accordion_handle_closed');
			});
		}
		
		
		
		$(this).siblings('.accordion + .accordion').css('margin-top','-1px');
	});
});
