
var Registration = new Class({
    initialize: function(){
	
		this.onglet1 = $('onglet1');
		this.onglet2 = $('onglet2');
		this.onglet3 = $('onglet3');
		this.onglet4 = $('onglet4');
		this.onglet5 = $('onglet5');
		
		if( !this.onglet1 || !this.onglet2  || !this.onglet3 || !this.onglet4 || !this.onglet5)
		{
			return;
		}
		this.onglet1.addEvent( 'click', function(){ this.toogle('o1') }.bind(this) );	
		this.onglet2.addEvent( 'click', function(){ this.toogle('o2') }.bind(this) );
		this.onglet3.addEvent( 'click', function(){ this.toogle('o3') }.bind(this) );
		this.onglet4.addEvent( 'click', function(){ this.toogle('o4') }.bind(this) );
		this.onglet5.addEvent( 'click', function(){ this.toogle('o5') }.bind(this) );
		
		if( $('lienautresphotos') ){
			this.lienautresphotos = $('lienautresphotos');
		this.lienautresphotos.addEvent( 'click', function(){ this.toogle('o5') }.bind(this) );
		}
		if( $('imagesautresphotos') ){
		this.imagesautresphotos = $('imagesautresphotos');
		this.imagesautresphotos.addEvent( 'click', function(){ this.toogle('o5') }.bind(this) );
		}

		this.toogle();
    },
	
	toogle: function(o){
	
		function show(elt)
		{
			$$(elt).setStyle( 'display', 'block' );
			$$(elt).each(function( element ){
						var fx = new Fx.Styles(element, {duration:10, wait:false});
						fx.start({
							'opacity': 1,
							'margin-top': 0
						});
					});
		}

		function hide(elt)
		{
			$$(elt).setStyle( 'display', 'none' );
			$$(elt).each(function( element ){
						var fx = new Fx.Styles(element, {duration:10, wait:false});
						fx.start({
							'opacity': 0,
							'margin-top': 0,
							'padding': 0
						});
					});
		}
									
	// affichage par defaut
	if(o == null || o == '')
	{
		o = 'o1';		
	}

	if( o == 'o1' )
	{
		show('#ongletdescription');
		hide('#ongletcarnet');
		hide('#ongletgalerie');
		hide('#onglettarif');
		hide('#ongletinfos');
		
		// update id pour changer de couleur
		if( $('lionglet1_off') ){ $('lionglet1_off').setProperty( 'id', 'lionglet1_on' );}
		
		// on ferme les autres
		if( $('lionglet2_on') ){ $('lionglet2_on').setProperty( 'id', 'lionglet2_off' );}
		if( $('lionglet3_on') ){ $('lionglet3_on').setProperty( 'id', 'lionglet3_off' );}
		if( $('lionglet4_on') ){ $('lionglet4_on').setProperty( 'id', 'lionglet4_off' );}
		if( $('lionglet5_on') ){ $('lionglet5_on').setProperty( 'id', 'lionglet5_off' );}
	}
	else if( o == 'o2' )
	{
		hide('#ongletdescription');
		show('#ongletcarnet');
		hide('#ongletgalerie');
		hide('#onglettarif');
		hide('#ongletinfos');
		
		// update id pour changer de couleur
		if( $('lionglet2_off') ){ $('lionglet2_off').setProperty( 'id', 'lionglet2_on' );}
		
		// on ferme les autres
		if( $('lionglet1_on') ){ $('lionglet1_on').setProperty( 'id', 'lionglet1_off' ); }
		if( $('lionglet3_on') ){ $('lionglet3_on').setProperty( 'id', 'lionglet3_off' ); }
		if( $('lionglet4_on') ){ $('lionglet4_on').setProperty( 'id', 'lionglet4_off' );}
		if( $('lionglet5_on') ){ $('lionglet5_on').setProperty( 'id', 'lionglet5_off' );}
		
	}
	else if( o == 'o3' )
	{
		hide('#ongletdescription');
		hide('#ongletcarnet');
		show('#ongletinfos');
		hide('#onglettarif');
		hide('#ongletgalerie');
		
		// update id pour changer de couleur
		if( $('lionglet3_off') ){$('lionglet3_off').setProperty( 'id', 'lionglet3_on' );}
		
		// on ferme les autres
		if( $('lionglet1_on') ){$('lionglet1_on').setProperty( 'id', 'lionglet1_off' );	}
		if( $('lionglet2_on') ){$('lionglet2_on').setProperty( 'id', 'lionglet2_off' );	}
		if( $('lionglet4_on') ){$('lionglet4_on').setProperty( 'id', 'lionglet4_off' );	}
		if( $('lionglet5_on') ){$('lionglet5_on').setProperty( 'id', 'lionglet5_off' );	}
			

	

	}else if( o == 'o4' )
	{
	
		hide('#ongletdescription');
		hide('#ongletcarnet');
		hide('#ongletgalerie');
		show('#onglettarif');
		hide('#ongletinfos');
		
		// update id pour changer de couleur
		if( $('lionglet4_off') ){$('lionglet4_off').setProperty( 'id', 'lionglet4_on' );}
		
		// on ferme les autres
		if( $('lionglet1_on') ){$('lionglet1_on').setProperty( 'id', 'lionglet1_off' );	}
		if( $('lionglet2_on') ){$('lionglet2_on').setProperty( 'id', 'lionglet2_off' );	}
		if( $('lionglet3_on') ){$('lionglet3_on').setProperty( 'id', 'lionglet3_off' );	}
		if( $('lionglet5_on') ){$('lionglet5_on').setProperty( 'id', 'lionglet5_off' );	}
			
	}
	else if( o == 'o5' )
	{
		hide('#ongletdescription');
		hide('#ongletcarnet');
		hide('#ongletinfos');
		hide('#onglettarif');
		show('#ongletgalerie');
		
		// update id pour changer de couleur
		if( $('lionglet5_off') ){$('lionglet5_off').setProperty( 'id', 'lionglet5_on' );}
		
		// on ferme les autres
		if( $('lionglet1_on') ){$('lionglet1_on').setProperty( 'id', 'lionglet1_off' );	}
		if( $('lionglet2_on') ){$('lionglet2_on').setProperty( 'id', 'lionglet2_off' );	}
		if( $('lionglet3_on') ){$('lionglet3_on').setProperty( 'id', 'lionglet3_off' );	}
		if( $('lionglet4_on') ){$('lionglet4_on').setProperty( 'id', 'lionglet4_off' );	}
			// GALERIE PHOTO
		function initProduct(){

			if($('ongletgalerie') && $('productImage'))
			{
				var productImage = $('productImage');
				
				var fx = new Fx.Style( productImage, 'opacity', { duration: 80, transition:Fx.Transitions.Circ.easeOut, wait: false } );
				var first = false;

				$$('#ongletgalerie a[rel=imageshow]').each(function(el)
				{
					if( first == false ){
						//el.getParent().setStyle( 'display', 'none' );
						first = true;
					}
					el.addEvent('click', function( e ){
						var e = new Event(e);
						fx.start( 0 ).chain(function(){
							productImage.empty();
							var img = new Asset.image( el.getProperty('href'), { onload: function(){ 
								fx.start( 1 );
								$$('.liste_images p.img').each(function(elMin){
							
									elMin.setStyle( 'display', '' );
								});
								el.getParent().setStyle( 'display', '' );
							} } ).injectInside( productImage );
							if( el.getProperty('title') ){
								var p = new Element('p').setText( el.getProperty('title') ).injectAfter( img );
							}
						});
						e.stop();
					});
				});
				
			}
			
		}
		window.addEvent('domready', initProduct);
			
	}
	
	
	

	}
});

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