// Fonction bgiframe (V3)
/*(function(jQuery){jQuery.fn.bgIframe=jQuery.fn.bgiframe=function(s){if(jQuery.browser.msie&&/6.0/.test(navigator.userAgent)){s=jQuery.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if(jQuery('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(jQuery);*/
jQuery.noConflict();
// Scripts pour pages service v2
jQuery(function ()
{
	// Affichage des layers de menu (issu de la V3)
	jQuery('.onOff').hover(
		function(){
			jQuery(this).attr('src',function(i,src){ return src.replace('_off.','_on.'); });
		},
		function(){
			jQuery(this).attr('src',function(i,src){ return src.replace('_on.','_off.'); })
		}
	);
	var closetimer = 0;
	jQuery('.navLayer').mouseover(
		function(){
			jQuery('.navLayer .active').removeClass('active');
			jQuery('.layerLev2').hide();
			jQuery('.layerLev1').hide();
			//jQuery(this).find('.navLayerItem').addClass('active').next('.layerLev2').bgiframe().show();
			jQuery(this).find('.navLayerItem').addClass('active').next('.layerLev2').show();
			jQuery('select').blur();
			nav_canceltimer(closetimer);
		}
	);
	jQuery('.navLayer').mouseout(
		function(){
			currentItem = jQuery(this);
			closetimer = window.setTimeout(function()
			{
			currentItem.find('.active').removeClass('active');
			currentItem.find('.layerLev2').hide();
			//console.log('time');
			},200);
		}
	);
	function nav_canceltimer(timerName)
	{  if(closetimer)
	   {  window.clearTimeout(timerName);
		  timerName = null;}}
	jQuery('.navContentItem').hover(function(){
			//jQuery(this).addClass('hover').find('.layerNavContent').bgiframe().show();
			jQuery(this).addClass('hover').find('.layerNavContent').show();
		},
		function(){
			jQuery(this).removeClass('hover').find('.layerNavContent').hide();
	});
	if(jQuery('.accordionList').html() != "")
		jQuery('.accordionList:not(.accordionFamille)').accordionList();
	//jQuery('.rollIllus').rollIllus('innerBorder');
	jQuery('#layerIdeesConseils li').hover(function(e)
	{
		jQuery('#layerIdeesConseils li').find('.innerBorder').show();
	},
	function(e){
		jQuery('#layerIdeesConseils li').find('.innerBorder').hide();
	}
	);
  // Layer d'itinéraire (fiche magasin)
  // Génération des liens d'impression
  jQuery('#layerMagasinSeRendre h2').append ('<a href="javascript: window.print ();" class="lienBouton">Imprimer</a>');
  jQuery('#layerMagasinSeRendre .layerProduitContent').append ('<p class="layerImprimer"><a href="javascript: window.print ();" class="lienBouton">Imprimer</a></p>');
  // Affichage du layer
  jQuery('.infosPratiquesMagCont .accesMagasin').click (function (e)
  {
    e.preventDefault ();
    displayLayer (jQuery(this), '#layerMagasinSeRendre');
    // Ajustements CSS
    jQuery('#layerMagasinSeRendre').css (
    {
      'width': '',
      'top': '',
      'left': ''
    });
    jQuery('#layerMagasinSeRendre .layerProduitBackground').css (
    {
      'width': '',
      'height': ''
    });
    jQuery('#layerMagasinSeRendre .layerProduitContent').css (
    {
      'width': '',
      'height': '',
      'overflow': ''
    });
    // Ajustement de la hauteur du fond pour IE 6
    /*@cc_on
    if (@_jscript_version <= 5.7 && navigator.userAgent.indexOf ('MSIE 6.0') != -1)
    {
      jQuery('#layerMagasinSeRendre .layerProduitBackground').css ('height', parseInt (jQuery('#layerMagasinSeRendre .layerProduitContent').outerHeight ()) + 30 + 'px');
    }
    @*/
  });
  // Layers confort magasin
  jQuery('body').addClass ('js');
  // Ajout des bordures supérieure et inférieure
  jQuery('.layerConfortMagasin').prepend ('<span class="bordure"></span><span class="bordure bordureInferieure"></span>');
  // Ajout des liens fermer et imprimer
  jQuery('.layerConfortMagasin .envoyerImprimerLayer').append ('<li class="imprimer"><a title="Imprimer la page" href="javascript: window.print ();"><span>Imprimer</span></a></li>');
  jQuery('<p class="fermer"><a href="#">Fermer</a></p>').insertAfter (jQuery('.layerConfortMagasin .envoyerImprimerLayer'));
  // Par défaut, les layers sont masqués
  jQuery('.layerConfortMagasin').addClass ('layerMasque');
  // Affichage des layers
  jQuery('.friseServicesList a').click (function (e)
  {
    e.preventDefault ();
    var sAncre = jQuery(this).attr ('href');
    // On masque un layer éventuellement affiché
    jQuery('.layerConfortMagasin').addClass ('layerMasque');
    jQuery(sAncre).removeClass ('layerMasque');
    jQuery('#overlay').css (
    {
      'width': parseInt (jQuery('body').width ()) + 'px',
      'height': parseInt (jQuery('body').height ()) + 'px'
    }).show ();
    // Fermeture du layer au clic dehors
    jQuery('#overlay').click (function (e)
    {
      e.preventDefault ();
      jQuery(this).hide ();
      jQuery(sAncre).addClass ('layerMasque');
    });
  });
  // Fermeture des layers de l'intérieur
  jQuery('.layerConfortMagasin .fermer a').click (function (e)
  {
    e.preventDefault ();
    jQuery(this).parents ('.layerConfortMagasin').addClass ('layerMasque');
    // Neutralisation de l'overlay
    jQuery('#overlay').unbind ('click').hide ();
  });
	// Carousel horizontal pour les services magasin (script issu de la V3)
	if(jQuery('.friseHorizontale').length>0)
	{
		friseHorizontal(
			jQuery('.friseHorizontale .onglets li'),
			jQuery('.friseHorizontale .onglets'),
			jQuery('.friseHorizontale .friseContenu'),
			39,
			jQuery('.friseHorizontale .defilDroite'),
			jQuery('.friseHorizontale .defilGauche'),
			jQuery('.friseHorizontale').next('.conteneurOnglet')
		);
	}
	if(jQuery('.friseServices').length>0)
	{
		friseHorizontal(
			jQuery('.friseServices .friseServicesList li'),
			jQuery('.friseServices .friseServicesList'),
			jQuery('.friseServices .friseServicesWrapper'),
			10,
			jQuery('.friseServices .btnRight'),
			jQuery('.friseServices .btnLeft')
		);
	}
	// Frise horizontale des services magasin (la classe de chaque lien correspond à l'id du layer)
	/*setTimeout(function()
	{
		jQuery('.friseServicesList li a').each(function()
		{
				jQuery(this).showInfobulle( jQuery('#'+jQuery(this).attr('class')) );
		});
	},200);
	jQuery('.descriptionVideo').hide();
	jQuery('.descriptionVideo:first').show();
	jQuery('.navigationList li a').click(function(e)
	{
		e.preventDefault();
		jQuery(this).closest('.navigationList').find('li').removeClass('actif');
		jQuery(this).parent().addClass('actif');
		if(jQuery('.descriptionVideo:eq('+jQuery(this).parent().index()+')').length>0)
		{
			jQuery('.descriptionVideo').hide();
			jQuery('.descriptionVideo:eq('+jQuery(this).parent().index()+')').show();
		}
	});*/
  // Carousel horizontal (V3)
	var scrolling;
	var ifScroll;
  function friseHorizontal(itemsLi,itemsContainer,listContainer,sizeItem,triggerRight,triggerLeft,tabContainer)
  {
    setTimeout(function()
      {
      var alwaysMoveLeft;
      var alwaysMoveRight;
      var widthList = 0;
      itemsLi.each(function()
      {
        widthList+=jQuery(this).width()+sizeItem;
      });
      itemsContainer.css('width',widthList+'px')
      if(itemsContainer.width()>=listContainer.width())
      {
        newItemsLi = itemsLi.clone();
        newItemsLi.appendTo(itemsContainer);
        widthListBis = widthList*2;
        itemsContainer.css('width',widthListBis+'px');
        if(tabContainer)
        {
          tabContainer.find('.contenuOnglet').clone().appendTo(tabContainer);
          generateTabs(itemsLi.length);
        }
        triggerRight.mousedown(function()
        {
            var widthContainer = listContainer.width();
            scrolling = true;
            startScrollingRight(itemsContainer,'-=5px',1,widthList);
        });
        triggerRight.mouseup(function()
        {
          scrolling = false;
          itemsContainer.pauseAnimation();
        });
        triggerRight.mouseleave(function()
        {
          scrolling = false;
          itemsContainer.pauseAnimation();
        });
        triggerLeft.mousedown(function()
        {
            scrolling = true;
            startScrollingLeft(itemsContainer,'+=5px',1,widthList);
        });
        triggerLeft.mouseup(function()
        {
          scrolling = false;
          itemsContainer.pauseAnimation();
        });
        triggerLeft.mouseleave(function()
        {
          scrolling = false;
          itemsContainer.pauseAnimation();
        });
        } else {
          triggerLeft.show();
          triggerRight.show();
        }
      },100);
  }
  function startScrollingRight(obj, param, speed, widthList)
  {
    obj.animate({"left": param}, speed, 'linear', function(){
      if (scrolling==true)
      {
        if(parseInt(obj.css('left'))<(-widthList))
        {
          obj.css({'left':'0px'})
        }
        startScrollingRight(obj, param,1,widthList);
      }
    });
  }
  function startScrollingLeft(obj, param, speed, widthList)
  {
    obj.animate({"left": param}, speed, 'linear', function(){
      if (scrolling==true)
      {
        if(parseInt(obj.css('left'))>0)
        {
          obj.css({'left':(-widthList)+'px'})
        }
        startScrollingLeft(obj, param, 1,widthList);
      }
    });
  }
  function startScrollRightWithoutLoop(obj, param, speed, widthList, widthContainer)
  {
    if(parseInt(obj.css('left'))>=(-(widthList-(widthContainer))))
    {
      obj.animate({"left": param}, speed, 'linear', function(){
        if (ifScroll==true)
        {
          startScrollRightWithoutLoop(obj, param,1,widthList, widthContainer);
        }
      });
    }
  }
  function startScrollLeftWithoutLoop(obj, param, speed, widthList)
  {
    if(parseInt(obj.css('left'))<widthList)
    {
      obj.animate({"left": param}, speed, 'linear', function(){
        if (ifScroll==true)
        {
          startScrollLeftWithoutLoop(obj, param, 1,widthList);
        }
      });
    }
  }
});
  // Fonction carrousel (issue de la V3)
  jQuery.fn.carrousel2 = function(previous, next, options){
    var sliderList = jQuery(this).children()[0];
    if (sliderList) {
      var increment;// = jQuery(sliderList).children().outerWidth(true);
      // Hack pour régler le problème de largeur sous Mac
      increment = parseInt(jQuery(this).parent().attr('class').replace(/[a-z,A-Z]/g,''));
      if(increment=='')
      {
        increment = jQuery(sliderList).children().outerWidth(true);
      }
      if(jQuery(this).parent().hasClass('visionneuse'))
      {
        increment = 117;
      }
      var elmnts = jQuery(sliderList).children(),
      numElmts = elmnts.length,
      sizeFirstElmnt = increment,
      shownInViewport = Math.round(jQuery(this).width() / sizeFirstElmnt),
      firstElementOnViewPort = 1,
      isAnimating = false;
      for (i = 0; i < shownInViewport; i++) {
        jQuery(sliderList).css('width',(numElmts+shownInViewport)*increment + increment + "px");
        jQuery(sliderList).append(jQuery(elmnts[i]).clone());
      }
      jQuery(previous).click(function(event){
        if (!isAnimating) {
          if (firstElementOnViewPort == 1) {
            jQuery(sliderList).css('left', "-" + numElmts * sizeFirstElmnt + "px");
            firstElementOnViewPort = numElmts;
          }
          else {
            firstElementOnViewPort--;
          }
          jQuery(sliderList).animate({
            left: "+=" + increment,
            y: 0,
            queue: true
          }, "swing", function(){isAnimating = false;});
          isAnimating = true;
        }
      });
      jQuery(next).click(function(event){
        if (!isAnimating) {
          if (firstElementOnViewPort > numElmts) {
            firstElementOnViewPort = 2;
            jQuery(sliderList).css('left', "0px");
          }
          else {
            firstElementOnViewPort++;
          }
          jQuery(sliderList).animate({
            left: "-=" + increment,
            y: 0,
            queue: true
          }, "swing", function(){isAnimating = false;});
          isAnimating = true;
        }
      });
    }
  };
  function ouvrir_lien_video(lien,alt,target,h,w)
    {
        var winl = (screen.width - 800) / 2;
        var wint = (screen.height - 600) / 2;
        window.open(lien,target,"height="+ h + ",width="+ w +",top=" + wint + ",left=" + winl + ",resizable=yes,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1").focus();
    }
    function ouvrir_lien(lien,alt,target,h,w)
    {
        var winl = (screen.width - 800) / 2;
        var wint = (screen.height - 600) / 2;
        window.open(lien,target,"height="+ h + ",width="+ w +",top=" + wint + ",left=" + winl + ",resizable=yes,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1").focus();
    }
    function openLink(sURLStart){
        var sURLStartfinal='';
        if(sURLStart.indexOf('lmtarget')==-1)
        {
            document.location.href=sURLStart;
        }
        else
        if(sURLStart.indexOf('modepopup')==-1)
    {
        sURLStartfinal=sURLStart.substr(0,sURLStart.lastIndexOf('&lmtarget'));
        window.open(sURLStartfinal,'lmtarget','').focus();
    }
    else
    {
        sURLStartfinal=sURLStart.substr(0,sURLStart.lastIndexOf('&lmtarget'));
        window.open(sURLStartfinal,'lmtarget','resizable=no, location=no, width=780, height=620 , menubar=no, status=no, scrollbars=yes, menubar=no').focus();
    }
}
var countclearinputs = 0;
function clearinput(caller) {
    if ( countclearinputs == 0 ) {
	caller.value = "";
	countclearinputs++;
    }
}
function submitForumForm(target) {
    var t = document.getElementById(target);
    t.submit();
}
function SubmitFormSearch() {
    if (ValidateFormSearch() == true ) {
       // document.submitformsearch.submitbutton.disabled=true;
	document.submitformsearch.submit();
    }
}
function ValidateFormSearch() {
    if (isBlank(document.submitformsearch.key, "Recherchez dans les forums")) return false;
    return true;
}
function isBlank(field, strBodyHeader) {
    strTrimmed = Trim(field.value);
    if (strTrimmed.length > 0) return false;
    alert("\"" + strBodyHeader + "\" est un champ obligatoire.");
    field.focus();
    return true;
}
function LTrim(value) {
    for (var x = 0; x < value.length; x++)  if (value.charAt(x) != " ")  return value.substring(x, 1+value.length-x)
    return ""
}
function RTrim(value) {
    for (var x = value.length - 1; x >= 0; x--)  if (value.charAt(x) != " ")  return value.substring(0, x+1);
    return ""
}
function Trim (value) {
    return RTrim (LTrim(value)) ;
}
// Fonction accordionList (V3)
jQuery.fn.accordionList = function() {
	var accordionContainer = jQuery(this);
	jQuery(this).find('dt').addClass('accordionClose');
	jQuery(this).find('dt.accordionOpen').removeClass('accordionClose').addClass('accordionOpen');
	jQuery(this).find('dt.accordionOpenEmpty').removeClass('accordionClose').removeClass('accordionOpenEmpty');
	jQuery(this).find('dd:has(.active)').addClass('active');
	jQuery(this).find('.active').siblings('dt').removeClass('accordionClose').addClass('accordionOpen');
    jQuery('.accordionClose').siblings('dd').hide();
	jQuery('.accordionOpen').siblings('dd').show();
	jQuery(this).find('.active').show().siblings('dd').show();
	jQuery(this).find('dt').each(function(i,elt){
		if (jQuery(elt).siblings('dd').size() == 0 || jQuery(elt).siblings('dd').find('dl') == 0){
			jQuery(elt).removeClass('accordionOpen').removeClass('accordionClose');
		}
	});
	jQuery(this).find('dt').click(function(e){
		e.preventDefault();
		if( jQuery(this).hasClass('accordionOpen')  ){
			jQuery(this).removeClass('accordionOpen').addClass('accordionClose');
		}
		else {
			jQuery(this).closest('dl').find('dt.accordionOpen').removeClass('accordionOpen').addClass('accordionClose');
			jQuery(this).closest('dl').find('dt.accordionOpenEmpty').removeClass('accordionOpenEmpty');
			jQuery(this).closest('dl').siblings('dl').find('dt.accordionOpen').removeClass('accordionOpen').addClass('accordionClose');
			jQuery(this).closest('dd').siblings('dd').find('dt.accordionOpen').removeClass('accordionOpen').addClass('accordionClose');
			if (jQuery(this).siblings('dd').size() > 0 || jQuery(this).siblings('dd').find('dl') > 0){
				jQuery(this).removeClass('accordionClose').removeClass('accordionOpenEmpty').addClass('accordionOpen');
			} else {
				jQuery(this).removeClass('accordionClose').removeClass('accordionOpen').addClass('accordionOpenEmpty');
			}
		}
		jQuery(this).closest('dl').siblings('dl').find('.accordionClose').siblings('dd').hide();
		jQuery(this).closest('dd').siblings('dd').find('.accordionClose').siblings('dd').hide();
		jQuery(this).closest('dl').find('.accordionClose').siblings('dd').hide();
		if(!jQuery(this).closest('dl').find('.voirPlus').hasClass('hide'))
		{
			jQuery(this).closest('dl').find('.accordionOpen').siblings('dd').show();
			jQuery(this).closest('dl').find('.voirPlus').nextAll('dd').hide();
		} else {
			jQuery(this).closest('dl').find('.accordionOpen').siblings('dd').show();
			jQuery(this).closest('dl').find('.voirPlus').removeClass('hide');
			jQuery(this).closest('dl').find('.voirPlus').nextAll('dd').hide();
		}
	});
	if(accordionContainer.has('.voirPlus'))
	{
		accordionContainer.find('.voirPlus').nextAll('dd').hide();
		accordionContainer.find('.voirPlus').find('a').click(function(e)
		{
			e.preventDefault();
			jQuery(this).closest('.voirPlus').addClass('hide');
			jQuery(this).closest('.voirPlus').nextAll('dd').show();
		});
	}
}
// Fonction lmHover (V3)
jQuery.fn.lmHover = function(className)
{
	jQuery(this).hover(function(e)
	{
		jQuery(this).find(className).show();
	},
	function(e){
		jQuery(this).find(className).hide();
	}
	);
}
// Fonction rollIllus (V3)
jQuery.fn.rollIllus = function(className){
	jQuery(this).hover(
		function(){
			jQuery(this).append( jQuery('<div class="'+ className +'" style="position:absolute;"></div>') );
		},
		function(){
			jQuery(this).find('div:last').remove();
		}
	);
}
// Fonction pour layers rectangulaires avec marge transparente, repr&eacute;sent&eacute;s par la variable layer
function displayLayer(trigger, layer)
{
		jQuery(layer).show();
		var globalScrollTop = document.body.scrollTop;
		var nonContextualiseLaRochelle = true;
		
		if(document.documentElement.scrollTop)
		{
			globalScrollTop = document.documentElement.scrollTop;
		}
		
		if(getCookie("anonymous_shop") && getCookie("anonymous_save")) {
			if(getCookie("anonymous_shop") == '139' && getCookie("anonymous_save") == "true") {
				nonContextualiseLaRochelle = false;
			}
		}
		if(nonContextualiseLaRochelle){
			if(layer == "#layerPanier")
				globalScrollTop = 0;
		/*}*/
		
		if(jQuery(layer).height()>document.documentElement.clientHeight)
		{
			currentTop = globalScrollTop+10;
			currentHeight = document.documentElement.clientHeight-90;
			currentWidth = jQuery(layer).width()+30;
		} else {
			currentTop = (globalScrollTop)+((parseInt(document.documentElement.clientHeight)/2)-(parseInt(jQuery(layer).height())/2));
			currentHeight = 'auto';
			currentWidth = jQuery(layer).width();
		}
		//console.log(document.documentElement.clientHeight)
		jQuery(layer).css({
			'left':(jQuery(document).width()/2)-(jQuery(layer).width()/2)+'px',
			'top':currentTop+'px',
			'width':currentWidth+'px'
		});
		if(jQuery(layer).height()>document.documentElement.clientHeight)
		{
			jQuery(layer).find('.layerProduitContent').css({
				'height':currentHeight+'px',
				'overflow':'auto',
				'width':(currentWidth-60)+'px'
			});
		}
		overlay(jQuery(layer));
		// Traitement du background des layers de produits
		jQuery(layer).find('.layerProduitBackground').css({
				'height':(jQuery(layer).height()+30)+'px',
				'width':currentWidth+30+'px'
			});
		if(layer == "#layerPanier")
			window.scrollTo(0, 0);
		}
}
//Fonction pour les layers de la fiche pas � pas
function displayLayerPasAPas(currentBtn,currentLayer)
{
	if(!currentLayer.is(':visible'))
	{
		jQuery('.btnLayerFichePratique').css('visibility','visible');
		currentBtn.css('visibility','hidden');
		currentLayer.show().css({
		'left':currentBtn.findPos().x+'px',
		'top':currentBtn.findPos().y+'px'
		});
		if(currentLayer.attr('id')=='materiauxNecessairesLayer')
		{
			currentLayer.css('left',(parseInt(currentBtn.findPos().x)-155)+'px')
		}
		overlay(currentLayer);
		currentLayer.siblings('.layerFichePratique').hide();
		jQuery('#overlay, .onclick2').bind('click',function()
		{
			currentBtn.css('visibility','visible');
		});
	} else {
		currentBtn.css('visibility','visible');
		currentLayer.hide();
		jQuery('#overlay').unbind('click').hide();
	}
}
// Fonction pour afficher le masque invisible global sur tout le site
function overlay(obj)
{
	jQuery('#overlay').show();
	jQuery('#overlay').css({'height':jQuery(document).height()+'px','width':jQuery(document).width()+'px',"background-color":"#000","opacity":0.0,"display":"block"})
	jQuery('#overlay').bind('click',function()
	{
		jQuery('#overlay').hide();
		obj.hide();
	});
}
// Fermer layer
jQuery(function(){
	jQuery('.layerClose a, .bouttonClose').click(function(e){
		e.preventDefault();
		jQuery(this).closest('.layerProduit, .layerVideo, .layerSon, .layerInfoBulle, .layerAjouterPanier, .layerQuantite, .layerHighSmall, .layerHighBig, .layerArticle, .layerAgenda, .layerForum').hide();
		jQuery('#overlay').unbind('click').hide();
	});
});
// Gestion des infobulles, représentées par la variable obj (V3)
jQuery.fn.showInfobulle = function(obj){
var obj = obj;
	jQuery(this).each(function(i,item){
		jQuery(item).click(
			function(e){
				e.preventDefault();
				var offset = jQuery('body').offset();
				var posX = jQuery(this).findPos().x+10;
				var posY = jQuery(this).findPos().y+(jQuery(this).height()/2);
				//obj.bgIframe();
				if(obj.attr('class')=='layerAjouterPanier'||obj.attr('class')=='layerHighBig'||obj.attr('class')=='layerHighSmall')
				{
					obj.show().css({'left':posX-offset.left-obj.width()+25+'px','top':posY-offset.top+10+'px'});
				} else if(obj.attr('class')=='layerQuantite'&&obj.attr('id')!='layerCalculette') {
					obj.show().css({'left':posX-offset.left-obj.width()+'px','top':posY-offset.top-15+'px'});
				} else if(obj.attr('class')=='layerQuantite'&&obj.attr('id')=='layerCalculette') {
					obj.show().css({'left':e.pageX-offset.left+'px','top':posY-offset.top-15+'px'});
				} else if(obj.attr('class')=='layerArticle') {
					obj.show().css({'left':posX-offset.left-obj.width()+'px','top':posY-offset.top-420+'px'});
				} else if(obj.attr('class')=='layerAgenda') {
					obj.show().css({'left':posX-offset.left-obj.width()+'px','top':posY-offset.top-40+'px'});
				} else {
					obj.show().css({'left':posX-offset.left+'px','top':posY-offset.top-10+'px'});
				}
				overlay(obj);
			}
		);
	});
}
// Animation du carrousel confort en magasin (script issu de la V3)
jQuery.fn.startAnimation = function(  params, duration, easing, callback ) {
	jQuery(this).animate( params, duration, easing, callback );
	var data = { target:this.get(0), params: params, duration: duration, easing: easing, callback: callback,
				startTime: new Date().getTime(), timePlayed: 0, timeRemaining: 0 };
	if( !jQuery.pauseableAnimations ) {
		jQuery.extend({ pauseableAnimations: new Array( data ) });
	} else {
		for( var i in jQuery.pauseableAnimations ) {
			if( jQuery.pauseableAnimations[i].target == this.get(0) ) {
				jQuery.pauseableAnimations[i] = data;
			} else {
				jQuery.pauseableAnimations.push( data );
			};
		};
	};
};
jQuery.fn.pauseAnimation = function() {
	if( jQuery.pauseableAnimations ) {
		for(var i in jQuery.pauseableAnimations ) {
			if( jQuery.pauseableAnimations[i].target == this.get(0) ) {
				jQuery(this).stop();
				var now = new Date().getTime();
				var data = jQuery.pauseableAnimations[i];
				data.timePlayed += ( now - data.startTime );
				data.timeRemaining = data.duration - data.timePlayed;
				if( data.timePlayed > data.duration ) {
					var newArray = new Array();
					for( var p in jQuery.pauseableAnimations ) {
						if( jQuery.pauseableAnimations[p] != data ) newArray.push( jQuery.pauseableAnimations[p] );
					};
					jQuery.pauseableAnimations = newArray.length > 0 ? newArray : null;
					delete newArray;
					return this;
				};
				break;
			};
		};
	};
	return this;
};
jQuery.fn.resumeAnimation = function() {
	if( jQuery.pauseableAnimations ) {
		for(var i in jQuery.pauseableAnimations ) {
			var data = jQuery.pauseableAnimations[i];
			if( data.target == this.get(0) ) {
				this.animate( data.params, data.timeRemaining, data.easing, data.callback );
				data.startTime = new Date().getTime();
				return this;
			};
		};
	};
};
/**Script Renaud */
// Layer télécharger image
function afficheInfoSupMagSimple(boutonSelecteur,booleen){
  jQuery(boutonSelecteur).click(function(e){
		e.preventDefault();
		if(booleen == true){
		  jQuery(".cacher").show();
		}else{
		  jQuery(".cacher").hide();
		}
		displayLayer(jQuery(this),'#layerInfoSupMagasin');
		/*debug IE le boulet
		jQuery('#layerInfoSupMagasin').height(1500);
		jQuery('#layerInfoSupMagasin .layerProduitContent').height(1500).css({"background-color":"red"});
		//jQuery(".infoSupMagasin").css({"margin-left":"0",});
		*/
  });
}
function remiseZeroLayer(){
  var infoSupMagasin = jQuery('div.infoSupMagasin[style*="images/bgd_border_zoom_carte.gif"]');
	jQuery('.layerProduitContent br[class*="clear"]').remove();
	jQuery('.contenuCarteZoom p').unwrap();
	infoSupMagasin.css({
	      'margin-top':'0',
	      'margin-left':'0',
	      'background-image':'none',
	      'padding-left':'0',
	      'width':'auto',
	      'height':'auto'
	});
	infoSupMagasin.children('p').css({
	  'clear':'both'
	});
	infoSupMagasin.children('h2').css({
	  'padding-top':'0px',
	  'float':'left'
	});
}
function afficheInfoSupMagDansZoomCarte(boutonSelecteur,booleen){
  jQuery(boutonSelecteur).click(function(e){
	    var largeurOrigineLayerProduit = jQuery(this).parents('.layerProduit').width();
	    var largeurOrigineLayerBackground = jQuery(this).parents('.layerProduitContent').siblings('.layerProduitBackground').width();
	    var largeurOrigineLayerProduitContent = jQuery(this).parents('.layerProduitContent').width();
	    remiseZeroLayer();
	    e.preventDefault();
	    if(booleen == true){
	      jQuery(".cacher").show();
	    }else{
	      jQuery(".cacher").hide();
	    }
	    jQuery(this).parents("p").wrap('<div class="contenuCarteZoom" />');
	    jQuery(".contenuCarteZoom").before('<br class="clear" />');
	    jQuery('.clear').css("clear","both");
	    jQuery(this).parents(".contenuCarteZoom").css({
	      "float":"left",
	      width:"520px"
	    });
	    jQuery(".infoSupMagasin").insertAfter(jQuery(this).parents(".contenuCarteZoom:last"));
	    jQuery(".infoSupMagasin .cacher").html('Découvrez aussi notre service exclusif : <br /><a href="#">le retrait en magasin.</a>');
	    jQuery(".infoSupMagasin form input[type^=check]").css({"float":"left"});
	    jQuery(".infoSupMagasin form label").css({"margin":"0 0 0 25px",'display':'block'});
	    jQuery(this).parents(".contenuCarteZoom").siblings('.infoSupMagasin').css({
	      'background-image':'url(images/bgd_border_zoom_carte.gif)',
	      'background-repeat':'repeat-y',
	      'background-position':'left top',
	      'margin-left':"530px",
	      'padding-left':'15px',
	      'width':'225px',
	      'height':parseInt(jQuery(this).parents(".contenuCarteZoom").height())+"px"
	    });
	    jQuery('.infoSupMagasin p').css({
	      'clear':'none'
	    });
	    jQuery('.infoSupMagasin h2').css({
	      'float':'none'
	    });
	      var tailleFin = 785;//765
	      jQuery(this).parents('.layerProduit').width(tailleFin+60);
	      jQuery(this).parents('.layerProduitContent').siblings('.layerProduitBackground').width(tailleFin+75);
	      jQuery(this).parents('.layerProduitContent').width(tailleFin);
	      jQuery(this).parents('.layerProduit').css({marginLeft: "-128px"});
	    /*
	    // comportement dans le cas où le texte passerait en bas de la carte
	    jQuery(".infoSupMagasin").insertAfter(jQuery(this).parents("p:last"));
	    var hauteurlayerProduitBackground = jQuery(this).parents(".layerProduitContent").siblings(".layerProduitBackground").height();
	    jQuery('.layerProduitBackground').css({
	      "height":parseInt(jQuery(this).parents('p').siblings(".infoSupMagasin").height()+hauteurlayerProduitBackground)+'px'
	    });
	    */
	    jQuery(this).parents("p").siblings(".infoSupMagasin h2").css("float","none");
    jQuery(".layerClose,#overlay").bind("click",function(){
      if(jQuery("#layerNord .infoSupMagasin").length > 0 || jQuery("#layerPACA .infoSupMagasin").length > 0 || jQuery("#layerIleDeFrance .infoSupMagasin").length > 0){
	jQuery(".infoSupMagasin").insertAfter("#layerInfoSupMagasin .layerClose").css({
	      'margin-left':'0',
	      'background-image':'none',
	      'padding-left':'0',
	      'width':'auto',
	      'height':'auto'
	});
	jQuery(".infoSupMagasin form input[type^=check]").css({"float":"none"});
	jQuery(".infoSupMagasin form label").css({"margin":"0",'display':'inline'});
	jQuery(".infoSupMagasin .cacher").html('Découvrez aussi notre service exclusif : <a href="#">le retrait en magasin.</a>');
	var tailleCarte = 520;
	jQuery('.layerProduit').width(tailleCarte+60);
	jQuery('.layerProduit .layerProduitContent').width(tailleCarte);
	jQuery('.layerProduit .layerProduitBackground').width(tailleCarte);
      }
    });
    });
}
jQuery(function(){
	jQuery('#IleDeFrance').click(function(e){
		e.preventDefault();
		displayLayer(jQuery(this),'#layerIleDeFrance');
	});
	jQuery('#PACA').click(function(e){
		e.preventDefault();
		displayLayer(jQuery(this),'#layerPACA');
	});
	jQuery('#Nord').click(function(e){
		e.preventDefault();
		displayLayer(jQuery(this),'#layerNord');
	});
	/*layer supplémentaire simple (affiche ligne avec lien retrait magasin)*/
	var villeBasic = new Array("#larochelle");
	for(var i in villeBasic){
	  afficheInfoSupMagSimple(villeBasic[i],true);
	}
	/*layer supplémentaire simple (cache ligne avec lien retrait magasin)*/
	var villeTexteCache = new Array('#angouleme');
	for(var j in villeTexteCache){
	  afficheInfoSupMagSimple(villeTexteCache[j],false);
	}
	/*infos supplémentaires dans les zoom carte (affiche ligne avec lien retrait magasin)*/
	var villeBasicDansZoomCarte = new Array('#valenciennes','#parisBeaubourg',"#marseille");
	for(var k in villeBasicDansZoomCarte){
	  afficheInfoSupMagDansZoomCarte(villeBasicDansZoomCarte[k],true);
	}
	/*infos supplémentaires dans les zoom carte (cache ligne avec lien retrait magasin)*/
	var villeTexteCacheDansZoomCarte = new Array("#maubeuge","#aubagne","#brie" )
	for(var l in villeTexteCacheDansZoomCarte){
	  afficheInfoSupMagDansZoomCarte(villeTexteCacheDansZoomCarte[l],false);
	}
});
jQuery(function(){
  jQuery("#listeParCodePostal").click(function(){
    if(jQuery(this).val() == "Code postal (ex : 59000)")
      jQuery(this).val("");
  });
});
jQuery(function(){
var defilSpanWidth = 0;
var defilSpanWidth2 = 0;
var defiltemps = 16000;
function defilPermanent(currentPos)
{
	//currentPos=0;
	//console.log((-defilSpanWidth)+currentPos)
	if(jQuery('.defilMove').children().length > 32) {
		defiltemps = 32000;
	}
	jQuery('.defilMove').startAnimation({'left':((-defilSpanWidth)+currentPos)+'px'}, defiltemps, 'linear', function()
	{
		jQuery('.defilMove').css('left',currentPos);
		defilPermanent(currentPos);
		//console.log(currentPos)
	})
}
  // Texte defilant (comportement de la balise marquee)
  setTimeout(function()
  {
          jQuery('.defilMove').defilMarquee(jQuery('.defilWrap'));
  },500);
jQuery.fn.defilMarquee = function(container)
{
	container.find('span').each(function(i,e)
	{
		defilSpanWidth += parseInt(jQuery(e).width()+5);
	});
	//console.log(defilSpanWidth)
	for(i=0;i<=2;i++)
	{
		container.find('span').clone().appendTo(jQuery(this));
	}
	defilSpanWidth2 = defilSpanWidth*3;
	jQuery(this).css('width',defilSpanWidth2+'px');
	defilPermanent(0);
	jQuery(this).mouseover(function()
	{
		jQuery(this).pauseAnimation();
	});
	jQuery(this).mouseout(function()
	{
		jQuery(this).resumeAnimation();
	});
}
jQuery.fn.pauseAnimation = function() {
	if( jQuery.pauseableAnimations ) {
		for(var i in jQuery.pauseableAnimations ) {
			if( jQuery.pauseableAnimations[i].target == this.get(0) ) {
				jQuery(this).stop();
				var now = new Date().getTime();
				var data = jQuery.pauseableAnimations[i];
				data.timePlayed += ( now - data.startTime );
				data.timeRemaining = data.duration - data.timePlayed;
				if( data.timePlayed > data.duration ) {
					var newArray = new Array();
					for( var p in jQuery.pauseableAnimations ) {
						if( jQuery.pauseableAnimations[p] != data ) newArray.push( jQuery.pauseableAnimations[p] );
					};
					jQuery.pauseableAnimations = newArray.length > 0 ? newArray : null;
					delete newArray;
					return this;
				};
				break;
			};
		};
	};
	return this;
};
jQuery.fn.resumeAnimation = function() {
	if( jQuery.pauseableAnimations ) {
		for(var i in jQuery.pauseableAnimations ) {
			var data = jQuery.pauseableAnimations[i];
			if( data.target == this.get(0) ) {
				this.animate( data.params, data.timeRemaining, data.easing, data.callback );
				data.startTime = new Date().getTime();
				return this;
			};
		};
	};
};
});
jQuery(function(){
  jQuery('.courDeBricolage').click(function(e){
	  e.preventDefault();
	  displayLayer(jQuery(this),'#courPratiqueBricolage');
    jQuery('#courPratiqueBricolage').show ().css (
    {
      'width': '960px',
      'top': '10px',
      'left': jQuery('#page').offset ().left + 'px'
    });
    // Ajustement du positionnement pour IE 6
    /*@cc_on
    if (@_jscript_version <= 5.7 && navigator.userAgent.indexOf ('MSIE 6.0') != -1)
    {
      jQuery('#courPratiqueBricolage').show ().css (
      {
        'top': '900px'
      });
    }
    @*/
    var dHauteurFenetre = document.documentElement.clientHeight;
    jQuery('#courPratiqueBricolage .layerProduitContent').css (
    {
      'width': '900px',
      'height': dHauteurFenetre - 65 + 'px'
    });
    jQuery('#courPratiqueBricolage .layerProduitBackground').css (
    {
      'width': '960px',
      'height': dHauteurFenetre - 20 + 'px'
    });
  });
  jQuery('.agendaCalendrier li a').click(function(e){
    //e.preventDefault();
    jQuery('.agendaCalendrier li a').removeClass('actif');
    jQuery(this).addClass('actif');
  });
  /*
  jQuery('div.detailCour').hide();
  jQuery('p.detailCour').click(function(e){
    e.preventDefault();
    if(jQuery(this).siblings('div.detailCour:visible').is(':visible')){
      jQuery(this).children('span').text('+');
      jQuery(this).siblings('div.detailCour').slideUp();
    }else{
      jQuery(this).children('span').text('-');
      jQuery(this).siblings('div.detailCour').slideDown();
    }
  });
  */
  jQuery('#courPratiqueBricolage .agenda').hide();
  jQuery('#courPratiqueBricolage .agenda:eq(0)').show();
  jQuery('#courPratiqueBricolage .agendaCalendrier li a').each(function(i){
    jQuery(this).click(function(){
      jQuery('.agenda').hide();
      jQuery('.agenda:eq('+i+')').show();
    });
  });
  function accordeon(){
	jQuery("p.detailCour").siblings("div.detailCour").hide();
	jQuery("p.detailCour").click(function(e){
		e.preventDefault();
		var paragrapheAccordeon = jQuery(this).siblings("div.detailCour");
		if(!paragrapheAccordeon.is(":visible")){
			jQuery("div.detailCour").slideUp();
			paragrapheAccordeon.slideDown();
			jQuery("p.detailCour span").text('+');
			jQuery(this).children('span').text('-');
		}else{
		  jQuery(this).children('span').text('+');
		  paragrapheAccordeon.slideUp();
		}
	});
  }
  accordeon();
  jQuery('.agenda .bloc .lienBouton').click(function(e){
    e.preventDefault();
    //console.log(jQuery('#courPratiqueBricolage .layerClose'));
    jQuery('#courPratiqueBricolage .layerClose a').trigger('click');
    displayLayer(jQuery(this),'#inscriptionCoursPratiqueBricolage');
    jQuery('#inscriptionCoursPratiqueBricolage').css({
      width: '',
      left: jQuery('#page').offset ().left + 180 + 'px'
    });
    jQuery('#inscriptionCoursPratiqueBricolage .layerProduitContent').css({
      width: '',
      height: '',
      overflow: ''
    });
    jQuery('#inscriptionCoursPratiqueBricolage .layerProduitBackground').css({
      width: '',
      height: jQuery('#inscriptionCoursPratiqueBricolage .layerProduitContent').outerHeight () + 30 + 'px'
    });
  });
});
/* fin de script Renaud */
// Impression du layer affiché
jQuery(function ()
{
  /*jQuery('#layerMagasinSeRendre .lienBouton, #courPratiqueBricolage .imprimer a, #inscriptionCoursPratiqueBricolage .imprimer a, #inscriptionCoursPratiqueBricolage a.imprimer, .layerConfortMagasin li.imprimer a').live ('click', function (e)
  {
    e.preventDefault ();
    imprimerLayer (jQuery(this));
  });*/
  jQuery('.infosPratiquesMagCont .accesMagasin').click (function (e)
  {
    e.preventDefault ();
    imprimerLayer ('#layerMagasinSeRendre');
  });
  jQuery('.courDeBricolage').click (function (e)
  {
    e.preventDefault ();
    imprimerLayer ('#courPratiqueBricolage');
  });
  jQuery('.agenda .bloc .lienBouton').click (function (e)
  {
    e.preventDefault ();
    imprimerLayer ('#inscriptionCoursPratiqueBricolage');
  });
  jQuery('.friseServicesList a').click (function (e)
  {
    e.preventDefault ();
    imprimerLayer (jQuery(this).attr ('href'));
  });
  jQuery('#layerMagasinSeRendre .layerClose a, #courPratiqueBricolage .layerClose a, #inscriptionCoursPratiqueBricolage .layerClose a, .layerConfortMagasin .fermer a, #overlay').live ('click', function (e)
  {
    e.preventDefault ();
    supprimerCSSPrintLayer ();
  });
  function imprimerLayer (selecteur)
  {
    var layer = (jQuery(selecteur).hasClass ('layerConfortMagasin'))? 'layerConfortMagasin': selecteur.replace (/#/, '');
    /*alert (selecteur);
    alert (layer);*/
    // Suppression de tout appel existant d'une feuille de style pour l'impression d'un layer
    jQuery('head link[media="print"]:last-child').remove ();
    // Suppression d'iframe (pour éviter un texte false sous IE 6 et 7)
    jQuery('#' + layer).find ('iframe').remove ();
    // Ajout de l'appel de la feuille de style pour l'impression du layer à imprimer
    jQuery('head').append ('<link rel="stylesheet" href="css/print-' + layer + '.css" type="text/css" media="print" />');
    // Neutralisation de l'overlay pour l'impression des layers confort magasin (contournement d'un bug de Safari)
    if (jQuery.browser.safari) jQuery('#overlay').unbind ('click').hide ();
  }
  // Suppression de tout appel existant d'une feuille de style pour l'impression d'un layer
  function supprimerCSSPrintLayer ()
  {
    //alert ('oui');
    jQuery('head link[media="print"]:last-child').remove ();
    //alert (jQuery('head link[media="print"]:last-child').size ());
  }
});
/*jQuery(function(){
	jQuery("#pathbarmag a").live("click",function(){
		if(getCookie("anonymous_save") == "true")
			setCookie("anonymous_save", false, null, "/", "." + document.domain)
		else if(getCookie("anonymous_save") == "false")
			setCookie("anonymous_save", true, null, "/", "." + document.domain)
		location.reload();
	});
});*/
/** Fonctions barre de recherche **/
/*function loadsearch(){
    document.intuitionnavigation.submit();
}
function loadsearchBottom(){
    document.intuitionnavigationBottom.submit();
}*/
function searchProductsAndBooks(question){
	if(question != undefined){
		document.intuitionnavigation.question.value=question
	}
    document.intuitionnavigation.intuitiontodo.value='newSearchProductsAndBooks';
    document.intuitionnavigation.submit();
}
function searchCouncilsAndIdeas(question){
	if(question != undefined){
		document.intuitionnavigation.question.value=question
	}
    document.intuitionnavigation.intuitiontodo.value='newSearchCouncilsAndIdeas';
    document.intuitionnavigation.submit();
}
function searchStoresAndServices(question){
	if(question != undefined){
		document.intuitionnavigation.question.value=question
	}
    document.intuitionnavigation.intuitiontodo.value='newSearchStoresAndServices';
    document.intuitionnavigation.submit();
}
/** Fonctions layers boutons contextuels **/
// Gestion des infobulles, repr&eacute;sent&eacute;es par la variable obj
jQuery.fn.showInfobulle = function(obj){
	var obj = obj;
	jQuery(this).each(function(i,item){
		jQuery(item).click(function(e){
			e.preventDefault();
			var offset = jQuery('body').offset();
			var posX = jQuery(this).findPos().x+10;
			var posY = jQuery(this).findPos().y+(jQuery(this).height()/2);
			//obj.bgIframe();
			if(obj.attr('class')=='layerAjouterPanier'||obj.attr('class')=='layerHighBig'||obj.attr('class')=='layerHighSmall')	{
				obj.show().css({'left':posX-offset.left-obj.width()+25+'px','top':posY-offset.top+10+'px'});
			} else if(obj.attr('class')=='layerQuantite'&&obj.attr('id')!='layerCalculette') {
				obj.show().css({'left':posX-offset.left+obj.width()+'px','top':posY-offset.top-15+'px'});
			} else if(obj.attr('class')=='layerQuantite'&&obj.attr('id')=='layerCalculette') {
				obj.show().css({'left':e.pageX-offset.left+'px','top':posY-offset.top-15+'px'});
			} else if(obj.attr('class')=='layerArticle') {
				obj.show().css({'left':posX-offset.left-obj.width()+'px','top':posY-offset.top-420+'px'});
			} else {
				obj.show().css({'left':posX-offset.left+'px','top':posY-offset.top-10+'px'});
			}
			overlay(obj);
			}
		);
	});
}
/* Recherche */
function autocompleteSelect(selected) {
	if (selected != "") {
		jQuery('#reche').val(selected);
	}
	controleRecherche(document.intuitionnavigation);
}
/** Fonction temporaire controle formulaire **/
function controleRecherche(formulaire, from){
	if (jQuery('#reche').val() == "" || !formulaire.question.changeValue) {
		return false;
	}
	var requeteRecherche = formulaire.question.value;
	requeteRecherche = requeteRecherche.toLowerCase();
	requeteRecherche = requeteRecherche.replace(/'/g, " ");
	formulaire.question.value = requeteRecherche;
	
	if (!from || from == '') from = 'submit';
	xt_med('C','1','navigation_permanente::bandeau_recherche::' + from,'N');
	formulaire.submit();
	return false;
}

