var Portrait = new Class({
	initialize: function() {
		var portraits = document.getElements('.portrait');
		portraits.each(function(port) {
			port.store('nb',port.getElement('.img_nb'));

			port.retrieve('nb').setStyle('opacity',0.9);

			port.addEvent('mouseenter', function() {
				port.retrieve('nb').fade(0.1);
			});

			port.addEvent('mouseleave', function() {
				port.retrieve('nb').fade(0.9);
			});

		});
	}

});

/*
	OthersMenu


*/

var OthersMenu = new Class({
	initialize: function(target) {
		this.container = target;
		
		if (!this.container) return;
		
		this.others = this.container.getElements('.other');

		this.selected = $('selected');

		if (this.others.length < 2) return;

		var i = 0;

		this.others.each(function(menu) {

			if (menu == this.selected) {

				if (i != 0) {
					this.selected.prev = this.others[i - 1].getFirst().getProperty('href');
				} else {
					this.selected.prev = this.others[this.others.length - 1].getFirst().getProperty('href');
				}

				if (i != this.others.length - 1) {
					this.selected.next = this.others[i + 1].getFirst().getProperty('href');
				} else {
					this.selected.next = this.others[0].getFirst().getProperty('href');
				}

			}

			i++;

			menu.store('fxopacity',new Fx.Tween(menu, {duration: 200, transition: Fx.Transitions.quadIn}));
			
			menu.setStyle('opacity',0.3);

			menu.addEvent('mouseenter', function() {
				menu.retrieve('fxopacity').cancel();								 
				menu.retrieve('fxopacity').start('opacity',1);
			});

			menu.addEvent('mouseleave', function() {
				menu.retrieve('fxopacity').cancel();		
				menu.retrieve('fxopacity').start('opacity',0.3);
			});

		}.bind(this));

	},
	// end constructor

	getMenuLength: function() {
		if (this.others)
		return this.others.length;
	},

	getPrev: function() {
		return this.selected.prev;
	},

	getNext: function() {
		return this.selected.next;
	}

}); // end OtherMenus;

//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////

var PrevNext = new Class({

	initialize: function(target) {

		this.text = new Element('span').inject(target);
		this.prevbtn = new Element('a').inject(target);
		var bar = new Element('span').appendText(' | ').inject(target);
		this.nextbtn = new Element('a').inject(target);
	},

	translate: function(nxt, bck, prj) {
		this.nextbtn.appendText(nxt);
		this.prevbtn.appendText(bck);
		this.text.appendText(prj);
	},

	setPrev: function(prev) {
		this.prevbtn.setProperty('href', prev);
	},

	setNext: function(next) {
		this.nextbtn.setProperty('href', next);
	}

}); // end PrevNext;

////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////

var Diaporama = new Class({
	
	actualpos: 0,
	distance0: 772,

	initialize: function(traduction) {
 
		this.container = $('diaporama');
		this.slider = $('slider');
		
		this.dias = this.container.getElements('.dia');
		this.dias.store('imgs',[]);
		
		if (this.dias.length < 2 || this.dias.length == 'undefined') return;
		
		this._createToolbar();
		
		this._loadDiasEffect();

		if (this.dias.length > 3) {
			this._startAjaxLoader();
		}
	},
	// end constructor	

	translate: function(nxt, bck, run, stp) {
		if (!this.toolbar) return;
		this.toolbar.retrieve('nxt').appendText(nxt);
		this.toolbar.retrieve('bck').appendText(bck);
		this.toolbar.retrieve('run').appendText(run);
		this.toolbar.retrieve('stp').appendText(stp);
	},

	_startAjaxLoader: function() {

		this.dias.each(function(dia) {

			dia.store('url',dia.getFirst().getProperty('src'));
			dia.store('alt',dia.getFirst().getProperty('alt'));
			dia.store('ttl',dia.getFirst().getProperty('title'));

			dia.getFirst().destroy();
			
			dia.store('isloaded',false);

		}); // end each
		
		this._loadByAjax(this.dias[0]);
		this._loadByAjax(this.dias[1]);
		this._loadByAjax(this.dias[this.dias.length - 1]);

	},

	_loadByAjax: function(dia) {

		dia.store('loader', new Element('div').addClass('loader').inject(dia));

		dia.store('img',new Asset.images([dia.retrieve('url')], {
			onComplete: function() {
				dia.retrieve('img').inject(dia);
				dia.store('isloaded',true);
				dia.retrieve('loader').destroy();
			}
		}));

	},

	_loadDiasEffect: function() {

		this.dias.each(function(dia) {
			dia.store('fxwidth',new Fx.Tween(dia, {
				duration: 600,
				transition: Fx.Transitions.quadInOut
			}));
		});
	},

	_createToolbar: function() {


		this.opak = new Element('div').addClass('opak').setOpacity(0.7).inject(this.container);
		this.toolbar = new Element('div').addClass('toolbar').inject(this.container);
		this.toolbar.store('bg',new Element('div').addClass('bg').setStyle('opacity',0.7).inject(this.toolbar));
		this.toolbar.store('btns',new Element('div').addClass('btns').inject(this.toolbar));
		this.toolbar.store('nxt',new Element('a').addClass('next').inject(this.toolbar.retrieve('btns')).setProperty('href', 'javascript:void(0)'));
		this.toolbar.store('bck',new Element('a').addClass('back').inject(this.toolbar.retrieve('btns')).setProperty('href', 'javascript:void(0)'));
		this.toolbar.store('run',new Element('a').addClass('run').inject(this.toolbar.retrieve('btns')).setProperty('href', 'javascript:void(0)'));
		this.toolbar.store('stp',new Element('a').addClass('stop').inject(this.toolbar.retrieve('btns')).setProperty('href', 'javascript:void(0)').setStyle('display', 'none'));
		
		this.container.addEvent('mouseenter', function() {
			this._showToolbar();
		}.bind(this));

		this.container.addEvent('mouseleave', function() {
			this._hideToolbar();
		}.bind(this));

		this.toolbar.retrieve('nxt').addEvent('click', function() {
			$clear(this.periodical);
			this.toolbar.retrieve('run').setStyle('display', '');
			this.toolbar.retrieve('stp').setStyle('display', 'none');
			this._nextDia();
		}.bind(this));

		this.toolbar.retrieve('bck').addEvent('click', function() {
			$clear(this.periodical);
			this.toolbar.retrieve('run').setStyle('display', '');
			this.toolbar.retrieve('stp').setStyle('display', 'none');
			this._prevDia();
		}.bind(this));

		this.toolbar.retrieve('run').addEvent('click', function() {
			this._runDiaporama();
		}.bind(this));

		this.toolbar.retrieve('stp').addEvent('click', function() {
			this._stopDiaporama();
		}.bind(this));

		this.toolbar.store('ypos', new Fx.Tween(this.toolbar, {
			duration: 200,
			transition: Fx.Transitions.quadInOut
		}));
	},

	_nextDia: function() {

		var nextimg = this.actualpos + 2;
		if (nextimg < this.dias.length && this.dias[nextimg].retrieve('isloaded') == false) {
			this._loadByAjax(this.dias[nextimg]);
		}

		if (this.actualpos < this.dias.length - 1) {
			this.dias[this.actualpos].retrieve('fxwidth').start('width',0);
			this.actualpos++;
		} else {
			// go to first dia:
			this.dias.each(function(dia) {
				dia.retrieve('fxwidth').start('width',772);
			});
			this.actualpos = 0;

		}

	},

	_prevDia: function() {

		var previmg = this.actualpos - 2;

		if (previmg == -1) previmg = this.dias.length - 1;
		if (previmg == -2) previmg = this.dias.length - 2;

		if (this.dias[previmg].retrieve('isloaded') == false) {
			this._loadByAjax(this.dias[previmg]);
		}

		if (this.actualpos > 0) {
			this.actualpos--;
			this.dias[this.actualpos].retrieve('fxwidth').start('width',772);
		} else {
			// go to last dia:
			this.dias.each(function(dia) {
				dia.retrieve('fxwidth').start('width',0);
			});
			this.dias[this.dias.length - 1].retrieve('fxwidth').cancel();
			this.dias[this.dias.length - 1].retrieve('fxwidth').start('width',772);
			this.actualpos = this.dias.length - 1;
		}
		/*this.distance = -this.actualpos*this.distance0;
		this.slider.xpos.stop();
		this.slider.xpos.start(this.distance);*/
	},

	autoRunDiaporama: function() {
		//this._nextDia();
		if (!this.toolbar) return;
		this.periodical = this._nextDia.periodical(6000, this);
		this.toolbar.retrieve('run').setStyle('display', 'none');
		this.toolbar.retrieve('stp').setStyle('display', '');
	},

	_runDiaporama: function() {
		this._nextDia();
		this.periodical = this._nextDia.periodical(5000, this);
		this.toolbar.retrieve('run').setStyle('display', 'none');
		this.toolbar.retrieve('stp').setStyle('display', '');
	},

	_stopDiaporama: function() {
		$clear(this.periodical);
		this.toolbar.retrieve('run').setStyle('display', '');
		this.toolbar.retrieve('stp').setStyle('display', 'none');
	},

	_showToolbar: function() {
		this.toolbar.retrieve('ypos').cancel();
		this.toolbar.retrieve('ypos').start('margin-top',405);
	},

	_hideToolbar: function() {
		this.toolbar.retrieve('ypos').cancel();
		this.toolbar.retrieve('ypos').start('margin-top',443);
	}

}); // end Diaporama;

////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////

var CheckLinks = new Class({

	initialize: function(linklist) {

		linklist.each(function(lnks) {

			lnks = document.getElements(lnks);

			lnks.each(function(lnk) {
				if (lnk.getProperty('href') && lnk.getProperty('href').test('/$') == true) {
					lnk.destroy();
				}
				if (lnk.getProperty('src') && lnk.getProperty('src').test('/$') == true) {
					lnk.destroy();
				}
			});

		});
	}

}); // end CheckLinks;

////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////

var OpenClosePlan = new Class({

	initialize: function() {
		this.map = document.getElement('.map');
		this.btn = document.getElement('.mapbtn');

		if (this.map && this.btn) {
			this.map.setStyle('opacity',0);
			this.map.store('isclosed',true);

			this.btn.addEvent('click', function() {
				if (this.map.retrieve('isclosed') == true) {
					this.map.setStyle('opacity',1);
					this.map.store('isclosed') = false;
				} else {
					this.map.setStyle('opacity',0);
					this.map.store('isclosed') = true;
				}
			}.bind(this));

		} else {
			if (this.btn)
				this.btn.destroy();
		}
	}
}); // end OpenClosePlan;

/*
	MenuImage
	


*/

var MenuImage = new Class({
	var1: 1,
	initialize: function(handle) {

		if (handle == 'undefined' || handle == false) return;

		this.container = $(handle);
		if (this.container) {
			this.txts = this.container.getElements('.txt');
			this.imgs = this.container.getElements('.img');
			
			// texts /////////////////////////////////////
			this.txts.each(function(txt) {
				txt.addClass('cube');
				//txt.setStyle('display','none');
				txt.setStyles({
					'position': 'absolute',
					'opacity': 0
				});
			},this);
		
			// images ////////////////////////////////////
			var i = 0;
	
			var toss = Math.random();
			if (toss >= 0.33) {
				this.floatside = 'left';
			} else {
				this.floatside = 'left';
				//this.floatside = 'right';
			}
	
			this.imgs.each(function(img) {
	
				//img.i = i;
				img.store('cubelink',this.txts[i]);
				i++;
	
				img.setStyles({
					'float': this.floatside
				});
	
				img.retrieve('cubelink').store('fxopacity', new Fx.Tween(img.retrieve('cubelink'), {duration: 200, transition: Fx.Transitions.quadIn}));
			
	
				img.addEvent('mouseenter', function() {
					img.x = img.getPosition().x;
					img.y = img.getPosition().y;
					img.w = img.getCoordinates().width;
					img.h = img.getCoordinates().height;
	
					if (img.x > 584) img.w = -img.w;
					if (img.x > 300 && img.w > 200) img.w = -img.w / 2;
	
					if (this.imgs.length == 2) {
						img.retrieve('cubelink').setStyles({
							'left': img.x - 3,
							'top': img.y + img.h - 3
						});
					} else {
						img.retrieve('cubelink').setStyles({
							'left': img.x + img.w - 3,
							'top': img.y - 3
						});
					}
					img.retrieve('cubelink').retrieve('fxopacity').cancel();
					img.retrieve('cubelink').retrieve('fxopacity').start('opacity',1);
				}.bind(this));
	
				img.addEvent('mouseleave', function() {
					img.retrieve('cubelink').retrieve('fxopacity').cancel();
					img.retrieve('cubelink').retrieve('fxopacity').start('opacity',0);
				});
	
				img.retrieve('cubelink').addEvent('mouseenter', function() {
					img.retrieve('cubelink').retrieve('fxopacity').cancel();
					img.retrieve('cubelink').retrieve('fxopacity').set('opacity',0);
				});
	
			},this);
	
			// shuffle //////////////////////////////////
			this.shuffle(this.imgs);
	
			switch (this.imgs.length) {
			case 0:
				return;
				break;
	
			case 1:
				this.serie = [1];
				this.setImages();
				this.addGreyBox(8);
				break;
	
			case 2:
				this.serie = [1, 1];
				this.setImages();
				this.addGreyBox(4);
				break;
	
			case 3:
				this.serie = [1, 0, 0];
				this.setImages();
				this.addGreyBox(6);
				break;
	
			case 4:
				this.serie = [1, 0, 0, 0];
				this.setImages();
				this.addGreyBox(5);
				break;
	
			case 5:
				this.serie = [1, 0, 0, 0, 0];
				this.setImages();
				this.addGreyBox(4);
				break;
	
			case 6:
				this.serie = [0, 0, 0, 0, 1];
				this.setImages();
				this.addGreyBox(3);
				break;
	
			case 7:
				this.serie = [0, 0, 0, 0, 1];
				this.setImages();
				this.addGreyBox(2);
				break;
	
			case 8:
				this.serie = [0, 0, 0, 0, 1];
				this.setImages();
				this.addGreyBox(1);
				break;
	
			case 9:
				this.serie = [0, 0, 0, 0, 1];
				this.setImages();
				//this.addGreyBox(0);
				break;
	
			default:
				this.serie = [0, 0, 0, 0, 1];
				this.setImages();
				this.addGreyBox((121 - this.imgs.length) % 4);
				break;
			};
}
	},
	// end constructor

	//methods:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	setImages: function() {

		var j = 0;
		this.imgs.each(function(img) {

			img.inject(this.container,'inside');
			if (this.serie[j] == 1) {
				img.setStyles({
					'width': '383px',
					'height': '339px'
				});
				img.getFirst().setStyles({
					'width': '383px',
					'height': '339px'
				});
			}
			j++;
		},
		this);

	},

	shuffle: function(tablo) {
		tablo.sort(function() {
			return Math.floor((3 * Math.random()) - 1);
		});

	},

	addGreyBox: function(n) {
		for (var i = 0; i < n; i++) {
			new Element('div').addClass('greybox').inject(this.container,'inside');
		}

	}

	//end methods

}); // end class MenuImage

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var Menu = new Class({

	var1: 1,
	initialize: function(handle, lang) {

		this.lang = lang;
		this.handle = $(handle);
		this.lis = document.getElements('.main');
		var i = 0;

		this.actualmainmenu = null;
		this.actualmenu = null;

		// memorize the css color for selected elements (tricky but works):
		var temp = new Element('div').addClass('s').inject(this.handle);
		this.colorselection = temp.getStyle('background-color');
		temp.destroy();

		this.mainopak = new Element('div').addClass('mainopak').inject($('container')).setStyle('opacity',0);
		this.mainopak.store('fxopacity',new Fx.Tween(this.mainopak, {
			duration: 200,
			transition: Fx.Transitions.quadIn
		}));
		this.mainopak.addEvent('click', function() {
			this.closeMenu(this.actualmenu);
		}.bind(this));

		// mainmenu lis behaviour /////////////////////////////////////////////////
		this.lis.each(function(li) {
							 
			i++;
			li.store('i',i);

			li.store('menu',li.getElement('.menu'));

			li.id = li.getProperty('id');

			// create a gradient color and memorize it (a bit tricky too...):
			li.store('colorclass','color' + i);
			li.getFirst().addClass(li.retrieve('colorclass'));
			li.store('color0',li.getFirst().getStyle('background-color'));
			if (li.getFirst().hasClass('s')) {
				this.actualmainmenu = li.getFirst();
				li.getFirst().removeClass('s');
				li.store('color0',li.getFirst().getStyle('background-color'));
				li.getFirst().addClass('s');
			}

			if (li.id == 'category25') { // only for news category
				this.attachNews(li, li.retrieve('color0'));
			}

			// mainmenu with menu: ////////////////////////////////////////////////
			
			//console.log(li.retrieve('menu'));
			
			if ((li.retrieve('menu') != null) && (li.id != 'category25')) {

				this.createMenu(li.retrieve('menu'), li.retrieve('color0'));

				// delete the a link only without the admin interface
				/*if (this.is_edited == false){
						li.getFirst().setProperty('href' , 'javascript:void(0)');
				}else{
					this.openMenuForEdition(li.menu);
				}*/
				li.getFirst().setProperty('href', 'javascript:void(0)');

				li.getFirst().addEvent('click', function() {
					//console.log("click!");
					this.openMenu(li.retrieve('menu'));
					li.getFirst().addClass('s');
					if (this.actualmainmenu) this.actualmainmenu.removeClass('s');
					this.actualmainmenu = li.getFirst();
				}.bind(this));

				// mainmenu without menu: ////////////////////////////////////////////
			} else if (li.id != 'category25') {

				li.addEvent('click', function() {
					this.tempoLink(li.getFirst());
					this.closeMenu(this.actualmenu);
					li.getFirst().addClass('s');
					this.actualmainmenu.removeClass('s');
					this.actualmainmenu = li.getFirst();
				}.bind(this));
			}

			// behaviours ///////////////////////////////////////////////////////
			li.addEvent('mouseover', function() {
				li.getFirst().addClass('s');
			}.bind(this));

			li.addEvent('mouseout', function() {
				if (li.getFirst() != this.actualmainmenu) li.getFirst().removeClass('s');
			}.bind(this));

		},
		this); // end each
	},
	// end constructor

	//methods:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	attachNews: function(li, color) {

		var container = new Element('ul').addClass('menu').setStyle('display', 'none').inject(li);

		if (this.lang == 'undefined') this.lang = 'fr';
		var url = '/floor/cs?server=lutz&lang=' + this.lang + '&item_categoryID=25&template=ajaxnews&itemlist=news_ajax&usepublishedpage=no';

		new Request.HTML({
			url:url,
			method: 'get',
			update: container,

			onComplete: function() {

				this.createMenu(container, color);
				li.getFirst().setProperty('href', 'javascript:void(0)');

				li.getFirst().addEvent('click', function() {
					container.setStyle('display', '');
					this.openMenu(container);
					li.getFirst().addClass('s');
					if (this.actualmainmenu) this.actualmainmenu.removeClass('s');
					this.actualmainmenu = li.getFirst();
				}.bind(this));
			}.bind(this)

		},
		this).send();

	},

	// tempolink: allocates time to menus to close before loading page
	tempoLink: function(lnk, memolnk) {
		if (this.actualmenu == null) return;

		if (lnk != null) {
			var lnk0 = lnk.getProperty('href');

			(function() {
				window.location = lnk0;
				
			}).delay(1100);
		} else {

			(function() {
				window.location = memolnk;
			}).delay(1100);
		}

	},

	createMask: function(li, color0) {

		li.mask = new Element('div').addClass('mask').setStyle('background', color0).inject(li);
		li.store('maskfx', new Fx.Tween(li.mask, {
			duration: 200,
			transition: Fx.Transitions.quadIn
		}));

	},

	hideMask: function(li) {

		li.retrieve('maskfx').cancel();
		li.retrieve('maskfx').start('opacity',0);
	},

	showMask: function(li) {

		li.retrieve('maskfx').cancel();
		li.retrieve('maskfx').start('opacity',1);
	},

	createMenu: function(menu, color0) {

		if (!menu) return;
		
		menu.lis = menu.getElements('li'); 
		

		if (menu.lis == undefined) return;

		menu.store('fx', new Fx.Tween(menu, {
			duration: 410,
			transition: Fx.Transitions.quadIn
		}));

		var i = 0;

		menu.lis.each(function(li) {

			li.addClass('cube');
			li.setStyles({
				'height': '0px',
				'border-width': '0px',
				'margin-top': '3px',
				'z-index': 100 - i,
				'background-color': this.colorselection

			});

			this.createMask(li, color0);

			li.store('fxh', new Fx.Tween(li, {
				duration: 400,
				transition: Fx.Transitions.quadIn
			}));
			li.store('fxpos', new Fx.Tween(li, {
				duration: 500,
				transition: Fx.Transitions.quadOut
			}));

			li.memolnk = li.getFirst().getProperty('href');
			li.getFirst().setProperty('href', 'javascript:void(0)');

			li.addEvent('mouseenter', function() {
				if ((li.mask != undefined) && (li.getFirst().hasClass('s') != true)) this.hideMask(li);
			}.bind(this));

			li.addEvent('mouseleave', function() {
				if ((li.mask != undefined) && (li.getFirst().hasClass('s') != true)) this.showMask(li);
			}.bind(this));

			li.addEvent('click', function() {
				this.openSelectedMenu(li, 'byclick');

			}.bind(this));

			i++;

			if (li.getFirst().hasClass('s') == true) {
				this.actualmenu = li.getParent();
				//console.log("li.getParent().fx: "+menu.retrieve('fx'));
				this.openSelectedMenu(li, 'byload');
			}

		},this);

	},

	openSelectedMenu: function(li, how) {

		li.getParent().retrieve('fx').set('padding-bottom',171);

		var i = 0;
		li.getParent().lis.each(function(li) {

			li.setStyles({
				'z-index': 100 - i,
				'height': '168px',
				'border-width': '3px',
				'margin-top': '0px'
			});
			i++;

		},this);

		li.setStyle('z-index', 101);

		if (li.getFirst().hasClass('s')) {

		} else {
			li.getFirst().addClass('s');
			this.tempoLink(null, li.memolnk);
		}

		li.getFirst().setStyle('background-color', 'transparent');

		li.retrieve('maskfx').set('opacity',0.5);

		if (this.actualmenu.isclosed == true) {
			this.halfOpenMenu(li.getParent());
			this.actualmenu.isallowedtoclick = true;
			li.getFirst().removeClass('s');
		} else {
			this.halfCloseMenu(li.getParent());
			this.actualmenu.isallowedtoclick = false;
		}

	},

	openMenu: function(menu) {
		if (!menu) return;
		
		if (this.actualmenu == menu) {
			this.closeMenu(this.actualmenu);
			return;
		};

		this.closeMenu(this.actualmenu);
		this.actualmenu = menu;

		if (menu.lis == undefined) return;

		//this.mainopak.opacity.stop();
		this.mainopak.retrieve('fxopacity').start('opacity',0.7);

		menu.lis.each(function(li) {
			//li.fxh.stop();
			li.retrieve('fxh').start('height',171);
			li.retrieve('fxpos').clearChain();
		},
		this);

		//menu.retrieve('fx').stop();
		menu.retrieve('fx').clearChain();

		menu.retrieve('fx').start('padding-bottom',171).chain(function() {

			menu.lis = menu.getElements('li');
			var i = 0;
			menu.lis.each(function(li) {

				//li.fxpos.stop();
				li.retrieve('fxpos').start('margin-left',i * 193);
				li.setStyles({
					'z-index': 100 - i,
					'height': '168px',
					'border-width': '3px',
					'margin-top': '0px'
				});
				i++;

			},
			this);

		});

	},

	closeMenu: function(menu) {

		//console.log("halfclose: "+menu);
		if (this.actualmenu == null) return;
		if (menu.retrieve('fx') == undefined) return;

		//this.mainopak.opacity.stop();
		this.mainopak.retrieve('fxopacity').start('opacity',0);

		//menu.fx.stop();
		menu.retrieve('fx').clearChain();

		menu.lis.each(function(li) {
			//li.fxpos.stop();
			li.retrieve('fxpos').start('margin-left',0).chain(function() {
				menu.retrieve('fx').start('padding-bottom',0);

				//li.fxh.stop();
				li.retrieve('fxh').start('height',0);

				li.setStyles({
					'border-width': '0px',
					'margin-top': '3px'
				});
			});

		},
		this);

		this.actualmenu = null;

	},

	halfOpenMenu: function(menu) {

		//console.log("halfopen: "+menu);
		if (this.actualmenu == null) return;

		//this.mainopak.opacity.stop();
		this.mainopak.fade(0.7);

		////menu.fx.stop();
		menu.retrieve('fx').clearChain();
		var i = 0;
		menu.lis.each(function(li) {

			//li.fxpos.stop();
			li.retrieve('fxpos').start('margin-left',193 * i);
			li.setStyles({
				'z-index': 100 - i,
				'height': '168px',
				'border-width': '3px',
				'margin-top': '0px'
			});

			if (li.hasClass('s')) {
				li.setStyle('z-index', 101);
				li.getFirst().addClass('s');
				li.getFirst().setStyle('background-color', 'transparent');
			}
			i++;

		},
		this);

		this.actualmenu = menu;
		this.actualmenu.isclosed = false;

	},

	halfCloseMenu: function(menu) {

		if (this.actualmenu == null) return;

		//this.mainopak.opacity.stop();
		this.mainopak.retrieve('fxopacity').start('opacity',0);

		////menu.fx.stop();
		//menu.fx.clearChain();
		//console.log("halfclose: "+menu);
		menu.lis.each(function(li) {
			if (li.retrieve('fxpos')) {
				//li.fxpos.stop();
				li.retrieve('fxpos').start('margin-left',0);
			}
		},
		this);

		this.actualmenu.isclosed = true;

	} //end methods

}); // end class Menu

//try to catch directly the color into the css ...////////////////////////
//console.log("stylesheet:: "+document.styleSheets+'::::');

/*document.getElementach(document.styleSheets, function(style){
			var rules = style.rules || style.cssRules;
			document.getElementach(rules, function(rule){
								  //console.log("rule.style: "+rule.style+'   '+'rule.selectorText: '+rule.selectorText);
								  if (rule.selectorText == '.s'){
								  	console.log("rule.style['background-color']: "+rule.style['background-color']);
								  }
				//if (!rule.selectorText.test('\.' + className + '$')) return;
				//Fx.CSS.Styles.each(function(style){
					
					// if (!rule.style || !rule.style[style]) return;
					// var ruleStyle = rule.style[style];
					// to[style] = (style.test(/color/i) && ruleStyle.test(/^rgb/)) ? ruleStyle.rgbToHex() : ruleStyle;
				//});
			});
		});*/

// floor cms detection : used to permit links when editing /////////////////
//if($('IFMainMenu') != false) {this.is_edited = true}
//else{this.is_edited = false};

/*openMenuForEdition: function(menu) {
		
		if (this.actualmenu == menu ) {
			//this.closeMenu(this.actualmenu);
			return;
		};	
		this.closeMenu(this.actualmenu);	
		this.actualmenu = menu;
		console.log("openMenuForEdition");
		if (menu.lis == undefined) return;
		menu.lis.each(function(li) {	
				li.fxh.stop();
				li.fxh.start(171);	
				li.fxpos.clearChain();
		}, this);
		//menu.fx.stop();
		menu.fx.clearChain();
		menu.fx.start(171).chain(function() {
			menu.lis = document.getElements('li', menu);
			var i = 0;
			menu.lis.each(function(li) {
				
				li.fxpos.stop();
				li.fxpos.start(i*193);
				li.setStyles({
							 'z-index': 100-i,
							 'height' : '168px',
							 'border-width' : '3px',
							 'margin-top' : '0px'
				});
				i++;	
			}, this);	
		});
	},*/

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

