	var SlideShow = new Class ({
	Implements: Options,

	options : {
		imageTime	:	4000,
		fadeTime	:	1500
	},
	
	initialize : function (container, images, options) {
		this.setOptions(options);
		this.container = $(container);
		
		this.images = images.map(function(url) {
			return new Element('img', 
							   {'src' : url,
							    'width' : '100%', 'height': '100%',
								'tween' : {duration : this.options.fadeTime}
							   });
		}, this);

		this.index = 0;
		this.currentImage = this.images[this.index].inject(container);
		this.fade.periodical(this.options.imageTime + this.options.fadeTime, this);
	},
	
	fade : function () {
		this.index = (this.index + 1) % this.images.length;
		this.lastImage = this.currentImage;
		
		this.currentImage = this.images[this.index].fade('hide').inject(this.container).fade('in');
	}
	
	});


	var DhtmlMenu = new Class ({
		Implements: Options,
		
		options : {
			menuList : [],
			submenuList : [],
			submenuOpenDelay : 750,
			submenuCloseDelay : 500,
			minTop : -15,
			maxTop : 35
		},
		
		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 - 2)
					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');
			});
		}
	});




	var RollingMenu = new Class ({
	Implements: Options,
	
	options: {
		base	:	'',
		links	:	[],
		fadeTime	:	1500
		},
	
	initialize : function (container, base, images, position, content, options) {
		this.setOptions(options);
		this.base = base;
		this.container = $(container);
		this.content = $A(content);
		this.position = $A(position);
		
		this.images = images.map(function(url, i) {
				var obj = {x :  (this.position[i] == 1)?'on':'off'};
				
				if (this.position[i] == 1) {
					$(this.content[i]).set({'styles': {'opacity' : '1'},
										   	'tween' : {duration : this.options.fadetime}
										   });
				}else $(this.content[i]).set({'styles': {'opacity' : '0'},
										   	'tween' : {duration : this.options.fadetime}
										   });

				return new Element('img', 
								   {'src' : base + url.substitute({x :  (this.position[i] == 1)?'on':'off'}),
								    'widh' : '100%', 
									'height' : '100%'
									});
		},this);

		
		this.images.each(function (item, index) {
			var p = this.position;
			var c = this.content;
			var alli = this.images;
			var link = new Element('a', {'href' : item.src,
								   		 'style' : 'cursor:pointer',
								   		 'events' : {
											 'mouseover'	: function () {
																item.src = base + images[index].substitute({x : 'on'});
															  },

											 'mouseout'		: function () {
												 		   		if (p[index] == 1)
																	item.src = base + images[index].substitute({x : 'on'});
																else item.src = base + images[index].substitute({x : 'off'});
															  },
															   
											 'click'		: function (event) {
												 				event.stop();

												 				var current;
												 				p.each(function(x,y) { if (x == 1) current = y });
																alli[current].src = base + images[current].substitute({x : 'off'});
																p[current] = 0;

												 				if (p[index] == 0) {
													 			  	alli[index].src = base + images[index].substitute({x : 'on'});
																	p[index] = 1;
																$(c[current]).get('tween', {property: 'opacity', duration: 1200}).start(0);
																$(c[index]).get('tween', {property: 'opacity', duration: 1200}).start(1);
																}
																
															  }
										 			}
										});

			(link.grab(item)).inject(this.container);
		}, this);


	}
	
	});



	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;
		} 
	});



	function addEventsPicto (container, target) {
		$(container).getElements('img').each(function(item, index) {
			item.set('style', 'cursor:pointer');
			item.addEvents({
				'mouseover' : function () {
					$(target).set('html',this.alt);
				},
				'mouseout'	: function () {
					$(target).set('html','Sélectionnez un service');
				}
			});
		});
	}
	
	
	function fixNavigation (container) {
		var elt = $(container).getElements('input');
		
		var path = [];
		var url = [];
		elt.each(function(item, index) {
			if (item.get('name') == 'path') path = (item.get('value')).split("|");
			if (item.get('name') == 'pathurl') url = (item.get('value')).split("|");
		});
	
		var ul = new Element('ul');
		path.each(function(item, index) {
				var p0 = new Element('a', {'href' : url[index], 'html' : '&gt; '+item, 'class' : ((index < path.length-1)?'link':'current')});
				var li = new Element('li');

				p0.inject(li,'bottom');
				li.inject(ul,'bottom');
		}, this);
		
		ul.inject($(container),'bottom');
	}
	
	
	function fixSubmenu (container, limit) {
		$$('#'+container+' div.menu').each(function (item, index) {
				var divMenu = item;
				
				var liste = fixSubmenuRecupList (item, limit);
				
				var firstUl = item.getElements('ul')
				//firstUl[0].destroy();
				
				
				var newMenu = new Element('div', {'class': 'menu'});
				var ul = new Element('ul', {'class' : 'sub_nav'});
				limit = Math.round(liste.length/2);
				for (var i=0, bool = false; i<liste.length; i++) {
					if (i%limit == 0 && i > 0) {
						ul.inject(newMenu,'bottom');
						bool = false;
						var ul = new Element('ul', {'class' : 'sub_nav'});
						bool = true;
					}

					$$(liste[i]).inject(ul, 'bottom');
					
				}
				if (bool = true) ul.inject(newMenu,'bottom');
				
				newMenu.replaces(item);
		});
	}
	
	function fixSubmenuRecupList (elt) {
		var tab = new Array();
		
		var lst = elt.getElements('li');
		lst.each(function(item, index) { 
			tab[index] = item;
		}, this);
		
		return tab;
	}


	function valideReservation (container, url) {
		var msg = '';

		$$('#'+container+' .important').each(function(element) {
			switch(element.get('tag')) {
				case "input"	:	if (element.get('type') == 'text' && element.get('value').trim() == '')
										msg += 'Le champs '+element.get('name')+' n\'est pas rempli\n';
									break;
			}
		});
		
		if (msg.trim() != '')
			alert(msg);
		else {
			alert('ok');
			$(container).set('action',url)	;
			$(container).submit();
		}
	}