function del( Obj ) {
	var label = ( Obj.title ) ? Obj.title : 'Etes vous sûr de vouloir supprimer cet élément ?';
	return confirm( label );	
}

function popup( href, name, h, l ) {
	var hauteur = Math.round( ( screen.availHeight - h ) / 2 );
	var largeur = Math.round( ( screen.availWidth - l ) / 2 );
	var popup = window.open( href, name, 'toolbar=0,location=0,directories=0,status=0, scrollbars=1,resizable=1,menubar=0,top='+hauteur+',left='+largeur+',width='+l+',height='+h);
	popup.focus();
	return false;	
}

function popupOrder( Obj ) {
	return popup( Obj.href, 'order', 600, 580 );
}

function popupArticle( Obj ) {
	return popup( Obj.href, 'article', 600, 800 );
}

var Registration = new Class({
    initialize: function(){
		this.statusPro = $('status_1');
		this.statusPart = $('status_2');
		if( !this.statusPro || !this.statusPart ){
			return;
		}
		
		this.statusPro.addEvent( 'click', function(){ this.toogle() }.bind(this) );
		this.statusPart.addEvent( 'click', function(){ this.toogle() }.bind(this) );
		
		if( !this.statusPart.getProperty('checked') && !this.statusPro.getProperty('checked') ){
			this.statusPart.setProperty('checked', 'checked' );
		}
		
		this.toogle();
    },
	
	toogle: function(){
		if( this.statusPro.getProperty('checked') ){
			$$('.professional').each(function( element ){
				var fx = new Fx.Styles(element, {duration:300, wait:false});
				fx.start({
					'opacity': 1,
					'height': 22,
					'margin-top': 5
				});
				
				
			});
		} else {
			$$('.professional').each(function( element ){
				var fx = new Fx.Styles(element, {duration:300, wait:false});
				fx.start({
					'opacity': 0,
					'height': 0,
					'margin-top': 0
				});
			});
		}
	}
});

function registration() {
	var reg = new Registration();
}
window.addEvent('domready', registration);

function tips() {	
	var tips = new Tips($$('.tips'), {
		initialize: function(){
			this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 200, wait: false}).set(0);
		},
		onShow: function(toolTip) {
			this.fx.start(1);
		},
		onHide: function(toolTip) {
			this.fx.start(0);
		}
	});
	
	if( $('cetelem') ) {
		var cetelem = new Tips($$('#cetelem p'), {
			fixed: true, 
			className: 'cetelem',
			offsets: { x: 0, y: 42 },
			initialize: function(){
				this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 200, wait: false}).set(0);
			},
			onShow: function(toolTip) {
				this.fx.start(1);
			},
			onHide: function(toolTip) {
				this.fx.start(0);
			}
		});
	}
}
window.addEvent('domready', tips);

function cgv() {
	cgv = $('cgv');
	
	if(cgv){
		var slideInd = new Fx.Slide('cgvIndividual', {'duration': 400, 'transition': Fx.Transitions.Expo.easeInOut, 'wait': false});
		var slidePro = new Fx.Slide('cgvProfessional', {'duration': 400, 'transition': Fx.Transitions.Expo.easeInOut, 'wait': false});

		slideInd.hide();
		slidePro.hide();
		
		$('linkCgvIndividual').removeProperty('href').addEvent('click', function(e){
			e = new Event(e);
			slidePro.slideOut();
			slideInd.slideIn();
			e.stop();
		});
		$('linkCgvProfessional').removeProperty('href').addEvent('click', function(e){
			e = new Event(e);
			slideInd.slideOut();
			slidePro.slideIn();
			e.stop();
		});
	}
}
window.addEvent('domready', cgv);