function hideButtons() {
    $(' .jQprev').stop().css({ display: 'none' });
    $(' .jQnext').stop().css({ display: 'none' });

    //Disable number buttons
    $('#controls ol').css({ display: 'none' });
}

function showButtons() {
    $(' .jQprev').stop().css({ display: 'block' });
    $(' .jQnext').stop().css({ display: 'block' });

    //Enable number buttons
    $('#controls ol').css({ display: 'block' });
}
function makeSelected(button) {
    $('#controls ol li a').removeClass("active");
    currentIndex = parseInt($(button).attr('class'));
    $(button).addClass("active");
}
function createCarousel(carouselSpeed, carouselScrollTime) {
    //Create go buttons Array
    if ($('#controls ol li').size() == 0) {
        $('.highlights ul li').each(function (i) {

            if ((i + 1) == currentIndex)
                var li = $(document.createElement('li')).html('<a class="' + (i + 1) + ' active" onClick="makeSelected(this)">&bull;</a>').appendTo('#controls ol');
            else
                var li = $(document.createElement('li')).html('<a class="' + (i + 1) + '" onClick="makeSelected(this)">&bull;</a>').appendTo('#controls ol');
            goButtonsArray.push('.' + (i + 1));

        });
    }
    listSize = $('#controls ol li').size();

    $(".highlights").jCarouselLite({
        auto: true,
        speed: 0, //carouselSpeed,
        timeout: carouselScrollTime,
        visible: 1,
        start: 0,
        easing: "easeOutSine",
        btnNext: " .jQnext",
        btnPrev: " .jQprev",
        btnGo: goButtonsArray,
        beforeStart: function (a) {
            advanceCounter = 0;
            $(a).parent().fadeTo(1000, 0);
            var bg = $(a).find('a').attr('style');
            bg = bg.substring(16, bg.length - 2);
            $('.highlights').css({
                backgroundImage: "url(" + bg + ")"
            }, 1000);
//            hideButtons();
        },
        afterEnd: function (a) {
            advanceCounter = 0;
            var currentButton = $('.' + currentIndex);
            makeSelected(currentButton);
            //showText(currentIndex);
//            showButtons();
            $(a).parent().fadeTo(1000, 1);
        }
    });
}
