
$(document).ready(function(){
	$(".kategory_body").hide();
	$("#sel").parents(".kategory_body").show();
//	$("#sel").parents(".kategory_head").attr("class","kategory_head_selected");
	$(".kategory_head").each(function(){
	if($(this).next().find("#sel").length) $(this).attr("class","kategory_head_selected");
	});
	//find_parent($("#sel"));
	$(".kategory_head").toggle(
		  function () {
		    $(this).attr("class","kategory_head_selected");	    
		  },
		  function () {
		    $(this).attr("class","kategory_head");	 
		  }
		);
		$(".kategory_head_selected").toggle(
		  function () {
		    $(this).attr("class","kategory_head");	    
		  },
		  function () {
		    $(this).attr("class","kategory_head_selected");	 
		  }
		);
	
	$(".kategory_head").click(function(){
		$(this).next(".kategory_body").slideToggle(300)
		return false;
	});
	$(".kategory_head_selected").click(function(){
		$(this).next(".kategory_body").slideToggle(300)
		return false;
	});
	
	$(".pod_kategory_head").click(function(){
		$(this).next(".kategory_body").slideToggle(300)
		return false;
	});

	//collapse all messages
	$(".collpase_all_message").click(function(){
		$(".kategory_body").slideUp(500)
		return false;
	});

	//show all messages
	$(".show_all_message").click(function(){
		$(this).hide()
		$(".show_recent_only").show()
		$(".message_list li:gt(4)").slideDown()
		return false;
	});

	//show recent messages only
	$(".show_recent_only").click(function(){
		$(this).hide()
		$(".show_all_message").show()
		$(".message_list li:gt(4)").slideUp()
		return false;
	});
// $("#raz").show();
	$("#gallery a").lightbox();
    $.Lightbox.construct({
    	"speed": 500,
    	"show_linkback": true,
    	"keys": {
			close:	"q",
			prev:	"z",
			next:	"x"
		},
		"opacity": 0.3,
		text: {
			image:		"Картинка",
			of:			"из",
			close:		"",
			closeInfo:	"",
			help: {
				close:		"",
				interact:	""
			},
			about: {
				text: 	"",
				title:	".",
				link:	""
			}
		},
		files: {
			images: {
				prev:		'lightbox_img/prev.gif',
				next:		'lightbox_img/next.gif',
				blank:		'lightbox_img/blank.gif',
				loading:	'lightbox_img/loading.gif'
			}
		}
    });	
});
function find_parent(my){
	alert(my.parent(":first").parent(":first").prev(":first").attr("class"));
	parent_p=my.parent().parent().prev();
/*
	var class_name=parent_p.attr("class");
	if(class_name=="kategory_head"){
		parent_p.attr("class","kategory_head_selected");
		return false;
	}
	else{
	find_parent(parent_p);
	return false;
	}
*/	
}
