$(document).ready(function() {
	totalTD = $('table#slide_poker td').length - 2;
	td_debut	= 1;
	photos_cell(td_debut, false, true);
});

function photos(etat) {
	td_debut += (etat ? +8 : -8);
	if (td_debut > totalTD) td_debut = 1;
	if (td_debut < 0) {
		td_latest = (Math.floor(totalTD/7) * 7) + 1;
		td_debut = td_latest;
	}
	photos_cell(td_debut, false, true);
}

// scrict = s'il n'y a pas les 7 images de dispo, on affiche les premieres images disponibles
function photos_cell(debut, fin, scrict) {
	td_number = 0;
	total_shows = 0;
	if (fin == false) 	fin = debut + 7;
	$('table#slide_poker td').each(function() {
		td_number++;
		if ($(this).attr('class') != 'nodeco') {
			if (td_number >= debut && td_number <= fin) {
				$(this).fadeIn();
				total_shows++;
			} else if (scrict) { // il ne faut pas effacer les dernieres images
				$(this).hide();
			}
		}
	});
	if (total_shows != 7 && scrict) {
		total_to_show = 7 - total_shows;
		photos_cell(1, total_to_show + 1, false);
	}
}