var ecransPos=[1,1,1];var ecransInt=0;$(function(){var blocEcran1=$('#ecran1');var firstHtml=blocEcran1.children('li:first').html();var lastHtml=blocEcran1.children('li:last').html();blocEcran1.prepend('<li>'+lastHtml+'</li>');blocEcran1.append('<li>'+firstHtml+'</li>');blocEcran1.after('<ul id="ecran2" class="ecrans">'+blocEcran1.html()+'</ul>'+'<ul id="ecran3" class="ecrans">'+blocEcran1.html()+'</ul><a href="javascript:ecransScroll(-1)" title="Réalisation précédente" class="btDefilEcran" id="btDefilPrev"></a><a href="javascript:ecransScroll(1)" title="Réalisation suivante" class="btDefilEcran" id="btDefilNext"></a><ul id="ecransCaption"></ul>');$('.ecrans').each(function(i)
{var ecran=$(this);var width=ecran.innerWidth();var childs=ecran.children('li');for(var i=0;i<childs.length;i++)
{childs.eq(i).css('left',(i*width)+'px');}});$('#ecran1 li img:last-child').each(function(i)
{$('#ecransCaption').append('<li></li>').children('li:last').append($(this).clone());});$('#ecran1 li img:first-child, #ecran3 li img:first-child').each(function(i)
{this.width=258;this.height=155;});$('.ecrans li img:last-child').each(function(i)
{$(this).hide();});ecranScroll(1,-1,false);ecranScroll(2,0,false);ecranScroll(3,1,false);ecransInt=setTimeout('ecransScroll(1)',7000);});function ecransScroll(value)
{$('.ecrans').stop(true,true);ecranScroll(1,value,true);ecranScroll(2,value,true);ecranScroll(3,value,true);if(ecransInt>0)
{clearTimeout(ecransInt);}
ecransInt=setTimeout('ecransScroll(1)',7000);}
function ecranScroll(ecranIndex,value,effect)
{var ecran=$('#ecran'+ecranIndex);var caption=$('#ecransCaption');var width=ecran.innerWidth();ecranIndex--;var nbChilds=ecran.children('li').length-2;ecransPos[ecranIndex]+=value;if(ecransPos[ecranIndex]<1)
{ecransPos[ecranIndex]+=nbChilds;ecran.scrollLeft((ecransPos[ecranIndex]+1)*width);if(ecranIndex==1)
{caption.scrollTop((ecransPos[ecranIndex]+1)*41);}}
else if(ecransPos[ecranIndex]>nbChilds)
{ecransPos[ecranIndex]-=nbChilds;ecran.scrollLeft((ecransPos[ecranIndex]-1)*width);if(ecranIndex==1)
{caption.scrollTop((ecransPos[ecranIndex]-1)*41);}}
if(effect)
{ecran.animate({scrollLeft:(ecransPos[ecranIndex]*width)},500);if(ecranIndex==1)
{caption.animate({scrollTop:(ecransPos[ecranIndex]*41)},500);}}
else
{ecran.scrollLeft(ecransPos[ecranIndex]*width);if(ecranIndex==1)
{caption.scrollTop(ecransPos[ecranIndex]*41);}}}