incremento = 0;

/* proxima imagem */
function next() {

	if(total > 0) { if(incremento >= total) { previous();
		}
		else {
			$('#proximo').trigger('click');
			foobar = setTimeout("next()", 5000);
		}
	}
}

/* imagem anterior */
function previous() {
	if(incremento <= 0) {
		next();
	}
	else {
		$('#voltar').trigger('click');
		foobar = setTimeout("previous()", 5000);
	}
}

$(document).ready(function() {
	total = $('#navSlide > li').length -1;
	
	foobar = setTimeout("next()", 5000);

	$('#proximo').click(function(){
		if(incremento < total) {
			$('#navSlide').animate({'left': '-=500px'}, 'slow', 'easeInOutBack');
			clearTimeout(foobar);
			incremento++;
		}
	});
	
	$('#voltar').click(function(){
		if(incremento > 0) {
			$('#navSlide').animate({'left': '+=500px'}, 'slow', 'easeInOutBack');
			clearTimeout(foobar);
			incremento--;
		}
	});
});

