var leMenuActif=''
var leSMenuActif=''
var sousActif = null
var categorieActif = null  
var menuTimeout = null
var LeTimeOut = null
var temp
var wMin=960
var hMin = 577


function pos()
{
	getSizes()	
	
	document.getElementById('tout').style.top= Number ((Number(h)/2) - 607/2 ) + 'px'
	document.getElementById('tout').style.left= Number ((Number(w)/2) - 962/2 ) + 'px'
	document.getElementById('tout').style.display='block'
	document.getElementById('ledivtxt').style.display='none'
	document.getElementById('ledivtxt').style.display='block'
	document.getElementById('EPM-Mecanic-logo').style.display='block'
	document.getElementById('arjuna').style.top=h/2+607/2 -10 + 'px'
	document.getElementById('arjuna').style.left=w/2+962/2 -85 + 'px'
	
	//setTimeout("pos2()",1)
}
function pos2(){
	
	document.getElementById('ledivtxt').style.display='none'
	document.getElementById('ledivtxt').style.display='block'
	

}

function r(ceci)
{
	if(leMenuActif!=ceci.id)
	{
		temp = ceci.src
		temp = temp.split(".jpg")
		ceci.src=temp[0] + "-r.jpg"
	}
}

function ro(ceci)
{
	if(leMenuActif!=ceci.id)
	{
		temp = ceci.src
		temp = temp.split("-r.jpg")
		ceci.src=temp[0] + ".jpg"
	}
}



function smr(ceci)
{
	if(leSMenuActif!=ceci.id)
	{
		ceci.style.backgroundColor='#333333';
		ceci.style.color='white';
		document.body.style.cursor='pointer';
	}
	else
	{
		document.body.style.cursor='default';	
	}
}

function smro(ceci)
{
	if(leSMenuActif!=ceci.id)
	{
		ceci.style.backgroundColor='#f7f1f1';
		ceci.style.color='#333333';
		document.body.style.cursor='';
	}
	else
	{
		document.body.style.cursor='';	
	}
}


function MenuRollOut(el) 
{
	clearInterval(intervale1);clearInterval(intervale2);clearInterval(intervale3);

}

function rollOverSM(el)
{
	document.getElementById(el).style.backgroundColor='#621316'
}

function setOpacitySimple(el, opacity) 
{
	el = document.getElementById(el);

	el.style.opacity = opacity;
	el.style.MozOpacity = opacity;
	el.style.KhtmlOpacity = opacity;
	el.style.filter = "alpha(opacity="+(opacity * 100)+")";
}


function MenuRoll(el) 
{
	document.getElementById(el).src = "0"+el+"r.jpg"

	intervale1 = setTimeout("setOpacitySimple('"+el+"', 0.8)", 100);
	intervale2 = setTimeout("setOpacitySimple('"+el+"', 0.9)", 200);
	intervale3 = setTimeout("setOpacitySimple('"+el+"', 1)", 300);
}


function CentrerImg()
{
	
	for(x=0;x<=70;x++)
	{
		var leId=String("img"+x)
		if( document.getElementById(leId) != null )
		{
			var toto = Number(document.getElementById(leId).height)

			if(isNaN(toto))
			{
				document.getElementById(String("img"+x)).style.marginTop='500px'
				return;
			}
			
			document.getElementById(String("img"+x)).style.marginTop = String(((200- toto)/2)) + 'px'
		}
	}
}
	
	
function afficherSous(menu)
{
	if(menuTimeout!=null)	//si un sm est actif le cacher 
	{
		cacherSous(menuTimeout)
		clearTimeout(LeTimeOut)
	}
	
	document.getElementById('menu3').src='nos-divisions-r.jpg'
	
	document.getElementById('s'+menu).style.display='block'
		//Trouver X
	document.getElementById('s'+menu).style.left=findPosX(document.getElementById(menu))+'px'  //10+emplacementX+'px'
		//Trouver Y
	document.getElementById('s'+menu).style.top=findPosY(document.getElementById(menu))+(document.getElementById(menu).height/2)+10+'px'

}

function findPosY(obj)
{
var curtop = 0;
if(obj.offsetParent)
	while(1)
	{
	  curtop += obj.offsetTop;
	  if(!obj.offsetParent)
		break;
	  obj = obj.offsetParent;
	}
else if(obj.y)
	curtop += obj.y;
return curtop;
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}


function SousMenuActif(id,menuCacher)
{
  
 MenuClick(id)
 LeTimeOut = setTimeout("cacherSous('"+menuCacher+"')",100)	
var temp = menuCacher.substring(1,menuCacher.length)

MenuRoll(temp)
} 

function IntervaleCacherSous(menu)
{
	//fermer le menu automatiquement apres 2 secondes
	menuTimeout=menu;
	LeTimeOut = setTimeout("cacherSous('"+menuTimeout+"')",400)
}

function ArretIntervaleCacherSous(menu)
{
	clearTimeout(LeTimeOut)
	//menuTimeout=null;
	LeTimeOut=null;
}


function cacherSous(menu)
{
	ro(document.getElementById('menu3'));
	//document.getElementById('menu3').src='nos-divisions.jpg'
	document.getElementById(menu).style.display='none';
}


  