function sniffer() {
    var agent = navigator.userAgent.toLowerCase();
    this.major = parseInt(navigator.appVersion);
    this.minor = parseFloat(navigator.appVersion);
    this.ns  = ((agent.indexOf('mozilla')!=-1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
    this.ns2 = (this.ns && (this.major == 2));
    this.ns3 = (this.ns && (this.major == 3));
    this.ns4b = (this.ns && (this.minor < 4.04));
    this.ns4 = (this.ns && (this.major == 4));
    this.ns6 = (this.ns && (this.major >= 5));
    this.ie   = (agent.indexOf("msie") != -1);
    this.ie3  = (this.ie && (this.major == 2));
    this.ie5  = (this.ie && (this.major >= 4) && (document.getElementById) ) ? true : false ;
    this.ie6  = (this.ie5 && (agent.indexOf('msie 6')!=-1) ) ? true : false ;
    this.ie4  = (this.ie && (this.major >= 4) && !(this.ie5));
    this.op3 = (agent.indexOf("opera") != -1);
    this.win   = (agent.indexOf("win")!=-1);
    this.mac   = (agent.indexOf("mac")!=-1);
    this.unix  = (agent.indexOf("x11")!=-1);
    this.dom = (this.ns6 || this.ie5 );
}

var clientIs = new sniffer();


var lay;
var t;
var s;
var popTimer = 0;
var believeTimer=false;
var s=new Array(1);
var lay=new Array(1);

//liste de tous les layers pouvant apparaitre dans le site
/*
lay[0]="drire";
lay[1]="seveso";
lay[2]="uic";
*/
for (i=0; i<31 ; i++)
{
lay[i]="layer"+i
}

if(clientIs.ns && !clientIs.ns6 ) 
{
	doc = "document";
	sty = "";
	htm = ".document";
	val = "hide";
	test="show";
} 
else if(clientIs.ie ) 
{
	doc = "document.all";
	sty = ".style";
	htm = "";
	val ="hidden";
	test="visible";
}
else if(clientIs.ns6) 
{
	doc = "document";
	sty = "";
	htm = ".document";
	val = "hidden";
	test="visible";
}

function openMenu(menuName) 
{
	believeTimer = false;
	//clearTimeout(popTimer);

	//pour netscape
	if (clientIs.ns && !clientIs.ns6) setTimeout("believeTimer = false;", 200);
	if (typeof(menuName) != "string" && clientIs.ns && !clientIs.ns6 ) return false;

	//on memorise le pointeur vers le layer
	if (clientIs.ns6 || clientIs.ie5)
		{targetMenuObj = document.getElementById(menuName);}
	else
		{targetMenuObj =  eval(doc + '["'+menuName+'"]');}


    	if (targetMenuObj) 
	{
		//on memorise le pointeur vers le layer pour la manipulation
		if (clientIs.ns6 || clientIs.ie5)
  			{targetMenuStyle = targetMenuObj.style;}
		else
			{targetMenuStyle = eval(doc + '["'+menuName+'"]' + sty);}

		//on efface tous les menu qui était visible
		hideall(menuName);

		//on rend visible le menu ŕ ouvrir
		targetMenuStyle.visibility = test;
		//targetMenuObj.onmouseout =closeMenu;
		targetMenuObj.onmouseover=openMenu;
	}


}

function closeMenu(menuName) 
{
	believeTimer = true;
	if (typeof(menuName)!= "string" )
		//appel venant de la page html suite ŕ un mouseOut
		{popTimer = setTimeout("hideall()", 100);}
	else
		//appel du ŕ l'ouverture d'un autre menu
		{hideall(menuName);}
}

function hideall(menuName)
{
	str="";

	if (!believeTimer && (typeof(menuName) != "string") && clientIs.ns && !clientIs.ns6  ) return false;

	for(i=0;i <lay.length;i++)
	{

		if (clientIs.ns6 || clientIs.ie5)
			{obj = document.getElementById(lay[i]);}
		else
			{obj =  eval(doc + '["'+lay[i]+'"]');}

		if(obj!=null && menuName != lay[i])
		{
			str+=lay[i];

			if (clientIs.ns6 || clientIs.ie)
  				{s[i] = obj.style;}
			else
				{s[i] = eval(doc + '["'+lay[i]+'"]' + sty);}

			s[i].visibility = val;
			s[i].onmouseout=null;
			s[i].onmouseover=null;

		}
	}
}

if (clientIs.ns) document.captureEvents(Event.MOUSEDOWN);
document.onclick = clickHandle;

function clickHandle(evt)
{
	believeTimer=true;
	hideall('click');
	if (clientIs.ns) document.routeEvent(evt);
}


