/*  sjs - SSWin - AJAX Framework
    www.cebinet.com.br
    silviosa@sswin.com.br
    Junho/2009
    ====================== */

// Objeto sjsMensagens
function sjsMensagens(props){

// construtor
    _defaults(this); if(props){ _construtor(this, props); };
    function _construtor(o, ps){ for(var p in ps){ if(o[p]!=undefined){ if(typeof(o[p])=='object'){ _construtor(o[p],ps[p]); } else o[p]=ps[p]; } } };
    function _defaults(o){

// propriedades
        o.classe='msgErro';
        o.ancora='Mensagens';
    };

// apagar a mensagem
    this.apagar=function(){
        $('#'+this.ancora).empty();
        $('#'+this.ancora).hide();
    };

// mostrar a mensagem
    this.mostrar=function(msg, fmt, titulo, estilo){

        this.apagar();

        // mensagem
        var t='';
        if(fmt=='V'){ for(im=0; im<msg.length; im++){ if(t){ t+='<br>'; } t+=msg[im].msg; } }
        else if(fmt=='A'){ for(im=0; im<msg.length; im++){ if(t){ t+='<br>'; } t+=msg[im]; } }
        else { t+=msg; }

        // título
        if(titulo){ t='<b>'+titulo+'</b><br>'+t; }

        // estilo
        if(!estilo){ estilo=this.classe; }

        // exibição
        $('#'+this.ancora).html(t);
        $('#'+this.ancora).attr("class", estilo);
        $('#'+this.ancora).slideDown(500);

    };

};

