// Title: COOLjsTree
// URL: http://javascript.cooldev.com/scripts/cooltree/
// Version: 2.7.0
// Last Modify: 23 Jul 2005
// Author: Alex Kunin <alx@cooldev.com>
// Notes: Registration needed to use this script on your web site.
// Copyright (c) 2001-2005 by CoolDev.Com
// Copyright (c) 2001-2005 by Sergey Nosenko

// Options: STANDARD, COMPRESSED, WATERMARK
// see http://www.crockford.com/JSON/index.html and http://www.crockford.com/JSON/js.html for explanation
// document.body: see http://www.december.com/html/4/element/body.html or http://www.quirksmode.org/js/doctypes.html



// added by dlam:
// this file was obtained from cooltree_no_so_tight.js:
// 1. open cooltree_no_so_tight.js in textpad (the file is split in 17 lines)
// 2. line 15 et 16, restore /MSIE 6/ which was split in the reg exp of match()
// 3. replace all ";" by ";\n"; with conditions text - match case - regular exp 
// 4. eliminate some erroneous CRLF (lines 197, 200, 280, 281, 293, 299, 403 (many), 412, 
// 6. Check that there is NO CR after any return!!
// 6. Errors:'_1A()' a la valeur null ou n'est pas un objet:
//	 motif: in definition of _1A(), we have return + CR + this._6[4].format} 
//	 remedy: remove the CR
function bigalert(text) {   
	msgWindow=window.open("","displayWindow","menubar=yes, scrollbars=yes")  
	msgWindow.document.write("=== start ===<br>"+text+"<br>=== end ===<br><br>")
	//msgWindow.document.write('<FORM><INPUT TYPE="button"  value="close" onClick="window.close()"></FORM>');
}

function ObjToString(val) {   // added by dlam (found in JS ref under 'Object'
	var i = 0;
	var ret = "[\n"   
	for (var prop in val) {
		ret += "  " + prop + " is " + val[prop] + ";\t"
		if (!(i++%4)) ret += "\n";
	}
	return ret + "]"
};

mydebug = new debug(false);	// true to activate debugging

function debug(active) {
	// warning: this must already exist for this code to work
/*	if (und(menuTree)) {  actually doen't work: à revoir
		alert('misplaced call to debug\'s constructor: this doen\'t yet exist');
		return;
	}*/
	if (active) {
		this.active = active;
		this.debugWindow=window.open("","debugWindow","menubar=yes, scrollbars=yes, resizable=yes") ;
		this.debugWindow.document.open()
	}
}
$=debug.prototype;
$.print=function(text) {
	if (this.active) this.debugWindow.document.write("=== start ===<br>"+text+"<br>=== end ===<br><br>")
}

//=======================================================
var undefined;	// from http://www.webreference.com/programming/javascript/gr/column9/index.html
function und(val){return val === undefined}; // if == au lieu de === then error line 416: length a la valeur null ou n'est pas un objet
//function und(val){return typeof(val)=='undefined'}; // formely _c

function isnumber(val){return typeof(val)=='number'};// seems not to be used
function _2J(val){return typeof(val)=='object'};	// seems not to be used
//=======================================================
function COOLjsTree(treeName,nodes,fmt, window_width){
//debugger call the MS debugger
	if (und(nodes)) {
		alert("COOLjsTree's constructor: passed argument nodes is undefined\n action canceled");
		return;
	}
	if (!und(mydebug)) mydebug.print("To cancel the debugger, set constructor's param to false line 42<br><br>");
	this.name=treeName;	
	
	this.bw=new lib_bwcheck();
	var format={};	// équivalent à créer un objet vide
	format.left=fmt[0];	// left position
	format.top=fmt[1];	// top position
	format.icon={nb:fmt[2],nf:fmt[5]}; // create an object with 2 name:value pairs: show +/- buttons and show folder image see http://www.crockford.com/JSON/index.html and http://www.crockford.com/JSON/js.html for explanation
	format._2g=fmt[3][0];	// "./img/plus square.gif"
	format._2j=fmt[3][1];	//"./img/minus square.gif"
	format.iE=fmt[3][2];	// "./img/blank.gif"
	format._1e=fmt[4][0]; // width for nodes w/o children new name : BW
	format.Bh=fmt[4][1]; // height for nodes w/o children
	format.Ew=fmt[4][2];	// ident
	format.clF=fmt[6][0];	// closed folder img's path
	format.exF=fmt[6][1];	// opened folder img's path
	format.iF=fmt[6][2];	// blue square
	format.Fw=fmt[7][0];	// width for folder w/o children
	format.Fh=fmt[7][1];	// height for folder w/o children
	format.ident=fmt[8];	// identation ba level ([0,8,16,24,32])
	format.bgcolor=fmt[9];	// added by dlam
	format.nodeStyle=fmt[10]; // formerly _1k default style for all nodes "clsNode" 
	format.levelStyle=fmt[11]; // styles for each level of menu (default style [] will be used for undefined levels): [],//["clsNodeL0","clsNodeL1","clsNodeL2","clsNodeL3","clsNodeL4"]
	format.so=fmt[12];	// true if only one branch can be opened at same time (false by default=>many subtrees allowed)
	format.pg=fmt[13][0];
	format.sp=fmt[13][1];
	if(format.icon.nb) for(var i in fmt[3])(new Image()).src = fmt[3][i];
	if(format.icon.nf) for(var i in fmt[6])(new Image()).src = fmt[6][i];
	this.format=format;
	if(!this.bw._G) this._1u=new _1u(format.bgcolor,this); //bw._G=this.hotjava||this.ie3; bgcolor ("" - transparent)
	if(und(window.CTrees)) window.CTrees=[];
	window.CTrees[treeName]=this;
	this.jsPath="window.CTrees['"+treeName+"']";
	this.Nodes=[];
	this.nodeIdx=-1;
	this.width = window_width;
//mydebug.print("width="+this.width);
	this._2b=0;
	this._1i={};
	// create the tree array by prepending root node manually
	this._n=this.extractNode(([{id:null},'',null,null,{format:{}}]).concat(nodes));// this.extractNode defined at line 284
	//alert("line 66 this._n="+this._n);
	this.px_unit=this.bw._J?'':'px';
	this._u=this.bw.dom&&!this.bw._J; //bw._J=this.opera&&!this.operaNew
	this.textdir_is_rtl=document.body&&document.body.dir=='rtl'; // dir=direction for weak/neutral text:'rtl' =right to left
	this._E=-1;
	this.init();
	this.draw()
};

$=COOLjsTree.prototype;
$._12={};
$.$handleEvent=function(widget_action_type,node_idx){	// ex. de widget_action_type: caption_onmouseout ou image_onmouseover
	var node=this.nodeByIndex(node_idx);
 	if(node&&!und(node.getFormat()[widget_action_type])) node.getFormat()[widget_action_type](node);
	return this[widget_action_type](node);
};

$._o=function(action_type,widget_type,_1j){
	return _$('on'+action_type,'return '+this.jsPath+'.$handleEvent(\'' + widget_type + '_' + 'on' + action_type + '\', '+_1j+')')
};
$.buildTagEventPart=function(_m,_1){	// formerly $._1y
	if(und(this._12[_m])){
		this._12[_m]={};
		for(var _o in this) if(_o.match(new RegExp('^'+_m+'_'+'on(.+)$'))) this._12[_m][RegExp.$1]=true
	};
	var s='';
	for(var _o in this._12[_m]) s+=this._o(_o,_m,_1._5);
//mydebug.print("$.buildTagEventPart s="+s);
	return s
};

$.getAdditionalColumns=function(_1){return''};

$.getRoot=function(){ // create the root node
	if(!this._C){
	//	this._n._g=this._C=new NTreeNode(this._n,this,null,false); // false stand for not a leaf node 
		this._n._g=this._C=new NTreeNode(this._n,this,null,false); // false stand for not a leaf node 
		this._C._M(true)
	};
	return this._C
};

$._1z=function(_5){ // seems not to be used
	var _k=this._18('n',_5,this._n._3);
	if(!_k) return null;
	var _8=this._n; //,i=0;
	for(var i=0;i<_k.length-1;i++) _8=_8._3[_k[i]];
//alert("line 126 fcn _1z return "+[_8,_k[i]]);
	return[_8,_k[i]]
};

$._11=function(_1){
	if(this._C&&_1._5==this._C._5) this._C=null;
	if(_1._g){
		_1._g._1g();
		_1.parentNode=null;
		_1._g=null
	};
	for(var i in _1._3) if(_1._3[i]._g) this._11(_1._3[i])
};

$._2T=function(_1E,_q,_6){
	var _8;
	if(_1E==this._n._5) _8=this._n;
	else{
		var _w=this._1z(_1E);
		if(_w)_8=_w[0]._3[_w[1]]
	};
	if(_8){
		this._11(_8);
		for(var i in _6) _6[i]=this.extractNode(_6[i]);
		_q=Math.max(0,Math.min(_q,_8._3.length));
		if(_q==_8._3.length){_8._3=_8._3.concat(_6)}
		else{
			var _3=_8._3;
			_8._3=[];
			for(var i in _3){
				if(i==_q) _8._3=_8._3.concat(_6);
				_8._3[_8._3.length]=_3[i]
			}
		};
		return _q
	} else return null
};

$._2o=function(_5,_6,_2u,_2v,_2t){
	var _w=this._1z(_5);
	if(_w){
		var _8=_w[0],_3=_8._3,_5=_w[1];
		this._11(_8);
		var _6=this.extractNode(_6);
		if(_2u) _6[0]=_8._3[_5][0];
		if(_2v) _6[4]=_8._3[_5][4];
		if(_2t) _6._3=_8._3[_5]._3;
		_8._3[_5]=_6
	}
};

$._2K=function(_8,_5){if(!und(_8._3[_5])){var _3=_8._3;
this._11(_8);
_8._3=[];
for(var i in _3) if(i!=_5)_8._3[_8._3.length]=_3[i]}};

$.getSelectedNode=function(){return this.nodeByIndex(this.selectedNode_idx)};
$._2y=function(_1){return this.selectedNode_idx===_1._5};
$._1p=function(_O){for(var i in _O){this._15[_O[i].id]=_O[i];
if(_O[i].layers)this._1p(_O[i].layers)}};

$._1G=$.getElementById=function(_h){ //_h may be 'clstree1_B', nttree1_0, nttree1_1, nttree1_2, nttree1_3, ...
	if(this.bw.ns4){
		if(!this._15){
			this._15={};
			this._1p(document.layers)
		};
		return this._15[_h];
	} else {
		return (document.all&&document.all[_h]) || document.getElementById(_h); //see http://simon.incutio.com/archive/2003/08/11/documentAll
	}
};

$.moveTo=function(x,y){
alert("line 177 in $.moveTo("+x+","+y+")");
	this._1u.top=y;
	this._1u.left=x;
	this._1u.moveTo(x,y);
	this.format.top=y;
	this.format.left=x;
	this.draw()
};

$.ensureVisible=function(idx,_2G){
	var node=this.nodeByIndex(idx);
	var _v=false;
	while(node){
		node=node.parentNode;
		if(node.treeView._n._5==node.index) break;
		if(!node.isExpandable()){
			this.expandNode(node._5,1); // Warning: following erroneous param 'node,idx,1' make the tree to collapse instead of expand
			_v=true
		}
	};
	if(_v&&!_2G) this.draw()
};

$._18=function(_T,val,_e){ 
	for(var i in _e){
		switch(typeof(val)){
			case'string':case'number':if(_e[i][_T]==val) return[i];break;
			default:if((''+_e[i][_T]).match(val)) return[i]
		};
		var _1o=this._18(_T,val,_e[i]._3);
//alert("line 179 in fcn $._18(): _1o="+_1o);
		if(_1o) return [i].concat(_1o)
	};
	return null
};

$._W=function(_T,val){return this.getRoot()._1R(this._18(_T,val,this._n._3))};

$.nbn=$.nodeByName=function(val){return this._W('c',val)};

$.nbf = $.nodeByFlag = function( nf ){  // nbf=node by flag: get a node according to node's flag called in tree_menu.html
		for (var i = 0;i<this.Nodes.length;i++){
//mydebug.print("$.nodeByFlag = function( nf ): i="+i+" nf="+nf);
			if (this.Nodes[i]!= null && this.Nodes[i].flag == nf)
				return this.Nodes[i];
		}
		return null;
	}

$.nodeByID=function(val){return this._W('i',val)};

$.nodeByURL=function(val){return this._W('u',val)};

$.nodeByIndex=function(val){
	if(!this.Nodes[val]) this.Nodes[val]=this._W('n',val);
	return this.Nodes[val]
};

$.nodeByXY=function(_X,_Y){
	for(var i in this.Nodes) 
		if(this.Nodes[i]) 
			with(this.Nodes[i])
				if(visible&&x<=_X&&y<=_Y&&x+w>_X&&y+h>_Y) return this.Nodes[i];
	return null
};

$._v=function(y){ 	
//alert("line 260 in fcn _v: y="+y+"  !this._1Z="+!this.timeout_id);
						// this.jsPath='window.CTrees['tree1']
	if(!this.timeout_id) 
		this.timeout_id=window.setTimeout(this.jsPath+'.draw()',1); // setTimeout probably to resolve the problem of double click
	if(typeof(y)=='number') this._E=Math.min(y,this._E);
	else this._E=-1
};
/*
$._1g=function(_1){ // seems not to be called and to generate an infinite loop
_1._1g()
};
*/
// test to comment this fcn
$._D=function(){
	if(this._u) for(var nodeIndex in this._1i){	// this._u true if browser is dom and if not new opera
		var _1=this.nodeByIndex(nodeIndex);
		if(_1) _1._D()
	};
	this._1i={}
};


$.draw=function(){
//mydebug.print("COOLjsTree.draw() line 311 pass 1");
	if(this.bw._G) return;	//this.bw._G=this.hotjava||this.ie3;
	this._D();
	this._21=true;
	this._y=0;
	this._t=0;
	with(this.getRoot()){
		draw(true); // NTreeNode.draw()
		if(this.textdir_is_rtl) draw(true) // NTreeNode.draw()
	}
//mydebug.print("COOLjsTree.draw() pass 2");
	this._1u._2r(this._t,this._y);
	this.timeout_id=null;
	this._E=10000000;	// à comprendre
//	if(this.ondraw) this.ondraw(this); // actually not defined 
	this._21=false
//mydebug.print("COOLjsTree.draw() sortie");

};

$.expandNode=function(index,_2M,_1M){ //_2M not used
//alert("line 263 in expandNode() pass 1");

	if(!this.bw._G){ //this.bw._G=this.hotjava||this.ie3;

		var node=this.nodeByIndex(index);
		if(_1M) this.selectNode(index);
		if(node&&node.hasChildren()){
			node.expandable = true;
			if (node.flag.substr(0,6) == 'intern'){ // we use flag instead of nbn because nbn is different for each language
				node.expandable = getCookie(this.nodeByIndex(index).cookiename);
	/*			if (!und(logWin)) {
					logWin.close(); // not found a better way to close the login window !!
					logWin = undefined;
				}*/
			}
			if (!node.expandable)
				return;
			var isExpandable=!node.isExpandable(); // Warning: don't move this statement below next block, because
													// node.isExpandable will be lost there
			if(this.format.so){	// true if only one branch can be opened at same time (false by default=>many subtrees allowed)
				this.collapseAll();
				this.ensureVisible(node.index,true)
			};
			node._M(isExpandable);	// defined at line 494: update some node's properties and shows buttons?
			this._v(node.y);	// draw the tree and update this._E
		} //if(node&&node.hasChildren()){
	} // if(!this.bw._G){
}; //$.expandNode=function()

$.selectNode=function(index){
	this.selectedNode_idx=index;
	this._v()
};

$._1N=function(_l,_1){
	for(var i in _1._3){
		this._1N(_l,_1._3[i]);
//alert("line 328 fcn $._1N=function(_l,_1) 1="+_1);
		if(_1._3[i]._3.length) 
			if(_1._3[i]._g) _1._3[i]._g._M(_l);
			else _1._3[i][4].format.expanded=_l
	}
};
		
$._1O=function(_l,_1){
	this._1N(_l,_1||this._n); // this._n=complete treenodes
	this._v()
};

$.collapseAll=	function(_1){ 
//alert("line 342 fcn $.collapseAll(_1)");
//bigalert(ObjToString(_1));
	this._1O( false,	_1&&_1._6)
};

$.expandAll	=	function(_1){ this._1O( true,	_1&&_1._6)};

// extractNode(): input: description de la node example:[ 0 is NOS POSITIONS; 1 is ../pagepositions.html; 2 is page; ]
// return 		output:	[ 0 is [object Object]; 1 is NOS POSITIONS; 2 is ../pagepositions.html; 3 is page; 4 is [object Object]; _3 is ; _5 is 4; _g is null; ]	


//example root node:[ 0 is [object Object]; 1 is ; 2 is null; 3 is null; 4 is [object Object]; 
//		5 is ACCUEIL,../pageaccueil.html,page; 6 is PARENTS,../pageparents.html,page; 7 is TEMOIGNAGES,../ ...
//example sub tree: [ 0 is INTERNE COMITE; 1 is null; 2 is null; 
// 		3 is FICHIER MEMBRES,../database/program_files/form.php?function=search&sql=&page=0&table_name=membre,_blank; 
//		4 is PUBLIPOSTAGE,../admin/publipostage/publipostage.php,_blank; 5 is DB ADMIN,../database/program_files/admin.php,_blank; 
//		6 is projets interactifs,,,calcul,,,Division,../interactif/calcul/division.html,_blank; ]
//example leaf node: [ 0 is ACCUEIL; 1 is ../pageaccueil.html; 2 is page; ]

$.extractNode=function(_1){ // formerly $._13; _1 est la description de la node avec le cas échéant les children

//mydebug.print("extractnode entry _1=\n"+ObjToString(_1));
	if(und(_1[_1.length-1])) _1=_1.slice(0,_1.length-1);
	if(und(_1[0].id)) _1=([{id:null}]).concat(_1);
	if(und(_1[4])||und(_1[4].format)) _1=_1.slice(0,4).concat([{format:{}}]).concat(_1.slice(4));
	var nodeIndex=this.nodeIdx++; 
	var _3=_1.slice(5); // extrait les children (vide si leaf node)
	_1 = _1.slice(0,5); // extrait la desc de la node, écarte les children)
	_1._3=[]; // array des children
	for(var i in _3) _1._3[i]=this.extractNode(_3[i]);
	_1[4]=_1Y(_1[4]);
	_1._5=nodeIndex;	//commented by dlam never used
	_1._g=null;
//mydebug.print("extractnode exit _1=\n"+ObjToString(_1));

	return _1
};

$.init=function(){
	var s=this.getRoot()._1K(!this._u); //this._u=this.bw.dom && !this.bw._J; (bw.dom si W3C DOM et bw._J=this.opera&&!this.operaNew)
	if(!this.bw._G) s=this._1u._2p(s);	//this.bw._G=this.hotjava||this.ie3;
	if(this.bw.ns4) s='<div id="'+this.name+'dummytreediv" style="position:absolute;"></div>'+s;
//mydebug.print("COOLjsTree.init(): s="+s);
	document.write(s)
};

$._2U=function(_b){return document.cookie.match(new RegExp('(\\W|^)'+this.name+name+'=([^;]+)'))?RegExp.$2:null};
$._2W=function(_b,_7){document.cookie=this.name+_b+'='+_7+'; path=/'};
$._1V=function(_1){var s='';
for(var i in _1._3)if(_1._3[i]._3.length)s+=(_1._3[i][4].format.expanded?1:0)+this._1V(_1._3[i]);
return s};

$._2V=function(){return this._1V(this._n)};

$._1W=function(_1,_l,_5){
alert("line 356 _l="+_l);
	for(var i in _1._3){
		if(_1._3[i]._3.length){
			if(_1._3[i]._g) _1._3[i]._g._M(_l.charAt(_5)=='1');
			else _1._3[i][4].format.expanded=_l.charAt(_5)=='1';
			_5=this._1W(_1._3[i],_l,_5+1)
		}
	};
	return _5
};

$._2R=function(_l){this._1W(this._n,_l||'',0)};

$.image_onclick=$.caption_onclick=function(_1){
//alert("line 370 $.image_onclick _1.index="+_1.index);
	this.expandNode(_1.index,1,1); // read 1,1 and not l,l
	return true
};

$.button_onclick=function(_1){
	this.expandNode(_1.index);
	return true
};
$.image_onmouseover=$.button_onmouseover=$.caption_onmouseover=function(_1){
//alert(_1.text);
	window.status=_1.text; // _1.text = texte du node survolé
	return true
};
$.image_onmouseout=$.button_onmouseout=$.caption_onmouseout=function(node){
	window.status=window.defaultStatus;
	return true
};

//======================================================================================================================
//function _1b(_6,_2,_8,_1U){	// semble être l'équivalent de l'ancienne function NTreeNode( treeView, parentNode , text, url, target){
function NTreeNode(_6,_2,_8,leaf){	// attention les paramètres ne correspondent pas!!
var index=_6._5;
this._6=_6;
this._5=this.index=index;
this.jsPath=_2.jsPath+'.nodeByIndex('+index+')';
this.treeView=this._2=_2;
this.parentNode=_8;
this.leaf=leaf;	//boolean (not used !?)
this.text=_6[1];
this.url=_6[2]; 
this.target=_6[3];
// added by dlam
//alert("line 344 in function NTreeNode(_6,_2,_8,_1U,target){  target="+target);
//mydebug.print("pass1 in function NTreeNode(_6,_2,_8,leaf)");
	if (this.target && this.target.substr(0,6) == "intern") {
//mydebug.print("pass2 in function NTreeNode(_6,_2,_8,leaf)  target="+this.target);
		this.expanded = false;
		this.url = "javascript:call_login('"+this.target+"')"; // defined in ./menu/tree_menu.htm
		this.intern = true;
		this.flag = this.target; // used to identify special nodes
		this.cookiename = this.treeView.name + "_" + this.target;
		this.target = "";	// target must not be null
	} else {
		this.expandable = true;
		this.flag = ' ';
		this.cookiename = '';
	}
//end added by dlam



this._2P=null;
this.nodeID=_6[0].id;
this.format=_6[4].format;
this._10=null;
this._M(this._6[4].format.expanded);
this.children=[];
this._x=this.level=_8?_8._x+1:-1;
this.visible=false;
this._r={};
this._1L=false;
this._Z={};
if(_8) this.getIconSize() // si leaf node, getIconSize()

};

$=NTreeNode.prototype;
//$._V=function(){return this.treeView._n._5==this.index}; // replaced by inline statement
$_i=$.isExpandable=function(){return this._6[4].format.expanded}; // formely fcn $._i
$.id=function(){
//alert("line 439 fcn $.id() "+this._h);
	return this._h
};
$._1h=function(_1S,_F,_1T){
	this.treeView._2o(this.index,[und(_1S)?this._27():_1S,und(_F)?this._25():_F,und(_1T)?this._24():_1T],true,true,true);
	this.treeView._v()
};

$.getTree=function(){return this.treeView};
$.getParent=function(){return this.parentNode};
$.getId=function(){return this._6[0].id};
$.getCaption=function(){return this._6[1]};
$.getUrl=function(){return this._6[2]};
$.getTarget=function(){return this._6[3]};

$.getFormat=function(){return this._6[4].format};
$.setCaption=function(_7){this._1h(_7,this._L,this._L)};
$.setUrl=function(_7){this._1h(this._L,_7,this._L)};
$.setTarget=function(_7){this._1h(this._L,this._L,_7)};
$._U=$.hasChildren=function(){return!!this._6._3.length};
$._2Q=function(){return this.parentNode&&this._2c()==0};
$._1Q=function(){return this.hasChildren()||this._6[4].format.isFolder};
$._1R=function(_k){ // may be fcn getnextchild()? is recursive , ucalled only line 194
//alert(_k);
	if(_k) return _k.length?this.getChild(_k[0])._1R(_k.slice(1)):this;
	return null
};

$._M=function(isExpandable){
//bigalert("line 465 this._6[4]="+ObjToString(this));
	this.expanded = this._6[4].format.expanded = isExpandable; // !!isExpandable replaced by isExpandable by dlam
	if(this._H){ //??
//alert("line 419 this._H =true");
		this._1P('nb',this._1J()); // show buttons
		this._1P('nf',this._1I())  // show folders
	}
};

$._1J=function(){
	if(!this.treeView.format.icon.nb||this.format.nobuttons) return null; // nobuttons never initialized !?
	if(!this.hasChildren()) return null;
	if(this.format.buttons) return this.isExpandable()?this.format.buttons[1]:this.format.buttons[0]; // buttons never initialized !?
	else return this.isExpandable()?this.treeView.format._2j:this.treeView.format._2g
};

$._1I=function(){if(!this.treeView.format.icon.nf||this.format.nofolders)return null;
if(this.format.folders)return this._1Q()?(this.isExpandable()?this.format.folders[1]:this.format.folders[0]):this.format.folders[2];
else return this._1Q()?(this.isExpandable()?this.treeView.format.exF:this.treeView.format.clF):this.treeView.format.iF};

$._1P=function(_d,_19){
	if(_19){
		var _17=(this.getLayer().document||document).images[this._h+_d];
		if(this.treeView.format.icon[_d]&&_17&&_17.src!=_19) this._Z[_d]={_2f:_17,_k:_19}
	}
};

$._2a=$.getIconSize=function(){
	this.Bw=und(this.format.bsize)?this.treeView.format.Bw:this.format.bsize[0]; // button width bsize always undefined
	this.Bh=und(this.format.bsize)?this.treeView.format.Bh:this.format.bsize[1];
	this.Fw=und(this.format.fsize)?this.treeView.format.Fw:this.format.fsize[0]; // folder width fsize always undefined
	this.Fh=und(this.format.fsize)?this.treeView.format.Fh:this.format.fsize[1]
};

$._1K=function(_14,_2S){ // create one node's <div> element see file div tag.txt called in fcn buildChildDivTag
	var s='';
	if(!(this.treeView._n._5==this.index)) {
		this._h='nt'+this.treeView.name+'_'+this.treeView._2b++;
		s+=this.treeView.bw._G?this.writeTree():'<div'+this.treeView.buildTagEventPart('layer',this)+' id="'+this._h+'d"  style="'+(this.treeView.bw.mac||this.treeView.bw._J?'':'height:1px;width:1px;')+'position:absolute;'+(this.treeView._u?'':'visibility:hidden;')+'z-index:'+(this.index+10)+';">'+this.writeTree()+'</div>'
//mydebug.print("line 547 fcn $.1K s="+s);
	};
	if(_14){
		if(!this.treeView._u)
			s+='<div id="'+this._h+'ch"  style="left:0;top:0;position:absolute;visibility:hidden;z-index:'+(this.index+10)+';">';
		s+=this.buildchildDivTag(_14);
		if(!this.treeView._u) s+='</div>'
	};
	return s
};

$._22=$.buildChildDivTag=function(_14){ // create child node's <div> elements see file div tag.txt called in fcn _1X() below
	var s='';
	for(var i=0;i<this.getNumberOfChildren();i++) s+=this.getChild(i)._1K(_14);
//bigalert(s);
	return s
};

/* fcn below create anchor tag: 
	* <a onmouseout="return window.CTrees['tree1'].$handleEvent('caption_onmouseout', 0)" 
	* onmouseover="return window.CTrees['tree1'].$handleEvent('caption_onmouseover', 0)" 
	* onclick="return window.CTrees['tree1'].$handleEvent('caption_onclick', 0)" 
	*	href="../pageaccueil.html" target="page" id="nttree1_0an" class="clsNode">ACCUEIL
	* </a>
	* ou
	* <a onmouseout="return window.CTrees['tree1'].$handleEvent('caption_onmouseout', 8)" 
	* onmouseover="return window.CTrees['tree1'].$handleEvent('caption_onmouseover', 8)" 
	* onclick="return window.CTrees['tree1'].$handleEvent('caption_onclick', 8)" 
	*	href="javascript:call_login()" id="nttree1_8an" class="clsNode">INTERNE MEMBRES
	* </a>
*/
$._23=$.buildFullAnchorTag=function(href_val,_m,_2d,_1k,_2m){	// _F replaced by href_val

//mydebug.print('fcn $._23 <a'+this.treeView.buildTagEventPart(_m,this)+' href="'+(href_val||'javascript:void(0)')+'"'+_$('target',href_val&&this.target)+_$('id',_2m&&(this._h+'an'))+_$('class',_1k)+'>'+_2d+'</a>');
	
	return'<a'+this.treeView.buildTagEventPart(_m,this)+' href="'+(href_val||'javascript:void(0)')+'"'+_$('target',href_val&&this.target)+_$('id',_2m&&(this._h+'an'))+
	_$('class',_1k)+'>'+_2d+'</a>'
};

$._1c=$.buildIconsCell=function(_m,_d,_1_,_28,_2F,w ,h ,_2L){
	if(!w||!_1_) return'';
	var i='<img'+(_d?' name="'+this._h+_d+'" id="'+this._h+_d+'"':'')+' src="'+_1_+'" width="'+w+'" height="'+h+'" border="0"'+(this.treeView.bw.ns4?'':' style="display: block"')+' />';
//mydebug.print('fcn $._1c <td style="font-size:1px;" width="'+w+'">'+(_28?this._23(_2F&&this.url,_m,i):i)+'</td>');
	return '<td style="font-size:1px;" width="'+w+'">'+(_28?this._23(_2F&&this.url,_m,i):i)+'</td>'
};

$._2e=function(){with(this.treeView.format) return und(ident[this.level])?ident[0]*this.level:ident[this.level]};

$.writeTree=function(){	// formerly $._1H
	var s='<table cellpadding="'+this.treeView.format.pg+'" cellspacing="'+this.treeView.format.sp+'" border="0" width="'+this.treeView.width+'" class="cls'+this.treeView.name+'_1u'+this.level+'"><tbody><tr>';
	s+=this._1c('','',this.treeView.format.iE,false,false,this._2e()+(this.hasChildren()?0:this.treeView.format.Ew),1);
	s+=this._1c('button','nb',this._1J(),true,false,this.Bw,this.Bh,'');
	s+=this._1c('image','nf',this._1I(),true,true,this.Fw,this.Fh,'');
	s+='<td ><div id="'+this._h+'a" style="position:relative; ">'+this._23(this.url,'caption',this.text,this._2E(),true)+'</div></td>';
//mydebug.print("fcn $.writeTree "+s+this.treeView.getAdditionalColumns(this).replace(/\{node\}/g,this.jsPath)+'</tr></tbody></table>');
//mydebug.print('fcn $.writeTree <div id="'+this._h+'a" style="position:relative; ">'+this._23(this.url,'caption',this.text,this._2E(),true)+'</div>');
	return s+this.treeView.getAdditionalColumns(this).replace(/\{node\}/g,this.jsPath)+'</tr></tbody></table>'
};

$._2E=function(){ // return "clsNode" ?!
	var s;
	with(this.treeView.format) s=levelStyle[this.level]||nodeStyle; // nodeStyle="clsNode"
	if(typeof(s)!='string') s=s[this.level];
//mydebug.print("fcn $._2E "+s||'');
	return s||''
};

$.setPosition=function(x,y){ // formerly $._2A=function(_p,_f) replaced by dlam
	if(this.x!=x||this.y!=y){
		this.x=x;
		this.y=y;
		with(this.getLayer()) 
			if(this.treeView.bw.ns4) moveTo(x,y);
			else {
				style.left=x+this.treeView.px_unit;
				style.top=y+this.treeView.px_unit;
			}
	}
};

$._1X=function(){ // called in draw()
	if(!this._A)
		if(this.treeView._u){ //treeView._u=this.bw.dom&&!this.bw._J; ie. DOM compatible and not old opera
			this._A=document.createElement('div'); // see http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/getelementbyid.asp
			this._A.style.position='absolute';
			this._A.style.top=this._A.style.left='0px';
			this._A.innerHTML=this.buildChildDivTag();
//mydebug.print("fcn $._1X this._A.innerHTML="+this._A.innerHTML);
			this.treeView._1u._j().appendChild(this._A)
		} else this._A=this.getLayer('ch');
//bigalert(ObjToString(this._A));
	return this._A
};

$._1$=function(){
	if(this._A){
		var _2C=this._A;
		this._A=null;
		for(var i in this._6._3) with(this._6._3[i]) if(_g) _g._D();
	//	_20(_2C) commented by dlam
		_2C.parentNode.removeChild(_2C)
	}
};

$._2H=function(){
	if(this.treeView._u&&!this._H){
		if(!(this.treeView._n._5==this.index)) this.parentNode._1X();
		this._H=true;
		this._r={}
	}
};

$._1g=function(){
	if(this.treeView._21) this._D();
	else {
		this.treeView._1i[this.index]=true;
		this.treeView._v()
	}
};
//  test to comment this fcn because this._H below seems to be not defined
$._D=function(){// seems to be not used
	if(this._H){ // don't understand why no error here because ._H is never defined
		for(var i in this._r){
			//_20(this._r[i]); commented by dlam (no more used replaced by statement inline below)
			this._r[i].parentNode.removeChild(this._r[i])
			this._r[i]=null
		};
		this._r={};
		this.w=this.h=this.x=this.y=0;
		this._H=false
	};
	this._1$();
	if(!(this.treeView._n._5==this.index)) this.parentNode._1$()
};

$.setVisibility=function(_P,isExpandableAndVisible){	// formely $._1n=
	if(this.treeView.bw.ns4) _P.visibility=isExpandableAndVisible?'show':'hide';
	else _P.style.visibility=isExpandableAndVisible?'visible':'hidden'
};

$._1v=function(){	// à étudier
	if(!this.treeView._u) this.setVisibility(this.getLayer(),this.visible);
	if(this.visible){
		for(var i in this._Z) with(this._Z[i]) _2f.src=_k;
		this._Z={}
	}
};


$.setOffset=function(_2s){	// formerly $._1F
	if(!this.h||_2s){

		if(this.treeView.bw.gecko) with(this.getLayer().childNodes[0]){
//alert("setoffset gecko offsetHeight="+offsetHeight);		
			this.w=offsetWidth;
			this.h=offsetHeight
		} else if(this.treeView.bw.ns4) with(this.getLayer()){
//alert("setoffset ns4 clip.height="+clip.height);		
			this.w=clip.width;
			this.h=clip.height	
		} else if(this.treeView.bw.operaNew) with(this.getLayer().childNodes[0]){
//alert("setoffset operanew offsetHeight="+offsetHeight);		
			this.w=offsetWidth;
			this.h=offsetHeight
		}else with(this.getLayer()){
//alert("setoffset else offsetHeight="+offsetHeight+" scrollHeight="+scrollHeight+" style.pixelHeight="+style.pixelHeight);		
			this.w=offsetWidth||scrollWidth||style.pixelWidth;
			this.h=offsetHeight||scrollHeight||style.pixelHeight// offsetWidth=scrollHeight=hauteur d'une node: 20 pour 1 ligne, 34 pour 2 ligne, 49 pour 3 lignes
		}														// style.pixelHeight=1
	}
};
//---------------------------------------------------------------------------------------
$.draw=function(expandable_and_visible){ // true if expandable and visible
	if(this.treeView._n._5==this.index){ // this.treeView._n._5 seems always equal to -1 => true only when index=-1 at initialisation
//mydebug.print("NTreeNode.draw() pass 1 this.index="+this.index);
		this.treeView.__=0;
		this.visible=expandable_and_visible
	} else if(this.y<this.treeView._E){
//mydebug.print("NTreeNode.draw() pass 2 this.index="+this.index);
		this.treeView.__=this.y+this.h;
		this.treeView._t=this._t;
		this.treeView._y=this._y
	} else if(this.visible||expandable_and_visible){
//mydebug.print("NTreeNode.draw() pass 3 this.index="+this.index);
		this.treeView._E=-1;
		this.visible=expandable_and_visible;
		this._1v();
		if(this.visible){
			this.setPosition(this.treeView.textdir_is_rtl?(this.treeView.bw.gecko?this.treeView._t:0)-this.w:0,this.treeView.__);
			this.setOffset();
			if(this._1L&&this._10!=this.isExpandable()&&this._H){
				this._D();
				this.visible=expandable_and_visible;
				this.setOffset();
				this.setPosition(this.treeView.textdir_is_rtl?(this.treeView.bw.gecko?this.treeView._t:0)-this.w:0,this.treeView.__);
				this._1v()
			};
			this.treeView._t=Math.max(this.w,this.treeView._t);
			this.treeView.__+=this.h;
			this.treeView._y=Math.max(this.treeView.__,this.treeView._y);
			this._t=this.treeView._t;
			this._y=this.treeView._y
		}
	};
	// 
	if( (this.visible&&(this._10||this.isExpandable()) ) || (!this.visible&&this.visible!=expandable_and_visible&&this._10))
		this.drawChildren(this.isExpandable()&&this.visible);
	if(this.hasChildren()&&this.isExpandable()||this._A) 
		this.setVisibility(this._1X(),this.isExpandable()&&this.visible);
	this._10=this.isExpandable()
};
//---------------------------------------------------------------------------------------
$.drawChildren=function(expandable_and_visible){ // do nothing if leaf node; expandable_and_visible is true if expandable and visible; 
	for(var i=0;i<this.getNumberOfChildren();i++) this.getChild(i).draw(expandable_and_visible)};

$.getNumberOfChildren=function(){return this._6._3.length};

$.getChild=function(_q){ // _q est l'index du child
	with(this._6._3[_q]){
		if(!_g){
			var menu_node=this._6._3[_q];	// this._6._3 est l'array des nodes tel que défini dans menu_nodes.js
	//	alert("menu_node._5.toString() = "+menu_node._5.toString());
			_g=this.treeView.Nodes[menu_node._5] = new NTreeNode(menu_node,this.treeView,this,_q<this.getNumberOfChildren()-1)
		};
		return _g
	}
};

$._2c=function(){	// get the idx of child in the parent's list of visible child?
	var _9=0;
	while(_9<this.parentNode._6._3.length)
		if(this.parentNode._6._3[_9]._5==this.index) return _9;
		else _9++;
	return null
};

$.getLayer=function(_d){
	if(!_d) _d='d';
	if(!this._r[_d]){ //this._r={};
		this._2H();
		this._r[_d]=this.treeView.getElementById(this._h+_d)
	};
	return this._r[_d]
}; 
//===============================================================================================================================

function _1u(bgcolor,treeView){
	this.treeView=treeView;
	this.left=treeView.format.left;
	this.top=treeView.format.top;
	this._b='cls'+treeView.name+'_B';	// par ex. "clstree1_B"

	this.color=bgcolor
//mydebug.print("function _1u  _1u._b="+this._b);

};

$=_1u.prototype;
$._j=$.getNodeById=function(_d){
// mydebug.print("line 843 in fcn _1u._j("+_d+") returning"+ObjToString(this.treeView.getElementById(this._b+(_d||''))));
	return this.treeView.getElementById(this._b+(_d||'')) 
};
$._2r=function(_1B,_I){
	if(this.treeView.bw._J&&!this._2r_visited){
		this._2r_visited=true
	} else {
		with(this.getNodeById('c')){
			if(this.treeView.bw.ns4) moveTo(0,_I);
			else style.top=_I+this.treeView.px_unit
		};
		_I+=7;
		with(this.getNodeById()){
			if(this.treeView.bw.ns4) resizeTo(_1B,_I);
			else{
				style.width=_1B+this.treeView.px_unit;
				style.height=_I+this.treeView.px_unit
			}
		}
	}
};

$._2p=function(_2l){var p='relative',l=0,t=0,w=1,h=1;
	l=this.left;
	t=this.top;
	p='absolute';
	var s='<div style="overflow:'+(this.treeView._J?'scroll':'hidden')+';'+(this.color==""?"":(this.treeView.bw.ns4?'layer-':'')+'background-color:'+this.color+";")+'position:'+p+';top:'+t+'px;left:'+l+'px;width:'+w+'px;height:'+h+'px;z-index:0;" id="'+this._b+'">'+
	(this.treeView.bw.ns4?'<img src="'+this.treeView.format.iE+'" width="'+w+'" height="'+h+'" />':'')+'<div id="'+this._b+'c" style="position:absolute;font:7px arial,helvetica;color:#d0d0d0;line-height:7px;">'+unescape(('434f4f4c6a7354726565').replace(/(..)/g,'%$1'))+'</div>';
//mydebug.print("function _1u._2p: return="+s+_2l+'</div>');

	return s+_2l+'</div>'
};

//========================================================================
_$=function(_b,_7){return _7?' '+_b+'="'+_7+'"':''};

function lib_bwcheck(){
				var _26=parseInt(navigator.appVersion);
				this.ver=navigator.appVersion;
				this.agent=navigator.userAgent;
				this.dom=document.getElementById?1:0; // dom=1 si le browser est conforme à W3C Document Object Model
				this.opera=window.opera?1:0;
				this.ie5=this.ver.match(/MSIE 5/)&&this.dom&&!this.opera; // this.dom=1 si browser conforme to W3C Document Object Model
				
				this.ie6=this.ver.match(/MSIE 6/)&& this.dom&&!this.opera;
				
				this.ie4=document.all&&!this.dom&&!this.opera;
				
				this.ie=this.ie4||this.ie5||this.ie6;
				
				this.mac=this.agent.match(/Mac/);
				this.ie3=this.ver.match(/MSIE/)&&_26<4;
				this.hotjava=this.agent.match(/hotjava/i);
				this.ns4=document.layers&&!this.dom&&!this.hotjava;
				this._G=this.hotjava||this.ie3;
				this.operaNew=this.agent.match(/opera.[789]/i);
				this.gecko=this.agent.match(/gecko/i);
				this._J=this.opera&&!this.operaNew
};

window._1q=window.onload;

window.onload=function(){
	var bw=new lib_bwcheck();
	if(typeof(window._1q)=='function') window._1q()
};

function _1Y(o){
	var r={};
	for(var i in o) r[i]=typeof(o[i])=='object'?_1Y(o[i]):o[i];
	return r
}
