// JavaScript Document

//------------------------------------------------------------------------------------------
// Définition de l'extention du noms des fichiers des images

var ext_off = '_off.gif';  //Image non survolée par la souris
var ext_on = '_on.gif';    //Image survolée par la souris


//-----------------------------------------------------------------------------------------

function hover(obj)
{
  
    UL = obj.getElementsByTagName('ul');
    if(UL.length > 0){
      sousMenu = UL[0].style;
	  
	  //Si aucun élément dans sous-menu --> pas de bordure
	  LI = UL[0].getElementsByTagName('li');
	  nLI = LI.length;
	   
	  if( nLI == 0 )
	  	sousMenu.border = 'none';
	  //----------------------------------------------------
	  
      if(sousMenu.display == 'none' || sousMenu.display == '')
	  {
        sousMenu.display = 'block';		
      }
	  else
	  {
        sousMenu.display = 'none';
      }
    }
  
}


function setHover()
{
  
  LI = document.getElementById('menu').getElementsByTagName('li');
  nLI = LI.length;
  for(i=0; i < nLI; i++)
  {
    LI[i].onmouseover = function()
	{
      hover(this);	  
	  
	  IMG = this.getElementsByTagName('img');
	  nIMG = IMG.length;
	  	  
	  for(j=0; j < nIMG; j++)
	  {
	    source = IMG[j].src;
		pos = source.indexOf(ext_off);
		if( pos != -1 )
		{
		  SwitchOn(IMG[j]);
		}
	 } //FIN de la boucle des images
	 
	  
    } //FIN de la fonction onmouseover de LI
	
    LI[i].onmouseout = function()
	{
      hover(this);
	  
	  IMG = this.getElementsByTagName('img');
	  nIMG = IMG.length;
	  	  	  
	  for(j=0; j < nIMG; j++)
	  {
	    
		source = IMG[j].src;
		
		pos = source.indexOf(ext_on);
		
		
		if( pos != -1 )
		{
		  source = IMG[j].src;
		  SwitchOff(IMG[j]);
		}
		
	 } //FIN de la boucle for des images
	  
    } //FIN de la fonction onmouseout
  } 
}

//---------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------

function GetWorkingDirectory()
{
	//Script pour obtenir le chemin du dossier courant
	//-------------------------------------------------
	var path = window.location.href;
	var patharray = path.split("/");
	delete patharray[(patharray.length-1)];
	path = patharray.join("/");
	//-------------------------------------------------
	
	return path;
}

function SwitchOn(obj)
{
	path = GetWorkingDirectory();
	nom = obj.src;
	nom = nom.replace(path, '');
	nom = nom.replace(ext_off, '');
	overimg = nom + ext_on;
	obj.src=overimg;
}

function SwitchOff(obj)
{
	path = GetWorkingDirectory();
	nom = obj.src;
	nom = nom.replace(path, '');
	nom = nom.replace(ext_on, '');
	offimg = nom + ext_off;
	obj.src=offimg;
}

//---------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------


