//function GetTreeData(AURL){ // var Request = new ActiveXObject('Microsoft.XMLHTTP'); // Request.open('GET', AURL, false); // Request.setRequestHeader('Accept','*/*'); // Request.setRequestHeader('Cache-Control', 'no-cache'); // Request.send(null); // var Rows = Request.responseText.split("\n"); // var DataRows = new Array(); // for(var I in Rows) // DataRows[I] = unescape(Rows[I]).split("|"); // return DataRows; //} function GetTreeData(AURL){ var Request = false; /*@cc_on @*/ /*@if (@_jscript_version >= 5) // JScript gives us Conditional compilation, we can cope with old IE versions. // and security blocked creation of the objects. try { Request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { Request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { Request = false; } } @end @*/ if (!Request && (typeof(XMLHttpRequest) != 'undefined')){ Request = new XMLHttpRequest(); } Request.open('GET', AURL, false); Request.setRequestHeader('Accept','*/*'); Request.setRequestHeader('Cache-Control', 'no-cache'); Request.send(null); var Rows = Request.responseText.split("\n"); var DataRows = new Array(); for(var I in Rows) DataRows[I] = unescape(Rows[I]).split("|"); return DataRows; } function ExpandTree(AID, ATree, AImage, APadding) { Padding = APadding + 20; var ImageID = 'img_'+AID; for (I=0;I < document.images.length;I++) { if (document.images[I].Id == ImageID) { AImage = document.images[I]; } } var Children = document.getElementById("Child_" + AID); if(Children == null) { var Children = ATree.Build(AID, "ChildCell_" + AID, Padding); } else { if(Children.style.display=="none") { AImage.src = "img/minus.gif"; Children.style.display="block"; } else { AImage.src = "img/plus.gif"; Children.style.display="none"; } } } function TreeView(ADataURL, AIDIndex, ADataIndex, AHasChildIndex) { this.URL = ADataURL; this.IdIdx = AIDIndex; this.DataIdx = ADataIndex; this.HasChildIdx = AHasChildIndex; this.Build = function(AParentID, AParentElementID, APadding){ Parent = document.getElementById(AParentElementID); var Table = document.createElement('table'); Table.id = "Child_" + AParentID; Parent.appendChild(Table); var TreeData = GetTreeData(this.URL.replace(/%parent%/, AParentID)); var TBody = document.createElement('tbody'); TBody.id = "TBody_" + AParentID; Table.appendChild(TBody); Table.border = 0; Table.width = 200; Table.cellSpacing = 0; Table.cellPadding = 0; for (var I in TreeData){ var TR_line = document.createElement('tr'); TBody.appendChild(TR_line); var TD_line = document.createElement('td'); TD_line.innerHTML = "\"\""; TR_line.appendChild(TD_line); var Row = document.createElement('tr'); TBody.appendChild(Row); var Cel1 = document.createElement('td'); var A = document.createElement('a'); Cel1.style.textAlign = "Left"; Cel1.style.padding = "0 0 0 " + APadding; Row.appendChild(Cel1); A.setAttribute('id', 'cel_'+TreeData[I][this.IdIdx]); A.style.cursor = 'hand'; A.className = "dop_m"; A.innerHTML = TreeData[I][this.DataIdx]; Cel1.appendChild(A); var HasChildren = TreeData[I][this.HasChildIdx]; // var Img = document.createElement('img'); // Cel1.appendChild(Img); // Img.src = 'img//plus.gif'; if(HasChildren=='1') { A.NodeID = TreeData[I][this.IdIdx]; A.Id = 'cel_'+A.NodeID; A.Name = A.NodeID; A.Tree = this; A.href = "javascript:var a = document.getElementById('" + A.id + "'); ExpandTree(a.NodeID, a.Tree, a, " + APadding + ")"; // Img.NodeID = TreeData[I][this.IdIdx]; // Img.Id = 'img_'+Img.NodeID; // Img.Name = 'img_'+Img.NodeID; // Img.src = 'Plus.gif'; Row = document.createElement('tr'); TBody.appendChild(Row); Cel1 = document.createElement('td'); Cel1.id = 'ChildCell_' + TreeData[I][this.IdIdx]; Row.appendChild(Cel1); } else { // Img.style.visibility = 'hidden'; A.href = 'cat.php?cat_id='+TreeData[I][this.IdIdx]; } } return TBody.id; } this.Exp = function() { var TreeData_ = GetTreeData(this.URL.replace(/%parent%/, this.IdIdx)); for (var I in TreeData_) { var HasChildren = TreeData_[I][this.HasChildIdx]; var IMGID = TreeData_[I][this.IdIdx]; for (K = 0; document.images[K]; K++) { if (document.images[K].NodeID == IMGID) { var Img = document.images[K]; if(HasChildren=='1'){ ExpandTree(Img.NodeID, this, Img); } } } } } }