home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 March / Chip_2000-03_cd.bin / tema / Forrest / js / Menu.js < prev    next >
Text File  |  1999-07-23  |  22KB  |  778 lines

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