home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2001 January / PCpro_2001_01.IMG / library / toolbar / toolbar.js
Encoding:
Text File  |  2000-01-21  |  18.4 KB  |  621 lines

  1. var ToolBar_Supported = false;
  2. var Frame_Supported   = false;
  3. var DoInstrumentation = false;
  4. myloc = document.location.pathname;
  5. myloc = myloc.substring(0,myloc.indexOf("germany")-1);
  6.  
  7.  
  8. if (navigator.userAgent.indexOf("MSIE")    != -1 && 
  9.     navigator.userAgent.indexOf("Windows") != -1 && 
  10.     navigator.appVersion.substring(0,1) > 3)
  11. {
  12.     ToolBar_Supported = true;
  13. }
  14.  
  15. if (ToolBar_Supported)
  16. {
  17.     var newLineChar = String.fromCharCode(10);
  18.     var char34 = String.fromCharCode(34);
  19.     var LastMSMenu = "";
  20.     var CurICPMenu = "";
  21.     var IsMSMenu = false;
  22.     var IsMenuDropDown = true;
  23.     var HTMLStr;
  24.     var x = 0;
  25.     var y = 0;
  26.     var x2 = 0;
  27.     var y2 = 0;
  28.     var MSMenuWidth;
  29.     var ToolbarMinWidth;
  30.     var ToolbarMenu;
  31.     var ToolbarBGColor;
  32.     var ToolbarLoaded = false;
  33.     var aDefMSColor  = new Array(3);
  34.     var aDefICPColor = new Array(3);
  35.     var aCurMSColor  = new Array(3);
  36.     var aCurICPColor = new Array(3);
  37.     var MSFont;
  38.     var ICPFont;
  39.     var MaxMenu = 30;
  40.     var TotalMenu = 0;
  41.     var arrMenuInfo = new Array(30);
  42.  
  43.     // Output style sheet and toolbar ID
  44.     document.write("<SPAN ID='StartMenu' STYLE='display:none;'></SPAN>");
  45.  
  46.     // Build toolbar template
  47.     HTMLStr = 
  48.         "<DIV ID='idToolbar'     STYLE='background-color:white;width:100%'>" +
  49.         "<DIV ID='idRow1'        STYLE='position:relative;height:20;'>" +
  50.         "<DIV ID='idICPBanner'   STYLE='position:absolute;top:0;left:0;height:60;width:250;overflow:hidden;vertical-align:top;'><!--BEG_ICP_BANNER--><!--END_ICP_BANNER--></DIV>" +
  51.         "<DIV ID='idMSMenuCurve' STYLE='position:absolute;top:0;left:250;height:20;width:18;overflow:hidden;vertical-align:top;'><IMG SRC='"+myloc+"/library/toolbar/images/curve.gif' BORDER=0></DIV>" +
  52.         "<DIV ID='idMSMenuPane'  STYLE='position:absolute;top:0;left:250;height:20;width:10;background-color:black;float:right;' NOWRAP><!--MS_MENU_TITLES--></DIV>" + 
  53.         "</DIV>" +
  54.         "<DIV ID='idRow2' STYLE='position:relative;left:250;height:40;'>" +
  55.         "<DIV ID='idADSBanner'   STYLE='position:absolute;top:0;left:0;height:40;width:200;vertical-align:top;overflow:hidden;'><!--BEG_ADS_BANNER--><!--END_ADS_BANNER--></DIV>" +
  56.         "<DIV ID='idMSCBanner'   STYLE='position:absolute;top:0;left:200;height:40;width:112;vertical-align:top;overflow:hidden;' ALIGN=RIGHT><!--BEG_MSC_BANNER--><!--END_MSC_BANNER--></DIV>" +
  57.         "</DIV>" +
  58.         "<DIV ID='idRow3' STYLE='position:relative;height:20;width:100%'>" +
  59.         "<DIV ID='idICPMenuPane' STYLE='position:absolute;top:0;left:0;height:20;background-color:black;' NOWRAP><!--ICP_MENU_TITLES--></DIV>" +
  60.         "</DIV>" +
  61.         "</DIV>" +
  62.         "<SCRIPT TYPE='text/javascript'>" + 
  63.         "   var ToolbarMenu = StartMenu;" + 
  64.         "</SCRIPT>" + 
  65.         "<DIV WIDTH=100%>";
  66.  
  67.     // Define event handlers
  68.     window.onresize  = resizeToolbar;
  69.  
  70.     // Intialize global variables
  71.     ToolbarBGColor    = "white";                        // toolbar background color
  72.     MSFont  = "xx-small Verdana";
  73.     ICPFont = "bold xx-small Verdana";
  74.     
  75.     aDefMSColor[0]    = aCurMSColor[0]  = "black";    // bgcolor;
  76.     aDefMSColor[1]    = aCurMSColor[1]  = "white";    // text font color
  77.     aDefMSColor[2]  = aCurMSColor[2]  = "red";        // mouseover font color
  78.     
  79.     aDefICPColor[0]    = aCurICPColor[0] = "#6699CC";    // bgcolor;
  80.     aDefICPColor[1] = aCurICPColor[1] = "white";    // text font color
  81.     aDefICPColor[2] = aCurICPColor[2] = "red";        // mouseover font color
  82. }
  83.  
  84. // The hard-coded numbers in functions - drawToolbar() & resizeToolbar()
  85. // correspond to the dimension of the four gif files:
  86. //        ICP_BANNER: 60h x 250w
  87. //        ADS_BANNER: 40h x 200w
  88. //        MSC_BANNER: 40h x 112w
  89. //        Curve:        20h x 18w
  90.  
  91. function drawToolbar()
  92. {
  93.     HTMLStr += "</DIV>";
  94.     document.write(HTMLStr);
  95.     ToolbarLoaded = true;
  96.  
  97.     MSMenuWidth     = Math.max(idMSMenuPane.offsetWidth, (200+112));
  98.     ToolbarMinWidth = (250+18) + MSMenuWidth;
  99.  
  100.     idToolbar.style.backgroundColor     = ToolbarBGColor;
  101.     idMSMenuPane.style.backgroundColor  = aDefMSColor[0];
  102.     idICPMenuPane.style.backgroundColor = aDefICPColor[0];
  103.     resizeToolbar();
  104.  
  105.     for (i = 0; i < TotalMenu; i++) 
  106.     {
  107.         thisMenu = document.all(arrMenuInfo[i].IDStr);
  108.         if (thisMenu != null)
  109.         {
  110.             if (arrMenuInfo[i].IDStr == LastMSMenu && arrMenuInfo[i].type == "R")
  111.             {
  112.                 //Last MSMenu has to be absolute width
  113.                 arrMenuInfo[i].type = "A";
  114.                 arrMenuInfo[i].unit = 200;
  115.             }
  116.             if (arrMenuInfo[i].type == "A")
  117.                 thisMenu.style.width = arrMenuInfo[i].unit;
  118.             else 
  119.                 thisMenu.style.width = Math.round(arrMenuInfo[i].width * arrMenuInfo[i].unit) + 'em';
  120.         }
  121.     }
  122. }
  123.  
  124. function resizeToolbar()
  125. {
  126.     if (ToolBar_Supported == false) return;
  127.  
  128.     w = Math.max(ToolbarMinWidth, document.body.clientWidth) - ToolbarMinWidth;
  129.     
  130.     idMSMenuCurve.style.left  = (250+w);
  131.     idMSMenuPane.style.left   = (250+w+18);
  132.     idMSMenuPane.style.width  = MSMenuWidth;
  133.  
  134.     idADSBanner.style.left    = (w+18);
  135.  
  136.     idMSCBanner.style.left    = (w+18+200);
  137.     idMSCBanner.style.width   = (MSMenuWidth - 200);
  138.     
  139.     idICPMenuPane.style.width = ToolbarMinWidth + w;
  140. }
  141.  
  142. function setToolbarBGColor(color)
  143. {    
  144.     ToolbarBGColor = color;
  145.     if (ToolbarLoaded == true)
  146.         idToolbar.style.backgroundColor = ToolbarBGColor;
  147. }    
  148.  
  149. function setMSMenuFont(sFont)
  150. {    MSFont = sFont;
  151. }
  152.  
  153. function setICPMenuFont(sFont)
  154. {    ICPFont = sFont;
  155. }
  156.  
  157. function setDefaultMSMenuColor(bgColor, fontColor, mouseoverColor)
  158. {    
  159.     if (bgColor   != "")      aDefMSColor[0] = bgColor;
  160.     if (fontColor != "")      aDefMSColor[1] = fontColor;
  161.     if (mouseoverColor != "") aDefMSColor[2] = mouseoverColor;
  162. }
  163.  
  164. function setDefaultICPMenuColor(bgColor, fontColor, mouseoverColor)
  165. {    
  166.     if (bgColor   != "")      aDefICPColor[0] = bgColor;
  167.     if (fontColor != "")      aDefICPColor[1] = fontColor;
  168.     if (mouseoverColor != "") aDefICPColor[2] = mouseoverColor;
  169. }
  170.  
  171. function setICPMenuColor(MenuIDStr, bgColor, fontColor, mouseoverColor)
  172. {    
  173.     if (ToolbarLoaded == false) return;
  174.  
  175.     // Reset previous ICP Menu color if any
  176.     if (CurICPMenu != "")
  177.     {
  178.         PrevID = CurICPMenu.substring(4);
  179.         CurICPMenu = "";
  180.         setICPMenuColor(PrevID, aDefICPColor[0], aDefICPColor[1], aDefICPColor[2]);
  181.     }
  182.  
  183.     var    id = "AM_" + "ICP_" + MenuIDStr;
  184.     var thisMenu = document.all(id);
  185.     if (thisMenu != null)
  186.     {
  187.         CurICPMenu = "ICP_" + MenuIDStr;
  188.         aCurICPColor[0] = bgColor;
  189.         aCurICPColor[1] = fontColor;
  190.         aCurICPColor[2] = mouseoverColor;
  191.  
  192.         // Change menu color
  193.         if (bgColor != "")
  194.             thisMenu.style.backgroundColor = bgColor;
  195.         if (fontColor != "")
  196.             thisMenu.style.color = fontColor;
  197.  
  198.         // Change subMenu color
  199.         id = "ICP_" + MenuIDStr;
  200.         thisMenu = document.all(id);
  201.         if (thisMenu != null)
  202.         {
  203.             if (bgColor != "")
  204.                 thisMenu.style.backgroundColor = bgColor;
  205.             
  206.             if (fontColor != "")
  207.             {
  208.                 i = 0;
  209.                 id = "AS_" + "ICP_" + MenuIDStr;
  210.                 thisMenu = document.all.item(id,i);
  211.                 while (thisMenu != null)
  212.                 {
  213.                     thisMenu.style.color = fontColor;
  214.                     i += 1;
  215.                     thisMenu = document.all.item(id,i);
  216.                 }
  217.             }
  218.         }
  219.     }
  220. }
  221.  
  222. function setAds(Gif,Url,AltStr)
  223. {    setBanner(Gif,Url,AltStr,"<!--BEG_ADS_BANNER-->","<!--END_ADS_BANNER-->");
  224. }
  225.  
  226. function setICPBanner(Gif,Url,AltStr)
  227. {    setBanner(Gif,Url,AltStr,"<!--BEG_ICP_BANNER-->","<!--END_ICP_BANNER-->");
  228. }
  229.  
  230. function setMSBanner(Gif,Url,AltStr)
  231. {    tempGif = myloc+"/library/toolbar/images/" + Gif;
  232.     setBanner(tempGif,Url,AltStr,"<!--BEG_MSC_BANNER-->","<!--END_MSC_BANNER-->");
  233. }
  234.  
  235. function setBanner(BanGif, BanUrl, BanAltStr, BanBegTag, BanEndTag)
  236. {
  237.     begPos = HTMLStr.indexOf(BanBegTag);
  238.     endPos = HTMLStr.indexOf(BanEndTag) + BanEndTag.length;
  239.     
  240.     SubStr = HTMLStr.substring(begPos, endPos);
  241.     SrcStr = "";
  242.     if (BanUrl != "")
  243.         SrcStr += "<A Target='_top' HREF='" + formatURL(BanUrl, BanGif) + "'>";
  244.     SrcStr += "<IMG SRC='" + BanGif + "' ALT='" + BanAltStr + "' BORDER=0>";
  245.     if (BanUrl != "")
  246.         SrcStr += "</A>";
  247.     SrcStr = BanBegTag + SrcStr + BanEndTag;
  248.     HTMLStr = HTMLStr.replace(SubStr, SrcStr);    
  249. }
  250.  
  251. function setICPSubMenuWidth(MenuIDStr, WidthType, WidthUnit)
  252. {    tempID = "ICP_" + MenuIDStr;
  253.     setSubMenuWidth(tempID, WidthType, WidthUnit);
  254. }
  255.  
  256. function setMSSubMenuWidth(MenuIDStr, WidthType, WidthUnit)
  257. {    tempID = "MS_" + MenuIDStr;
  258.     setSubMenuWidth(tempID, WidthType, WidthUnit);
  259. }
  260.  
  261. function setSubMenuWidth(MenuIDStr, WidthType, WidthUnit)
  262. {
  263.     var fFound = false;
  264.     if (TotalMenu == MaxMenu)
  265.     {
  266.         alert("Unable to process menu. Maximum of " + MaxMenu + " reached.");
  267.         return;
  268.     }
  269.     
  270.     for (i = 0; i < TotalMenu; i++)
  271.         if (arrMenuInfo[i].IDStr == MenuIDStr)
  272.         {
  273.             fFound = true;
  274.             break;
  275.         }
  276.  
  277.     if (!fFound)
  278.     {
  279.         arrMenuInfo[i] = new menuInfo(MenuIDStr);
  280.         TotalMenu += 1;
  281.     }
  282.  
  283.     if (!fFound && WidthType.toUpperCase().indexOf("DEFAULT") != -1)
  284.     {
  285.         arrMenuInfo[i].type = "A";
  286.         arrMenuInfo[i].unit = 160;
  287.     }
  288.     else
  289.     {
  290.         arrMenuInfo[i].type = (WidthType.toUpperCase().indexOf("ABSOLUTE") != -1)? "A" : "R";
  291.         arrMenuInfo[i].unit = WidthUnit;
  292.     }
  293. }
  294.  
  295. // This function creates a menuInfo object instance.
  296. function menuInfo(MenuIDStr)
  297. {
  298.     this.IDStr = MenuIDStr;
  299.     this.type  = "";
  300.     this.unit  = 0;
  301.     this.width = 0;
  302.     this.count = 0;
  303. }
  304.  
  305. function updateSubMenuWidth(MenuIDStr)
  306. {
  307.     for (i = 0; i < TotalMenu; i++)
  308.         if (arrMenuInfo[i].IDStr == MenuIDStr)
  309.         {
  310.             if (arrMenuInfo[i].width < MenuIDStr.length) 
  311.                 arrMenuInfo[i].width = MenuIDStr.length;
  312.             arrMenuInfo[i].count = arrMenuInfo[i].count + 1;
  313.             break;
  314.         }
  315. }
  316.  
  317. function addICPMenu(MenuIDStr, MenuDisplayStr, MenuHelpStr, MenuURLStr)
  318. {     
  319.     if (addICPMenu.arguments.length > 4)
  320.         TargetStr = addICPMenu.arguments[4];
  321.     else
  322.         TargetStr = "_top";
  323.     tempID = "ICP_" + MenuIDStr;
  324.     addMenu(tempID, MenuDisplayStr, MenuHelpStr, MenuURLStr, TargetStr, true); 
  325. }
  326.  
  327. function addMSMenu(MenuIDStr, MenuDisplayStr, MenuHelpStr, MenuURLStr)
  328. {    
  329.     TargetStr = "_top";
  330.     tempID = "MS_" + MenuIDStr;
  331.     addMenu(tempID, MenuDisplayStr, MenuHelpStr, MenuURLStr, TargetStr, false); 
  332.     LastMSMenu = tempID;
  333. }
  334.  
  335. function addMenu(MenuIDStr, MenuDisplayStr, MenuHelpStr, MenuURLStr, TargetStr, bICPMenu)
  336. {
  337.     cFont   = bICPMenu? ICPFont : MSFont;
  338.     cColor0 = bICPMenu? aDefICPColor[0] : aDefMSColor[0];
  339.     cColor1 = bICPMenu? aDefICPColor[1] : aDefMSColor[1];
  340.     cColor2 = bICPMenu? aDefICPColor[2] : aDefMSColor[2];
  341.     tagStr  = bICPMenu? "<!--ICP_MENU_TITLES-->" : "<!--MS_MENU_TITLES-->";
  342.  
  343.     MenuStr = newLineChar;
  344.     if (bICPMenu == false && LastMSMenu != "")
  345.         MenuStr += "<SPAN STYLE='font:" + cFont + ";color:" + cColor1 + "'> </SPAN>"; 
  346.     MenuStr += "<A TARGET='" + TargetStr + "' TITLE='" + MenuHelpStr + "'" +
  347.                "   ID='AM_" + MenuIDStr + "'" +
  348.                "   STYLE='text-decoration:none;cursor:hand;font:" + cFont + ";background-color:" + cColor0 + ";color:" + cColor1 + ";'";
  349.     if (MenuURLStr != "")
  350.     {
  351.         if (bICPMenu)
  352.             MenuStr += " HREF='" + formatURL(MenuURLStr, ("ICP_" + MenuDisplayStr)) + "'";
  353.         else
  354.             MenuStr += " HREF='" + formatURL(MenuURLStr, ("MS_" + MenuDisplayStr)) + "'";
  355.     }
  356.     else
  357.         MenuStr += " HREF='' onclick='window.event.returnValue=false;'";
  358.     MenuStr +=     " onmouseout="  + char34 + "mouseMenu('out' ,'" + MenuIDStr + "'); hideMenu();" + char34 + 
  359.                 " onmouseover=" + char34 + "mouseMenu('over','" + MenuIDStr + "'); doMenu('"+ MenuIDStr + "');" + char34 + ">" +
  360.                 " " + MenuDisplayStr + " </a>";
  361.     if (bICPMenu)
  362.         MenuStr += "<SPAN STYLE='font:" + cFont + ";color:" + cColor1 + "'> </SPAN>";
  363.     MenuStr += tagStr;
  364.     
  365.     HTMLStr = HTMLStr.replace(tagStr, MenuStr);    
  366.     setSubMenuWidth(MenuIDStr,"default",0);
  367. }
  368.  
  369. function addICPSubMenu(MenuIDStr, SubMenuStr, SubMenuURLStr)
  370. {    
  371.     if (addICPSubMenu.arguments.length > 3)
  372.         TargetStr = addICPSubMenu.arguments[3];
  373.     else
  374.         TargetStr = "_top";
  375.     tempID = "ICP_" + MenuIDStr;
  376.     addSubMenu(tempID,SubMenuStr,SubMenuURLStr,TargetStr,true); 
  377. }
  378.  
  379. function addMSSubMenu(MenuIDStr, SubMenuStr, SubMenuURLStr)
  380. {    
  381.     TargetStr = "_top";
  382.     tempID = "MS_" + MenuIDStr;
  383.     addSubMenu(tempID,SubMenuStr,SubMenuURLStr,TargetStr,false); 
  384. }
  385.  
  386. function addSubMenu(MenuIDStr, SubMenuStr, SubMenuURLStr, TargetStr, bICPMenu)
  387. {
  388.     cFont   = bICPMenu? ICPFont : MSFont;
  389.     cColor0 = bICPMenu? aDefICPColor[0] : aDefMSColor[0];
  390.     cColor1 = bICPMenu? aDefICPColor[1] : aDefMSColor[1];
  391.     cColor2 = bICPMenu? aDefICPColor[2] : aDefMSColor[2];
  392.     
  393.     var MenuPos = MenuIDStr.toUpperCase().indexOf("MENU");
  394.     if (MenuPos == -1) { MenuPos = MenuIDStr.length; }
  395.     InstrumentStr = MenuIDStr.substring(0 , MenuPos) + "" + SubMenuStr;;
  396.     URLStr        = formatURL(SubMenuURLStr, InstrumentStr);
  397.  
  398.     var LookUpTag  = "<!--" + MenuIDStr + "-->";
  399.     var sPos = HTMLStr.indexOf(LookUpTag);
  400.     if (sPos <= 0)
  401.     {
  402.         HTMLStr += newLineChar + newLineChar +
  403.                 "<SPAN ID='" + MenuIDStr + "'" +
  404.                 " STYLE='display:none;position:absolute;width:160;background-color:" + cColor0 + ";padding-top:0;padding-left:0;padding-bottom:20;z-index:9;'" +
  405.                 " onmouseout='hideMenu();'>";
  406.         if (Frame_Supported == false || bICPMenu == false)
  407.             HTMLStr += "<HR  STYLE='position:absolute;left:0;top:0;color:" + cColor1 + "' SIZE=1>";
  408.         HTMLStr += "<DIV STYLE='position:relative;left:0;top:8;'>";
  409.     }
  410.  
  411.     TempStr = newLineChar +
  412.                 "<A ID='AS_" + MenuIDStr + "'" +
  413.                 "   STYLE='text-decoration:none;cursor:hand;font:" + cFont + ";color:" + cColor1 + "'" +
  414.                 "   HREF='" + URLStr + "' TARGET='" + TargetStr + "'" +
  415.                 " onmouseout="  + char34 + "mouseMenu('out' ,'" + MenuIDStr + "');" + char34 + 
  416.                 " onmouseover=" + char34 + "mouseMenu('over','" + MenuIDStr + "');" + char34 + ">" +
  417.                 " " + SubMenuStr + "</A><BR>" + LookUpTag;
  418.     if (sPos <= 0)
  419.         HTMLStr += TempStr + "</DIV></SPAN>";
  420.     else
  421.         HTMLStr = HTMLStr.replace(LookUpTag, TempStr);    
  422.  
  423.     updateSubMenuWidth(MenuIDStr);    
  424. }
  425.  
  426. function addICPSubMenuLine(MenuIDStr)
  427. {    
  428.     tempID = "ICP_" + MenuIDStr;
  429.     addSubMenuLine(tempID,true);
  430. }
  431.  
  432. function addMSSubMenuLine(MenuIDStr)
  433. {    
  434.     tempID = "MS_" + MenuIDStr;
  435.     addSubMenuLine(tempID,false);
  436. }
  437.  
  438. function addSubMenuLine(MenuIDStr, bICPMenu)
  439. {
  440.     var LookUpTag = "<!--" + MenuIDStr + "-->";
  441.     var sPos = HTMLStr.indexOf(LookUpTag);
  442.     if (sPos > 0)
  443.     {
  444.         cColor  = bICPMenu? aDefICPColor[1] : aDefMSColor[1];
  445.         TempStr = newLineChar + "<HR STYLE='color:" + cColor + "' SIZE=1>" + LookUpTag;
  446.         HTMLStr = HTMLStr.replace(LookUpTag, TempStr);
  447.     }
  448. }
  449.  
  450. function mouseMenu(id, MenuIDStr) 
  451. {
  452.     IsMSMenu   = (MenuIDStr.toUpperCase().indexOf("MS_") != -1);
  453.     IsMouseout = (id.toUpperCase().indexOf("OUT") != -1);
  454.  
  455.     if (IsMouseout)
  456.     {
  457.         color = IsMSMenu? aDefMSColor[1] : aDefICPColor[1];
  458.         if (MenuIDStr == CurICPMenu && aCurICPColor[1] != "") 
  459.             color = aCurICPColor[1];
  460.     }
  461.     else
  462.     {
  463.         color = IsMSMenu? aDefMSColor[2] : aDefICPColor[2];
  464.         if (MenuIDStr == CurICPMenu && aCurICPColor[2] != "") 
  465.             color = aCurICPColor[2];
  466.     }
  467.     window.event.srcElement.style.color = color;
  468. }
  469.  
  470. function doMenu(MenuIDStr) 
  471. {
  472.     var thisMenu = document.all(MenuIDStr);
  473.     if (ToolbarMenu == null || thisMenu == null || thisMenu == ToolbarMenu) 
  474.     {
  475.         window.event.cancelBubble = true;
  476.         return false;
  477.     }
  478.     // Reset dropdown menu
  479.     window.event.cancelBubble = true;
  480.     ToolbarMenu.style.display = "none";
  481.     showElement("SELECT");
  482.     showElement("OBJECT");
  483.     ToolbarMenu = thisMenu;
  484.     IsMSMenu = (MenuIDStr.toUpperCase().indexOf("MS_") != -1);
  485.  
  486.     // Set dropdown menu display position
  487.     x  = window.event.srcElement.offsetLeft +
  488.           window.event.srcElement.offsetParent.offsetLeft;
  489.     if (MenuIDStr == LastMSMenu) 
  490.         x += (window.event.srcElement.offsetWidth - thisMenu.style.posWidth);
  491.     x2 = x + window.event.srcElement.offsetWidth;
  492.     y  = (IsMSMenu)? 
  493.          (idRow1.offsetHeight) :
  494.          (idRow1.offsetHeight + idRow2.offsetHeight + idRow3.offsetHeight);
  495.     thisMenu.style.top  = y;
  496.     thisMenu.style.left = x;
  497.     thisMenu.style.clip = "rect(0 0 0 0)";
  498.     thisMenu.style.display = "block";
  499.  
  500.     // delay 2 millsecond to allow the value of ToolbarMenu.offsetHeight be set
  501.     window.setTimeout("showMenu()", 2);
  502.     return true;
  503. }
  504.  
  505. function showMenu() 
  506. {
  507.     if (ToolbarMenu != null) 
  508.     { 
  509.         IsMenuDropDown = (Frame_Supported && IsMSMenu == false)? false : true;
  510.         if (IsMenuDropDown == false)
  511.         {
  512.             y = (y - ToolbarMenu.offsetHeight - idRow3.offsetHeight);
  513.             if (y < 0) y = 0;
  514.             ToolbarMenu.style.top = y;
  515.         }
  516.         y2 = y + ToolbarMenu.offsetHeight;
  517.  
  518.         ToolbarMenu.style.clip = "rect(auto auto auto auto)";
  519.         hideElement("SELECT");
  520.         hideElement("OBJECT");
  521.     }
  522. }
  523.  
  524. function hideMenu()
  525. {
  526.     if (ToolbarMenu != null && ToolbarMenu != StartMenu) 
  527.     {
  528.         // Don't hide the menu if the mouse move between the menu and submenus
  529.         cY = event.clientY + document.body.scrollTop;
  530.         if ( (event.clientX >= (x+5) && event.clientX <= x2) &&
  531.              ((IsMenuDropDown == true  && cY > (y-10) && cY <= y2)      ||
  532.               (IsMenuDropDown == false && cY >= y     && cY <= (y2+10)) ))
  533.         {
  534.             window.event.cancelBubble = true;
  535.             return; 
  536.         }
  537.  
  538.         ToolbarMenu.style.display = "none";
  539.         ToolbarMenu = StartMenu;
  540.         window.event.cancelBubble = true;
  541.  
  542.         showElement("SELECT");
  543.         showElement("OBJECT");
  544.     }
  545. }
  546.  
  547. function hideElement(elmID)
  548. {
  549.     for (i = 0; i < document.all.tags(elmID).length; i++)
  550.     {
  551.         obj = document.all.tags(elmID)[i];
  552.         if (! obj || ! obj.offsetParent)
  553.             continue;
  554.  
  555.         // Find the element's offsetTop and offsetLeft relative to the BODY tag.
  556.         objLeft   = obj.offsetLeft;
  557.         objTop    = obj.offsetTop;
  558.         objParent = obj.offsetParent;
  559.         while (objParent.tagName.toUpperCase() != "BODY")
  560.         {
  561.             objLeft  += objParent.offsetLeft;
  562.             objTop   += objParent.offsetTop;
  563.             objParent = objParent.offsetParent;
  564.         }
  565.         // Adjust the element's offsetTop relative to the dropdown menu
  566.         objTop = objTop - y;
  567.  
  568.         if (x > (objLeft + obj.offsetWidth) || objLeft > (x + ToolbarMenu.offsetWidth))
  569.             ;
  570.         else if (objTop > ToolbarMenu.offsetHeight)
  571.             ;
  572.         else if (IsMSMenu && (y + ToolbarMenu.offsetHeight) <= 80)
  573.             ;
  574.         else
  575.             obj.style.visibility = "hidden";
  576.     }
  577. }
  578.  
  579. function showElement(elmID)
  580. {
  581.     for (i = 0; i < document.all.tags(elmID).length; i++)
  582.     {
  583.         obj = document.all.tags(elmID)[i];
  584.         if (! obj || ! obj.offsetParent)
  585.             continue;
  586.         obj.style.visibility = "";
  587.     }
  588. }
  589.  
  590. function formatURL(URLStr, InstrumentStr)
  591. {
  592.     var tempStr = URLStr;
  593.  
  594.     if (DoInstrumentation && URLStr != "" )
  595.     {
  596.         var ParamPos1 = URLStr.indexOf("?");
  597.         var ParamPos2 = URLStr.lastIndexOf("?");
  598.         var ParamPos3 = URLStr.toLowerCase().indexOf("target=");
  599.         var ParamPos4 = URLStr.indexOf("#");
  600.         var Bookmark  = "";
  601.         var URL = URLStr;
  602.         if (ParamPos4 >= 0)
  603.         {
  604.              URL = URLStr.substr(0, ParamPos4);
  605.             Bookmark = URLStr.substr(ParamPos4);
  606.         }
  607.         
  608.         if (ParamPos1 == -1)
  609.             tempStr = "?MSCOMTB=";
  610.         else if (ParamPos1 == ParamPos2 && ParamPos3 == -1)    
  611.             tempStr = "&MSCOMTB=";
  612.         else if (ParamPos1 == ParamPos2 && ParamPos3 != -1)    
  613.             tempStr = "?MSCOMTB=";
  614.         else if (ParamPos1 < ParamPos2)
  615.             tempStr = "&MSCOMTB=";
  616.  
  617.         tempStr = URL;
  618.     }
  619.     return tempStr;
  620. }
  621.