var Icon = {root:"root.gif",folderopen:"folderopen.gif",folderclosed:"folderclosed.gif",leaf:"folderclosed.gif",Rminus:"Rminus.gif",Rplus:"Rplus.gif",minusbottom:"Lminus.gif",plusbottom:"Lplus.gif",minus:"minus.gif",plus:"plus.gif",join:"T.gif",joinbottom:"L.gif",blank:"blank.gif",line:"I.gif",only:"blank.gif"}
window.zProductTreeBuffer = [];
function zProductTreeLib(MainStyle,MainChangeStyle,ItemStyle,ItemChangeStyle){this.id = window.zProductTreeBuffer.length;window.zProductTreeBuffer[this.id] = this;this.target = "_self";this.showLeaf = true;this.showAll = true;this.Nodes ={ 0 : { ID : 0, ParentID : -1, Text : null, Href : null, Image : null, childNodes: new Array() } };this.showMine = 0;this.PageLocation = "";this.ItemLocation = "";this.mouseOver = MainChangeStyle;this.ItemChangeStyle = ItemChangeStyle;this.ItemStyle = ItemStyle;this.mouseOut = MainStyle;}
zProductTreeLib.prototype.setTarget = function(v) {this.target = v;}
zProductTreeLib.prototype.useLeaf = function(v) {this.showLeaf = v;}
zProductTreeLib.prototype.setShowAll = function(v) {this.showAll = v;}
zProductTreeLib.prototype.setPageLocation = function(v){this.PageLocation = v;}
zProductTreeLib.prototype.setMyDocument = function(v) {this.showMine = v;}
zProductTreeLib.prototype.MainMenuStatus = function(objTD,intStatus,Station) {if(Station==0){if (intStatus == 1) {objTD.className = this.mouseOver;} else {objTD.className = this.mouseOut;}}else{objTD.className = this.mouseOver;}}
zProductTreeLib.prototype.isShow = function(currID,OpenID){if (OpenID != 0){var par = this.getParentNode(OpenID);if (currID == OpenID){return(true);}if (par.ID == 0){return(false);}else{if (this.getNode(par.ID).ParentID != 0){return(this.isShow(currID,par.ID));	}else{if (par.ID == currID){return(true);}}return(false);}return(false);}}
zProductTreeLib.prototype.setImagePath = function(sPath) {for(o in Icon){tmp = sPath + Icon[o];Icon[o] = new Image();Icon[o].src = tmp;}}
zProductTreeLib.prototype.add = function(iD,ParentiD,sText,sHref,sTarget,sImage) {	this.Nodes[iD] = { ID : iD, ParentID : ParentiD, Text : sText, Href : sHref, Target : sTarget, Image : sImage , childNodes: new Array() , open : false ,isLast : true};	var ch = this.getNode(ParentiD).childNodes;	ch[ch.length] = this.Nodes[iD];if (ch.length>1) { ch[ch.length-2].isLast = false;}var CurrUrl = "/"+sHref;var strUrl = CurrUrl.split("/");if (this.PageLocation.toLowerCase() == strUrl[strUrl.length-1].toLowerCase()){	this.setMyDocument(ParentiD);this.ItemLocation = iD;}};
zProductTreeLib.prototype.getNode = function(sKey) {if (typeof this.Nodes[sKey] != "undefined") {return this.Nodes[sKey];}return null;};
zProductTreeLib.prototype.getParentNode = function(ID) {var key = this.getNode(ID).ParentID;if(this.getNode(key) == null) return null;return this.getNode(key);}
zProductTreeLib.prototype.hasChildNodes = function(sKey) {return this.getNode(sKey).childNodes.length > 0;};
zProductTreeLib.prototype.getRoot = function(ID) {var par = this.getParentNode(ID);if (this.getNode(ID).ParentID == 0){return this.getNode(ID);}else{return this.getRoot(par.ID);}}
zProductTreeLib.prototype.drawNode = function(ID) {var html = "";var node = this.getNode(ID);var rootid = this.getRoot(ID).ID;var hc = this.hasChildNodes(ID);var ParentID = node.ParentID ;var It = (this.ItemLocation == node.ID);if (ParentID == 0){	html +="<div id=\"nullline\"><table border=\"0\"  cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"2\"></td></tr></table></div>\n";}html += '<div id="div'+ID+'"'+(ParentID == 0&&(this.mouseOver != "") ? 'class="'+(this.isShow(ID,this.showMine)?this.mouseOver:this.mouseOut)+'" onmouseout="void window.zProductTreeBuffer['+this.id+'].MainMenuStatus(div'+ID+',0,'+(this.isShow(ID,this.showMine)?1:0)+')" onmouseover="void window.zProductTreeBuffer['+this.id+'].MainMenuStatus(div'+ID+',1,'+(this.isShow(ID,this.showMine)?1:0)+')"': 'class="'+this.ItemStyle+'"')+' nowrap>'+this.drawIndent(ID);if (this.showLeaf == true) {html += '<img id="icon'+ID+'" src="'+( node.Image ? node.Image : (hc ? Icon.folderclosed.src : (this.useLeaf ? Icon.leaf.src : Icon.folderclosed.src)))+'" align="absmiddle" style="cursor:hand;" onclick="void window.zProductTreeBuffer['+this.id+'].openFolder('+ID+')">';}html += '<span><a  id="node'+ID+'" '+(ParentID == 0 ?"class=boldGray":(It?'class="'+this.ItemChangeStyle+'"':""))+' href="'+node.Href+'" target="'+(node.Target ? node.Target : this.target)+'" onclick="window.zProductTreeBuffer['+this.id+'].setSelected('+ID+')" onfocus="this.blur();" ondblclick="window.zProductTreeBuffer['+this.id+'].openFolder('+ID+')">'+ node.Text +'</a></span></div>\n';if (hc) {var io = (this.isShow(ID,this.showMine));node.open = io;html += ('<div id="container'+ID+'" style="display:'+(io ? '' : 'none')+'">\n');html += this.addNode(ID);html += '</div>\n';}return html;}
zProductTreeLib.prototype.addNode = function(ID) {var node = this.getNode(ID);var html = "";for(var i = 0;i<node.childNodes.length;i++) html += this.drawNode(node.childNodes[i].ID);return html;}
zProductTreeLib.prototype.drawIndent = function(ID) {var s = '';var ir = this.getRoot(ID).ID == ID;var hc = this.hasChildNodes(ID);var iL = this.getNode(ID).isLast;var iM = this.isShow(ID,this.showMine);if(this.getParentNode(ID) != null) s += ((hc ? '<a href="javascript:void window.zProductTreeBuffer['+this.id+'].openHandler('+ID+');" target="_self" onfocus="this.blur();">':'')+'<img id="handler'+ID+'" src="'+ (this.hasChildNodes(ID) ? (iM ? (iL ? Icon.minusbottom.src : Icon.minus.src) : (ir? Icon.Rplus.src : (iL ? Icon.plusbottom.src : Icon.plus.src))) : (ir ? Icon.only.src : (iL ? Icon.joinbottom.src : Icon.join.src))) + '" align="absmiddle" border="0">'+(hc?'</a>':''));var p = this.getParentNode(ID);while(p != null){if(this.getParentNode(p.ID) == null) break;s = ('<img src="'+(this.getNode(p.ID).isLast ? Icon.blank.src : Icon.line.src) + '" align="absmiddle">')+s;p = this.getParentNode(p.ID);}return s;}
zProductTreeLib.prototype.setSelected = function(ID) {if(this.selectedID) { document.getElementById("node" + this.selectedID).className = "normal";}this.selectedID = ID;var node = document.getElementById("node" + ID);node.className = "selected";node.focus();}
zProductTreeLib.prototype.openHandler = function(ID) {if (this.hasChildNodes(ID)) {if (this.getNode(ID).open) {this.collapse(ID);}	else {this.expand(ID);}}}
zProductTreeLib.prototype.openFolder = function(ID) {if (this.hasChildNodes(ID) && !this.getNode(ID).open) {this.expand(ID);} else {if (this.hasChildNodes(ID) && this.getNode(ID).open) {this.collapse(ID);}}this.setSelected(ID);}
zProductTreeLib.prototype.expand = function(ID) {var handler = document.getElementById("handler"+ID);var container = document.getElementById("container"+ID);var folder = document.getElementById("icon" + ID);handler.src = this.getRoot(ID).ID == ID ? Icon.Rminus.src : ( this.getNode(ID).isLast ? Icon.minusbottom.src : Icon.minus.src);container.style.display = '';if (this.hasChildNodes(ID) && this.showLeaf) {if(this.getNode(ID).Image == null)folder.src = Icon.folderopen.src;}this.getNode(ID).open = true;if(this.getRoot(ID).ID == ID && this.showAll == false) {var ch = this.getParentNode(ID).childNodes;for (var i=0; i<ch.length; i++) {if(this.getNode(ID) != ch[i] && this.hasChildNodes(ch[i].ID))this.collapse(ch[i].ID);}}}
zProductTreeLib.prototype.collapse = function(ID) {var handler = document.getElementById("handler"+ID);var container = document.getElementById("container"+ID);var folder = document.getElementById("icon" + ID);handler.src = this.getRoot(ID).ID == ID ? Icon.Rplus.src : ( this.getNode(ID).isLast ? Icon.plusbottom.src : Icon.plus.src);container.style.display = 'none';if (this.hasChildNodes(ID) && this.showLeaf) {if(this.getNode(ID).Image == null) folder.src = Icon.folderclosed.src;}this.getNode(ID).open = false;}
zProductTreeLib.prototype.expandAll = function() { this.All(1);}
zProductTreeLib.prototype.collapseAll = function() { this.All(0);}
zProductTreeLib.prototype.All = function(v) {for(var i in this.Nodes) {if(this.Nodes[i].ID==0) continue;if(this.hasChildNodes(this.Nodes[i].ID)) {if (v) {this.expand(this.Nodes[i].ID);} else {this.collapse(this.Nodes[i].ID);}}}}
zProductTreeLib.prototype.OpenNull = function(arrayValue,arrayID){	var strUrl = this.PageLocation.toLowerCase();for(var i=0;i<arrayValue.length;i++){if (strUrl.indexOf(arrayValue[i]) != -1){this.showMine = arrayID[i];	this.ItemLocation = arrayID[i];	}}}
zProductTreeLib.prototype.setup = function() {	if (this.showMine == 0){if (typeof(arrayValue) != "undefined"){this.OpenNull(arrayValue,arrayID);}}var html = this.addNode(0);document.write(html);}