// Use Freely as long as following disclaimer is intact ::
//---------------------------------------------------------------
// Cross Browser Multi-Orientation Menu v1.0 23rd October 2003
// This script written by Rik Comery. www.ricom.co.uk
// For support, visit the "Resources" section at www.ricom.co.uk
// All rights reserved.


var Menu = new Array ()
var subMenu = new Array ()
var Larg = new Array ()

////// ADD MENU ITEMS  //////////////////////////////////////////////////////////////////////////////////////////////
//  To add a new menu item, follow the format below.  Every "Menu" must adhere to the following rules
//
//  1. Each menu has a number. i.e. "Menu[0]". This number must start at 0 and be incremented by one for each menu item added.
//  2. Whether you want a sub menu or not, each menu must have the "subMenu[x] = new Array()" line, where x is the same as the 
//     main "Menu[x]" number.
//  3. If you DO want a sub menu, you must assign it TWO numbers. i.e. "subMenu[x][x]". The first number is the same 
//     as the main "Menu" number, and the second must start at 0 and be incremented by one, for every sub menu item added.
//  4. the script is CASE SENSITIVE. 
//
//  -- Example --
//  Menu[0] = new Array ("Link Name", "URL", "Frame Target")
//    subMenu[0] = new Array()
//    subMenu[0][0] = new Array ("Link Name", "URL", "Frame Target")
//    subMenu[0][1] = new Array ("Link Name", "URL", "Frame Target")
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

   Menu[0] = new Array("Accueil", "../index.htm","_top","100")
     subMenu[0] = new Array()       

   Menu[1] = new Array("Médecine du travail", "../medecinedutravail.htm","_top","200")
     subMenu[1] = new Array() 
     subMenu[1][0] = new Array ("Vision", "../vision.htm","_top")
     subMenu[1][1] = new Array ("ORL", "../orl.htm","_top")
     subMenu[1][2] = new Array ("ECG", "../ecg.htm","_top")
	 subMenu[1][3] = new Array ("Sonomètres", "../sonometres.htm","_top")
 	 subMenu[1][4] = new Array ("Défibrillateurs", "../defibrillateurs_pub.htm","_top")
 	 subMenu[1][5] = new Array ("Tensiomètres", "../tensiometres.htm","_top")
 	 subMenu[1][6] = new Array ("Spirométrie", "../spirometrie.htm","_top")
 	 subMenu[1][7] = new Array ("Luxmètre-Oxymètre", "../luxcobande.htm","_top")
	 subMenu[1][8] = new Array ("Divers", "../divers.htm","_top")
	 subMenu[1][9] = new Array ("Orthèses PROTEC", "../ortheses.htm","_top")	 

   Menu[2] = new Array("Support", "../support.htm","_top","120") 
     subMenu[2] = new Array()
     subMenu[2][0] = new Array ("Documentations", "../documentations.htm","_top")
     subMenu[2][1] = new Array ("Support logiciels", "../supportlogiciels.htm","_top")
     subMenu[2][2] = new Array ("Hotline", "../hotline.htm","_top")

   Menu[3] = new Array("Liens", "../liens.htm","_top","100")
     subMenu[3] = new Array() 
	 
   Menu[4] = new Array("Contact", "../contact.htm","_top","100")
     subMenu[4] = new Array() 	 

////// FORMAT MENU  ///////////////////////////////////////////////////////////////////
cellPadding = 3                            // Cell Padding
cellBorder = 1                             // Include table border (for no border, enter 0)
verticalOffset = 0                         // Vertical offset of Sub Menu. (if set to 0, default offset will be used)
horizontalOffset = 0                       // Horizontal offset of Sub Menu. (if set to 0, default offset will be used)
subMenuDelay = 2                           // Time sub menu stays visible for (in seconds)

// Main Menu Items
borderColor = "#06578F"                    // Border Colour 
menuBackground = "#99CCFF"                 // Cell Background Colour
menuHoverBackground = "#0099FF"            // Cell Background Colour on mouse rollover
fontFace = "arial"                         // Font Face
fontColour = "#003399"                     // Font Colour
fontHoverColour = "#003399"                // Font Colour on mouse rollover
fontSize = "13pt"                           // Font Size
fontDecoration = "none"                    // Style of the link text (none, underline, overline, line-through)
fontWeight = "normal"                      // Font Weight (normal, bold)

// Sub Menu Items
sborderColor = "#568DB1"                    // Border Colour 
smenuBackground = "#99CCFF"                 // Cell Background Colour
smenuHoverBackground = "#0099FF"            // Cell Background Colour on mouse rolloverr
sfontFace = "arial"                         // Font Face
sfontColour = "#003399"                     // Font Colour
sfontHoverColour = "#003399"                // Font Colour on mouse rollover
sfontSize = "13pt"                           // Font Size
sfontDecoration = "none"                    // Style of the link text (none, underline, overline, line-through)
sfontWeight = "normal"                      // Font Weight (normal, bold)



////// DO NOT EDIT BELOW THIS LINE  ///////////////////////////////////////////////////////////////////

// Browser Sniffer
var isIE = (document.getElementById && document.all)?true:false;
var isNS4 = (document.layers)?true:false;
var isNS6 = (document.getElementById && !document.all)?true:false;

var timer
var obj = (isIE)?"document.all":"document.getElementById"

// Default horizontal and vertical offsets
if (verticalOffset == 0 || verticalOffset == "") 
{
  verticalOffset = 24
}

if (horizontalOffset == 0 || horizontalOffset == "") 
{
  horizontalOffset = -1
}

// Menu Styles
document.writeln ('<style>');
document.writeln ('.rcMenuStatic {font-family:'+fontFace+';font-size:'+fontSize+';color:'+fontColour+';font-weight:'+fontWeight+';background-color:'+menuBackground+'; cursor:hand; text-decoration:'+fontDecoration+'}');
document.writeln ('.rcMenuHover  {font-family:'+fontFace+';font-size:'+fontSize+';color:'+fontHoverColour+';font-weight:'+fontWeight+';background-color:'+menuHoverBackground+'; cursor:hand; text-decoration:'+fontDecoration+'}');
document.writeln ('.rcSubMenuStatic {font-family:'+sfontFace+';font-size:'+sfontSize+';color:'+sfontColour+';font-weight:'+sfontWeight+';text-decoration:'+sfontDecoration+';background-color:'+smenuBackground+'; cursor:hand}');
document.writeln ('.rcSubMenuHover  {font-family:'+sfontFace+';font-size:'+sfontSize+';color:'+sfontHoverColour+';font-weight:'+sfontWeight+';text-decoration:'+sfontDecoration+';background-color:'+smenuHoverBackground+'; cursor:hand}');
document.writeln ('</style>');

// Build and show the main menu items
function showMenus()
{
  document.writeln ('<table border="0" cellpadding="0" cellspacing="'+cellBorder+'" bgColor="'+borderColor+'"><tr>')

  document.writeln ('<td align="center" width="'+Menu[0][3]+'" onclick="tdMouseClick(\'mainLink'+0+'\')" onMouseOver="hoverMenu(); popDown('+0+', \'button'+0+'\'); " onMouseOut="clearMenu('+0+')" ><div id="button'+0+'"><table border="0" cellpadding="'+cellPadding+'" cellspacing="0" width="100%"><tr><td class="rcMenuStatic" id="cell'+0+'" nowrap>');
  document.writeln ('<a id="mainLink'+0+'" href="Templates/'+Menu[0][1]+'" target="'+Menu[0][2]+'" class="rcMenuStatic">'+Menu[0][0]+'</a></td>');
  document.writeln ('</tr></table></div></td>');
  
  document.writeln ('<td align="center" width="'+Menu[1][3]+'" onclick="tdMouseClick(\'mainLink'+1+'\')" onMouseOver="hoverMenu(); popDown('+1+', \'button'+1+'\'); " onMouseOut="clearMenu('+1+')" ><div id="button'+1+'"><table border="0" cellpadding="'+cellPadding+'" cellspacing="0" width="100%"><tr><td class="rcMenuStatic" id="cell'+1+'" nowrap>');
  document.writeln ('<a id="mainLink'+1+'" href="Templates/'+Menu[1][1]+'" target="'+Menu[1][2]+'" class="rcMenuStatic">'+Menu[1][0]+'</a></td>');
  document.writeln ('</tr></table></div></td>');

  document.writeln ('<td align="center" width="'+Menu[2][3]+'" onclick="tdMouseClick(\'mainLink'+2+'\')" onMouseOver="hoverMenu(); popDown('+2+', \'button'+2+'\'); " onMouseOut="clearMenu('+2+')" ><div id="button'+2+'"><table border="0" cellpadding="'+cellPadding+'" cellspacing="0" width="100%"><tr><td class="rcMenuStatic" id="cell'+2+'" nowrap>');
  document.writeln ('<a id="mainLink'+2+'" href="Templates/'+Menu[2][1]+'" target="'+Menu[2][2]+'" class="rcMenuStatic">'+Menu[2][0]+'</a></td>');
  document.writeln ('</tr></table></div></td>');
  
  document.writeln ('<td align="center" width="'+Menu[3][3]+'" onclick="tdMouseClick(\'mainLink'+3+'\')" onMouseOver="hoverMenu(); popDown('+3+', \'button'+3+'\'); " onMouseOut="clearMenu('+3+')" ><div id="button'+3+'"><table border="0" cellpadding="'+cellPadding+'" cellspacing="0" width="100%"><tr><td class="rcMenuStatic" id="cell'+3+'" nowrap>');
  document.writeln ('<a id="mainLink'+3+'" href="Templates/'+Menu[3][1]+'" target="'+Menu[3][2]+'" class="rcMenuStatic">'+Menu[3][0]+'</a></td>');
  document.writeln ('</tr></table></div></td>');

//  document.writeln ('<td width="200"></td><table border="0" cellpadding="'+cellPadding+'" cellspacing="0" width="100%"><tr><td class="rcMenuStatic" id="cellvide" nowrap>');

//  document.writeln ('<td align="center" width="200"><table border="0" cellpadding="'+cellPadding+'" cellspacing="0" width="100%"><tr><td class="rcMenuStatic" id="cellvide">');
  document.writeln ('<td align="center" width="350" bgcolor="#99CCFF">');
  document.writeln ('<a id="mainLinkVide">    </a></td>');
  document.writeln ('</td>');

  document.writeln ('<td align="center" width="'+Menu[4][3]+'" onclick="tdMouseClick(\'mainLink'+4+'\')" onMouseOver="hoverMenu(); popDown('+4+', \'button'+4+'\'); " onMouseOut="clearMenu('+4+')" ><div id="button'+4+'"><table border="0" cellpadding="'+cellPadding+'" cellspacing="0" width="100%"><tr><td class="rcMenuStatic" id="cell'+4+'" nowrap>');
  document.writeln ('<a id="mainLink'+4+'" href="Templates/'+Menu[4][1]+'" target="'+Menu[4][2]+'" class="rcMenuStatic">'+Menu[4][0]+'</a></td>');
  document.writeln ('</tr></table></div></td>');

  document.writeln ('</tr></table>');
}  

// Build the sub menu items
  for (x=0; x<Menu.length; x++)
  { 
    if (subMenu[x].length > 0)
    {     
      document.writeln ('<div id="MENU'+x+'" style="visibility:hidden; position:absolute; z-index:2" >');
      document.writeln ('<table border="0" width="'+Menu[x][3]+'" cellpadding="'+cellPadding+'" cellspacing="'+cellBorder+'" bgColor="'+sborderColor+'">');
      for (y=0; y<subMenu[x].length; y++)
      {
        document.writeln ('<tr><td id="subMenu'+x+y+'" class="rcSubMenuStatic" onMouseOver="hoverMenu(); highlightMenu(\'sub\','+x+','+y+')" onMouseOut="clearMenu('+x+');" onclick="tdMouseClick(\'subLink'+x+y+'\')" nowrap><a id="subLink'+x+y+'" href="Templates/'+subMenu[x][y][1]+'" target="'+subMenu[x][y][2]+'" class="rcSubMenuStatic">'+subMenu[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)
{
  state=(state == "hover")?"rcMenuHover":"rcMenuStatic"
  if (element == "sub")
  {
    for (x=0; x < subMenu[mainMenu].length; x++)
    {
      eval(obj+'("subMenu'+mainMenu+x+'").className = "rcSubMenuStatic"')
      eval(obj+'("subLink'+mainMenu+x+'").className = "rcSubMenuStatic"')
    }
    eval(obj+'("subMenu'+mainMenu+dropMenu+'").className="rcSubMenuHover"')
    eval(obj+'("subLink'+mainMenu+dropMenu+'").className="rcSubMenuHover"')
  }
  else
  {
    eval(obj+'("cell'+mainMenu+'").className = "'+state+'"')
    eval(obj+'("mainLink'+mainMenu+'").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
  {
    alert("Error: invalid offset dimension '" + dim + "' in getOffset()")
    return false;
  }
}

// Show sub menus
function popDown(param, id)
{
  var menu;
  var button;

  if (id)
  {
    getOffset(eval(obj+'(id)'),'left');
    getOffset(eval(obj+'(id)'),'top');
  }
  n = 0;
  while (n < Menu.length)
  {

    //button = eval(obj+'("cell'+n+'")')
    menu = "MENU"+n
    if (param == n)
    {
        if (eval(obj+'(menu)'))
        {
          eval(obj+'(menu).style.visibility = "visible"')
          eval(obj+'(menu).style.left = oLeft + horizontalOffset;')
          eval(obj+'(menu).style.top = oTop + verticalOffset;')
        }
         highlightMenu('main',n,'','hover')
         if (subMenu[param].length > 0)
         {
           for (x=0; x<subMenu[param].length; x++)
           {
             eval (obj+'("subMenu'+param+x+'").className = "rcSubMenuStatic"')
             eval (obj+'("subLink'+param+x+'").className = "rcSubMenuStatic"')
           }
         }
      }
      else 
      {
        if (eval(obj+'(menu)'))
        {
          eval(obj+'(menu).style.visibility = "hidden"')
        }
        highlightMenu ('main',n,'','static')

      }
    n++
  }  
}

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

// Set timer for sub menus
function clearMenu(menu)
{
  setDelay = subMenuDelay*200
  delay = (subMenu[menu].length > 0)?setDelay:1
  
  timer = setTimeout("popDown("+(Menu.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()')
}
