/* * Name: * nav.js * * Description: * javascript file for navigation function * * Preconditions/Input: * [None] * * Postconditions/Output: * javascript file for navigation function * * Function[s]: * swapNavImage * showElement * hideElement * hoverElement * initMenu * * Log: * Surendra Shukla * - Creation 02/25/2008 * */ /* * Name: * swapNavImage * * Description: * Swaps Navigation Image * * Preconditions/Input: * el REQUIRED Html Element Name * fileName REQUIRED File Name * width REQUIRED Width * height REQUIRED height * * Postconditions/Output: * Swaps Navigation Image * * Function[s]: * [None] * * Log: * Surendra Shukla * - Creation 02/25/2008 * */ function swapNavImage(el, fileName, width, height) { // If object then only if(el) { el.src = fileName; el.width = width; el.height = height; } // If object is passed then only change } // END function - swapNavEl /* * Name: * showElement * * Description: * Show Html Object (div, span, etc...) * * Preconditions/Input: * elName REQUIRED Html Element Name * * Postconditions/Output: * Show Html Object (div, span, etc...) * * Function[s]: * getElement * * Log: * Surendra Shukla * - Creation 02/25/2008 * */ function showElement(elName) { // If element name is passed then only block it if(getElement(elName)) { getElement(elName).style.display = 'block'; } // END IF - elName checking } // End function showElement /* * Name: * hideElement * * Description: * Hide Html Object (div, span, etc...) * * Preconditions/Input: * elName REQUIRED Html Element Name * * Postconditions/Output: * Hide Html Object (div, span, etc...) * * Function[s]: * getElement * * Log: * Surendra Shukla * - Creation 02/25/2008 * */ function hideElement(elName) { // If element name is passed then only block it if(getElement(elName)) { getElement(elName).style.display = 'none'; } // END IF - elName checking } // End function - hideElement /* * Name: * hoverElement * * Description: * Function is applied to all list items as a mouseover/out from a single call to the initMenu function, * to eliminate confusion in html page... * * Preconditions/Input: * * Postconditions/Output: * Code below is used for navigation with ul and li * * Function[s]: * None * * Log: * Surendra Shukla * - Creation 02/25/2008 * */ function hoverElement(current,stat) { // If you want to use alternate css names for menu states, just change them here. var hidemenu = "hide-menu" ; var activemenu = 'active-menu' ; var hovermenu = 'hover-menu' ; // Find the root menu id from the passed mouseover... menus = document.getElementById(current).parentNode.getElementsByTagName('UL'); // This is the nested UL id by a string itemname = current +'-'; // // Hide all menus to set even playing field // for (var i=0; i< menus.length; i++){ menus[i].setAttribute('class',hidemenu); menus[i].setAttribute('className',hidemenu); } // END FOR - Looping through LIs // // Find default or active current menu item and display it based on state... // for (var i=0; i< menus.length; i++){ // If its current menu if (menus[i].id == itemname) { // If stat == default then active menu... if (stat == 'default') { menus[i].setAttribute('class',activemenu); menus[i].setAttribute('className',activemenu); } else { // Hover menu and Submenus if (stat =='show') { menus[i].setAttribute('class',hovermenu); menus[i].setAttribute('className',hovermenu); menus[i].style.overflow="visible"; // If stat == hide then hide the durn menu... } else { menus[i].setAttribute('class',hidemenu); menus[i].setAttribute('className',hidemenu); } // END IF - stat checking for show } // END IF - stat checking L default } // END IF - itemname checking } // END FOR - Looping through LIs } // END FUNCTION - hoverElement /* * Name: * initMenu * * Description: * Code below is used for navigation with ul and li * It will get all Li of UL list and make add function on mouseOver nad mouseOut * * Preconditions/Input: * * Postconditions/Output: * Code below is used for navigation with ul and li * It will get all Li of UL list and make add function on mouseOver nad mouseOut * * Function[s]: * hoverElement * * Log: * Surendra Shukla * - Creation 02/25/2008 * */ function initMenu(menun) { // Get all LI for given menun(UL) element menus = document.getElementById(menun).getElementsByTagName("LI"); // // Loop through menus(LI List) so that we can function on mouseOver and mouseOut event. // for (var i=0; i< menus.length; i++){ // Call show function on mouse over event document.getElementById(menus[i].id).onmouseover=function(){ // Call hoverElement function hoverElement(this.getAttribute("id"),'show'); } // END FUNCTION - show function on mouse over // Call show function on mouse out event document.getElementById(menus[i].id).onmouseout=function(){ // Call hoverElement function hoverElement(this.getAttribute("id"),'hide'); } // END FUNCTION - show function on mouse out } // END FOR - Looping through LI List }// end initMenu function