/*
Published under GNU GPL2
Author Leonid "PhoeniX" Ponomarev
Edited by Vah aka Anton Bakhtin 
*/
$(document).ready(initCut);

var cut_settings={'more_text': 'Читать далее...', 'less_text': 'Свернуть'};

function initCut()
{
	$("div.pxpostwrap div.cut").each(function(){
		var alt=$(this).attr('alt');
		if (!alt) alt=cut_settings['more_text'];
		pc=$("P", this).size(); var pc_string="абзацев";
		if (pc>0){
			if (pc%10==2 || pc%10==3 || pc%10==4) pc_string="абзаца";
			if (pc%10==1) pc_string="абзац";
			// exceptions
			if (pc>=11 && pc<=14) pc_string="абзацев";
			alt=alt + " (" +pc + " " + pc_string + ")";
		}
		$(this).after("<div class=\"cut_toogle_text\" alt=\"" + alt + "\">" + alt + "</div>");
	});
	$("div.cut_toogle_text").toggle(
		function(){
			$(this).text("Загрузка...").prev().fadeIn("slow",
				function(){$(this).next().text(cut_settings['less_text']);}
			);
		},
		function(){
			$(this).prev().fadeOut("fast");
			$(this).text($(this).attr("alt"));
		}
	);
}
