// JavaScript Document

function noaccent(chaine) {
  temp = chaine.replace(/[àâä]/gi,"a")
  temp = temp.replace(/[éèêë]/gi,"e")
  temp = temp.replace(/[îï]/gi,"i")
  temp = temp.replace(/[ôö]/gi,"o")
  temp = temp.replace(/[ùûü]/gi,"u")
  temp = temp.replace(/[?,.;:!*&'()]/gi," ")
  return temp
}

function showev (name) {
      x = currentX;
      y = currentY + 20;
      if (NS4) {
         document.layers[name].xpos = parseInt(x);
         document.layers[name].left = parseInt(x);
         document.layers[name].ypos = parseInt(y);
         document.layers[name].top = parseInt(y);
         document.layers[name].visibility = "show";
      }
      if (IE4) {
         document.all[name].style.left = self.document.body.scrollLeft + parseInt(x);
         document.all[name].style.top = self.document.body.scrollTop + parseInt(y);
         document.all[name].style.visibility = "visible";
      }
      if (MOZ) { 
         document.getElementById(name).style.left = parseInt(x);
         document.getElementById(name).style.top = parseInt(y);
         document.getElementById(name).style.visibility = "visible";
      }
}
function showtw (name) {
      if (NS4) {
         document.layers[name].visibility = "show";
      }
      if (IE4) {
         document.all[name].style.visibility = "visible";
      }
      if (MOZ) { 
         document.getElementById(name).style.visibility = "visible";
      }
}
function hideev (name) {
      if (NS4) { document.layers[name].visibility = "hide"; }
      if (IE4) { document.all[name].style.visibility = "hidden"; }
      if (MOZ) { document.getElementById(name).style.visibility = "hidden"; }
}
function grabEl(e) {
      if (IE4) { currentX = event.x; currentY = event.y; } else { currentX = e.pageX; currentY = e.pageY; }
}

function fillup(){
	if (iedom){
	cross_slide=document.getElementById? document.getElementById("test2") : document.all.test2
	cross_slide2=document.getElementById? document.getElementById("test3") : document.all.test3
	cross_slide.innerHTML=cross_slide2.innerHTML=leftrightslide
	actualwidth=document.all? cross_slide.offsetWidth : document.getElementById("temp").offsetWidth
	cross_slide2.style.left=actualwidth+slideshowgap+"px"
	}
	else if (document.layers){
	ns_slide=document.ns_slidemenu.document.ns_slidemenu2
	ns_slide2=document.ns_slidemenu.document.ns_slidemenu3
	ns_slide.document.write(leftrightslide)
	ns_slide.document.close()
	actualwidth=ns_slide.document.width
	ns_slide2.left=actualwidth+slideshowgap
	ns_slide2.document.write(leftrightslide)
	ns_slide2.document.close()
	}
	lefttime=setInterval("slideleft()",30)
}


function slideleft(){
	if (iedom){
	if (parseInt(cross_slide.style.left)>(actualwidth*(-1)+8))
	cross_slide.style.left=parseInt(cross_slide.style.left)-copyspeed+"px"
	else
	cross_slide.style.left=parseInt(cross_slide2.style.left)+actualwidth+slideshowgap+"px"
	
	if (parseInt(cross_slide2.style.left)>(actualwidth*(-1)+8))
	cross_slide2.style.left=parseInt(cross_slide2.style.left)-copyspeed+"px"
	else
	cross_slide2.style.left=parseInt(cross_slide.style.left)+actualwidth+slideshowgap+"px"
	
	}
	else if (document.layers){
	if (ns_slide.left>(actualwidth*(-1)+8))
	ns_slide.left-=copyspeed
	else
	ns_slide.left=ns_slide2.left+actualwidth+slideshowgap
	
	if (ns_slide2.left>(actualwidth*(-1)+8))
	ns_slide2.left-=copyspeed
	else
	ns_slide2.left=ns_slide.left+actualwidth+slideshowgap
	}
}

function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) { if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';} }
	if (d) {d.style.display='block';}
}
function montrepuce(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) { if (document.getElementById('spuce'+i)) {document.getElementById('spuce'+i).style.display='none';} }
	if (d) {d.style.display='block';}
}
function montrediapo(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) { if (document.getElementById('spuce'+i)) {document.getElementById('spuce'+i).style.display='none';} }
	if (d) {d.style.display='block';}
}

function open_gal() {
  Shadowbox.open(obj);
  Shadowbox.play();
}
function pause_gal() {
  clearTimeout(timer);
  toggle_affich();
}
function play_gal() {
  timer = setTimeout(function() {
    Shadowbox.next();
  },duree);
  toggle_affich();
}
function toggle_affich() {
  var pl = document.getElementById("sb-nav-play");
  var pa = document.getElementById("sb-nav-pause");
  if(pa.style.display != "none") {
    pa.style.display = "none";
    pl.style.display = "inline";
  } else {
    pa.style.display = "inline";
    pl.style.display = "none";
  }
  pl.onclick=play_gal;
  pa.onclick=pause_gal;
}
/* function changeSize(add) */

function changeSize(add){
	foo=document.getElementsByTagName("body")[0].style.fontSize;
	bar=foo.split(".");
	
	entier=parseInt(bar[0]);

	if(bar[1])
		decimal=parseInt(bar[1].substr(0,1));
	else
		decimal=0;

	if(decimal==0 && add<0) {
		entier+=add;
		decimal=9;
	}
	else if(decimal==9 && add>0) {
		entier+=add;
		decimal=0;
	}
	else {
		decimal+=add;
	}

	size=entier+"."+decimal;

	if(size=='0.5')
		size='0.6';

	if(size=='1.0')
		size='0.9';

	document.getElementsByTagName("body")[0].style.fontSize=size+"em";

	storeSize();
}

/* function storeSize() */

function storeSize(){
	var exp = new Date();
	exp.setTime(exp.getTime() + 1*30*60*90*1000);
	size=document.getElementsByTagName("body")[0].style.fontSize;
	setCookie("dc_fontsize",size,exp,"/");
}

/* function setCookie() */

function setCookie(name, value, expires, path, domain, secure) { 
	var curCookie = name + "=" + escape(value) + 
	((expires) ? "; expires=" + expires.toGMTString() : "") + 
	((path) ? "; path=" + path : "") + 
	((domain) ? "; domain=" + domain : "") + 
	((secure) ? "; secure" : "") 
	document.cookie = curCookie 
} 

/* function getCookie() */

function getCookie(name) { 
	var prefix = name + "=" 
	var cookieStartIndex = document.cookie.indexOf(prefix) 
	if (cookieStartIndex == -1) 
	return null 
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + 
	prefix.length) 
	if (cookieEndIndex == -1) 
	cookieEndIndex = document.cookie.length 
	return unescape(document.cookie.substring(cookieStartIndex + 
	prefix.length, 
	cookieEndIndex)) 
} 

function controlsubseccont()
	{
	var info = document.formsubseccont;
	var retour = true;
	if(info.title.value=="") { alert("Vous devez saisir un libellé"); info.title.focus(); retour = false; }
	return retour;
	}
function controlseccont()
	{
	var info = document.formseccont;
	var retour = true;
	if(info.title.value=="") { alert("Vous devez saisir un libellé"); info.title.focus(); retour = false; }
	return retour;
	}
function controlsection()
	{
	var info = document.formsection;
	var retour = true;
	if(info.secname.value=="") { alert("Vous devez saisir un libellé"); info.secname.focus(); retour = false; }
	return retour;
	}
function controlrubrique()
	{
	var info = document.formrubrique;
	var retour = true;
	if(info.rubname.value=="") { alert("Vous devez saisir un libellé"); info.rubname.focus(); retour = false; }
	return retour;
	}
function hover(obj){
	 obj.style.zindex = 1000;
	 if(document.all){
		 UL = obj.getElementsByTagName('ul');
		 if(UL.length > 0){
			 sousMenu = UL[0].style;
			 if(sousMenu.display == 'none' || sousMenu.display == ''){ sousMenu.display = 'block'; } else { sousMenu.display = 'none';
			 }
		 }
	 }
}
function setHover(id){
	 LI = document.getElementById(id).getElementsByTagName('li');
	 nLI = LI.length;
	 for(i=0; i < nLI; i++){
		 LI[i].onmouseover = function(){
			 hover(this);
		 }
		 LI[i].onmouseout = function(){
			 hover(this);
		 }
	 }
}
function sfHover(id) {
	 var sfEls = document.getElementById('menulab').getElementsByTagName('li');
	 for (var i=0; i<sfEls.length; i++) {
		 sfEls[i].onmouseover=function() {
			 this.className+=" sfhover"; this.style.zindex = 1000;
		 }
		 sfEls[i].onmouseout=function() {
			 this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		 }
	 }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function sendajax(param, page, contenu) {
if(document.all && !window.opera) { var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ; } else { var XhrObj = new XMLHttpRequest(); }
var content = document.getElementById(contenu);
XhrObj.open("POST", page);
XhrObj.onreadystatechange = function() { if (XhrObj.readyState == 4 && XhrObj.status == 200) { content.innerHTML = XhrObj.responseText ; } }
XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
XhrObj.send(param);
}
function HorizontalInfiniteScroller(containerId,normalSlideSpeed,buttonSlideSpeed,delay,div_size)
{
	//this.slideTimeBetweenSteps = 30;	// General speed variable (Lower = slower)
	
	var scrollingContainer = document.getElementById(containerId);
	scrollingContainer.horizontal_infinite_scroller=this;
	var scrollingContent = scrollingContainer.getElementsByTagName('DIV')[0];
		
	scrollingContainer.style.position = 'relative';
	scrollingContainer.style.overflow = 'hidden';
	scrollingContent.style.position = 'relative';
	scrollingContent.style.left = '0px';
	
	this.slidelock=0;
	this.autoslidelock=0;
	
	this.products=new Array();
	var content=scrollingContent.getElementsByTagName('DIV');
	for (var i=0; i<content.length; i++)
	{
		if (content[i].className=='element_div')
		{
			this.products.push(content[i]);
			content[i].style.position = 'relative';
			content[i].style.width = div_size + 'px';
			content[i].style.height = '25px';
		}
	}
	
	var cleft=0;		
	/*
	for (var i=0; i< this.products.length; i++)
		{
			cleft+=this.products[i].offsetWidth;
		}
	*/
	cleft=this.products.length * div_size;
	scrollingContent.style.width = cleft+'px';
	
	this.containerId=containerId;
	this.objRef = scrollingContent;
	this.contentWidth = scrollingContent.offsetWidth;
	this.containerWidth = scrollingContainer.clientWidth;
	this.slideSpeed = normalSlideSpeed;
	this.originalSlideSpeed = normalSlideSpeed;
	this.buttonSlideSpeed = buttonSlideSpeed;
	this.divSize=div_size;
	this.delay=delay;
	this.autosliding=false;
	this.currentProductIndex=0;
	
	if (this.products.length < 2 || this.containerWidth >= this.contentWidth)
	{
		this.originalSlideSpeed=0;
		this.buttonSlideSpeed=0;
		this.slideSpeed=0;
	}
	else
	{
		//this.autoSlideStart();
	}
}

HorizontalInfiniteScroller.prototype.autoSlideStart = function()
{
	this.autosliding=true;
	
	this.autoslidelock++;
	
	if (this.autoslidelock == 1)
	{
		setTimeout('document.getElementById("'+this.containerId+'").horizontal_infinite_scroller.autoSlideContinue()',this.delay*1000);
	}
	else
	{
		this.autoslidelock--;
	}
}

HorizontalInfiniteScroller.prototype.autoSlideStop = function()
{
	this.autosliding=false;
}

HorizontalInfiniteScroller.prototype.autoSlideContinue = function()
{
	this.autoslidelock--;

	if (this.autosliding)
	{
		this.restartSliding(-1,true);
	}
}

HorizontalInfiniteScroller.prototype.slideContent = function()
	{
		if (this.slidelock ==0)

		{
		this.slidelock++;
		
		var leftPos = this.objRef.style.left.replace(/[^\-0-9]/g,'');
		leftPos = leftPos - this.slideSpeed;
		var reordered=false;
		
		if (this.slideSpeed != 0)
		{
		
		while (leftPos < -this.products[this.currentProductIndex].offsetWidth)
		{
			leftPos+=this.products[this.currentProductIndex].offsetWidth;
			this.currentProductIndex++;
			
			if (this.currentProductIndex >= this.products.length)
			{
				this.currentProductIndex=0;
			}
			
			reordered=true;
		}
		
		while (leftPos > 0)
		{
			leftPos-=this.products[this.currentProductIndex].offsetWidth;
			this.currentProductIndex--;
			
			if (this.currentProductIndex < 0)
			{
				this.currentProductIndex=this.products.length-1;
			}
			
			reordered=true;
		}
		
		}
		
		if (reordered)
		{
			var cleft=0;
			var cright=0;
			
			for (var i=0; i< this.products.length; i++)
			{
				if (i < this.currentProductIndex)
				{
					cleft+=this.products[i].offsetWidth;
				}
				else
				{
					cright+=this.products[i].offsetWidth;
				}
			}
			
			var ctotal=cleft+cright;
			cleft=cleft%ctotal;
			cright=cright%ctotal;
			
			for (var i=0; i< this.products.length; i++)
			{
				if (i >= this.currentProductIndex)
				{
					this.products[i].style.left=(-cleft)+'px';
				}
				else
				{
					this.products[i].style.left=cright+'px';
				}
			}
			
		}
		
		if (this.autosliding && reordered)
		{
			leftPos=0;
			this.stopSliding();
		}
		
		if(leftPos/1 + this.contentWidth/1<0 && this.slideSpeed != 0)
		{
			leftPos = this.containerWidth;
			
		}
		this.objRef.style.left = leftPos + 'px';

		if (this.slideSpeed != 0)
		{
			var cdelay=this.buttonSlideSpeed;
			if (this.autosliding)
			{
				cdelay=this.normalSlideSpeed;
			}
			setTimeout('document.getElementById("'+this.containerId+'").horizontal_infinite_scroller.slideContinue()',cdelay);
		}
		else
		{
			this.slidelock--;
		}
		}
	}
	
HorizontalInfiniteScroller.prototype.slideContinue = function()
{

	this.slidelock--;
	this.slideContent();

}
	
HorizontalInfiniteScroller.prototype.stopSliding = function()
	{
		this.slideSpeed = 0;
		//this.autoSlideStart();
	}
	
HorizontalInfiniteScroller.prototype.mouseStopSliding = function()
    {
        this.slideSpeed = 0;
        this.autoSlideStop();
    }

	
HorizontalInfiniteScroller.prototype.restartSliding = function(direction,autospeed)
	{
		if (this.products.length > 1)
		{
			this.slideSpeed = -direction * this.originalSlideSpeed; //this.divSize;
			this.slideContent();
		}
	}
	
HorizontalInfiniteScroller.prototype.startSliding = function(direction)
	{
		this.autoSlideStop();
		this.restartSliding(direction);
	}
function VerticalInfiniteScroller(containerId,normalSlideSpeed,buttonSlideSpeed,delay,div_size)
{
	//this.slideTimeBetweenSteps = 30;	// General speed variable (Lower = slower)
	
	var scrollingContainer = document.getElementById(containerId);
	scrollingContainer.vertical_infinite_scroller=this;
	var scrollingContent = scrollingContainer.getElementsByTagName('DIV')[0];
		
	scrollingContainer.style.position = 'relative';
	scrollingContainer.style.overflow = 'hidden';
	scrollingContent.style.position = 'relative';
	scrollingContent.style.top = '0px';
	
	this.slidelock=0;
	this.autoslidelock=0;
	
	this.products=new Array();
	var content=scrollingContent.getElementsByTagName('DIV');
	for (var i=0; i<content.length; i++)
	{
		if (content[i].className=='element_div')
		{
			this.products.push(content[i]);
			content[i].style.position = 'relative';
			content[i].style.height = div_size + 'px';
		}
	}
	
	var ctop=0;		
	/*
	for (var i=0; i< this.products.length; i++)
		{
			cleft+=this.products[i].offsetWidth;
		}
	*/
	ctop=this.products.length * div_size;
	//scrollingContent.style.width = ctop+'px';

	
	this.containerId=containerId;
	this.objRef = scrollingContent;
	this.contentHeight = scrollingContent.offsetHeight;
	this.containerHeight = scrollingContainer.clientHeight;
	this.slideSpeed = normalSlideSpeed;
	this.originalSlideSpeed = normalSlideSpeed;
	this.buttonSlideSpeed = buttonSlideSpeed;
	this.divSize=div_size;
	this.delay=delay;
	this.autosliding=false;
	this.currentProductIndex=0;
	
	if (this.products.length < 2 || this.containerHeight >= this.contentHeight)
	{
		this.originalSlideSpeed=0;
		this.buttonSlideSpeed=0;
		this.slideSpeed=0;
	}
	else
	{
		this.autoSlideStart();
	}
}

VerticalInfiniteScroller.prototype.autoSlideStart = function()
{
	this.autosliding=true;
	
	this.autoslidelock++;
	
	if (this.autoslidelock == 1 && this.delay > 0)
	{
		setTimeout('document.getElementById("'+this.containerId+'").vertical_infinite_scroller.autoSlideContinue()',this.delay*1000);
	}
	else
	{
		this.autoslidelock--;
	}
}

VerticalInfiniteScroller.prototype.autoSlideStop = function()
{
	this.autosliding=false;
}

VerticalInfiniteScroller.prototype.autoSlideContinue = function()
{
	this.autoslidelock--;

	if (this.autosliding)
	{
		this.restartSliding(-1,true);
	}
}

VerticalInfiniteScroller.prototype.slideContent = function()
	{
		if (this.slidelock ==0)

		{
		this.slidelock++;
		
		var topPos = this.objRef.style.top.replace(/[^\-0-9]/g,'');
		topPos = topPos - this.slideSpeed;
		var reordered=false;
		
		if (this.slideSpeed != 0)
		{
		
		while (topPos < -this.products[this.currentProductIndex].offsetHeight)
		{
			topPos+=this.products[this.currentProductIndex].offsetHeight;
			this.currentProductIndex++;
			
			if (this.currentProductIndex >= this.products.length)
			{
				this.currentProductIndex=0;
			}
			
			reordered=true;
		}
		
		while (topPos > 0)
		{
			topPos-=this.products[this.currentProductIndex].offsetHeight;
			this.currentProductIndex--;
			
			if (this.currentProductIndex < 0)
			{
				this.currentProductIndex=this.products.length-1;
			}
			
			reordered=true;
		}
		
		}
		
		if (reordered)
		{
			var ctop=0;
			var cbottom=0;
			
			for (var i=0; i< this.products.length; i++)
			{
				if (i < this.currentProductIndex)
				{
					ctop+=this.products[i].offsetHeight;
				}
				else
				{
					cbottom+=this.products[i].offsetHeight;
				}
			}
			
			var ctotal=ctop+cbottom;
			ctop=ctop%ctotal;
			cbottom=cbottom%ctotal;
			
			for (var i=0; i< this.products.length; i++)
			{
				if (i >= this.currentProductIndex)
				{
					this.products[i].style.top=(-ctop)+'px';
				}
				else
				{
					this.products[i].style.top=cbottom+'px';
				}
			}
			
		}
		
		if (this.autosliding && reordered)
		{
			topPos=0;
			this.stopSliding();
		}
		
		if(topPos/1 + this.contentHeight/1<0 && this.slideSpeed != 0)
		{
			topPos = this.containerHeight;
			
		}
		this.objRef.style.top = topPos + 'px';

		if (this.slideSpeed != 0)
		{
			var cdelay=this.buttonSlideSpeed;
			if (this.autosliding)
			{
				cdelay=this.normalSlideSpeed;
			}
			setTimeout('document.getElementById("'+this.containerId+'").vertical_infinite_scroller.slideContinue()',cdelay);
		}
		else
		{
			this.slidelock--;
		}
		}
	}
	
VerticalInfiniteScroller.prototype.slideContinue = function()
{

	this.slidelock--;
	this.slideContent();

}
	
VerticalInfiniteScroller.prototype.stopSliding = function()
	{
		this.slideSpeed = 0;
		this.autoSlideStart();
	}
	
VerticalInfiniteScroller.prototype.mouseStopSliding = function()
    {
        this.slideSpeed = 0;
        this.autoSlideStop();
    }

	
VerticalInfiniteScroller.prototype.restartSliding = function(direction,autospeed)
	{
		if (this.products.length > 1)
		{
			this.slideSpeed = -direction * this.originalSlideSpeed; //this.divSize;
			this.slideContent();
		}
	}
	
VerticalInfiniteScroller.prototype.startSliding = function(direction)
	{
		this.autoSlideStop();
		this.restartSliding(direction);
	}
	
	
	
var timeout = 300;

// not very clean but simple
// the function can be run in the HTML for faster display
// window.onload=initMenu;

// creat timeout variables for list item
// it's for avoid some warning with IE
for( var i = 0; i < 100; i++ )
{
    eval("var timeoutli" + i + " = false;");
}

// this fonction apply the CSS style and the event
function initMenu()
{
    // a test to avoid some browser like IE4, Opera 6, and IE Mac
    if ( browser.isDOM1 
    && !( browser.isMac && browser.isIE ) 
    && !( browser.isOpera && browser.versionMajor < 7 )
    && !( browser.isIE && browser.versionMajor < 5 ) )
    {
        // get some element
        var menu = document.getElementById('menu'); // the root element
        var lis = menu.getElementsByTagName('li'); // all the li
        
        // change the class name of the menu, 
        // it's usefull for compatibility with old browser
        menu.className='menu';
        
        // i am searching for ul element in li element
        for ( var i=0; i<lis.length; i++ )
        {
            // is there a ul element ?
            if ( lis.item(i).getElementsByTagName('ul').length > 0 )
            {        
                // improve IE key navigation
                if ( browser.isIE )
                {
                    addAnEvent(lis.item(i),'keyup',show);
                }
                // link events to list item
                addAnEvent(lis.item(i),'mouseover',show);
                addAnEvent(lis.item(i),'mouseout',timeoutHide);
                addAnEvent(lis.item(i),'blur',timeoutHide);
                addAnEvent(lis.item(i),'focus',show);
                
                // add an id to list item
                lis.item(i).setAttribute( 'id', "li"+i );
            }
        }
    }
}

function addAnEvent( target, eventName, functionName )
{
    // apply the method to IE
    if ( browser.isIE )
    {
        //attachEvent dont work properly with this
        eval('target.on'+eventName+'=functionName');
    }
    // apply the method to DOM compliant browsers
    else
    {
        target.addEventListener( eventName , functionName , true ); // true is important for Opera7
    }
}
    
// hide the first ul element of the current element
function timeoutHide()
{
    // start the timeout
    eval( "timeout" + this.id + " = window.setTimeout('hideUlUnder( \"" + this.id + "\" )', " + timeout + " );");
}

// hide the ul elements under the element identified by id
function hideUlUnder( id )
{   
    document.getElementById(id).getElementsByTagName('ul')[0].style['visibility'] = 'hidden';
}

// show the first ul element found under this element
function show()
{
    // show the sub menu
    this.getElementsByTagName('ul')[0].style['visibility'] = 'visible';
    var currentNode=this;
    while(currentNode)
    {
            if( currentNode.nodeName=='LI')
            {
                currentNode.getElementsByTagName('a')[0].className = 'linkOver';
            }
            currentNode=currentNode.parentNode;
    }
    // clear the timeout
    eval ( "clearTimeout( timeout"+ this.id +");" );
    hideAllOthersUls( this );
}

// hide all ul on the same level of  this list item
function hideAllOthersUls( currentLi )
{
    var lis = currentLi.parentNode;
    for ( var i=0; i<lis.childNodes.length; i++ )
    {
        if ( lis.childNodes[i].nodeName=='LI' && lis.childNodes[i].id != currentLi.id )
        {
            hideUlUnderLi( lis.childNodes[i] );
        }
    }
}

// hide all the ul wich are in the li element
function hideUlUnderLi( li )
{
    var as = li.getElementsByTagName('a');
    for ( var i=0; i<as.length; i++ )
    {
        as.item(i).className="";
    }
    var uls = li.getElementsByTagName('ul');
    for ( var i=0; i<uls.length; i++ )
    {
        uls.item(i).style['visibility'] = 'hidden';
    }
} 
	
	
	
	
function BrowserDetectLite() {
   var ua = navigator.userAgent.toLowerCase(); 

   // browser name
   this.isGecko     = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isMozilla   = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isNS        = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   this.isIE        = ( (ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) ); 
   this.isSafari    = (ua.indexOf('safari') != - 1);
   this.isOpera     = (ua.indexOf('opera') != -1); 
   this.isKonqueror = (ua.indexOf('konqueror') != -1 && !this.isSafari); 
   this.isIcab      = (ua.indexOf('icab') != -1); 
   this.isAol       = (ua.indexOf('aol') != -1); 
   
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isNS && this.isGecko) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('/') + 1 ) );
   }
   else if (this.isOpera) {
      if (ua.indexOf('opera/') != -1) {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera/') + 6 ) );
      }
      else {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera ') + 6 ) );
      }
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isIcab) {
      if (ua.indexOf('icab/') != -1) {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab/') + 6 ) );
      }
      else {
         this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab ') + 6 ) );
      }
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin   = (ua.indexOf('win') != -1);
   this.isWin32 = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac   = (ua.indexOf('mac') != -1);
   this.isUnix  = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
}
var browser = new BrowserDetectLite();
