/*************************************************************
 *                                                           *
 *   Created by Tamas Manhertz (PYLON)/Manhertz-Pylon Ltd.   *
 *            All rights reserved. 2009.                     *
 *                                                           *
 *************************************************************/
/*************************************************************
 *    #DEP: DOMComponent, singletons                         *
 *************************************************************/
/*************************************************************
 *  JSO Object:  UserMenu                                    *
 *        Type:  prototype                                   *
 *                                                           *
 * Description: Javascript usermenu handler object           *
 *                                                           *
 *                                                           *
 *************************************************************/

function pUserMenu( sName, sType )
 {
        pDOMComponent.call(this, sName, sType);
 };
pUserMenu.extend( 'DOMComponent',
 {
   // ***************************************************
   //                  PROPERTIES
   // ***************************************************

     /*
      *    Temporar variables
      */
           /**
            *   HTML ID for the UserMenu HTML main div-section
            * @type: string
            */
       _sUserMenuID : "",

   // ***************************************************
   //                  PRIVATE  METHODS
   // ***************************************************
           /**
            * Component ID string.
            */
       _getIDString : function ()
        {
           return "JSO UserMenu object.";
        },

   // ***************************************************
   //                   PUBLIC METHODS
   // ***************************************************

           /**
            *   Initializes the UserMenu object,
            *       - sets the basic variables,
            *       - sets the callback functions in LogonHandler
            */
       init : function ( sUserMenuID )
        {
             /*  stores temporarily the necessery data  */
           this._sUserMenuID = sUserMenuID;
           
           if (jso_LogonHandler)
            {
               jso_LogonHandler.registerCallback ( "Logon", this.getUserMenu, this );
               jso_LogonHandler.registerCallback ( "Logout", this.clearUserMenu, this );
            }
        },

           /**
            * Writes the given system variables into the HTML code.
            *    - usage: <span name="SYSTEM_VAR_<varname>"></span>
            */
       getUserMenu : function ()
        {
              /*  calling the server getUserMenu() function  */
           this._call( "getUserMenu", this._sUserMenuID );
        },
           /**
            *   
            */
       clearUserMenu : function ()
        {
            if (_oDOMObject = document.getElementById( "menu_"+this._sUserMenuID+"_USERMENU" ))
                _oDOMObject.innerHTML = "";
        },


       processServerData : function ( sDName )
        {
            switch (sDName)
             {
                case "_sUserMenuCode":
                    if (_oDOMObject = document.getElementById( "menu_"+this._sUserMenuID+"_USERMENU" ))
                        _oDOMObject.innerHTML = this._sUserMenuCode;
                    syLog( "UserMenu code was set." );
                    break;

                default:
                    break;
             }
        },

           /**
            *   Sends the log buffer to the server.
            */
       sendBufferToServer : function ()
        {
           this._sendData();
           return true;
        }
});
oUserMenu = new pUserMenu( "oUserMenu", "pUserMenu" );

