VZT.MLPHeroController = new Class({
    Extends: VZT.TabsetController,
    rotating: null,
    toRotate: true,
    r_index: 1,
    initialize: function (rotate) {

        var me = this;
       
        this.parent();
        this._extraBind();
        
        if(rotate == false) {
            
            this.toRotate = false;
        }
    },
    _extraBind: function () {
        var launchers = $('TabHero').getElements('[class*=TabHeroExternal::]');
        var me = this;
        launchers.each(function (l) {
            l.addEvents({
                'click': function () { me._Externalclick(this.get('class')); }
            });
        } .bind(this));
    },
    _Externalclick: function (classs) {
        var base = this;

        var args = VZT.Parser.parse(classs, 'TabHeroExternal', {
            id: 1
        });
        base._onGo(args.id);
    },
    _click: function () {
        var me = this;
        if (this.rotating == null) {
            var f = function () {
                me._onGo(me.r_index);                
				me.r_index = (me.r_index + 1) % me._view._items.length;
				
            }
            if(this.toRotate != false)				
                this.rotating = setInterval(f, 5000);
        } else {
            clearInterval(this.rotating);
        }
    },
    _onGo: function (i) {
        if (this._view.running == true)
            return;

        this.parent(i);
    }

});

VZT.MLPHeroView = new Class({
    Extends: VZT.TabsetView,
    running: false,
    initialize: function (wrapper, items, controller) {
        this.parent(wrapper, items, controller);
        this.running = false;
    },
    displayContent: function (i) {

        var area = $('TabHero');

        var self = this;
	
		this._items[i].setStyle('opacity',0);
        this._items[i].removeClass('hidden');

        VZT.AppCore.Animations.revertAnimation("generic_fade", this._items[i], {
            duration: 500
        }, function () {

        } .bind(this));


    },
    hideContent: function (i) {
        this.running = true;
        var me = this;
        this._items[i].addClass('tab_over');
        VZT.AppCore.Animations.runAnimation("generic_fade", this._items[i], {
            duration: 500
        }, function () {
            this._items[i].removeClass('tab_over');
            this._items[i].addClass('hidden');
            this.running = false;
        } .bind(this));
    }

});
