/* --------------------------------- */
/* Created:      2000-10-21          */
/* Issued:       2001-01-11          */
/* Modified:     2001-07-14          */
/* Copyright (c) 2001-2002 by        */
/* Philip Shaw, all rights reserved. */
/* --------------------------------- */

/* Changed to graphic links with tables for menus. */
/* Gord Fisch 2003 */

///////////////////////////////////////
// Successfully debugged for:        //
//   Mozilla                         //
//     M15                           //
//   Netscape                        //
//     3, 4.5, 6.0                   //
//   Internet Explorer               //
//     4.0 5.0, 5.5                  //
//   Opera                           //
//     3.62, 4.0, 5.0, 5.11. 6.0     //
///////////////////////////////////////

// We create a LINK row on the top
//  with graphics
// define absolute positioning in style sheet
// we need a MENU for each link, even if it is blank
// this script creates table in the menu and a row for each item
// each row gets a CELL created
///////////////////////////////////////

// Declare the number of menus
// N.B. Add menu IDs and adjust
// widths of divs in stylesheet:
// Menus.css
///////////////////////////////////////

// Global number for total menus:
///////////////////////////////////////
var totalmenus = 2;

// rollover cell background colour
///////////////////////////////////////
var cell_bg1 = '#749C6A';
var cell_bg2 = '#BFCEB7';

// Global string for menu output:
///////////////////////////////////////
var menutxt = '';

// Global array for menu data:
///////////////////////////////////////
var menu = new makeArray(totalmenus);

// Custom array constructor,
// indexed from 1:
///////////////////////////////////////
function makeArray(n){
  this.size = n;
  for(i=1; i<=n; i++){
    this[i] = 0;
  }
  return(this);
}

// Menu group constructor:
///////////////////////////////////////
function menuObject(n,MenuTitle,MenuURL,MenuGraphic){
  this.size =       n;
  this.MenuTitle =  MenuTitle;
  this.MenuURL =    MenuURL;
  this.MenuGraphic =    MenuGraphic;
  this.Cell =     new makeArray(n);
}

// Menu item constructor:
///////////////////////////////////////
function cellObject(CellTitle,CellURL){
  this.CellTitle =  CellTitle;
  this.CellURL =   CellURL;
}

// Define menus. Add new items by
// increasing menu rows argument
// and adding a new indexed row
// object to the end of the list.
//
// Menu arguments:
// 1 = No. of rows
// 2 = Menu title
// 3 = Menu URL
// 4 = Graphic

// Cell arguments:
// 1 = Cell title
// 2 = Cell URL
///////////////////////////////////////

// First Menu
///////////////////////////////////////
menu[1] = new menuObject(4,'produits et services','#','shim-18');

menu[1].Cell[1] = new cellObject('URMobile pour Évènements ','event_fr.html');
menu[1].Cell[2] = new cellObject('URMobile pour Exposants  ','exhibit_fr.html');
menu[1].Cell[3] = new cellObject('Solutions sur Mesure     ','custom_fr.html');
menu[1].Cell[4] = new cellObject('Téléchargement          ','down_fr.html');

// First Menu
///////////////////////////////////////
menu[2] = new menuObject(0,'contactez-nous','contact_fr.html','shim-18');





// Compile the static menu headings: Links
///////////////////////////////////////
// optional div around the whole thing
//menutxt += '<div id="LinkBar">\n';

  for(i=1;i<=totalmenus;i++){
    menutxt += '<div id="Link' + i + '" class="Link' + i + '" style="z-index:100">';
    menutxt += '<a href="' + menu[i].MenuURL + '"';
    
    // Only compile the event handlers if able to handle them
    if(document.getElementById){// DOM1 compliant   
      menutxt += ' onmouseover="menuOver(\'Menu' + i + '\'); return true;"';
      menutxt += ' onmouseout="menuOut(\'Menu' + i + '\'); return true;"';
    }
    menutxt += '><img src="images/' + menu[i].MenuGraphic + '.gif"  height="16" border="0" alt="' + menu[i].MenuTitle +'"></a>';
    menutxt += '<\/div>\n';
  }

// optional div around the whole thing
//menutxt += '<\/div>\n';

// If DOM1 compliant, add the
// drop-down menus: Menu1, Menu2, etc.
///////////////////////////////////////

if(document.getElementById){// DOM1 compliant
  menutxt += '<div id="MenuBar" style="z-index:150">\n';
  for(i=1;i<=totalmenus;i++){
    menutxt += '<div id="Menu' + i + '" class="Menu' + i + '">';
    menutxt += '<table cellpadding="3" cellspacing="0" border="0" bordercolor="#9599AC">';
    // Build the Cell list
    menutxt += '\n\t';
    for(j=1;j<=menu[i].size;j++){
      menutxt += '<tr><td id="cell' + i + j + '" class="Menucell"><a href="' + menu[i].Cell[j].CellURL + '"';
      menutxt += ' onmouseover="stayOpen(\'Menu' + i + '\',\'cell' + i + j + '\'); return true;"';
      menutxt += ' onmouseout="menuOut(\'Menu' + i + '\',\'cell' + i + j + '\'); return true;">';
      menutxt += menu[i].Cell[j].CellTitle;
      menutxt += '<\/a><\/td><\/tr>\n\t';
    }
    menutxt += '<\/table>\n<\/div>\n';
  }
  menutxt += '<\/div>\n';
}

// Global menu element handle:
///////////////////////////////////////
var LiveMenu = null;

// Global menu timeout handle:
///////////////////////////////////////
var Timeout_ID = null;

// Opens or keeps open a given menu and shuts any previous menu:
///////////////////////////////////////
function menuOver(MenuID){
  // If DOM1 supported and element exists ...
  if((document.getElementById)&&(document.getElementById(MenuID)!=null)){
    // If this menu is already open ...
    if(LiveMenu==document.getElementById(MenuID)){
      // Do not close it
      clearTimeout(Timeout_ID);
    }
    // Another might still be open ...
    else{
      // If another menu is open ...
      if(LiveMenu!=null){
        // Do not wait, shut it now
        clearTimeout(Timeout_ID);
        hideNow();
      }
    }
    // This is the new 'live' menu, make it visible
    LiveMenu = document.getElementById(MenuID);
    // LiveMenu.style.visibility is
    // initially empty in IE5 until
    // it is assigned by these
    // functions, so must check that
    // it's not null before proceeding...
    if((LiveMenu.style)&&(LiveMenu.style.visibility!=null)){
      LiveMenu.style.visibility = 'visible';
      LiveMenu.style.color = '#749C6A';
    }
  }
}

// Stops menu links from opening menu onmouseover when shut to
// workaround mouse events which are not hidden by z-index in Opera 4!
///////////////////////////////////////
function stayOpen(MenuID,CellID){
  // If menuOver has not been called or the menu is hidden, do nothing
  if((LiveMenu==null)||((LiveMenu.style)&&(LiveMenu.style.visibility)&&(LiveMenu.style.visibility=='hidden'))){
	return;
  }else{
	if(CellID!=null){
		LiveCell = document.getElementById(CellID);
		LiveCell.style.backgroundColor = cell_bg2;

	}
    menuOver(MenuID);
   }
}

// Shuts a given menu in 250 milliseconds, unless timeout is
// cleared by menuOver()
///////////////////////////////////////
function menuOut(MenuID,CellID){
  // If DOM1 supported and a menu is open ...
  if((document.getElementById)&&(document.getElementById(MenuID)!=null)){
    if(CellID!=null){
        LiveCell = document.getElementById(CellID);
        LiveCell.style.backgroundColor =  cell_bg1;
    }
    // Get the current live menu
    LiveMenu = document.getElementById(MenuID);
    // Prepare to shut it in 250 milliseconds
      LiveMenu.style.color = '#749C6A';
    Timeout_ID = window.setTimeout('hideNow();',250);

  }
}

// Called by menu handlers to shut previous menu immediately
///////////////////////////////////////
function hideNow(){
  if((LiveMenu.style)&&(LiveMenu.style.visibility)){
    LiveMenu.style.visibility = 'hidden';
  }
}

