var fnAppID="english"; var fnPathNodes=new Array(); var fnStk=new Array(); var fnRootNode; var fnAppNode; var fnDepth1Node; var fnDepth2Node; var fnDepth3Node; var fnDepth4Node; var fnDepth5Node; var fnCurrentNode; var fnAppRootRegExp = /approot/g function fnDepthNNode(idx) { return fnPathNodes[idx + 1]; } function fnNodeID(node, prefix) { if (prefix == null) { prefix = ""; } return node != null ? prefix + node.id : ""; } function fnNodeDesc(node) { return node != null ? node.desc : ""; } function fnNodeChild(node, idx) { return node == null || node.children == null ? null : node.children[idx]; } function fnNodeChildByID(node, id) { return node == null || node.children == null ? null : node.childrenByID[id]; } function fnNodeChildrenLength(node) { return node == null || node.children == null ? 0 : node.children.length; } function fnNodeUrl(argNode) { var url = "/"; var node; node = argNode.parent; while (node != fnRootNode) { url = "/" + node.id + url; node = node.parent; } node = argNode; do { if (node.url != null) { url = node.url; break; } url += node.id + "/"; if (fnNodeOption(node, "nopage")) { node = fnNodeChild(node,0); } else { node = null; } } while (node != null); return url; } function fnNodeOption(node, keyword) { return node.option != null && node.option.indexOf(keyword) != -1; } function fnEnsurePathInfo() { var tokenList = fnPath.split("/"); var token; var node = fnRootNode; for (var i = 1; i < tokenList.length; i++) { token = tokenList[i]; node = fnNodeChildByID(node, token); if (node == null) { break; } node.onPath = true; fnCurrentNode = node; fnPathNodes[i] = node; } fnAppNode = fnPathNodes[1]; fnDepth1Node = fnDepthNNode(1); fnDepth2Node = fnDepthNNode(2); fnDepth3Node = fnDepthNNode(3); fnDepth4Node = fnDepthNNode(4); fnDepth5Node = fnDepthNNode(5); } function fnWritePathDesc(path) { var tokenList = path.split("/"); var token var node = fnAppNode var desc = "" for (var i = 2; i < tokenList.length; i++) { token = tokenList[i]; node = fnNodeChildByID(node, token); if (node == null) { break; } desc += (desc == "" ? "" : " / ") + node.desc; } document.write(desc); } function fnTranslatedHtml(html) { return html.replace(fnAppRootRegExp, fnAppID); } function fN(sp, id) { this.id = id; this.parent = null; fnStk[sp] = fT = this; if (sp > 0) { var parent = this.parent = fnStk[sp-1]; if (parent.children == null) { parent.children = new Array(); parent.childrenByID = new Array(); } parent.children[parent.children.length] = parent.childrenByID[id] = this; } } new fN(0,'') fT.desc='Root' new fN(1,'english') fT.desc='SK EuroChemicals' new fN(2,'home') fT.desc='Home' fT.option='hidden' new fN(2,'company') fT.desc='Company' new fN(2,'product') fT.desc='Products' new fN(2,'sitemap') fT.desc='SiteMap' fT.option='hidden' fnRootNode = fnStk[0]; fnEnsurePathInfo();