window.addEvent('domready', function(){
	MOOdalBox.init({resizeDuration: 200, evalScripts: true, evalResponse: true});
	//return; // XL : below scripts crashed => to be investigated...

	var mouseMove = $('mousemove');

	if (mouseMove != null) {
		var scroll2 = new Scroller('mousemove', {area: 170, velocity: .03});

		// Mousemove
		// $('mousemove').addEvent('mouseover', scroll2.start());
		// $('mousemove').addEvent('mouseout', scroll2.stop());
	
		mouseMove.addEvent('mousedown', function() {
			scroll2.start();
		});
		mouseMove.addEvent('mouseup', function() {
			scroll2.stop();
		});
	
		scroll2.start();
	}

	var clicked = false;
	var fader;

	$$('.bloc-enlight').each(function(e){
		/*
		var fade = new Fx.Style(e, 'opacity', {wait:false, duration: 100});
		fade.set(.5); /* .001 (not .0)) so the element stays visible and is still able to be mouse-entered * /
		*/
		e.fade(.5);
		
		e.addEvent('mouseover', function() {
			if ( fader && this.id != clicked ) {
				e.fade(1);
			}
			/*
			if ( fade ) fade.start(1);
			else {
				if ( fader && this.id != clicked ) {
					fade = new Fx.Style(e, 'opacity', {wait:false, duration: 100});
					fade.start(1);
				}
			}
			*/
		});
		e.addEvent('mouseout', function() {
			if ( fader && this.id != clicked ) {
				e.fade(.5);
			}
			/*
			if ( fade ) fade.start(.5);
			else {
				if ( fader && this.id != clicked ) {
					fade = new Fx.Style(e, 'opacity', {wait:false, duration: 100});
					fade.start(.5);
				}
			}
			*/
		});
		e.addEvent('click', function() {
			if ( clicked && clicked != false && this.id != clicked ) {
				e.fade(.5);
			}
			if ( $(this.id) ) {
				e.fade(1);
				
				$(this.id).removeClass('bloc-enlight');
								
				fader		= true;
				if ( clicked ) {
					$(clicked).fade(.5);
				}
				
				clicked	= this.id;
				
				
				fade = null;
				/* alert("Adresse : " + clicked + " choisie"); */
				$('orderaddr').value = clicked;
				return;
			}
			/* 
			if ( clicked && clicked != false && this.id != clicked ) {
				fader.set(.5);
			}
			if ( $(this.id) && fade ) {
				fade.start(1);
				
				$(this.id).removeClass('bloc-enlight');
								
				fader		= fade;
				clicked	= this.id;
				
				fade = null;
				/* alert("Adresse : " + clicked + " choisie"); * /
				$('orderaddr').value = clicked;
				return;
			}
			*/
		});
		e.addEvent('dblclick', function(){
			if ( clicked && clicked != false ) {
				$(this.id).addClass('bloc-enlight');
				e.fade(.5);
				
				clicked = false;
				/*
				$(this.id).addClass('bloc-enlight');
				fade = new Fx.Style(e, 'opacity', {wait:false, duration: 100});
				fade.set(.5);
				
				clicked = false;
				*/
			}
				
		});
		
	});
	
	if ( $('mb_close_link') ) {
		$('mb_close_link').addEvent("click", function(event) {
			document.location.reload();
		});
	}
	
	if ( $('payment_bycheck') ) {
		/*
		$('payment_bycheck').addEvent('mouseover', function() {
			$('payment_bycheck_valid').style.display = 'block';
		});
		$('payment_bycheck').addEvent('mouseout', function() {
			$('payment_bycheck_valid').style.display = 'none';
		});
		*/
		var mySlide = new Fx.Slide($('payment_bycheck_valid'), {wait: false});
	
		$('vbank_valid').addEvent('mouseover', function(e){
			e = new Event(e);
			mySlide.slideIn();
			e.stop();
		});
		$('payment_bycheck').addEvent('mouseover', function(e){
			e = new Event(e);
			mySlide.slideIn();
			e.stop();
		});
		$('payment_bycheck').addEvent('mouseout', function(e){
			e = new Event(e);
			mySlide.slideOut();
			e.stop();
		});
		
		
		$('payment_bycard').addEvent('mouseover', function(){
			$('payment_bycard').style.background = "#eee";
		});
		$('payment_bycard').addEvent('mouseout', function(){
			$('payment_bycard').style.background = "#fff";
		});
		
		mySlide.hide();
	}
	
	
	/* alert( $$('.bloc-enlight').length ); */
	// alert($$('.bloc-enlight')[0].id);
	
	
});