	var layer = 2;
	var n_layer = 0;
	var save_el;
	var max_size = 1680;
	var min_size = 950;
	var max_height = 1050;
	var margins = null;
	var margins2 = 0;
	
	window.addEvent('domready', function() {
		redim();
		$('text_1x0_n0').fade('hide');
		$('text_2x0_n0').fade('hide');
		$('text_3x0_n0').fade('hide');
		fondu_layer()	
		

		$('btn_0_n0').addEvent('click', function(el) {
			if($('text_0x0_n0').getStyle('visibility')!='hidden') show_niv0b('0-presentation/0-actualites')
			if($('text_1x0_n0').getStyle('visibility')!='hidden') show_niv0b('1-locations/0-choisir-sa-roulotte')
			if($('text_2x0_n0').getStyle('visibility')!='hidden') show_niv0b('2-vente-aux-particuliers/0-que-faisons-nous')
			if($('text_3x0_n0').getStyle('visibility')!='hidden') show_niv0b('3-vente-aux-professionnels/0-que-faisons-nous')
		});
		
		$('text_0').addEvent('click', function(el) {
			show_niv0b('0-presentation/0-actualites')
		 });
		$('text_1').addEvent('click', function(el) {
			 show_niv0b('1-locations/0-choisir-sa-roulotte')
		 });
		$('text_2').addEvent('click', function(el) {
			show_niv0b('2-vente-aux-particuliers/0-que-faisons-nous')
		 });
		$('text_3').addEvent('click', function(el) {
			show_niv0b('3-vente-aux-professionnels/0-que-faisons-nous')
		 });
		

		$$('.menu').each(function(el) {						  
			el.addEvent('mouseenter', function(el) {
				save_el = this
				$$('.menu').each(function(el) {
					if(el!=save_el){
					el.fade('0.25');					  
					}
				});	
			});		
			el.addEvent('mouseleave', function(el) {	
				save_el = this
				$$('.menu').each(function(el) {
					if(el!=save_el){
						el.fade('1.00');					  
					}
				});	
			});	
			
									  
			el.addEvent('click', function(el) {									  
				$$('.menu').each(function(el) {
					if(el.getStyle('width')=='0px'){
						save_el = el
					}
				});		
				l = this.getSize()
				n_layer = this.id.substr(5,1)
				var myEffect = new Fx.Morph(save_el,{duration: 1000,onComplete:function(){click2();}},{transition: Fx.Transitions.linear} );
				var myEffect2 = new Fx.Morph(this,{duration: 1000},{transition: Fx.Transitions.linear} );
				myEffect.start({
								'width': l.x+'px'
								});			  
				myEffect2.start({
								'width': '0px'
								});	
			});					
		});	
		$('main').fade('hide');
		$('main').setStyle('display','');
		$('main_load').fade('show')
		images = new Array();
		$$('img').each(function(element){
			images.include(element.getProperty('src'));
		}); 		
		new Asset.images(images, {
			onload: function(){},
			onComplete: function(){
				redim()
				$('main').fade('1.00');
				$('main_load').fade('0.00')  // et on cache le texte de chargement  
			}
		});
		
	});	
	function click2(){
		scrolling()
				
		for(i=0;i<=n_layer;i++){
			$('text_'+i+'x0_n0').fade('1')
		}
		for(i=1+1*n_layer;i<5;i++){
			if($('text_'+i+'x0_n0')) $('text_'+i+'x0_n0').fade('0')
		}
	}
	window.addEvent('resize', function() {
		//window.location.href= 'index.php';
		redim()
	});	
	
	function redim(){
		window.addEvent('domready', function() {
			size = document.getSize();
			largeur = parseInt(size.x);
			if(size.x>max_size) largeur = max_size;
			if(size.x<min_size) largeur = min_size;
			margins = parseInt((size.x-largeur)/2);
			hauteur = size.y
			margins2 = (hauteur-max_height)/2			
			if(margins2<0) margins2=0
			if(hauteur > max_height) hauteur = max_height
			hauteur -= 40
			ligne = parseInt(hauteur / 2)
			cellule_gauche = parseInt(ligne/5*6)
			h_colonne_right = hauteur/2		
			$('main_load').setStyles({'left':size.x/2-200,'top':size.y/3});
			$('cadre_gauche').setStyles({
				'width':cellule_gauche+'px',
				'height':hauteur+'px'
			});
			$('cadre_droite').setStyles({
				'width':(largeur-cellule_gauche)+'px',
				'height':hauteur+'px'
			});
			$('logo').setStyles({
				'width':cellule_gauche+'px',
				'height':Math.ceil(h_colonne_right+3)+'px'
			});
			$('slide_pic').setStyles({
				'width':cellule_gauche+'px',
				'height':Math.floor(h_colonne_right-3)+'px'
			});
			
			$('layer_1').setStyles({
								   'height':ligne+'px',
								   'top':-(n_layer*ligne)+'px'
								   });
			$('layer_2').setStyles({
								   'height':ligne+'px',
								   'top':-(n_layer*ligne)+'px'
											 })
			$('main').setStyle('width',largeur+'px')
			// MENU
			l_colonne_right = (largeur-cellule_gauche)
			$('menu_n0').setStyles({
									'width':l_colonne_right+'px',
									'height':Math.ceil(h_colonne_right+3)+'px'
								   })
			
			// TEXTE
			
			$('cadre_texte_n0').setStyles({
											'width':l_colonne_right+'px',
											'height':Math.floor(h_colonne_right-3)+'px'
										  })
			x_btn = parseInt(size.x/1600*175)
			y_btn = parseInt(x_btn/223*296)
			$('btn_0_n0').setStyles({
									'width':x_btn+'px',
									'left':(largeur-x_btn+margins)+'px',
									'top':(hauteur-y_btn+margins2)+'px'
									})		
			$('text_0x0_n0').setStyles({
									   'width':l_colonne_right+'px',
									   'height':h_colonne_right+'px',
									   'background-position':'right -'+h_colonne_right+'px',
									   'top':'0px'
									   });
			$('text_1x0_n0').setStyles({
									   'width':l_colonne_right+'px',
									   'height':h_colonne_right+'px',
									   'background-position':'right -'+h_colonne_right+'px',
									   'top':-h_colonne_right+'px'
									   });
			$('text_2x0_n0').setStyles({
									   'width':l_colonne_right+'px',
									   'height':h_colonne_right+'px',
									   'background-position':'right -'+h_colonne_right+'px',
									   'top':-2*h_colonne_right+'px'
									   });
			$('text_3x0_n0').setStyles({
									   'width':l_colonne_right+'px',
									   'height':h_colonne_right+'px',
									   'background-position':'right -'+h_colonne_right+'px',
									   'top':-3*h_colonne_right+'px'
									   });
			// TEXTE GENERAL
			$('main').setStyle('font-size',parseInt(size.x/1600*12)+'px')
			$('table_m0').setStyle('font-size',parseInt(size.x/1600*12)+'px')
			$$('.text_n0').setStyle('font-size',parseInt(size.x/1600*24)+'px')
		
			// BOUTONS IMAGE
			size = document.getSize()	
			largeur = size.x;
			if(size.x>max_size) largeur = max_size;
			
			h_colonnes = parseInt(size.y-40)
			unites = parseInt(h_colonnes/20*12)
			l_colonne_right = parseInt(largeur-unites)-2
			
			if($('menu_0').getStyle('width')!='0px') $('menu_0').setStyles({
									   'width':parseInt(l_colonne_right/3-8)+'px'
											});
			if($('menu_1').getStyle('width')!='0px') $('menu_1').setStyles({
									   'width':parseInt(l_colonne_right/3-8)+'px'
											});
			if($('menu_2').getStyle('width')!='0px') $('menu_2').setStyles({
									   'width':parseInt(l_colonne_right/3-8)+'px'
											});
			if($('menu_3').getStyle('width')!='0px') $('menu_3').setStyles({
									   'width':parseInt(l_colonne_right/3-8)+'px'
											});
			//alert(margins2)
			$('main').setStyle('margin-top',margins2)
		});	
	}
	
	function fondu_layer(){
		myEffect = new Fx.Morph('layer_2',{duration: 10000, fps: 10, onComplete: function(){fondu_layer_2();}},{transition: Fx.Transitions.linear} );
		myEffect.start({
										'opacity':'0.0'
										});	
		
	}	
	function fondu_layer_2(){
		myEffect = new Fx.Morph('layer_2',{duration: 10000, fps: 10, onComplete: function(){fondu_layer();}},{transition: Fx.Transitions.linear} );
		myEffect.start({
										'opacity':'1.0'
										});			
	}	

	function scrolling(){
		
		size = document.getSize();
		hauteur = size.y-40
		ligne = parseInt(hauteur / 2)
			
		$('layer_1').tween('top',-(n_layer*ligne)+'px')
		$('layer_2').tween('top',-(n_layer*ligne)+'px')
	}


	function show_niv0(el){
		var myEffect = new Fx.Morph($('main'),{duration: 1000,onComplete:function(){window.location.href= el+'.html';  }},{transition: Fx.Transitions.linear} );
		myEffect.start({
						'opacity':'0.0'
						});			  
  
	}
	
	function show_niv0b(el){
		var myEffect = new Fx.Morph($('main'),{duration: 1000,onComplete:function(){window.location.href= el;  }},{transition: Fx.Transitions.linear} );
		myEffect.start({
						'opacity':'0.0'
						});			  
  
	}	