home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 March / CHIPCD_MAR2001_PLAYWARE.iso / code / hierMenus.js < prev    next >
Encoding:
Text File  |  2000-12-21  |  23.2 KB  |  845 lines

  1. /*hierMenus.js
  2. * by Peter Belesis. v3.10.3 000731
  3. * Copyright (c) 2000 internet.com Corp. All Rights Reserved.
  4. * Originally published and documented at http://www.dhtmlab.com/
  5. * You may use this code only if this entire copyright notice
  6. * appears unchanged. http://www.dhtmlab.com/.
  7. *
  8. */
  9.  
  10. loader = (isFrames) ? (NS4) ? parent : parent.document.body : window;
  11. loader.onload = startIt;
  12. if(NS4){
  13.     origWidth = loader.innerWidth;
  14.     origHeight = loader.innerHeight;
  15.     loader.onresize = reDo;
  16. }
  17. isLoaded = false;
  18. NSresized = false;
  19.  
  20. if (!window.menuVersion) {
  21.     clickKill = keepHilite = clickStart = false;
  22. }
  23.  
  24. if (!window.imgHspace) imgHspace=0;
  25.  
  26. isWin = (navigator.appVersion.indexOf("Win") != -1)
  27.  
  28. mSecsVis = secondsVisible*1000;
  29. isRight = (window.navFrLoc && navFrLoc == "right");
  30. fullImgSize = (imgSiz+(imgHspace*2));
  31. if(!IE5) {
  32.      imgSuf = (isRight) ? ">"  : " ALIGN=RIGHT>";
  33.      imgStr = "<IMG SRC='" + imgSrc + "' WIDTH=" + imgSiz + " HEIGHT=" + imgSiz +" VSPACE=2 HSPACE="+ imgHspace +" BORDER=0"+ imgSuf;
  34.      if(IE4) imgStr = "<SPAN STYLE='height:100%;width:"+ (fullImgSize-(isRight?3:0)) +";float:"+ (isRight?"left":"right") +";overflow:hidden'>"+ imgStr +"</SPAN>";
  35. }
  36.  
  37. areCreated = false;
  38. menuLoc = null;
  39.  
  40. function initVars() {
  41.     if(areCreated) {
  42.         for(i=1; i<topCount; i++) {
  43.             cur = eval("elMenu"+i);
  44.             clearTimeout(cur.hideTimer);
  45.             cur.hideTimer=null;
  46.         }
  47.         clearTimeout(allTimer);
  48.     }
  49.     topCount = 1;
  50.     areCreated = false;
  51.     beingCreated = false;
  52.     isOverMenu = false;
  53.     currentMenu = null;
  54.     allTimer = null;
  55. }
  56.  
  57. initVars();
  58.  
  59. function NSunloaded(){
  60.     isLoaded = false;
  61. }
  62.  
  63. function NSloaded(e){
  64.     if (e.target.name == mainFrName) {
  65.         initVars();
  66.         startIt();
  67.     }
  68. }
  69.  
  70. function IEunloaded() {
  71.     initVars();
  72.     isLoaded = false;
  73.     setTimeout("keepTrack()",50)
  74. }
  75.  
  76. function keepTrack() {
  77.     if (menuLoc.document.readyState == "complete") {
  78.         initVars();
  79.         startIt();
  80.     }
  81.     else {
  82.         setTimeout("keepTrack()",50);
  83.     }
  84. }
  85.  
  86. function startIt() {
  87.     isLoaded = true;
  88.     if (isFrames) {
  89.         menuLoc = eval("parent.frames." + mainFrName);
  90.         if (NS4) {
  91.             loader.captureEvents(Event.LOAD);
  92.             loader.onload = NSloaded;
  93.             menuLoc.onunload = NSunloaded;
  94.         }
  95.         if (IE4) {
  96.             menuLoc.document.body.onunload = IEunloaded;
  97.         }
  98.     }
  99.     else {
  100.         menuLoc = window;
  101.     }
  102.     menuLoc.nav = nav = window;
  103.     if (clickKill) {
  104.         if (NS4) menuLoc.document.captureEvents(Event.MOUSEDOWN);
  105.         menuLoc.document.onmousedown = clicked;
  106.     }
  107.     makeTop();   
  108. }
  109.  
  110. function makeTop(){
  111.     beingCreated = true;
  112.     if(IE4) {
  113.         topZ = 0;
  114.         for (z=0;z<menuLoc.document.all.length;z++){
  115.             oldEl = menuLoc.document.all(z);
  116.             topZ = Math.max(oldEl.style.zIndex,topZ)
  117.         }
  118.     }
  119.     while(eval("window.arMenu" + topCount)) {
  120.         (NS4) ? makeMenuNS(false,topCount) : makeMenuIE(false,topCount);
  121.         topCount++
  122.     }
  123.  
  124.     // status = (topCount-1) + " Hierarchical Menu Trees Created"
  125.     areCreated = true;
  126.     beingCreated = false;
  127. }
  128.  
  129. function makeMenuNS(isChild,menuCount,parMenu,parItem) {
  130.     tempArray = eval("arMenu" + menuCount);
  131.     
  132.     if (!isChild) {
  133.         tempWidth = tempArray[0] ? tempArray[0] : menuWidth;
  134.         menu = makeElement("elMenu" + menuCount,tempWidth,null,null);
  135.     }
  136.     else {
  137.         menu = makeElement("elMenu" + menuCount,null,parMenu,null);
  138.     }
  139.     menu.array = tempArray;
  140.     menu.setMenuTree = setMenuTree;
  141.     menu.setMenuTree(isChild,parMenu);
  142.  
  143.     while (menu.itemCount < menu.maxItems) {
  144.         menu.itemCount++;
  145.         // status = "Creating Hierarchical Menus: " + menuCount + " / " + menu.itemCount;
  146.         prevItem = (menu.itemCount > 1) ? menu.item : null;
  147.         itemName = "item" + menuCount + "_" + menu.itemCount;
  148.  
  149.         menu.item = makeElement(itemName,null,null,menu);
  150.  
  151.         menu.item.prevItem = prevItem;
  152.         menu.item.setup = itemSetup;
  153.         menu.item.setup(menu.itemCount,menu.array);
  154.         if (menu.item.hasMore) {
  155.             makeMenuNS(true,menuCount + "_" + menu.itemCount,menu,menu.item);
  156.             menu = menu.parentMenu;
  157.         }
  158.     }
  159.     menu.lastItem = menu.item;
  160.     menu.setup(isChild,parMenu,parItem);
  161. }
  162.  
  163. function findTree(men){
  164.     foundTree = false;
  165.     for(i=11;i<men.array.length;i+=3){
  166.         if(men.array[i]) {
  167.             foundTree = true;
  168.             break;
  169.         }
  170.     }
  171.     return foundTree;
  172. }
  173.  
  174. function setMenuTree(isChild,parMenu) {
  175.     if (!isChild) {
  176.         this.menuWidth = this.array[0] ? this.array[0] : menuWidth;
  177.         this.menuLeft = this.array[1];
  178.         this.menuTop = this.array[2];
  179.         this.menuFontColor = this.array[3] ? this.array[3] : fntCol;
  180.         this.menuFontOver = this.array[4] ? this.array[4] : overFnt;
  181.         this.menuBGColor = this.array[5] ? this.array[5] : backCol;
  182.         this.menuBGOver = this.array[6] ? this.array[6] : overCol;
  183.         this.menuBorCol = this.array[7] ? this.array[7] : borCol;
  184.         this.menuSeparatorCol = this.array[8] ? this.array[8] : separatorCol;
  185.         this.treeParent = this;
  186.         this.startChild = this;
  187.         this.isTree = findTree(this);
  188.     }
  189.     else {
  190.         this.menuWidth = parMenu.menuWidth;
  191.         this.menuLeft = parMenu.menuLeft;
  192.         this.menuTop = parMenu.menuTop;
  193.         this.menuFontColor = parMenu.menuFontColor;
  194.         this.menuFontOver = parMenu.menuFontOver;
  195.         this.menuBGColor = parMenu.menuBGColor;
  196.         this.menuBGOver = parMenu.menuBGOver;
  197.         this.menuBorCol = parMenu.menuBorCol;
  198.         this.menuSeparatorCol = parMenu.menuSeparatorCol;
  199.         this.treeParent = parMenu.treeParent;
  200.         this.isTree = parMenu.isTree;
  201.     }
  202.  
  203.     this.maxItems = (isChild) ? this.array.length/3 : (this.array.length-9)/3;
  204.     this.hasParent = isChild;
  205.     this.setup = menuSetup;
  206.     this.itemCount = 0;
  207. }
  208.  
  209. function makeMenuIE(isChild,menuCount,parMenu) {
  210.     menu = makeElement("elMenu" + menuCount);
  211.     menu.array = eval("arMenu" + menuCount);
  212.     menu.setMenuTree = setMenuTree;
  213.     menu.setMenuTree(isChild,parMenu);
  214.     menu.itemStr = "";
  215.     
  216.     while (menu.itemCount < menu.maxItems) {
  217.         menu.itemCount++;
  218.         // status = "Creating Hierarchical Menus: " + menuCount + " / " + menu.itemCount;
  219.         itemName = "item" + menuCount + "_" + menu.itemCount;
  220.  
  221.         arrayPointer = (isChild) ? (menu.itemCount-1)*3 :((menu.itemCount-1)*3)+9;
  222.         dispText = menu.array[arrayPointer];
  223.         hasMore = menu.array[arrayPointer + 2];
  224.  
  225.         if(IE5) {
  226.             newSpan = menuLoc.document.createElement("SPAN");
  227.             with(newSpan) {
  228.                 id = itemName;
  229.                 with(style) {
  230.                     width = (menu.menuWidth-(borWid*2));
  231.                     fontSize = fntSiz + "pt";
  232.                     fontWeight = (fntBold) ? "bold" : "normal";
  233.                     fontStyle = (fntItal) ? "italic" : "normal";
  234.                     fontFamily = fntFam;
  235.                     padding = itemPad;
  236.                     borderBottomWidth = separator + "px";
  237.                     borderBottomStyle = "solid";
  238.  
  239. //3.10.3 added conditional:
  240.                     if(menu.isTree)    {
  241.                         if (isRight) paddingLeft = itemPad+fullImgSize;
  242.                         else paddingRight = itemPad+fullImgSize;
  243.                     }
  244.                 }
  245.                 innerHTML = dispText;
  246.             }
  247.  
  248.             newBreak = menuLoc.document.createElement("BR");
  249.             menu.appendChild(newSpan);
  250.             menu.appendChild(newBreak);
  251.  
  252.             if(hasMore) {
  253.  
  254. //3.10.3 omitted next 2 statements:
  255. //                if (isRight) newSpan.style.paddingLeft = itemPad+fullImgSize;
  256. //                else newSpan.style.paddingRight = itemPad+fullImgSize;
  257.  
  258.                 newImage = menuLoc.document.createElement("IMAGE");
  259.                 with(newImage){
  260.                     src = imgSrc;
  261.                     with(style) {
  262.                         position = "absolute";
  263.                         width = imgSiz;
  264.                         height = imgSiz;
  265.                         left = (isRight) ? itemPad : (newSpan.style.pixelWidth - itemPad - imgSiz);
  266.                         top = newSpan.offsetTop + itemPad + (isMac ? 0 : 2);
  267.                     }
  268.                 }
  269.                 newSpan.appendChild(newImage);
  270.             }
  271.         }
  272.         else {
  273.             htmStr = (hasMore) ? imgStr + dispText : dispText;
  274.             menu.itemStr += "<SPAN ID=" + itemName + " STYLE=\"width:" + (menu.menuWidth-(borWid*2)) + "\">" + htmStr + "</SPAN><BR>";
  275.         }
  276.         if (hasMore) {
  277.             makeMenuIE(true,menuCount + "_" + menu.itemCount,menu);
  278.             menu = menu.parentMenu;
  279.         }
  280.     }
  281.  
  282.     if(!IE5) menu.innerHTML = menu.itemStr;
  283.  
  284.     itemColl = menu.children.tags("SPAN");
  285.     for (i=0; i<itemColl.length; i++) {
  286.         it = itemColl(i);
  287.         it.setup = itemSetup;
  288.         it.setup(i+1,menu.array);
  289.     }
  290.     menu.lastItem = itemColl(itemColl.length-1);
  291.     menu.setup(isChild,parMenu);
  292. }
  293.  
  294. function makeElement(whichEl,whichWidth,whichParent,whichContainer) {
  295.     if (NS4) {
  296.         if (whichWidth) {
  297.             elWidth = whichWidth;
  298.         }
  299.         else {
  300.             elWidth = (whichContainer) ? whichContainer.menuWidth : whichParent.menuWidth;
  301.             if (whichContainer) elWidth = elWidth-(borWid*2)-(itemPad*2);
  302.         }
  303.         if (!whichContainer) whichContainer = menuLoc;
  304.         eval(whichEl + "= new Layer(elWidth,whichContainer)");
  305.     }
  306.     else {
  307.         if (IE5) {
  308.             newDiv = menuLoc.document.createElement("DIV");
  309.             newDiv.style.position = "absolute";
  310.             newDiv.id = whichEl;
  311.             menuLoc.document.body.appendChild(newDiv);
  312.         }
  313.         else {
  314.             elStr = "<DIV ID=" + whichEl + " STYLE='position:absolute'></DIV>";
  315.             menuLoc.document.body.insertAdjacentHTML("BeforeEnd",elStr);
  316.         }
  317.         if (isFrames) eval(whichEl + "= menuLoc." + whichEl);
  318.     }
  319.     return eval(whichEl);
  320. }
  321.  
  322. function itemSetup(whichItem,whichArray) {
  323.     this.onmouseover = itemOver;
  324.     this.onmouseout = itemOut;
  325.     this.container = (NS4) ? this.parentLayer : this.parentElement;
  326.  
  327.     arrayPointer = (this.container.hasParent) ? (whichItem-1)*3 : ((whichItem-1)*3)+9;
  328.     this.dispText = whichArray[arrayPointer];
  329.     this.linkText = whichArray[arrayPointer + 1];
  330.     this.hasMore = whichArray[arrayPointer + 2];
  331.  
  332.     if (IE4 && this.hasMore) {
  333.         this.child = eval("elMenu" + this.id.substr(4));
  334.         this.child.parentMenu = this.container;
  335.         this.child.parentItem = this;
  336.     }
  337.  
  338.     if (this.linkText) {
  339.         if (NS4) {
  340.             this.captureEvents(Event.MOUSEUP)
  341.             this.onmouseup = linkIt;
  342.         }
  343.         else {
  344.             this.onclick = linkIt;
  345.             this.style.cursor = "hand";
  346.         }
  347.     }
  348.  
  349.     if (NS4) {
  350.         htmStr = this.dispText;
  351.         if (fntBold) htmStr = htmStr.bold();
  352.         if (fntItal) htmStr = htmStr.italics();
  353.  
  354.         htmStr = "<FONT FACE='" + fntFam + "' POINT-SIZE=" + fntSiz + ">" + htmStr+ "</FONT>";
  355.         this.htmStrOver = htmStr.fontcolor(this.container.menuFontOver);
  356.         this.htmStr = htmStr.fontcolor(this.container.menuFontColor);
  357.         if(this.hasMore) {
  358.             this.document.write(imgStr);
  359.             this.document.close();
  360.         }
  361.         this.visibility = "inherit";
  362.         this.bgColor = this.container.menuBGColor;
  363.         if (whichItem == 1) {
  364.             this.top = borWid + itemPad;
  365.         }
  366.         else {
  367.             this.top = this.prevItem.top + this.prevItem.clip.height + separator;
  368.         }
  369.         this.left = borWid + itemPad;
  370.         this.clip.top = this.clip.left = -itemPad;
  371.         this.clip.right = this.container.menuWidth-(borWid*2)-itemPad;
  372.         maxTxtWidth = this.container.menuWidth-(borWid*2)-(itemPad*2);
  373.         if (this.container.isTree) maxTxtWidth-=(fullImgSize);
  374.  
  375.         this.txtLyrOff = new Layer(maxTxtWidth,this);
  376.         if (isRight && this.container.isTree) this.txtLyrOff.left = fullImgSize;
  377.         this.txtLyrOff.document.write(this.htmStr);
  378.         this.txtLyrOff.document.close();
  379.         this.txtLyrOff.visibility = "inherit";
  380.  
  381.         this.clip.bottom = this.txtLyrOff.document.height+itemPad;
  382.  
  383.         this.txtLyrOn = new Layer(maxTxtWidth,this);
  384.         if (isRight && this.container.isTree) this.txtLyrOn.left = fullImgSize;
  385.         this.txtLyrOn.document.write(this.htmStrOver);
  386.         this.txtLyrOn.document.close();
  387.         this.txtLyrOn.visibility = "hide";
  388.  
  389.         this.dummyLyr = new Layer(100,this);
  390.         this.dummyLyr.left = this.dummyLyr.top = -itemPad;
  391.         this.dummyLyr.clip.width = this.clip.width;
  392.         this.dummyLyr.clip.height = this.clip.height;
  393.         this.dummyLyr.visibility = "inherit";
  394.     }
  395.     else {
  396.         with (this.style) {
  397.             if(!IE5) {
  398.                 fontSize = fntSiz + "pt";
  399.                 fontWeight = (fntBold) ? "bold" : "normal";
  400.                 fontStyle =   (fntItal) ? "italic" : "normal";
  401.                 fontFamily = fntFam;
  402.                 padding = itemPad;
  403.                 borderBottomWidth = separator + "px";
  404.                 borderBottomStyle = "solid";
  405.  
  406. //3.10.3 moved conditional here from below:
  407.  
  408.                  if (this.container.isTree && !this.hasMore) {
  409.                     if (isRight) paddingLeft = itemPad+fullImgSize;
  410.                     else paddingRight = itemPad+fullImgSize;
  411.                 } 
  412.  
  413.             }
  414.  
  415. //3.10.3 moved conditional above
  416. //            if (this.container.isTree && !this.hasMore) {
  417. //                if (isRight) paddingLeft = itemPad+fullImgSize;
  418. //                else paddingRight = itemPad+fullImgSize;
  419. //            }
  420.  
  421.             color = this.container.menuFontColor;
  422.             borderBottomColor = this.container.menuSeparatorCol;
  423.             backgroundColor = this.container.menuBGColor;
  424.         }
  425.     }
  426. }   
  427.  
  428. function menuSetup(hasParent,openCont,openItem) {
  429.     this.onmouseover = menuOver;
  430.     this.onmouseout = menuOut;
  431.     
  432.     this.showIt = showIt;
  433.     this.keepInWindow = keepInWindow;
  434.     this.hideTree = hideTree
  435.     this.hideParents = hideParents;
  436.     this.hideChildren = hideChildren;
  437.     this.hideTop = hideTop;
  438.     this.hasChildVisible = false;
  439.     this.isOn = false;
  440.     this.hideTimer = null;
  441.  
  442.     this.childOverlap = (perCentOver != null) ? ((perCentOver/100) * this.menuWidth) : childOverlap;
  443.     this.currentItem = null;
  444.     this.hideSelf = hideSelf;
  445.         
  446.     if (hasParent) {
  447.         this.hasParent = true;
  448.         this.parentMenu = openCont;
  449.         if (NS4) {
  450.             this.parentItem = openItem;
  451.             this.parentItem.child = this;
  452.         }
  453.     }
  454.     else {
  455.         this.hasParent = false;
  456.     }
  457.  
  458.     if (NS4) {
  459.         this.bgColor = this.menuBorCol;
  460.         this.fullHeight = this.lastItem.top + this.lastItem.clip.bottom + borWid;
  461.         this.clip.right = this.menuWidth;
  462.         this.clip.bottom = this.fullHeight;
  463.     }
  464.     else {
  465.         with (this.style) {
  466.             width = this.menuWidth;
  467.             borderWidth = borWid;
  468.             borderColor = this.menuBorCol;
  469.             borderStyle = borSty;
  470.             zIndex = topZ;
  471.             overflow = "hidden";
  472.         }
  473.         this.lastItem.style.border="";
  474.         this.fullHeight = this.offsetHeight;
  475.         if(isMac)this.style.pixelHeight = this.fullHeight;
  476.         this.fullHeight = this.scrollHeight;
  477.         this.showIt(false);
  478.         this.onselectstart = cancelSelect;
  479.         this.moveTo = moveTo;
  480.         this.moveTo(0,0);
  481.     }
  482. }
  483.  
  484. function popUp(menuName,e){
  485.     if (NS4 && NSresized) startIt();
  486.     if (!isLoaded) return;
  487.     linkEl = (NS4) ? e.target : event.srcElement;
  488.     if (clickStart) linkEl.onclick = popMenu;
  489.     if (!beingCreated && !areCreated) startIt();
  490.     linkEl.menuName = menuName;   
  491.     if (!clickStart) popMenu(e);
  492. }
  493.  
  494. function popMenu(e){
  495.     if (!isLoaded || !areCreated) return true;
  496.  
  497.     eType = (NS4) ? e.type : event.type;
  498.     if (clickStart && eType != "click") return true;
  499.     hideAll();
  500.  
  501.     linkEl = (NS4) ? e.target : event.srcElement;
  502.     
  503.     currentMenu = eval(linkEl.menuName);
  504.     currentMenu.hasParent = false;
  505.     currentMenu.treeParent.startChild = currentMenu;
  506.     
  507.     if (IE4) menuLocBod = menuLoc.document.body;
  508.     if (!isFrames) {
  509.         xPos = (currentMenu.menuLeft) ? currentMenu.menuLeft : (NS4) ? e.pageX : (event.clientX + menuLocBod.scrollLeft);
  510.         yPos = (currentMenu.menuTop) ? currentMenu.menuTop : (NS4) ? e.pageY : (event.clientY + menuLocBod.scrollTop);
  511.     }
  512.     else {
  513.         switch (navFrLoc) {
  514.             case "left":
  515.                 xPos = (currentMenu.menuLeft) ? currentMenu.menuLeft : (NS4) ? menuLoc.pageXOffset : menuLocBod.scrollLeft;
  516.                 yPos = (currentMenu.menuTop) ? currentMenu.menuTop : (NS4) ? (e.pageY-pageYOffset)+menuLoc.pageYOffset : event.clientY + menuLocBod.scrollTop;
  517.                 break;
  518.             case "top":
  519.                 xPos = (currentMenu.menuLeft) ? currentMenu.menuLeft : (NS4) ? (e.pageX-pageXOffset)+menuLoc.pageXOffset : event.clientX + menuLocBod.scrollLeft;
  520.                 yPos = (currentMenu.menuTop) ? currentMenu.menuTop : (NS4) ? menuLoc.pageYOffset : menuLocBod.scrollTop;
  521.                 break;
  522.             case "bottom":
  523.                 xPos = (currentMenu.menuLeft) ? currentMenu.menuLeft : (NS4) ? (e.pageX-pageXOffset)+menuLoc.pageXOffset : event.clientX + menuLocBod.scrollLeft;
  524.                 yPos = (currentMenu.menuTop) ? currentMenu.menuTop : (NS4) ? menuLoc.pageYOffset+menuLoc.innerHeight : menuLocBod.scrollTop + menuLocBod.clientHeight;
  525.                 break;
  526.             case "right":
  527.                 xPos = (currentMenu.menuLeft) ? currentMenu.menuLeft : (NS4) ? menuLoc.pageXOffset+menuLoc.innerWidth : menuLocBod.scrollLeft+menuLocBod.clientWidth;
  528.                 yPos = (currentMenu.menuTop) ? currentMenu.menuTop : (NS4) ? (e.pageY-pageYOffset)+menuLoc.pageYOffset : event.clientY + menuLocBod.scrollTop;
  529.                 break;
  530.         }
  531.     }
  532.  
  533.     currentMenu.moveTo(xPos,yPos);
  534.     currentMenu.keepInWindow()
  535.     currentMenu.isOn = true;
  536.     currentMenu.showIt(true);
  537.  
  538.     return false;
  539. }
  540.  
  541. function menuOver(e) {
  542.     this.isOn = true;
  543.     isOverMenu = true;
  544.     currentMenu = this;
  545.     if (this.hideTimer) clearTimeout(this.hideTimer);
  546. }
  547.  
  548. function menuOut() {
  549.     if (IE4) {
  550.         theEvent = menuLoc.event;
  551.         if (theEvent.srcElement.contains(theEvent.toElement)) return;
  552.     }
  553.     this.isOn = false;
  554.     isOverMenu = false;
  555.  
  556.     // menuLoc.status = "";
  557.     if (!clickKill) allTimer = setTimeout("currentMenu.hideTree()",10);
  558. }
  559.  
  560. function itemOver(){
  561.     if (keepHilite) {
  562.         if (this.container.currentItem && this.container.currentItem != this) {
  563.             if (NS4) {
  564.                 this.container.currentItem.bgColor = this.container.menuBGColor;
  565.                 this.container.currentItem.txtLyrOff.visibility = "inherit";
  566.                 this.container.currentItem.txtLyrOn.visibility = "hide";
  567.             }
  568.             else {
  569.                 with (this.container.currentItem.style) {
  570.                     backgroundColor = this.container.menuBGColor;
  571.                     color = this.container.menuFontColor;
  572.                 }
  573.             }
  574.         }
  575.     }
  576.  
  577.     if (IE4) {
  578.         theEvent = menuLoc.event;
  579.         if (theEvent.srcElement.tagName == "IMG") return;
  580.         this.style.backgroundColor = this.container.menuBGOver;
  581.         this.style.color = this.container.menuFontOver;
  582.     }
  583.     else {
  584.         this.bgColor = this.container.menuBGOver;
  585.         this.txtLyrOff.visibility = "hide";
  586.         this.txtLyrOn.visibility = "inherit";
  587.     }
  588.  
  589.     // menuLoc.status = this.linkText;
  590.  
  591.     this.container.currentItem = this;
  592.  
  593.     if (this.container.hasChildVisible) {
  594.         this.container.hideChildren(this);
  595.     }
  596.  
  597.     if (this.hasMore) {
  598.         horOffset = (isRight) ? (this.container.childOverlap - this.container.menuWidth) : (this.container.menuWidth - this.container.childOverlap);
  599.  
  600.         if (NS4) {
  601.             this.childX = this.container.left + horOffset;
  602.             this.childY = (this.pageY+this.clip.top) + childOffset;
  603.         }
  604.         else {
  605.             this.childX = this.container.style.pixelLeft + horOffset;
  606.             this.childY = this.offsetTop + this.container.style.pixelTop + childOffset + borWid;
  607.         }
  608.  
  609.         this.child.moveTo(this.childX,this.childY);
  610.         this.child.keepInWindow();
  611.         this.container.hasChildVisible = true;
  612.         this.container.visibleChild = this.child;
  613.         this.child.showIt(true);
  614.     }
  615. }
  616.  
  617. function itemOut() {
  618.     if (IE4) {
  619.         theEvent = menuLoc.event;
  620.          if (theEvent.srcElement.contains(theEvent.toElement)
  621.       || (theEvent.fromElement.tagName=="IMG" && theEvent.toElement.contains(theEvent.fromElement)))
  622.           return;
  623.         if (!keepHilite) {
  624.             this.style.backgroundColor = this.container.menuBGColor;
  625.             this.style.color = this.container.menuFontColor;
  626.         }
  627.     }
  628.     else {
  629.         if (!keepHilite) {
  630.             this.bgColor = this.container.menuBGColor;
  631.             this.txtLyrOff.visibility = "inherit";
  632.             this.txtLyrOn.visibility = "hide";
  633.         }
  634.         if (!isOverMenu && !clickKill) {
  635.             allTimer = setTimeout("currentMenu.hideTree()",10); 
  636.         }
  637.     }
  638. }
  639.  
  640. function moveTo(xPos,yPos) {
  641.     this.style.pixelLeft = xPos;
  642.     this.style.pixelTop = yPos;
  643. }
  644.  
  645. function showIt(on) {
  646.     if (NS4) {
  647.         this.visibility = (on) ? "show" : "hide";
  648.         if (keepHilite && this.currentItem) {
  649.             this.currentItem.bgColor = this.menuBGColor;
  650.             this.currentItem.txtLyrOff.visibility = "inherit";
  651.             this.currentItem.txtLyrOn.visibility = "hide";
  652.         }
  653.     }
  654.     else {
  655.         this.style.visibility = (on) ? "visible" : "hidden";
  656.         if (keepHilite && this.currentItem) {
  657.             with (this.currentItem.style) {
  658.                 backgroundColor = this.menuBGColor;
  659.                 color = this.menuFontColor;
  660.             }
  661.         }
  662.     }
  663.     this.currentItem = null;
  664. }
  665.  
  666. function keepInWindow() {
  667.     scrBars = 20;
  668.     botScrBar = (isFrames && navFrLoc=="bottom") ? (borWid*2) : scrBars;
  669.     rtScrBar = (isFrames && navFrLoc=="right") ? (borWid*2) : scrBars;
  670.     if (NS4) {
  671.         winRight = (menuLoc.pageXOffset + menuLoc.innerWidth) - rtScrBar;
  672.         rightPos = this.left + this.menuWidth;
  673.     
  674.         if (rightPos > winRight) {
  675.             if (this.hasParent) {
  676.                 parentLeft = this.parentMenu.left;
  677.                 newLeft = ((parentLeft-this.menuWidth) + this.childOverlap);
  678.                 this.left = newLeft;
  679.             }
  680.             else {
  681.                 dif = rightPos - winRight;
  682.                 this.left -= dif;
  683.             }
  684.         }
  685.  
  686.         winBot = (menuLoc.pageYOffset + menuLoc.innerHeight) - botScrBar ;
  687.         botPos = this.top + this.fullHeight;
  688.  
  689.         if (botPos > winBot) {
  690.             dif = botPos - winBot;
  691.             this.top -= dif;
  692.         }
  693.         
  694.         winLeft = menuLoc.pageXOffset;
  695.         leftPos = this.left;
  696.  
  697.         if (leftPos < winLeft) {
  698.             if (this.hasParent) {
  699.                 parentLeft = this.parentMenu.left;
  700.                 newLeft = ((parentLeft+this.menuWidth) - this.childOverlap);
  701.                 this.left = newLeft;
  702.             }
  703.             else {
  704.                 this.left = 5;
  705.             }
  706.         }
  707.     }
  708.     else {
  709.          winRight = (menuLoc.document.body.scrollLeft + menuLoc.document.body.clientWidth) - rtScrBar;
  710.         rightPos = this.style.pixelLeft + this.menuWidth;
  711.     
  712.         if (rightPos > winRight) {
  713.             if (this.hasParent) {
  714.                 parentLeft = this.parentMenu.style.pixelLeft;
  715.                 newLeft = ((parentLeft - this.menuWidth) + this.childOverlap);
  716.                 this.style.pixelLeft = newLeft;
  717.             }
  718.             else {
  719.                 dif = rightPos - winRight;
  720.                 this.style.pixelLeft -= dif;
  721.             }
  722.         }
  723.  
  724.         winBot = (menuLoc.document.body.scrollTop + menuLoc.document.body.clientHeight) - botScrBar;
  725.         botPos = this.style.pixelTop + this.fullHeight;
  726.  
  727.         if (botPos > winBot) {
  728.             dif = botPos - winBot;
  729.             this.style.pixelTop -= dif;
  730.         }
  731.         
  732.         winLeft = menuLoc.document.body.scrollLeft;
  733.         leftPos = this.style.pixelLeft;
  734.  
  735.         if (leftPos < winLeft) {
  736.             if (this.hasParent) {
  737.                 parentLeft = this.parentMenu.style.pixelLeft;
  738.                 newLeft = ((parentLeft+this.menuWidth) - this.childOverlap);
  739.                 this.style.pixelLeft = newLeft;
  740.             }
  741.             else {
  742.                 this.style.pixelLeft = 5;
  743.             }
  744.         }
  745.     }
  746. }
  747.  
  748. function linkIt() {
  749.     if (this.linkText.indexOf("javascript:")!=-1) eval(this.linkText)
  750.     else menuLoc.location.href = this.linkText;
  751. }
  752.  
  753. function popDown(menuName){
  754.     if (!isLoaded || !areCreated) return;
  755.     whichEl = eval(menuName);
  756.     whichEl.isOn = false;
  757.     if (!clickKill) whichEl.hideTop();
  758. }
  759.  
  760. function hideAll() {
  761.     for(i=1; i<topCount; i++) {
  762.         temp = eval("elMenu" + i + ".startChild");
  763.         temp.isOn = false;
  764.         if (temp.hasChildVisible) temp.hideChildren();
  765.         temp.showIt(false);
  766.     }   
  767. }
  768.  
  769. function hideTree() { 
  770.     allTimer = null;
  771.     if (isOverMenu) return;
  772.     if (this.hasChildVisible) {
  773.         this.hideChildren();
  774.     }
  775.     this.hideParents();
  776. }
  777.  
  778. function hideTop() {
  779.     whichTop = this;
  780.     (clickKill) ? whichTop.hideSelf() : (this.hideTimer = setTimeout("if(whichTop.hideSelf)whichTop.hideSelf()",mSecsVis));
  781. }
  782.  
  783. function hideSelf() {
  784.     this.hideTimer = null;
  785.     if (!this.isOn && !isOverMenu) { 
  786.         this.showIt(false);
  787.     }
  788. }
  789.  
  790. function hideParents() {
  791.     tempMenu = this;
  792.     while (tempMenu.hasParent) {
  793.         tempMenu.showIt(false);
  794.         tempMenu.parentMenu.isOn = false;      
  795.         tempMenu = tempMenu.parentMenu;
  796.     }
  797.     tempMenu.hideTop();
  798. }
  799.  
  800. function hideChildren(item) {
  801.     tempMenu = this.visibleChild;
  802.     while (tempMenu.hasChildVisible) {
  803.         tempMenu.visibleChild.showIt(false);
  804.         tempMenu.hasChildVisible = false;
  805.         tempMenu = tempMenu.visibleChild;
  806.     }
  807.  
  808.     if (!this.isOn || !item.hasMore || this.visibleChild != this.child) {
  809.         this.visibleChild.showIt(false);
  810.         this.hasChildVisible = false;
  811.     }
  812. }
  813.  
  814. function cancelSelect(){return false}
  815.  
  816. function reDo(){
  817.     if (loader.innerWidth==origWidth && loader.innerHeight==origHeight) return;
  818.     initVars();
  819.     NSresized=true;
  820.     menuLoc.location.reload();
  821. }
  822.  
  823. function clicked() {
  824.     if (!isOverMenu && currentMenu!=null && !currentMenu.isOn) {
  825.         whichEl = currentMenu;
  826.         whichEl.hideTree();
  827.     }
  828. }
  829.  
  830. window.onerror = handleErr;
  831.  
  832. function handleErr(){
  833.     arAccessErrors = ["permission","access"];
  834.     mess = arguments[0].toLowerCase();
  835.     found = false;
  836.     for (i=0;i<arAccessErrors.length;i++) {
  837.         errStr = arAccessErrors[i];
  838.         if (mess.indexOf(errStr)!=-1) found = true;
  839.     }
  840.     return found;
  841. }
  842.  
  843. //end
  844.  
  845.