// -----------------------------------------------------------------------------------
//
//	Lightbox v2.04
//	by Lokesh Dhakar - http://www.lokeshdhakar.com
//	Last Modification: 2/9/08
//
//	For more information, visit:
//	http://lokeshdhakar.com/projects/lightbox2/
//
//	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
//  	- Free for use in both personal and commercial projects
//		- Attribution requires leaving author name, author link, and the license info intact.
//	
//  Thanks: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.com), and Thomas Fuchs(mir.aculo.us) for ideas, libs, and snippets.
//  		Artemy Tregubenko (arty.name) for cleanup and help in updating to latest ver of proto-aculous.
//
// -----------------------------------------------------------------------------------
//  Used and modified by C-ROM : http://c-rom.com : alexishuet@c-rom.com
// -----------------------------------------------------------------------------------
//
//  Configurationl
//
LightboxOptions = Object.extend({
    fileLoadingBox:        'images/loading.gif',     
	
    fileBottomNavCloseBox: 'images/closelabel.gif',

    overlayOpacity: 0.8,   // controls transparency of shadow overlay

    animate: true,         // toggles resizing animations
	
    resizeSpeed: 10,        // controls the speed of the box resizing animations (1=slowest and 10=fastest)

    borderSize: 10,         //if you adjust the padding in the CSS, you will need to update this variable
	
	main: 'site',
	
	conteneur: 'lightbox',
	
	conteneurBox: 'outerBoxContainer',
	
	headerbox: 'logo',
	
	flashBox: 'flashBox',
	
	flash: false,
	
	imageBox: 'imageBox',
	
	vignetteBox: 'vignetteBox',
	
	tellAFriendBox: 'tellAFriend',
	
	sendToAFriendBox: 'envoyerAUnAmi',
	
	borderSize: 0,
	
	vignettesOuvertes: false,
	
	vignetteOuverte: false,
	
	image: false,
	
	menu: false,
	
	numeroParfum: 1,
	
	itemSelect: false,
	
	loadingBox: 'loading',
	
	centreGaucheBox: 'centreGauche',
	
	centreBox: 'centre',
	
	centreDroitBox: 'centreDroit',
	
	menuGaucheBox: 'menuGauche',
	
	lienHomeBox: 'lienHome',
	
	logoBox: 'logoDroit',
	
	logo: false,
	
	texteBox: 'texteDroit',
	
	texte: false,
	
	logoTexteDroitBox: 'logoTexteDroit',
	
	parfumCharge: false,
	
	fonduBasBox: 'fondu_bas',
	
	fonduBasGaucheBox: 'fondu_bas_gauche',
	
	fonduBasDroitBox: 'fondu_bas_droit',	

	// When grouping boxs this is used to write: Box # of #.
	// Change it for non-english localization
	labelBox: "Box",
	labelOf: "of"
}, window.LightboxOptions || {});

// -----------------------------------------------------------------------------------

var Lightbox = Class.create();

Lightbox.prototype = {
    activeBox: undefined,
    
    // initialize()
    // Constructor runs on completion of the DOM loading. Calls updateBoxList and then
    // the function inserts html at the bottom of the page which is used to display the shadow 
    // overlay and the box container.
    //
    initialize: function() {    

        if (LightboxOptions.resizeSpeed > 10) LightboxOptions.resizeSpeed = 10;
        if (LightboxOptions.resizeSpeed < 1)  LightboxOptions.resizeSpeed = 1;

	    this.resizeDuration = LightboxOptions.animate ? ((11 - LightboxOptions.resizeSpeed) * 0.20) : 0;
		this.appearDuration = LightboxOptions.animate ? ((11 - LightboxOptions.resizeSpeed) * 0.20)*2 : 0;
		this.disappearDuration = LightboxOptions.animate ? ((11 - LightboxOptions.resizeSpeed) * 0.20)*1.5 : 0;
	    this.overlayDuration = LightboxOptions.animate ? 0.2 : 0;  // shadow fade in/out duration

        // When Lightbox starts it will resize itself from 250 by 250 to the current box dimension.
        // If animations are turned off, it will be hidden as to prevent a flicker of a
        // white 250 by 250 box.
        var size = (LightboxOptions.animate ? 250 : 1) + 'px';
    },

    
    //
    //  start()
    //  Display overlay and lightbox. If box is part of a set, add siblings to boxArray.
    //
    start: function(boxLink) {    

        //$$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' });

        // stretch overlay to fill page and fade in
        var arrayPageSize = this.getPageSize();

        // calculate top and left offset for the lightbox 
        var arrayPageScroll = document.viewport.getScrollOffsets();
        var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 10);
        var lightboxLeft = arrayPageScroll[0];
        this.lightbox.setStyle({ top: lightboxTop + 'px', left: lightboxLeft + 'px' }).show();
        
    },

    //
    //  resizeBoxContainer()
    //
    resizeBox: function(boxWidth, boxHeight, box, vignettes) {

		//Cacher les dernieres selections
		this.unload();
		
		//Afficher loader
		$(LightboxOptions.loadingBox).show() ;	

		// get current width and height
		var arrayPageSize = this.getPageSize() ;
		var reg=new RegExp("px", "g");
		widthMax = arrayPageSize[0] ;/*$(LightboxOptions.main).getStyle('width').replace(reg, "")-200;*/
		heightMax = arrayPageSize[1] ;/*$(LightboxOptions.main).getStyle('height').replace(reg, "")-240;*/

		// get current width and height
		var widthCurrent  = $(LightboxOptions.conteneurBox).getWidth();
		var heightCurrent = $(LightboxOptions.conteneurBox).getHeight();

		// get new width and height
		var widthNew  = (boxWidth);
		var heightNew = (boxHeight);
		//if(widthNew>widthMax) widthNew = widthMax ;
		//if(heightNew>heightMax) heightNew = heightMax ;		

		// scalars based on change from old to new
		var xScale = (widthNew  / widthCurrent)  * 100;
		var yScale = (heightNew / heightCurrent) * 100;

		// calculate size difference between new and old image, and resize if necessary
		var wDiff = widthCurrent - widthNew;
		var hDiff = heightCurrent - heightNew;

		//Modifier hauteur centre
		if (hDiff != 0) new Effect.Scale($(LightboxOptions.conteneurBox), yScale, {scaleX: false, duration: this.resizeDuration, queue: 'front'}); 
		//Modifier largeur centre
		if (wDiff != 0) new Effect.Scale($(LightboxOptions.conteneurBox), xScale, {scaleY: false, duration: this.resizeDuration, delay: this.resizeDuration});		
		//Modifier largeur centre gauche
		xScaleLeft = ((arrayPageSize[0]-widthNew)/2)-5 ;
		//Modifier largeur centre droit
		xScaleRight = xScaleLeft ;		

		// if new and old image are same size and no scaling transition is necessary, 
		// do a quick pause to prevent box flicker.
		var timeout = 0;
		if ((hDiff == 0) && (wDiff == 0)){
			timeout = 100;
			if (Prototype.Browser.IE) timeout = 250;   
		}
		(function(){
			//Modifier espacement logoTexteDroit
			var moveXMenuDroite = 0 ;
			var leftMarge = parseInt($(LightboxOptions.logoTexteDroitBox).getStyle('margin-left').replace(reg, "")) ;
			moveXMenuDroite = (xScaleLeft+widthNew) ; 
			moveXMenuDroite = ((moveXMenuDroite)>arrayPageSize[0]-parseInt($(LightboxOptions.logoTexteDroitBox).getStyle('width').replace(reg, "")))?arrayPageSize[0]-parseInt($(LightboxOptions.logoTexteDroitBox).getStyle('width').replace(reg, "")):(moveXMenuDroite) ;
			moveXMenuDroite = ((moveXMenuDroite+leftMarge)>=(arrayPageSize[0]-parseInt($(LightboxOptions.logoTexteDroitBox).getStyle('width').replace(reg, ""))-leftMarge)?arrayPageSize[0]-parseInt($(LightboxOptions.logoTexteDroitBox).getStyle('width').replace(reg, ""))-leftMarge:(moveXMenuDroite+leftMarge)) ;
			if (wDiff != 0) new Effect.Move($(LightboxOptions.logoTexteDroitBox), { x: moveXMenuDroite, y: parseInt($(LightboxOptions.headerbox).getStyle('height').replace(reg, "")), mode: 'absolute', duration: this.resizeDuration });
			
			//Modifier espacement menuGauche
			/*
			var moveXMenuGauche = 0 ;
			var rightMarge = parseInt($(LightboxOptions.menuGaucheBox).getStyle('margin-right').replace(reg, "")) ;
			
			moveXMenuGauche = (arrayPageSize[0]-(widthNew+xScaleRight+parseInt($(LightboxOptions.menuGaucheBox).getStyle('width').replace(reg, "")))) ; 
			moveXMenuGauche = ((moveXMenuGauche-rightMarge)<0)?10:(moveXMenuGauche-rightMarge) ;
			if (wDiff != 0) new Effect.Move($(LightboxOptions.menuGaucheBox), { x: moveXMenuGauche, y: 0, mode: 'absolute', duration: this.resizeDuration }) ;
			
			//Modifier de home
			var moveXLienHome = 0 ;
			var rightMarge = parseInt($(LightboxOptions.menuGaucheBox).getStyle('margin-right').replace(reg, "")) ;
			moveXLienHome = (arrayPageSize[0]-(widthNew+xScaleRight+parseInt($(LightboxOptions.menuGaucheBox).getStyle('width').replace(reg, "")))) ; 
			moveXLienHome = ((moveXLienHome-rightMarge)<0)?10:(moveXLienHome-rightMarge) ;
			moveXLienHome = (/IE/.test(navigator.userAgent))?moveXLienHome+15:moveXLienHome ;//Bug marge IE
			if (wDiff != 0) new Effect.Move($(LightboxOptions.lienHomeBox), { x: moveXLienHome, y: 0, mode: 'absolute', duration: this.resizeDuration }) ;
			*/
			
			//Modifier le cadre du centre gauche
			$(LightboxOptions.centreGaucheBox).setStyle({ 'width': xScaleLeft });
			//Modifier le cadre du centre
			$(LightboxOptions.centreBox).setStyle({ 'width': widthNew });	
			//Modifier le cadre du centre droit
			$(LightboxOptions.centreDroitBox).setStyle({ 'width': xScaleRight });
			
			//Cacher le loader
			varLightbox.hideBox(LightboxOptions.loadingBox);
			this.showBox(box, vignettes);			
		}).bind(this).delay(this.resizeDuration);
    },

    //
    //  getPageSize()
    //
    getPageSize: function() {
	        
	     var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}

		return [pageWidth,pageHeight];
	},
	
    //
    //  showBox()
    //
    showBox: function(box, vignettes) {
		//En cas de chargement de vignettes
		var vide = "" ;
		
		new Effect.Appear(box, {
			duration:this.appearDuration,
			to:1.0, 
			from:0.0,
			queue: 'end',
			afterFinish:(function(){			  
				if(vignettes && vignettes!=""){
					//Recuperer le nombre de sous vignettes
					var children = $$("ul#"+vignettes+" li");
					if(children.length>1) this.showBox(vignettes, vide) ;
				}				
			}).bind(this)
		});
    },	
	
    //
    //  hideBox()
    //
    hideBox: function(box) {
		if($(box) && $(box).visible()){
			new Effect.Appear(box, {
				duration:this.disappearDuration,
				to:0.0, 
				from:1.0,
				queue: 'end',
				afterFinish:(function(){ 
					$(box).hide();
				}).bind(this)
			});
		}
    },		
	
    //
    //  loadMovie()
    //
    loadFlash: function(video, width, height, vignettes){
		if(LightboxOptions.vignettesOuvertes!=vignettes || !vignettes){		
			if(vignettes || vignettes==''){
				if(LightboxOptions.vignettesOuvertes) this.hideBox(LightboxOptions.vignettesOuvertes) ;
				if(vignettes==''){
					LightboxOptions.vignettesOuvertes = false ;
				}else{
					LightboxOptions.vignettesOuvertes = vignettes ;
				}
			}		
			
			if(video){		
				LightboxOptions.flash = true ;
				//Cacher l'image
				if(LightboxOptions.image) this.hideBox(LightboxOptions.imageBox) ;	
				//Vider l'image
				LightboxOptions.image = false ;			
				
				//Cacher le flash
				if(LightboxOptions.flash) this.hideBox(LightboxOptions.flashBox) ;	
				LightboxOptions.flash = false ;
				$(LightboxOptions.flashBox).hide() ;
				$(LightboxOptions.flashBox).innerHTML = "" ;				
				
				new Effect.Appear(LightboxOptions.flashBox, {
					duration:this.appearDuration,
					to:0.0, 
					from:1.0,
					queue: 'end',
					afterFinish:(function(){								  
						varLightbox.resizeBox(width, height, LightboxOptions.flashBox, vignettes) ;						
						video.write(LightboxOptions.flashBox);		
					})
				});
			}
		}	
	},
	
    //
    //  loadPicture()
    //	
	loadPicture: function(source, width, height, vignettes) {
		if(LightboxOptions.vignettesOuvertes!=vignettes){	
			if(vignettes || vignettes==''){
				if(LightboxOptions.vignettesOuvertes) this.hideBox(LightboxOptions.vignettesOuvertes) ;
				if(vignettes==''){
					LightboxOptions.vignettesOuvertes = false ;
				}else{
					LightboxOptions.vignettesOuvertes = vignettes ;
				}
			}
			
			if(source){				
				if(LightboxOptions.image != source){
					LightboxOptions.image = source ;
					new Effect.Appear(LightboxOptions.imageBox, {
						duration:this.appearDuration,
						to:0.0, 
						from:1.0,
						queue: 'end',
						beforeStart:(function(){	
							if(LightboxOptions.flash){
								varLightbox.hideBox(LightboxOptions.flashBox) ;
							}
							if(LightboxOptions.image){
								varLightbox.hideBox(LightboxOptions.image) ;	
							}							
						}),						
						afterFinish:(function(){	
							//Vider le flash
							LightboxOptions.flash = false ;											  
							var imgPreloader = new Image() ;					
							imgPreloader.onload = (function(){																
								this.resizeBox(width, height, LightboxOptions.imageBox, vignettes) ;
								$(LightboxOptions.imageBox).src = source ;
							}).bind(this) ;
							imgPreloader.src = source ;					
						}).bind(this) 
					});
				}
			}			
		}
	},	
	
	//
	// loadMenu
	//
	loadMenu: function(idMenu){	
		if(idMenu){
			//Pour eviter de modifier le code source du flash
			//2009 02 18
			if(idMenu == "instinctAfterDark"){ idMenu = "pureInstinct" ; }
			
			LightboxOptions.parfumCharge = false ;
			
			//Cacher l'image
			this.hideBox(LightboxOptions.imageBox) ; LightboxOptions.imageBox.src = "" ;
			LightboxOptions.image = false ;
			
			//Cacher le flash
			this.hideBox(LightboxOptions.flashBox) ;
			LightboxOptions.flash = false ;
			
			//Cacher le texte 
			this.viderTexte() ;	
			
			//Cacher les vignettes
			this.viderVignette() ;				
			
			//Afficher le menu desire
			this.selectMenu(idMenu) ;
			LightboxOptions.menu = idMenu ;		
	
			//Flash a ouvrir par defaut	selon le menu	
			switch(idMenu){
				case 'instinct':
					this.loadFlash(f_instinct(), 183, 351, 'design_instinct_0'); 
					this.selectVignette('design_instinct_0', 'design_instinct_0_1');
					LightboxOptions.numeroParfum = 1 ;
				break;
				case 'pureInstinct':
					this.loadFlash(f_pureInstinct(), 280, 320, 'design_pureInstinct_0');
					this.selectVignette('design_pureInstinct_0', 'design_pureInstinct_0_1');
					LightboxOptions.numeroParfum = 3 ;
				break;
				case 'intenseInstinct':
					this.loadFlash(f_intenseInstinct(), 183, 351, 'design_intenseInstinct_0');
					this.selectVignette('design_intenseInstinct_0', 'design_intenseInstinct_0_1');
					LightboxOptions.numeroParfum = 2 ;
				break;	
				case 'intimatelyHer':
					this.loadFlash(f_intimatelyHer(), 238, 328, 'design_intimatelyHer_0');
					this.selectVignette('design_intimatelyHer_0', 'design_intimatelyHer_0_1');
					LightboxOptions.numeroParfum = 5 ;
				break;	
				case 'intimatelyHim':
					this.loadFlash(f_intimatelyHim(), 238, 328, 'design_intimatelyHim_0');
					this.selectVignette('design_intimatelyHim_0', 'design_intimatelyHim_0_1');
					LightboxOptions.numeroParfum = 4 ;
				break;
				case 'intimatelyNightHer':
					this.loadFlash(f_intimatelyNightHer(), 238, 328, 'design_intimatelyNightHer_0');
					this.selectVignette('design_intimatelyNightHer_0', 'design_intimatelyNightHer_0_1');
					LightboxOptions.numeroParfum = 7 ;
				break;			
				case 'intimatelyNightHim':
					this.loadFlash(f_intimatelyNightHim(), 238, 328, 'design_intimatelyNightHim_0');
					this.selectVignette('design_intimatelyNightHim_0', 'design_intimatelyNightHim_0_1');
					LightboxOptions.numeroParfum = 6 ;
				break;	
				case 'signatureHer':
					this.loadFlash(f_signatureHer(), 169, 298, 'design_signatureHer_0'); 
					this.selectVignette('design_signatureHer_0', 'design_signatureHer_0_1');
					LightboxOptions.numeroParfum = 9 ;
				break;				
				case 'signatureHim':
					this.loadFlash(f_signatureHim(), 249, 290, 'design_signatureHim_0'); 
					this.selectVignette('design_signatureHim_0', 'design_signatureHim_0_1');
					LightboxOptions.numeroParfum = 8 ;
				break;				
				case 'storyHim':
					this.loadFlash(f_storyHim(), 249, 305, 'design_storyHim_0'); 
					this.selectVignette('design_storyHim_0', 'design_storyHim_0_1');
					LightboxOptions.numeroParfum = 10 ;
				break;				
				case 'storyHer':
					this.loadFlash(f_storyHer(), 249, 290, 'design_storyHer_0'); 
					this.selectVignette('design_storyHer_0', 'design_storyHer_0_1');
					LightboxOptions.numeroParfum = 11 ;
				break;				
				default:
					this.loadFlash(f_instinct(), 183, 351, 'design_instinct_0'); 
					this.selectVignette('design_instinct_0', 'design_instinct_0_1');
					LightboxOptions.numeroParfum = 1 ;
				break;
			}
			//alert(idMenu+"-"+LightboxOptions.numeroParfum);

			//Faire disparaitre le fondu du bas
			new Effect.Appear(LightboxOptions.fonduBasBox, {
				duration:this.disappearDuration,
				to:0.0, 
				from:1.0,
				afterFinish:(function(){
					//Fondu bas gauche
					$(LightboxOptions.fonduBasGaucheBox).src = 'http://'+ADRESSE_SITE+'/images/'+idMenu+'/'+idMenu+'-fondu_bas_gauche.jpg' ;
					//Fondu bas droit
					$(LightboxOptions.fonduBasDroitBox).src = 'http://'+ADRESSE_SITE+'/images/'+idMenu+'/'+idMenu+'-fondu_bas_droit.jpg' ; 									  
									  
					//Changer le fondu bas
					$(LightboxOptions.fonduBasBox).setStyle({ backgroundImage: 'url(../images/'+idMenu+'/'+idMenu+'-fondu_bas.jpg)' }) ;
					$(LightboxOptions.fonduBasBox).setStyle({ backgroundPosition:'top' }) ;
					$(LightboxOptions.fonduBasBox).setStyle({ backgroundRepeat:'repeat-x' }) ;			
				})
			});
			//Faire apparaitre le fondu du bas
			new Effect.Appear(LightboxOptions.fonduBasBox, {
				duration:this.appearDuration,
				to:1.0, 
				from:0.0,
				queue: 'end',
				afterFinish:(function(){
					//
				}).bind(this)
			});	
			
			(function(){
				this.selectLogo('logo_'+idMenu);
				this.selectItem('design_'+idMenu);	
			}).bind(this).delay(this.disappearDuration) ;
		}
	},
	
    //
    //  showSendToAFriend()
    //	
	showSendToAFriend: function() {
        new Effect.Parallel(
            [ 
                new Effect.SlideDown(LightboxOptions.sendToAFriendBox+"_"+LightboxOptions.menu, { sync: true, duration: this.resizeDuration, from: 0.0, to: 0.5 }), 
                new Effect.Appear(LightboxOptions.sendToAFriendBox+"_"+LightboxOptions.menu, { sync: true, duration: this.resizeDuration}) 
            ], 
            { 
                duration: this.resizeDuration
            } 
        );
		$(LightboxOptions.sendToAFriendBox+"_"+LightboxOptions.menu).show();
	},
	
    //
    //  selectVignette()
    //		
	selectVignette: function(parent, vignette){
		
		if(parent != LightboxOptions.vignetteOuvertes){
			new Effect.Appear(LightboxOptions.vignetteBox, {
				duration:this.disappearDuration,
				to:0.0, 
				from:1.0,
				queue: 'end',
				beforeStart:(function(){	
					LightboxOptions.vignetteOuvertes = false ;	
					LightboxOptions.vignetteOuverte = false ;			 
				}),
				afterFinish:(function(){	
					if($(parent)){
						LightboxOptions.vignetteOuvertes = parent ;
						$(LightboxOptions.vignetteBox).hide() ;
						$(LightboxOptions.vignetteBox).update($(parent).innerHTML) ;
						this.showBox(LightboxOptions.vignetteBox) ;
						this.selectVignette(LightboxOptions.vignetteOuvertes, vignette) ;
					}
				}).bind(this)
			});
		}else{
			
			//Recuperer les vignettes dans un tableau
			var childrenLi = $$("ul#"+parent+" li") ;
			
			if(childrenLi.length>1){
				var idVignette;
				if(parent && $(parent)){
					for(i=0; i<childrenLi.length; i++){
						idVignette = childrenLi[i].id;
						if(idVignette && $(idVignette)){
							if(idVignette==vignette){
								LightboxOptions.vignetteOuverte = vignette ;
								
								//Selectionner image vignette
								var reg=new RegExp("[ _]+", "g");
								var tabChaineVignette=vignette.split(reg);							
								var numVignette = tabChaineVignette[3] ;
								if(numVignette<2){numVignette="";}
								MM_swapImage(vignette+'_img','','http://'+ADRESSE_SITE+'/images/'+LightboxOptions.menu+'/'+LightboxOptions.menu+'-'+tabChaineVignette[0]+'-vignette-on'+numVignette+'.jpg',1, true);
								MM_swapImgRestore();
								//Selection image : fin
								$(idVignette).setStyle({ background: '#ababab' })
								$(idVignette).setStyle({ cursor: 'default' })
							}else{
								$(idVignette).setStyle({ background: '#444444' })
								$(idVignette).setStyle({ cursor: 'pointer' })
							}					
						}
					}
				}
			}
		}
	},
	
    //
    //  selectLogo()
    //		
	selectLogo: function(parfum){
		if(parfum!=LightboxOptions.logo && $(parfum)){
			new Effect.Appear(LightboxOptions.logoBox, {
				duration:this.disappearDuration,
				to:0.0, 
				from:1.0,
				queue: 'end',
				beforeStart:(function(){	
					LightboxOptions.logo = false ;	 
				}),
				afterFinish:(function(){	
					if($(parfum)){
						$(LightboxOptions.logoBox).hide() ;
						LightboxOptions.logo = parfum ;
						$(LightboxOptions.logoBox).update($(parfum).innerHTML) ;
						this.showBox(LightboxOptions.logoBox) ;
					}
				}).bind(this)
			});
		}		
	},	
	
    //
    //  selectTexte()
    //		
	selectTexte: function(texte){
		if(texte!=LightboxOptions.texte && $(texte)){
			new Effect.Appear(LightboxOptions.texteBox, {
				duration:this.disappearDuration,
				to:0.0, 
				from:1.0,
				queue: 'end',
				beforeStart:(function(){	
					LightboxOptions.texte = false ;	 
				}),
				afterFinish:(function(){	
					if($(parent)){
						$(LightboxOptions.texteBox).hide() ;
						LightboxOptions.texte = texte ;
						$(LightboxOptions.texteBox).update($(texte).innerHTML) ;
						this.showBox(LightboxOptions.texteBox) ;
					}
				}).bind(this)
			});
		}
	},
	
    //
    //  viderTexte()
    //		
	viderTexte: function(){
		if($(LightboxOptions.texteBox).visible() && $(LightboxOptions.texteBox).innerHTML != "" && LightboxOptions.texte){
			new Effect.Appear(LightboxOptions.texteBox, {
				duration:this.disappearDuration,
				to:0.0, 
				from:1.0,
				queue: 'end',
				beforeStart:(function(){
					LightboxOptions.texte = false ;						  
				}).bind(this),
				afterFinish:(function(){		
					$(LightboxOptions.texteBox).hide() ;
					$(LightboxOptions.texteBox).innerHTML = "" ;
				}).bind(this)
			});
		}
	},		
	
    //
    //  viderVignette()
    //		
	viderVignette: function(){
		if($(LightboxOptions.vignetteBox).visible() && $(LightboxOptions.vignetteBox).innerHTML != "" && LightboxOptions.vignetteOuvertes){
			new Effect.Appear(LightboxOptions.vignetteBox, {
				duration:this.disappearDuration,
				to:0.0, 
				from:1.0,
				queue: 'end',
				beforeStart:(function(){
					LightboxOptions.vignetteOuvertes = false ;	
					LightboxOptions.vignetteOuverte = false ;						  
				}).bind(this),
				afterFinish:(function(){	
					$(LightboxOptions.vignetteBox).hide() ;
					$(LightboxOptions.vignetteBox).innerHTML = "" ;
				}).bind(this)
			});
		}
	},
	
    //
    //  selectMenu()
    //		
	selectMenu: function(menu){
		if(menu!=LightboxOptions.menu && $(menu)){
			new Effect.Appear(LightboxOptions.menuGaucheBox, {
				duration:this.disappearDuration,
				to:0.0, 
				from:1.0,
				queue: 'end',
				beforeStart:(function(){	
					LightboxOptions.menu = false ;	 
				}),
				afterFinish:(function(){	
					$(LightboxOptions.menuGaucheBox).hide() ;
					LightboxOptions.menu = menu ; 
					$(LightboxOptions.menuGaucheBox).update($(menu).innerHTML) ;
					this.showBox(LightboxOptions.menuGaucheBox) ;
				}).bind(this)
			});
		}
	},	
	
	//
	//  selectItem()
	//
	selectItem: function(idItem) {
		if(idItem != LightboxOptions.itemSelect || idItem == LightboxOptions.tellAFriendBox+"_"+LightboxOptions.menu){
		
			//Cacher l'envoi a un ami
			if(idItem != LightboxOptions.tellAFriendBox+"_"+LightboxOptions.menu){
				this.hideBox(LightboxOptions.sendToAFriendBox+"_"+LightboxOptions.menu) ;
				
				//Cacher le texte 
				this.viderTexte() ;	
				
				//Cacher les vignettes
				this.viderVignette() ;
			}
			
			//Cacher l'ancien element selectionne
			if(LightboxOptions.itemSelect) $(LightboxOptions.itemSelect).setStyle({ color: '#FFFFFF' }) ;
			
			if(LightboxOptions.menu){
				var children = $(LightboxOptions.menu).childNodes;
				if(children.length>0){				
					for(i=0; i<children.length; i++){
						if(children[i].id && children[i].id!=null && $(children[i].id) && idItem == children[i].id) {
							$(children[i].id).setStyle({ color: '#444444' }) ;
							LightboxOptions.itemSelect = children[i].id ;
							//Different de "tell a friend"
							if(LightboxOptions.itemSelect != LightboxOptions.tellAFriendBox+"_"+LightboxOptions.menu){				
								//Afficher le texte correspondant s'il y en a un
								if($("texte_"+children[i].id) || "texte_"+children[i].id!=null){
									this.selectTexte("texte_"+children[i].id) ;
								}
							}
						}else if(children[i].id && children[i].id!=null && $(children[i].id)){
							$(children[i].id).setStyle({ color: '#FFFFFF' }) ;
						}
					}
				}
			}
		}
	},
	
    //
    //  unload()
    //	
	unload: function() {
		//Cacher l'image
		$(LightboxOptions.imageBox).hide();	
		//Vider l'image
		$(LightboxOptions.imageBox).src = "/images/imageDefaut.gif" ;
		
		//et le flash
		$(LightboxOptions.flashBox).hide();
		$(LightboxOptions.flashBox).innerHTML = "" ;
	
		return true ;
	}
}

//document.observe('dom:loaded', function () { var varLightbox = new Lightbox(); });