﻿// JScript File


     //Store the Id of top menu item when mouse is moved over the menu.
      //This Id is used to set the color of the TopNode when mouse is hovered
      //child menu items.
      var topMenuId = null;

      //On mouse over on the 3rd level menu item
      function onMenuMouseOver(p_menuItem)
      {
            if(topMenuId != null)
            {
                //Get the top node and highlight
                 var topNode = document.getElementById(topMenuId);
                 
                 if(topNode)
                    //highlight the top node if mouse is moved over child menu item
                    highlightStaticMenuItem(topNode);
            }
      }
      
      //On mouse over on the 2nd level menu item
      function onMenuMouseOverStaticMenuItem(p_menuItem)
      {
           
            topMenuId = (window.navigator.userAgent.indexOf("Firefox") != -1) ? p_menuItem.attributes["id"].value : p_menuItem.id;
            
            highlightStaticMenuItem(p_menuItem);
      }        
      
      //highlight 3rd level menu item
      function highlightMenuItem(p_menuItem)
      {
            
      }
        
      //highlight 2nd level menu item
      function highlightStaticMenuItem(p_menuItem)
      {
       // Firefox attributes are only avialable in the attributes collection
        var highliteImageUrl = (window.navigator.userAgent.indexOf("Firefox") != -1) ? p_menuItem.attributes["highlightedImageUrl"].value : p_menuItem.highlightedImageUrl;
        
        if(highliteImageUrl != null && highliteImageUrl != "")
        {
             //Get the top node and highlight
             var menuItemImage = p_menuItem.firstChild; //.getElementById("StaticMenuItemImage");
             
             if(menuItemImage)
             {
                p_menuItem.imageUrl = menuItemImage.src;
                menuItemImage.src = highliteImageUrl;
             }
        }
      }

      //onmouse out on 3rd level menu item
      function onMenuMouseOut(p_menuItem)
      {
         
        if(topMenuId != null)
        {
             var topNode = document.getElementById(topMenuId);
             if(topNode)
                //unhighlight the top node if mouse is moved out child menu item
                unHighlightStaticMenuItem(topNode);
        }                 
      }
      
      //onmouse out on 2nd level menu item
      function onMenuMouseOutStaticMenuItem(p_menuItem)
      {
    
            unHighlightStaticMenuItem(p_menuItem);           
      }      
      
      //unhighlight 3rd level menu item
      function unHighlightMenuItem(p_menuItem)
      {
          

      }
      
      //unhighlight 2nd level menu item
      function unHighlightStaticMenuItem(p_menuItem)
      {
            // Firefox attributes are only avialable in the attributes collection      
            var highliteImageUrl = (window.navigator.userAgent.indexOf("Firefox") != -1) ? p_menuItem.attributes["highlightedImageUrl"].value : p_menuItem.highlightedImageUrl;
            if(highliteImageUrl != null && highliteImageUrl != "" && p_menuItem.firstChild != null)
                p_menuItem.firstChild.src = p_menuItem.imageUrl;
        }    
      
     function menuItemClick(prmThis)
     {
        //iterate upto top element till "A" element not found.
        //this is required as table is not allowed inside "a" element
        //so click event do not bubble upto "a" from table element
        while(prmThis != null && prmThis.tagName != "A")
        {
            prmThis = prmThis.parentNode;
        }
        
         if(prmThis != null)
                prmThis.click();
        
        return true;
     }                        
