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



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

	jQuery("#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>");
	jQuery("#liste_miniatures a[rel='desactive']").attr("rel", "gallerie");
	jQuery("#liste_miniatures a[rel='gallerie'][id='"+ID+"']").attr("rel", "desactive");




position_img = position;


//alert(position);

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


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


}

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


function goLeft(el){

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

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

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

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

widthTotal = widthImages + widthMarges;
}

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



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

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



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



jQuery(window).load(function(){

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


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






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

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

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

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

clearAllTimeouts();
});

});



