/********************************
 *   Handy functions library    *
 *   Rollovers, hiding emails   *
 *   from harvesters and more   *
 * By: Mathieu Brousseau-Julien *
 ********************************/

// Hide email address from harvesters
var email = "exemple@domaine.ext";

function mbjWriteEmail()
{
  document.writeln("<a href=\"mailto:" + email + "\" title=\"Nous &eacute;rire.\">" + email + "</a>");
}

// Rollovers
function mbjOver(imageName, state)
{
  var imgRef = document[imageName].src;
  var ext = imgRef.substr(imgRef.lastIndexOf("."));
  var wover;
  var img;
  
  switch(state)
  {
    case 0: // MouseOut
	  img = imgRef.replace(imgRef.substr(imgRef.lastIndexOf("_")), ext);
      document[imageName].src = img;
      break;
    case 1: // MouseOver
	  img = imgRef.replace(ext, ("_over" + ext));
      document[imageName].src = img;
  }
}

// Detects which page we are on, for the menu tabs
function mbjGetPage()
{
  var here = document.location.toString();
  var slash, dot, tpage;
  if (document.all || document.getElementById)
  {
    slash = here.lastIndexOf("/");
    here = here.substr(slash + 1);
    dot = here.lastIndexOf(".");
    tpage = here.substr(0, dot);
    if(tpage != "")
    {
      document.getElementById(tpage).style.background = "#DB2222";
    }
    else
    {
      document.getElementById("index").style.background = "#DB2222";
    }
  }
}

/* 
   CSS dropdown menus, JS code for Internet Explorer
   taken from A List Apart.com
   http://www.alistapart.com/articles/dropdowns/
   Edited for clarity, in case modifications
   are needed
*/
function AddOver()
{
  var navRoot;
  var node;
  if (document.all && document.getElementById)
  {
    navRoot = document.getElementById("menu");
    for(i = 0; i < navRoot.childNodes.length; i++)
    {
      node = navRoot.childNodes[i];
      if (node.nodeName == "LI")
      {
        node.onmouseover = function()
        {
		  this.className += " over";
        }
        node.onmouseout = function()
        {
	      this.className = this.className.replace(" over", "");
        }
      }
    }
  }
}





// General auto calls 
//window.onload = AddOver();
