//================================= CLASS CONSTRUCTOR ========================================
function SysMsg(isysMsgMgr,imsg,itype,ieClose,typeOkCancel)
{
//MEMBER VARIABLES
 this.sysMsgMgr = isysMsgMgr;
 this.msg = imsg;
 this.type = itype;
 this.eClose = ieClose;
 this.okCancel = typeOkCancel;
 this.shown = false;
 /* valore di ritorno per una finestra ok cancel
    pu�assumere i valori ok, cancel, close */
 this.returnValue = 'close'; // default value
}

//====================================== STATIC ==============================================
SysMsg.MSGTYPE_INFO    = 0;
SysMsg.MSGTYPE_WARNING = 1;
SysMsg.MSGTYPE_ERROR   = 2;

//====================================== MEMBERS =============================================
SysMsg.prototype.onWinClose = function(isenderWin)
{
 var
  thisobj = isenderWin.getTag();

//The system message is no longer shown ...
 thisobj.shown = false;
 /* finestra di messaggio con il solo bottone ok */
 if( ! thisobj.okCancel )
 {
//Executing the close event ...
 if (thisobj.eClose != null)
  thisobj.eClose();
//Alerting the manager that this message has closed!
 thisobj.sysMsgMgr.onSysMsgClose();
}
 /* finestra di conferma ok cancel */
 else
 {
     if( thisobj.returnValue == 'cancel' )
        thisobj.sysMsgMgr.onSysMsgCloseCancel();
     else if( thisobj.returnValue == 'ok' )
        thisobj.sysMsgMgr.onSysMsgCloseOk();
     else if( thisobj.returnValue == 'close' )
        if (thisobj.eClose != null)
            thisobj.eClose();
 }
}

SysMsg.prototype.show = function()
{
 var
  win = null,
  prm = "";

 if (this.shown == true)
   return;
 win = this.sysMsgMgr.winMgr.createWindow(true,false,false);
 win.setTitle(this.sysMsgMgr.rmgr.getResource0('JSP_PLG_SMMGR_4'));
 win.resizeTo(300,177);
 win.center();
 win.setCloseEvent(this.onWinClose);
 win.setTag(this);
 win.loadContent('/adiJed/plugins/sysmsgmgr/events/SysMsgDlg.jsp','');
 win.show(true);
 this.shown = true;
}

SysMsg.prototype.isShown = function()
{
 return this.shown;
}
