// JavaScript Document
function handleSliderChangeLeft(e, ui){ 
	clearInterval(randoms);
	if(globalCible==globalVar){
		$("#right-slider").hide("fast");
		$("#left-slider").show("fast");
	}else if(globalCible==1){
		$("#left-slider").hide("fast");
		$("#right-slider").show("fast");
	}else{
		$("#right-slider").show("fast");
		$("#left-slider").show("fast");
	}
  if(globalCible>1){
	  //$("#left-slider").show("fast");
	  var currentId = globalCible-1;		    
	  var i;
	  for(i=1; i<=globalVar;i++){
		  
		  if(currentId!=i ){			
				$("#image"+i).css("backgroundPosition","0px 0px");
		   }else{
			   $("#image"+i).css("backgroundPosition","0px -20px");
		   }
		   if(currentId==i){	
			   globalCible=i;
								  
			   $("#img"+globalCible).animate({opacity: 1}, fadeInSpeedImg);
			   $("#titre"+globalCible).animate({opacity: 1}, fadeInSpeedTitre);
			   $("#text"+globalCible).animate({opacity: 1}, fadeInSpeedTexte);
			   $("#bt"+globalCible).animate({opacity: 1}, fadeInSpeedBt);
			   
		   }else{
			   $("#img"+i).animate({opacity: 0},fadeOutSpeedImg, "linear");
			   $("#titre"+i).animate({opacity: 0},fadeOutSpeedTitre, "linear");
			   $("#text"+i).animate({opacity: 0},fadeOutSpeedTexte, "linear");
			   $("#bt"+i).animate({opacity: 0},fadeOutSpeedBt, "linear");
		   }
	   }
	   
		var largeurImages=$(".content-item").width();
		var moitieImage=(largeurImages/2);
		var windowSizeWidth = $("#aio-slideshow-bloc").width();
		var diffWidth = ((windowSizeWidth-largeurImages)/2);
	 
	  if(globalCible==globalVar){
		  var maxScroll = (($(".content-item").width()*(globalCible-2))-diffWidth);
		  $("#titre-scroll").animate({
										scrollLeft:maxScroll,
										marginLeft: "-"+diffWidth+"px"    
									  },  globalVitesseTitre);
		  
		  $("#second-scroll").animate({
										scrollLeft:maxScroll,
										marginLeft: "-"+diffWidth+"px"        
									  },  globalVitesseTexte);
		  
		  
		  $("#bt-scroll").animate({
										scrollLeft:maxScroll,
										marginLeft: "-"+diffWidth+"px"    
									  },  globalVitesseBt);
		  $("#content-scroll").animate({
										scrollLeft:maxScroll,
										marginLeft: "-"+diffWidth+"px"        
									  }, globalVitesseImg);
	  }else if(globalCible==1){
		  
		  var maxScroll=(windowSizeWidth/2)-moitieImage;		 
		  
		  $("#titre-scroll").animate({
											marginLeft: maxScroll 							
										   
									  },  { queue: false, duration: globalVitesseTitre }
		  )
		  .animate({
										
											scrollLeft:0
										   
									  },  globalVitesseTitre-200
		  );
		  
		  $("#second-scroll").animate({
										
										marginLeft: maxScroll 
												
									  },  { queue: false, duration: globalVitesseTexte })
		  .animate({
										scrollLeft:0
										
												
									  },  globalVitesseTexte-200);
		  
		  
		  $("#bt-scroll").animate({
										 
										marginLeft: maxScroll 
										 
									  },  { queue: false, duration: globalVitesseBt })
		  .animate({
										scrollLeft:0
										
										 
									  },  globalVitesseBt-200);
		  
		  $("#content-scroll").animate({
										
										marginLeft: maxScroll
											
									  }, { queue: false, duration: globalVitesseImg })
		  .animate({
									   scrollLeft:0
										
											
									  }, globalVitesseImg-200);
	  }else{
		  var maxScroll = (($(".content-item").width()*(globalCible-1))-diffWidth);
		  $("#titre-scroll").animate({
										
										marginLeft: 0   
									  },  { queue: false, duration: globalVitesseTitre-400 })  
		  .animate({
										scrollLeft:maxScroll
										   
									  },  globalVitesseTitre  
		  );
		  
		  $("#second-scroll").animate({
										
										marginLeft: 0        
									  },  { queue: false, duration: globalVitesseTexte-400 })
		  .animate({
										scrollLeft:maxScroll
											   
									  },  globalVitesseTexte);
		  
		  
		  $("#bt-scroll").animate({
										
										marginLeft: 0   
									  },  { queue: false, duration: globalVitesseBt-400 })
		  .animate({
										scrollLeft:maxScroll
											
									  },  globalVitesseBt);
		  
		  
		  $("#content-scroll").animate({
										
										marginLeft: 0    
									  }, { queue: false, duration: globalVitesseImg-400 })
		  .animate({
										scrollLeft:maxScroll
											  
									  }, globalVitesseImg);
	  }
  }else{
	//$("#left-slider").hide("fast");  
  }
  if(globalCible==globalVar){
		$("#right-slider").hide("fast");
		$("#left-slider").show("fast");
	}else if(globalCible==1){
		$("#left-slider").hide("fast");
		$("#right-slider").show("fast");
	}else{
		$("#right-slider").show("fast");
		$("#left-slider").show("fast");
	}
  randoms = setInterval("rands()", 10000);
}

function handleSliderChangeRight(e, ui)
{
	
	clearInterval(randoms);
	if(globalCible==globalVar){
		$("#right-slider").hide("fast");
		$("#left-slider").show("fast");
	}else if(globalCible==1){
		$("#left-slider").hide("fast");
		$("#right-slider").show("fast");
	}else{
		$("#right-slider").show("fast");
		$("#left-slider").show("fast");
	}
	if(globalCible<globalVar){
		//$("#right-slider").show("fast");
		var currentId = globalCible+1;		
		var i;
		for(i=1; i<=globalVar;i++){
			if(currentId!=i ){			
				$("#image"+i).css("backgroundPosition","0px 0px");
		   }else{
			   $("#image"+i).css("backgroundPosition","0px -20px");
		   }
		   if(currentId==i){	
			   globalCible=i;
								  
			   $("#img"+globalCible).animate({opacity: 1}, fadeInSpeedImg);
			   $("#titre"+globalCible).animate({opacity: 1}, fadeInSpeedTitre);
			   $("#text"+globalCible).animate({opacity: 1}, fadeInSpeedTexte);
			   $("#bt"+globalCible).animate({opacity: 1}, fadeInSpeedBt);
			  
		   }else{
			   $("#img"+i).animate({opacity: 0},fadeOutSpeedImg, "linear");
			   $("#titre"+i).animate({opacity: 0},fadeOutSpeedTitre, "linear");
			   $("#text"+i).animate({opacity: 0},fadeOutSpeedTexte, "linear");
			   $("#bt"+i).animate({opacity: 0},fadeOutSpeedBt, "linear");
		   }
	   }
	   
	   var largeurImages=$(".content-item").width();
	   var moitieImage=(largeurImages/2);
	   var windowSizeWidth = $("#aio-slideshow-bloc").width();
	  var diffWidth = ((windowSizeWidth-largeurImages)/2);
	 	   
	  if(globalCible==globalVar){
		  var maxScroll = (($(".content-item").width()*(globalCible-1))-diffWidth);
		  $("#titre-scroll").animate({
										scrollLeft:maxScroll,
										marginLeft: "-"+diffWidth+"px"   
									  },  globalVitesseTitre  
		  );
		  
		  $("#second-scroll").animate({
										scrollLeft:maxScroll,
										marginLeft: "-"+diffWidth+"px"        
									  },  globalVitesseTexte);
		  
		  
		  $("#bt-scroll").animate({
										scrollLeft:maxScroll,
										marginLeft: "-"+diffWidth+"px"
									  },  globalVitesseBt);
		  $("#content-scroll").animate({
										scrollLeft:maxScroll,
										marginLeft: "-"+diffWidth+"px"        
									  }, globalVitesseImg);
	  }else if(globalCible==1){
		  
		  var maxScroll=(windowSizeWidth/2)-moitieImage;
		 
		  
		  $("#titre-scroll").animate({
											marginLeft: maxScroll 							
										   
									  },  { queue: false, duration: globalVitesseTitre } 
		  )
		  .animate({
										
											scrollLeft:0
										   
									  },  globalVitesseTitre-200
		  );
		  
		  $("#second-scroll").animate({
										
										marginLeft: maxScroll 
												
									  },  { queue: false, duration: globalVitesseTexte })
		  .animate({
										scrollLeft:0
										
												
									  },  globalVitesseTexte-200);
		  
		  
		  $("#bt-scroll").animate({
										 
										marginLeft: maxScroll 
										 
									  },  { queue: false, duration: globalVitesseBt })
		  .animate({
										scrollLeft:0
										
										 
									  },  globalVitesseBt-200);
		  
		  $("#content-scroll").animate({
										
										marginLeft: maxScroll
											
									  }, { queue: false, duration: globalVitesseImg })
		  .animate({
									   scrollLeft:0
										
											
									  }, globalVitesseImg-200);
	  }else{
		  var maxScroll = (($(".content-item").width()*(globalCible-1))-diffWidth);
		  $("#titre-scroll").animate({
										
										marginLeft: 0  
									  },  { queue: false, duration: globalVitesseTitre-400 })  
		  .animate({
										scrollLeft:maxScroll
										   
									  },  globalVitesseTitre  
		  );
		  
		  $("#second-scroll").animate({
										
										marginLeft: 0         
									  },  { queue: false, duration: globalVitesseTexte-400 })
		  .animate({
										scrollLeft:maxScroll},  globalVitesseTexte);
		  
		  
		  $("#bt-scroll").animate({
										
										marginLeft: 0},  { queue: false, duration: globalVitesseBt-400 })
		  .animate({
										scrollLeft:maxScroll},  globalVitesseBt);
		  
		  
		  $("#content-scroll").animate({
										
										marginLeft: 0}, { queue: false, duration: globalVitesseImg-400 })
		  .animate({
										scrollLeft:maxScroll}, globalVitesseImg);
	  }
		  
	} else{
		//$("#right-slider").hide("fast");
	}
	if(globalCible==globalVar){
		$("#right-slider").hide("fast");
		$("#left-slider").show("fast");
	}else if(globalCible==1){
		$("#left-slider").hide("fast");
		$("#right-slider").show("fast");
	}else{
		$("#right-slider").show("fast");
		$("#left-slider").show("fast");
	}
	randoms = setInterval("rands()", 10000);
}

function nivControl(){
	clearInterval(randoms);
   old=globalCible;
   var currentId = $(this).attr('id');
   var i;
 
  
   for(i=1; i<=globalVar;i++){
	   if(currentId=="image"+i){	
		   globalCible=i;
	   }
   }
   
   if(globalCible==globalVar){
		$("#right-slider").hide("fast");
		$("#left-slider").show("fast");
	}else if(globalCible==1){
		$("#left-slider").hide("fast");
		$("#right-slider").show("fast");
	}else{
		$("#right-slider").show("fast");
		$("#left-slider").show("fast");
	}
   
   function complete() {		
  		$("#img"+globalCible).animate({opacity: 1}, fadeInSpeedImg);
		   $("#titre"+globalCible).animate({opacity: 1}, fadeInSpeedTitre);
		   $("#text"+globalCible).animate({opacity: 1}, fadeInSpeedTexte);
		$("#bt"+globalCible).animate({opacity: 1}, fadeInSpeedBt);
  }

   for(i=1; i<=globalVar;i++){
	   
	   if(currentId!="image"+i ){			
	   		$("#image"+i).css("backgroundPosition","0px 0px");
	   }else{
		   $("#image"+i).css("backgroundPosition","0px -20px");
	   }
	   
	   if(currentId!="image"+i ){			   
		   function btFadeOut(i){
	  			$("#bt"+i).animate({opacity: 0},{ queue: true, duration: fadeOutSpeedBt }, "linear")
				.animate({opacity: 0},fadeOutSpeedTitre, movments);
  			}
		   $("#titre"+i).delay(fadeOutSpeedTitre).animate({opacity: 0},fadeOutSpeedTitre, "linear");
		   $("#text"+i).animate({opacity: 0},fadeOutSpeedTexte, "linear");
		
			    $("#img"+i).animate({opacity: 0},fadeOutSpeedImg, "linear");
				$("#bt"+i).animate({opacity: 0},fadeOutSpeedBt, "linear");
	
		   
	   }
   }

  
  
  var largeurImages=$(".content-item").width();
  var moitieImage=(largeurImages/2);
  var windowSizeWidth = $("#aio-slideshow-bloc").width();
  var diffWidth = ((windowSizeWidth-largeurImages)/2);
 
  
  
	  if(globalCible==globalVar){
		  var maxScroll = (($(".content-item").width()*(globalCible-1))-diffWidth);
		  $("#titre-scroll").animate({
										scrollLeft:maxScroll,
										marginLeft: "-"+diffWidth+"px"},  globalVitesseTitre  
		  );
		  
		  $("#second-scroll").animate({
										scrollLeft:maxScroll,
										marginLeft: "-"+diffWidth+"px"},  globalVitesseTexte);
		  
		  
		  $("#bt-scroll").animate({
										scrollLeft:maxScroll,
										marginLeft: "-"+diffWidth+"px"},  globalVitesseBt);
		  $("#content-scroll").animate({
										scrollLeft:maxScroll,
										marginLeft: "-"+diffWidth+"px"}, globalVitesseImg, complete);
	  }else if(globalCible==1){
		  
		  var maxScroll=(windowSizeWidth/2)-moitieImage;
		 
		  
		  $("#titre-scroll").animate({
											marginLeft: maxScroll 							
										   
									  },  { queue: false, duration: globalVitesseTitre } 
		  )
		  .animate({
										
											scrollLeft:0
										   
									  },  globalVitesseTitre-200
		  );
		  
		  $("#second-scroll").animate({
										
										marginLeft: maxScroll 
												
									  },  { queue: false, duration: globalVitesseTexte })
		  .animate({
										scrollLeft:0
										
												
									  },  globalVitesseTexte-200);
		  
		  
		  $("#bt-scroll").animate({
										 
										marginLeft: maxScroll 
										 
									  },  { queue: false, duration: globalVitesseBt })
		  .animate({
										scrollLeft:0
										
										 
									  },  globalVitesseBt-200);
		  
		  $("#content-scroll").animate({
										
										marginLeft: maxScroll
											
									  }, { queue: false, duration: globalVitesseImg })
		  .animate({
									   scrollLeft:0
										
											
									  }, globalVitesseImg-200, complete);
	  }else{
		  var maxScroll = (($(".content-item").width()*(globalCible-1))-diffWidth);
		  $("#titre-scroll").animate({
										
										marginLeft: 0},  { queue: false, duration: globalVitesseTitre-400 })  
		  .animate({
										scrollLeft:maxScroll},  globalVitesseTitre  
		  );
		  
		  $("#second-scroll").animate({
										
										marginLeft: 0},  { queue: false, duration: globalVitesseTexte-400 })
		  .animate({
										scrollLeft:maxScroll},  globalVitesseTexte);
		  
		  
		  $("#bt-scroll").animate({
										
										marginLeft: 0},  { queue: false, duration: globalVitesseBt-400 })
		  .animate({
										scrollLeft:maxScroll},  globalVitesseBt);
		  
		  
		  $("#content-scroll").animate({
										
										marginLeft: 0}, { queue: false, duration: globalVitesseImg-400 })
		  .animate({
										scrollLeft:maxScroll}, globalVitesseImg, complete);
	  } 
	  if(globalCible==globalVar){
		$("#right-slider").hide("fast");
		$("#left-slider").show("fast");
	}else if(globalCible==1){
		$("#left-slider").hide("fast");
		$("#right-slider").show("fast");
	}else{
		$("#right-slider").show("fast");
		$("#left-slider").show("fast");
	}
	  randoms = setInterval("rands()", 10000);
}
function isNumeric(n){
	return !isNaN(n);
}
function randsInit(){
	
	old=globalCible;
		
	//id=Math.round( Math.random() * (4));   
	
	//if(old>1){
		var numLow = 1;
		var numHigh = 4;
	//}
	var numEvit=old;	
	
	var adjustedHigh = (parseFloat(numHigh) - parseFloat(numLow)) + 1;

	var numRand = Math.floor(Math.random()*adjustedHigh) + parseFloat(numLow);

	if (parseFloat(numLow) <= parseFloat(numHigh) && numRand!=old) {
		id=numRand;		
		
	   
	   
		if(id==old){
		   id=Math.round( Math.random() * (4));
		}
		var currentId = "image"+id;
		var i;
		
		
		for(i=1; i<=globalVar;i++){
			
		   if(currentId=="image"+i){	
			   globalCible=i;
		   }
		}
		
		function complete() {		
			$("#img"+globalCible).animate({opacity: 1}, fadeInSpeedImg);
			$("#titre"+globalCible).animate({opacity: 1}, fadeInSpeedTitre);
			$("#text"+globalCible).animate({opacity: 1}, fadeInSpeedTexte);
			$("#bt"+globalCible).animate({opacity: 1}, fadeInSpeedBt);
		}
		
		for(i=1; i<=globalVar;i++){
			if(currentId!="image"+i ){			
				$("#image"+i).css("backgroundPosition","0px 0px");
		   }else{
			   $("#image"+i).css("backgroundPosition","0px -20px");
		   }
		   if(currentId!="image"+i ){			   
			   function btFadeOut(i){
					$("#bt"+i).animate({opacity: 0},{ queue: true, duration: fadeOutSpeedBt }, "linear")
					.animate({opacity: 0},fadeOutSpeedTitre, movments);
				}
			   $("#titre"+i).delay(fadeOutSpeedTitre).animate({opacity: 0},fadeOutSpeedTitre, "linear");
			   $("#text"+i).animate({opacity: 0},fadeOutSpeedTexte, "linear");
			
					$("#img"+i).animate({opacity: 0},fadeOutSpeedImg, "linear");
					$("#bt"+i).animate({opacity: 0},fadeOutSpeedBt, "linear");
		
			   
		   }
		}
		
		
		
		var largeurImages=$(".content-item").width();
		var moitieImage=(largeurImages/2);
		var windowSizeWidth = $("#aio-slideshow-bloc").width();
		var diffWidth = ((windowSizeWidth-largeurImages)/2);
		
		
		
		if(globalCible==globalVar){
		  var maxScroll = (($(".content-item").width()*(globalCible-1))-diffWidth);
		  $("#titre-scroll").animate({
										scrollLeft:maxScroll,
										marginLeft: "-"+diffWidth+"px"},  globalVitesseTitre  
		  );
		  
		  $("#second-scroll").animate({
										scrollLeft:maxScroll,
										marginLeft: "-"+diffWidth+"px"},  globalVitesseTexte);
		  
		  
		  $("#bt-scroll").animate({
										scrollLeft:maxScroll,
										marginLeft: "-"+diffWidth+"px"},  globalVitesseBt);
		  $("#content-scroll").animate({
										scrollLeft:maxScroll,
										marginLeft: "-"+diffWidth+"px"}, globalVitesseImg, complete);
		  randoms = setInterval("rands()", 10000);
		}else if(globalCible==1){
		  
		  var maxScroll=(windowSizeWidth/2)-moitieImage;
		 
		  
		  $("#titre-scroll").animate({
											marginLeft: maxScroll 							
										   
									  },  { queue: false, duration: globalVitesseTitre } 
		  )
		  .animate({
										
											scrollLeft:0
										   
									  },  globalVitesseTitre-200
		  );
		  
		  $("#second-scroll").animate({
										
										marginLeft: maxScroll 
												
									  },  { queue: false, duration: globalVitesseTexte })
		  .animate({
										scrollLeft:0
										
												
									  },  globalVitesseTexte-200);
		  
		  
		  $("#bt-scroll").animate({
										 
										marginLeft: maxScroll 
										 
									  },  { queue: false, duration: globalVitesseBt })
		  .animate({
										scrollLeft:0
										
										 
									  },  globalVitesseBt-200);
		  
		  $("#content-scroll").animate({
										
										marginLeft: maxScroll
											
									  }, { queue: false, duration: globalVitesseImg })
		  .animate({
									   scrollLeft:0
										
											
									  }, globalVitesseImg-200, complete);
		  randoms = setInterval("rands()", 10000);
		}else{
		  var maxScroll = (($(".content-item").width()*(globalCible-1))-diffWidth);
		  $("#titre-scroll").animate({
										
										marginLeft: 0},  { queue: false, duration: globalVitesseTitre-400 })  
		  .animate({
										scrollLeft:maxScroll},  globalVitesseTitre  
		  );
		  
		  $("#second-scroll").animate({
										
										marginLeft: 0},  { queue: false, duration: globalVitesseTexte-400 })
		  .animate({
										scrollLeft:maxScroll},  globalVitesseTexte);
		  
		  
		  $("#bt-scroll").animate({
										
										marginLeft: 0},  { queue: false, duration: globalVitesseBt-400 })
		  .animate({
										scrollLeft:maxScroll},  globalVitesseBt);
		  
		  
		  $("#content-scroll").animate({
										
										marginLeft: 0}, { queue: false, duration: globalVitesseImg-400 })
		  .animate({
										scrollLeft:maxScroll}, globalVitesseImg, complete);
		  randoms = setInterval("rands()", 10000);
		}
		
	}
	
}
function rands(){
	
	old=globalCible;
		
	//id=Math.round( Math.random() * (4));   
	
	//if(old>1){
		var numLow = 1;
		var numHigh = 4;
	//}
	var numEvit=old;	
	
	var adjustedHigh = (parseFloat(numHigh) - parseFloat(numLow)) + 1;

	var numRand = Math.floor(Math.random()*adjustedHigh) + parseFloat(numLow);

	if (parseFloat(numLow) <= parseFloat(numHigh) && numRand!=old) {
		id=numRand;		
	
   
   
   if(id==old){
	   id=Math.round( Math.random() * (4));
   }
   var currentId = "image"+id;
   var i;
 
  
   for(i=1; i<=globalVar;i++){
	   if(currentId=="image"+i){	
		   globalCible=i;
	   }
   }
   
   function complete() {	
   		
  		$("#img"+globalCible).animate({opacity: 1}, fadeInSpeedImg);
		$("#titre"+globalCible).animate({opacity: 1}, fadeInSpeedTitre);
		$("#text"+globalCible).animate({opacity: 1}, fadeInSpeedTexte);
		$("#bt"+globalCible).animate({opacity: 1}, fadeInSpeedBt);
  }

   for(i=1; i<=globalVar;i++){
	   if(currentId!="image"+i ){			
				$("#image"+i).css("backgroundPosition","0px 0px");
		   }else{
			   $("#image"+i).css("backgroundPosition","0px -20px");
		   }
	   if(currentId!="image"+i ){			   
		   function btFadeOut(i){
	  			$("#bt"+i).animate({opacity: 0},{ queue: true, duration: fadeOutSpeedBt }, "linear")
				.animate({opacity: 0},fadeOutSpeedTitre, movments);
  			}
		   $("#titre"+i).delay(fadeOutSpeedTitre).animate({opacity: 0},fadeOutSpeedTitre, "linear");
		   $("#text"+i).animate({opacity: 0},fadeOutSpeedTexte, "linear");
		
			    $("#img"+i).animate({opacity: 0},fadeOutSpeedImg, "linear");
				$("#bt"+i).animate({opacity: 0},fadeOutSpeedBt, "linear");
	
		   
	   }
   }

  
  
  var largeurImages=$(".content-item").width();
  var moitieImage=(largeurImages/2);
  var windowSizeWidth = $("#aio-slideshow-bloc").width();
  var diffWidth = ((windowSizeWidth-largeurImages)/2);
 
  
  
	  if(globalCible==globalVar){
		  var maxScroll = (($(".content-item").width()*(globalCible-1))-diffWidth);
		  $("#titre-scroll").animate({
										scrollLeft:maxScroll,
										marginLeft: "-"+diffWidth+"px"},  globalVitesseTitre  
		  );
		  
		  $("#second-scroll").animate({
										scrollLeft:maxScroll,
										marginLeft: "-"+diffWidth+"px"},  globalVitesseTexte);
		  
		  
		  $("#bt-scroll").animate({
										scrollLeft:maxScroll,
										marginLeft: "-"+diffWidth+"px"},  globalVitesseBt);
		  $("#content-scroll").animate({
										scrollLeft:maxScroll,
										marginLeft: "-"+diffWidth+"px"}, globalVitesseImg, complete);
	  }else if(globalCible==1){
		  
		  var maxScroll=(windowSizeWidth/2)-moitieImage;
		 
		  
		  $("#titre-scroll").animate({
											marginLeft: maxScroll 							
										   
									  },  { queue: false, duration: globalVitesseTitre } 
		  )
		  .animate({
										
											scrollLeft:0
										   
									  },  globalVitesseTitre-200
		  );
		  
		  $("#second-scroll").animate({
										
										marginLeft: maxScroll 
												
									  },  { queue: false, duration: globalVitesseTexte })
		  .animate({
										scrollLeft:0
										
												
									  },  globalVitesseTexte-200);
		  
		  
		  $("#bt-scroll").animate({
										 
										marginLeft: maxScroll 
										 
									  },  { queue: false, duration: globalVitesseBt })
		  .animate({
										scrollLeft:0
										
										 
									  },  globalVitesseBt-200);
		  
		  $("#content-scroll").animate({
										
										marginLeft: maxScroll
											
									  }, { queue: false, duration: globalVitesseImg })
		  .animate({
									   scrollLeft:0
										
											
									  }, globalVitesseImg-200, complete);
	  }else{
		  var maxScroll = (($(".content-item").width()*(globalCible-1))-diffWidth);
		  $("#titre-scroll").animate({
										
										marginLeft: 0},  { queue: false, duration: globalVitesseTitre-400 })  
		  .animate({
										scrollLeft:maxScroll},  globalVitesseTitre  
		  );
		  
		  $("#second-scroll").animate({
										
										marginLeft: 0},  { queue: false, duration: globalVitesseTexte-400 })
		  .animate({
										scrollLeft:maxScroll},  globalVitesseTexte);
		  
		  
		  $("#bt-scroll").animate({
										
										marginLeft: 0},  { queue: false, duration: globalVitesseBt-400 })
		  .animate({
										scrollLeft:maxScroll},  globalVitesseBt);
		  
		  
		  $("#content-scroll").animate({
										
										marginLeft: 0}, { queue: false, duration: globalVitesseImg-400 })
		  .animate({
										scrollLeft:maxScroll}, globalVitesseImg, complete);
	  }
	  
	} else{
		clearInterval(randoms); 
		randoms = setInterval("rands()", 10000);
	}
	if(globalCible==globalVar){
		$("#right-slider").hide("fast");
		$("#left-slider").show("fast");
	}else if(globalCible==1){
		$("#left-slider").hide("fast");
		$("#right-slider").show("fast");
	}else{
		$("#right-slider").show("fast");
		$("#left-slider").show("fast");
	}
}

function resizeWindow(globalCible){
	//clearInterval(randoms); 
	//randsInit();
	randoms = setInterval("rands()", 10000);
	/*for(i=1; i<=globalVar;i++){
		if(i!=globalCible){
			$("#img"+i).animate({opacity: 0}, 100);
			$("#titre"+i).animate({opacity: 0}, 100);
			$("#text"+i).animate({opacity: 0}, 100);
			$("#bt"+i).animate({opacity: 0}, 100);
		}
		
	}*/
	
   
		
		//
	
	
   
  /* 
   
   
   var currentId = globalCible;
   var i;
 
  function complete() {		
		
  }
  
   for(i=1; i<=globalVar;i++){
	   if(currentId==i){	
		   globalCible=i;
		      		   		  
		   $("#img"+globalCible).animate({opacity: 1}, fadeInSpeedImg);
		   $("#titre"+globalCible).animate({opacity: 1}, fadeInSpeedTitre);
		   $("#text"+globalCible).animate({opacity: 1}, fadeInSpeedTexte);
		   $("#bt"+globalCible).animate({opacity: 1}, fadeInSpeedBt);
		
	   }else{
		   $("#img"+i).animate({opacity: 0},fadeOutSpeedImg, "linear");
		   $("#titre"+i).animate({opacity: 0},fadeOutSpeedTitre, "linear");
		   $("#text"+i).animate({opacity: 0},fadeOutSpeedTexte, "linear");
		   $("#bt"+i).animate({opacity: 0},fadeOutSpeedBt, "linear");
	   }
   }
   
   var largeurImages=$(".content-item").width();
   var moitieImage=(largeurImages/2);
   var windowSizeWidth = $("#aio-slideshow-bloc").width();
  var diffWidth = ((windowSizeWidth-largeurImages)/2);
 
  
  if(globalCible==globalVar){
	  var maxScroll = (($(".content-item").width()*(globalCible-1))-diffWidth);
	  $("#titre-scroll").animate({
									scrollLeft:maxScroll,
									marginLeft: "-"+diffWidth+"px"},  1  
	  );
	  
	  $("#second-scroll").animate({
									scrollLeft:maxScroll,
									marginLeft: "-"+diffWidth+"px"},  1);
	  
	  
	  $("#bt-scroll").animate({
									scrollLeft:maxScroll,
									marginLeft: "-"+diffWidth+"px"},  1);
	  $("#content-scroll").animate({
									scrollLeft:maxScroll,
									marginLeft: "-"+diffWidth+"px"}, 1);
  }else if(globalCible==1){
	  
	  var maxScroll=(windowSizeWidth/2)-moitieImage;
	
	  $("#titre-scroll").animate({
								 								
									   scrollLeft:0
								  },  { queue: false, duration: 1 } 
	  )
	  .animate({
								 	marginLeft: maxScroll 	
										
									   
								  },  1
	  );
	  
	  $("#second-scroll").animate({
								  	
									scrollLeft:0
									        
								  },  { queue: false, duration: 1 })
	  .animate({
								  	
									marginLeft: maxScroll 
									        
								  },  1);
	  
	  
	  $("#bt-scroll").animate({
							  		 
									
									 scrollLeft:0
								  },  { queue: false, duration: 1 })
	  .animate({
							  		
									marginLeft: maxScroll 
									 
								  },  1);
	  
	  $("#content-scroll").animate({
								    scrollLeft:0
									
									    
								  }, { queue: false, duration: 1 })
	  .animate({
								   marginLeft: maxScroll
									
									    
								  }, 1);
  }else{
	  var maxScroll = (($(".content-item").width()*(globalCible-1))-diffWidth);
	  $("#titre-scroll").animate({
									
									marginLeft: 0},  { queue: false, duration: 1 })  
	  .animate({
									scrollLeft:maxScroll},  1  
	  );
	  
	  $("#second-scroll").animate({
									
									marginLeft: 0},  { queue: false, duration: 1 })
	  .animate({
									scrollLeft:maxScroll},  1);
	  
	  
	  $("#bt-scroll").animate({
									
									marginLeft: 0},  { queue: false, duration: 1 })
	  .animate({
									scrollLeft:maxScroll},  1);
	  
	  
	  $("#content-scroll").animate({
									
									marginLeft: 0}, { queue: false, duration: 1 })
	  .animate({
									scrollLeft:maxScroll}, 1);
  }*/
  
  
}





function init(){
	
	var currentId=1;
	
	for(i=1; i<=globalVar;i++){
	 	$("<span id='image"+i+"' class='nivo-control'>"+i+"</span>").appendTo("div#nivo"); 
	  
		$("#image"+i).slider({
						   
			animate: true,	
			change: nivControl
		
		});
	   $("#img"+i).animate({opacity: 0},1, "linear");
	   $("#titre"+i).animate({opacity: 0},1, "linear");
	   $("#text"+i).animate({opacity: 0},1, "linear");
	   $("#bt"+i).animate({opacity: 0},1, "linear");
		
		$("#second-scroll").show("fast");
		$("#titre-scroll").show("fast");
		$("#content-scroll").show("fast");
		$("#bt-scroll").show("fast");
		if(currentId!=i ){			
				$("#image"+i).css("backgroundPosition","0px 0px");
		   }else{
			   $("#image"+i).css("backgroundPosition","0px -20px");
		   }
		if(currentId==i){	
		   globalCible=i;
							  
		  /* $("#img"+globalCible).animate({opacity: 1}, fadeInSpeedImg);
		   $("#titre"+globalCible).animate({opacity: 1}, fadeInSpeedTitre);
		   $("#text"+globalCible).animate({opacity: 1}, fadeInSpeedTexte);
		   $("#bt"+globalCible).animate({opacity: 1}, fadeInSpeedBt);*/
		  
		}else{
		  /* $("#img"+i).animate({opacity: 0},fadeOutSpeedImg, "linear");
		   $("#titre"+i).animate({opacity: 0},fadeOutSpeedTitre, "linear");
		   $("#text"+i).animate({opacity: 0},fadeOutSpeedTexte, "linear");
		   $("#bt"+i).animate({opacity: 0},fadeOutSpeedBt, "linear");*/
		}
	}
	
	var largeurImages=$(".content-item").width();
	var moitieImage=(largeurImages/2);
	var windowSizeWidth = $("#aio-slideshow-bloc").width();
	var diffWidth = ((windowSizeWidth-largeurImages)/2);

	//var maxScroll=(windowSizeWidth/2)-485;
	
	/*$("#titre-scroll").animate({
								
								marginLeft: maxScroll},  200  
	);
	
	$("#second-scroll").animate({
								
								marginLeft: maxScroll},  200);
	
	
	$("#bt-scroll").animate({
								
								marginLeft: maxScroll},  200);
	$("#content-scroll").animate({
								
								marginLeft: maxScroll}, 200); */
	
	
	var maxScroll=(windowSizeWidth/2)-moitieImage;
	
	  $("#titre-scroll").animate({
								 								
									   scrollLeft:0
								  },  { queue: false, duration: globalVitesseTitre } 
	  )
	  .animate({
								 	marginLeft: maxScroll 	
										
									   
								  },  1
	  );
	  
	  $("#second-scroll").animate({
								  	
									scrollLeft:0
									        
								  },  { queue: false, duration: globalVitesseTexte })
	  .animate({
								  	
									marginLeft: maxScroll 
									        
								  },  1);
	  
	  
	  $("#bt-scroll").animate({
							  		 
									
									 scrollLeft:0
								  },  { queue: false, duration: globalVitesseBt })
	  .animate({
							  		
									marginLeft: maxScroll 
									 
								  },  1);
	  
	  $("#content-scroll").animate({
								    scrollLeft:0
									
									    
								  }, { queue: false, duration: globalVitesseImg })
	  .animate({
								   marginLeft: maxScroll
									
									    
								  }, 1);
	  
	  
	  
	
	$("#titre1").animate({opacity: 1},fadeInSpeedTitre, "linear");
   $("#text1").animate({opacity: 1},fadeInSpeedTexte, "linear");
   $("#bt1").animate({opacity: 1},fadeInSpeedBt, "linear");
   $("#img1").animate({opacity: 1},fadeInSpeedImg, "linear");
	//randoms = randsInit();
	if(globalCible==globalVar){
		$("#right-slider").hide("fast");
		$("#left-slider").show("fast");
	}else if(globalCible==1){
		$("#left-slider").hide("fast");
		$("#right-slider").show("fast");
	}else{
		$("#right-slider").show("fast");
		$("#left-slider").show("fast");
	}
	randoms = setInterval("rands()", 10000);
 
}


function handleSliderSlideLeft(e, ui)
{

}

function handleSliderSlideRight(e, ui)
{

}
