/** LavaLamp/Fancy menu : http://ftp-developpez.com/vodiem/source/js/LavaLamp , Date: 17/11/2009, Auteur: Vo Jacques */
var LLMenu = {
	menu:[],
	
	Wrap : function(id,sl,pos){
		var im=$(id);
		cm=this.menu[id]={i:0,ni:35,t:20,is:$("a", im),sr:document.getElementById(sl),sd:pos};
		es=this.menu[id].is;
		im.onmouseout=Function("LLMenu.MoveTo('"+id+"','sd')");
		for(i=0;i<es.length;i++){
			es[i].onmouseover=function(id,i){return function(){LLMenu.MoveTo(id,i)}}(id,i);
			es[i].onclick=function(id,i){return function(){LLMenu.Clicked(id,i)}}(id,i);
			if(i==pos) {
				cm.sr.style.top=im.offsetTop+Math.floor((im.offsetHeight-cm.sr.offsetHeight)/2)+'px';
				cm.sr.style.left=es[i].parentNode.offsetLeft+'px';cm.sr.style.width=es[i].offsetWidth+'px';
			}
		}
	},
	
	Clicked: function(m,pos){this.menu[m].sd=pos},
	
	MoveTo: function(m,pos){
		cm=this.menu[m];cm.i=0;e=cm.is[(pos=='sd')?cm.sd:pos];cm.ps=cm.sr.offsetLeft;cm.d=e.offsetParent.offsetLeft-cm.ps;cm.w=cm.sr.offsetWidth;
		clearTimeout(cm.timer);LLMenu.MoveToStep(cm,e);
	},
	
	MoveToStep: function(cm,e){
		cm.i++;x=(cm.i/cm.ni);p=Math.exp(-Math.pow(Math.pow((x-0.98)*1.7,2)-0.308,2)+0.095);d=cm.ps+p*cm.d;
		cm.sr.style.left=d+'px';cm.sr.style.width=(cm.w+(e.offsetWidth-cm.w)*p)+'px';
		cm.i%=cm.ni;
		if(cm.i!=0){cm.timer=setTimeout(function(){LLMenu.MoveToStep(cm,e)},cm.t)}
			else {cm.ps=e.offsetParent.offsetLeft;cm.sr.style.left=cm.ps+'px';cm.sr.style.width=e.offsetWidth};
	}
};
