To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > Misc Help > ClientSide Technologies

ClientSide Technologies Discuss HTML/CSS/Javascript, and any other client-side technologies, here.

Reply
 
Thread Tools Rate Thread Display Modes
Old 04-07-2006, 05:02 PM   #1
rayh2
Junior Member
 
Join Date: Jul 2005
Posts: 8
Help with menu script (2 of 2)

PHP Code:
// Build the sub menu items
  
for (x=0; x<eval("Menu"+quant).length; x++)
  {
    if (eval(
"subMenu"+quant)[x].length > 0)
    {     
      
document.writeln ('<div id="'+quant+'MENU'+x+'" style="visibility:hidden; position:absolute; z-index:2" >');
      
document.writeln ('<table border="0" cellpadding="'+cellPadding+'" cellspacing="'+styleBorder+'" bgColor="'+sborderColor+'">');
      for (
y=0; y<eval("subMenu"+quant)[x].length; y++)
      {
        
document.writeln ('<tr><td id="'+quant+'subMenu'+x+y+'" class="rcSubMenuStatic" onMouseOver="hoverMenu(); highlightMenu(\'sub\','+x+','+y+',\'\','+quant+')" onMouseOut="clearMenu('+quant+','+x+');" onclick="tdMouseClick(\''+quant+'subLink'+x+y+'\')" nowrap')
        if (
menuStyle.toLowerCase() == "3d"){document.writeln ('style="border-left:'+cellBorder+'px solid '+sborderHighlight+';border-top:'+cellBorder+'px solid '+sborderHighlight+';border-right:'+cellBorder+'px solid '+sborderShadow+';border-bottom:'+cellBorder+'px solid '+sborderShadow+';"');}
        
document.writeln ('><a id="'+quant+'subLink'+x+y+'" href="'+eval("subMenu"+quant)[x][y][1]+'" target="'+eval("subMenu"+quant)[x][y][2]+'" class="rcSubMenuStatic">'+eval("subMenu"+quant)[x][y][0]+'</a></td></tr>');
      }
      
document.writeln ('</table></div>');
    }
  }
}

// Change colour or menu and submenu items when the mouse hovers over.  
function highlightMenu(element,mainMenu,dropMenu,state,quant)
{
  
hoverMenu();
  
state=(state == "hover")?"rcMenuHover":"rcMenuStatic"
  
if (element == "sub")
  {
    for (
x=0; x < eval("subMenu"+quant)[mainMenu].length; x++)
     {
      eval(
obj+'("'+quant+'subMenu'+mainMenu+x+'").className = "rcSubMenuStatic"')
      eval(
obj+'("'+quant+'subLink'+mainMenu+x+'").className = "rcSubMenuStatic"')
    }   
    eval(
obj+'("'+quant+'subMenu'+mainMenu+dropMenu+'").className="rcSubMenuHover"')
    eval(
obj+'("'+quant+'subLink'+mainMenu+dropMenu+'").className="rcSubMenuHover"')
  }
  else
  {
    eval(
obj+'("'+quant+'cell'+mainMenu+'").className = "'+state+'"')
    eval(
obj+'("'+quant+'mainLink'+mainMenu+'").className = "'+state+'"')
    if (
subIndicate == 1&&eval("subMenu"+quant)[mainMenu].length>=1)
    {
      eval(
obj+'("'+quant+'cell'+mainMenu+'a").className = "'+state+'"')
      eval(
obj+'("'+quant+'mainLink'+mainMenu+'a").className = "'+state+'"')
    }
  }
}

// Find positioning for sub menus
function getOffset(obj, dim)
{
  if(
dim=="left")
  {     
    
oLeft = obj.offsetLeft;    
    while(
obj.offsetParent!=null)
    {    
      
oParent = obj.offsetParent     
      oLeft
+= oParent.offsetLeft
      obj
= oParent     
    
}
    return
oLeft
  
}
  else if(
dim=="top")
  {
    
oTop = obj.offsetTop;
    while(
obj.offsetParent!=null)
    {
      
oParent = obj.offsetParent
      oTop
+= oParent.offsetTop
      obj
= oParent     
    
}
    return
oTop
  
}
  else if(
dim=="width")
  {
    
oWidth = obj.offsetWidth
    
return oWidth
  
}  
  else if(
dim=="height")
  {
    
oHeight = obj.offsetHeight
    
return oHeight
  
}    
  else
  {
    
alert("Error: invalid offset dimension '" + dim + "' in getOffset()")
    return
false;
  }
}

// Show sub menus
function popDown(quant, param, id, orientation)
{
  var
cellBorderOffset = (isNS6)?cellBorder:eval(cellBorder*2)
  var
browserAdjustment = (isNS6)?cellBorder:0
  
var menu;
  var
button;

  if (
id)
  {    
    
getOffset(eval(obj+'(id)'),'left');
    
getOffset(eval(obj+'(id)'),'top');    
    
getOffset(eval(obj+'(id)'),'width');  
    
getOffset(eval(obj+'(id)'),'height');
    
    if (eval(
"Menu"+quant+"["+param+"][3]")=="right")
    {
      
oLeft=oLeft  
      oLeft
=oLeft+oWidth;
      
getOffset(eval(obj+'("'+quant+'MENU'+param+'")'),'width');
      
oLeft=oLeft-oWidth ;
      
alignAdjustment = cellBorder*2 + 1
    
}
    else
    {
      
alignAdjustment = 0
      oLeft
=oLeft
    
}    
  }  

  
  
n = 0;    
  while (
n < eval("Menu"+quant).length)
  {          
    
menu = quant+"MENU"+n
    
if (param == n)
    {
      
theObj = eval(obj+'(menu)');
      if (
theObj)
      {
         
theObj.style.visibility = "visible"

          
if (orientation.toLowerCase()=="vertical"){
            
theObj.style.left=(menuStyle.toLowerCase()=="flat")?oLeft+oWidth+cellBorder+horizontalOffset:oLeft+oWidth+cellBorderOffset+horizontalOffset;
            
theObj.style.top=(menuStyle.toLowerCase()=="flat")?oTop-cellBorder+verticalOffset:oTop+verticalOffset-browserAdjustment}
          else{
            
theObj.style.left=(menuStyle.toLowerCase()=="flat")?oLeft-cellBorder+horizontalOffset+alignAdjustment:oLeft+horizontalOffset-browserAdjustment+alignAdjustment;
            
theObj.style.top=(menuStyle.toLowerCase()=="flat")?oTop+oHeight+cellBorder+verticalOffset:oTop+oHeight+cellBorderOffset+verticalOffset;}
        }
      
       
highlightMenu('main',n,'','hover',quant)
       if (eval(
"subMenu"+quant)[param].length > 0)
       {
         for (
x=0; x<eval("subMenu"+quant)[param].length; x++)
         {
           eval (
obj+'("'+quant+'subMenu'+param+x+'").className = "rcSubMenuStatic"')
           eval (
obj+'("'+quant+'subLink'+param+x+'").className = "rcSubMenuStatic"')         
         }
       }
    }
    else
    {  
      for (
x=1; x<quantity+1; x++)
      {       
        
menu = x+"MENU"+n   
        
//alert(menu)     
        
if (eval(obj+'(menu)'))
        {
          eval(
obj+'(menu).style.visibility = "hidden"')            
        }
        
highlightMenu ('main',n,'','static',quant)
      }
    }
    
n++
  }  
}

// Re-set timer for sub menus
function hoverMenu()
{
  if(
timer)
  
clearTimeout(timer)
}

// Set timer for sub menus
function clearMenu(quant,menu)
{
  
setDelay = subMenuDelay*1000
  delay
= (eval("subMenu"+quant)[menu].length > 0)?setDelay:1
  
  timer
= setTimeout("popDown("+quant+","+(eval("Menu"+quant).length + 1)+")",delay)
}

// when you click the box, perform the same function as if the user had clicked the hyperlink
function tdMouseClick(theElement)
{
  eval(
obj+'(theElement).click()')
}
//-->
</script>
</head>



<td><div align="center"><script>showMenus(1,'Horizontal')</script></div>
rayh2 is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 01:38 PM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.