var JMenu = new Class({
	initialize: function(el,thisStyle)
	{
		if(el){
			var elements = el.getElements('li');
			var nested = null;
			for (var i=0; i<elements.length; i++){	
			
				var element = elements[i];
	
				element.addEvent('mouseover', function(){
					this.addClass(thisStyle);
					this.setStyle('cursor','pointer');
					this.setAttribute('overattr', 1);
					if($(this.getFirst('ul'))){
						//$(this.getFirst('ul')).setStyle('visibility', 'visible');	
					}
				});
				element.addEvent('mouseout', function(){
					toggleMenuOff(this, 0,thisStyle);							  	
				});
				element.addEvent('click', function(){
					var a = this.getFirst('div').getFirst('a')
					window.location = a.href;
				});
	
				//find nested UL
				nested = $('ul', element);
				if(!nested) {
					continue;
				}
	
				//declare width
				var offsetWidth  = 0;
	
				//find longest child
				for (k=0; k < nested.childNodes.length; k++) {
					var node  = nested.childNodes[k]
					if (node.nodeName == "LI")
						offsetWidth = (offsetWidth >= node.offsetWidth) ? offsetWidth :  node.offsetWidth;
				}
	
				//match longest child
				for (l=0; l < nested.childNodes.length; l++) {
					var node = nested.childNodes[l]
					if (node.nodeName == "LI") {
						$(node).setStyle('width', offsetWidth+'px');
					}
				}
	
				$(nested).setStyle('width', offsetWidth+'px');
			}
		}
	},
	setFooter:function () {
            var myCentre = document.getElementById('centre');
            var hauteurCentre = myCentre.offsetHeight;
            var myFooter = document.getElementById('newFooter');
            hauteurFooter = myFooter.offsetHeight;
            var hauteurFinal = 110 + hauteurCentre;
            myFooter.style.top = hauteurFinal+'px';
            
        }
        
    
});
function toggleMenuOff(el, second,thisStyle){
            if(!second){
                setTimeout(function(){this.toggleMenuOff(el, 1,thisStyle);}, 20);
                el.setAttribute('overattr', 0);
                return;
            }
            if(el.getAttribute('overattr') == 1) return;
			el.removeClass(thisStyle);
            //el.className = el.className.replace(/ sfhover/gi, '');      
}
/*****************************************************/
function toggleTween(id){
	var mc = $(id);
	var myFx = new Fx.Morph(mc,{duration: 200, transition: Fx.Transitions.Sine.easeOut})
	mc.addEvent('mouseover', function() {
		myFx.start('.bottomHomeRight1');
	});
	mc.addEvent('mouseout', function() {
		myFx.start('.bottomHomeRight');
	});

}
/*****************************************************/
window.addEvent('domready',function(){
		var menu1= new JMenu($('nav'),'selected');
		var menu2= new JMenu($('nav2'),'selected');
	}
)
/*****************************************************/
function Popup(url,name,width,height,resize,scroll) {
	 var dialogWin = new Object();
	 dialogWin.width = width;
	 dialogWin.height = height;
	 if (navigator.appName == "Netscape") {
		 dialogWin.left = window.screenX + ((window.outerWidth - dialogWin.width) / 2);
		 dialogWin.top = window.screenY + ((window.outerHeight - dialogWin.height) / 2);
		 var attr = 'screenX=' + dialogWin.left + ',screenY=' + dialogWin.top + ',resizable=' + resize + ',width=' + dialogWin.width + ',height=' + dialogWin.height + ',scrollbars=' + scroll + ',menubar=no,location=no,toolbar=no,status=no,directories=no';
	 } else if (document.all) {
		 dialogWin.left = (screen.width - dialogWin.width) / 2;
		 dialogWin.top = (screen.height - dialogWin.height) / 2;
		 var attr = 'left=' + dialogWin.left + ',top=' + dialogWin.top + ',resizable=' + resize + ',width=' + dialogWin.width + ',height=' + dialogWin.height + ',scrollbars=' + scroll + ',menubar=no,location=no,toolbar=no,status=no,directories=no';
	 }
	 window.open(url,name,attr);
}