$(document).ready(function() {
	var maxImages=13;
	var imageIndex=0;
	var transition=true;
	
	$("#fichas_info").html((imageIndex+1)+'/'+maxImages);
	
	function showNextImage(){
		if(transition){
			transition=false;
			$('#right #ficha_'+imageIndex).css("z-index","1");
			$('#right #ficha_'+imageIndex).animate({"left": "+=430px"}, 1000);
	
			imageIndex++;
			imageIndex=imageIndex%maxImages;
			$("#fichas_info").html((imageIndex+1)+'/'+maxImages);
			
			$('#right #ficha_'+imageIndex).css("z-index","2");
			$('#right #ficha_'+imageIndex).animate({"left": "-=430px"}, 1000,function(){
				transition=true;
			});
		}
	}
	function showPreviousImage(){
		if(transition){
			transition=false;
			$('#right #ficha_'+imageIndex).css("z-index","2");
			$('#right #ficha_'+imageIndex).animate({"left": "+=430px"}, 1000);
			imageIndex--;
			if(imageIndex < 0) imageIndex=(maxImages-1);
			$("#fichas_info").html((imageIndex+1)+'/'+maxImages);
			$('#right #ficha_'+imageIndex).css("z-index","1");
			$('#right #ficha_'+imageIndex).animate({"left": "-=430px"}, 1000,function(){
				transition=true;
			});
		}
	}
	
	$('#right #ButtonNext').click(function(){
			showNextImage();
			return false;
	});
	$('#right #ButtonBack').click(function(){
			showPreviousImage();
			return false;
	});	

});