// Function that relate to the left hand navigation menu

function addDivider(menuTable)
{
  var row = document.createElement('tr');
  var cell = document.createElement('td');
  cell.innerHTML = "<img src='images/menuDiv.jpg'></img>";
  row.appendChild(cell);
  menuTable.appendChild(row);   
}

function rowMouseOver()
{
  this.className = 'navMenuOver';
}

function rowMouseOut()
{
  this.className = 'navMenuNormal';
}

function rowClick()
{
  window.location = this.getAttribute('url');
}

function crossPlatformAddEvent(object, event, eventFunc)
{
  if (object.addEventListener)
  {
    object.addEventListener(event, eventFunc, false);
  }
  else
  if (object.attachEvent)
  {
    object.attachEvent("on" + event, eventFunc);
  }
  else
  {
    alert('Internal error setting up the event listener. Please mail the webmaster and report this.');
  }
}

function addMenuItem(menuTable, text, url)
{
  var row = document.createElement('tr');

//  crossPlatformAddEvent(row, 'mouseover', rowMouseOver);
//  crossPlatformAddEvent(row, 'mouseout', rowMouseOut);
//  crossPlatformAddEvent(row, 'click', rowClick);
  row.onmouseover = rowMouseOver;
  row.onmouseout = rowMouseOut;
  row.onclick = rowClick;
  row.setAttribute('url', url);
  row.setAttribute('style', 'font-size: 11pt;');
  var cell = document.createElement('td');

  //var text = document.createTextNode(text);
  //cell.appendChild(text);
  cell.innerHTML = "<div style='cursor: default; font-size: 11pt; font-weight: normal; text-align: left;'>" + text + "</div>";
  row.appendChild(cell);
  menuTable.appendChild(row);
}

function displayMenu(menu)
{
  var menuTable = document.getElementById("navMenu");
  var body = document.createElement('tbody');
  body.setAttribute("class", "navmenutable");
  menuTable.appendChild(body);

  if (menu == "services")
  {
    addMenuItem(body, "> Discover", "content.php?menu=services&page=discover");
    addDivider(body);
    addMenuItem(body, "> Define", "content.php?menu=services&page=define");
    addDivider(body);
    addMenuItem(body, "> Deliver", "content.php?menu=services&page=deliver");
    addDivider(body);
    addMenuItem(body, "> Develop", "content.php?menu=services&page=develop");
    addDivider(body);
    addMenuItem(body, "> Advise", "content.php?menu=services&page=advise");
    addDivider(body);
    addMenuItem(body, "> Educate", "content.php?menu=services&page=educate");
  }

  if (menu == "specialty")
  {
    addMenuItem(body, "> Business Process Management", "content.php?menu=specialty&page=whatisBPM");
    addDivider(body);
    addMenuItem(body, "> Information Management", "content.php?menu=specialty&page=whatisIM");
    addDivider(body);
    addMenuItem(body, "> Enterprise Application Integration", "content.php?menu=specialty&page=whatisEAI");
  }
}

