/* * Defines a menu item. * Params: * name - images name * link - where the menu item links to * alt - The alt tag used. */ function menuItem(aName,aLink,anAlt) { this.name = aName; this.link = aLink; this.alt = anAlt; this.imageOn = new Image(); this.imageOff = new Image(); } /* * Returns a sub-menu based on the menu items passed in. * Params: * imagePath - The path to the images,e.g. "/common/images/subNav/" * menuItems - An array of menu items. * selectedName - The name of the item that is selected * (Should be a menuItem.name) */ function makeBottomMenu(imagePath, menuItems, selectedName) { setupImages(imagePath, menuItems); //Top section of the menu var colspan = menuItems.length + menuItems.length-1; var topPart = "
\n" + "" // + "\n\n" // + "" var middlePart = "\n\n" + "\n"; for (var i = 0; i < menuItems.length; i++) { middlePart = middlePart + "\n"; if (i != menuItems.length-1) { //Add divider middlePart = middlePart + ""; } } middlePart = middlePart //padding on right hand side of menu + "\n"; //Bottom section of the menu var buttomPart = "\n
\""
\n" + "
" return topPart + (middlePart + buttomPart); } /* * Sets the images ready for mouse overs: * imagePath - The path to the images,e.g. "/common/images/subNav/" * menuItems - An array of menu items. */ function setupImages(imagePath, menuItems) { if (document.images) { for (var i = 0; i < menuItems.length; i++) { menuItems[i].imageOn.src = eval('"' + imagePath + menuItems[i].name + "_on.gif" + '"'); menuItems[i].imageOff.src = eval('"' + imagePath + menuItems[i].name + "_off.gif" + '"'); } //end for } //end if } // Function to 'activate' pics. function bottomMenuImgOn(imgName, index) { if (document.images) { document[imgName].src = items[index].imageOn.src; } } // Function to 'deactivate' pics. function bottomMenuImgOff(imgName, index) { if (document.images) { document[imgName].src = items[index].imageOff.src; } } //duplicate this code for now in subNav.js, but remove from subNav.js when we put Bikes site live // Function to 'activate' pics. function menuImgOn(imgName, index, menuItems, divName) { if (document.images) { if (arguments.length == 4) { eval('document.' + divName + '.document[imgName].src = menuItems[index].imageOn.src;'); } else { document[imgName].src = menuItems[index].imageOn.src; } } } // Function to 'deactivate' pics. function menuImgOff(imgName, index, menuItems, divName) { if (document.images) { if (arguments.length == 4) { eval('document.' + divName + '.document[imgName].src = menuItems[index].imageOff.src;'); } else { document[imgName].src = menuItems[index].imageOff.src; } } }