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