// JavaScript Document
jQuery.fn.litree = function(options){
	var options = jQuery.extend({
		speed: 200, // Скорость анимации
		classActive: '.cur' // Класс активного элемента
	},options);
	return this.each(function() {
		//menu_tree
	litree = jQuery(this)	
	
	jQuery(litree).find('.p_1_wrap').children('ul').addClass('tree_parent').css({display:'block'})
	jQuery(litree).find('li:not(".p_1_wrap")').prepend('<span></span>')
	jQuery(litree).find(options.classActive).parents('ul').show() //открываем активный пункт
	jQuery(litree).find('ul').parent('li:not(".p_1_wrap")').addClass('tree_full') //метим списки, которые содержат подгруппы
	jQuery(litree).find('ul:visible').parent('li:not(".p_1_wrap")').addClass('tree_minus') //ставим маркер "минус" для открытых списков
	jQuery(litree).find('ul:hidden').parent('li:not(".p_1_wrap")').addClass('tree_plus') //ставим маркер "плюс" для закрытых списков
	jQuery(litree).find('.tree_full>span')
		.click(function(){  
			jQuery(this).parent().children('ul') 
				.slideToggle(options.speed,function(){  // по клику переключаем состояние вложеных списков		
						jQuery('.tree_parent').find('ul:visible').parent('li:not(".p_1_wrap")').removeClass('tree_plus').addClass('tree_minus')
						jQuery('.tree_parent').find('ul:hidden').parent('li:not(".p_1_wrap")').removeClass('tree_minus').addClass('tree_plus').find('ul').hide() //закрываем все списки внутри закрытого списка
						})
		height()
		return false
		})
		
		//coll height
		function height(){
		jQuery('.coll_h').height('auto')
		var h1 = $('#coll_1').height();
		var h2 = $('#coll_2').height();
		var h3 = $('#coll_3').height();
		var h4 = h1
		if(h4 < h2){h4 = h2}
		if(h4 < h3){h4 = h3}
		jQuery('.coll_h').animate({height:h4})
		}
	height()
	});
};
