// 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(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');

			},1000);

		}

	);

	function nav_canceltimer(timerName)

	{  if(closetimer)

	   {  window.clearTimeout(timerName);

		  timerName = null;}}

	

	jQuery('.navContentItem').hover(
		(function(){jQuery(this).addClass('hover').find('.layerNavContent').bgiframe().show();})
		,
		(function(){jQuery(this).removeClass('hover').find('.layerNavContent').hide();})
		);
	//jQuery('.accordionList').accordionList();

	//jQuery('.rollIllus').rollIllus('innerBorder');

	//jQuery('#layerIdeesConseils li').lmHover('.innerBorder');

    

  

  // 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);

        }

      });

    }

  }

 

});






