	var DhtmlMenu = new Class ({
		Implements: Options,
		
		options : {
			menuList : [],
			submenuList : [],
			submenuOpenDelay : 750,
			submenuCloseDelay : 500,
			minTop : 0,
			maxTop : 43
		},
		
		initialize : function (menuContainer, submenuContainer, options) {
			this.setOptions(options);
			this.menuList = this.options.menuList;
			this.submenuList = this.options.submenuList;
			this.current = null;
			this.currentFlag = 0;

			this.menu = $(menuContainer);
			
			// Récupérer la liste des menus
			this.menuItems();
			
			// Récupérer la liste des sous-menus
			this.submenuItems();
			
			this.animateMenuItems();
			
			$(this.menu.id+'-container').addEvent('mouseleave',
				function() {
					if (this.current != null && this.currentFlag == 1) {
						this.closeSubmenu(this.current);
						this.current = null;
					}
				}.bindWithEvent(this)
				
				);
		},
		
		menuItems: function () {
			var lst = this.menu.getElements('li[id^='+this.menu.id+']');
			lst.each(function(item,index) {
				this.menuList[index] = item;
			}, this);
		},
		
		submenuItems: function () {
			this.menuList.each(function(item,index) {
				var id = item.id.match(/menu(\d+)/);
				this.submenuList[index] = $('sub'+this.menu.id+id[1]);
				
				// Si le sous-menu existe >> ajouter un évènement
				if (this.submenuList[index] != null) {
					
					var openDelay = this.options.submenuOpenDelay;
					var closeDelay = this.options.submenuCloseDelay;
					var minTop = this.options.minTop;
					var maxTop = this.options.maxTop;
					
					this.submenuList[index].addEvents({
						'open' : function() {
							this.set('tween', {duration: openDelay});
							if (this.style.top == "" || this.style.top.toInt() != maxTop)
								this.tween('top', [minTop, maxTop]);
							else this.tween('top', [maxTop, minTop]);
						},
						
						'close' : function() {
							this.set('tween', {duration: closeDelay});
							if (this.style.top.toInt() == maxTop) this.tween('top', [maxTop, minTop]);
						}
					});
					
					this.fixsubmenu(this.submenuList[index]);
				}

			}, this);
		},
		
		animateMenuItems: function () {
			this.menuList.each(function(item,index) {
				var submenu = this.submenuList[index];

				item.addEvents({
					'mouseover' : function(event) {
						if (this.current == null) {
							this.openSubmenu(index);
						}
						else if (this.current != index) {
							this.closeSubmenu(this.current);
							this.openSubmenu(index);
						}
						else if (this.current == index && this.currentFlag == 0) {
							this.openSubmenu(index);
						}
						this.current = index;
						
					}.bindWithEvent(this)
				});
				
			}, this);
		},
		
		testSubmenu: function (index) {
			return	(this.submenuList[index] != null);
		},
		
		openSubmenu: function (index) {
			if (this.testSubmenu(index) == true) {
				this.submenuList[index].fireEvent('open');
				this.currentFlag = 1;
			}
			return this.submenuList[index];
		},
		
		closeSubmenu: function (index) {
			if (this.testSubmenu(index) == true) {
				this.submenuList[index].fireEvent('close');
				this.currentFlag = 0;
			}
			return this.submenuList[index];
		},
		
		fixmenu: function(container) {
			var temp = $(container).getElements('li');
			var length = temp.length;
			temp.each(function(item, index) {
				if (index == length - 1)
					item.set('class', 'last-item');
			});
		},
		
		fixsubmenu: function(container) {
			var temp = $(container).getElements('li');
			var length = temp.length;
			temp.each(function(item, index) {
				if (index == length - 1)
					item.set('class', 'last-item');
			});
		}
	});


	function httpRequest (srcElt, dstElt) {
	srcElt.addEvent('click', function(event) { 
		event.stop();
        var req = new Request({  
					method: 'get',  
             		url: srcElt.get('href'), 
	             	onComplete: function(response) { dstElt.set('html',response) ; }  
		         	}).send();  
    	});  
	}

	function httpRequestPost (srcElt, dstElt) {
				var data = "";
							var elt = $$("#searchForm input").each(function (item, index) {
							data += item.getProperty("name") + "=" +item.getProperty("value")+"&";
							});

         		var req = new Request({  
					method: 'post',  
					data: data,
        	     	url: srcElt.getProperty('action'), 
            	 	onComplete: function(response) { $('content').set('html',response) ; }  
	         	}).send();  
				
		}

	function httpRequestPostUrl (srcElt, dstElt, urlPost) {
				var data = "";
							var elt = $$("#search input.txt").each(function (item, index) {
							data += item.get("name") + "=" +item.get("value")+"&";
							});

         		var req = new Request({  
					method: 'post',  
					data: data,
        	     	url: urlPost, 
            	 	onComplete: function(response) { $('content').set('html',response) ; }  
	         	}).send();  
				
		}
		

	var Tools = new Class({
		Implements: Options,

		options : {
			size: '11px',
			line: '15px'
		},
	
		initialize : function (container, className, options) {
			this.setOptions(options);
			this.classNames = [];
			
			if ($chk(this.options.font) == true) {
				var temp = this.options.font.match(/(\w+)\/(\w+)*/);
				this.options.size = temp[1];
				this.options.line = temp[2];
			}
			
			className.each(function(item, index) {
				var font = (item.font).match(/(\w+)\/(\w+)*/);
				this.classNames[index] = {title: item.className, size: font[1], line: font[2]};
			}, this);
		
			this.container = $(container);
			
		},
		
		updateFont : function () {
			var param;
			var body = this.container.getElements('*');

			body.each(function(item, index) {
				var param = this.searchClass(item.get('class'));
				if ( param != false)
					item.set('style', 'font-size:'+ param.size+'; line-height:'+param.line+';');
				else item.set('style', 'font-size:'+ this.options.size+'; line-height:'+this.options.line+';');	
				
			}, this);
		},
		
		
		upto1 : function () {
			this.classNames.each(function(item, index) {
				item.size = (item.size.toInt()+1)+'px';
				item.line = (item.line.toInt()+1)+'px';
			});
			
			this.options.size = (this.options.size.toInt()+1)+'px';
			this.options.line = (this.options.line.toInt()+1)+'px';
		},
		
		downto1 : function () {
			this.classNames.each(function(item, index) {
				item.size = (item.size.toInt()-1)+'px';
				item.line = (item.line.toInt()-1)+'px';
			});
			
			this.options.size = (this.options.size.toInt()-1)+'px';
			this.options.line = (this.options.line.toInt()-1)+'px';
		},
		
		
		searchClass : function (name) {
			var bool = false;
			
			this.classNames.each(function(item,index) {
				if (item.title == name) {
					bool = {size: item.size, line: item.line};
				}
			});

			return bool;
		} 
	});