$.fn.sliderjoueur = function () {
	
	var num = '';

	$('.info').hide();
	$('#info-1').show();
	$('#joueur-1').children('.spot').addClass("spot-actif");
	
	$('.slider-tot').children().each(function(){
		var num = $(this).attr('id');
		var posjoueur = num.lastIndexOf('-');
		var numjoueur = num.substring(posjoueur+1)
		// alert(numjoueur);
		$(this).click(function(){
			$('.spot-actif').removeClass('spot-actif');
			$('.info').hide();
			$('#info-'+numjoueur).show();
			$(this).children('.spot').addClass("spot-actif");
		});
		
		$(this).hover(
			function () {
				 $('.spot', this).addClass("spot-hover");
			},
			function () {
				$('.spot', this).removeClass("spot-hover");
			}
		);
		
		
	});
	
	var nmrelement = parseInt($('.fiche-joueur').size());
	var nmbrdecalage = 4;
	
	// alert(nmrelement);
	
	var widthjoueur = parseInt($('.fiche-joueur').width());
	var marginjoueur = parseInt($('.fiche-joueur').css("margin-left"));
	var sizefichejoueur = widthjoueur+marginjoueur;
	var sizetochange = nmbrdecalage*sizefichejoueur;
	var nmbrpage = Math.ceil(nmrelement/nmbrdecalage);
	var sizetotal = nmbrpage*nmbrdecalage*sizefichejoueur;
	$('.slider-tot').width(sizetotal);
	// alert(sizetotal);
	// var sizejoueur = 816;
	// var sizetotal = $('.slider-tot').width();
	// alert(sizetotal);
	var margin_actuelle = 0;
	
	$('.right').click(function(){
		margin_actuelle = (margin_actuelle-sizetochange)%sizetotal;
		$('.slider-tot').animate({marginLeft:margin_actuelle+'px'},1000); 
	});
	$('.left').click(function(){ 
		if (margin_actuelle >= 0){
			margin_actuelle = (sizetochange-sizetotal);
		} else {
			margin_actuelle = (margin_actuelle+sizetochange)%sizetotal;
		}
		$('.slider-tot').animate({marginLeft:margin_actuelle+"px"},1000);
	});	

	
}
