function str_replace(a, b, str) {
    return str_replace2(str, a, b);
}
function str_replace2(SRs, SRt, SRu) {
  SRRi = SRs.indexOf(SRt);
  SRRr = '';
  if (SRRi == -1) return SRs;
  SRRr += SRs.substring(0,SRRi) + SRu;
  if ( SRRi + SRt.length < SRs.length)
    SRRr += str_replace2(SRs.substring(SRRi + SRt.length, SRs.length), SRt, SRu);
  return SRRr;
}

function selectReplacement(obj) {
      // append a class to the select
      obj.className += ' replaced';
      // create list for styling
      var ul = document.createElement('ul');
      ul.className = 'selectReplacement';
      var opts = obj.options;
      for (var i=0; i<opts.length; i++) {
        var selectedOpt;
        if (opts[i].selected) {
          selectedOpt = i;
          break;
        } else {
          selectedOpt = 0;
        }
      }
      for (var i=0; i<opts.length; i++) {
        var li = document.createElement('li');
        var txt = document.createTextNode(opts[i].text);
        li.appendChild(txt);
        li.selIndex = opts[i].index;
        li.selectID = obj.id;
        li.onclick = function() {
          selectMe(this);
        }
        if (i == selectedOpt) {
          li.className = 'selected';
          li.onclick = function() {
            this.parentNode.className += ' selectOpen';
            this.onclick = function() {
              selectMe(this);
            }
          }
        }
        if (window.attachEvent) {
          li.onmouseover = function() {
            this.className += ' hover';
          }
          li.onmouseout = function() {
            this.className = 
              this.className.replace(new RegExp(" hover\\b"), '');
          }
        }
        ul.appendChild(li);
      }
      // add the input and the ul
      obj.parentNode.appendChild(ul);
    }
    function selectMe(obj) {
      var lis = obj.parentNode.getElementsByTagName('li');
      for (var i=0; i<lis.length; i++) {
        if (lis[i] != obj) { // not the selected list item
          lis[i].className='';
          lis[i].onclick = function() {
            selectMe(this);
          }
       } else {
          setVal(obj.selectID, obj.selIndex);
          obj.className='selected';
          obj.parentNode.className = 
            obj.parentNode.className.replace(new RegExp(" selectOpen\\b"), '');
          obj.onclick = function() {
            obj.parentNode.className += ' selectOpen';
            this.onclick = function() {
              selectMe(this);
            }
          }
        }
      }
    }
    function setVal(objID, selIndex) {
      var obj = document.getElementById(objID);
      obj.selectedIndex = selIndex;
    }
    function setForm() {
      var s = document.getElementsByTagName('select');
      for (var i=0; i<s.length; i++) {
        selectReplacement(s[i]);
      }
    }
    function closeSel(obj) {
      // close the ul
    }

 
function checkemail(mel_name,form_name)
	{
	adresse = document.forms[form_name].elements[mel_name].value;
	taille = document.forms[form_name].elements[mel_name].value.length;
	// on cree 3 variables pour valider au fur et à mesure le login, le domaine et l'extension qui constituent l'adresse e-mail
	validelog = false;
	validedom = false;
	valideext = false;
	// on extrait le 'login' qui se situe avant l'arobace
	arob = adresse.lastIndexOf("@");
	login = adresse.substring(0,arob);
	// on extrait l'extension qui se situe à partir du dernier point
	pointfinal = adresse.lastIndexOf(".");
	extension = adresse.substring(pointfinal,taille);
	// on extrait le domaine qui se trouve entre l'arobace et le dernier point
	domaine = adresse.substring(arob+1,pointfinal);
	// un login a toujours plus de 2 caractères, on fait le test
	if ( login.length > 2 ) { validelog = true; }
	else 
	{
		alert(adresse+' n\'est pas une adresse e-mail valide.\nUne adresse e-mail comporte un arobace precede d\'un login \'convenable\'.');
		validelog = false; return false;
	}
	// un domaine a toujours plus de 1 caractère, on fait le test
	if ( domaine.length > 1 ) {
		validedom = true;
		}
	else {
		alert(adresse+' n\'est pas une adresse e-mail valide.\nLe nom de domaine n\'existe pas.');
		validelog = false; return false;
			}
		// une extension a toujours 2 ou 3 caractères, on fait le test
	if ( pointfinal > -1 && (extension.length == 3 || extension.length == 4) ) {
		valideext = true;
		}
	else {
		alert(adresse+' n\'est pas une adresse e-mail valide.\nL\'extension n\'est pas bonne.');
		valideext = false; return false;
		}
		// on verifie que nos trois variables sont vraies pour accepter la soumission du formulaire
	if ( validelog == true && validedom == true && valideext == true ) {
		 return true;
		}
	else {
		return false;
		}
}


function doBoutNewcmpt() {
	var ok=1;
	
	if ($('idel_civ').value!=1 && $('idel_civ').value!=2 && $('idel_civ').value!=3) {$('idlab_civ').setStyle('color','#41281B'); var ok=0;}
	else {$('idlab_civ').setStyle('color','#515053'); }
	if ($('idel_nom').value=='') {$('idlab_nom').setStyle('color','#41281B'); var ok=0;}
	else {$('idlab_nom').setStyle('color','#515053'); }
	if ($('idel_prenom').value=='') {$('idlab_prenom').setStyle('color','#41281B'); var ok=0;}
	else {$('idlab_prenom').setStyle('color','#515053'); }
	if ($('idel_adr1').value=='') {$('idlab_adr1').setStyle('color','#41281B'); var ok=0;}
	else {$('idlab_adr1').setStyle('color','#515053'); }
	if ($('idel_ville').value=='') {$('idlab_ville').setStyle('color','#41281B'); var ok=0;}
	else {$('idlab_ville').setStyle('color','#515053'); }
	if ($('idel_cpostal').value=='') {$('idlab_cpostal').setStyle('color','#41281B'); var ok=0;}
	else {$('idlab_cpostal').setStyle('color','#515053'); }
	if ($('idel_ville').value=='') {$('idlab_ville').setStyle('color','#41281B'); var ok=0;}
	else {$('idlab_ville').setStyle('color','#515053'); }
	/*if ($('idel_telfixe').value=='') {$('idlab_telfixe').setStyle('color','#e05190'); var ok=0;}
	else {$('idlab_telfixe').setStyle('color','black'); }*/
	if ($('idel_mel1').value=='') {$('idlab_mel1').setStyle('color','#41281B'); var ok=0;}
	else {if (checkemail('email1','nouveau')) {$('idlab_mel1').setStyle('color','#515053');}
	else {$('idlab_mel1').setStyle('color','#e05190'); var ok=0;}}
	/*if ($('idel_mel2').value!=$('idel_mel1').value) {$('idlab_mel2').setStyle('color','#e05190'); var ok=0;} else {$('idlab_mel2').setStyle('color','black');}*/
	if ($('idel_p1').value=='') {$('idlab_p1').setStyle('color','#41281B'); var ok=0;}
	else {$('idlab_p1').setStyle('color','#515053'); }	
	if ($('idel_p2').value!=$('idel_p1').value) {$('idlab_p2').setStyle('color','#41281B'); var ok=0;} else {$('idlab_p2').setStyle('color','#515053');}
		
	if (ok==1){
	$('idel_mel2').value=$('idel_mel1').value;
	document.forms['nouveau'].submit();
	} else {$('warnchamps').fade('in'); return false;}
}

function makeScrollbar(content,scrollbar,handle,horizontal,ignoreMouse){
	var steps = (horizontal?(content.getScrollSize().x - content.getSize().x):(content.getScrollSize().y - content.getSize().y))
	var slider = new Slider(scrollbar, handle, {	
		steps: steps,
		mode: (horizontal?'horizontal':'vertical'),
		 onTick: function(pos){
        //this.element.setStyle('border-color', '#f00');
        this.knob.setStyle(this.property, pos);
    },

		onChange: function(step){
			// Scrolls the content element in x or y direction.
			var x = (horizontal?step:0);
			var y = (horizontal?0:step);
			content.scrollTo(x,y);
		}
	}).set(0);
	if( !(ignoreMouse) ){
		// Scroll the content element when the mousewheel is used within the 
		// content or the scrollbar element.
		$$(content, scrollbar).addEvent('mousewheel', function(e){	
			e = new Event(e).stop();
			var step = slider.step - e.wheel * 30;	
			slider.set(step);					
		});
	}
	// Stops the handle dragging process when the mouse leaves the document body.
	$(document.body).addEvent('mouseleave',function(){slider.drag.stop()});
}

function makeScrollbar2(content,scrollbar,handle,horizontal,ignoreMouse){
	var steps = (horizontal?(content.getScrollSize().x - content.getSize().x):(content.getScrollSize().y - content.getSize().y))
	var slider = new Slider(scrollbar, handle, {	
		steps: steps,
		mode: (horizontal?'horizontal':'vertical'),
		 onTick: function(pos){
        //this.element.setStyle('border-color', '#f00');
        this.knob.setStyle(this.property, pos);
    },

		onChange: function(step){
			// Scrolls the content element in x or y direction.
			var x = (horizontal?step:0);
			var y = (horizontal?0:step);
			content.scrollTo(x,y);
		}
	}).set(0);
	if( !(ignoreMouse) ){
		// Scroll the content element when the mousewheel is used within the 
		// content or the scrollbar element.
		$$(content, scrollbar).addEvent('mousewheel', function(e){	
			e = new Event(e).stop();
			var step = slider.step - e.wheel * 30;	
			slider.set(step);					
		});
	}
	// Stops the handle dragging process when the mouse leaves the document body.
	$(document.body).addEvent('mouseleave',function(){slider.drag.stop()});
	
	return slider;
}

var Bibi={
switchPan:function(x) {
	if (x=="ferme") {
		$$('.ficheslide').each(function(el) {
			
			if (el.hasClass('ouvert')) {
				if ($('fenactiveback')) {$('fenactiveback').value=$('fenactive').value; $('fenactive').value=el.get('id');}
			}
			el.removeClass('ouvert');
			el.addClass('ferme');
			if (el.hasClass('fich')) {var lenombre=350;} else {var lenombre=250;}
			//el.set('morph',{onComplete:function(){if ($('closemenu')) {$('closemenu').addClass('closed');}}});
			el.morph({'opacity' : 0,'margin-left' : lenombre});
			
			
			
	});
	if ($('closemenu')) {$('closemenu').addClass('closed'); $('closemenu').store('tip:title', 'ouvrir le menu&nbsp;&nbsp;&nbsp;&nbsp;');
}
	} else {
	
	$$('.ficheslide').each(function(el) {
		//alert(el.get('id'));
		if (el.get('id')!=x) {
			el.removeClass('ouvert');
			el.addClass('ferme');
			if (el.hasClass('fich')) {var lenombre=350;} else {var lenombre=250;}
			el.morph({'opacity' : 0,'margin-left' : lenombre});
			
		} else {
			el.removeClass('ferme');
			el.addClass('ouvert');
			if ($('fenactiveback')) {$('fenactiveback').value=$('fenactive').value; $('fenactive').value=el.get('id');}
			if ($('maskmore').hasClass('fich')) {if (el.hasClass('fich')) {var lenombre=0;} else {var lenombre=100;}} else {var lenombre=0;}
			
			el.morph({'opacity' : 1,'margin-left' : lenombre});
			if ($('closemenu')) {if (x=="fichemenu"){$('closemenu').removeClass('closed');$('closemenu').store('tip:title', 'fermer le menu&nbsp;&nbsp;&nbsp;&nbsp;');}else{$('closemenu').addClass('closed');$('closemenu').store('tip:title', 'ouvrir le menu&nbsp;&nbsp;&nbsp;&nbsp;');}}
		}
	});
	}
	$('closemenu').morph({'opacity' : 1});
	if ($('holdquickliste').getStyle('visibility')=="visible") {$('closequick').fireEvent('click');}
	if ($('holdfavoris').getStyle('visibility')=="visible") {$('closefav').fireEvent('click');}
	if ($('zeprice') && $('zeprice').get('opacity')<1) {$('zeprice').fade('in');}
	if ($('divcondi') && $('divcondi').get('opacity')<1) {$('divcondi').fade('in');}
	if ($('paulieude') && $('paulieude').get('opacity')<1) {$('paulieude').fade('in');}
	
	if (x=="fichebuy" || x=="ficheinfo") {
		
		
		if ($('aaddtofav').getStyle('opacity')==0){
			
			
			if (x=="ficheinfo") {
				//check taille fen ingo
				var tinfos=$('ficheinfo').getCoordinates();
				
				if (tinfos.height<490) {Bibi.doAffichShare();}
			} else {Bibi.doAffichShare();}
			
			}
		
		/*
		
		if ($('aaddtofav')) {
			if ($('aaddtofav').getStyle('opacity')!=1){(function(){
			if ($('aaddtofav').hasClass('tipzcoul')) {
			$('aaddtofav').setStyles({'display':'','opacity':0,'cursor':'default'}); $('aaddtofav').morph({'opacity':.5});
			} else {
			$('aaddtofav').setStyles({'display':'','opacity':0}); $('aaddtofav').fade('in');
			} }).delay(300);}
		}
		if ($('aspktofriend')) { 
			if ($('aspktofriend').getStyle('opacity')!=1){(function(){$('aspktofriend').setStyles({'display':'','opacity':0});$('aspktofriend').fade('in');}).delay(500);}
		}
		*/
	} else {
		if ($('aaddtofav')) {$('aaddtofav').setStyles({'display':'none','opacity':0,'visibility':'hidden'});}
		if ($('aspktofriend')) {$('aspktofriend').setStyles({'display':'none','opacity':0,'visibility':'hidden'});}
	}
	$$('#abio','#ainfo','#abuy').each(function(el){
		el.removeClass('shown');
		tit=el.get('id');
		if (x=="fichebio" && tit=="abio") {el.addClass('shown');}
		if (x=="ficheinfo" && tit=="ainfo") {el.addClass('shown');}
		if (x=="fichebuy" && tit=="abuy") {el.addClass('shown');}
	});
	
	
},
doAffichShare:function(){
	if ($('aaddtofav')) {
			(function(){
				if ($('aaddtofav').hasClass('tipzcoul')) {
					$('aaddtofav').setStyles({'display':'','opacity':0,'cursor':'default'}); $('aaddtofav').morph({'opacity':.5});
				} else {
					$('aaddtofav').setStyles({'display':'','opacity':0}); $('aaddtofav').fade('in');
				} 
			}).delay(500);
		}
		if ($('aspktofriend')) { 
			if ($('aspktofriend').getStyle('opacity')!=1){(function(){$('aspktofriend').setStyles({'display':'','opacity':0});$('aspktofriend').fade('in');}).delay(800);}
		}
},
checkAffichShare:function() {
	if ($('fichebuy').getStyle('visibility')=='visible' || $('ficheinfo').getStyle('visibility')=='visible') {
		Bibi.doAffichShare();
	} 
},
doOnResize:function() {
alert('yo');
},
checkNavFprod:function() {
	//Check si on doit monter la nav
	if ($('ctrprod')) {		
		var coordbarre=$('ctrprod').getCoordinates();	
		var win=window.getCoordinates();
		
		var alors = win.height - coordbarre.top - coordbarre.height ;
		if (alors<0) {
			var dif = win.height - coordbarre.top - coordbarre.height ;
			var newtopp = dif + parseInt($('ctrprod').getStyle('margin-top'));
			//var newtopp = dif + parseInt($('ctrprod').getStyle('margin-top'));
			var newmtop = parseInt($('bubblewrap').getStyle('margin-top')) + dif;
			$('ctrprod').set('morph',{'duration':1000,'transition': Fx.Transitions.Back.easeOut});
			$('ctrprod').morph({ 'margin-top' : newtopp });
			$('bubblewrap').setStyle('margin-top',newmtop); //idem pour les bubbles...
			
			if ($('ctrtofnumber')) {
				var numeros=$('ctrtofnumber').getCoordinates();
				var alorsNum = win.height - numeros.top - numeros.height ;
				if (alorsNum<0) {
					var difNum = win.height - numeros.top - numeros.height -10;
					var newtoppNum = difNum + parseInt($('ctrtofnumber').getStyle('margin-top'));
					$('ctrtofnumber').set('morph',{'duration':1000,'transition': Fx.Transitions.Back.easeOut});
					$('ctrtofnumber').morph({ 'margin-top' : newtoppNum });
				
				}
			}
		}
		
		if ($('holdquickliste')) { $('holdquickliste').setStyle('top',coordbarre.bottom+10); }
		if ($('holdfavoris')) { $('holdfavoris').setStyle('top',coordbarre.bottom+10);}
	
	}
	
	
		
},
chargeFavoris:function() {

	$('quicklistefav').addClass('loading');
	$('slideinsidefav').empty();
	var myRequest = new Request({url: 'produitsfav.php', method: 'post', onSuccess: 
		function(responseText, responseXML) {
			$('slideinsidefav').set('html',responseText);
			var lataille = 0;
			$$('#slideinsidefav ul li').each(function(elem,i){ lataille=lataille+85; }); ;
			$('slideinsidefav').setStyle('width',lataille);
			$('quicklistefav').removeClass('loading');
			if ($$('.tipzel')) {
				var myTips = new Tips('.tipzel',{className:'ben',offset:{'x': 16, 'y': 30}});
				myTips.addEvent('show', function(tip, el){ tip.fade('in'); });
				myTips.addEvent('hide', function(tip, el){ tip.fade('out'); });
				var bc=[];  var HaltAlt = $$('h5.h5dby');
				HaltAlt.each(function(el,i){ bc[i]=el.get('text'); el.setStyle('opacity','0'); });
				var HaltAlt2 = $$('.tipzel');
				HaltAlt2.each(function(el,i){ el.store('tip:text',bc[i]); });
			}
		} 
	}).send();
},
switchBarreBas:function(barre,closemoi) {
	var bMini=$('holdquickliste');
	var bFavo=$('holdfavoris');
	if (barre=="mini") { var jEntre=bMini; var jPars=bFavo; var jFire=$('closequick'); var bouteactif=$('amini'); var bouteautre=$('amesfav');}
	if (barre=="favo") { var jEntre=bFavo; var jPars=bMini; var jFire=$('closefav');var bouteactif=$('amesfav');var bouteautre=$('amini');}
	var combien = 90; var bibidif=20; var laval=290; var ladiff=110;
	
	if (closemoi==1) {
		//on bouge jEntre
			var quickback=jPars.getCoordinates();  var quick=jEntre.getCoordinates();
			var titi=$('ctrprod').getCoordinates();
			var toto=$('bubblewrap').getCoordinates();
			var tata=titi.top-toto.top;
			
			var coordbarreback=$('ctrprod').getStyle("margin-top").toInt()+quick.height+bibidif;
			var yBulleback=$('bubblewrap').getStyle("margin-top").toInt()+quick.height+bibidif;
			
			jEntre.set('morph',{duration: 1000,transition: Fx.Transitions.Back.easeOut});
			jEntre.morph({ 'opacity' : 0,'top':quickback.top});
			$('surminime').morph({ 'opacity' : 0});
				$('surminime').removeEvent('click');
				$('ctrprod').set('morph',{duration: 1000,transition: Fx.Transitions.Back.easeOut});
				 
				$('ctrprod').morph({ 'margin-top':coordbarreback});
				
				
				$('bubblewrap').setStyle('margin-top',$('bubblewrap').getStyle("margin-top").toInt() + quick.height+bibidif); 
				//$('bubblewrap').setStyle('margin-top',yBulleback); 
				
				bouteactif.removeClass('shown'); bouteautre.removeClass('shown');
				Bibi.checkAffichShare();
			
	} else {
	
	
	if (jEntre.getStyle('visibility')=="hidden") {
	
	if (jPars.getStyle('visibility')=="visible") { //cas jPars deja ouvert
			//on bouge jPars
			var quickback=jEntre.getCoordinates();
			jPars.set('morph',{duration: 1000,transition: Fx.Transitions.Back.easeOut});
			jPars.morph({ 'opacity' : 0,'top':quickback.top});
			//on monte jEntre
			var coordbarre=$('ctrprod').getCoordinates(); 
			var newtopquick = coordbarre.bottom + 15;
			jEntre.set('morph',{duration: 1000,transition: Fx.Transitions.Back.easeOut});
			jEntre.morph({ 'opacity' : 1,'top':newtopquick});
			//cas specifique
			if (barre=="mini") {var elelelel=$('amini').get('rel');$(''+elelelel).fireEvent('click');} else {Bibi.chargeFavoris();}
			
			//penser a laction du overlay
			$('surminime').removeEvent('click');	
			$('surminime').addEvent('click',function(){ jFire.fireEvent('click');});
			
			bouteactif.addClass('shown'); bouteautre.removeClass('shown');
		} else { // cas normal
			
			$$('#abio','#ainfo','#abuy').each(function(el){ el.removeClass('shown'); });
			
			if ($('aaddtofav')) {$('aaddtofav').setStyles({'display':'none','opacity':0,'visibility':'hidden'});}
			if ($('aspktofriend')) { 
			$('aspktofriend').setStyles({'display':'none','opacity':0,'visibility':'hidden'});
		}
			
			
			var quick=jEntre.getCoordinates();
			//il faut monter aussi le overlay
			$('surminime').morph({ 'opacity' : .75}); $('surminime').removeEvent('click');	
			$('surminime').addEvent('click',function(){ jFire.fireEvent('click');});
			
			//on monte jEntre
			var coordbarre=$('ctrprod').getCoordinates();
			var coordbull=$('bubblewrap').getCoordinates(); 
		var newtopquick = coordbarre.top - combien ;
			var newforbarre=  $('ctrprod').getStyle("margin-top").toInt() - quick.height -bibidif;
			var newforbulle=  $('bubblewrap').getStyle("margin-top").toInt() - quick.height - bibidif;

			
			/*var newforbarre=  coordbarre.top - laval;
			var newforbulle=  coordbull.top - laval;
			var newtopquick = coordbarre.top - laval + coordbarre.height+ladiff;
*/

			$('ctrprod').set('morph',{duration: 1000,transition: Fx.Transitions.Back.easeOut});
			$('bubblewrap').set('morph',{duration: 1000,transition: Fx.Transitions.Back.easeOut});
			jEntre.set('morph',{duration: 1000,transition: Fx.Transitions.Back.easeOut});
			$('ctrprod').morph({ 'margin-top':newforbarre});
			$('bubblewrap').morph({ 'margin-top':newforbulle});
					
			jEntre.morph({ 'opacity' : 1,'top':newtopquick});
			/*$('ctrprod').morph({ 'margin-top':newforbarre});
			$('bubblewrap').morph({ 'margin-top':newforbulle});
					
			jEntre.morph({ 'opacity' : 1,'top':newtopquick});
			*/		
			if (barre=="mini") {var elelelel=$('amini').get('rel');$(''+elelelel).fireEvent('click');} else {Bibi.chargeFavoris();}
			bouteactif.addClass('shown'); bouteautre.removeClass('shown');
			
		}
		}
	
	}
	
},
doOnStart:function() {
	
	if ($('bubblewrap')) { $('bubblewrap').setStyle('visibility',''); }
	if ($('bubblewraptof')) { $('bubblewraptof').setStyle('visibility',''); }
	if ($('bubblewrapcoul')) { $('bubblewrapcoul').setStyle('visibility',''); }
	if ($('bubblewrapbuy')) { $('bubblewrapbuy').setStyle('visibility',''); }
	if ($('bubblewrapmod')) { $$('#bubblewrapmod div').each(function(el) {el.setStyle('opacity',0);}); $('bubblewrapmod').setStyle('visibility',''); }
	if ($('bubblewrapserie')) { $('bubblewrapserie').setStyle('visibility',''); }
	
	
	//accueil
	if ($('loadaccueil')) { $('loadaccueil').fade('out'); }
	
	//Fiche prod
	if (!$$('#uldesseriesinfo li a')[0] && $('seriesinfo')) {  $('seriesinfo').destroy(); } 
	
	//Cas rubrique
	if ($('isCateg')) {
		if ($('lenbrdobjtofind')) { $('lenbrdobjtofind').morph({'opacity' : 1,'margin-top' : 0}); }
		
		var valCateg = $('isCateg').value;
		if (valCateg<=13) {/*Bibi.doClick('az1');*/ 
		if ($('ispecial') && $('ispecial').value==1) {
			
			if ($('elspecateg')) {  Bibi.doClickBibi('az2');}
			if ($('elspeprix')) {  Bibi.doClickBibi('az3');}
			if ($('spchedesi')) {/*Bibi.doClick('az4');*/ Bibi.doClickBibi('az4');}
			if ($('spchemark')) {/*Bibi.doClick('az5');*/  Bibi.doClickBibi('az5');  }
			
	} else {
		
		Bibi.doClickBibi('az1');}} 
		else {
			if (valCateg<=34) {/*Bibi.doClick('az2');*/ Bibi.doClickBibi('az2');} 
			else { 
				if (valCateg>35 && valCateg<=45) {/*Bibi.doClick('az3');*/ Bibi.doClickBibi('az3');}
				else {
					if (valCateg==998) {
						//mep du bo item selected
						/*if ($('liddesigner')) {
							$$("ul#ulsousaz5 li a").each(function(el) {
								if (el.get('rel')==$('liddesigner').value) {el.addClass('selection'); var myFx = new Fx.Scroll('toscrollaz5').toElement(el);}
							});
						}*/
						//Bibi.doClick('az5');
						Bibi.doClickBibi('az5');
					}
					else {
						if (valCateg==999) {
							/*if ($('liddesigner')) {
								$$("ul#ulsousaz4 li a").each(function(el) {
									if (el.get('rel')==$('liddesigner').value) {el.addClass('selection'); }
								});
							}*/
							//Bibi.doClick('az4');
							Bibi.doClickBibi('az4');

						} else {if (valCateg==9999 || valCateg==9998) {Bibi.doClickBibi('az1');} } 
					} 							
				}
			}
		} //FIN ELSE if (valCateg<=13)
	} else { 
	if ($('ispecial') && $('ispecial').value==1) {
			if ($('elspeprix')) {  Bibi.doClickBibi('az3');}
			if ($('elspecateg')) { /*alert($('elspecateg').get('rel'));*/ Bibi.doClickBibi('az2');}
			if ($('spchedesi')) {/*Bibi.doClick('az4');*/ Bibi.doClickBibi('az4');}
			if ($('spchemark')) {/*Bibi.doClick('az5');*/ Bibi.doClickBibi('az5');}
	} else {
	//Bibi.doClick('az1');
	Bibi.doClickBibi('az2');
	}
	
	 }
	

	if ($('fichemenu')) { 
		//MENU
		//Mise en place du menu sur le bon item si on est dans une categ ou rien
		//OUVERTURE FENETRE DROITE
		if ($('fichebio')) { // Si fiche prod ouvir bio...
			Bibi.checkNavFprod(); //... et replacer le menu
			if ($('copybio') && !$('copybio').get('rel')) {$('copybio').destroy();}
			if ($('copybio') && $('copybio').get('rel') && $('copybio').get('rel')=="photo : ") {$('copybio').destroy();}
			
			
			//Check taille pr maj du mask
			var tbio = $('fichebio').getCoordinates();
			var tinfo = $('ficheinfo').getCoordinates();
			var tmask = $('maskmore').getCoordinates();
			if (tbio.height > tmask.height) {$('maskmore').setStyle('height',tbio.height);}
			if (tinfo.height > tmask.height) {$('maskmore').setStyle('height',tinfo.height);}
			
			
			//check photo bio
			if ($('picbio')) {
			var tPhoto = $('picbio').getCoordinates();
			//alert(tPhoto.width);
			if (tPhoto.width==340) {
			//alert('todo');
				$('picbio').setStyle('padding-left',45);
				if ($('copybio')) {$('copybio').setStyle('margin-left',-233);}
			}
			}
			
			
			//Check si bio pas vide sinon ouvrir info $('ficheinfo')
			var testHtml="0"+$('fichebio').get('text');
			
			if (testHtml==0) { Bibi.switchPan('ficheinfo'); } 
			else {
				//Accordion ??
				var tabTest=$$('#fichebio h3.question'); var tabTest2=$$('#fichebio p.reponses');
				if (tabTest[1] && tabTest2[1]) {
					var myAccordionBio = new Fx.Accordion(tabTest, tabTest2, {
    				display: 0,
    				alwaysHide: true,
    				onActive:function(tog,ele) {
    					tog.setStyle('font-weight','bold');
    				},
    				onBackground:function(tog,ele) {
    					tog.setStyle('font-weight','normal');
    				}
					});
				}
				Bibi.switchPan('fichebio');
			}
		} else {
			//sinon on ouvre par default le menu...
			
				$('fichemenu').morph({'opacity' : 1,'margin-left' : 0}); 
				$('fichemenu').addClass('opened');
				
		}
		//Affiche de la fleche fenetre
		if ($('closemenu')) {$('closemenu').morph({'opacity' : 1});}
	}
	
	//Si image fiche prod
	if ($('surbuyme')) {$('surbuyme').setStyle('opacity',0);}
	if ($('roteme')) {
		//Recentrage vertical
		h=$('roteme').getChildren(); var t=h[0].getStyle('height');
		var dif=600-t.toInt();
		if (dif>0) { var dif2=dif/2; h.each(function(el,i) {el.setStyle('margin-top',dif2)}); }
		$$('#roteme span.spcopyright').each(function(el,i){
		if (i==0) { children = el.getChildren(); if (children[0].get('name')) {el.setStyle('opacity',1);} else {el.setStyle('opacity',0);}} else {el.setStyle('opacity',0); }
		
	});
		
		if ($('surroteme')) {(function(){$('surroteme').morph({'opacity' : 0});}).delay(500);}		
	}
	
	//Routine pour mettre en place actif sur coloris et/ou modele
	if ($('roteme')) {
	var timg=$$("#roteme img");
	var tnumber=$$("#ctrtofnumber a.anumber");
	
	if ($('maislaunc') && $('maislaunc').value!="") {
		var lindice=$('maislaunc').value-1;
		var lelem=timg[lindice]; if (tnumber[lindice]) {tnumber[lindice].addClass('onview'); tnumber[lindice].getParent().addClass('actif'); }
		} else { var lelem=timg[0]; }
	
	var tabelem=lelem.get('id').split('_');
	
	Bibi.checkPriceRef(tabelem[1]);
	if (lelem.get('id')=="zoom_1") {
		
} else {
		var tabtab = lelem.get('id').split('_');
		if ($('elcoloris')) {
			var u=0;
			while ($('elcoloris').options[u]) {
				if (tabtab[1]==$('elcoloris').options[u].value) {$('elcoloris').options[u].selected=true; }
				u+=1;
			}
			$$("#contenu a.achangecoul").each(function(el){
				if (el.get('name')==tabtab[1]) {el.getParent().addClass('actif'); } else {el.getParent().removeClass('actif');}
			});
			
		}
		if ($('elmodele')) {
			var u=0;
			while ($('elmodele').options[u]) {
				if (tabtab[1]==$('elmodele').options[u].value) {$('elmodele').options[u].selected=true; }
				u+=1;
			}
			$$("#lesmod2 a.amod2").each(function(el){
				if (el.get('name')==tabtab[1]) {el.getParent().addClass('actif');} else {el.getParent().removeClass('actif');}
			});
		}
	}
	}
	
	if ($('surrayons')) {(function(){$('surrayons').morph({'opacity' : 0});}).delay(500);}
	if ($('lenbrdobjtofind')) {(function(){$('lenbrdobjtofind').morph({'opacity' : 1,'margin-top':0});}).delay(800);}
	
},
initPanSlide:function() {
	//Init Pano Droite FICHE PROD
	if ($$('.ficheslide')) { $$('.ficheslide').each(function(el, i) {el.setStyle('opacity', 0);}); }
	if ($('abio')) {  Bibi.CheckZoom('0'); $('abio').addEvent('click',Bibi.switchPan.pass(['fichebio'])); }
	if ($('ainfo')) { $('ainfo').addEvent('click',Bibi.switchPan.pass(['ficheinfo'])); }
	if ($('abuy')) { $('abuy').addEvent('click',Bibi.switchPan.pass(['fichebuy'])); }
	if ($('amini')) { $('amini').addEvent('click',function(event){ event.stop(); Bibi.switchBarreBas('mini','0'); }); }
	if ($('closequick')) { $('closequick').addEvent('click',function(){ Bibi.switchBarreBas('mini','1'); }); }
	if ($('amesfav')) { $('amesfav').addEvent('click',function(){ Bibi.switchBarreBas('favo','0');});}
	if ($('closefav')) {$('closefav').addEvent('click',function(){Bibi.switchBarreBas('favo','1');});}	
	if ($('aspktofriend')) {$('aspktofriend').setStyles({'display':'none','opacity':0,'visibility':'hidden'}); }
	if ($('aaddtofav')) { $('aaddtofav').setStyles({'display':'none','opacity':0,'visibility':'hidden'}); }
	if ($('warncoul')) {$('warncoul').setStyle('opacity', 0);}
	if ($('warnmod')) {$('warnmod').setStyle('opacity', 0);}
	if ($('closemenu')) {
		$('closemenu').setStyle('opacity', 0);
		$('closemenu').addEvent('click',function(){		
		$('closemenu').setStyle('opacity', 0);
		

			if ($('fichemenu').getStyle('opacity')==0) {
					Bibi.switchPan('fichemenu');
				} else {
				//Sinon on ouvre le menu
					//Bibi.switchPan('ferme');
					//alert($('fenactive').value);
				if ($('fenactiveback')) {	Bibi.switchPan($('fenactiveback').value);} else {Bibi.switchPan('ferme');}
					
				}
		});
	}
},
initCtrlBar:function() {
	if ($$('#contenu a.achangecoul')) {
		var myTab = $$('#contenu a.achangecoul');
		myTab.each(function(el, i) {
		tabdescoulbis = $$('#coulbarinfo ul li a');
		
		tabdesbullescoul=$$('#bubblewrapcoul div.bubble');
			var lacouleur = el.get('name');
			var test = lacouleur;

			
			ideux=i+1;
			if (el.getParent().getParent().get('id')=="ulcoul") {
			if ($('elmodele')) {
					var testimg = "zoom_"+lacouleur+"-"+$('elmodele').options[1].value;
					} else {var testimg = "zoom_"+lacouleur; }
			
			
					
					if ($(testimg)) {
						var leclone = $(testimg).clone().setStyles({'width':50, 'height':50});
						var myAnchorA = new Element('div', { 'class': 'bubble num'+ideux, 'id':'coulbibi'+i});
						var myAnchorI = new Element('img', { 'width':50, 'height':50, 'src':$(testimg).get('src')});
						//alert($(testimg).get('src'));
					
					
					//alert('done');
					limage='<img src="'+$(testimg).get('src')+'" width="50" height="50">';
					myAnchorA.set('html',limage).setStyle('opacity',0).inject('bubblewrapcoul');
					} else {
					//test cas model et coul
					
					}
			}
			
			var lea="zoom_"+test;

			el.addEvents({
				'click':function(event){ 
					if (event) {event.stop();}
					if ($('elmodele') && $('elmodele').value=="0") {
						$('elmodele').options[0].selected=false; $('elmodele').options[1].selected=true;
					}
					if (tabdesbullescoul[i]) {tabdesbullescoul[i].morph({ 'opacity' : 0, 'margin-top' : 0 });}
				Bibi.changeCoulOrMod(test,"0");
				Bibi.checkPriceRef(test);
				},
				'mouseenter': function() {
					if (!el.getParent().hasClass('actif') && tabdesbullescoul[i]) { tabdesbullescoul[i].morph({ 'opacity' : 1, 'margin-top' : '5px' }); }
				},
				'mouseleave' : function() {
					if (tabdesbullescoul[i]) { tabdesbullescoul[i].morph({ 'opacity' : 0, 'margin-top' : 0 });}
				}
		
		});
		});
	}
	//idem pr le select COLORIS
	if ($('elcoloris')) {
		$('elcoloris').addEvent('change',function(){
			if ($('elcoloris').value!="0") {
			if ($('elmodele') && $('elmodele').value=="0") {
				$('elmodele').options[0].selected=false; $('elmodele').options[1].selected=true;
			}
			lacouleur = $('elcoloris').value;
			var test = lacouleur;
		
			Bibi.changeCoulOrMod(test,"0");
			Bibi.checkPriceRef(test);
			if ($('warncoul') && $('warncoul').get('opacity')>0) { $('warncoul').morph({'margin-top':0,'opacity':0}); }
			}				
		});	
	}
	
	//idem pr le select form buy MODELE
	if ($('elmodele')) {
		$('elmodele').addEvent('change',function(){
			if ($('elmodele').value!="0") {
			if ($('elcoloris') && $('elcoloris').value=="0") {
				$('elcoloris').options[0].selected=false; $('elcoloris').options[1].selected=true;
			}
			lacouleur = $('elmodele').value;
			var test = lacouleur;
		
			Bibi.changeCoulOrMod("0",test);
			Bibi.checkPriceRef(test);
			if ($('warnmod') && $('warnmod').get('opacity')>0) { $('warnmod').morph({'margin-top':0,'opacity':0});}
			}
		});	
	}

	if ($$('.countertof a.anumber')) {
		var myPagesTof = $$('.countertof a.anumber');
		var myBubblesTof = $$('#bubblewraptof .bubble');
		myBubblesTof.setStyle('opacity', 0);
		myPagesTof.each(function(el, i) {
			el.set('morph', {link : 'cancel'});
			el.addEvents({
				'mouseenter': function() {
					if (!el.hasClass('onview')) { myBubblesTof[i].morph({ 'opacity' : 1, 'margin-top' : '5px' }); }
				},
				'mouseleave' : function() {
					myBubblesTof[i].morph({ 'opacity' : 0, 'margin-top' : 0 });
				},
				'click' : function(){
					$$('.countertof a.anumber').each(function(ele) { ele.removeClass('onview'); ele.getParent().removeClass('actif'); });
					el.addClass('onview'); el.getParent().addClass('actif');
					myBubblesTof[i].morph({ 'opacity' : 0, 'margin-top' : 0 });
					if ($$('#contenu a.achangecoul')) {
						$$('#contenu a.achangecoul').each(function(elem) { 
							elem.removeClass('onview'); elem.getParent().removeClass('actif'); 
						});
					}
					if ($$('a.amod2')) {$$('a.amod2').each(function(ele) { ele.removeClass('onview'); ele.getParent().removeClass('actif'); });}

					
					if (el.get('id')!="numyoutube") {
					y=i+1; 
					//Afficher la 1 si elle existe attention cas des couleurs ets pls tofs
					if ($("zoom_"+y)) {Bibi.PixShowMe("zoom_"+y); Bibi.checkPriceRef(y);} else {
						
						var toto=$$('#roteme img');
						var lindi=y-1;
						
						if (toto[lindi]) {
							Bibi.PixShowMe(toto[lindi].get('id')); 
							var ici=toto[lindi].get('id').split('_');
							Bibi.checkPriceRef(ici[1]);
							}
						else {
							Bibi.PixShowMe(toto[0].get('id')); 
							var ici=toto[0].get('id').split('_');
							Bibi.checkPriceRef(ici[1]);
							 }
						
						
					}
				} 
				}
			});
			
			
		});
	}
	
	
	
	
	if ($$('a.amod2')) {
		var myPagesTof = $$('a.amod2');
		//var myBubblesTofMod = $$('#bubblewrapmod .bubble');
		//myBubblesTofMod.setStyle('opacity', 0);
		//if (!($('hprodmarque'))) {$('bubblewrapmod').setStyle('top',120);}
		
		
		var tabdesmodbis = $$('#lesmod2info ul li a');
		
		myPagesTof.each(function(el, i) {
			el.set('morph', {link : 'cancel'});
			y = el.get('name');
			
			ideux=i+1;
			if ($('elcoloris')) {
					var testimg = "zoom_"+$('elcoloris').options[1].value+"-"+y;
					} else {var testimg = "zoom_"+y; }
		//	var testimg = "zoom_"+y; 
			
			if ($('elcoloris') && $('elcoloris').value=="0") { $('elcoloris').options[0].selected=false; $('elcoloris').options[1].selected=true;  }
		/*if ($('elcoloris')) {
			var testimg2 = "zoom_"+$('elcoloris').value+"-"+y;
			} else {var testimg2="zdezd";}*/
			
					if ($(testimg)) {
						var leclone = $(testimg).clone().setStyles({'width':50, 'height':50});
						var myAnchorA = new Element('div', { 'class': 'bubble num'+ideux, 'id':'modbibi'+i});
						var myAnchorI = new Element('img', { 'width':50, 'height':50, 'src':$(testimg).get('src')});
						//alert($(testimg).get('src'));
					
					
					//alert('done');
					limage='<img src="'+$(testimg).get('src')+'" width="50" height="50">';
					myAnchorA.set('html',limage).setStyle('opacity',0).inject('bubblewrapmod');
					//myAnchorI.inject(myAnchorA);
					if (tabdesmodbis[i]) {tabdesmodbis[i].set('html',''); myAnchorI.inject(tabdesmodbis[i]).setStyles({'width':50,'height':50});}
					
					} else {
					if ($(testimg2)) {
						var leclone = $(testimg2).clone().setStyles({'width':50, 'height':50});
						var myAnchorA = new Element('div', { 'class': 'bubble num'+ideux, 'id':'modbibi'+i});
						var myAnchorI = new Element('img', { 'width':50, 'height':50, 'src':$(testimg2).get('src')});
						//alert($(testimg).get('src'));
					
					
					//alert('done');
					limage='<img src="'+$(testimg2).get('src')+'" width="50" height="50">';
					myAnchorA.set('html',limage).inject('bubblewrapmod');
					//myAnchorI.inject(myAnchorA);
					if (tabdesmodbis[i]) {tabdesmodbis[i].set('html',''); myAnchorI.inject(tabdesmodbis[i]);}
					
					}
					}

			el.addEvents({
				'mouseenter': function() {
					if (!el.hasClass('onview') && $('modbibi'+i)) { $('modbibi'+i).morph({ 'opacity' : 1, 'margin-top' : 5 }); }
				},
				'mouseleave' : function() {
					if ($('modbibi'+i)) { $('modbibi'+i).morph({ 'opacity' : 0, 'margin-top' : 0 }); }
				},
				'click' : function(){
					if ($('elcoloris') && $('elcoloris').value=="0") { $('elcoloris').options[0].selected=false; $('elcoloris').options[1].selected=true; }
					
					$$('#lesmod2 ul li a.amod2').each(function(ele) { ele.removeClass('onview'); if (ele.getParent()){ele.getParent().removeClass('actif'); }});
					//k=0; while(myPagesTof[k]) {myPagesTof[k].removeClass('onview'); if (myPagesTof[k].getParent()) {myPagesTof[k].getParent().removeClass('actif');}  k++;}
					el.addClass('onview'); el.getParent().addClass('actif');
					if ($$('a.anumber')) {$$('a.anumber').each(function(ele) { ele.removeClass('onview'); ele.getParent().removeClass('actif'); });} 
					//tabdesmodbis.each(function(ele) { ele.removeClass('onview'); ele.getParent().removeClass('actif'); });
					if ($('modbibi'+i)) {$('modbibi'+i).morph({ 'opacity' : 0, 'margin-top' : 0 });}
					y = el.get('name');
					Bibi.changeCoulOrMod("0",y);
					Bibi.checkPriceRef(y);
					
				}
			});
						
		});
	} 
	
	if ($$('#memeserie ul li a')) {
	tabserie=$$('#bubblewrapserie div.bubble');
	tabserie.setStyle('opacity',0);
	$$('#memeserie ul li a').each(function(el,i){
	
	el.addEvents({
				'mouseenter': function() {
					tabserie[i].morph({ 'opacity' : 1, 'margin-top' : 5 }); 
				},
				'mouseleave' : function() {
					tabserie[i].morph({ 'opacity' : 0, 'margin-top' : 0 });
				}
			});
	});
	}
	
	if ($$('a.amodinfo')) {
		var myPagesTof = $$('a.amodinfo');
		
		myPagesTof.each(function(el, i) {
			//el.set('morph', {link : 'cancel'});
			y = el.get('name');
			
			ideux=i+1;

		el.addEvents({
				
				'click' : function(){
					if ($('elcoloris') && $('elcoloris').value=="0") {
				$('elcoloris').options[0].selected=false; $('elcoloris').options[1].selected=true;
			}
					//myPagesTof.each(function(ele) { ele.removeClass('onview');  });
					//el.addClass('onview'); 
					if ($$('a.anumber')) {$$('a.anumber').each(function(ele) { ele.removeClass('onview');  });} 
					y = el.get('name');
					
										
					Bibi.changeCoulOrMod("0",y);
					Bibi.checkPriceRef(y);
					
				}
			});
			});
	}
	//MAZ des opacites/action/comportement des btns non utilisables
	//NEXT_PrEV
	if ($('anext') && $('anext').hasClass('off')) {$('anext').setStyles({'opacity':'.25','cursor':'default'});}
	if ($('aprev') && $('aprev').hasClass('off')) {$('aprev').setStyles({'opacity':'.25','cursor':'default'});}
	//ZOOM IN-OUT

	if ($$('.controlzoom a.plien')) {
		var myPages = $$('.controlzoom a.plien');
		var myBubbles = $$('#bubblewrap .bubble');
		myBubbles.setStyle('opacity', 0);
		myPages.each(function(el, i) {
			el.set('morph', {link : 'cancel'});
			el.addEvents({
				'mouseenter': function() {
					if (!el.hasClass('off')) {
					myBubbles[i].morph({ 'opacity' : 1,'margin-top' : '5px'});
					}
				},
				'mouseleave' : function() {
					//if ( !el.hasClass('off')) {
					myBubbles[i].morph({'opacity' : 0,'margin-top' : 0});
					//}
				},
				'click' : function() {
					
					myBubbles[i].setStyles({'opacity' : 0,'margin-top' : 0});
					
				}	
			});
		});
	}
	
	if ($('aaddtofav')) {$('aaddtofav').setStyle('display','none');}
	if ($('aspktofriend')) {
	$('aspktofriend').setStyle('display','none');	
	
		$('aspktofriend').addEvent('click',function(){
			$('amidiv').set('morph', {duration:1000,'transition': Fx.Transitions.Back.easeOut,onComplete:function(){
				/*$('formami').set('morph',{duration:1000});
				$('formami').morph({'opacity':1});*/
				$('formami').fade('in');
				
			}});
			$('amidiv').morph({'opacity':1,'height':285});
			if ($('sharemoi')) {$('sharemoi').setStyle('visibility',''); }
		});
		if ($('famireturn')) {
			$('famireturn').addEvent('click',function(){
					/*$('amidiv').set('morph', {duration:1500,'transition': Fx.Transitions.Back.easeInOut,onStart:function(){
					$('formami').set('morph',{duration:1000});
					$('formami').morph({'opacity':0});
					
					}
			});
			$('amidiv').morph({'opacity':0,'height':0}); */
			$('amidiv').setStyles({'opacity':0,'height':0});
			$('formami').setStyle('opacity',0);
			
		});
		}
		if ($('formami')) {
			$('formami').set('send', {url: 'contactami.php', method: 'post',onSuccess: function(responseText, responseXML) {
				$('suramime').addClass('okay');	
				(function(){
				$('surroteme').morph({'opacity' : 0});
				$('suramime').morph({'opacity' : 0});
				}).delay(1000);
					
			} });
			

		}
		if ($('famivalid')) {
			$('famivalid').addEvent('click',function(){ 
				
				if ($('hprodtitre')) {$('zamiprodnom').value=$('hprodtitre').get('text');}
				if ($('hproddesigner')) {$('zamiprodby').value=$('hproddesigner').get('text');}
				if ($('hprodmarque')) {$('zamiprodmark').value=$('hprodmarque').get('text');}
				tabrot=$$('#roteme img');
				tabrot.each(function(el){if(el.getStyle('opacity')==1) {$('zamiprodimg').value=el.get('src');}});
				
				$('holdformami').setStyle('background-position','center 5px');
				//$('formami').fade('out');
				$('amidiv').setStyles({'opacity':'0','visibility':'hidden','height':0});
				$('formami').setStyle('opacity','0');
				
				$('surroteme').morph({'opacity' : .5});
				$('suramime').morph({'opacity' : 1});
				(function(){$('formami').send();}).delay(1000);
				/*$('amidiv').set('morph',{duration:1000});
				$('amidiv').morph({'opacity':.5,'height':80,'transition': Fx.Transitions.Back.easeInOut,onComplete:function(){}});*/
				
			});
		}
	}
	
	
	
},
CheckZoom:function(x) {
	var zMoins=0; var zPlus=0; var idMoins=""; var idPlus="";
	var tabzoom = $$("#roteme img");
	if (x==0) {	var lenomtodeal = tabzoom[0].get('id');} else {var lenomtodeal = x;}
	var splited=lenomtodeal.split("_");
	//quel cas de figure
	if (splited[1]!="Zoom") { //cas par defaul premiere image affichee
		if ($('zoom_Zoom_'+splited[1]+'_2')) {zPlus=1; idPlus="zoom_Zoom_"+splited[1]+"_2";}
	} else {
		if (splited[3]=="2") { zMoins=1; idMoins="zoom_"+splited[2]; if ($('zoom_Zoom_'+splited[2]+'_3')) {zPlus=1; idPlus="zoom_Zoom_"+splited[2]+"_3";} }
		if (splited[3]=="3") { zMoins=1; idMoins="zoom_Zoom_"+splited[2]+"_2"; zPlus=0; }
	}
	//alert("zMoins="+zMoins+" zPlus="+zPlus+" idMoins="+idMoins);
	if (zPlus==1 && $('azoomin')) {
		$('azoomin').removeEvents('click');  $('azoomin').setStyles({'opacity':1,'cursor':'pointer'}); $('azoomin').removeClass('off');

		$('azoomin').addEvent('click',function(){Bibi.PixShowMe(idPlus)});
	} else {$('azoomin').setStyles({'opacity':.25,'cursor':'default'}); $('azoomin').addClass('off'); }
	if (zMoins==1 && $('azoomout')) {
		$('azoomout').removeEvents('click');  $('azoomout').setStyles({'opacity':1,'cursor':'pointer'}); $('azoomout').removeClass('off');
		$('azoomout').addEvent('click',function(){Bibi.PixShowMe(idMoins)});
	} else {$('azoomout').setStyles({'opacity':.25,'cursor':'default'}); $('azoomout').addClass('off');}
	if (zPlus==0 && zMoins==0) {
		$('azoomout').removeEvents('click'); $('azoomin').removeEvents('click');
		$('azoomout').addClass('off'); $('azoomin').addClass('off');
		$('azoomin').setStyles({'opacity':0,'cursor':'default'}); $('azoomout').setStyles({'opacity':0,'cursor':'default'});
	}
},
PixShowMe:function(idpix) {
	//alert(idpix);
	$$('#roteme img').each(function(el,i){
		if (el.getStyle('opacity')==1) {el.fade('out'); }  
	});
	$$('#roteme span.spcopyright').each(function(el){
		el.setStyle('opacity',0); 
	});
	
	if ($('you')) {$('you').setStyle('display','none');}
	
	$(idpix).fade('in');
	var children = $('elsp_'+idpix).getChildren();
	//alert(children[0].get('name'));
	if ($('elsp_'+idpix) && children[0].get('name') ) { 
 $('elsp_'+idpix).fade('in');}
	//teste si image est plus grande que 700 et dans ce cas on ferme Bibi.switchPan('ferme')
	taillimg = $(idpix).getCoordinates();
	if (taillimg.width>700) {
		Bibi.switchPan('ferme');
		//et aussi le prix
		if ($('zeprice')) {$('zeprice').fade('out');}
		if ($('divcondi')) {$('divcondi').fade('out');}
		if ($('paulieude')) {$('paulieude').fade('out');}
		
		} 
	else {
		var stop=0;
		$$('div.ficheslide').each(function(eleme) {if (eleme.hasClass('ouvert')) {stop=1;} });
		lafen = $('fenactive').value;
		if (stop==0 && !$(lafen).hasClass('ouvert')) {Bibi.switchPan(lafen); if ($('zeprice')) {$('zeprice').fade('in');}
		if ($('divcondi')) {$('divcondi').fade('in'); if ($('paulieude')) {$('paulieude').fade('in');}}}
	}
	//check zoom sur la tof ou nom 
	Bibi.CheckZoom(idpix);
},
MajIndice:function(idpic) {	
	
	var TabPic = idpic.split('_');
	var TabPicDeux = TabPic[1].split('-');
	if (TabPicDeux[1]) {
		var lemodeltocomp=TabPicDeux[1]; var lacoultocomp=TabPicDeux[0];
	} else {
	 	var lemodeltocomp=TabPic[1]; var lacoultocomp=TabPic[0];
	}
		
	//Carre modele
	if ($$("#lesmod2 a.amod2")) {
		$$("#lesmod2 a.amod2").each(function(ele){
			var teste="zoom_"+ele.get('name');
			if (teste==idpic) { //mep carre coul
				$$("#lesmod2 a.amod2").each(function(el){
							el.getParent().removeClass('actif');
						});
						ele.getParent().addClass('actif');
						//mep select coul
						var u=0;
						while ($('elmodele').options[u]) {
							$('elmodele').options[u].selected=false;
							var lemodu = $('elmodele').options[u].value;	
							var alorsu = "zoom_"+Bibi.remixStr(lemodu);
							//alert(teste);
							if (alorsu==teste) {
								$('elmodele').options[u].selected=true; 
								
							}
							u+=1;
						}
						
						//Maj prix ?
						Bibi.checkPriceRef(ele.get('name'));
					
					}
	});
	}
	
	//Carre coul
	if ($$("#contenu a.achangecoul")) {
	$$("#contenu a.achangecoul").each(function(ele){
					var teste="zoom_"+ele.get('name');
					if (teste==idpic) {
						//mep carre coul
						
						$$("#contenu a.achangecoul").each(function(el){
							el.getParent().removeClass('actif');
						});
						ele.getParent().addClass('actif');
						//mep select coul
						var u=0;
						while ($('elcoloris').options[u]) {
							$('elcoloris').options[u].selected=false;
							var lemodu = $('elcoloris').options[u].value;	
							var alorsu = "zoom_"+Bibi.remixStr(lemodu);
							if (alorsu==teste) {
								$('elcoloris').options[u].selected=true;
									
							}
							u+=1;
						}
					
					}
	});
	}

},
checkPriceRef:function(y) {
	/* longdesc = ref_prix --- $('dPrice') is an input to keep the default price */
	//alert(y);
	var notcoul=0;
	var notmod=0; var both=0; var modtoput=0; var coultoput=0;
	var tabLongDesc="";
	if ($('elcoloris') && $('elmodele')) {
	
		var z1=$('elmodele').value;
		var z2=$('elcoloris').value;
		var t1="zoom_"+y+"-"+z1;
		var t2="zoom_"+z2+"-"+y;
		
		if ($(t1)) {var goodId=t1; var modtoput=z1; var coultoput=y; var notcoul=1;} else{if($(t2)){var goodId=t2;
		 var modtoput=y; var coultoput=z2; var notmod=1;} else {var both=1; }}
		//alert(goodId);
		if ($(goodId)){var tabLongDesc = $(goodId).get('longdesc');}
	
	
	}
	else {if ($("zoom_"+y)) {var tabLongDesc = $("zoom_"+y).get('longdesc'); var goodId="zoom_"+y; var modtoput=y; var coultoput=y;} }
	
	//if (both==1) {alert(y);}
	
	//alert('modtoput='+modtoput+' et coultoput='+coultoput);
	//alert(tabLongDesc);
	if (tabLongDesc!="") {
	
	
	var splitedDesc=tabLongDesc.split("_");
	if (splitedDesc[0]) {var reelref=splitedDesc[0];} else {var reelref=$('dRef').value;}
	if (splitedDesc[1]) {var reelprice=splitedDesc[1];} else {var reelprice=$('dPrice').value;}
	//maj des prix et ref
	if (reelprice!="") {var nprice=reelprice+' <span class="elprix">&euro;</span>'; $('zeprice').set('html',nprice);
	$('elreelprix').value = reelprice;
	}
	if (reelref!="") {var nref=reelref; $('elreelref').value = nref;}
	//maj des select
	if ($('elmodele')) {
		var newcondi="0";
		//if (notmod==0) {
		var a=0;  
		while ($('elmodele').options[a]) {
			if ($('elmodele').options[a].value==modtoput) 
			{$('elmodele').options[a].selected=true; var newcondi = $('elmodele').options[a].text; var newcondiprog = $('elmodele').options[a].value; } else { $('elmodele').options[a].selected=false;} 
			a=a+1;
		}
		
		//changement du condi selon le modele
		if ($('changecondibymod') && $('changecondibymod').value=="oui") {
			var tavant="", tapres="";
			if ($('txtavant') && $('txtavant').value!="") {tavant=$('txtavant').value;}
			if ($('txtapres') && $('txtapres').value!="") {tapres=$('txtapres').value;}
			//alert(newcondi);
			if ($('translatecondimod') && $('translatecondimod').value!="") {
				var tabzero =  $('translatecondimod').value.split('*');
				var u=0;
				while (tabzero[u] && tabzero[u]!="") {
					var tabdeux = tabzero[u].split('=');
					if (tabdeux[0]==newcondi) {newcondi=tabdeux[1];}
					u=u+1;
				} 
			}
			if ($('utilaussiprmod') && $('utilaussiprmod').value=="oui") {
				var tabzero =  $('translatecondimod').value.split('*');
				var tablette = $$('');
				$$("#lesmod2 a.amod2").each(function(ele,i){
					var u=0;
					while (tabzero[u] && tabzero[u]!="") {
						var tabdeux = tabzero[u].split('=');
						if (tabdeux[0]==ele.get('text')) {ele.set('text',tabdeux[1]); $('elmodele').options[i+1].text=tabdeux[1];}
						u=u+1;
					} 
				
				});
			}
			var toput="<p class=\"pcondi\">"+tavant+" "+newcondi+" "+tapres+"</p>";
			
			if ($('changecondirestrict') && $('changecondirestrict').value!="") {
				var tabzero =  $('changecondirestrict').value.split('*');
				var tablette = $$('');
				var u=0; var okgo=0;
				while (tabzero[u] && tabzero[u]!="") {
				if (newcondiprog==tabzero[u]) {okgo=1;}
				u=u+1;
				}
				
				
				if (okgo==1) {$('divcondi').set('html',toput);} 
				else {toput="<p class=\"pcondi\">"+tavant+" "+$('condibackup').value+" "+tapres+"</p>"; $('divcondi').set('html',toput);}
			} else {
				$('divcondi').set('html',toput);
			 }
		
		}
		
		
		
		//}
		$$("#lesmod2 a.amod2").each(function(ele){
			ele.getParent().removeClass('actif');  if (ele.get('name')==modtoput) {ele.getParent().addClass('actif');}
		});
		
	}
	if ($('elcoloris')) {
		//if (notcoul==0) {
		var a=0;  
		while ($('elcoloris').options[a]) {
			if ($('elcoloris').options[a].value==coultoput) 
			{$('elcoloris').options[a].selected=true; } else { $('elcoloris').options[a].selected=false;} 
			a=a+1;
		}
		//}
		$$("#contenu a.achangecoul").each(function(ele){
			ele.getParent().removeClass('actif'); if (ele.get('name')==coultoput) {ele.getParent().addClass('actif'); }
		});
	}	
	
	//maj de numeros de photo
	//il faut chercher sil existe un num correpondant au model/coul choisi, sinon tt mettre a off
	var tabdespics=$$("#roteme img");
	var tabdesnum=$$("#ctrtofnumber a.anumber");
	tabdesnum.each(function(el,i) {
		if (goodId==tabdespics[i].get('id')) {el.addClass('onview'); el.getParent().addClass('actif')} else {el.removeClass('onview'); el.getParent().removeClass('actif');}
	});
	}
	
},
remixStr:function(txt) {
	var test2 = str_replace("Chêne blanc","Cheneblanc",txt);
	test2 = str_replace("&eacute;","e",test2);
	return test2;

},
initNav:function(){
	
	
	/*produitrayons.php?id_rubrique=7*/
	
	
	if ($('elkado')) {
		$('elkado').addEvent('change',function() {
			if ($('elkado').checked==true) {
			$('dmesskado').setStyle('display','');
			} else {  $('dmesskado').setStyle('display','none'); }
			
		});
		$('elkado').addEvent('click',function() {
			if ($('elkado').checked==true) {
			$('dmesskado').setStyle('display','');
			} else {  $('dmesskado').setStyle('display','none'); }
			
		});
	}

	
	
	//Tipz
	if ($('closemenu')) {
	
		$('closemenu').addClass('tipzmenu').set('title','fermer le menu&nbsp;&nbsp;&nbsp;&nbsp;');
	}
	if ($$('.tipzmenu')) {
		var myTipsMenu = new Tips('.tipzmenu',{className:'benmenu', offset:{'x': -300, 'y': -5}, fixed:true});
		myTipsMenu.addEvent('show', function(tip, el){ tip.fade('in');  });
		myTipsMenu.addEvent('hide', function(tip, el){ tip.fade('out'); });
		if ($('closemenu')) {$('closemenu').addEvent('click',function(){myTipsMenu.hide();});}
	}
	
	if ($$('.tipzel')) {
		var myTips = new Tips('.tipzel',{className:'ben',offset:{'x': 16, 'y': 30}});
		myTips.addEvent('show', function(tip, el){ tip.fade('in'); });
		myTips.addEvent('hide', function(tip, el){ tip.fade('out'); });
		var bc=[];  var HaltAlt = $$('h5.h5dby');
		HaltAlt.each(function(el,i){ bc[i]=el.get('text'); el.setStyle('opacity','0'); });
		var HaltAlt2 = $$('.tipzel');
		HaltAlt2.each(function(el,i){ el.store('tip:text',bc[i]); });
	}
	
	if ($$('.tipzpay')) {
		var myTipsC = new Tips('.tipzpay',{className:'benpay', offset:{'x': 16, 'y': 10}});
		myTipsC.addEvent('show', function(tip, el){ tip.fade('in'); });
		myTipsC.addEvent('hide', function(tip, el){ tip.fade('out'); });
	}
	if ($$('.tipzcoul')) {
		var myTipsC = new Tips('.tipzcoul',{className:'benserie', offset:{'x': 16, 'y': 10}});
		myTipsC.addEvent('show', function(tip, el){ tip.fade('in'); });
		myTipsC.addEvent('hide', function(tip, el){ tip.fade('out'); });
	}
	if ($$('.tipzcopy')) {
		var myTipsCopy = new Tips('.tipzcopy',{ className:'bencopy', offset:{'x': 16, 'y': -5}});
		myTipsCopy.addEvent('show', function(tip, el){  tip.fade('in'); });
		myTipsCopy.addEvent('hide', function(tip, el){ tip.fade('out'); });
	}
	if ($$('.tipzprocess')) {
		var myTipsPro = new Tips('.tipzprocess',{className:'benprocess', offset:{'x': 16, 'y': 10}});
		myTipsPro.addEvent('show', function(tip, el){ if (tip.get('text')) { tip.fade('in');} });
		myTipsPro.addEvent('hide', function(tip, el){tip.fade('out');});
	}
	if ($$('.tipzserie')) {
		var myTipsSerie = new Tips('.tipzserie',{className:'benserie', offset:{'x': 16, 'y': 10}});
		myTipsSerie.addEvent('show', function(tip, el){ tip.fade('in'); });
		myTipsSerie.addEvent('hide', function(tip, el){ tip.fade('out'); });
	}

	
	//Eleiminates all old bad alt et tittle on img
	var HaltAlt = $$('#othersmod a img','#othersmod a','a.tipzel img','#roteme img');
	HaltAlt.each(function(el,i){el.set('title','');el.set('alt','');});

	//InitAllComportement boutons
	var myTabH5TableBtns = $$('#othersmod h5');
	var nbt=0;
	myTabH5TableBtns.each(function(h,y){
		h.setStyles({'opacity':0,'left':550,'position':'absolute','background-color':'#FFFFFF','font-size':'10px','font-weight':'normal','color':'#867766','margin-top':'-15px'});
		var coo=h.getNext().getCoordinates();
	  	nbt=nbt+coo.width;
	});
	var TableBtns = $$('#othersmod a');
	TableBtns.each(function(el,i){
		el.setStyle('opacity',.5);
		el.addEvents({
			'mouseenter' : function() { 
				var coo2=$('h3autre').getCoordinates();
				u=nbt+coo2.x;
				el.morph({ 'opacity' : 1}); 
				myTabH5TableBtns[i].set('morph',{duration: 1000,transition: Fx.Transitions.Sine.easeOut});
				myTabH5TableBtns[i].morph({ 'opacity' : 1,'left':u});  
			},
			'mouseleave' : function() { 
				el.morph({ 'opacity' : .5});
				myTabH5TableBtns[i].set('morph',{duration: 1000,transition: Fx.Transitions.Sine.easeIn});
				myTabH5TableBtns[i].morph({ 'opacity' : 0,'left':550});  
			}					
		});
	});

	
	
	
	
},
StylisePan:function() {
// SI PAGE PANIER
	var tabSpanCoul=$$('span.spcoloris');
	var tabSpanMod=$$('span.spmodele');
	tabSpanCoul.each(function(el,i) {
		var temp = $('spincoloris_'+i).get('text'); //alert(temp);
		temp = Bibi.remixStr(temp);
		var temp2=$('spinmodele_'+i).get('text');
		temp2 = Bibi.remixStr(temp2);
			if (temp=="") {
				if (temp2=="") {
					//cas pas coul et pas modele
					$$("#holdimgpan_"+i+" img.tocheck").each(function(ele,b) { if (b>0) { ele.destroy(); }
					else {ele.setStyle('opacity',1);} });
					el.destroy(); tabSpanMod[i].destroy();
				} else {
					//cas pas coul mais modele 
					$$("#holdimgpan_"+i+" img.tocheck").each(function(ele,b) { if (ele.get('rel')!=temp2) { ele.destroy(); }
					else {ele.setStyle('opacity',1);} });
					el.destroy(); tempemoi=str_replace("| m","m",tabSpanMod[i].get('html')); tabSpanMod[i].set('html',tempemoi);
				}
			} else {
				
				if (temp2=="") {
					//Cas coul et pas modele
					var letest=temp;
					tabSpanMod[i].destroy();
				} else {
					//cas coul et modele
					var letest=temp+"-"+temp2;
				}
				$$("#holdimgpan_"+i+" img.tocheck").each(function(ele) { 
					if (ele.get('rel')!=letest) {
						ele.destroy();  
					} else {ele.setStyle('opacity',1);}
				});
			}
		});
		
	//Tipz
				if ($$(".tipzpan")) {
					var bcpan=[];  var HaltAltPan = $$('div.myartdesc');
					HaltAltPan.each(function(el,i){ el.setStyles({'position':'absolute','margin':'-16px 0 0 25px','z-index':15}); });
					$$(".tipzpan").each(function(el,i){
						el.addEvents({
							'mouseenter' : function() {$('plusinfo').set('html',HaltAltPan[i].get('html'));},
							'mouseleave' : function() {$('plusinfo').set('html','');}
						})
					});
					
				}
	if ($('onmypan')) {$('onmypan').destroy();}
	
},
MakeServices:function() {
	var TabTitres = $$('ul#lestitresdos li h3');
	var TabCont = $$('ul#lescontdos li');
	TabCont.each(function(el,i) {el.setStyle('opacity','0');});
	TabTitres.each(function(el,i){
		el.addEvents({'click':function(){
			TabCont.each(function(ele) { ele.fade('out');});
			TabTitres.each(function(ele,ie) {if (ele==el) {TabCont[ie].fade('in');} 
			ele.removeClass('actif'); ele.setStyle('color','#AB957E');});
			el.addClass('actif'); el.setStyle('color','#FFF');
		},
		'mouseenter' : function() {if (!el.hasClass('actif')) {el.setStyle('color','#41281B');}},
		'mouseleave' : function() {if (!el.hasClass('actif')) {el.setStyle('color','#AB957E');}}
		});
	});
	if ($('mcview') && $('mcview').value!="") {TabTitres[$('mcview').value].fireEvent('click');}
	
	
},
initAll:function() {
	Bibi.initNav(); Bibi.initPanSlide(); 
	if ($('ctrprod')) {Bibi.initCtrlBar();}
	if ($('tabpan')) {Bibi.StylisePan();}
	if ($('lestitresdos')) {Bibi.MakeServices();}
},
changeCoulOrMod:function(coul,model) {
	//determiner le cas c/m/b coul/modele/both
	if (model=="0") {
		var cas="c"; if ($('elmodele')) {var cas="b"; model=$('elmodele').value;}
	} else {
		//coul==0
		var cas="m"; if ($('elcoloris')) {var cas="b"; coul=$('elcoloris').value;}
	}
	
	//if ($('elcoloris')) {var cas="c"; if ($('elmodele')) {var cas="b";}} else {if ($('elmodele')) {var cas="m";}}	
	if (cas=="c") {var picToTest = "zoom_"+coul;}
	if (cas=="m") {var picToTest = "zoom_"+model;}
	if (cas=="b") {var picToTest = "zoom_"+coul+"-"+model;}
	//on atrouve la bonne image
	if ($(picToTest)) { Bibi.PixShowMe(picToTest); } else {
		//cas premier click sur coul ou modele
	 }
},
doClick:function(x) {
//x= az1 / az1	
 //Init
	var bonul="ul#zelmenu  li.sous"+x+" a";
		var titi = $$(bonul);
	var ultoopen="ul#zelmenu li#ulsous"+x+" ul";
	var y="ulsous"+x;
	var labarre="scrollbar"+x;
	var lhandle="handle"+x;
	var ctscroll="toscroll"+x;
	var del=0;
	var totalh=0;
	var maxHeight=290;
	var noneedscroll=0;
		   //--
	var bonul="ul#zelmenu li.ulsous ul li.sous"+x+" a";
	var classul="sous"+x;
//alert(classul);
//On bouge les sous menu ouvert
	var totonotag = $$('ul#zelmenu li.ulsous ul li a.notag');
	totonotag.each(function(el){ 
		if (!el.getParent().hasClass(classul)) {
			el.set('morph', {duration: 'short', onComplete:function() {el.getParent().setStyle('height',0)}});
			el.morph({'opacity':0});
			//el.set('tween', {duration: 'short', onComplete:function() {el.getParent().setStyle('height',0)}});
			//el.tween('opacity', 0);
		}
	});
	//goTo 0 pr les scrollbars
	var hideul = $$('div.scrollbar-vert');
	hideul.each(function(el){ 
		 var wi=el.getCoordinates();
		 if (wi.height>0) {
			 	el.set('morph', {duration: '1000'});
				el.morph({'opacity': 0, 'height': 0});
		 }
	});
	//goTo 0 pr les cont qui scrolle
	var hideul2 = $$('div.ctscrolle');
	hideul2.each(function(el){ 
		 var wi=el.getCoordinates();
		 if (wi.height>0) {
			el.set('morph', {duration: '1000'});
			el.morph({'height': 0});
		 }
	});
	var totoin = $$('ul#zelmenu li a');
	totoin.each(function(el,i){
		if (el.get('id')!=x && !el.hasClass('notag')){
			el.removeEvents('click');
		 	el.morph({'font-size': '20px','line-height':'25%','color':'#41281B'});
		}
	});
	var myEffect = new Fx.Morph(x, {duration: 1000, wait:false, onComplete:function(ele) {
		totoin.each(function(elee,i){elee.removeClass('mactive');});
		ele.addClass('mactive');
		ele.removeEvent('click');
		var tototata = $$('ul#zelmenu li a');
		tototata.each(function(el,i){ 
			if (!el.hasClass('notag')){ el.addEvent('click',Bibi.doClick.pass([el.get('id')])); }
		});
	}});
	myEffect.start({ 'font-size': '50px','line-height':'58px','color':'#41281B','background':'transparent' });

	
	(function(){	
	var jeanben=0, jb=0;  
		titi.each(function(el,i){ 
			var wi=el.getCoordinates();
			var wi2=$(x).getCoordinates();
			var total = wi2.left - wi.left;
			totalh += wi.height.toInt();
			jeanben=i; jb=wi.height;
			el.setStyles({'margin-left':0,'margin-top':0});
			el.getParent().setStyle('height', wi.height);
			
			el.setStyle('opacity', 1);
			//(function(){ 
				/*el.set('tween', {duration: 'short'});
				el.tween('opacity', 1);*/
				//el.fade('in');
				//el.setStyle('opacity', 1);
				/*el.getParent().set('tween', {duration: '1000'});
				el.getParent().tween('height', wi.height);*/
				
				
			//}).delay(del);
			del += 25;
		}); // #END# titi.each
		
		 //alert(jeanben);
		//Ouverture du ul
		/*var scrollici = new Scroller(ctscroll, {area: 50, velocity: 0.2});
		scrollici.start();*/
		/*alert(totalh); totalh+=1*(jeanben+1);*/
		if (totalh>maxHeight) { tth=maxHeight; } else { totalh+=30; tth=totalh; noneedscroll=1;}
		$(y).set('tween', {duration: '1000',onComplete:function() {
			if (noneedscroll==0) {
				/*$(labarre).set('tween', {duration: '500'});
				$(labarre).tween('opacity', 1);*/
								
				$(labarre).fade('in');
				laslide=makeScrollbar2( $(ctscroll), $(labarre), $(lhandle) );
				
	if ($('isCateg')) {
		var valCateg = $('isCateg').value;
		if ($('OverisCateg')) {var valcateg = $('OverisCateg').value; }
		if (valCateg==998) {
						//mep du bo item selected
						if ($('liddesigner')) {
							$$("ul#ulsousaz5 li a").each(function(el,i) {
								if (el.get('name')=="nom_"+$('liddesigner').value) {el.addClass('selection'); 
								
								laslide.set(i*16);
								
								}
							});}
		}
		
		if (valCateg==999) {
						//mep du bo item selected
						if ($('liddesigner')) {
							$$("ul#ulsousaz4 li a").each(function(el,i) {
								if (el.get('name')=="nom_"+$('liddesigner').value) {el.addClass('selection'); 
								
								laslide.set(i*16);
								
								}
							});}
		}
		}

				
				
			}
		}});
		
		//CALAGE DES SS MENU AVEC MOT
		var un = $(x).getParent().getCoordinates();
		var deux = $(x).getCoordinates();
		var lemltomove = un.width - deux.width;
		//alert(lemltomove);
			var lemltomove2 = lemltomove -40;	
		//$(ctscroll).setStyle('height',tth);
		$(ctscroll).set('tween', {duration: '1000'});
		$(ctscroll).tween('height', tth);

		$(y).setStyles({'margin-left': lemltomove2+'px','height':totalh});
		//$(y).tween('height', totalh);
		$(y).tween('opacity', 1);
		//$(ctscroll).set('tween', {duration: '1000'});
		//$(ctscroll).tween('height', tth);
		
		if (noneedscroll==0) {
			/*$(labarre).set('tween', {duration: '1000'});
			$(labarre).tween('height', tth);*/
			$(labarre).setStyle('height',tth);
		}
		
		
		
		
	}).delay(1000);
	
	
	
	
},
doClickBibi:function(x) {
//x= az1 / az1	
 //Init
	var bonul="ul#zelmenu  li.sous"+x+" a";
		var titi = $$(bonul);
	var ultoopen="ul#zelmenu li#ulsous"+x+" ul";
	var y="ulsous"+x;
	var labarre="scrollbar"+x;
	var lhandle="handle"+x;
	var ctscroll="toscroll"+x;
	var del=0;
	var totalh=0;
	var maxHeight=290;
	var noneedscroll=0;
		   //--
	var bonul="ul#zelmenu li.ulsous ul li.sous"+x+" a";
	var classul="sous"+x;

	//On bouge les sous menu ouvert
	var totonotag = $$('ul#zelmenu li.ulsous ul li a.notag');
	totonotag.each(function(el){ 
		if (!el.getParent().hasClass(classul)) {
			el.setStyle('opacity',0);
			el.getParent().setStyle('height',0);
			//el.set('morph', {duration: 'short', onComplete:function() {el.getParent().setStyle('height',0)}});
			//el.morph({'opacity':0});
			
		}
	});
	//goTo 0 pr les scrollbars
	var hideul = $$('div.scrollbar-vert');
	hideul.each(function(el){ 
		 var wi=el.getCoordinates();
		 if (wi.height>0) { el.setStyles({'opacity': 0, 'height': 0}); }
	});
	//goTo 0 pr les cont qui scrolle
	var hideul2 = $$('div.ctscrolle');
	hideul2.each(function(el){ 
		 var wi=el.getCoordinates();
		 if (wi.height>0) { el.setStyle('height',0); }
	});
	var totoin = $$('ul#zelmenu li a');
	totoin.each(function(el,i){
		if (el.get('id')!=x && !el.hasClass('notag')){
			el.removeEvents('click');
		 	el.morph({'font-size': '20px','line-height':'25%','color':'#41281B'});
		}
	});
	var myEffect = new Fx.Morph(x, {duration: 1000, wait:false, onComplete:function(ele) {
		totoin.each(function(elee,i){elee.removeClass('mactive');});
		ele.addClass('mactive');
		ele.removeEvent('click');
		var tototata = $$('ul#zelmenu li a');
		tototata.each(function(el,i){ 
			if (!el.hasClass('notag')){ el.addEvent('click',Bibi.doClick.pass([el.get('id')])); }
		});
	}});
	myEffect.start({ 'font-size': '50px','line-height':'58px','color':'#41281B','background':'transparent' });

	
	(function(){	
	var jeanben=0, jb=0;  
		titi.each(function(el,i){ 
			var wi=el.getCoordinates();
			var wi2=$(x).getCoordinates();
			var total = wi2.left - wi.left;
			totalh += wi.height.toInt() ;
			jeanben=i; jb=wi.height;
			el.setStyles({'margin-left':0,'margin-top':0});
			el.getParent().setStyle('height', wi.height);
			
			el.setStyle('opacity', 1);
			
			del += 25;
		}); // #END# titi.each
		
		
		//Ouverture du ul
		
		if (totalh>maxHeight) { tth=maxHeight; } else { totalh+=30; tth=totalh; noneedscroll=1;}
		$(y).set('tween', {duration: '1000',onComplete:function() {
			if (noneedscroll==0) {
											
				$(labarre).fade('in');
				laslide=makeScrollbar2( $(ctscroll), $(labarre), $(lhandle) );
				
	if ($('isCateg')) {
		var valCateg = $('isCateg').value;
		if (valCateg==998) {
						//mep du bo item selected
						if ($('liddesigner')) {
							$$("ul#ulsousaz5 li a").each(function(el,i) {
								if (el.get('name')=="nom_"+$('liddesigner').value) {el.addClass('selection'); 
								
								laslide.set(i*16);
								
								}
							});}
		}
		if (valCateg==999) {
						//mep du bo item selected
						if ($('liddesigner')) {
							$$("ul#ulsousaz4 li a").each(function(el,i) {
								if (el.get('name')=="nom_"+$('liddesigner').value) {el.addClass('selection'); 
								
								laslide.set(i*16);
								
								}
							});}
		}
		}

				
				
			}
		}});
		
		//CALAGE DES SS MENU AVEC MOT
		var un = $(x).getParent().getCoordinates();
		var deux = $(x).getCoordinates();
		var lemltomove = un.width - deux.width;
		//alert(lemltomove);
			var lemltomove2 = lemltomove -40;	
		//$(ctscroll).setStyle('height',tth);
		$(ctscroll).set('tween', {duration: '1000'});
		$(ctscroll).tween('height', tth);

		$(y).setStyles({'margin-left': lemltomove2+'px','height':totalh});
		//$(y).tween('height', totalh);
		$(y).tween('opacity', 1);
		//$(ctscroll).set('tween', {duration: '1000'});
		//$(ctscroll).tween('height', tth);
		
		if (noneedscroll==0) {
			/*$(labarre).set('tween', {duration: '1000'});
			$(labarre).tween('height', tth);*/
			$(labarre).setStyle('height',tth);
		}
		
		
		
		
	}).delay(1000);
	
	
	
	
},
doAzapFprod:function(){
	
	
	
	if ($('ctrtofnumber').getStyle('width').toInt()<2) { $('ctrtofnumber').setStyle('display','none'); }
	/*translate*/
	if ($('transmodele') && $('transmodele').value!="") {
	
				var tabzero =  $('transmodele').value.split('*');
				var tablette = $$('');
				//var tabBis=$$("#lesmod2info a.amodinfo");
				$$("#lesmod2 a.amod2").each(function(ele,i){
					var u=0;
					while (tabzero[u] && tabzero[u]!="") {
						var tabdeux = tabzero[u].split('=');
						if (tabdeux[0]==ele.get('name')) {
							ele.set('title','<span>mod&egrave;le</span><br>'+tabdeux[1]); $('elmodele').options[i+1].text=tabdeux[1];
							//tabBis[u].set('title',tabdeux[1]);
							}
						u=u+1;
					} 
				
				});
				$$("#lesmod2info a.amodinfo").each(function(ele,i){
					var u=0;
					while (tabzero[u] && tabzero[u]!="") {
						var tabdeux = tabzero[u].split('=');
						if (tabdeux[0]==ele.get('name')) {
							//ele.set('title','<span>mod&egrave;le</span><br>'+tabdeux[1]); $('elmodele').options[i+1].text=tabdeux[1];
							ele.set('title',tabdeux[1]);
							}
						u=u+1;
					} 
				
				});
				
				
		
	}
	
	
	if ($('transcoloris') && $('transcoloris').value!="") {
	
				var tabzero =  $('transcoloris').value.split('*');
				var tablette = $$('');
				//var tabBis=$$("#lesmod2info a.amodinfo");
				$$("ul#ulcoul a.achangecoul").each(function(ele,i){
					var u=0;
					while (tabzero[u] && tabzero[u]!="") {
						var tabdeux = tabzero[u].split('=');
						if (tabdeux[0]==ele.get('name')) {
							ele.set('title','<span>coloris</span><br>'+tabdeux[1]); $('elcoloris').options[i+1].text=tabdeux[1];
							//tabBis[u].set('title',tabdeux[1]);
							}
						u=u+1;
					} 
				
				});
				$$("ul#ulcoulinfo li a").each(function(ele,i){
					var u=0;
					while (tabzero[u] && tabzero[u]!="") {
						var tabdeux = tabzero[u].split('=');
						if (tabdeux[0]==ele.get('name')) {
							ele.set('title',tabdeux[1]);
							}
						u=u+1;
					} 
				
				});
				
				
		
	}
	
	
	
	if ($('hproddesigner') && $('ispecial').value==1 && $('spchedesi')) { 
	$('spchedesi').set('text',$('hproddesigner').get('text'));
	$$("ul#ulsousaz1 li a.selection").each(function(el) {el.removeClass('selection');});
	$$("ul#ulsousaz4 li a").each(function(el) {if (el.get('text')==$('hproddesigner').get('text')) {el.addClass('selection');}});
	}
	if ($('ahprodmarque')) {
		var timar="nom_"+$('hprodmarque').get('title');
		$('hprodmarque').set('title','');
		
		$$('ul#ulsousaz5 li.sousaz5 a').each(function(el) { if (el.get('name')==timar) {
			$('ahprodmarque').set('href',el.get('href')); 
			if ($('spchemark')) {$('spchemark').set('href',el.get('href')); }
			} });
		
	}
	if ($('ahproddesigner')) {
		var timar="nom_"+$('hproddesigner').get('title');
		$('hproddesigner').set('title','');
		
		$$('ul#ulsousaz4 li.sousaz4 a').each(function(el) { if (el.get('name')==timar) {
			$('ahproddesigner').set('href',el.get('href')); 
			if ($('spchedesi')) {$('spchedesi').set('href',el.get('href')); }
			} });
		
	}
	
	if ($('elspeprix')) {
		var timar=$('elspeprix').get('text');
		$$('ul#ulsousaz3 li.sousaz3 a').each(function(el) { if (el.get('text')==timar) {
			el.addClass('selection');
			$('elspeprix').set('href',el.get('href')); 
			} });
	}
	
	if ($('elspecateg')) {
		var timar=str_replace(" - ","",$('elspecateg').get('text')).toLowerCase(); 
		
		$$('ul#ulsousaz2 li.sousaz2 a').each(function(el) { if (str_replace(" / ","",el.get('text')).toLowerCase()==timar) {
			el.addClass('selection');
			$('elspecateg').set('href',el.get('href')); 
			
		} else { //hack lampe a poser
		if ($('elspecateg').get('rel')=="73" && el.get('name')=="nom_29") {
			el.addClass('selection');
			$('elspecateg').set('href',el.get('href')); 
		}
		}  
		});
		
			
	}
	
	
	
	if ($('hprodmarque') && $('ispecial').value==1 && $('spchemark')) { 
	$('spchemark').set('text',$('hprodmarque').get('text'));
	} 
	if ($('hprodtitre') && $('hproddesigner') && $$('#roteme span.spcopyright') && !$('hprodmarque')) {
	$$('#roteme span.spcopyright').each(function(el) { el.addClass('notroisieme'); });
}
	
	
	
	
	
	
	
	$$('#roteme img').each(function(el, i) { 
	
	if (el.hasClass('imgdocu')) {
	var elpId = 'p'+el.get('id');
	$(elpId).setStyle('cursor','pointer');
	$(elpId).addEvent('click',function(){
		if ($$('.countertof a.anumber')) {$$('.countertof a.anumber').each(function(ele) {ele.removeClass('onview');});}
		if ($$('a.amod2')) {$$('a.amod2').each(function(ele) { ele.removeClass('onview'); ele.getParent().removeClass('actif'); });}
		if ($$('#contenu a.achangecoul')) {$$('#contenu a.achangecoul').each(function(ele) { ele.removeClass('onview'); ele.getParent().removeClass('actif'); });}
		
		Bibi.PixShowMe(el.get('id'));
		
	})
	} // FIN : if (el.hasClass('imgdocu'))
	
	//cas miniarure differente de la première fimg ds fiche prod
	if ($('maislaunc') && $('maislaunc').value!="") {
		var lindice=$('maislaunc').value-1;
		if (i!=lindice) {	el.setStyle('opacity',0); }
	} else {
	
	if (i!=0) {	el.setStyle('opacity',0); } 
	else {
		if ($('elcoloris')) {
		//mise en place des select coloris et reelref
		var a=0;  
		var test=el.get('longdesc');
		var coultab=el.get('id');
		var coultab2 = coultab.split('_');
		
		
		while ($('elcoloris').options[a]) {
			/*hack inverse pr le select Chêne blanc*/
			lacouleur = $('elcoloris').options[a].value;	
			var test2 =lacouleur;
			/*var test2 = str_replace("é","e",lacouleur);
			test2 = str_replace("ê","e",test);
			test2 = str_replace(" ","",test);*/
			if (test2==coultab2[1]) {$('elcoloris').options[a].selected=true; $('elreelref').value = test; } 
			else { $('elcoloris').options[a].selected=false;} 
			a=a+1;
		}
		}	
	}
	}
});
	if ($('youtube')) {
	//alert('youtube');
	var clone = $('youtube').clone().set('id','you');	
	clone.setStyles({'display':'none', 'padding':'145px 0 0 52px'});
	clone.inject('roteme');
	
	
	if ($('youtube').hasClass('pourbio')) {
	if ($$('img.tipzprocess')) {
	var tabanum=$$('img.tipzprocess');
	var lenum = tabanum.length +1;
	} else {
	var lenum = 1;
	}
	letexte='';
	if ($('youtubedescri')) {
		letexte = $('youtubedescri').get('text');
		
		}
	
	var myAnchor = new Element('a', {
    'href': '#',
    'id' : 'numyoutube',
    'class': 'anumber',
    'title' : letexte,
    'html': '<img src="pix/playtube.gif">',
    'events': {
        'click': function(){
            //alert('clicked');
            $$('#roteme img').each(function(el) {el.fade('out');});
            //$$('#ctrtofnumber a.anumber').each(function(el) {el.removeClass('onview'); el.getParent().removeClass('actif');});
            $('you').setStyle('display','');
        },
        'mouseover': function(){
            //alert('mouseovered');
        }
    }
});
		myAnchor.injectAfter(tabanum[tabanum.length-1]);
		
		
	} 
	else {
	
	
	if ($$('#ctrtofnumber a.anumber')) {
	var tabanum=$$('#ctrtofnumber a.anumber');
	var lenum = tabanum.length +1;
	} else {
	var lenum = 1;
	}
	var myAnchor = new Element('a', {
    'href': '#',
    'id' : 'numyoutube',
    'class': 'anumber',
    'html': lenum,
    'events': {
        'click': function(){
            //alert('clicked');
            $$('#roteme img').each(function(el) {el.fade('out');});
            $$('#ctrtofnumber a.anumber').each(function(el) {el.removeClass('onview'); el.getParent().removeClass('actif');});
            $('you').setStyle('display','');
        },
        'mouseover': function(){
            //alert('mouseovered');
        }
    }
});

	myAnchor.inject('ctrtofnumber');
	
	//Ajout de la vignette youtube
	//#bubblewraptof div.bubble num1
	var myAnchor2 = new Element('div', {
    
    'class': 'bubble num'+lenum,
    'html': '<img src="pix/playtube.gif">'
});
myAnchor2.inject('bubblewraptof');
}
	
		//alert('done');
	
	}
	
	
	if ($('aaddpan')) {
		
		
		//$('aaddpan').set('href','#');
		$('aaddpan').addEvent('click',function(event){
			event.stop();
			//if ($('fenpanier')) {toset='<p style="text-align:center"><br><br><img src="ajax-loader.gif" width="50" height="50"></p>';$('fenpanier').set('html',toset);}
			lienpan=$('urlpanbakup').value;
			//var lienpan="panierquick.php?action=ajouter&amp;append=1&amp;ref="+$('dRef').value;
			var okpass=okpasscoul=okpassmod=0;
			
			if (($('elcoloris') && $('elcoloris').value!="0") || (!$('elcoloris'))) {okpasscoul=1;}
			if (($('elmodele') && $('elmodele').value!="0") || (!$('elmodele'))) {okpassmod=1;}
			
			
			
			
			if (okpasscoul==1 && okpassmod==1) {
			
			/*if (($('elcoloris') && $('elcoloris').value!="0") || ($('elmodele') && $('elmodele').value!="0")
			|| (!$('elcoloris') && !$('elmodele'))) {*/
			
			if ($('elcoloris')) { lienpan = lienpan +'&coloris='+$('elcoloris').value;  }
			if ($('elmodele')) { lienpan = lienpan +'&modele='+$('elmodele').value; }
			if ($('elreelref')) { lienpan = lienpan +'&reelref='+$('elreelref').value; }
			if ($('elreelprix')) { lienpan = lienpan +'&reelprix='+$('elreelprix').value; }
			//alert(lienpan);
			var Table = $$('#roteme img');
			Table.each(function(el){
				if (el.getStyle('opacity')==1) {
					//var T=$('h3pan').getCoordinates();
					//var P=el.getCoordinates(); 
					//var clone = el.clone().setStyles({'position':'absolute','z-index':20000}).injectBefore(el);
					//el.morph({'opacity' : .5});
					$('surroteme').morph({'opacity' : .5});
					$('surbuyme').morph({'opacity' : 1});
					
					
					var dim=$('monpan').getCoordinates();
					
					var toset2='<span id="loadminpan" style="visibility:hidden"><br><br><img src="ajax-loader.gif" width="50" height="50" ></span>';
					$('monpan').set('html',toset2);
					
					//var newdiv = new Element('div',{'class':'loadingtemp','id':'onmypan'});
					//newdiv.inject('monpan');
					/* ######################## */
					/* ### REQUEST PANIER #### */
					/* ####################### */
					var myRequest = new Request({url: lienpan, method: 'post', encoding : 'iso-8859-1', 
					
					onSuccess: function(responseText, responseXML) {
   						$('loadminpan').setStyle('opacity',1);
   						var myRequest2 = new Request({url: 'panierfiche.php', method: 'post',
   							onSuccess: function(responseText2, responseXML2) {
   								if (!$('fenpanier').hasClass('noncharge')) {
   									topout='<p style="text-align:center"><br><br><img src="ajax-loader.gif" width="50" height="50"></p>';
   									$('fenpanier').set('html',topout);
   									$('fenpanier').addClass('noncharge');
   								}
   								$('monpan').set('html',responseText2);
   								
   								Bibi.StylisePan();
   								
   								if ($('reelnbinpan')) {
								toset=$('reelnbinpan').value+' article';
								if ($('reelnbinpan').value>1) {toset=toset+'s';}
								$('mycontpan').set('text',toset);
							}
   								
   								}
   						}).send();
   						
   							if ($('onmypan')) {$('onmypan').destroy();}
   							$('surroteme').morph({'opacity' : 0});
   							$('surbuyme').morph({'opacity' : 0}); 
   						
   					}
					}).send();
				} /* END if (el.getStyle('opacity')==1) */
			}); /* END Table.each */
			} else {
				//alert choix options article
				if ($('warncoul') && $('warncoul').get('opacity')==0 && okpasscoul==0) {
					$('warncoul').morph({'margin-top':5,'opacity':1});
					
					$('aclosewarncoul').addEvent('click',function(){
						$('warncoul').morph({'margin-top':0,'opacity':0});
					});
				}
				if ($('warnmod') && $('warnmod').get('opacity')==0 && okpassmod==0) {
					$('warnmod').morph({'margin-top':5,'opacity':1});
					
					$('aclosewarnmod').addEvent('click',function(){
						$('warnmod').morph({'margin-top':0,'opacity':0});
					});
				}
				
				//alert('Merci de choisir vos options');
				
			}
		}); /* END $('aaddpan').addEvent('click') */
	}
	
	if ($('aaddtofav')) {
		
		
		if ($('aaddtofav').hasClass('tipzcoul')) {
			$('aaddtofav').setStyles({'opacity':'.5','cursor':'default'});
			$('aaddtofav').addEvent('click',function(event){/*event.stop();*/ $('amesfav').fireEvent('click');});
		} 
		else {
			$('aaddtofav').addEvent('click',function(event){
				event.stop();
				if (!$('aaddtofav').hasClass('tipzafterfav')) {
				$('surroteme').morph({'opacity' : .5});
				$('surfavme').morph({'opacity' : 1});
				(function(){
					var lerekette = "ajoutfav.php?reffav="+$('dRef').value+"&action=addfav";
					var myRequeste = new Request({url: lerekette, method: 'post', evalScripts:false ,
					onSuccess: function(responseText, responseXML) {
						//$('resufav').set('html',responseText);
						/*
						$('loadfav').set('morph',{duration:500});
						$('loadfav').morph({'opacity':0});*/
						$('aaddtofav').addClass('tipzafterfav');
						tiptoset="<span>Cet article est d&eacute;j&agrave; enregistr&eacute; dans vos favoris</span><br>Cliquez pour afficher vos favoris";
						$('aaddtofav').set('title',tiptoset);
						$('aaddtofav').removeEvent('click');
						$('aaddtofav').setStyles({'opacity':'.5','cursor':'default'});
						$('aaddtofav').addEvent('click',function(event){event.stop(); $('amesfav').fireEvent('click');});	
						$('surfavme').addClass('okay');
						(function(){$('surfavme').morph({'opacity' : 0});
						$('surroteme').morph({'opacity' : 0});}).delay(1000);
						var myTipsAfter = new Tips('.tipzafterfav',{className:'benserie', offset:{'x': 16, 'y': 10}});
						myTipsAfter.addEvent('show', function(tip, el){ tip.fade('in'); });
						myTipsAfter.addEvent('hide', function(tip, el){ tip.fade('out'); });
					} 
				}).send();
			}).delay(1000);
			}
		});
		}
	}
	
	
	//miniatures fiche produit
	if ($('quickliste')) {
		
	/*var scroll4 = new Scroller('quickliste', {area: 100, velocity: 0.2});
		scroll4.start();
	*/	
		var tabTog=$$('#listesh5 h5 a');
		tabTog.each(function(el) {
			
				el.addEvent('click',function(event) {
					//scroll4.scrollTo(0, 0);
var myFx = new Fx.Scroll('quickliste').toLeft();



					$('quickliste').addClass('loading');
					temp=el.get('id');
					temp2=temp.split("_");
					if (event) {event.stop();}
					tabTog.each(function(ele) {ele.removeClass('selection');});
					$('slideinside').empty();
					var myRequest = new Request({
							url: 'produitrayons.php?id_rubrique='+temp2[1], 
							method: 'post', encoding : 'iso-8859-1',
							onSuccess: function(responseText, responseXML) {
								$('slideinside').set('html',responseText);
								var lataille = 0;
								$$('#slideinside ul li').each(function(elem,i){ lataille=lataille+85; }); ;
								
								$('slideinside').setStyle('width',lataille);
								$('quickliste').removeClass('loading');
								
								el.addClass('selection');
								if ($$('.tipzel')) {
		var myTips = new Tips('.tipzel',{className:'ben',offset:{'x': 16, 'y': 30}});
		myTips.addEvent('show', function(tip, el){ tip.fade('in'); });
		myTips.addEvent('hide', function(tip, el){ tip.fade('out'); });
		var bc=[];  var HaltAlt = $$('h5.h5dby');
		HaltAlt.each(function(el,i){ bc[i]=el.get('text'); el.setStyle('opacity','0'); });
		var HaltAlt2 = $$('.tipzel');
		HaltAlt2.each(function(el,i){ el.store('tip:text',bc[i]); });
	}
							
							var scroll4 = new Scroller('quickliste', {area: 200, velocity: 0.2});
		scroll4.start();
							
							} 
						}).send();
				})
			
		});
}
	
	
},
doAzapMenu:function(){
	
	//comportement et action bout MON PANIER
	if ($('h3pan')) {
		var myStarter = $('h3pan');
		/*if ($('fenpanier')) {
			var lehrefpan = $('h3pan').get('href');
			$('h3pan').set('href','#');
			
		}*/
		var myPagesA = $$('.navbar li.tomark a.tomarkto');
		var myHidden = $$('#bubblewrappan .bubble');
		var cPanier = $('monPanier').getCoordinates();
		myHidden[0].setStyle('opacity', 0);
		if ($('isPanier')) {myHidden[0].morph({ 'opacity' : 1, 'margin-top' : '0px' }); $('h3pan').setStyle('color','#fff');}
		myStarter.addEvents({
			'mouseenter': function() {
				if (!myPagesA[1].getParent().hasClass('on')) {/*myHiddenC[0].morph({ 'opacity' : 0, 'margin-top' : 0 });*/
				myHidden[0].morph({ 'opacity' : 1, 'margin-top' : '0px' });}
			},
			'mouseleave' : function() {if (!myPagesA[1].getParent().hasClass('on')) {myHidden[0].morph({'opacity' : 0,'margin-top' : '5px'}); }},
			'click':function(event) {
			
				if ($('h3pan').get('href')=="#") {event.stop();}
				if ($('ctrprod')) {
				event.stop();
				Bibi.switchPan('fenpanier');
				if ($('fenpanier').hasClass('noncharge')) {
				if ($('monpan')) {
					var toset2='<span id="loadminpan" style="visibility:hidden"><br><br><img src="ajax-loader.gif" width="50" height="50" ></span>';
					$('monpan').set('html',toset2);
				}
				var myRequest = new Request({
						url: 'panierfiche.php', 
						encoding : 'iso-8859-1',
						method: 'post', 
						evalScripts:false, 
						onSuccess: function(responseText, responseXML) {
							//$('fenpanier').removeClass('loading');
							$('fenpanier').set('html',responseText);  
							$('fenpanier').removeClass('noncharge');
							Bibi.StylisePan();
							
							if ($('reelnbinpan')) {
								toset=$('reelnbinpan').value+' article';
								if ($('reelnbinpan').value>1) {toset=toset+'s';}
								$('mycontpan').set('text',toset);
							}
							
						}
					}).send();
					}
				}
				 	
 			
 			}
				
		});
	
}	

	//comportement et action bout MON COMPTE
	if ($('wrapmoncompte') && $('h3cmpt')) {
		//comportement roolover bout MON COMPTE
		var myStarterC = $('h3cmpt');
		if ($('fencompte')) {
			var lehrefcmpt = $('h3cmpt').get('href');
			$('h3cmpt').set('href','#');
			
		}
		var myHiddenC = $$('#wrapmoncompte .bubble');
		myHiddenC[0].setStyle('opacity', 0);
		
	} // #FIN# if ($('wrapmoncompte') && $('h3cmpt')) {
	
	
	//mise a zero des href des Menu principaux Shop (themes, prix,etc...)
	var Table = $$('#az1','#az2','#az3','#az4','#az5');
	Table.each(function(el){el.set('href','#');});
	
	if ($$('.navbar li')) {
		var myPages2 = $$('.navbar li.tomark');
		var myBubbles2 = $$('#bubblewrapnav .bubble');
		var myPagesA = $$('.navbar li.tomark a.tomarkto');
		//var TabForm = $$('#wrapmoncompte .bubble');
		myPages2.each(function(el, i) {
			var p=el.getStyle('width');  
			el.setStyle('width',p); 
		});
		var wi0=$('h1logo').getCoordinates();
		//alert(wi0.left);
		myBubbles2.each(function(el, i) { //mise en place des fonc hover du menu top
			var wi=myPages2[i].getCoordinates();
			var wi2=myBubbles2[i].getCoordinates();
			var bibi=wi.left - wi0.left - 40;
			//alert(wi.left);
			myBubbles2[i].setStyles({'margin-left':bibi,'width':wi.width});
			//myBubbles2[i].setStyle('width',wi.width);
		});

var coor=$('monCompte').getCoordinates();
var basdep=$('btloginform').getCoordinates();
var maxcmpt=coor.bottom;
var lextodepasse = coor.left + coor.width;
$('monCompte').addEvents({
	'mouseenter':function(el) {$('monCompte').addClass('viewed');},
	'mouseleave':function(event) {
		if ( event.page.y>99 || event.page.y>maxcmpt) {
			myBubbles2[0].set('morph', {link : 'cancel', duration:300});
			myBubbles2[0].morph({'opacity' : 0,'margin-top' : 0,'height':25}); 
			myPages2[0].setStyle('height',25);
			$('monCompte').morph({ 'opacity' : 0, 'margin-top' : '10px'}); $('monCompte').removeClass('viewed');
			myPagesA[0].set('morph', {link : 'cancel'});
			coulor="#41281B";
			(function(){myPagesA[0].morph({'color' : coulor});}).delay(200);	
	}
		//if (event.page.y<=100) {$('monCompte').removeClass('viewed');} 
	
	}
});
$('monCompte').setStyle('opacity',0);	

myPagesA.each(function(el, i) {
		if ($('isPanier') && i==1) {
		myBubbles2[1].setStyles({ 'opacity' : 1, 'margin-top' : '-2px' });
		el.getParent().addClass('on');
	} else {
			
			if (el.getParent().hasClass('on')) {
				//mise en place du menu actif si jamais
				myBubbles2[i].setStyles({ 'opacity' : 1, 'margin-top' : '-2px' });
			} 
			else {
				el.set('morph', {link : 'cancel'});
				el.addEvents({
						'mouseenter': function() {
							el.set('morph', {link : 'cancel'}); 
							el.morph({'color' : '#FFF'});
							
							myBubbles2[i].set('morph', {link : 'cancel', duration:300});
							if (i==0) {
							
							
								if ($('h3cmpt').get('href')=="compte") {
								var newh = coor.height-5;
								var newh = coor.height-basdep.height+13; 
								var newh2 = coor.height;
									myBubbles2[i].morph({'opacity' : 1,'margin-top' : '-2px','height':newh}); 
									/*el.setStyle('height',120);*/ myPages2[i].setStyle('height',newh2);
									$('monCompte').morph({ 'opacity' : 1, 'margin-top' : '5px'}); 
								} 
								else {
								var newh = coor.height-basdep.height+10; 
								var newh2 = coor.height;
								myBubbles2[i].morph({'opacity' : 1,'margin-top' : '-2px','height':newh}); 
								/*el.setStyle('height',120);*/ myPages2[i].setStyle('height',newh);
								$('monCompte').morph({ 'opacity' : 1, 'margin-top' : '5px'}); 
								}
									
							} else {
							
							if (i==1) {
								
								var tailllle = $('bubblewrappan').getCoordinates();
								myBubbles2[i].morph({'opacity' : 1,'margin-top' : '-2px','height':tailllle.height+10}); 
								myPages2[i].setStyle('height',newh2);
								//$('monPanier').morph({ 'opacity' : 1, 'margin-top' : '5px'});
							
							} else {
								myBubbles2[i].morph({'opacity' : 1,'margin-top' : '-2px'});
								}
							}
							
							 
						},
						'mouseleave' : function(event) {
							
							
							if (i==0) {
								if (event.page.y<99 || event.page.y>maxcmpt && !$('monCompte').hasClass('viewed')) {
								//alert(event.page.x);
								myBubbles2[i].set('morph', {link : 'cancel', duration:300});
								myBubbles2[i].morph({'opacity' : 0,'margin-top' : 0,'height':25}); 
								myPages2[i].setStyle('height',25);
								$('monCompte').set('morph',{ duration:250}); 
								$('monCompte').morph({ 'opacity' : 0, 'margin-top' : '10px'}); 
								el.set('morph', {link : 'cancel'});
								if (i==0 || i==1) {coulor="#41281B"} else {coulor="#AB957E";}
								(function(){myPagesA[i].morph({'color' : coulor}); }).delay(200);	
								}
							} else {
								myBubbles2[i].set('morph', {link : 'cancel', duration:300});
								myBubbles2[i].morph({'opacity' : 0,'margin-top' : 0});
								el.set('morph', {link : 'cancel'});
								if (i==0 || i==1) {coulor="#41281B"} else {coulor="#AB957E";}
								(function(){myPagesA[i].morph({'color' : coulor});}).delay(200);
							}
							
							
							
						}	
				}); /* END el.addEvents */
			}
			}
		}); /* END myPagesA.each */
	}
	
	
	//MENU DROITE
	//maz hauteur ul conteneur
	var toto = $$('ul#zelmenu li a');
	toto.each(function(el){ 
		if (el.hasClass('notag')) {} else {
		
		//el.setStyle('opacity',.8);
		el.addEvents({
			'click' :Bibi.doClick.pass([el.get('id')]),
			'mouseenter': function() { if (!el.hasClass('mactive')) {el.set('morph', {duration : '500'});el.morph({ 'color' : '#AB957E' });} },
			'mouseleave' : function() { if (!el.hasClass('mactive')) {el.set('morph', {duration : '500'});el.morph({ 'color' : '#41281B' });} }	
		});
		}
	}); //#END# toto.each
},
doAzapRayons:function(){
	$('lenbrdobjtofind').setStyles({'opacity':0,'margin-top':5});
	var lei=0;
	$$('#contenuPageRubriqueBibi div.petitBlocProduitBibi').each(function(el,i) {lei+=1;});
	if (lei>1) {var letexte=lei+' objets';} else {var letexte=lei+' objet';}
	$('lenbrdobjtofind').set('text',letexte);
	
	/*TEST MINIATURE*/
	if ($$('div.contenu a.boxtof')) {
	var tabdesmini=$$('div.contenu a.boxtof');
	var tabdesminispan=$$('div.contenu span');
	if (Browser.Engine.gecko) {
		tabdesminispan.each(function(el) {
			if (el.hasClass('pucenews') || el.hasClass('pucesoldes')) {el.setStyle('margin-left',-160);} }) 
			
			}
	/*tabdesmini.each(function(el,i) {
	
		el.addEvents({
			'mouseenter' : function(){ tabdesmini.each(function(ele,i2) {if (i2!=i) {ele.morph({'opacity':.5}); if (tabdesminispan[i2].hasClass('pucenews') || tabdesminispan[i2].hasClass('pucesoldes')){tabdesminispan[i2].morph({'opacity':.5}); }   }}); },
			'mouseleave' : function(){ tabdesmini.each(function(ele,i2) {if (i2!=i) {ele.morph({'opacity':1}); if (tabdesminispan[i2].hasClass('pucenews')  || tabdesminispan[i2].hasClass('pucesoldes')){tabdesminispan[i2].morph({'opacity':1}); }}}); }
		});
	});*/
	}
	
	
},
doAzap:function(){
	Bibi.doAzapMenu();
	if ($('lenbrdobjtofind')) {Bibi.doAzapRayons();}
	if ($('roteme')) {Bibi.doAzapFprod();}
	//CGV
	if ($('aspecgv')) {
		$('aspecgv').addEvent('click',function(event) {
		if (event) {event.stop();}
		$('lescgvstep3').addClass('loading');
		var myRequest = new Request({url: 'cgvstep3.php', method: 'post', onSuccess: 
		function(responseText, responseXML) {
			$('lescgvstep3').set('html',responseText);
			$('lescgvstep3').removeClass('loading');	
		} 
		}).send();
		});
	}
	
	//bo Step3
	if ($('mybostep3')) {
		$('mybostep3').addEvent('click',function(event){
			if (event) {event.stop();}
			if (document.forms['fogotopaiest4'].elements['checkcgv'].checked) {document.forms['fogotopaiest4'].submit();} 
			else {alert('Merci de cocher la case');}
		});
		
	}
	
	
	
}
} // #FIN# Bibi

window.addEvent('load',Bibi.doOnStart);
window.addEvent('domready',function(){

	Bibi.doAzap();
	Bibi.initAll();

	/*setInterval(function(){ layers[i].fade('out');  i = (i == layers.length-1)? 0 : i+1; layers[i].fade('in');},delay);*/

if ($('slideacc')) {
	
	
	var BoxTof = $$("#boxslideacctof a");
	var BoxTit = $$("#masktitreprodacc div.tiaccboxes");
	BoxTof.each(function(ele,u) {if (u!=0) {ele.setStyle('opacity','0'); BoxTit[u].setStyles({'margin-top':-10,'opacity':0});}});
	var y=0;
	setInterval(function(){  BoxTof[y].fade('out'); BoxTit[y].setStyles({'opacity':0,'margin-top':-10});  y = (y == BoxTof.length-1)? 0 : y+1; BoxTof[y].set('morph',{'duration':1500,'transition': Fx.Transitions.Sine.easeOut}); BoxTof[y].morph({'opacity':1}); BoxTit[y].set('morph',{'duration':1500,'transition': Fx.Transitions.Back.easeOut});BoxTit[y].morph({'margin-top':-2,'opacity':1});},4000);
	
	
	var TabBox = $$("#slideacc div.colacc");
	var TabH = $$("#slideacc h3");
	var TabC = $$("#slideacc div.colacc div");
	var TabB = $$("#slideacc p.holdboutnews");
	TabBox.each(function(ele,u) {if (u!=0) {ele.setStyle('opacity','0'); TabB[u].setStyle('opacity','0'); TabC[u].setStyles({'margin-top':-20,'opacity':0});}});
	
	var i=0;
	setInterval(function(){ 
	TabBox[i].fade('out'); TabB[i].fade('out'); TabC[i].setStyles({'opacity':0,'margin-top':-20});
	i = (i == TabBox.length-1)? 0 : i+1; 
	TabBox[i].fade('in'); TabB[i].fade('in'); TabC[i].set('morph',{'duration':1500,'transition': Fx.Transitions.Back.easeOut});TabC[i].morph({'margin-top':0,'opacity':1});  },8000);
}

	
});

