/*************************************************************
 *                                                           *
 *   Created by Tamas Manhertz (PYLON)/Manhertz-Pylon Ltd.   *
 *            All rights reserved. 2007.                     *
 *                                                           *
 *************************************************************/
/*************************************************************
 *    #DEP: DOMComponent, singletons                         *
 *************************************************************/
/*************************************************************
 *  JSO Object:  Language                                    *
 *        Type:  singleton                                   *
 *                                                           *
 * Description: Javascript Language object component         *
 *                                                           *
 *                                                           *
 *************************************************************/

jso_Language = new pDOMComponent( "jso_Language", "jso_Language" );
jso_Language.extend(
 {
   // ***************************************************
   //                  PROPERTIES
   // ***************************************************
       
     /*
      *    Temporar variables
      */
           /**
            *  The current language
            * @type: string
            */
       _sLang : "",
           /**
            *  The available languages
            * @type: string
            */
       _sAvailableLanguages : "EN HU DE",

   // ***************************************************
   //                  PRIVATE  METHODS
   // ***************************************************
           /**
            * Component ID string.
            */
       _getIDString : function ()
        {
           return "JSO Language object.";
        },

   // ***************************************************
   //                   PUBLIC METHODS
   // ***************************************************
           /**
            *   Initializes the Language object, it receives the current language from the server
            */
       init : function ( sLang, sAvailableLanguages )
        {
           this._sLang = sLang;
           syLog( "Language: language has been set to "+sLang );
           this._sAvailableLanguages = sAvailableLanguages;
        },

           /**
            *   get the current language
            */
       getLang : function ()
        {
           return this._sLang;
        },
           /**
            *   sets the current language
            */
       setLang : function ( sLang, sType )
        {
           if (this._sAvailableLanguages.search(sLang)>-1)
            {
               this._sLang = sLang;
               syLog( "Language: language has been set to "+sLang );
               if (sType=="server")
                {
                   _sPath = window.location+'';
                   if (_sPath.search("#")>-1) _sPath = _sPath.substr(0, _sPath.length-1);
                   syLog( "changing to "+_sPath+'?lang='+sLang );
                   window.location = _sPath+'?lang='+sLang;
                }
            }
           else
               syLog( "Language: requested language '"+sLang+"' is not available." );
        }
});

