var Landing = new Class({
    
    Implements: [Options, Events],

    options: {
        'list_items' : { 0 : 'create', 1 : 'earn', 2 : 'meet' },
        'current_item' : 0
    },

    initialize: function() {
        this.switcherId = 0;
        this.initDivSwitcher();
    },
    
    stopDivSwitcher: function() {
        if (this.switcherId > 0) {
            clearInterval(this.switcherId);
        }
    },

    initDivSwitcher: function() {
        this.switcherId = setInterval("landing.updateShownDiv()", 9000);
    },

    updateShownDiv: function() {
        var currentItemId = this.options.current_item + 1;
        
        if (currentItemId > 2) {
            currentItemId = 0;
        }

        this.showDiv(currentItemId);
    },

    showDiv: function(divId) {
        var previous = this.options.list_items[this.options.current_item];
        var which = this.options.list_items[divId];

        $(previous + '_li').removeClass('selected');
        $(which + '_li').addClass('selected');

        new Fx.Tween(previous + '_div').start('opacity', 0).chain(function() {
            $(previous + '_div').removeClass('active');
            $(which + '_div').setStyle('opacity', 0);
            $(which + '_div').addClass('active');
            new Fx.Tween(which + '_div').start('opacity', 1);
        });

        this.options.current_item = divId;
    },

    stopAndShowDiv: function(divId) {
        this.stopDivSwitcher();
        this.showDiv(divId);
    }
});
