var count = 0;
function setValues(move_me){
    count++;
    var child_lngth = $('.slide').length;
    if(count==child_lngth){
        count=0;
        move_me=0;
    }
    return move_me;
}
function returnNum(){
    $(".slide").each(function(i){
        if(count==i){
            $('.marker'+i+'').css({background: '#F58025', color: '#000000'});
        }else{
            $('.marker'+i+'').css({background: '#202020', color: '#ffffff'});
        }
    });
}

$(document).ready(function(){
    var wdth = $('.slide').outerWidth();
    var child_lngth = $('.slide').length;
    var move = parseInt($('.slide').outerWidth());
    var next = '-=' + move;
   
///CONFIGURE HOLDER AND SLIDER DIMENSIONS///
    $('.holder').css({width: $('.slide').outerWidth()}); //CONFIGURE HOLDER WIDTH
    $('.holder').css({height: $('.slide').outerHeight()}); //CONFIGURE HOLDER HEIGHT
    $('.slider').css({width: (wdth * child_lngth), float: 'right'}); //CONFIGURE SLIDER WIDTH
   
///display scale///
    $('.holder').append('<ul id="markers">');
    $(".slide").each(function(i){
        $('#markers').append('<li class="marker'+i+'">'+(i+1));
        if(i==0){
            $('.marker'+i+'').css({background: '#F58025', color: '#000000'});
        }
        $('.marker'+i).click(function(){
            var multi = i+1;
            var slide = $('.slider').outerWidth() / $('.slide').length;
                stopTimer();
                $('.slide').stop().animate({opacity: 0.1, left: -slide * i}, 400).add($('.slide').animate({opacity: 1}, 400));
                count=i;
                returnNum();
                startTimer();
        });
    });
   
    var inter;
    function startTimer(){
        inter = setInterval(function(){
                $('.slide').stop().animate({opacity: 0.1, left: setValues(next)}, 400).add($('.slide').animate({opacity: 1}, 400));
                returnNum();
            }, 6000);
    }
    function stopTimer(){
        clearInterval(inter);   
    }
   
    startTimer();
});
