var currentPosition = 0;
var slides = $(".myclass");
var numberOfSlides = slides.length;
manageControls(currentPosition);
function manageControls(position){
var count = document.getElementById("count");
count.innerHTML =(position + 1) + "/" + numberOfSlides;
}
setActive(0);
$('li').click(function() {
setActive($(this).index());
manageControls($(this).index());
});
$(".next").click(function(){
var current = $('ul li.selected').index(),
maxIndex = $('ul li').length - 1,
next = (current + 1) > maxIndex ? 0 : (current + 1);
manageControls(next);
setActive(next);
});
function setActive(i) {
var li = $('ul li').eq(i);
$('ul li').removeClass('selected');
li.addClass('selected');
$('.myclass').removeClass('selected');
$('.myclass').eq(i).addClass('selected');
}