home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 July / PCpro_2004_07.ISO / docs / western / software_files / fw_menu.js < prev    next >
Encoding:
JavaScript  |  2003-12-28  |  24.3 KB  |  843 lines

  1. //var menuserver = "";                                                      // Uncomment this for www.wdc.com
  2. //if (typeof menuserver == "undefined") menuserver="";    // This is to make sure the mainserver is defined.
  3.  
  4. var menuserver = "http://support.wdc.com";                                                        // Uncomment this for support.wdc.com
  5. if (typeof menuserver == "undefined") menuserver="http://support.wdc.com";    // This is to make sure the mainserver is defined.
  6.  
  7. var intMenu = 0;
  8.  
  9. function Menu(label, mw, mh, fnt, fs, fclr, fhclr, bg, bgh) 
  10. {
  11.     if (label == "root")
  12.         this.id = intMenu++;
  13.         
  14.     this.version = "990702 [Menu; menu.js]";
  15.     this.type = "Menu";
  16.     this.menuWidth = mw;
  17.     this.menuItemHeight = mh;
  18.     this.fontSize = fs||12;
  19.     this.fontWeight = "plain";
  20.     this.fontFamily = fnt||"arial,helvetica,verdana,sans-serif";
  21.     this.fontColor = fclr||"#000000";
  22.     this.fontColorHilite = fhclr||"#ffffff";
  23.     this.bgColor = "#ffffff";
  24.     this.menuBorder = 1;
  25.     this.menuItemBorder = 1;
  26.     this.menuItemBgColor = bg||"#cccccc";
  27.     this.menuLiteBgColor = "#e6e6e6";
  28.     this.menuBorderBgColor = "#777777";
  29.     this.menuHiliteBgColor = bgh||"#000084";
  30.     this.menuContainerBgColor = "#cccccc";
  31.     this.childMenuIcon = "arrows.gif";
  32.     this.items = new Array();
  33.     this.actions = new Array();
  34.     this.childMenus = new Array();
  35.     this.hideOnMouseOut = true;
  36.     this.addMenuItem = addMenuItem;
  37.     this.addMenuSeparator = addMenuSeparator;
  38.     this.writeMenus = writeMenus;
  39.     this.FW_showMenu = FW_showMenu;
  40.     this.onMenuItemOver = onMenuItemOver;
  41.     this.onMenuItemAction = onMenuItemAction;
  42.     this.hideMenu = hideMenu;
  43.     this.hideChildMenu = hideChildMenu;
  44.  
  45.     if (!window.menus) window.menus = new Array();
  46.     this.label = label || "menuLabel" + window.menus.length;
  47.     window.menus[this.label] = this;
  48.     window.menus[window.menus.length] = this;
  49.     if (!window.activeMenus) window.activeMenus = new Array();
  50. }
  51.  
  52. function addMenuItem(label, action) 
  53. {
  54.     this.items[this.items.length] = label;
  55.     this.actions[this.actions.length] = action;
  56. }
  57.  
  58. function addMenuSeparator() 
  59. {
  60.     this.items[this.items.length] = "separator";
  61.     this.actions[this.actions.length] = "";
  62.     this.menuItemBorder = 0;
  63. }
  64.  
  65. function writeMenus(container) 
  66. {
  67.     if (window.triedToWriteMenus) return;
  68.  
  69.     if (!container && document.layers) 
  70.     {
  71.         window.delayWriteMenus = this.writeMenus;
  72.         var timer = setTimeout('delayWriteMenus()', 250);
  73.         container = new Layer(100);
  74.         clearTimeout(timer);
  75.     } 
  76.     else if (document.all || document.hasChildNodes) 
  77.     {
  78.         document.writeln('<SPAN ID="menuContainer"></SPAN>');
  79.         container = FIND("menuContainer");
  80.     }
  81.  
  82.     window.fwHideMenuTimer = null;
  83.     if (!container) return;    
  84.     window.triedToWriteMenus = true; 
  85.     container.isContainer = true;
  86.     container.menus = new Array();
  87.     for (var i=0; i<window.menus.length; i++) 
  88.         container.menus[i] = window.menus[i];
  89.     window.menus.length = 0;
  90.     var countMenus = 0;
  91.     var countItems = 0;
  92.     var top = 0;
  93.     var content = '';
  94.     var lrs = false;
  95.     var theStat = "";
  96.     var tsc = 0;
  97.     if (document.layers) lrs = true;
  98.     for (var i=0; i<container.menus.length; i++, countMenus++) 
  99.     {
  100.         var menu = container.menus[i];
  101.         if (menu.bgImageUp) 
  102.         {
  103.             menu.menuBorder = 0;
  104.             menu.menuItemBorder = 0;
  105.         }
  106.         if (lrs) 
  107.         {
  108.             var menuLayer = new Layer(100, container);
  109.             var lite = new Layer(100, menuLayer);
  110.             lite.top = menu.menuBorder;
  111.             lite.left = menu.menuBorder;
  112.             var body = new Layer(100, lite);
  113.             body.top = menu.menuBorder;
  114.             body.left = menu.menuBorder;
  115.         } 
  116.         else 
  117.         {
  118.             content += ''+
  119.             '<DIV ID="menuLayer'+ countMenus +'" STYLE="position:absolute;z-index:1;left:10;top:'+ (i * 100) +';visibility:hidden;">\n'+
  120.             '  <DIV ID="menuLite'+ countMenus +'" STYLE="position:absolute;z-index:1;left:'+ menu.menuBorder +';top:'+ menu.menuBorder +';visibility:hide;" onMouseOut="mouseoutMenu();">\n'+
  121.             '     <DIV ID="menuFg'+ countMenus +'" STYLE="position:absolute;left:'+ menu.menuBorder +';top:'+ menu.menuBorder +';visibility:hide;">\n'+
  122.             '';
  123.         }
  124.         var x=i;
  125.         for (var i=0; i<menu.items.length; i++) 
  126.         {
  127.             var item = menu.items[i];
  128.             var childMenu = false;
  129.             var defaultHeight = menu.fontSize+6;
  130.             var defaultIndent = menu.fontSize;
  131.  
  132.             if (item.label) 
  133.             {
  134.                 item = item.label;
  135.                 childMenu = true;
  136.             }
  137.             menu.menuItemHeight = menu.menuItemHeight || defaultHeight;
  138.             menu.menuItemIndent = menu.menuItemIndent || defaultIndent;
  139.             var itemProps = 'font-family:' + menu.fontFamily +';font-weight:' + menu.fontWeight + ';fontSize:' + menu.fontSize + ';';
  140.             if (menu.fontStyle) itemProps += 'font-style:' + menu.fontStyle + ';';
  141.             if (document.all) 
  142.                 itemProps += 'font-size:' + menu.fontSize + ';" onMouseOver="onMenuItemOver(null,this);" onClick="onMenuItemAction(null,this);';
  143.             else if (!document.layers) 
  144.             {
  145.                 itemProps += 'font-size:' + menu.fontSize + 'px;'; // zilla wants 12px.
  146.             }
  147.             var l;
  148.             if (lrs) 
  149.             {
  150.                 l = new Layer(800,body);
  151.             }
  152.             var dTag    = '<DIV ID="menuItem'+ countItems +'" STYLE="position:absolute;left:0;top:'+ (i * menu.menuItemHeight) +';'+ itemProps +'">';
  153.             var dClose = '</DIV>'
  154.  
  155.             if (menu.bgImageUp) 
  156.             {
  157.                 menu.menuBorder = 0;
  158.                 menu.menuItemBorder = 0;
  159.                 dTag    = '<DIV ID="menuItem'+ countItems +'" STYLE="background:url('+menu.bgImageUp+');position:absolute;left:0;top:'+ (i * menu.menuItemHeight) +';'+ itemProps +'">';
  160.                 if (document.layers) 
  161.                 {
  162.                     dTag = '<LAYER BACKGROUND="'+menu.bgImageUp+'" ID="menuItem'+ countItems +'" TOP="'+ (i * menu.menuItemHeight) +'" style="' + itemProps +'">';
  163.                     dClose = '</LAYER>';
  164.                 }
  165.             }
  166.             var textProps = 'position:absolute;left:' + menu.menuItemIndent + ';top:1;';
  167.             if (lrs) 
  168.             {
  169.                 textProps +=itemProps;
  170.                 dTag = "";
  171.                 dClose = "";
  172.             }
  173.  
  174.             var dText    = '<DIV ID="menuItemText'+ countItems +'" STYLE="' + textProps + 'color:'+ menu.fontColor +';">'+ item +' </DIV>\n<DIV ID="menuItemHilite'+ countItems +'" STYLE="' + textProps + 'top:1;color:'+ menu.fontColorHilite +';visibility:hidden;">'+ item +' </DIV>';
  175.             if (item == "separator") 
  176.             {
  177.                 content += ( dTag + '<DIV ID="menuSeparator'+ countItems +'" STYLE="position:absolute;left:1;top:2;"></DIV>\n<DIV ID="menuSeparatorLite'+ countItems +'" STYLE="position:absolute;left:1;top:2;"></DIV>\n' + dClose);
  178.             } 
  179.             else if (childMenu) 
  180.             {
  181.                 content += ( dTag + dText + '<DIV ID="childMenu'+ countItems +'" STYLE="position:absolute;left:0;top:3;"><IMG SRC="'+menuserver+'/images/header/'+ menu.childMenuIcon +'"></DIV>\n' + dClose);
  182.             } 
  183.             else 
  184.             {
  185.                 content += ( dTag + dText + dClose);
  186.             }
  187.             if (lrs) 
  188.             {
  189.                 l.document.open("text/html");
  190.                 l.document.writeln(content);
  191.                 l.document.close();    
  192.                 content = '';
  193.                 theStat += "-";
  194.                 tsc++;
  195.                 if (tsc > 50) 
  196.                 {
  197.                     tsc = 0;
  198.                     theStat = "";
  199.                 }
  200.                 status = theStat;
  201.             }
  202.             countItems++;  
  203.         }
  204.         if (lrs) 
  205.         {
  206.             // focus layer
  207.             var focusItem = new Layer(100, body);
  208.             focusItem.visiblity="hidden";
  209.             focusItem.document.open("text/html");
  210.             focusItem.document.writeln(" ");
  211.             focusItem.document.close();    
  212.         } 
  213.         else 
  214.         {
  215.           content += '      <DIV ID="focusItem'+ countMenus +'" STYLE="position:absolute;left:0;top:0;visibility:hide;" onClick="onMenuItemAction(null,this);"> </DIV>\n';
  216.           content += '   </DIV>\n  </DIV>\n</DIV>\n';
  217.         }
  218.         i=x;
  219.     }
  220.     if (document.layers) 
  221.     {        
  222.         container.clip.width = window.innerWidth;
  223.         container.clip.height = window.innerHeight;
  224.         container.onmouseout = mouseoutMenu;
  225.         container.menuContainerBgColor = this.menuContainerBgColor;
  226.         for (var i=0; i<container.document.layers.length; i++) 
  227.         {
  228.             proto = container.menus[i];
  229.             var menu = container.document.layers[i];
  230.             container.menus[i].menuLayer = menu;
  231.             container.menus[i].menuLayer.Menu = container.menus[i];
  232.             container.menus[i].menuLayer.Menu.container = container;
  233.             var body = menu.document.layers[0].document.layers[0];
  234.             body.clip.width = proto.menuWidth || body.clip.width;
  235.             body.clip.height = proto.menuHeight || body.clip.height;
  236.             for (var n=0; n<body.document.layers.length-1; n++) 
  237.             {
  238.                 var l = body.document.layers[n];
  239.                 l.Menu = container.menus[i];
  240.                 l.menuHiliteBgColor = proto.menuHiliteBgColor;
  241.                 l.document.bgColor = proto.menuItemBgColor;
  242.                 l.saveColor = proto.menuItemBgColor;
  243.                 l.onmouseover = proto.onMenuItemOver;
  244.                 l.onclick = proto.onMenuItemAction;
  245.                 l.action = container.menus[i].actions[n];
  246.                 l.focusItem = body.document.layers[body.document.layers.length-1];
  247.                 l.clip.width = proto.menuWidth || body.clip.width + proto.menuItemIndent;
  248.                 l.clip.height = proto.menuItemHeight || l.clip.height;
  249.                 if (n>0) l.top = body.document.layers[n-1].top + body.document.layers[n-1].clip.height + proto.menuItemBorder;
  250.                 l.hilite = l.document.layers[1];
  251.                 if (proto.bgImageUp) l.background.src = proto.bgImageUp;
  252.                 l.document.layers[1].isHilite = true;
  253.                 if (l.document.layers[0].id.indexOf("menuSeparator") != -1) 
  254.                 {
  255.                     l.hilite = null;
  256.                     l.clip.height -= l.clip.height / 2;
  257.                     l.document.layers[0].document.bgColor = proto.bgColor;
  258.                     l.document.layers[0].clip.width = l.clip.width -2;
  259.                     l.document.layers[0].clip.height = 1;
  260.                     l.document.layers[1].document.bgColor = proto.menuLiteBgColor;
  261.                     l.document.layers[1].clip.width = l.clip.width -2;
  262.                     l.document.layers[1].clip.height = 1;
  263.                     l.document.layers[1].top = l.document.layers[0].top + 1;
  264.                 } 
  265.                 else if (l.document.layers.length > 2) 
  266.                 {
  267.                     l.childMenu = container.menus[i].items[n].menuLayer;
  268.                     l.document.layers[2].left = l.clip.width -13;
  269.                     l.document.layers[2].top = (l.clip.height / 2) -4;
  270.                     l.document.layers[2].clip.left += 3;
  271.                     l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
  272.                 }
  273.             }
  274.             body.document.bgColor = proto.bgColor;
  275.             body.clip.width  = l.clip.width +proto.menuBorder;
  276.             body.clip.height = l.top + l.clip.height +proto.menuBorder;
  277.             var focusItem = body.document.layers[n];
  278.             focusItem.clip.width = body.clip.width;
  279.             focusItem.Menu = l.Menu;
  280.             focusItem.top = -30;
  281.             focusItem.captureEvents(Event.MOUSEDOWN);
  282.             focusItem.onmousedown = onMenuItemDown;
  283.             menu.document.bgColor = proto.menuBorderBgColor;
  284.             var lite = menu.document.layers[0];
  285.             lite.document.bgColor = proto.menuLiteBgColor;
  286.             lite.clip.width = body.clip.width +1;
  287.             lite.clip.height = body.clip.height +1;
  288.             menu.clip.width = body.clip.width + (proto.menuBorder * 3) ;
  289.             menu.clip.height = body.clip.height + (proto.menuBorder * 3);
  290.         }
  291.     } 
  292.     else 
  293.     {
  294.         if ((!document.all) && (container.hasChildNodes)) 
  295.         {
  296.             container.innerHTML=content;
  297.         } 
  298.         else 
  299.         {
  300.             container.document.open("text/html");
  301.             container.document.writeln(content);
  302.             container.document.close();    
  303.         }
  304.         if (!FIND("menuLayer0")) return;
  305.         var menuCount = 0;
  306.         for (var x=0; x<container.menus.length; x++) 
  307.         {
  308.             var menuLayer = FIND("menuLayer" + x);
  309.             container.menus[x].menuLayer = "menuLayer" + x;
  310.             menuLayer.Menu = container.menus[x];
  311.             menuLayer.Menu.container = "menuLayer" + x;
  312.             menuLayer.style.zIndex = 1;
  313.             var s = menuLayer.style;
  314.             s.top = s.pixelTop = -300;
  315.             s.left = s.pixelLeft = -300;
  316.  
  317.             var menu = container.menus[x];
  318.             menu.menuItemWidth = menu.menuWidth || menu.menuIEWidth || 140;
  319.             menuLayer.style.backgroundColor = menu.menuBorderBgColor;
  320.             var top = 0;
  321.             for (var i=0; i<container.menus[x].items.length; i++) {
  322.                 var l = FIND("menuItem" + menuCount);
  323.                 l.Menu = container.menus[x];
  324.                 if (l.addEventListener) 
  325.                 { // ns6
  326.                     l.style.width = menu.menuItemWidth;    
  327.                     l.style.height = menu.menuItemHeight;
  328.                     l.style.top = top;
  329.                     l.addEventListener("mouseover", onMenuItemOver, false);
  330.                     l.addEventListener("click", onMenuItemAction, false);
  331.                     l.addEventListener("mouseout", mouseoutMenu, false);
  332.                 } 
  333.                 else 
  334.                 { //ie
  335.                     l.style.pixelWidth = menu.menuItemWidth;    
  336.                     l.style.pixelHeight = menu.menuItemHeight;
  337.                     l.style.pixelTop = top;
  338.                 }
  339.                 top = top + menu.menuItemHeight+menu.menuItemBorder;
  340.                 l.style.fontSize = menu.fontSize;
  341.                 l.style.backgroundColor = menu.menuItemBgColor;
  342.                 l.style.visibility = "inherit";
  343.                 l.saveColor = menu.menuItemBgColor;
  344.                 l.menuHiliteBgColor = menu.menuHiliteBgColor;
  345.                 l.action = container.menus[x].actions[i];
  346.                 l.hilite = FIND("menuItemHilite" + menuCount);
  347.                 l.focusItem = FIND("focusItem" + x);
  348.                 l.focusItem.style.pixelTop = l.focusItem.style.top = -30;
  349.                 var childItem = FIND("childMenu" + menuCount);
  350.                 if (childItem) 
  351.                 {
  352.                     l.childMenu = container.menus[x].items[i].menuLayer;
  353.                     childItem.style.pixelLeft = childItem.style.left = menu.menuItemWidth -11;
  354.                     childItem.style.pixelTop = childItem.style.top =(menu.menuItemHeight /2) -4;
  355.                     l.Menu.childMenus[l.Menu.childMenus.length] = l.childMenu;
  356.                 }
  357.                 var sep = FIND("menuSeparator" + menuCount);
  358.                 if (sep) 
  359.                 {
  360.                     sep.style.clip = "rect(0 " + (menu.menuItemWidth - 3) + " 1 0)";
  361.                     sep.style.width = sep.style.pixelWidth = menu.menuItemWidth;    
  362.                     sep.style.backgroundColor = menu.bgColor;
  363.                     sep = FIND("menuSeparatorLite" + menuCount);
  364.                     sep.style.clip = "rect(1 " + (menu.menuItemWidth - 3) + " 2 0)";
  365.                     sep.style.width = sep.style.pixelWidth = menu.menuItemWidth;    
  366.                     sep.style.backgroundColor = menu.menuLiteBgColor;
  367.                     l.style.height = l.style.pixelHeight = menu.menuItemHeight/2;
  368.                     l.isSeparator = true
  369.                     top -= (menu.menuItemHeight - l.style.pixelHeight)
  370.                 } 
  371.                 else 
  372.                 {
  373.                     l.style.cursor = "hand"
  374.                 }
  375.                 menuCount++;
  376.             }
  377.             menu.menuHeight = top-1;
  378.             var lite = FIND("menuLite" + x);
  379.             var s = lite.style;
  380.             s.height = s.pixelHeight = menu.menuHeight +(menu.menuBorder * 2);
  381.             s.width = s.pixelWidth = menu.menuItemWidth + (menu.menuBorder * 2);
  382.             s.backgroundColor = menu.menuLiteBgColor;
  383.  
  384.             var body = FIND("menuFg" + x);
  385.             s = body.style;
  386.             s.height = s.pixelHeight = menu.menuHeight + menu.menuBorder;
  387.             s.width = s.pixelWidth = menu.menuItemWidth + menu.menuBorder;
  388.             s.backgroundColor = menu.bgColor;
  389.  
  390.             s = menuLayer.style;
  391.             s.width = s.pixelWidth  = menu.menuItemWidth + (menu.menuBorder * 4);
  392.             s.height = s.pixelHeight  = menu.menuHeight+(menu.menuBorder*4);
  393.         }
  394.     }
  395.     if (document.captureEvents) 
  396.     {    
  397.         document.captureEvents(Event.MOUSEUP);
  398.     }
  399.     if (document.addEventListener) 
  400.     {    
  401.         document.addEventListener("mouseup", onMenuItemOver, false);
  402.     }
  403.     if (document.layers && window.innerWidth) 
  404.     {
  405.         window.onresize = NS4resize;
  406.         window.NS4sIW = window.innerWidth;
  407.         window.NS4sIH = window.innerHeight;
  408.     }
  409.     document.onmouseup = mouseupMenu;
  410.     window.fwWroteMenu = true;
  411.     status = "";
  412. }
  413.  
  414. function FW_showMenu(menu, x, y, child) 
  415. {    
  416.     if (!window.fwWroteMenu) return;
  417.     FW_clearTimeout();
  418.     
  419.     if (document.layers)     // for NS4.x
  420.     {
  421.         if (menu) 
  422.         {
  423.             var l = menu.menuLayer || menu;
  424.             l.left = 1;
  425.             l.top = 1;
  426.             hideActiveMenus();
  427.             if (this.visibility) l = this;
  428.             window.ActiveMenu = l;
  429.         } 
  430.         else 
  431.         {
  432.             var l = child;
  433.         }
  434.         if (!l) return;
  435.         for (var i=0; i<l.layers.length; i++) 
  436.         {                
  437.             if (!l.layers[i].isHilite) 
  438.                 l.layers[i].visibility = "inherit";
  439.             if (l.layers[i].document.layers.length > 0) 
  440.                 FW_showMenu(null, "relative", "relative", l.layers[i]);
  441.         }
  442.         
  443.         if (l.parentLayer) 
  444.         {
  445.             if (x != "relative") 
  446.             {                
  447.                 l.parentLayer.left = x || window.pageX || 0;                
  448.             }
  449.             if (l.parentLayer.left + l.clip.width > window.innerWidth) 
  450.                 l.parentLayer.left -= (l.parentLayer.left + l.clip.width - window.innerWidth);
  451.             if (y != "relative") 
  452.             {
  453.                 y = y + 5;
  454.                 l.parentLayer.top = y || window.pageY || 0;
  455.             }                
  456.             if (l.parentLayer.isContainer) 
  457.             {
  458.                 l.Menu.xOffset = window.pageXOffset;
  459.                 l.Menu.yOffset = window.pageYOffset;
  460.                 l.parentLayer.clip.width = window.ActiveMenu.clip.width +2;
  461.                 l.parentLayer.clip.height = window.ActiveMenu.clip.height +2;
  462.                 if (l.parentLayer.menuContainerBgColor) l.parentLayer.document.bgColor = l.parentLayer.menuContainerBgColor;
  463.             }
  464.         }
  465.         l.visibility = "inherit";
  466.         if (l.Menu) l.Menu.container.visibility = "inherit";
  467.     }     
  468.     else if (FIND("menuItem0")) // for IE or NS6
  469.     {
  470.         var l = menu.menuLayer || menu;    
  471.  
  472.         hideActiveMenus();
  473.  
  474.         if (typeof(l) == "string") 
  475.         {
  476.             l = FIND(l);
  477.         }
  478.  
  479.         window.ActiveMenu = l;
  480.                 
  481.         var s = l.style;
  482.         s.visibility = "inherit";
  483.         if (x != "relative") 
  484.             s.left = s.pixelLeft = x || (window.pageX + document.body.scrollLeft) || 0;
  485.         if (y != "relative") 
  486.         {
  487.             if (ie4)
  488.                 s.top = s.pixelTop = y || (window.pageY + document.body.scrollTop) || 0;
  489.             else
  490.                 s.top = s.pixelTop = (y - 7) || (window.pageY + document.body.scrollTop) || 0;
  491.         }
  492.         l.Menu.xOffset = document.body.scrollLeft;
  493.         l.Menu.yOffset = document.body.scrollTop;
  494.     }
  495.     
  496.     // swap image when mouse over (added codes)
  497.     switch(window.ActiveMenu.Menu.id)
  498.     {
  499.         case 0:
  500.             MM_swapImage('imgPartners','',menuserver+'/images/header/on5.gif',1);
  501.             break;
  502.         case 1:
  503.             MM_swapImage('imgCompany','',menuserver+'/images/header/on4.gif',1);
  504.             break;            
  505.         case 2:
  506.             MM_swapImage('imgBuy','',menuserver+'/images/header/on3.gif',1);
  507.             break;            
  508.         case 3:
  509.             MM_swapImage('imgSupport','',menuserver+'/images/header/on2.gif',1);
  510.             break;            
  511.         case 4:
  512.             MM_swapImage('imgProducts','',menuserver+'/images/header/on1.gif',1);
  513.             break;        
  514.     }        
  515.     
  516.     if (menu) 
  517.     {
  518.         window.activeMenus[window.activeMenus.length] = l;        
  519.     }
  520. }
  521.  
  522.  
  523. function onMenuItemOver(e, l) 
  524. {
  525.     FW_clearTimeout();
  526.     l = l || this;
  527.     a = window.ActiveMenuItem;
  528.  
  529.     if (document.layers) 
  530.     {
  531.         if (a) 
  532.         {            
  533.             a.document.bgColor = a.saveColor;
  534.             if (a.hilite) a.hilite.visibility = "hidden";
  535.             if (a.Menu.bgImageOver) 
  536.             {
  537.                 a.background.src = a.Menu.bgImageUp;
  538.             }
  539.             a.focusItem.top = -100;
  540.             a.clicked = false;
  541.         }
  542.         if (l.hilite) 
  543.         {
  544.             l.document.bgColor = l.menuHiliteBgColor;
  545.             l.zIndex = 1;
  546.             l.hilite.visibility = "inherit";
  547.             l.hilite.zIndex = 2;
  548.             l.document.layers[1].zIndex = 1;
  549.             l.focusItem.zIndex = this.zIndex +2;
  550.         }
  551.         if (l.Menu.bgImageOver) 
  552.         {
  553.             l.background.src = l.Menu.bgImageOver;
  554.         }
  555.         l.focusItem.top = this.top;
  556.         l.Menu.hideChildMenu(l);
  557.     } 
  558.     else if (l.style && l.Menu)     // for IE or NS6
  559.     {
  560.         if (a) 
  561.         {
  562.             a.style.backgroundColor = a.saveColor;
  563.             if (a.hilite) a.hilite.style.visibility = "hidden";
  564.             if (a.Menu.bgImageUp) 
  565.             {
  566.                 a.style.background = "url(" + a.Menu.bgImageUp +")";;
  567.             }
  568.         } 
  569.         if (l.isSeparator) return;
  570.         l.style.backgroundColor = l.menuHiliteBgColor;
  571.         l.zIndex = 1;  // magic IE 4.5 mac happy doohicky.    jba
  572.         if (l.Menu.bgImageOver) 
  573.         {
  574.             l.style.background = "url(" + l.Menu.bgImageOver +")";
  575.         }
  576.         if (l.hilite) 
  577.         {
  578.             l.style.backgroundColor = l.menuHiliteBgColor;
  579.             l.hilite.style.visibility = "inherit";
  580.         }
  581.         l.focusItem.style.top = l.focusItem.style.pixelTop = l.style.pixelTop;
  582.         l.focusItem.style.zIndex = l.zIndex +1;
  583.         l.Menu.hideChildMenu(l);
  584.     } 
  585.     else 
  586.     {
  587.         return; // not a menu - magic IE 4.5 mac happy doohicky.  jba
  588.     }
  589.     window.ActiveMenuItem = l;
  590. }
  591.  
  592. function onMenuItemAction(e, l) 
  593. {
  594.     l = window.ActiveMenuItem;
  595.     if (!l) return;
  596.     hideActiveMenus();
  597.     if (l.action) 
  598.     {
  599.         eval("" + l.action);
  600.     }
  601.     window.ActiveMenuItem = 0;
  602. }
  603.  
  604. function hideMenu(mouseup, e) 
  605. {
  606.     var a = window.ActiveMenuItem;
  607.         
  608.     if (a && document.layers) 
  609.     {
  610.         a.document.bgColor = a.saveColor;
  611.         a.focusItem.top = -30;
  612.         if (a.hilite) a.hilite.visibility = "hidden";
  613.         if (mouseup && a.action && a.clicked && window.ActiveMenu) 
  614.         {
  615.              if (a.eX <= e.pageX+15 && a.eX >= e.pageX-15 && a.eY <= e.pageY+10 && a.eY >= e.pageY-10) 
  616.             {
  617.                 setTimeout('window.ActiveMenu.Menu.onMenuItemAction();', 2);
  618.             }
  619.         }
  620.         a.clicked = false;
  621.         if (a.Menu.bgImageOver) 
  622.         {
  623.             a.background.src = a.Menu.bgImageUp;
  624.         }
  625.     } 
  626.     else if (window.ActiveMenu && FIND("menuItem0")) 
  627.     {
  628.         if (a) 
  629.         {
  630.             a.style.backgroundColor = a.saveColor;
  631.             if (a.hilite) a.hilite.style.visibility = "hidden";
  632.             if (a.Menu.bgImageUp) 
  633.             {
  634.                 a.style.background = "url(" + a.Menu.bgImageUp +")";;
  635.             }
  636.         }
  637.     }
  638.     if (!mouseup && window.ActiveMenu) 
  639.     {
  640.         if (window.ActiveMenu.Menu) 
  641.         {
  642.             if (window.ActiveMenu.Menu.hideOnMouseOut) 
  643.             {
  644.                 FW_startTimeout();
  645.             }
  646.             return(true);
  647.         }
  648.     }
  649.     return(true);
  650. }
  651.  
  652. function hideChildMenu(hcmLayer) 
  653. {
  654.     FW_clearTimeout();
  655.     var l = hcmLayer;
  656.     for (var i=0; i < l.Menu.childMenus.length; i++) 
  657.     {
  658.         var theLayer = l.Menu.childMenus[i];
  659.         if (document.layers) 
  660.         {
  661.             theLayer.visibility = "hidden";
  662.         } 
  663.         else 
  664.         {
  665.             theLayer = FIND(theLayer);
  666.             theLayer.style.visibility = "hidden";
  667.         }
  668.         theLayer.Menu.hideChildMenu(theLayer);
  669.     }
  670.  
  671.     if (l.childMenu) 
  672.     {
  673.         var childMenu = l.childMenu;
  674.         if (document.layers) 
  675.         {
  676.             l.Menu.FW_showMenu(null,null,null,childMenu.layers[0]);
  677.             childMenu.zIndex = l.parentLayer.zIndex +1;
  678.             childMenu.top = l.top + l.parentLayer.top + l.Menu.menuLayer.top + 1;
  679.             
  680.             if (childMenu.left + childMenu.clip.width > window.innerWidth) 
  681.             {
  682.                 childMenu.left = l.parentLayer.left - childMenu.clip.width + l.Menu.menuLayer.left + 15;
  683.                 l.Menu.container.clip.left -= childMenu.clip.width;
  684.             } 
  685.             else 
  686.             {
  687.                 childMenu.left = l.parentLayer.left + l.parentLayer.clip.width  + l.Menu.menuLayer.left - 2;
  688.             }
  689.             var w = childMenu.clip.width+childMenu.left-l.Menu.container.clip.left;
  690.             if (w > l.Menu.container.clip.width)  
  691.                 l.Menu.container.clip.width = w;
  692.             var h = childMenu.clip.height+childMenu.top-l.Menu.container.clip.top;
  693.             if (h > l.Menu.container.clip.height) l.Menu.container.clip.height = h;
  694.             l.document.layers[1].zIndex = 0;
  695.             childMenu.visibility = "inherit";
  696.         } 
  697.         else if (FIND("menuItem0")) 
  698.         {
  699.             childMenu = FIND(l.childMenu);
  700.             var menuLayer = FIND(l.Menu.menuLayer);
  701.             var s = childMenu.style;
  702.             s.zIndex = menuLayer.style.zIndex+1;
  703.             if (document.all) 
  704.             { // ie case.
  705.                 s.pixelTop = l.style.pixelTop + menuLayer.style.pixelTop + 2;
  706.                 s.left = s.pixelLeft = (menuLayer.style.pixelWidth) + menuLayer.style.pixelLeft - 3;    
  707.             } 
  708.             else 
  709.             { // zilla case
  710.                 var top = PxToNum(l.style.top) + PxToNum(menuLayer.style.top) + 2;
  711.                 var left = (PxToNum(menuLayer.style.width)) + PxToNum(menuLayer.style.left) - 3;
  712.                 s.top = top;
  713.                 s.left = left;
  714.             }
  715.             childMenu.style.visibility = "inherit";
  716.         } 
  717.         else 
  718.         {
  719.             return;
  720.         }
  721.         window.activeMenus[window.activeMenus.length] = childMenu;
  722.     }
  723. }
  724.  
  725. function FW_clearTimeout()
  726. {
  727.     if (fwHideMenuTimer) clearTimeout(fwHideMenuTimer);
  728.     fwHideMenuTimer = null;
  729.     fwDHFlag = false;
  730. }
  731.  
  732. function FW_startTimeout()
  733. {
  734.     fwStart = new Date();
  735.     fwDHFlag = true;
  736.     fwHideMenuTimer = setTimeout("fwDoHide()", 1000);
  737. }
  738.  
  739. function fwDoHide()
  740. {
  741.     if (!fwDHFlag) return;    
  742.     
  743.     var elapsed = new Date() - fwStart;
  744.     if (elapsed < 1000) 
  745.     {
  746.         fwHideMenuTimer = setTimeout("fwDoHide()", 1100-elapsed);
  747.         return;
  748.     }
  749.  
  750.     fwDHFlag = false;
  751.     hideActiveMenus();    
  752.     window.ActiveMenuItem = 0;
  753. }
  754.  
  755.  
  756. function onMenuItemDown(e, l) 
  757. {
  758.     var a = window.ActiveMenuItem;
  759.  
  760.     if (document.layers) 
  761.     {
  762.         if (a) 
  763.         {
  764.             a.eX = e.pageX;
  765.             a.eY = e.pageY;
  766.             a.clicked = true;
  767.         }
  768.     }
  769. }
  770.  
  771. function mouseupMenu(e)
  772. {
  773.     hideMenu(true, e);
  774.     hideActiveMenus();
  775.     return true;
  776. }
  777.  
  778. function mouseoutMenu()
  779. {
  780.     hideMenu(false, false);
  781.     return true;
  782. }
  783.  
  784.  
  785. function PxToNum(pxStr)
  786. { // pxStr == 27px, we want 27.
  787.     if (pxStr.length > 2) 
  788.     {
  789.         n = Number(pxStr.substr(0, pxStr.length-2));
  790.         return(n);
  791.     }
  792.     return(0);
  793. }
  794.  
  795. function hideActiveMenus() 
  796. {
  797.     if (!window.activeMenus) {return;}
  798.     
  799.     for (var i=0; i < window.activeMenus.length; i++) 
  800.     {
  801.         if (!activeMenus[i]) {continue;}
  802.         if (activeMenus[i].visibility && activeMenus[i].Menu) 
  803.         {
  804.             activeMenus[i].visibility = "hidden";
  805.             activeMenus[i].Menu.container.visibility = "hidden";
  806.             activeMenus[i].Menu.container.clip.left = 0;
  807.         } 
  808.         else if (activeMenus[i].style) 
  809.         {
  810.             var s = activeMenus[i].style;
  811.             s.visibility = "hidden";
  812.             s.left = -200;
  813.             s.top = -200;
  814.         }
  815.     }
  816.     if (window.ActiveMenuItem) 
  817.     {
  818.         hideMenu(false, false);
  819.     }
  820.     
  821.     window.activeMenus.length = 0;
  822.     MM_swapImgRestore();
  823. }
  824.  
  825.  
  826. function FIND(item) 
  827. {
  828.     if (document.all) return(document.all[item]);
  829.     if (document.getElementById) return(document.getElementById(item));
  830.     return(false);
  831. }
  832.  
  833. function NS4resize() 
  834. {
  835.     if (NS4sIW < window.innerWidth || 
  836.         NS4sIW > window.innerWidth || 
  837.         NS4sIH > window.innerHeight || 
  838.         NS4sIH < window.innerHeight ) 
  839.     {
  840.         window.location.reload();
  841.     }
  842. }
  843.