$(document).ready(function() {
						   
	var img_actual = 1;
	var img_total = $("#ListaImg li").length;
	var mov = false;
	var img_width = 689;
	
	if (img_total > 1) {
	
		nextImg = function(e) {
			if ( (!mov) ) {
				mov = true;
				
				$("#ListaImg").animate({
					
					left: - (img_width)
				}, 1500, function() {
					img_actual++;
					$('#ListaImg li:first-child').clone().appendTo('#ListaImg').css({left:(img_width * img_total)});
					$('#ListaImg li:first-child').remove();
					$('#ListaImg li').each(function(i,e) {
						var left = $(e).position().left;
						$(e).css({left: (left - img_width)});
					});
					$('#ListaImg').css({left:0});
					mov = false;
				});
			}
		}
		
		prevImg = function(e) {
			if ( (!mov) ) {
				
				mov = true;
				$('#ListaImg li:last-child').clone().prependTo('#ListaImg').css({left:-(img_width)});
				$('#ListaImg li:last-child').remove();
				$('#ListaImg li').each(function(i,e) {
					var left = $(e).position().left;
					$(e).css({left: (left + img_width)});
				});
				$('#ListaImg').css({left:-(img_width)});
				$("#ListaImg").animate({
					left: 0
				}, 1500, function() {
					img_actual--;
					mov = false;
				});
			}
				
		}
	
		$('#FlechaSiguiente a').click(function(e) {
			clearInterval(play);
			nextImg(e);
			play = setInterval(nextImg, 5000);
		});
		$('#FlechaAnterior a').click(function(e) {
			clearInterval(play);
			prevImg(e);
			play = setInterval(nextIm, 5000);
		});
	
	
		play = setInterval(nextImg, 5000);
	}
});
