var url = "";

function menu(i,p,n,c,h,o)
{
  this.id = i;
  this.parent = p;
  this.name = n;
  this.cname = c;
  if (h.indexOf("contents.asp") == -1)
  {
    if ((h != '#') && (h.indexOf('http') == -1) )
      this.href = url + h; 
    else
      this.href = h; 
  }
  else
    this.href = h; 

  this.opt = o;
  return(this);
} var wasopen;

var menus = new Array();

menus[0] = new menu(13,0,'Salary and Benefits','MenuItem','/whywork/salary.asp','c','160','20');
menus[1] = new menu(15,0,'Learning and Development','MenuItem','/whywork/learning.asp','c','160','20');
menus[2] = new menu(16,0,'Work life balance','MenuItem','/whywork/balance.asp','c','160','20');
menus[3] = new menu(23,0,'Locations','MenuItem','/whywork/locations/index.asp','c','160','20');
menus[4] = new menu(79,0,'Employee Profiles','MenuItem','/whywork/employee.asp','c','160','20');
menus[5] = new menu(80,23,'UK','SubItem','/whywork/uk.asp','c','160','20');
menus[6] = new menu(81,23,'Guernsey','SubItem','/whywork/guernsey.asp','c','160','20');
menus[7] = new menu(32,27,'Karen Hillman','SubItem','/whywork/profiles/hillman.asp','c','160','20');
menus[8] = new menu(31,27,'Nicola Little','SubItem','/whywork/profiles/little.asp','c','160','20');
menus[9] = new menu(29,27,'Alex Maltby','SubItem','/whywork/profiles/maltby.asp','c','160','20');
menus[10] = new menu(66,27,'Rodelia Puzon','SubItem','/whywork/profiles/puzon.asp','c','160','20');
menus[11] = new menu(26,27,'Renée Schaufelberger','SubItem','/whywork/profiles/schaufelberger.asp','c','160','20');
menus[12] = new menu(30,27,'Rory Smith','SubItem','/whywork/profiles/smith.asp','c','160','20');
menus[13] = new menu(27,27,'Ediz Tari','SubItem','/whywork/profiles/tari.asp','c','160','20');
menus[14] = new menu(73,27,'Barry Williamson','SubItem','/whywork/profiles/williamson.asp','c','160','20');
menus[15] = new menu(49,27,'Jo Wiltshire','SubItem','/whywork/profiles/wiltshire.asp','c','160','20');
menus[16] = new menu(50,27,'Kerry Summersgill','SubItem','/whywork/profiles/summersgill.asp','c','160','20');
menus[17] = new menu(53,46,'UK','SubItem','/whywork/locations/uk.asp','c','160','20');
menus[18] = new menu(55,46,'Switzerland','SubItem','/whywork/locations/switzerland.asp','c','160','20');
menus[19] = new menu(56,46,'Middle East','SubItem','/whywork/locations/middleeast.asp','c','160','20');
menus[20] = new menu(57,46,'Hong Kong','SubItem','/whywork/locations/hongkong.asp','c','160','20');
menus[21] = new menu(58,46,'Singapore','SubItem','/whywork/locations/singapore.asp','c','160','20');
menus[22] = new menu(59,46,'Jersey','SubItem','/whywork/locations/jersey.asp','c','160','20');
menus[23] = new menu(60,46,'Other locations','SubItem','/whywork/locations/other.asp','c','160','20');
menus[24] = new menu(87,79,'Colin','SubItem','/whywork/profiles/colinc.asp','c','160','20');
menus[25] = new menu(89,79,'Philip','SubItem','/whywork/profiles/philipm.asp','c','160','20');
menus[26] = new menu(104,79,'Jim','SubItem','/whywork/profiles/jim.asp','c','160','20');
menus[27] = new menu(105,79,'Lynne','SubItem','/whywork/profiles/lynne.asp','c','160','20');



var opened = '';
var toopen = 0;

function DrawMenuItems(l)
{
var html='';;
var i,j;
var f;

  f = 0;
  
  for (i = 0; i < menus.length; i ++)
    {
  	if (menus[i].parent == l)
      {
      f = 1;
      
      if (menus[i].parent == 0)
        {
        html += '<div class=default-td>';
	    }
      else
        {
        html += '<div class="default-submenu-td">';
  	    }
      
      if (menus[i].opt == 'n'){
        html += "<a target='newbrowser' class='" + menus[i].cname + "' href='" + menus[i].href + "' onclick='DrawMenu(" + menus[i].id + ");'>" + menus[i].name + "</a>";
        }
	  else 
	    {

	    html += "<a class='" + menus[i].cname + "' href='" + menus[i].href + "' onclick='DrawMenu(" + menus[i].id + ");'>" + menus[i].name + "</a>";
        }
	  
	  if (opened.indexOf(menus[i].id) != -1) html += DrawMenuItems(menus[i].id);
        html += "</div>";
        }
    }
  //html += "</div>";
   //html += "</div>";
  if (f == 0)
    return("");
  else
    return(html);
}

function HasChildren(x)
{
var i;

  for (i = 0; i < menus.length; i ++)
    if (menus[i].parent = x) return(true);
    
  return (false);
}

function GetParentSubscript(x)
{
var i;

  for (i = 0; i < menus.length; i ++)
        
	if (menus[i].id == x) return(i);
    
  return(-1);
}

function strtolower(s)
{
var t;

  t = s;
  
  while (t.indexOf(" ") != -1){
    t = t.replace(" ", "");

  }  

  return(t.toLowerCase());
}

function DrawMenu(l)
{
var m = MM_findObj("menux");
var pos;
var apos;
var i;
var searchString;
var url='nowhere';
  
  if (l != 0)
    {
    var p;
    p = l;
    
    if (opened.indexOf(l) == -1)
      opened = l + ' ';
    else
      opened = '';
    
    while (GetParentSubscript(p) != -1)
      {
      j = GetParentSubscript(p);
      opened = menus[j].parent + ' ' + opened;
      p = menus[j].parent;
      }
    }
  else 
    {
    opened = '';
    }
  
  m.innerHTML = DrawMenuItems(0);
}

toopen = 0;
pos = document.location.href;
i = pos.indexOf('www');
if (i > 0) pos = pos.substring(i, pos.length);
i = pos.indexOf('/');
if (i > 0) pos = pos.substring(i, pos.length);

if (pos.indexOf('contents.asp') > 0)
  {
  i = pos.indexOf('contents.asp');
  pos = pos.substring(i, pos.length);
  }

var dirs = pos.split("/");
var searchVal;
var matchToVal;
var foundMatching = false;
var inString;

for (i = menus.length-1; i > -1; i --) 
  {
  foundMatching = false;
  searchString = strtolower(menus[i].href); 
  if (pos.indexOf(searchString) >= 0)
    {
	toopen = menus[i].id;
	break;
	}
  } 

DrawMenu(toopen);
