/**
* @author hedgehog
*/

//  @import com.hedgehoglab.application.controller.BaseController;
//  @import com.hedgehoglab.events.Thread;


function FlashMessageController(scope){
    BaseController.call(this,scope);
    var _this = this;

    var list = [];

    var timeout = 700;

    scope.service.subscribe_to('show_message',function(e){
        list.push(e);
    });

    var process_messages=function(){
        scope.model.model(null);
        if (list.length>0)
        {
            var tempMessage = list.shift();
            scope.model.model(tempMessage);
            if (tempMessage.duration==null) tempMessage.duration=3000;
            setTimeout(process_messages,tempMessage.duration);
        }
        else
        {
        setTimeout(process_messages,timeout);
        }
    };

    process_messages();

};