/**
 * lsc Javascript
 *
 */

lsc = {

    activeSlide : 1
    ,_slideSpeed : 500
    ,maxSlides   : 6
    ,timer : null
    ,speed : 6000

    ,domReady: function() {
        this.resetTimer();
    }



    ,gotoSlide: function(slide) {
        _ = this;

        // Animate to this slide
        $('#featuresContainer').animate({
            left: '-' + ((slide - 1) * 920) + 'px'
        }, _.slideSpeed);

        $('#carousel_nav a').removeClass('active');
        $('#carousel_nav a[rel=' + slide + ']').addClass('active');
        _.activeSlide = slide;

        _.resetTimer();
    }



    ,gotoNext: function() {
        if(this.activeSlide >= this.maxSlides) {
            this.gotoSlide(1);
        } else {
            this.gotoSlide(this.activeSlide + 1);
        }

        _.resetTimer();
    }


    ,gotoBack: function() {
        if(this.activeSlide <= 1) {
            this.gotoSlide(this.maxSlides);
        } else {
            this.gotoSlide(this.activeSlide - 1);
        }

        _.resetTimer();
    }

    ,resetTimer: function() {
        if(typeof this.timer != null) {
            clearInterval(this.timer);
        }
        this.timer = setInterval(function() {
            lsc.gotoNext();
        }, this.speed);
    }

}

$(function() { lsc.domReady(); });

