;fb.fn.steps = function(stepsContainer, navContainer) {

    this.stepsContainer = $(stepsContainer);
    this.navContainer = $(navContainer);
    this.steps = this.stepsContainer.children('li');
    this.navs = this.navContainer.children('li');
    this.current = null;
    var that = this;

    this.getStep = function(step) {
        var to = typeof step;
        if (null == step) {
            return this.current;
        } else if ('number' == to) {
            return this.steps.eq(step);
        } else if ('string' == to) {
            return $('#step-' + step);
        } else {
            return $(step);
        }
    };

    this.getNav = function(step) {
        step = this.getStep(step);
        return $('#' + step.attr('id') + '-nav');
    };

    this.next = function(step) {
        return this.steps[this.steps.index(this.getStep(step)) + 1];
    };

    this.setActive = function(step) {
        step = this.getStep(step);

        this.steps.add(this.navs).removeClass('active');
        step.add(this.getNav(step)).addClass('active');
        this.current = step;
//         $.scrollTo(that.steps.index(step) ? step : 0, 250);
        return step;
    };

    this.enable = function(step) {

        step = this.getStep(step);
        var enableToIndex = this.steps.index(step);

        $.each(this.steps, function(i){
            var elms = $(this).add(that.getNav(this));
            debug(i);
            if (i <= enableToIndex) {
                elms.filter('.disabled').removeClass('disabled')
                                        .unblock();
            } else {
                elms.not('.disabled').addClass('disabled')
                                     .block();

            }
        })
        return step;
    };

    this.select = function() {
        var step = $(this);
        if (step[0] == that.current[0] || step.is('.disabled')) {
            return;
        }
        debug(that.current.attr('id'));
        var list = step.closest('ol');
        if (list.is('.navi')) {
            var id = step.attr('id');
            step = $('#' + id.substr(0, id.length - 4));
            that.setActive(step);
            $.scrollTo(that.steps.index(step) ? step : 0, 250);
            return false;
        } else {
            that.setActive(step);
            return step;
        }
    }

    this.steps.add(this.navs).click(this.select);
}

