var NbSlide = SlideShow.length, CurrentSlide=0, timer1=null, timer2=null, SlidePasse = 0, CurrentSliding=0;

function startSlide(sliding){
  $("#SlideReferent").append('<img src="'+PathIMG+"/"+SlideShow[CurrentSlide]+'" id="SlideImg" alt="" onload="ShowImgSlide()" />');
  CurrentSliding = sliding; NavigSlide(); $("#SlideNavi").height( $("#SlideNavi").height() );
  $("#SlideImg").width( $("#SlideReferent").width() );
}

function heightSlide(){
  var h = $("#SlideImg").height();
  $("#SlideReferent").animate({height:h+"px"},250);
}

function ShowImgSlide(){
  clearTimeout(timer1); clearTimeout(timer2); heightSlide();
	if( EffectType == "fade" ) $("#SlideImg").fadeIn(TransIn);
	else if( EffectType == "slide" ) $("#SlideImg").slideDown(TransIn);
	NavigSlide(); if( CurrentSliding==1 ) timer2 = setTimeout(ChangeSlide,RefTemps);
}

function HideImgSlide(){
  clearTimeout(timer1); clearTimeout(timer2);
  if( EffectType == "fade" ) $("#SlideImg").fadeOut(TransOut,NextSlide);
	else if( EffectType == "slide" ) $("#SlideImg").slideUp(TransOut,NextSlide);
}
function NextSlide(){
  timer1 = setTimeout(function(){
	   $("#SlideImg").attr("src",PathIMG+"/"+SlideShow[CurrentSlide]);
	},RefTemps2);
}

function ChangeSlide(){ // Affiche l'image courante
  CurrentSlide++; if(CurrentSlide >= NbSlide) CurrentSlide=0; HideImgSlide();
}
function gotoSlide(num){ CurrentSlide=num; CurrentSliding = 0; SlidePasse = 1; ChangeSlide(); } // Stop le slide

function ReplaySlide(id){
	clearTimeout(timer1); clearTimeout(timer2);
	if( CurrentSliding == 0 ) CurrentSliding = 1;	else CurrentSliding = 0;
	if( CurrentSliding==1 ) timer1 = setTimeout(ChangeSlide,RefTemps);
	SlidePasse=0; NavigSlide();
}

function NavigSlide(){
  var opt = CurrentSlide;
  var thumb = $("#thumbSlide"+(opt+1));
  if( thumb.length!=0 ){
    thumb.parent().find('a').removeClass('select');
    thumb.addClass('select');
  }

  if( AfficheNavi==0 ) return;
	if( opt<=0 ) prec = NbSlide-2; else prec = opt-2;
	if( opt>=NbSlide ) suiv = -1; else suiv = opt;
	if( CurrentSliding == 1 ) text = "Pause"; else text = "Lecture";

	var cont = '<div><strong>PHOTOS ></strong> ';
	for( var i=1; i<NbSlide+1; i++ ){
		var select = ''; if( opt==(i-1) ) select = ' class="select"';
		cont += '<a href="javascript:;" onclick="gotoSlide('+(i-2)+');"'+select+'>'+i+'</a>';
		if(i<NbSlide) cont += " | ";
	}
	cont += ' <strong>';
	cont += '<a href="javascript:;" onclick="gotoSlide('+prec+');">&laquo;</a>';
  cont += ' <a href="javascript:;" onclick="ReplaySlide('+opt+');">'+text+'</a> ';
	cont += ' <a href="javascript:;" onclick="gotoSlide('+suiv+');">&raquo;</a>';
	cont += '</strong></div>';
	
	$("#SlideNavi").html(cont);
}
//////////////////////////FIN REFERENCE PACK

