positionImage = new Array();
var description = new Array();
var timers = new Array();
widthTotal = 0;
heightTotal = 0;
familleActuelle = 0;
function afficheGrande(ID, position){



var famille = $("#liste_miniatures a#"+ID).parent().attr('name');
	$("#liste_miniatures img#"+ID).removeClass("origin");
	$("#liste_miniatures img#"+ID).addClass("light");

	$("#grande_photo").html("<a id='"+ID+"' rel='gallerie' href='/cgi-local/album_photo.pl?Action=Image&ID="+ID+"&format=Photo'><img src='/cgi-local/album_photo.pl?Action=Image&ID="+ID+"&format=Photo' border='0' alt='' title=''></a>");
	$("#liste_miniatures a[rel='desactive']").attr("rel", "gallerie");
	$("#liste_miniatures a[rel='gallerie'][id='"+ID+"']").attr("rel", "desactive");
	



position_img = position;


//alert(position);

	$("a[rel='gallerie']").colorbox({photo:'false', current:'image {current} sur {total}'});


	$("#description_photo").html(description[ID]);


}

function clearAllTimeouts(){  
  for(key in timers ){  
    clearTimeout(timers[key]);  
  }  
}  


function goLeft(el){

famille = $(el).attr("name");
pos = $(".liste_miniatures.famille"+famille).css("left");

if(widthTotal < 1 || famille != familleActuelle)
{
widthTotal = 0;
nbImage = 0;
widthImages = 0;
$(".liste_miniatures.famille"+famille+" img").each(function(i){
widthImages += $(this).outerWidth();
nbImage++;
});

marge = parseInt($(".liste_miniatures.famille"+famille+" img").css("marginRight"));
//bordure = parseInt($("#liste_miniatures[name="+famille+"] img").css("border-left"));

widthMarges = marge*2*nbImage - (2*marge);
//widthBordures = bordure*2*nbImage;

widthTotal = widthImages + widthMarges;
}

familleActuelle = famille;
//alert($("#liste_miniatures img:last-child").offset().left);
pos= parseInt(pos);
abspos = Math.abs(pos);



if( widthTotal - $("#bloc_miniatures").width() > abspos )
{
	newpos = pos-2;
	$(".liste_miniatures.famille"+famille).css("left",newpos+"px");

	timers.pop;
	timers.push(setTimeout(function(){goLeft(el);}, 1));
}
}



function goRight(el){
famille = $(el).attr("name");
pos = $(".liste_miniatures.famille"+famille).css("left");

if(parseInt(pos)<0)
{
	newpos = parseInt(pos)+2;
	$(".liste_miniatures.famille"+famille).css("left",newpos+"px");	
	timers.pop;
	timers.push(setTimeout(function(){goRight(el);}, 1));
}
}



$(window).load(function(){

$(".liste_miniatures img").mouseover(function(){
ID = $(this).attr("id");
$(this).removeClass("origin");
$(this).addClass("light");
});


$(".liste_miniatures img").mouseout(function(){
$(this).removeClass("light");
$(this).addClass("origin");
});






$("img.gauche").mouseover(function(){
goRight($(this));
});

$(".gauche").mouseout(function(){
clearAllTimeouts();
});

$("img.droite").mouseover(function(){
goLeft($(this));
});

$(".droite").mouseout(function(){

clearAllTimeouts();
});

});



