home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / javascript / menuItem.js < prev   
Text File  |  2003-09-22  |  19KB  |  609 lines

  1. // MOUSEOVER AND MENU OPENING FUNCTIONS
  2. function menuMouse(n)
  3. {
  4.     var myObj = getObject("menubox" + n);
  5.     var theobj;
  6.     if (menu[n].opened)
  7.     {
  8.         if (IE4 && (testEventElement(n) || !old) || NN6)
  9.         {
  10.             myObj.clip = "rect(0px " + menu[n].width + "px " + menu[n].height + "px 0px)";
  11.             if (NN6)
  12.             {
  13.                 for (var i = 0; i < menu[n].subnames.length; i++ )
  14.                 {
  15.                     theobj = getObject(stripUnderscores(menu[n].subnames[i],"space"));
  16.                     theobj.visibility = "hidden";
  17.                 }
  18.                 theobj = getObject("nn6bg" + n);
  19.                 theobj.visibility = "hidden";
  20.             }
  21.             loLight(n);
  22.             menu[n].opened = false;
  23.         }
  24.     } else if (NN6 || window.event.type == "mouseover")
  25.     {
  26.         var h = (menu[n].subnames.length * (menu[n].subheight + menu[n].subvspace)) + menu[n].height + menu[n].vspace;
  27.         var w = menu[n].width;
  28.         if (menu[n].subwidth > menu[n].width)
  29.         {
  30.             w = menu[n].subwidth;
  31.         }
  32.         myObj.clip = "rect(0px " + w + "px " + h + "px 0px)";
  33.         if (NN6)
  34.         {
  35.             for (var i = 0; i < menu[n].subnames.length; i++ )
  36.             {
  37.                 theobj = getObject(stripUnderscores(menu[n].subnames[i],"space"));
  38.                 theobj.visibility = "visible";
  39.             }
  40.             theobj = getObject("nn6bg" + n);
  41.             theobj.visibility = "visible";
  42.         }
  43.         hiLight(n);
  44.         menu[n].opened = true;
  45.     }
  46. }
  47.  
  48. function testEventElement(n)
  49. {
  50.     if (!window.event.toElement)
  51.         return true;
  52.     else if (!window.event.toElement.parentElement)
  53.         return true;
  54.       else if (!window.event.toElement.parentElement.parentElement)
  55.         return true;
  56.     else if ((window.event.toElement.parentElement.parentElement && window.event.toElement.parentElement.parentElement.id != "menubox" + n) && (window.event.toElement.parentElement && window.event.toElement.parentElement.id != "menubox" + n))
  57.         return true;
  58.     else
  59.         return false;
  60. }
  61.  
  62. function moveAct(evt)
  63. {
  64.     var clickX = evt.pageX;
  65.     var clickY = evt.pageY;
  66.     for (var i = document.layers.length-1; i > 0; i--)
  67.     {
  68.         var testObj = document.layers[i];
  69.         if (testObj.id.indexOf("menubox") == -1)
  70.         {
  71.             continue;
  72.         }
  73.         else if ((clickX > testObj.left) && (clickX < testObj.left + testObj.clip.width) && (clickY > testObj.top) && (clickY < testObj.top + testObj.clip.height))
  74.         {
  75.             if (menuCheck(parseInt(testObj.id.charAt(testObj.id.length-1))))
  76.             {
  77.                 break;
  78.             }
  79.         }
  80.         else
  81.         {
  82.             closeMenu(testObj.id.charAt(testObj.id.length-1));
  83.         }
  84.     }
  85. }
  86.  
  87. function menuCheck(n) 
  88. {
  89.     if (!menu[n].opened)
  90.     {
  91.         if (!(menu[n+1] && menu[n+1].opened))
  92.         {
  93.             openMenu(n);
  94.             return true;
  95.         }
  96.         else
  97.         {
  98.             return true;
  99.         }
  100.     }
  101.     else if (menu[n+1] && menu[n+1].opened)
  102.     {
  103.         closeMenu(n);
  104.         return true;
  105.     }
  106.     return false;
  107. }
  108.  
  109. function closeMenu(n)
  110. {
  111.     loLight(n);
  112.     myObj = getObject("menubox" + n);
  113.     myObj.clip.bottom = menu[n].height;
  114.     menu[n].opened = false;
  115. }
  116.  
  117. function openMenu(n)
  118. {
  119.     hiLight(n);
  120.     myObj = getObject("menubox" + n);
  121.     var c = menu[n].height + menu[n].vspace;
  122.     for (var i = 0; i < menu[n].subnames.length; i++)
  123.     {
  124.         c += menu[n].subheight + menu[n].subvspace;
  125.     }
  126.     if (menu[n].subwidth > menu[n].width)
  127.     {
  128.         myObj.clip.width = menu[n].subwidth;
  129.     }
  130.     myObj.clip.bottom = c;
  131.     menu[n].opened = true;
  132. }
  133.  
  134. function hiLight(i,j)
  135. {
  136.     var myimage,pic;
  137.     if (j == 0 || j)
  138.     {
  139.         var myObj = getObject(stripUnderscores(menu[i].subnames[j],"space"),"menubox"+i);
  140.         
  141.         if (NN4)
  142.         {
  143.             myObj.visibility = "show";
  144.         }
  145.         else if (IE4 || NN6)
  146.         {
  147.             myObj.cursor = "hand";
  148.             myObj.backgroundColor = "#686AAC";
  149.             if (NN6)
  150.             {
  151.                 myObj = getObject(stripUnderscores(menu[i].subnames[j],"space") + "ff");
  152.                 if (menu[i].sublow)
  153.                 {
  154.                     pic = findImage("arrow_" + stripUnderscores(menu[i].subnames[j],"space"));
  155.                     pic.src = menu[i].subhigh.src;
  156.                 }
  157.             }
  158.             else
  159.             {
  160.                 if (menu[i].sublow)
  161.                 {
  162.                     pic = getObject("arrow_" + stripUnderscores(menu[i].subnames[j],"space"));
  163.                     pic.visibility = "hidden";
  164.                 }
  165.             }
  166.             myObj.color = "#DADDEF";
  167.             
  168.         }
  169.     }
  170.     else if (IE4 || NN6)
  171.     {
  172.         myObj = getObject(menu[i].name + "imagehi","menubox"+i);
  173.         myObj.visibility = "visible";
  174.     }
  175.     else
  176.     {
  177.         myimage = findImage(menu[i].name);
  178.         myimage.src = menu[i].highlight.src;
  179.     }
  180. }
  181.  
  182. function loLight(i,j)
  183. {
  184.     var myimage,pic;
  185.     if (j == 0 || j)
  186.     {
  187.         var myObj = getObject(stripUnderscores(menu[i].subnames[j],"space"),"menubox"+i);
  188.         if (NN4)
  189.         {
  190.             myObj.visibility = "hide";
  191.         }
  192.         else if (IE4 || NN6)
  193.         {
  194.             myObj.backgroundColor = "#DADDEF";
  195.             if (NN6)
  196.             {
  197.                 myObj = getObject(stripUnderscores(menu[i].subnames[j],"space") + "ff");
  198.                 if (menu[i].sublow)
  199.                 {
  200.                     pic = findImage("arrow_" + stripUnderscores(menu[i].subnames[j],"space"));
  201.                     pic.src = menu[i].sublow.src;
  202.                 }
  203.             }
  204.             else
  205.             {
  206.                 if (menu[i].sublow)
  207.                 {
  208.                     pic = getObject("arrow_" + stripUnderscores(menu[i].subnames[j],"space"));
  209.                     pic.visibility = "visible";
  210.                 }
  211.             }
  212.             myObj.color = "#686AAC";
  213.         }
  214.     }
  215.     else if (IE4 || NN6)
  216.     {
  217.         myObj = getObject(menu[i].name + "imagehi","menubox"+i);
  218.         myObj.visibility = "hidden";
  219.     }
  220.     else
  221.     {
  222.         myimage = findImage(menu[i].name);
  223.         myimage.src = menu[i].img.src;
  224.     }
  225. }
  226.  
  227. // END MENU OPENING ETC FUNCTIONS
  228.  
  229. // CREATE AN ARRAY OF MENU OBJECTS
  230.  
  231. var menu = [];
  232.  
  233. function menuItem(imgLo,imgHigh,name,action)
  234. {
  235.  
  236.     // Set menu item action
  237.     if (action)
  238.     {
  239.         this.action = action;
  240.     }
  241.     else if (name)
  242.     {
  243.         this.action = "/" + globalPath + "/" + stripUnderscores(name,"%20");
  244.     }
  245.     
  246.     // Set closed image
  247.     if (imgLo)
  248.     {
  249.         this.img = new Image();
  250.         this.img.src = imgPath + imgLo;
  251.     }
  252.     
  253.     // Set highlighted image
  254.     if (imgHigh)
  255.     {
  256.         this.highlight = new Image();
  257.         this.highlight.src = imgPath + imgHigh;
  258.     }
  259.     if (name)
  260.     {
  261.         this.name = stripUnderscores(name,"space");
  262.     }
  263.     
  264.     menu[menu.length] = this;
  265.     this.subactions = [];
  266.     this.subnames = [];
  267. }
  268.  
  269. function addSubMenu(name,action)
  270. {
  271.     if (name)
  272.     {
  273.         this.subnames[this.subnames.length] = name;
  274.         if (action)
  275.         {
  276.             this.subactions[this.subactions.length] = action;
  277.         }
  278.         else
  279.         {
  280.             this.subactions[this.subactions.length] = this.action + "/" + stripUnderscores(name,"%20");
  281.         }
  282.     }
  283.     else
  284.     {
  285.         this.subnames[this.subnames.length] = null;
  286.         this.subactions[this.subactions.length] = null;
  287.     }
  288. }
  289.  
  290. menuItem.prototype.opened = false;
  291. menuItem.prototype.action = null;
  292. menuItem.prototype.img = null;
  293. menuItem.prototype.name = null;
  294. menuItem.prototype.sublow = null;
  295. menuItem.prototype.addSubMenu = addSubMenu;
  296.  
  297.  
  298. function setOptionalSubmenuImages(hi,lo,w,h)
  299. {
  300.     menuItem.prototype.subhigh = new Image();
  301.     menuItem.prototype.subhigh.src = imgPath + hi;
  302.     menuItem.prototype.subimgwidth = w;
  303.     menuItem.prototype.subimgheight = h;
  304.     menuItem.prototype.sublow = new Image();
  305.     menuItem.prototype.sublow.src = imgPath + lo;
  306. }
  307.  
  308.  
  309. function setGlobalMainSizes(w,h)
  310. {
  311.     if (w)
  312.     {
  313.         menuItem.prototype.width = w;
  314.     }
  315.     else
  316.     {
  317.         menuItem.prototype.width = null;
  318.     }
  319.     if (h)
  320.     {
  321.         menuItem.prototype.height = h;
  322.     }
  323.     else
  324.     {
  325.         menuItem.prototype.height = null;
  326.     }
  327. }
  328.  
  329. function setGlobalSubSizes(w,h)
  330. {
  331.     if (w)
  332.     {
  333.         menuItem.prototype.subwidth = w;
  334.     }
  335.     else
  336.     {
  337.         menuItem.prototype.subwidth = null;
  338.     }
  339.     if (h)
  340.     {
  341.         menuItem.prototype.subheight = h;
  342.     }
  343.     else
  344.     {
  345.         menuItem.prototype.subheight = null;
  346.     }
  347. }
  348.  
  349. function setGlobalSpaces(h,v,subv,space)
  350. {
  351.     menuItem.prototype.hspace = h;
  352.     menuItem.prototype.vspace = v;
  353.     menuItem.prototype.subvspace = subv;
  354.     if (space)
  355.     {
  356.         menuItem.prototype.space = space;
  357.     }
  358.     else
  359.     {
  360.         menuItem.prototype.space = null;
  361.     }
  362. }
  363.  
  364. // END MENU OBJECT ARRAY CREATION
  365.  
  366.  
  367. // PAGE INITIALISATION FUNCTIONS
  368. function HMenuInit()
  369. {
  370.     var xpos = 0;
  371.     var maxheight = 0;
  372.     for (var i = 0; i < menu.length; i++)
  373.     {
  374.         myObj = getObject("menubox" + i);
  375.         if (IE4 || NN6)
  376.         {
  377.             myObj.clip = "rect(0px " + menu[i].width + "px " + menu[i].height + "px 0px)";
  378.             if (NN6) 
  379.             {
  380.                 myObj.left = (xpos + nn6_posX) + "px";
  381.                 myObj.top = nn6_posY + "px";
  382.                 for (var j = 0; j < menu[i].subnames.length; j++)
  383.                 {
  384.                     subobj = getObject(stripUnderscores(menu[i].subnames[j],"space"));
  385.                     subobj.top = (menu[i].height + (menu[i].subheight * j) + menu[i].vspace + (menu[i].subvspace * j)) + "px";
  386.                 }
  387.             }
  388.             else
  389.             {
  390.                 myObj.left = xpos + "px";
  391.             }
  392.             if (menu[i].height > maxheight)
  393.             {
  394.                 maxheight = menu[i].height;
  395.             }
  396.             myObj.visibility = "visible";
  397.         }
  398.         else if (NN4)
  399.         {
  400.             myObj.width = menu[i].subwidth;
  401.             myObj.height = menu[i].height;
  402.             myObj.left = document.posItem.pageX + xpos;
  403.             myObj.moveToAbsolute(myObj.pageX,document.posItem.pageY);
  404.             myObj.visibility = "show";
  405.         }
  406.         xpos += menu[i].width
  407.         if (i < menu.length-1)
  408.         {
  409.             xpos += menu[i].hspace;
  410.         }
  411.     }
  412.     if (!NN6)
  413.     {
  414.         myObj = getObject("posItem");
  415.         if (IE4)
  416.         {
  417.             myObj.height = maxheight;
  418.             myObj.width = xpos - menu[menu.length-1].hspace;
  419.         }
  420.         else if (NN4)
  421.         {
  422.             document.captureEvents(Event.MOUSEMOVE);
  423.             document.onmousemove = moveAct;
  424.         }
  425.         myObj.visibility = "visible";
  426.     }
  427. }
  428.  
  429. // END INITIALISATION FUNCTIONS
  430.  
  431. // WRITE THE NAVBAR
  432.  
  433. function renderHMenu()
  434. {
  435.     var w = 0;
  436.     var xx  = "";
  437.     var sp;
  438.     var maxheight = 0;
  439.     if (IE4)
  440.     {
  441.         xx  += "<div id=\"posItem\">\n";
  442.     }
  443.     for (var i = 0; i < menu.length; i++)
  444.     {
  445.         w += menu[i].width;
  446.         if (i < menu.length)
  447.         {
  448.             w += menu[i].hspace;
  449.         }
  450.         
  451.         if (IE4)
  452.         {
  453.             xx += "<span id=\"menubox"+ i + "\" class=\"menuholder\" onMouseover=\"menuMouse(" + i + ")\" onMouseout=\"menuMouse(" + i + ")\">\n<a href=\"" + menu[i].action + "\" target=\"_top\"><img id=\"" + menu[i].name + "imagelo\" class=\"hmMainImageLo\" src=\"" + menu[i].img.src + "\" border=0 width=" + menu[i].width + " height=" + menu[i].height + " alt=\"\"></a>\n<a href=\"" + menu[i].action + "\" target=\"_top\"><img id=\"" + menu[i].name + "imagehi\" class=\"hmMainImageHi\" src=\"" + menu[i].highlight.src + "\" border=0 width=" + menu[i].width + " height=" + menu[i].height + " alt=\"\"></a>\n";
  454.         }
  455.         else if (NN6)
  456.         {
  457.             xx += "<span id=\"menubox"+ i + "\" class=\"menuholder\" onMouseover=\"menuMouse(" + i + ")\" onMouseout=\"menuMouse(" + i + ")\">\n<div id=\"" + menu[i].name + "imagelo\" class=\"hmMainImageLo\"><a href=\"" + menu[i].action + "\" target=\"_top\"><img src=\"" + menu[i].img.src + "\" border=0 width=" + menu[i].width + " height=" + menu[i].height + " alt=\"\"></a></div>\n<div id=\"" + menu[i].name + "imagehi\" class=\"hmMainImageHi\"><a href=\"" + menu[i].action + "\" target=\"_top\"><img SRC=\"" + menu[i].highlight.src + "\" border=0 width=" + menu[i].width + " height=" + menu[i].height + " alt=\"\"></a></div>\n";
  458.         }
  459.         else if (NN4)
  460.         {
  461.             xx += "<layer id=\"menubox"+ i + "\" class=\"menuholderNN4\" visibility=\"hide\" clip=\"" + menu[i].width + "," + menu[i].height +"\">\n<a href=\"" + menu[i].action + "\" target=\"_top\"><img name=\"" + menu[i].name + "\" src=\"" + menu[i].img.src + "\" border=0 width=" + menu[i].width + " height=" + menu[i].height + " alt=\"\"></a><br>\n";
  462.         }
  463.         
  464.         if (menu[i].vspace)
  465.         {
  466.             menu[i].subwidth > menu[i].width ? sp = menu[i].width : sp = menu[i].subwidth;
  467.             if (!NN6)
  468.             {
  469.                 xx += "<img style=\"filter:alpha(opacity=" + opacity + ")\" src=\"" + imgPath + menu[i].space + "\" height=\"" + menu[i].vspace + "\" width=\"" + sp + "\" border=0><br>\n";
  470.             }
  471.             else if (NN6)
  472.             {
  473.                 var nn6h = menu[i].vspace + ((menu[i].subvspace + menu[i].subheight) * menu[i].subnames.length);
  474.                 xx += "<div id=\"nn6bg" + i + "\" class=\"nn6bghide\"><img src=\"" + imgPath + menu[i].space + "\" height=\"" + nn6h + "\" width=\"" + menu[i].subwidth + "\" border=0></div>\n";
  475.             }
  476.         }
  477.         
  478.         for (var j = 0; j < menu[i].subnames.length; j++)
  479.         {
  480.             if (IE4)
  481.             {
  482.                 xx += "<div id=\"" + stripUnderscores(menu[i].subnames[j],"space") + "\" class=\"hmSubitem\" style=\"width:" + menu[i].subwidth + "; height:" + menu[i].subheight + "\" onMouseover=\"hiLight(" + i + "," + j + ")\" onMouseout=\"loLight(" + i + "," + j + ")\" onClick=\"top.location='" + menu[i].subactions[j] + "'\">\n";
  483.                 if (menu[i].sublow)
  484.                 {
  485.                     xx += "<img id=\"arrow2_" + stripUnderscores(menu[i].subnames[j],"space") + "\" style=\"position:absolute; left:" + (menu[i].subwidth - menu[i].subimgwidth) + "px\" src=\"" + menu[i].subhigh.src + "\" width=" + menu[i].subimgwidth + " height=" + menu[i].subimgheight + " border=0 alt=\"\">\n<img id=\"arrow_" + stripUnderscores(menu[i].subnames[j],"space") + "\" style=\"position:absolute; left:" + (menu[i].subwidth - menu[i].subimgwidth) + "px\" src=\"" + menu[i].sublow.src + "\" width=" + menu[i].subimgwidth + " height=" + menu[i].subimgheight + " border=0 alt=\"\">";
  486.                 }
  487.                 xx += menu[i].subnames[j] + "</div>\n";
  488.             }
  489.             else if (NN6)
  490.             {
  491.                 xx += "<a href=\"" + menu[i].subactions[j] + "\" onMouseover=\"hiLight(" + i + "," + j + ")\" onMouseout=\"loLight(" + i + "," + j + ")\" target=\"_top\"><div id=\"" + stripUnderscores(menu[i].subnames[j],"space") + "\" class=\"imgbox\" style=\"width:" + menu[i].subwidth + "px; height:" + menu[i].subheight + "px\">\n";
  492.                 if (menu[i].sublow)
  493.                 {
  494.                     xx += "<img id=\"arrow_" + stripUnderscores(menu[i].subnames[j],"space") + "\" src=\"" + menu[i].sublow.src + "\" width=" + menu[i].subimgwidth + " height=" + menu[i].subimgheight + " border=0 align=RIGHT alt=\"\">";
  495.                 }
  496.                 xx += "<nobr><a class=\"lowlit\" id= \"" + stripUnderscores(menu[i].subnames[j],"space") + "ff\" href=\"" + menu[i].subactions[j] + "\" target=\"_top\">" + menu[i].subnames[j] + "</a></nobr><br></div></a>\n";
  497.             }
  498.             else if (NN4)
  499.             {
  500.                 xx += "<ilayer id=\"" + stripUnderscores(menu[i].subnames[j],"space") + "\" class=\"nn4Layer\" width=" + menu[i].subwidth + " height=" + menu[i].subheight + " clip=\"" + menu[i].subwidth + "," + menu[i].subheight + "\">\n";
  501.                 xx += "<layer id=\"" + stripUnderscores(menu[i].subnames[j],"space") + "xx\" class=\"nn4Layer\" bgcolor=\"#DADDEF\" width=" + menu[i].subwidth + " height=" + menu[i].subheight + " clip=\"" + menu[i].subwidth + "," + menu[i].subheight + "\">";
  502.                 if (menu[i].sublow)
  503.                 {
  504.                     xx += "<img src=\"" + menu[i].sublow.src + "\" width=" + menu[i].subimgwidth + " height=" + menu[i].subimgheight + " border=0 align=RIGHT alt=\"\">";
  505.                 }
  506.                 xx += "<a class=\"lowlit\"><nobr> " + menu[i].subnames[j] + "</nobr></a></layer>\n";
  507.                 xx += "<layer id=\"" + stripUnderscores(menu[i].subnames[j],"space") + "x\" class=\"nn4Layer\" bgcolor=\"#686AAC\" width=" + menu[i].subwidth + " height=" + menu[i].subheight + " visibility=\"hide\">";
  508.                 if (menu[i].sublow)
  509.                 {
  510.                     xx += "<img src=\"" + menu[i].subhigh.src + "\" width=" + menu[i].subimgwidth + " height=" + menu[i].subimgheight + " border=0 align=RIGHT alt=\"\">";
  511.                 }
  512.                 xx += "<a class=\"highlit\"><nobr> " + menu[i].subnames[j] + "</nobr></a></layer>\n";
  513.                 xx += "<layer id=\"" + stripUnderscores(menu[i].subnames[j],"space") + "xxx\" class=\"nn4Layer\" width=" + menu[i].subwidth + " height=" + menu[i].subheight + " clip=\"" + menu[i].subwidth + "," + menu[i].subheight + "\" Z-INDEX=\"99\"><a href=\"" + menu[i].subactions[j] + "\" onMouseover=\"hiLight(" + i + "," +j + ")\" onMouseout=\"loLight(" + i + "," +j + ")\" target=\"_top\"><img src=\"" + imgPath + "v6_trans.gif\" width=" + menu[i].subwidth + " height=" + menu[i].subheight + " border=0 alt=\"\"></a></layer>\n";
  514.                 xx += "</ilayer><br>\n";
  515.             }
  516.             if (menu[i].subvspace && !NN6)
  517.             {
  518.                 xx += "<img style=\"filter:alpha(opacity=" + opacity + ")\" src=\"" + imgPath + menu[i].space + "\" height=\"" + menu[i].subvspace + "\" width=\"" + menu[i].subwidth + "\" border=0><br>\n";
  519.             }
  520.         }
  521.         if (IE4 || NN6)
  522.         {
  523.             xx += "</span>\n";
  524.         }
  525.         else if (NN4)
  526.         {
  527.             xx += "</layer>\n";
  528.             if (menu[i].height > maxheight)
  529.             {
  530.                 maxheight = menu[i].height;
  531.             }
  532.         }
  533.     }
  534.     if (IE4)
  535.     {
  536.         xx += "</div>";
  537.     }
  538.     else if (NN4)
  539.     {
  540.         xx = "<div id=\"posItem\"><img src=\"" + imgPath + menu[0].space + "\" width=" + (w - menu[menu.length-1].hspace) + " height=" + maxheight + " border=0></div>\n" + xx;
  541.     }
  542.     document.write(xx);
  543.     document.close();
  544. }
  545.  
  546.  
  547. function stripUnderscores(str,rplc)
  548. {
  549.     if (!rplc)
  550.     {
  551.         rplc = " ";
  552.     }
  553.     if (rplc == "space")
  554.     {
  555.         while (str.indexOf(" ") != -1)
  556.         {
  557.             str = str.substring(0,str.indexOf(" ")) + "" + str.substring(str.indexOf(" ")+1);
  558.         }
  559.     }
  560.     while (str.indexOf("_") != -1)
  561.     {
  562.         str = str.substring(0,str.indexOf("_")) + rplc + str.substring(str.indexOf("_")+1);
  563.     }
  564.     while (str.indexOf("$$") != -1)
  565.     {
  566.         str = str.substring(0,str.indexOf("$$")) + "-" + str.substring(str.indexOf("$$")+2);
  567.     }
  568.     while (str.indexOf("xxyxx") != -1)
  569.     {
  570.         str = str.substring(0,str.indexOf("xxyxx")) + "'" + str.substring(str.indexOf("xxyxx")+5);
  571.     }
  572.     while (str.indexOf(" and ") != -1)
  573.     {
  574.         str = str.substring(0,str.indexOf(" and ")) + " & " + str.substring(str.indexOf(" and ")+5);
  575.     }
  576.     while (str.indexOf(".") != -1)
  577.     {
  578.         str = str.substring(0,str.indexOf(".")) + str.substring(str.indexOf(".")+1);
  579.     }
  580.     return str;
  581. }
  582.  
  583. var subject;
  584. var forumid = [1,2,3,4,5,6,8];
  585. function renderSubjectMenu()
  586. {
  587.     var sm = "";
  588.     var bs = "";
  589.     var bh = "";
  590.     for (var i = 0; i < menu.length; i++)
  591.     {
  592.         var n = stripUnderscores(menu[i].name);
  593.         if (n == subject)
  594.             break;
  595.     }
  596.     sm += "<div class=\"largegap\"><div class=\"largemauvebold\">" + n + "</div></div><table width=\"100%\" CELLPADDING=2 CELLSPACING=0 border=0>";
  597.     for (var j = 0; j < menu[i].subnames.length; j++)
  598.     {
  599.         sm += "<tr><td width=11 valign=TOP><a href=\"" + menu[i].subactions[j] + "\"><img src=\"" + imgPath + "v6_arrow_vnu.gif\" width=7 height=7 VSPACE=3 border=0 alt=\"\"></a></td><td><a class=\"midmauvelink\" href=\"" + menu[i].subactions[j] + "\">" + menu[i].subnames[j] + "</a></td></tr>";
  600.     }
  601.     if (!(n == "Personal computing" || n == "Gaming"))
  602.     {
  603.         bs += "<tr><td width=11 valign=TOP><a class=\"midmauvelink\" href=\"/CSS/index.jsp\"><img src=\"" + imgPath + "v6_arrow_vnu.gif\" width=7 height=7 VSPACE=3 border=0 alt=\"\"></a></td><td><div class=\"midmauve\" style=\"font-size:12px\"><a class=\"midmauvelink\" href=\"/CSS/index.jsp\">Service locator</a></div></td></tr>";
  604.     }    
  605.     bh += "<tr><td width=11 valign=TOP><a class=\"midmauvelink\" href=\"/Registration/index.jsp?regSource=NEWSLETTER\"><img src=\"" + imgPath + "v6_arrow_vnu.gif\" width=7 height=7 VSPACE=3 border=0 alt=\"\"></a></td><td><div class=\"midmauve\" style=\"font-size:12px\"><a class=\"midmauvelink\" href=\"/Registration/index.jsp?regSource=NEWSLETTER\">" + n + " Newsletter</a></div></td></tr><tr><td width=11 valign=TOP><a class=\"midmauvelink\" href=\"/forums/forum.jsp?forum=" + forumid[i] + "\"><img src=\"" + imgPath + "v6_arrow_vnu.gif\" width=7 height=7 VSPACE=3 border=0 alt=\"\"></a></td><td><div class=\"midmauve\" style=\"font-size:12px\"><a class=\"midmauvelink\" href=\"/forums/forum.jsp?forum=" + forumid[i] + "\">" + n + " forum</a></div></td></tr></table>";
  606.     sm += bs + bh;
  607.     document.writeln(sm);
  608. }
  609.