var KB_TREE = function ( address_project , address_short , cur_ppid ) {
	this.address_project = address_project;
	this.address_short = address_short;
	if( cur_ppid ) {
		this.cur_obj = getElement( cur_ppid + '_caption' );
		KB_cur_ppid = cur_ppid;
		}
	this.ico_folder = address_short + "img/knowledge_base/";
	this.closed_img_src = this.ico_folder + "closed.gif";
	this.opened_img_src = this.ico_folder + "opened.gif";
	}
KB_TREE.prototype.run_to_node = function () {
	}
KB_TREE.prototype.show_tree_part = function ( pp_id , action_type ) {
	var result = true;	//Что нам вернет функция по-умолчанию
	tmp_el = getElement( pp_id + "_child" );
	img_el = getElement( pp_id + "_img" );
	if( tmp_el && img_el ) { //Если у элемента есть потомки и картинка
		var mode = img_el.getAttribute( 'status' ) == 'opened' ? 'opened' : 'closed'; //Создаем флаг с атрибутом-состоянием элемента
		if( mode == 'closed' && action_type != 'close' ) { //Если элемент "свернут" и тип действия не равен 'close'
			img_el.src = this.opened_img_src; //Заменяем рисунок (с плюсика на минусик)
			img_el.setAttribute( 'status' , 'opened' ); //меняем атрибут-состояние элемента на "развернут" 
			tmp_el.style.display = "block"; //div, где выводятся потомки элемента делаем видимым
			if( tmp_el.innerHTML == '' ) { //смотрим, загружались ли уже потомки для элемента
				//если нет, то вызываем функцию, которая должна вывести этих потомков, если с ней какая-то беда, она вернет нам false и эта функция тоже 
				result = KB_SERVER_OBJ.loadFragmentInToElement( "/scripts/for_KBtree.php?pp_id=" + pp_id + ( KB_cur_bookmark ? "&bokm_id=" + KB_cur_bookmark : "" ) + "&select_mode=part" , tmp_el, "<small class=gray>" + KB_lang[ "loading" ] + "</small>" ); 
				//alert(el_tree_active); 
				}
			}
		else if( mode == 'opened' && ( action_type == 'auto' || action_type == 'close' ) ) { //если элемент "развернут" и тип действия равен 'auto' или 'close'
			img_el.src = this.closed_img_src; //Заменяем рисунок (с минускиа на плюсик)
			img_el.setAttribute( 'status' , 'closed' ); //меняем атрибут-состояние элемента на "свернут" 
			tmp_el.style.display = "none"; //и скрываем его потомков
			}
		}
	return result;
	}
KB_TREE.prototype.show_by_link = function ( pp_id, str, not_load_tree_part ) {
	var result = false;	
	if( this.cur_obj ) {
		this.cur_obj.className = "not_active";
		this.cur_obj.setAttribute( 'previousClassName' , 'not_active' );
		}
	//getElement( 'group_check_span' ).style.display = 'block';
	if (typeof not_load_tree_part == 'undefined') not_load_tree_part=false;
	
	if (!not_load_tree_part) {
		clicked_obj = getElement( pp_id + '_caption' );
		clicked_obj.className = "active";
		clicked_obj.setAttribute( 'previousClassName' , 'active' );
		this.cur_obj = clicked_obj;
	}
	KB_CONTENT_AREA_OBJ.showTreeActive (pp_id);
	
	
	if( not_load_tree_part || this.show_tree_part( pp_id , 'open' ) ) { 
		if( KB_cur_bookmark == 'search_bookmark' ) KB_TABSET_OBJ.loadTab ( 'all_docs' , true );
		result =  KB_CONTENT_OBJ.printContent( pp_id , '' , KB_cur_bookmark );
	}
	return result;
	
}
