/*
  Ce script est une oeuvre originale d'ACORLINE et ne peut être utilisé sans autorisation
*/

//		alert(inod.nod.Cle + ", " + inod.nod.Lib)
//var voiture1 = {marque:"Renault", modele:"Safrane", numero:"1245 AAA 34", km:25000, prix:10000};


/*function TreeConf() {
	this.Rep = "/Applis/Pack/Img/Tree/"
	this.Space = "<IMG SRC='/Applis/Pack/Img/Space.gif' WIDTH=16 HEIGHT=10 BORDER=0>"
	this.Open  = "<IMG SRC='/Applis/Pack/Img/Tree/BookOuv.gif' WIDTH=16 HEIGHT=16 BORDER=0>"
	this.Close = "<IMG SRC='/Applis/Pack/Img/Tree/BookFerm.gif' WIDTH=16 HEIGHT=16 BORDER=0>"
	this.Doc   = "<IMG SRC='/Applis/Pack/Img/Tree/Generic.gif' WIDTH=16 HEIGHT=16 BORDER=0>"
	this.Page  = "<IMG SRC='/Applis/Pack/Img/Tree/BookFeui.gif' WIDTH=16 HEIGHT=16 BORDER=0>"
	//this.O = function(NomImg) {  var S = this[NomImg];  if (!S)  return "";  if (S.indexOf("/")<0)  S = this.Rep + S  }
}*/

function TreeConf() {
	this.Rep = "/sites/i2g/img/"
	this.Space = new Object();  this.Space.T = "<IMG I=Space WIDTH=16 HEIGHT=10 BORDER=0>";  this.Space.I = new Image(16,10);  this.Space.I.src = "/applis/pack/img/Space.gif"
	this.Open  = new Object();  this.Open.T = "<IMG I=Open WIDTH=16 HEIGHT=12 BORDER=0>";   this.Open.I = new Image(16,12);  this.Open.I.src = "/sites/i2g/img/TreeOpen.gif"
	this.Close = new Object();  this.Close.T = "<IMG I=Close WIDTH=16 HEIGHT=12 BORDER=0>";  this.Close.I = new Image(16,12);  this.Close.I.src = "/sites/i2g/img/TreeClose.gif"
	this.Doc      = "<IMG SRC='/applis/pack/img/tree/Generic.gif' WIDTH=16 HEIGHT=16 BORDER=0>"
	this.Page     = "<IMG SRC='/applis/pack/img/tree/BookFeui.gif' WIDTH=16 HEIGHT=16 BORDER=0>"
	this.BackgroundSelOn = "white"
	/*this.O = function(NomImg) {  var S = this[NomImg];  if (!S)  return "";  if (S.indexOf("/")<0)  S = this.Rep + S  }*/
}

function TIco() {
	//this.xls = "/sites/i2g/img/"
}

/*
 * ====================================================             LIST NODE  Objet           ================================
 */
ListList = new ListListObj

function ListListObj (Liste) {
	this.nb = 0
	this.all = {}
	this.Add = Add

	function Add (Liste) {
		this[this.nb] = Liste
		this.all[Liste.Nom] = Liste
		this.nb++
	}
}



function ListNodObj (Nom, Data, Opt) {
	this.Nom   = Nom
  this.nb    = 0
  this.all   = {}
  this.InitCoche = InitCoche
  this.ListCoche = ListCoche
  this.AddSuite = null
  AddProperty (this, Opt)
	this.Clear   = function () {
		for (var i=0; i<this.nb; i++) {
			this.all[this[i].cl1] = null
			this[i] = null
		}
		this.nb=0
	}
	if (Nom)  ListList.Add(this)
	if (Data) this.InitListe(Data)
}

function NodObj (Cle, Lib, Opt) {
  this.Cle		= Cle
  this.cl1		= Cle
  this.Lib		= Lib
  this.Coche0	= false
  this.Coche	= false
  AddProperty (this, Opt)
  if (!this.Lien)  this.Lien = ""
  this.clp		= this.Lien
	return this
}

ListNodObj.prototype.Add = function(cl1, Lib, Opt) {
	var Nod
  if (!Lib && !Opt) { Opt=cl1;  cl1="" }
  if (this.PreparOpt)  Opt = this.PreparOpt(Opt)
  if (!cl1)  cl1 = this.nb
	if (this.all[cl1]) {
		Nod = this.all[cl1]
	  Nod.Lib = Lib
	  AddProperty (Nod, Opt)
	}else{
		Nod = new NodObj(cl1, Lib, Opt)
		Nod.List = this
	  this[this.nb] = Nod
	  this.all[cl1] = this[this.nb]
  	this.all[cl1].Index = this.nb
  	this.nb++
	}
	if (!Nod.Code)  Nod.Code = Nod.cl1
	if (this.AddSuite)  this.AddSuite(Nod)
	return Nod
}

ListNodObj.prototype.Suppr = function(cl1, NomCh) {
	var Nod
	if (NomCh)
		Nod = this.Rech("nod." + NomCh + "=='" + cl1 + "'")
	else
		Nod = this.all[cl1]
	if (!Nod)  return
	Index = Nod.Index
	this[Index]   = null
  this.all[cl1] = null
	for (var i=Index; i<this.nb-1; i++) {
		this[i] = this[i+1]
	}
  this.nb--
}

ListNodObj.prototype.InitListe = function(Data) {
	var TR = Data.split(";")
	for (i=0; i<TR.length; i++) {
		if (TR[i])  TD = TR[i].split(",");  else  continue;  if (TD.length<1)  continue
		V = Trim(TD[1])
		if (TD.length==1) {  Key = i+1;  V = Trim(TD[0]) }  else  Key = TD[0];
	  this.Add (Key, V, (TD.length>2) ? Trim(TD[2]) : "")
	}
}

function InitCoche(Chaine) {
	var nod
	for (var i=0; i<this.nb; i++) {
		nod = this[i];
 	  if (Chaine && Chaine.indexOf(nod.Cle + ",")>=0)  nod.Coche0 = nod.Coche = true;  else  nod.Coche0 = nod.Coche = false
	}
}

function ListCoche(NomCh) {
	var nod, L1="", L2="", Cle
	for (var i=0; i<this.nb; i++) {
		nod = this[i];  Cle = nod.Cle
	  if (nod.Coche!=nod.Coche0) {
	  	if (NomCh)  L1 += eval("nod." + NomCh) + ";"
	  	else{
	  		if (nod.Coche)  L1 += Cle + ",";  else  L2 += Cle + ","
	  	}
	  }
	}
	if (L2)  L1 += ";" + L2
  return L1
}

ListNodObj.prototype.Init = function(AFaire, Test) {
	// ex : List.Init("nod.Op='+'")
	var nod, Cle, Lien, TypP, TypNiv, Lib
	if (!Test)  Test = "true"
	for (var i=0; i<this.nb; i++) {
		nod = this[i];  Cle = nod.Cle;  Lib = nod.Lib;  Lien = nod.Lien;  TypP = nod.TypP;  TypNiv = nod.TypNiv
		if (eval(Test))  eval(AFaire)
		//alert(AFaire + ", eval=" + eval(AFaire) + ", nb=" + nb + ", Lib=" + Lib + ", " + nod.RepLie)
	}
}

ListNodObj.prototype.Rech = function(Test) {
	var nod, Cle, Lien, TypP, TypNiv, Lib
	for (var i=0; i<this.nb; i++) {
		nod = this[i];  Cle = nod.Cle;  Lib = nod.Lib;  Lien = nod.Lien;  TypP = nod.TypP;  TypNiv = nod.TypNiv
		if (eval(Test))  return nod
	}
}

ListNodObj.prototype.Copy = function(ListSource) {
	var nod, nd, i, O, V, S
	for (var i=0; i<ListSource.nb; i++) {
		nod = ListSource[i]
		nd  = this.Add(nod.cl1, nod.Lib)
		FusionNod(nod, nd)
	}
}

function FusionNod(nodS, nodD) {
	var O, V
	for (NomObj in nodS) {
  	O = nodS[NomObj]
  	if (typeof(O)!="function") {
  		if (NomObj=="RechParent")  continue
  		V = O
  		//if (nodS.Lib=="Questionnaire")  alert("NomObj=" + NomObj + ", V=" + V)
	  	if (V)  nodD[NomObj] = V
	  }
  }
}

ListNodObj.prototype.toXml = function() {
	var O, S="", H="", avt="", i
	if (this.Nom)  S = this.Nom
	//H = "<?xml version='1.0' encoding='windows-1252'?>\n"
	H+= "<ROOT Nom='" + S + "'>\n"
	for (var i=0; i<this.nb; i++) {
		nod = this[i]
		H+= NodtoXml(nod, "N", 1, "Index,")
	}
	H+= "</ROOT>"
  return H
}


NodObj.prototype.Copy = function(nod) {
	var i, O, V
	for (NomObj in nod) {
  	O = nod[NomObj]
	  if (typeof(O)!="function") {
	  	V = O
		 	if (V)  this[NomObj] = V
		}
	}
}

NodObj.prototype.RechParent = function(Test, DepartPere) {
	var nod, Cle, Lien, TypP, TypNiv, Lib
	if (DepartPere)  nod = this.List.all[this.Lien];  else  nod = this
	while (nod) {
		Cle = nod.Cle;  Lib = nod.Lib;  Lien = nod.Lien;  TypP = nod.TypP;  TypNiv = nod.TypNiv
		if (eval(Test))  return nod
		nod = nod.List.all[nod.Lien]
	}
}





/*
 * ====================================================             TREE  Objet           ================================
 */
function TreeObj (Nom, ListNod, Index, Opt) {
	this.Nom = Nom
	if (!ListNod || ListNod.nb==0)  return
	if (!Index)  Index = 0
	this.ids = {}
	this.Init = function (Index) {
		this.ListNod  = ListNod;  if (typeof(Index)=="number")  nod = ListNod[Index];  else  nod = ListNod.all[Index]
		if (!nod)  return
		this.Racine   = new INodObj(nod)
		this.Racine.Tree = this
		this.RootTree = this.Racine
		this.RootAff  = this.Racine
	}
	this.Init (Index)
	this.nb				= 0
	this.Sel			= null
	this.On				= null
	this.ModeRangt = "Cle"  //Rangt disque
  AddProperty (this, Opt)
  if (!this.Look)  this.Look = "Tree"

  this.Clear    = ClearTreeNod
  this.Make()
  if (this.CodRoot) {
  	inod = this[this.CodRoot];  if (inod) {  this.RootTree = inod;  this.RootAff  = inod  }
  	//alert(this.CodRoot + ", " + inod.nod.Lib)
  }
}

TreeObj.prototype.Make = function() {
	var inod, ind, nod, T, Code, i, j, Filtre, Lien, Liens
	inod = this.Racine;  nod = this.Racine.nod
	this[nod.Code] = inod;  this.nb++	//this.Racine.Make()
	inod.Tree.ids[nod.Lien + "_" + nod.Code] = inod
	var ListNod = this.ListNod
	Filtre = this.Filtre
	for (i=1; i<ListNod.nb; i++) {
		nod = ListNod[i];  //alert(nod.Code + ", " + nod.Lib + ", " + nod.TypDoc + ", " + Filtre + ", " + eval(Filtre))
		if (Filtre && !eval(Filtre))  continue
		Liens = nod.Lien + "";  if (!Liens)  Liens = this.Racine.nod.Code + ""
		T = Liens.split(",")
		for (j=0; j<T.length; j++) {
			Lien = T[j]
			inod = this[Lien]
			if (inod) {
				ind = inod.Add(nod)
			}
		}
	}
}

TreeObj.prototype.RechPath = function(Path, Champ, Exec, Param) {
	var inod, nod, T, i, R
	var T = Path.split("/");  if (!T.length)  return
	if (!T[0])
		inod = this.RootTree
	else if (this.ListNod) {
		nod = this.ListNod.Rech('Lib=="' + T[0] + '"')
		if (nod)  inod = this[nod.cl1]
		T = T.slice(1)  // sauf le 1° (slice(0,-1) = sauf le dernier)
		Path = T.join("/")
	}
	if (inod) {
		R = inod.RechPath(Path, Champ, Exec, Param)
		return R
	}
}

function ClearTreeNod (Obj) {
	var inod
	if (typeof(Obj)=="string") {
  	inod = this[Obj];  if (!inod)  return
	  inod.SupprChilds()
	  this[Obj] = null
	}else{
	  if (!Obj)  Obj = this.Racine
	  this[Obj.nod.cl1] = null
	  Obj.SupprChilds()
		OP = Obj.Parent;  var Index = Obj.Index
		if (OP) {
			OP.nb--
  		OP[Index] = null
		  OP.all[Obj.nod.cl1] = null
			for (var i=Index; i<OP.nb; i++) {
				OP[i] = OP[i+1]
			}
		}
		Obj = null
  }
}

function SupprNod(ID) {
	if (typeof(ID)=="string")  D = LID(ID);  else  D = ID
	//alert(ID + ", " + D)
	if (D)  D.removeNode (true)
}



/*
 * ====================================================             VUE  Objet           ================================
 */
function VueObj (Nom, NomDiv, Tree, Opt, Model) {
	var nod, St
	if (!Tree || !Tree.nb)  return
	this.Trees		= new Array;  this.Point = new Array
	this.Nom      = Nom
	this.NomDom   = Nom
	this.Div      = (NomDiv.indexOf(".")<0) ? LID(NomDiv) : eval(NomDiv)
	this.Model    = LID(Model)
	//this.SetTree(Tree)
	this.PushTree(Tree);  if (this.RootAff!=this.RootTree)  this.PushTree(Tree, this.RootAff)
	this.TreeConf = new TreeConf()
	this.ready = true
	this.Style = new Object();  this.Style.addTR=""

  AddProperty (this, Opt)
  if (!this.Look)  this.Look = "Tree"

  if (!this.TypLook && this.Look=="Tree") {
	  //nod = Tree.ListNod.Rech("TypP=='" + this.RootTree.nod.TypP + "' && Lien==" + this.RootTree.nod.Cle)
	  nod = this.RootTree.nod
	  this.TypLook = "Niv" + ((nod.TypP=="SITES" && nod.TypNiv==0) ? 2:1)
  }
  this.InitMenuIco()

  this.Div.onclick = VueClic
  this.Div.onmousemove = VueMouseMove
  this.Div.oncontextmenu = VueClicD
	this.Div.setAttribute("NomVue", this.NomDom)

	AddFunction(this, "ClicAction", "ClicTree")
	AddFunction(this, "ClicVue", "Clic_" + Nom)
	AddFunction(this, "ClicOutTree", "ClicOutTree")
	AddFunction(this, "ClicDAction", "ClicDTree")
	AddFunction(this, "onFinDrawTree")
	AddFunction(this, "onEndDraw", "onEndDraw_" + Nom)
	AddFunction(this, "onFinDrawNod")
}

VueObj.prototype.PushTree = function(Tree, RootAff) {
	this.Trees.push(Tree)
	this.Tree     = Tree
	this.RootTree = Tree.RootTree
	this.On = this.Sel = this.RootAff = (RootAff ? RootAff:Tree.RootAff);  //alert(this.RootTree + ", " + this.RootAff)
	this.Point.push(this.RootAff)
}

VueObj.prototype.PopTree = function() {
	this.Trees.pop();  this.Point.pop()
	var Tree	= this.Trees[this.Trees.length-1]
	var R = this.Point[this.Point.length-1]
	this.Tree	= Tree
	this.RootTree = Tree.RootTree
	this.On = this.Sel = this.RootAff = R
}

	VueObj.prototype.SetTree = function(Tree) {
		this.Tree     = Tree
		this.RootTree = Tree.RootTree
		this.On = this.Sel = this.RootAff = Tree.RootAff;  //alert(this.RootTree + ", " + this.RootAff)
	}

VueObj.prototype.Draw = function(Opt) {
	var Tree, List, Div, Dest, DivTit, O, Os, inodCle, inod, S, Filtre, Look, Root, IcoRet="", i, n

	Tree = this.Tree;  if (!Tree)  return
	this.nbAff = 0
	List = Tree.ListNod
	var Pos = VarListe(Opt,"Pos")
	if ((S=VarListe(Opt,"Root"))) {
		Root = S;  inod = Tree[Root]
		if (inod) {  this.RootAff = inod;  }
	}else if (this.RootAff)  Root = this.RootAff.nod.Code
	if ((S = VarListe(Opt,"Dest"))) Div = LID(S);  if (!Div) Div = this.Div
	D = LID(Div.id + "_Corps");  if (D)  Dest = D;  else  Dest = Div
	//this.DivDest = Dest;  Dest.setAttribute("Vue",this.Nom)
	DivTit = LID(Div.id + "_Titre")
	if ((S = VarListe(Opt,"Look")))  Look = S;  else  Look = this.Look
	Div.setAttribute("NomVue", this.NomDom)

  inodCle = Tree[Root];  if (!inodCle)  return
  if (!this.Sel)  this.Sel = this.RootTree
  if (this.Sel.Niv<this.RootAff.Niv)  this.Sel = this.RootAff
	this.ready = false
	Aff(this.Div)

  switch(Look) {
  	case "Tree":
			inod = inodCle;  this.RootAff = inod
			//if (this.TypLook=="Niv2") {  if (inod.Niv==Tree.RootTree.Niv  && inod.nb)  inod = inod[0];  else  this.TypLook="Niv1"  }
			var nod = inod.nod
			if (DivTit) {
	  	  M1="none";  M2="";  if (this.SiCoche) {  M1="inline";  if (nod.Coche)  M2=" checked";    }
	  	  if (this.Trees.length>1 && !this.noIco)  IcoRet = "<TD Elem=BackTree style='font-family:webdings; cursor:pointer'>3</TD>\n"
		  	H = "<TABLE class=TreeEntete border=0><TR id='" + this.Div.id + "_row_" + nod.cl1 + "' Elem=Row cl1='" + nod.cl1 + "' Code='" + nod.Code + "' Lien='" + nod.Lien + "'>\n"
	  		H+= "<TD style='display:" + M1 + "'><INPUT type=checkbox" + M2 + "></TD>"
	  		H+= IcoRet
			  H+= "<TD Elem=LibTree style='font:bold; cursor:pointer'>" + nod.Lib + "</TD>\n"
			  H+= "</TR></TABLE>\n"
				DivTit.innerHTML = H;  //alert(D.outerHTML)
			}
			if (List.nb<15)  inod.Init("inod.Ouv=1")
			Dest.innerHTML = this.DrawTree(inod, Opt)
			if ((S=LX(Dest,"ID"))) {
				if (ServerName=="localhost")  n=100;  else  n=900
				setTimeout("InitImg(" + this.Nom + ", " + S + ")", n);
			}else
				InitImg(this, Dest)
			//Dest.innerText = Dest.outerHTML
			break
		case "Cible":  this.DrawCible(inodCle, Div, Opt);  break
		case "Bloc":
			if (DivTit) {
				DivTit.innerHTML = inodCle.nod.Lib
			}
			H=""
		  if (this.THead) {  //H += this.THead;
		  	H += DrawBlocNod (this, inodCle, "", this.THead, false)
		  }
			H += this.DrawBloc(inodCle, Opt);
		  if (this.TFoot) {  H += this.TFoot;  }
			Dest.innerHTML = H
			break
		case "Div":
			S = VarListe(Opt,"Model");  if (S)  Model = LID(S);  else  Model = this.Model
		  Div.innerHTML = ""
		  Div.style.display="block"
  	  this.DrawDiv(inodCle, Model, Div, "", null, Opt);   //alert(Div.parentNode.outerHTML)
			if (Pos=="Mouse") {
			  if (document.all) { e=event;  X = e.x;  Y = e.y }  else  { X = e.pageX;  Y = e.pageY  }
			  Div.style.left = X - 10 + window.document.body.scrollLeft
				Div.style.top  = Y - 18 + window.document.body.scrollTop
			}
  	  break
  	default:
  		AddFunction(this, Look)
  		this[this.Look](inodCle, Div, Opt);
  		break
  }
	if (this.SelPremFils && this.RootTree.nb)  this.Sel = this.RootAff[0];	//alert(this.Nom + ", " + this.RootAff.nod.Lib)
	if (VarListe(Opt,"Suite")!="n") { this.onFinDrawTree();  this.onEndDraw()  }
	this.ready = true
	if (this.AfterDraw=="ClicSel")  this.Clic()
}

function InitImg(NomTree, IdDiv) {
	var Os, O, i, Vue, Div
	if (typeof(NomTree)=="string")  Vue = eval(NomTree);  else  Vue = NomTree
	if (typeof(IdDiv)=="string")  Div = LID(IdDiv);  else  Div = IdDiv
	if (!Vue || !Div)  return
	Os = LTags(Div,"IMG")
	for (i=0; i<Os.length; i++) {
		O = Os[i];  //alert(Lout(O) + "\n\n" + Lout(Div))
		if ((S=LX(O,"I"))) {
			O.src = Vue.TreeConf[S].I.src;  O.removeAttribute("I")
		}
	}
}

VueObj.prototype.DrawTree = function (inodP, Opt) {
	var S="", SS="", H="", Li, TDIco="", TDIco2="", Ico="", Spac="", Space, FinH="", TDAv="", TDAp="", CB="", Class, inodP, nod, Filtre, D0, ParamT=""
	var delta = this.RootAff.Niv;  //alert(delta + ", ", + inodP.nod.Lib)
	Filtre = VarListe(Opt,"Filtre");  if (!Filtre)  Filtre=this.Filtre;

	D0 = new Date("1/1/1970")
	for (i=0; i<inodP.Niv-delta; i++)  Spac += "<TD width=16>" + this.TreeConf.Space.T + "</TD>"
	for (var i=0; i<inodP.nb; i++) {
		inod = inodP[i];  nod = inod.nod;  if (!nod)  continue
		  //if (this.Nom=='VueTree')  alert(Filtre + ", " + eval(Filtre) + ", " + nod.Lib + ", " + nod.TypDoc)
		if (Filtre && !eval(Filtre))  continue
		this.nbAff++
  	if (!this.SiCoche)  Space=Spac;  else  Space = "<TD width=20><INPUT type=checkbox" + ((nod.Coche) ? " checked":"") + "></TD>" + Spac
  	ParamT = TDAp = CB = ""

		if (inod.nb==0) {
			S = (i==inodP.nb-1) ? "TraitOut" : "TraitIn"
			//nod.TypDoc=="M" &&
			if (!this.noIco)  TDIco = "<TD Elem=IcoTree class=" + S + " valign=top style='width:18'><IMG I=Space width=18></TD>"
			Class = "Tree" + (inodP.Niv+1)
		}else{
			S = (inod.Ouv) ? this.TreeConf.Open.T : this.TreeConf.Close.T
			if (!this.noIco)  TDIco = "<TD Elem=IcoTree style='width:18'>" + S + "</TD>"
			Class = "Tree" + (inodP.Niv)
		}

		S = nod.AdrWeb;  if (!S)  S = nod.Fic
		Ext = FicPartie (S, "Ext")
		if (nod.TypDoc!="M") {
			if (Ext) {
				if ("doc,xls,ppt,pdf,txt,htm,jpg,".indexOf(Ext.toLowerCase()+",")>=0)  Ico = "typdoc/" + Ext + "1.gif' width=16";  else  Ico = "tree/Ico_Page.gif' width=11"
				if (nod.IcoAv)  TDAv = "<TD Elem=" + nod.ElemAv + " style='width:16;' title=\"" + nod.TitAv + "\"><IMG SRC='" + nod.IcoAv + "' width=12 border=0></TD>"
			}else{
				Ico = "Space.gif' width=16"
				Ico = "tree/Ico_Page.gif' width=11"
				//TDAv  = "<TD title=\"" + nod.TitAv + "\" style='width:12;'>&nbsp;</TD>"
			}
			TDIco2 = "<TD Elem=IcoDoc align=center style='width:16; xpadding:1 4 1 0' title=\"Lire " + ServerName + " >" + nod.Lib + "\"><IMG SRC='/applis/pack/img/" + Ico + " border=0></TD>"
			Class = "TreeDoc";
		}

		if (nod.Lect && !nod.FicLie) {
			//if (nod.Cle=="27")  alert(nod.DatMaj)
			SS="";  S = "lu le " + FormatDate(nod.DatLect) + "\nMaj le " + FormatDate(nod.DatMaj)
			switch (nod.Lect) {
				case "lu":  SS = "PuceVert";  break
				case "-":   SS = "PuceRouge";  S = "Nouveau document (" + FormatDate(nod.DatMaj) + ")";  break
				case "maj": SS = "PuceOr";  S += "\nmodifié le " + FormatDate(nod.DatMaj);  break
			}
			if (SS)  Li="<IMG SRC='/applis/pack/img/puce/" + SS + ".gif' border=0>";  else  Li=""
			if (!(nod.TypDoc=='M' && SS=="PuceVert"))  TDAp = "<TD Elem=PuceLect style='width:10' title=\"" + S + "\">" + Li + "</TD>"
		}
		if (this.ColorT1) { ParamT = " bgColor=";  ParamT+= (i & 1) ? this.ColorT1 : this.ColorT2 }
		if (nod.DatFin)  Class+= " Archiv"

	  H += "<TABLE class='" + Class + "' width=100% cellpadding=0 cellspacing=0 border=0" + ParamT + ">"
	  H += "<TR id='" + this.Div.id + "_row_" + nod.cl1 + "' Elem=Row cl1='" + nod.cl1 + "' Code='" + nod.Code + "' Lien='" + nod.Lien + "' " + this.Style.addTR + ">\n"
	  H += Space + "\n"
	  S="";  if (nod.Fic)  S="title=\"Lire " + nod.Fic + "\" "
	  SS = ""
	  //SS = (inod.nb) ? " &nbsp;<sup style='font:8pt; color:AAAAAA'>(" + inod.nb + ")</sup>" : ""
	  if (Bug=='1')  SS = ", <font size=1 color=white>(" + nod.DroitFiche + "," + nod.Droit + ")</font>"
	  H += TDIco + TDAv + TDIco2 + CB + "<TD Elem=LibTree " + S + " xvAlign=top style='padding:0 2 0 4'>" + nod.Lib + SS + "</TD>" + TDAp + "\n"
	  H += "</TR></TABLE>\n"

  	if (inod.Ouv)  Ouv="block";  else  Ouv="none"
  	if (this.Look=="Tree") {
		  H += "<DIV ID='" + this.Div.id + "_Div_" + nod.cl1 + "' style='display:" + Ouv + "'>"
		  if (nod.AffNod && nod.AffNod=="Isol")  S="n";  else  S=""
			if (!this.ssNiv && !S)  H += this.DrawTree(inod, Opt)
	   	H += "</DIV>"
	  }
	}
	if (this.Edit) {
	  H += "<TABLE class='" + Class + "' width=100% cellpadding=0 cellspacing=0 border=0 " + ParamT + ">\n"
	  H += "<TR ID='" + this.Div.id + "_row_add" + "' Elem=Row cl1 Lien='" + inodP.nod.Code + "' " + this.Style.addTR + ">\n"
	  H +=  TDIco + TDAv + TDIco2 + CB + "<TD Elem=LibTree style='padding:0 2 0 4'><img src='/applis/pack/img/ico/PlusBlue.gif'>&nbsp;Nouveau menu</TD>\n"
	  H += "</TR></TABLE>\n"
	}
	return H
}

VueObj.prototype.DrawBloc = function (inodP, Opt) {
  var inod, nod, H="", S, i

  nod = inodP.nod
  if (this.THeadIn) {  H = this.THeadIn;  H = Replace(H,"$cl1",nod.cl1);  H = Replace(H,"$Code",nod.Code);  H = Replace(H,"$Lib",nod.Lib) }
	for (var i=0; i<inodP.nb; i++) {
		inod = inodP[i]
		H += DrawBlocNod (this, inod, Opt, this.TBody, true)
	}
  if (this.TFootIn)  H+=this.TFootIn
  return H
}

	function DrawBlocNod (Vue, inod, Opt, HX, SiTree) {
	  var nod, Div, Div2, H="", HX, S, i, n, d, f, Formul, Filtre, Ok

		nod = inod.nod;  if (!nod)  return ""
		Filtre = VarListe(Opt,"Filtre");  if (!Filtre)  Filtre=this.Filtre;  if (!Filtre)  Filtre="true"

		if (eval(Filtre)) {
			Vue.nbAff++
		  HX = Replace(HX,"$RowID", "ID='" + Vue.Div.id + "_row_" + nod.cl1 + "'")
		  HX = Replace(HX,"$cl1",nod.cl1)
		  HX = Replace(HX,"$Code",nod.Code)
		  HX = Replace(HX,"$Lib",nod.Lib)
		  while ((d=HX.indexOf("{"))>=0) {
		  	f = HX.substr(d+1).indexOf("}")
		  	Formul = HX.substr(d+1,f)
				try {  S = eval(Formul)   }catch(e){  S = ""  }
		  	HX = Replace(HX, HX.substr(d,f+2), S)
		  	//if (i==0) alert(d + ", " + f + ", F=" + Formul + ", Res=" + S + ", " + HX.substr(d,f+2))
		  }
			Ok=true
	  }else
	  	Ok = false
	  if (HX.indexOf("$Repeat")>=0) {
	  	if (SiTree && inod.nb) {
	  		S = Vue.DrawBloc(inod, Opt, true);  //alert(inod.nod.Lib + "\n\n" + S + "\n\n" + HX)
	  	}else  S=""
	  	if (Ok)  HX = Replace(HX,"$Repeat",S);  else  HX = S
	  }
	  //if (!SiTree)  alert(nod.Lib + ", " + HX)
	  return HX
	}

VueObj.prototype.DrawCible = function (inodP, DivP, Opt) {
	// Placer dans une cible définie, par ID ou par n° de TR
	var inod, nod, Div, Div2, S, i, n, Tag
	Tag = VarListe(Opt,"Tag")
	Inverse = (VarListe(Opt,"Ordre")=="Inverse")
	S=LX(DivP,"Titre");  if (S) {  D=eval(S);  if (D)  D.innerText = Replace(inodP.nod.Lib,"Site ","")  }

	for (i=0; i<inodP.nb; i++) {
		inod = inodP[i];  nod = inod.nod;  if (!nod)  continue
		if (Inverse)  n=inodP.nb-i-1;  else  n=i
		if (Tag=="TR" && DivP.tagName=="TABLE") {
			if (!i)  for (j=1; j<DivP.rows.length; j++)  DivP.rows[j].cells[0].innerText=""
			if (DivP.rows.length>n)  Div = DivP.rows[n].cells[0]
	  }else{
	  	Div = LID(DivP.id + "_M" + n)
	  }
		if (!Div)  continue
		if (nod.Lib)  Div.innerHTML = nod.Lib;  Div.style.cursor = "pointer"
		inod.CodH = Div
		Div.className = "Btn";  Div.setAttribute("cl1",nod.cl1);  Div.setAttribute("Code",nod.Code);  Div.setAttribute("Elem", "LibTree")
		Div.onmouseover = MenuOver;  Div.onmouseout  = MenuOut
		S = LX(Div,"SuiteEval");  if (S)  Div2 = eval(S)

		this.onFinDrawNod(Div)

		if (Div2)  this.DrawCible(inod, Div2, "Tag=TR")
	}
}

VueObj.prototype.DrawDiv = function(inodP, ElemMod, Dest, DivMod, ElemRepeat, Opt) {
	var Tree, O, OC, nod, Ok, Test, TD, Objs, MajMod, Nb, Filtre, FiltreDraw
	Tree = this.Tree
	if (!ElemMod || !Dest)  return
	if (!DivMod)  DivMod = ElemMod
	MajMod = DivMod.getAttribute("Maj")
	FiltreDraw = VarListe(Opt,"Filtre");  if (!FiltreDraw)  FiltreDraw = this.Filtre;
	Objs = ElemMod.childNodes
		//alert("nb=" + Dest.outerHTML + "\n" + ElemMod.outerHTML)
	for (var i=0; i<Objs.length; i++) {
		O  = Objs[i];  //alert("nb=" + Objs.length + "\n" + O.outerHTML)
		OC = O.cloneNode(false)
		if (O.nodeName=="#text") {
			InsertBef (Dest,OC)			}
		else {
			if (O.getAttribute("Elem")=="DivMenu")  OC.setAttribute("Model", O.parentNode.getAttribute("id"))
			inod = inodP;  nod = (inod) ? inod.nod : null
			Ok = 1;  Test = OC.getAttribute("Si")
			if (Test) {
				Ok = eval(Test);  //alert("Test=" + Test + ", Ok=" + Ok)
			}
			if (!Ok)  continue

			if (ElemMod.getAttribute("Repeat")) {
				ElemRepeat = OC
				OC.setAttribute("Elem", "LibTree")
				OC.setAttribute("cl1", (nod) ? nod.cl1 : "")
				OC.setAttribute("Code", (nod) ? nod.Code : "")
				OC.setAttribute("Lien", (nod) ? nod.Lien : "")
				//NewDest.onclick     = MenuClic
				OC.onmouseover = MenuOver
				//OC.onmouseover = new Function (this.Nom + ".onmouseover(this," + nod.Code + ")")
				OC.onmouseout  = MenuOut
				OC.style.cursor = "pointer"
			}

			if (O.getAttribute("Repeat")) {
				if (inodP) {
					Nb = inodP.nb
					for (var j=0; j<Nb; j++) {
						inod = inodP[j];  nod = inod.nod;  if (!nod)  continue
						if (Nb>20)  window.status = j+1
						NewDest = InsertBef (Dest,OC)
						Ok = 1;
						if (FiltreDraw)  Filtre = FiltreDraw;  else  Filtre = nod.Filtre
						if (Filtre) {
							Ok = eval(Filtre);
						  //if (this.Nom=='VueTree')  alert(Filtre + ", " + Ok + ", " + nod.Lib + ", " + nod.TypDoc)
						}
						if (Ok) {
							this.DrawDiv (inod, O, NewDest, DivMod, ElemRepeat, Opt)
							if (!this.nbAff)  this.Sel = inod
							this.nbAff++
						}
					}
				}
				if (MajMod && MajMod.indexOf("+")>=0) {
					NewDest = InsertBef (Dest,OC);  //alert(NewDest.outerHTML + "\n" + O.outerHTML)
					this.DrawDiv (null, O, NewDest, DivMod, ElemRepeat, Opt)
				}
			}else {
				NewDest = InsertBef (Dest,OC);
				this.DrawDiv (inod, O, NewDest, DivMod, ElemRepeat, Opt)
			}

			if ((S = OC.getAttribute("Champ"))) {
				inod.CodH = ElemRepeat
				if (nod)  OC.innerHTML = (nod[S]) ? nod[S] : ""
				this.onFinDrawNod(OC)
			}
			if ((S = OC.getAttribute("AttrChamp")) && nod) {
				var tl = S.split("|")
				if (tl.length==2) {
					S = ReplaceVar(tl[1],inod);  //alert(S + ", " + tl[1] + ", " + nod.Code)
					OC.setAttribute(tl[0],S)
				}
			}
		}
	}
	if (LID("DivBug"))  DivBug.innerHTML=""
}

VueObj.prototype.InitMenuIco = function() {
	inod = this.RootTree
	if (LX(this.Div,"TypTree")!="Integre" || !inod.nb || !LID("MenuContext"))  return

	this.ListTree = new ListNodObj()
	this.ListTree.Add ('1',  "ListTree");
  //S = this.RootTree.nod.Chemin;  if (S)
  this.ListTree.Add ("Ident", "Changer d'identifiant", "Lien=1|Action=Ident|Ouv=1")
  if (Proj=="D25")
	  this.ListTree.Add ("Archiv", "Voir Archives", "Lien=1|Action=Archiv|Ouv=1")
	else {
	  this.ListTree.Add ("Retour", "Retour", "Lien=1|Action=GoRoot|Ouv=1")
	  //this.ListTree.Add ("Config", "Configuration", "Lien=1|Action=Config|Ouv=1")
	  this.ListTree.Add ("Explor", "Explorateur", "Lien=1|Action=Explor|Ouv=1")
	}
  //this.ListTree.Add ("Niv1", "Afficher tous niveaux", "Lien=1|Action=Niv1|Ouv=1")
	//for (var i=0; i<inod.nb; i++) {  inoD = inod[i];  if (inoD)  this.ListTree.Add (inoD.nod.Cle, inoD.nod.Lib, "Lien=1|Action=GoFam|Ouv=1") }
	this.FamTree = new TreeObj('FamTree', this.ListTree, 0)
	this.MenuIco = new VueObj("MenuIco", "MenuContext", this.FamTree, "Look=Div", "ModelMenuV")
	this.MenuIco.NomDom = this.Nom + "~MenuIco"
	this.MenuIco.VueParent = this
}

VueObj.prototype.MenuIcoDraw = function() {
  if (this.MenuIco)  this.MenuIco.Draw("Root=1;Pos=Mouse")
}

VueObj.prototype.Ouvrir = function(inod) {
	var nod, TR, TD
	while(inod) {
		nod = inod.nod
		TR = inod.DivRow(this.Div.id);  if (!TR)  return
			//alert(inod.Ouv + ", " + TR.outerHTML)
		if (!inod.Ouv)  if ((TD=ElemIn(TR, "LX(O,'Elem')=='IcoTree'")))  TD.click()
		inod = inod.Parent
	}
}

VueObj.prototype.Check = function(Operations) {
	var Rep, L1="", L2="", nod, inod, cl1
	ListChk = this.Div.all.tags("INPUT")
	var T = Operations.split(";");  NbOp = T.length;  if (!NbOp)  return
	for (i=0; i<ListChk.length; i++) {
		O = ListChk[i];  TD = O.parentNode;  TR = TD.parentNode
		Code = LX(TR,"Code");  inod = this.Tree[Code];  nod = inod.nod;	 //alert(O.type + ", Code=" + Code + "\n" + O.outerHTML)
		if (O.type=="checkbox" && TD.tagName=="TD") {
			for (j=0; j<NbOp; j++) {
				Op = Isole(T[j],":",1);  M2 = Isole(T[j],":",2)
			  switch (Op) {
			  	case "Aff":
			  	  if (M2=="none")  this.SiCoche = false;  else  this.SiCoche = true;
			  	  O.parentNode.style.display = M2;  break
			  	case "Init":   O.checked = nod.Coche;  break
			  	case "SelOn":  if (this.On.nod.Code==Code)  {  O.checked = true;  nod.Coche = true;  }  break
			  }
			}
	  }
	}
	return Rep
}

VueObj.prototype.Clic = function(O) {
	var Code, ind, inod, nod, ElemClic, Vue
	inod = this.Sel;  nod = inod.nod;  //alert(this.Nom + ".Clic " + nod.Code + ", "  + nod.Lib + ", " + O)
	if (typeof(O)=="string")
	  Quoi = O
	else if (O) {
   	if (O.tagName=="INPUT" && O.type=="checkbox") {
      this.Sel.nod.Coche = O.checked;  Quoi="checkbox"
		}else {
	 	  var ElemClic = ElemPAt(O,"Elem")
		  Quoi = LX(ElemClic,"Elem")
		}
	}else{
	  Quoi="LibTree"
  }
    //alert(this.Nom + " " + Quoi)
 	switch (Quoi) {
    case "BackTree":
    	if (this.Trees.length>1) {
    		this.PopTree()
    		this.Draw()
    	}
    	break

    case "IcoTree":
			if (this.ready && this.ssNiv=="n" && nod.TypDoc=="M")  { this.Draw("Root=" + nod.Code);  return; }
		 	var Div  = document.all(this.Div.id + "_Div_" + nod.cl1);  if (!Div)  return
		 	  //alert(nod.Code + ", " + "\n\n" + Div.outerHTML)
		 	if (inod.nb==0) {  if (inod.Clic)  inod.Clic("Lib");  return;  }
		 	if (inod.Ouv) {
		 		Div.style.display="none";   Ico = this.TreeConf.Close
		 	}else{
		 		Div.style.display="block";  Ico = this.TreeConf.Open
		 	}
		 	inod.Ouv=!inod.Ouv
		 	var TD = ElemFils(Div.previousSibling,"O.getAttribute('Elem')=='IcoTree'");  if (TD)  LTags(TD,"IMG")[0].src = Ico.I.src
      break

    case "LibTree":
			if (this.ready && nod.TypDoc=="M" && (this.ssNiv=="n" || (nod.AffNod && nod.AffNod=="Isol"))) {
				if (this.SuiteTree)  Vue = this.SuiteTree;  else  Vue = this
				Vue.PushTree(Vue.Tree, inod)
				Vue.Draw()
				if (this.SuiteTree && !Vue.nbAff && !Vue.Edit)  Hide(Vue.Div)
			}
			var VueP = this.VueParent;  nod = this.Sel.nod
		  if (nod.Action && VueP) {
		  	  //alert(nod.Action)
		  	switch(nod.Action) {
		  		//case "GoFam":   VueP.TypLook = "Niv2";  VueP.RootAff = VueP.Tree[nod.Code];  VueP.Draw();  break
		  		case "GoRoot":
		  		  if (VueP.TreeInit) { VueP.SetTree (VueP.TreeInit);  VueP.TreeInit = null;  VueP.Draw();  return  }
		  		  S = VueP.RootTree.nod.Chemin;  if (!S)  return;
		  		  nod = VueP.Tree.ListNod.all[parseInt(S.substring(1))]
		  		  GoMenuSite(nod)
		  		  break
		  		case "GoSite":  window.open (CheminSite("Web"));  break
		  		case "Archiv":
		  			//document.location = document.location.href + "&Archiv=o";
						location = MajListe(location.href, "Archiv", "o", "&", "=", true, "n")
						break
		  		case "Ident":  document.location = "/sites/i2g/ident.aspx?" + AjUrl + "&Page=" + escape(document.location.href);  break
		  		//case "Niv1":  if (VueP.TypLook=="Niv1") { VueP.TypLook = "Niv2" }else{ VueP.TypLook = "Niv1";  VueP.RootAff = VueP.Tree.RootAff };  VueP.Draw();  break
		  	}
			}
      break

    default:  break
 	}
 	if (Quoi) {
 		this.ClicAction(O, Quoi)
 		this.ClicVue(O, Quoi)
 	}
}

VueObj.prototype.ClicOut = function(O) {
	var TR, V
	TR=ElemPAt(O,"Elem","Row")
	//alert(Lout(TR))
	if (!LX(TR,"Code") && this.SuiteTree) {  //Clic sur TR Nouveau Menu
		V = this.SuiteTree
		while (V && SiAff(V.Div)) {
			Hide(V.Div)
			V = V.SuiteTree
		}
	}
	this.ClicOutTree(O)
}

VueObj.prototype.OnMouseSel = function(inod) {
	var TD = GetElemTree(this, inod, "LibTree");  if (!TD) return
	TD.style.backgroundColor = this.TreeConf.BackgroundSelOn
}

VueObj.prototype.OnMouseSelOff = function() {
	var inod = this.Sel
	var TD = GetElemTree(this, inod, "LibTree")
	if (TD)  TD.style.backgroundColor=""
}

VueObj.prototype.MouseMove = function(O) {
	var ind, inod, nod, ElemClic
	inod = this.On;  nod = inod.nod
	if (typeof(O)=="string")
	  Quoi = O
	else if (O) {
 	  var ElemClic = ElemPAt(O,"Elem")
	  Quoi = LX(ElemClic,"Elem")
	}else{
	  Quoi="LibTree"
  }
    //alert(this.Nom + " " + Quoi)
 	switch (Quoi) {
    case "LibTree":  this.OnMouseOn(inod);  break
  }
}

VueObj.prototype.OnMouseOn = function(inod) {
	var TD = GetElemTree(this, inod, "LibTree")
	if (TD)  TD.style.textDecoration="underline"
	//alert(inod.nod.Lib + ", " + Lout(TD))
}

VueObj.prototype.OnMouseOut = function() {
	var inod = this.On
	var TD = GetElemTree(this, inod, "LibTree")
	if (TD)  TD.style.textDecoration="none"
}

function GetElemTree(Vue, inod, Elem) {
	if (!inod)  return
	TR = inod.DivRow(Vue.Div.id);  if (!TR)  return
	return ElemIn(TR, "LX(O,'Elem')=='" + Elem + "'")
}

VueObj.prototype.ClicDElem = function(O) {
	var Code, ind, nod
	//alert(this.On.nod.Code)
  TR = ElemPAt(O,"Code")
 	if (TR) {
   	Code = LX(TR,"Code");  if (Code)  inod = Vue.Tree[Code]
   	if (inod) {
   		Vue.On = inod
		}
	}
	this.ClicDAction()
}

function CalcVue(Obj, e, Pars) {
  //if (document.all)  e = event
  Pars.O = (ie) ? window.event.srcElement : e.target;  //alert(Pars.O.outerHTML + "\n" + Obj.outerHTML)
  try {
	  return eval(Replace(LX(Obj,"NomVue"),"~","."))
	}catch(e){}
}


/*  ====================================================             Evénements          ================================  */
function VueClic(e) {
	var cl1, Code, inod, TR, TD, O, A, N, S, inodP, inod, Pars={O:null}
	Vue = CalcVue(this, e, Pars);  O=Pars.O;  if (!Vue)  return
	Vue.OnMouseSelOff()
  TR = ElemPAt(O,"Code");  Code = LX(TR,"Code");  Lien = LX(TR,"Lien")
 	if (Code)  inod = Vue.Tree.ids[Lien + "_" + Code]
		//alert("VueClic: " + Lout(O) + "\n\n" + Lout(O.parentNode) + "\n\n" + Lout(TR))

 	if (Vue.Edit) {
	  var obj = event.srcElement
	 	if (Layers.length>0) 	Layers[0].ClearAll()
	 	if ((A=ElemPAt(obj,"Elem","LibTree"))) {
	 		S = "Vue=" + Vue.Nom + ";TR=" + LX(TR,"id") + ";Code=" + Code + ";Lien=" + Lien;  //alert(S + "\n\n" + Lout(TR))
		 	A = new Layer(A, S)
	 		inodP = Vue.Tree[Lien]
		 	A.Vue = Vue
		 	A.inodP = inodP;  A.inod = inod
		}
	 	AnnulEvent(e)
	 	//return
	}

 	if (TR) {
   	if (inod) {
   	  //alert("VueClic: " + Code + ", " + inod.nod.cl1 + ", "  + inod.nod.Code + ", "  + inod.nod.Lib + "\n\n" + Lout(TR))
   		Vue.Sel = Vue.On = inod
			Vue.OnMouseSel(inod)
		  Vue.Clic(O)
   	}else{
   		Vue.ClicOut(O)
  	}
	}
}

function VueMouseMove(e) {
	var Code, inod, TR, TD, O, N, Pars={O:null}

	Vue = CalcVue(this, e, Pars);  O=Pars.O;  if (!Vue)  return
	Vue.OnMouseOut()
  TR = ElemPAt(O,"Code")
 	if (TR) {
   	Code = LX(TR,"Code");  if (Code)  inod = Vue.Tree[Code]
   	  //alert("VueMouseMove : " + Code + ", " + inod.nod.Code + ", "  + inod.nod.Lib)
   	if (inod) {
   		Vue.On = inod
		  Vue.MouseMove(O)
   	}
	}
}

function VueClicD(e) {
	var inod, TR, TD, O, Pars={O:null}
	Vue = CalcVue(this, e, Pars);  O=Pars.O;  //alert(Vue.Nom)
 	Vue.ClicDElem(O)
  AnnulEvent(e, true)
}

VueObj.prototype.onmouseover = function(e, Code) {
  if (document.all) { e = event;  O = e.srcElement;  Ofrom = e.fromElement;  }  else  {  O=e;  /*Ofrom = e.relatedTarget;*/  }
	alert(O.innerHTML)
}

function MenuOver(e) {
	var Code, D, S, T, M, inod, Model, NomClass, Pars={O:null}
  if (document.all)  e = event
  var Obj = ElemPAt(this, "Objet", "Tree");  if (!Obj)  return
 	var Vue = Eval(Replace(LX(Obj,"NomVue"),"~","."));  if (!Vue)  return

 	var Css = ElemPAt(this,"NomClass");  NomClass = LX(Css,"NomClass");  if (!NomClass)  NomClass="";  else  NomClass+="_"
 	var Men = ElemPAt(this,"Elem", "DivMenu");  //alert(Men.outerHTML)
 	var Elm = ElemParent(this,"O.className=='" + NomClass + "Menu'");  if (Elm)  Elm.className = NomClass + "MenuOver"

 	Code = this.getAttribute("Code")
 	e.cancelBubble = true
 	var inod = Vue.Tree[Code];  if (!inod || inod.nb==0 || !Men) { return; }
    //wb ("MenuOver")

 	NomMod = Men.getAttribute("Model");  if (NomMod)  Model = LID(NomMod);  else  Model = null
 	var Men2 = ElemPAt(this,"MenuSuiv")
  if (Men2)  var NomMenu = Men2.getAttribute("MenuSuiv")
  if (NomMenu)  M = LID(NomMenu);  else  M = Model;  if (!M) return;   //wb(NomMod + ", " + NomMenu + ", " + M.outerHTML.substr(0,50))
  NomMenu = LX(M,"id")
  var ID = NomMenu

  if (LX(M,"Duplic")) {
  	ID = NomMenu + "_" + inod.nod.Code;
      //alert(ID + ", " + inod.Niv + "\n" + M.outerHTML)
  	var D = LID(ID);
  	var DP = LID(NomMenu + "_" + inod.Parent.nod.Code)
  	if (D) {
  		if (D.getAttribute("Lien")==Code) { e.cancelBubble = true;  return; }
  	}
    else {
  		var O = M.cloneNode(false)
  		P = this;  if (P.tagName=="TR")  P = this.childNodes[0]
	    D = InsertBef (P,O)
      D.setAttribute("id", ID);  this.setAttribute("MenuF", ID)
        //alert(ID + ", " + inod.Niv + "\n" + P.outerHTML + "\n" + D.outerHTML)
      D.setAttribute("Lien", Code)
      D.setAttribute("ModelBase", NomMenu)
    }
  }
 	if (!D)  D = LID(ID);
  D.style.position = "absolute";  D.style.zIndex = 2
  var niv = inod.Niv - Vue.RootTree.Niv
  var Horiz = LX(M,"Horiz");  if (!Horiz)  Horiz=2;    //alert(Vue.RootTree.nod.Lib + ", " + niv + ", " + inod.Niv + ", " + (niv<Horiz) + "\n" + M.outerHTML)
  if (niv<Horiz) {
	  D.style.width  = this.offsetWidth
	  if (!DP)  DP = Obj
  	if (DP.style.position=="absolute") {
		  D.style.top  = this.offsetHeight -1
		  D.style.left = this.offsetLeft;
		}else{
		  D.style.top  = GetPos(this,"Top") + this.offsetHeight - 1
	  	D.style.left = GetPos(this,"Left")
			//wb("top=" + D.style.top + ", left=" + D.style.left + DP.outerHTML)
		}
	}
  else {
	  D.style.top = this.offsetTop - 1 //+ parseInt(Obj.style.paddingTop) : plante si pas de top
	  var oW = this.offsetWidth //+ parseInt(Obj.style.paddingLeft)
	  var Wmax = GetPos(this,"Left") + oW + oW
	  if (Wmax > document.body.scrollWidth)  oW=oW*-1 + 2
	    //wb("oW=" + oW + ", GetLeft=" + GetPos(this,"Left") + ", docW=" + document.body.scrollWidth + ", Wmax=" + Wmax)
	  D.style.left  = oW
	  D.style.width = this.offsetWidth
	}
  Vue.Draw("Root=" + Code + ";Look=Div;Dest=" + ID + ";Model=" + NomMenu)
}

function MenuOut(e) {
	var CodTor, nod, Vue, S, T, MenuP, O, oTarget, Men, Css, NomClass
  if (document.all) {
  	e=event;  X = event.x;  Y = event.y
  	O = e.srcElement;  oTarget = e.toElement
  	//alert(Contains(oTarget,O) + ", " + Contains(O,oTarget) + "\n\n" + O.outerHTML + "\n\n" + oTarget.outerHTML)
  }else{
    X = e.pageX;  Y = e.pageY;  oTarget = e.relatedTarget;
  }
 	Css = ElemPAt(this,"NomClass");  NomClass = LX(Css,"NomClass");  if (!NomClass)  NomClass="";  else  NomClass+="_"
 	Men = ElemPAt(this,"Code");  //alert(Men.outerHTML)
  if (Contains(Men,oTarget)) { e.cancelBubble = true;  return  }    //wb ("MenuOut")
 	var Elm = ElemParent(this,"O.className=='" + NomClass + "MenuOver'");  if (Elm)  Elm.className = NomClass + "Menu"

  var NomMenu = this.getAttribute("MenuF")  //wb("QUITTE " + NomMenu + "(" + this.getAttribute("Code") + ")\n" + this.outerHTML + "[BR]")
  if (NomMenu) var M = LID(NomMenu);  if (M) RMNod(M);

 	Men = ElemPAt(this,"Elem", "DivMenu")
 	if (Men) {
	 	var Mod = ElemPAt(this,"ModelBase")
	 	if (!Mod) {
	    	//wb(oTarget.outerHTML + "[BR]" + Contains(Men, oTarget, true) + "[BR]")
	    if (LX(Men,"Permanent")=="N" && (!oTarget || !Contains(Men, oTarget, true))) {
	    	//if (Men.id)  setTimeout("SupprNod(" + Men.id + ")",100);  else  Men.removeNode (true)
	    	RMNod(Men)
	    }
	 	}
 	}
}



/*
 * ====================================================             NODE  Objet           ================================
 */
function INodObj (nod) {
	this.nod  = nod
	this.Parent = null
	this.Tree   = null
  this.nb   = 0
  this.all  = {}
  this.Niv  = 0
  this.Ouv  = true
  this.IParent = IParent
}

INodObj.prototype.Add = function(nod) {
	var Code, inod
  Code = nod.Code
	if (this.all[Code]) {
    inod = this.all[Code]
  }else{
	  this[this.nb] = inod = new INodObj(nod)
	  this.all[Code] = inod
	  this.all[Code].Index = this.nb
	  this.Tree[Code] = inod
	  this.nb++
	  this.Tree.nb++
	}
  inod.Parent = this
	inod.Tree = this.Tree
	inod.Tree.ids[nod.Lien + "_" + Code] = inod
  inod.Ouv  = inod.nod.Ouv
  inod.Niv  = this.Niv + 1
  return inod
}

INodObj.prototype.Make = function() {
	var inod, nod, T, Code, CleNew, i, j, Filtre, Lien
	//alert(aa)
	var Tree = this.Tree
	var ListNod = Tree.ListNod
	Filtre = Tree.Filtre
  Code = this.nod.Code
    //alert("C=" + Code + ", " + ListNod.nb)
	for (i=0; i<ListNod.nb; i++) {
		nod = ListNod[i]
		if (Filtre && !eval(Filtre))  continue
		Lien = nod.Lien + "";  if (!Lien)  Lien = Tree.Racine.nod.Code + ""
		T = Lien.split(",")
		CleNew = nod.Code
		for (j=0; j<T.length; j++) {
			if (nod && Code==T[j] && CleNew!=Code) {
				inod = this.Add(nod)
	      inod.Make()
			}
		}
	}
}

INodObj.prototype.Init = function(AFaire, Test, AvecPere, NotIn) {
	// inod.Init("App.FicSuppr+=inod.AdTree()+';'", "nod.Coche", true) place dans App.FicSuppr ttes les clés des nod ayant un Op
	// inod.Init("nod.Coche=true", "nod.Op=='<'", true)
	// inod.Init("App.NbDoc++", "nod.TypDoc!='M'", false, true)  compte le nb de doc
	var inod, ind, nd, S
	//if (In==undefined)  In = true
	if (!Test)  Test = "true"
	if (AvecPere)  InitExec(this, AFaire, Test)

	for (var i=0; i<this.nb; i++) {
		inod = this[i]
		//InitExec(inod, AFaire, Test)
		//if (inod.nb)
		if (!AvecPere)  InitExec(inod, AFaire, Test)
		if (!NotIn)  inod.Init(AFaire, Test, AvecPere, NotIn)
	}

	function InitExec(inod, AFaire, Test) {
		var nod, Code, Code, Lien, TypP, TypNiv, Lib
		nod = inod.nod
		Code = nod.Code;  Code = nod.Code;  Lib = nod.Lib;  Lien = nod.Lien;  TypP = nod.TypP
		if (eval(Test)) {
			if (inod.Tree.nbInit!=undefined)  inod.Tree.nbInit++
			eval(AFaire)
		}
	}
	return this.Tree.nbInit
}

INodObj.prototype.Rech = function(Test, AvecFils) {
	var nod, nd, Code, Lien, TypP, TypNiv, Lib
	for (var i=0; i<this.nb && !nd; i++) {
		inod = this[i];  nod = inod.nod
		Code = nod.Code;  Lib = nod.Lib;  Lien = nod.Lien;  TypP = nod.TypP;  TypNiv = nod.TypNiv
		//if (Test=="nod.TypDoc=='M'")  alert(Code + ", " + Lib + ", " + nod.TypDoc + ", " + eval(Test))
		if (eval(Test))  nd = inod;
		else if (AvecFils)  nd = inod.Rech(Test, AvecFils)
	}
	return nd
}

INodObj.prototype.RechPath = function(Path, Champ, Exec, Param) {
	var inod, ind, nod, T, i, R, Lib, List, Test, SiAdd
	var T = Path.split("/")
	inod	= this;  nod = inod.nod
	Test	= VarListe(Param,"Test");  if (!Test)  Test="true"
	SiAdd	= VarListe(Param,"SiAdd")
	if (Exec && eval(Test))  eval(Exec)
	for (i=0; i<T.length; i++) {
		Lib = T[i]
		ind = inod.Rech('Lib=="' + Lib + '"')
		if (!ind) {
			if (!SiAdd)  return null
			// Ajout d'un nod manquant
			List = inod.Tree.ListNod
			nod = List.Add(List.nb+1, Lib, "Lien=" + inod.nod.Code + "|TypDoc='M'")
			ind = inod.Add(nod)
		}
		inod = ind;  nod = inod.nod
		if (Exec && eval(Test)) {
			eval(Exec)
			//alert(Lib + ", " + Exec + ", " + nod.Lib)
		}
	}
	nod = inod.nod
	if (!Champ)  return inod
	else{
	  R = null
		if (nod[Champ])  R = nod[Champ];  else  R = inod[Champ]
	}
	return R
}

INodObj.prototype.DivRow = function(NomDiv) {
	if (!NomDiv)  NomDiv = this.Tree.Nom
  return document.getElementById(NomDiv + "_row_" + this.nod.cl1)
}

INodObj.prototype.OrderInod = function(CleS, CleD) {
	var ns, nd, i, Changt="", nod, inos, Sens
	//alert(CleS + "\n\n" + CleD + aa)
	ns = this.all[CleS].Index;  nd = this.all[CleD].Index
	Sens = (ns>nd) ? -1:1
	inos = this[ns]
	for (i=ns; (ns>nd) ? (i>nd):(i<nd); i+=Sens) {
		this[i] = this[i+Sens];  nod = this[i].nod
		this[i].Index = i
		nod.Rang = i+1
		Changt += "*Code=" + nod.Code + ";Rang=" + nod.Rang + "|"
	}
	this[nd] = inos;  nod = inos.nod
	this[nd].Index = nd
	nod.Rang = nd+1
	Changt += "*Code=" + nod.Code + ";Rang=" + nod.Rang
	return Changt
}

INodObj.prototype.SupprChilds = function() {
  for (var i=0; i<this.nb; i++) {
  	this[i].SupprChilds();  //alert("SupprChilds(" & + this[i].nod.Code + ", " + this[i].nod.Lib)
		this.all[this.nod.Code] = null
	  this[i] = null
  }
	this.nb = 0
}

INodObj.prototype.AdTree = function(AvecRoot) {
	return AddStr(this.PathTree(AvecRoot), this.nod.NomFic, "/")
}

INodObj.prototype.PathTree = function(AvecRoot) {
	var inodP, nod, nd, Ad="", RepLie="", Pat, S, l, Code, App
	App = this.Tree.App
	inodP = this.Parent
	nod = this.nod
  if (nod.FicLie) RepLie = FicPartie(inodP.nod.NomFic,"RepLie")
  //alert(aa)

	if (App.Source=="Fiche") {
	  Dest = AddStr(App.PathDoc, RepLie, "/")
		return Dest
	}

	if (this.Tree.ModeRangt=="Path") {
		if (nod.FicLie)  inodP = inodP.Parent
		Pat = App.PathDoc;
		if (inodP) {
			Ad = Isole(inodP.IParent("Dest"),";",1)
			S = Right(Pat, 1, "/");  l = S.length;  if (S==Ad.substr(0,l))  Ad=Ad.substr(l)
		}
	}else{
		if (AvecRoot) {
			Ad  = App.PathDoc
			Code = nod.Code
			if (nod.CleCalc) {
			 	nd = nod.RechParent("!nod.CleCalc")
			 	if (nd)  Code = nd.Code;  else  Code = null
			}
			if (!Code)  Code = this.Tree.CodRoot
			if (Code)  Ad = AddStr(Ad, Code, "/");  else  return ""
		}
	}
	Ad = AddStr(Pat, Ad, "/")
	Ad = AddStr(Ad, RepLie, "/")
	return Ad
}

function IParent(Action, ParentNod, Opt, Exec) {
	var Li="", Lib, Lig, S, SS, inod, sinod, nod, i, Niv, Test, TestFin, TestFinDeb
	var Ok, SiMenu, SiRootNiv, OutRootNiv
	if (!ParentNod)  ParentNod = this.Tree.RootAff;
	inod = this
  Niv = VarListe(Opt,"Niv");  Test = VarListe(Opt,"Test");  TestFin = VarListe(Opt,"TestFin");  TestFinDeb = VarListe(Opt,"TestFinDeb")
  do {
  	nod = inod.nod;  Lib = nod.Lib;  //if (Action=="DossSite")  alert(nod.Code + ", " + Lib + ", " + inod.Niv);
  	SiMenu = (nod.TypDoc=="M")
  	SiRootNiv = (nod.TypNiv=="0" && SiMenu);  if (SiRootNiv)  OutRootNiv = true
  	if (TestFinDeb) if (eval(TestFinDeb))  break
  	switch(Action) {
  		case "Niv":  			if (inod.Niv==Niv)  return inod;  break
  		case "RootNiv":		if (SiRootNiv)  return inod;  break
  		case "inod":			if (eval(Test))  return inod;  break
  		case "TypNiv0":		if (nod.TypNiv=="0")  return nod.TypP;  break
  		case "Chemin":		Li = AddStr(nod.Code, Li, "/");  break
  		case "ChaineTree":
  		  if (Test)  Ok = eval(Test);  else  Ok = true
  		  if (Ok)  Li = AddStr(Lib, Li, "/")
  		  break
  		case "ChaineLien":
  		  if (Test)  Ok = eval(Test);  else  Ok = true
  		  if (Ok)  Li = AddStr("<A href='javascript:GoLien(" + nod.Code + ")'>" + Lib + "</A>", Li, "&nbsp;>&nbsp;")
  		  break
  		case "Dest":
		  	if (this.Tree.VersionBD>1.11)  S = nod.Info;  else  S = nod.AdrWeb
				if (!Lig && !S)  Li = AddStr(Lib, Li, "/")
				if (S) {
					Lig = AddStr(S, Lig, "/")
					if (Lig.substr(0,1)=="/")  TestFin="true"
				}
  		  break
  		case "ChaineTyp":   Li = AddStr(((nod.TypP && nod.TypNiv==0) ? nod.TypP : ""), Li, "/");	break
  		case "DossSite":
		  	if (this.Tree.VersionBD>1.1)  S = nod.Info;  else  S = nod.AdrWeb
		  	SS = S
		  	if (!S)  S = Lib
		  	else {
		  		if (nod.TypP=="SIT")  return S
		  	}
		  	Li = AddStr(S, Li, "/");  //alert("Li=" + Li)
		  	if (SS)  return Li
  		  break
  		case "PathDocAval":   // chaine avant le site
  			if (nod.TypNiv=="0" && nod.TypDoc=="M")  return  Li
  		  Li = AddStr(Lib, Li, "/")
  		  break
  		case "PathDoc":       // racine Doc + avant le site
  			if (nod.TypNiv=="0" && nod.TypDoc=="M")  return  "doc/" + nod.Code + "/" + Li
  		  Li = AddStr(Lib, Li, "/")
  		  break
  		case "PathSite":
  		  Li = AddStr(this.Tree.RootAff.IParent("DossSite", ParentNod), this.IParent("PathDoc", ParentNod), "/")
  		  return Li
  		  break
  		default:
  			// ex : inod.IParent("nod.Form", null, null, "nod.Form"))
	  		if (Action && eval(Action)) {
	  			if (Exec)  return eval(Exec)
	  			else return inod
	  		}
  	}
  	if (Exec) {
  		if (typeof(Exec)=="function")  Exec(inod)
  		else  eval(Exec)
  	}
  	if (TestFin)  if (eval(TestFin))  break
  	sinod = inod;  inod = inod.Parent
  }while (inod && sinod!=ParentNod)
  if (Action=="Chemin" && Li!="")  Li="/" + Li
  if (Lig)  Li += ";" + Lig
  return Li
}

INodObj.prototype.toXml = function() {
	var O, V, H="", avt="", i
	Niv = this.Niv;  for (i=0; i<Niv; i++)  avt+= "    "
	H+= avt + "<N"
	H+= NodtoXml(this.nod, "", this.Niv, "Index,")
	H+= NodtoXml(this, "", this.Niv, "Index,")
	if (!this.nb)
		H+= "/>\n"
  else {
		H+= ">\n"
		for (var i=0; i<this.nb; i++) {
		  H+= this[i].toXml()
	  }
	  H+= avt + "</N>\n"
	}
  return H
}


// ====================================      D I V E R S        ===============================
function MenuContains(O,X,Y) {
	if (ContainsXY(O,X,Y))  return 1
	F = MenuFils(O);
 	/*if (!F) {  M = ElemFils(O,"O.getAttribute('MenuF')");  F = MenuFils(M);	}*/
	if (F)  return MenuContains(F,X,Y);
}

function MenuFils(O) {
	var NomMenu = O.getAttribute("MenuF")
  if (NomMenu) var M = LID(NomMenu);
  return M
}


