function initSpoilers(context)
{
	$('div.sp-body', context).each(function(){
		var $sp_body = $(this);
		var name = this.title || 'скрытый текст';
		this.title = '';
		$('<div class="sp-head folded clickable">'+ name +'</div>').insertBefore($sp_body).click(function(e){
			if (!$sp_body.hasClass('inited')) {
				$sp_body.prepend('<div class="clear"></div>').append('<div class="clear"></div>').addClass('inited');
			}
			if (e.shiftKey) {
				e.stopPropagation();
				e.shiftKey = false;
				var fold = $(this).hasClass('unfolded');
				$('div.sp-head', $($sp_body.parents('td')[0])).filter( function(){ return $(this).hasClass('unfolded') ? fold : !fold } ).click();
			}
			else {
				$(this).toggleClass('unfolded');
				$sp_body.slideToggle('fast');
			}
		});
	});
}

$(function(){
	$('div.postcolor, span.postcolor').each(function(){ initSpoilers( $(this) ) });
});
