window.addEvent('domready', function() {

	var test="";
	var list = $$('.toTopPage');

	list.each(function(element) {

		//var fx = new Fx.Styles(element, {duration:200, wait:false});
		var scroll = new Fx.Scroll(window, {
			wait: false,
			duration: 500,
			transition: Fx.Transitions.Quad.easeInOut
		});

		 element.addEvent('click', function(event) {
			event = new Event(event).stop();
  			scroll.toTop();
  		});
	});


	var list2 = $$('.titleScrollDown');
	
	list2.each(function(element) {
		
		var scroll2 = new Fx.Scroll(window, {
			wait: false,
			duration: 500,
			transition: Fx.Transitions.Quad.easeInOut
		});

		element.addEvent('click', function(event) {
			test = element.get('html');
			test = test.toLowerCase();
			test = test+'Scroll';
			test = test.replace(' ','');
			test = test.replace(' ','');
			test = test.replace(' ','');
			test = test.replace(' ','');
			event = new Event(event).stop();
			scroll2.toElement(test);
		});
	});

	if($('formAlreadyClient')) $('formAlreadyClient').addEvent('submit', function(e) {
		//Prevents the default submit event from loading a new page.
		e.stop();
		//Empty the log and show the spinning indicator.
		var log = $('log_res').empty().addClass('ajax-loading');
		//Set the options of the form's Request handler. 
		//("this" refers to the $('myForm') element).
		this.set('send', {onComplete: function(response) { 
			log.removeClass('ajax-loading');
			log.set('html', response);
		}});

		//Send the form.
		this.send();
	});
	
/*
	//gestion du click sur la case a cocher pour copier les informations de facturation
	if($('copyData')) $('copyData').addEvent('click', function(e) {

		//Prevents the default submit event from loading a new page.
		e.stop();

		//Empty the log and show the spinning indicator.
		$('lastname').value = $('lastname_bill').value;
		$('firstname').value = $('firstname_bill').value;
		$('address').value = $('address_bill').value;
		$('address2').value = $('address2_bill').value;
		$('zipcode').value = $('zipcode_bill').value;
		$('city').value = $('city_bill').value;
		$('zipcode').value = $('zipcode_bill').value;
		$('country').value = $('country_bill').value;
		$('telephone').value = $('telephone_bill').value;
	});
	*/

	//cache les menus au demarrage et chage l'opacité
	$('scroll1').setStyle('height', '0'); //The width is now 300px.
	$('scroll1').setStyle('visibility', 'hidden');
	$('scroll1').setOpacity(0.90); //The width is now 300px.
	
	$('scroll2').setStyle('height', '0'); //The width is now 300px.
	$('scroll2').setStyle('visibility', 'hidden');
	$('scroll2').setOpacity(0.90); //The width is now 300px.
	
	$('scroll3').setStyle('height', '0'); //The width is now 300px.
	$('scroll3').setStyle('visibility', 'hidden');
	$('scroll3').setOpacity(0.90); //The width is now 300px.
	
	$('scroll4').setStyle('height', '0'); //The width is now 300px.
	$('scroll4').setStyle('visibility', 'hidden');
	$('scroll4').setOpacity(0.90); //The width is now 300px.
	
	$('scroll5').setStyle('height', '0'); //The width is now 300px.
	$('scroll5').setStyle('visibility', 'hidden');
	$('scroll5').setOpacity(0.90); //The width is now 300px.
	
	$('scroll6').setStyle('height', '0'); //The width is now 300px.
	$('scroll6').setStyle('visibility', 'hidden');
	$('scroll6').setOpacity(0.90); //The width is now 300px.

	$('scroll7').setStyle('height', '0'); //The width is now 300px.
	$('scroll7').setStyle('visibility', 'hidden');
	$('scroll7').setOpacity(0.90); //The width is now 300px.	

	$('scroll8').setStyle('height', '0'); //The width is now 300px.
	$('scroll8').setStyle('visibility', 'hidden');
	$('scroll8').setOpacity(0.90); //The width is now 300px.	
	
	
	//ouvre le menu 1 lors du survol du scroller 1
	$('item1').addEvent('mouseover', function(e) {
		e.stop();
		$('scroll1').setStyle('visibility', 'visible');
		$('scroll1').setStyle('height', 480); //The width is now 300px.
		$('scroller1').setStyle('background-position', '0px -53px'); //The width is now 300px

		//ferme les autres menus
		$('scroll2').setStyle('height', 0); //The width is now 300px.
		$('scroll3').setStyle('height', 0); //The width is now 300px.
		$('scroll4').setStyle('height', 0); //The width is now 300px.
		$('scroll5').setStyle('height', 0); //The width is now 300px.
		$('scroll6').setStyle('height', 0); //The width is now 300px.
		$('scroll7').setStyle('height', 0); //The width is now 300px.
		$('scroll8').setStyle('height', 0); //The width is now 300px.
	});

	//ouvre le menu 2 lors du survol du scroller 2
	$('item2').addEvent('mouseover', function(e) {
		e.stop();
		$('scroll2').setStyle('visibility', 'visible');
		$('scroll2').setStyle('height', 480); //The width is now 300px.
		$('scroller2').setStyle('background-position', '-105px -53px'); //The width is now 300px

		//ferme les autres menus
		$('scroll1').setStyle('height', 0); //The width is now 300px.
		$('scroll3').setStyle('height', 0); //The width is now 300px.
		$('scroll4').setStyle('height', 0); //The width is now 300px.						
		$('scroll6').setStyle('height', 0); //The width is now 300px.
		$('scroll7').setStyle('height', 0); //The width is now 300px.
		$('scroll8').setStyle('height', 0); //The width is now 300px.			
	});

	//ouvre le menu 3 lors du survol du scroller 3
	$('item3').addEvent('mouseover', function(e) {
		e.stop();
		$('scroll3').setStyle('visibility', 'visible');
		$('scroll3').setStyle('height', 480); //The width is now 300px.
		$('scroller3').setStyle('background-position', '-209px -53px'); //The width is now 300px

		//ferme les autres menus
		$('scroll1').setStyle('height', 0); //The width is now 300px.
		$('scroll2').setStyle('height', 0); //The width is now 300px.
		$('scroll4').setStyle('height', 0); //The width is now 300px.			
		$('scroll6').setStyle('height', 0); //The width is now 300px.
		$('scroll7').setStyle('height', 0); //The width is now 300px.
	});

	//ouvre le menu 3 lors du survol du scroller 3
	$('item4').addEvent('mouseover', function(e) {
		e.stop();
		$('scroll4').setStyle('visibility', 'visible');
		$('scroll4').setStyle('height', 480); //The width is now 300px.
		$('scroller4').setStyle('background-position', '-402px -53px'); //The width is now 300px
	
		//ferme les autres menus
		$('scroll1').setStyle('height', 0); //The width is now 300px.
		$('scroll2').setStyle('height', 0); //The width is now 300px.
		$('scroll3').setStyle('height', 0); //The width is now 300px.
		$('scroll6').setStyle('height', 0); //The width is now 300px.
		$('scroll7').setStyle('height', 0); //The width is now 300px.
	});

	//ouvre le menu 3 lors du survol du scroller 3
	$('item5').addEvent('mouseover', function(e) {
		e.stop();
		$('scroll5').setStyle('visibility', 'visible');
		$('scroll5').setStyle('height', 480); //The width is now 300px.
		$('scroller5').setStyle('background-position', '-471px -53px'); //The width is now 300px

		//ferme les autres menus
		$('scroll1').setStyle('height', 0); //The width is now 300px.
		$('scroll2').setStyle('height', 0); //The width is now 300px.
		$('scroll3').setStyle('height', 0); //The width is now 300px.
		$('scroll4').setStyle('height', 0); //The width is now 300px.			
		$('scroll6').setStyle('height', 0); //The width is now 300px.
		$('scroll7').setStyle('height', 0); //The width is now 300px.
		$('scroll8').setStyle('height', 0); //The width is now 300px.
	});

	//ouvre le menu 3 lors du survol du scroller 3
	$('item6').addEvent('mouseover', function(e) {
		e.stop();
		$('scroll6').setStyle('visibility', 'visible');
		$('scroll6').setStyle('height', 480); //The width is now 300px.
		$('scroller6').setStyle('background-position', '-611px -53px'); //The width is now 300px

		//ferme les autres menus
		$('scroll1').setStyle('height', 0); //The width is now 300px.
		$('scroll2').setStyle('height', 0); //The width is now 300px.
		$('scroll3').setStyle('height', 0); //The width is now 300px.
		$('scroll4').setStyle('height', 0); //The width is now 300px.			
		$('scroll7').setStyle('height', 0); //The width is now 300px.
		$('scroll8').setStyle('height', 0); //The width is now 300px.			
	});

	//ouvre le menu 3 lors du survol du scroller 3
	$('item7').addEvent('mouseover', function(e) {
		e.stop();
		$('scroll7').setStyle('visibility', 'visible');
		$('scroll7').setStyle('height', 480); //The width is now 300px.
		$('scroller7').setStyle('background-position', '-730px -53px'); //The width is now 300px

		//ferme les autres menus
		$('scroll1').setStyle('height', 0); //The width is now 300px.
		$('scroll2').setStyle('height', 0); //The width is now 300px.
		$('scroll3').setStyle('height', 0); //The width is now 300px.
		$('scroll4').setStyle('height', 0); //The width is now 300px.			
		$('scroll6').setStyle('height', 0); //The width is now 300px.
		$('scroll8').setStyle('height', 0); //The width is now 300px.
	});

	$('item8').addEvent('mouseover', function(e) {
		e.stop();
		$('scroll8').setStyle('visibility', 'visible');
		$('scroll8').setStyle('height', 480); //The width is now 300px.
		$('scroller8').setStyle('background-position', '-788px -53px'); //The width is now 300px

		//ferme les autres menus
		$('scroll1').setStyle('height', 0); //The width is now 300px.
		$('scroll2').setStyle('height', 0); //The width is now 300px.
		$('scroll3').setStyle('height', 0); //The width is now 300px.
		$('scroll4').setStyle('height', 0); //The width is now 300px.			
		$('scroll6').setStyle('height', 0); //The width is now 300px.
		$('scroll7').setStyle('height', 0); //The width is now 300px.
	});


	//ferme les menu lors des sorties
	$('item1').addEvent('mouseout', function(e) {
		e.stop();
		$('scroll1').setStyle('height', 0); //The width is now 300px.
		$('scroll1').setStyle('visibility', 'hidden');
		$('scroller1').setStyle('background-position', '-0px 0px'); //The width is now 300px
	});

	$('item2').addEvent('mouseout', function(e) {
		e.stop();
		$('scroll2').setStyle('visibility', 'hidden');
		$('scroll2').setStyle('height', 0); //The width is now 300px.
		$('scroller2').setStyle('background-position', '-105px 0px'); //The width is now 300px
	});

	$('item3').addEvent('mouseout', function(e) {
		e.stop();
		$('scroll3').setStyle('visibility', 'hidden');
		$('scroll3').setStyle('height', 0); //The width is now 300px.
		$('scroller3').setStyle('background-position', '-209px 0px'); //The width is now 300px
	});

	$('item4').addEvent('mouseout', function(e) {
		e.stop();
		$('scroll4').setStyle('visibility', 'hidden');
		$('scroll4').setStyle('height', 0); //The width is now 300px.
		$('scroller4').setStyle('background-position', '-402px 0px'); //The width is now 300px
	});

	$('item5').addEvent('mouseout', function(e) {
		e.stop();
		$('scroll5').setStyle('visibility', 'hidden');
		$('scroll5').setStyle('height', 0); //The width is now 300px.
		$('scroller5').setStyle('background-position', '-471px 0px'); //The width is now 300px
	});	

	$('item6').addEvent('mouseout', function(e) {
		e.stop();
		$('scroll6').setStyle('visibility', 'hidden');
		$('scroll6').setStyle('height', 0); //The width is now 300px.
		$('scroller6').setStyle('background-position', '-611px 0px'); //The width is now 300px
	});	

	$('item7').addEvent('mouseout', function(e) {
		e.stop();
		$('scroll7').setStyle('visibility', 'hidden');
		$('scroll7').setStyle('height', 0); //The width is now 300px.
		$('scroller7').setStyle('background-position', '-730px 0px'); //The width is now 300px
	});	

	$('item8').addEvent('mouseout', function(e) {	
		e.stop();
		$('scroll8').setStyle('visibility', 'hidden');
		$('scroll8').setStyle('height', 0); //The width is now 300px.
		$('scroller8').setStyle('background-position', '-788px 0px'); //The width is now 300px
	});	

});
