var ALWAYS_OPEN = true; var REMEMBER_CLOSE = true; var REMEMBER_DATE = 1; var carouseling = false; function leftCarousel() { if (carouseling) { return; } carouseling = true; var active = $('#BANNER_WRAP .carousel_inner .item.active'); var last = $('#BANNER_WRAP .carousel_inner .item').last(); active.before(last); var width = last.width(); $('#BANNER_WRAP .carousel_inner').css('left', '-'+width+'px'); $('#BANNER_WRAP .carousel_inner').animate({ 'left': 0 }, 500, function() { active.removeClass('active').prev().addClass('active'); carouseling = false; }); }; function rightCarousel() { if (carouseling) { return; } carouseling = true; var active = $('#BANNER_WRAP .carousel_inner .item.active'); var width = active.width(); $('#BANNER_WRAP .carousel_inner').animate({ 'left': '-=' + width }, 500, function() { active.removeClass('active').next().addClass('active'); $('#BANNER_WRAP .carousel_inner').css('left', '0').append(active); carouseling = false; }); }; function autoCarousel() { setTimeout(function() { rightCarousel(); autoCarousel(); }, 3000); }; function initCarousel() { $('#BANNER_WRAP .carousel-control.left').click(function(event) { event.preventDefault(); leftCarousel(); return false; }); $('#BANNER_WRAP .carousel-control.right').click(function(event) { event.preventDefault(); rightCarousel(); return false; }); autoCarousel(); }; $(document).ready(function() { initCarousel(); });