﻿//================ TOP MENU JS ================//
    //GLOBAL VARIABLES
    var mnuLevel1ID="mnuLevel1";
    var mnuLevel2ID="mnuLevel2";
    var lengthLevel1;
    var i;
   // var ar2;
   
    function fixTopMenuBg()
     {  
       if(document.getElementById)
	   {  
	      /****************** level1 *******************/
		   //get menu items
		   ar = document.getElementById(mnuLevel1ID).getElementsByTagName("li");
		   arLinks = document.getElementById(mnuLevel1ID).getElementsByTagName("a"); 
           
           //level1 length
           lengthLevel1=ar.length;
            
            //no items - exit
           if(lengthLevel1<1)
                    return;
                    
           var isSelectedLeft=checkMenuLeftEdge();         
           
           if(!isSelectedLeft)
           { 
             var isSelectedRight = checkMenuRightEdge();
              
             if(!isSelectedRight)
             {  
                checkSelectedMiddleItem(); 
             }
                
           }
           
           checkLevel2();
				 
	     }//if
     }//function
     //------------------------------------------
     
     function checkLevel2()
     {
            ar2 = document.getElementById(mnuLevel2ID).getElementsByTagName("li");
			//var arLinks2 = document.getElementById(mnuLevel1ID).getElementsByTagName("a"); 
            
            if((ar2==null)||(ar2.length<=0)) 
            return;
            
			//delete the left edge background image separator
			if(ar2.length>0)
			{   ar2[0].style.background = "url('')";  
			}
			
     }
     //------------------------------------------
     //align top menu level 2 by current top level selection 
     //this function is called by the page load event of the master page
     function alignLevel2(currTopLevelMemuTitle)
     {
        //alert("alignLevel2");
        ar2 = document.getElementById(mnuLevel2ID).getElementsByTagName("li");
        
        if((ar2==null)||(ar2.length<=0)) 
           return;
        
			//browser detection
			var browser=navigator.appName;
			//var b_version=navigator.appVersion;
			//if ((browser=="Netscape"||browser=="Microsoft Internet Explorer")
			
			var isIE=false;
			if (browser=="Microsoft Internet Explorer")
			{isIE=true;
			}
			
			
			//if the file belongs to the news and events category
			//then center level 2 under the selected top level
			if(currTopLevelMemuTitle=="News")
			{
			    //if ((browser=="Netscape"||browser=="Microsoft Internet Explorer")
			    if (isIE==true)
			    {   ar2[0].style.marginLeft = "340px";//news and events category
			    }
			    else
			    {   ar2[0].style.marginLeft = "300px";
			    }
			}
			else if(currTopLevelMemuTitle=="Service & Support")
			{
			    if (isIE==true)
			    {   ar2[0].style.marginLeft = "555px";
			    }
			    else
			    {   ar2[0].style.marginLeft = "515px";
			    }
			}
			else if(currTopLevelMemuTitle=="Distributors Entry")
			{
			    if (isIE==true)
			    {   ar2[0].style.marginLeft = "428px";
			    }
			    else
			    {   ar2[0].style.marginLeft = "388px";
			    }
			}
			else if(currTopLevelMemuTitle=="Contact Us")
			{
			    if (isIE==true)
			    {   ar2[0].style.marginLeft = "645px";
			    }
			    else
			    {   ar2[0].style.marginLeft = "605px";
			    }
			}

     }
     
     //------------------------------------------
     function getCurrentFileName() 
     {
        var file_name = document.location.href;//full path
        var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
        
        return file_name.substring(file_name.lastIndexOf("/")+1, end);
    }
     
     //------------------------------------------
     function checkMenuLeftEdge()
     {
        //if left edge node selected - brown bg 
            //in the selected class name - 1 space for IE 2 spaces for FF
			if ((ar[0].className=="AspNet-Menu-Leaf  AspNet-Menu-Selected")||(ar[0].className=="AspNet-Menu-Leaf AspNet-Menu-Selected")) 
			{ 
				document.getElementById("divMenuLeftEdge").style.left="20px"; //separator width - 5
				//display brown edge bg
				document.getElementById("menuLeftEdgeSelected").style.display="inline";
				
				//brown bg
				//ar[0].style.background = "#D8CFA0 url('')";	
				
				//gray right edge
				ar[lengthLevel1-1].style.background = " url('images/menu/menuRightEdgeGrey.gif') no-repeat right top";
				
				//current link bg
				arLinks[0].style.background = "url('images/menu/menuSelected.gif') no-repeat right top";
			    //arLinks[lengthLevel1-1].style.marginLeft = "5px";
				//brown bg
				//ar[0].style.background = "#D8CFA0 url('')";	
				
				return true;
			}
			return false;
     }
     //-------------------------------------------
     
     function checkMenuRightEdge()
     {
        //if right edge  selected - brown bg
			//1 space for IE 2 spaces for FF  
			if ((ar[lengthLevel1-1].className=="AspNet-Menu-Leaf  AspNet-Menu-Selected")||(ar[lengthLevel1-1].className=="AspNet-Menu-Leaf AspNet-Menu-Selected")) 
			{  //right edge brown bg
			    //arLinks[lengthLevel1-1].style.background = "url('images/menu/menuRightEdgeBrown.gif') no-repeat right top";
			    arLinks[lengthLevel1-1].style.background = "url('images/menu/menuSelectedRightEdge2.gif') no-repeat right top";
			    arLinks[lengthLevel1-1].style.marginLeft = "5px";
			    
			    //delete the right separator of the item before the selected item
			    if(lengthLevel1>=2)
			    {
			        ar[lengthLevel1-2].style.background = "url('')";
				    arLinks[lengthLevel1-2].style.margin = "0px";
				    //arLinks[lengthLevel1-1].style.marginLeft = "4px";
			    }
			    
				//left edge not selected - gray bg 	
                 document.getElementById("menuLeftEdgeSelected").style.display="none";
                 document.getElementById("ImgLeftEdgeGrey").style.display="block";
                   
                 arLinks[0].style.marginLeft = "5px";
			    
			    return true;
			}
			
			return false;
     }
     
     //------------------------------------------
     function checkSelectedMiddleItem()
     {
         if(lengthLevel1<3)//no middle item
            return;
         
         //the selected item is in the middle
	     //right edge not selected - gray bg
			ar[lengthLevel1-1].style.background = " url('images/menu/menuRightEdgeGrey.gif') no-repeat right top";

            //look for the selected item
		    for ( i=1; i<lengthLevel1-1; i++ )
			{   //alert("ar[i].className = "+ar[i].className)
			    // 1 space for IE 2 spaces for FF
				if ((ar[i].className=="AspNet-Menu-Leaf  AspNet-Menu-Selected")||(ar[i].className=="AspNet-Menu-Leaf AspNet-Menu-Selected")) 
				{   
					ar[i-1].style.background = "url('')";
    
					arLinks[i-1].style.margin = "0px";
					//arLinks[i-1].style.marginLeft = "5px";
					
					//current link bg
					arLinks[i].style.background = "url('images/menu/menuSelected.gif') no-repeat right top";
					
                    document.getElementById("menuLeftEdgeSelected").style.display="none";
                    document.getElementById("ImgLeftEdgeGrey").style.display="block";
                   
                    arLinks[0].style.marginLeft = "5px";
                    
					break; 
			    }

			}//for
		
     }
     //***************************************************************
     