home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 August / Chip_1999-08_cd.bin / msdn / Library / TOOLBAR / TOOLBAR.JS
Text File  |  1999-06-29  |  19KB  |  618 lines

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