Changeset 4496 for branches


Ignore:
Timestamp:
05/24/11 17:55:57 (13 years ago)
Author:
rafaelraymundo
Message:

Ticket #1726 - Sincronizado Jabber com as alteracoes vindas do branch 2.2

Location:
branches/2.2.0.1/jabberit_messenger/jmessenger
Files:
4 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.0.1/jabberit_messenger/jmessenger/inc/jabberit_acl.inc.php

    r4453 r4496  
    9090                echo "<script type='text/javascript' src='".$webserver_url .        "js/strophe.mini.js'></script>"; 
    9191                echo "<script type='text/javascript' src='".$webserver_expresso .   "js/browser/browserDetect.js'></script>"; 
    92                 echo "<script type='text/javascript' src='".$webserver_url .        "js/jscode/loadIM.mini.js'></script>"; 
     92                echo "<script type='text/javascript' src='".$webserver_url .        "js/jscode/loadIM.mini.js'></script>"; 
    9393                echo "<script type='text/javascript' src='".$webserver_url .        "js/connector.mini.js'></script>"; 
    9494                echo "<script type='text/javascript' src='".$webserver_expresso .   "js/x_tools/xtools.js'></script>"; 
     
    9898                echo "<script type='text/javascript' src='".$webserver_url .        "js/show_hidden.mini.js'></script>"; 
    9999                echo "<script type='text/javascript' src='".$webserver_url .        "js/trophyim_constants.js'></script>"; 
    100                 echo "<script type='text/javascript' src='".$webserver_url .        "js/trophyim.mini.js'></script>"; 
    101                 echo "<script type='text/javascript' src='".$webserver_url .        "js/AddUser.mini.js'></script>";                                             
     100                echo "<script type='text/javascript' src='".$webserver_url .        "js/trophyim.mini.js'></script>"; 
     101                echo "<script type='text/javascript' src='".$webserver_url .        "js/AddUser.mini.js'></script>";                                             
    102102                echo "<script type='text/javascript' src='".$webserver_url .        "js/json2.js'></script>"; 
    103103                echo "<script type='text/javascript' src='".$webserver_url .        "js/SelectEditable.mini.js'></script>"; 
  • branches/2.2.0.1/jabberit_messenger/jmessenger/js/jscode/loadIM.js

    r4453 r4496  
    11(function() 
    2 { 
    3         var _autoStatus; 
    4         var _autoStatusTime             = 60000; // 1 minuto 
    5         var addUser                     = null; 
    6         var conn                        = null; 
    7         var fullName                    = ""; 
    8         var path                        = ""; 
     2    { 
     3        var _autoStatus; 
     4        var _autoStatusTime             = 60000; // 1 minuto 
     5        var addUser                     = null; 
     6        var conn                        = null; 
     7        var fullName                    = ""; 
     8        var path                        = ""; 
    99        var path_phpgwapi               = ""; 
    10         var _preferencesIM              = ""; 
    11         var selectEditable              = null; 
    12         var showhidden                  = null; 
    13         var statusUserIM                = ""; 
    14         var _statusMessage              = ""; 
    15         var timeoutId                   = null; 
    16         var userCurrent                 = null; 
    17         var _timeOutNotification        = ""; 
    18         var Xtools                      = null; 
    19         var zIndex                      = 9001; 
    20         var windowPopUp                 = []; 
    21          
    22         // Images 
    23         var add_user = new Image(); 
    24         add_user.src = path_jabberit + 'templates/default/images/adduser_azul.png'; 
    25  
    26         var arrow_down = new Image(); 
    27         arrow_down.src = path_jabberit + 'templates/default/images/arrow_down.gif';  
    28  
    29         var arrow_right = new Image(); 
    30         arrow_right.src = path_jabberit + 'templates/default/images/arrow_right.gif'; 
    31          
    32         function actionButton() 
    33         { 
    34                 if( arguments.length > 0 ) 
    35                 { 
    36                         var e                   = arguments[0]; 
    37                         var _element    = ( e.target ) ? e.target : e.srcElement; 
    38                         var jid         = arguments[1]; 
    39                         var coord       = null; 
    40  
    41                         if ( !e ) 
    42                                 e = window.event; 
    43  
    44                         var _X = e.clientX + document.body.scrollLeft - document.body.clientLeft; 
    45                         var _Y = e.clientY + document.body.scrollTop  - document.body.clientTop; 
    46                                  
    47                         coord = { X : _X, Y : _Y }; 
    48                  
    49  
    50                         var _onContextMenu = function() 
    51                         { 
    52                                 return false; 
    53                         }; 
    54                          
    55                         window.document.oncontextmenu   = _onContextMenu; 
    56                          
    57                         if( e.button ) 
    58                         { 
    59                                 if( e.button > 1 ) 
    60                                         optionsItensContact( jid, coord ); 
    61                                 else 
    62                                         TrophyIM.rosterClick(jid); 
    63                         }        
    64                         else if( e.which ) 
    65                         { 
    66                                 if( e.which > 1 ) 
    67                                         optionsItensContact( jid, coord ); 
    68                                 else 
    69                                         if( e.target.id ) 
    70                                                 TrophyIM.rosterClick(jid); 
    71                         } 
    72                          
    73                         setTimeout(function() 
    74                         { 
    75                                 window.document.oncontextmenu = function() 
    76                                 { 
    77                                         return true; 
    78                                 }; 
    79                                  
    80                         },500); 
    81                 } 
    82         } 
    83  
    84         function addContact() 
    85         { 
    86                 if( arguments.length > 0 ) 
    87                         addUser.add(); 
    88                 else 
    89                         addUser.show(); 
    90         } 
    91          
    92         function addIcon() 
    93         { 
    94                  
    95                 var div_write_msg       = ( getElement('em_div_write_msg') != null ) ? getElement('em_div_write_msg') : null ; 
    96                 var StatusBar           = ( getElement('divStatusBar') != null ) ? getElement('divStatusBar') : null ; 
    97                 var StatusBarIM         = ( getElement('JabberMessenger') != null ) ?  getElement('JabberMessenger') : null; 
    98                  
    99                 /************************************************************************** 
     10        var _preferencesIM              = ""; 
     11        var selectEditable              = null; 
     12        var showhidden                  = null; 
     13        var statusUserIM                = ""; 
     14        var _statusMessage              = ""; 
     15        var timeoutId                   = null; 
     16        var userCurrent                 = null; 
     17        var _timeOutNotification        = ""; 
     18        var Xtools                      = null; 
     19        var zIndex                      = 9001; 
     20        var windowPopUp                 = []; 
     21         
     22        // Images 
     23        var add_user = new Image(); 
     24        add_user.src = path_jabberit + 'templates/default/images/adduser_azul.png'; 
     25 
     26        var arrow_down = new Image(); 
     27        arrow_down.src = path_jabberit + 'templates/default/images/arrow_down.gif';  
     28 
     29        var arrow_right = new Image(); 
     30        arrow_right.src = path_jabberit + 'templates/default/images/arrow_right.gif'; 
     31         
     32        function actionButton() 
     33        { 
     34            if( arguments.length > 0 ) 
     35            { 
     36                var e                   = arguments[0]; 
     37                var _element    = ( e.target ) ? e.target : e.srcElement; 
     38                var jid         = arguments[1]; 
     39                var coord       = null; 
     40 
     41                if ( !e ) 
     42                    e = window.event; 
     43 
     44                var _X = e.clientX + document.body.scrollLeft - document.body.clientLeft; 
     45                var _Y = e.clientY + document.body.scrollTop  - document.body.clientTop; 
     46                                 
     47                coord = { 
     48                    X : _X,  
     49                    Y : _Y 
     50                }; 
     51                 
     52 
     53                var _onContextMenu = function() 
     54                { 
     55                    return false; 
     56                }; 
     57                         
     58                window.document.oncontextmenu   = _onContextMenu; 
     59                         
     60                if( e.button ) 
     61                { 
     62                    if( e.button > 1 ) 
     63                        optionsItensContact( jid, coord ); 
     64                    else 
     65                        TrophyIM.rosterClick(jid); 
     66                }        
     67                else if( e.which ) 
     68                { 
     69                    if( e.which > 1 ) 
     70                        optionsItensContact( jid, coord ); 
     71                    else 
     72                    if( e.target.id ) 
     73                        TrophyIM.rosterClick(jid); 
     74                } 
     75                         
     76                setTimeout(function() 
     77                { 
     78                    window.document.oncontextmenu = function() 
     79                    { 
     80                        return true; 
     81                    }; 
     82                                 
     83                },500); 
     84            } 
     85        } 
     86 
     87        function addContact() 
     88        { 
     89            if( arguments.length > 0 ) 
     90                addUser.add(); 
     91            else 
     92                addUser.show(); 
     93        } 
     94         
     95        function addIcon() 
     96        { 
     97                 
     98            var div_write_msg   = ( getElement('em_div_write_msg') != null ) ? getElement('em_div_write_msg') : null ; 
     99            var StatusBar               = ( getElement('divStatusBar') != null ) ? getElement('divStatusBar') : null ; 
     100            var StatusBarIM             = ( getElement('JabberMessenger') != null ) ?  getElement('JabberMessenger') : null; 
     101                 
     102            /************************************************************************** 
    100103                 *  
    101104                 * Quando estiver habilitada a opção fora de escritório nos filtros. 
     
    103106                 */ 
    104107 
    105                 if( ( div_write_msg && StatusBarIM ) != null ) 
    106                 {                
    107                         div_write_msg.parentNode.insertBefore(StatusBarIM, div_write_msg); 
    108                         StatusBarIM.style.paddingLeft = '33px'; 
    109                         return; 
    110                 } 
    111                  
    112                 /**************************************************************************/ 
    113                  
    114                 if ( !StatusBarIM ) 
    115                 { 
    116                         StatusBarIM = document.createElement('div'); 
    117                         StatusBarIM.setAttribute('id', 'JabberMessenger'); 
    118                 } 
    119                  
    120                 if( StatusBar ) 
    121                 { 
    122                         StatusBar.style.paddingLeft = '33px'; 
    123                          
    124                         var _div = document.createElement('div'); 
    125                                 _div.appendChild(StatusBar.parentNode.removeChild(StatusBar.previousSibling)); 
    126                          
    127                                 StatusBar.parentNode.insertBefore( _div, StatusBar); 
    128                          
    129                         var _fastMenu = top.document.createElement('div'); 
    130                                 _fastMenu.setAttribute('id', 'fast_menu_jabber_expresso'); 
    131                                 _fastMenu.style.background              = 'no-repeat'; 
    132                                 _fastMenu.style.backgroundImage = 'url(' + arrow_down.src + ')'; 
    133                                 _fastMenu.style.float                   = 'left'; 
    134                                 _fastMenu.style.height                  = '15px'; 
    135                                 _fastMenu.style.left                    = '7px'; 
    136                                 _fastMenu.style.margin                  = '8 0 0 10px'; 
    137                                 _fastMenu.style.padding                 = '0px'; 
    138                                 _fastMenu.style.position                = 'absolute'; 
    139                                 _fastMenu.style.width                   = '15px'; 
    140                                 _fastMenu.style.cursor                  = 'pointer'; 
    141  
    142                         StatusBarIM.insertBefore( _fastMenu, StatusBarIM.firstChild ); 
    143                          
    144                         // Add event onclick element _fastMenu 
    145                         configEvents( _fastMenu, 'onclick', function(){ fastMenu(_fastMenu); }); 
    146  
    147                         var _statusJabber = top.document.createElement('div'); 
    148                                 _statusJabber.setAttribute('id','status_jabber_expresso'); 
    149                                 _statusJabber.style.background          = 'no-repeat'; 
    150                                 _statusJabber.style.backgroundImage = 'url(' + add_user.src +')'; 
    151                                 _statusJabber.style.float                       = 'left'; 
    152                                 _statusJabber.style.height                      = '18px'; 
    153                                 _statusJabber.style.left                        = '19px'; 
    154                                 _statusJabber.style.margin                      = '0 0 0 10px'; 
    155                                 _statusJabber.style.padding                     = '0px'; 
    156                                 _statusJabber.style.position            = 'absolute'; 
    157                                 _statusJabber.style.width                       = '18px'; 
    158                                 _statusJabber.style.cursor                      = 'pointer'; 
    159                                 _statusJabber.style.zindex                      = '999999'; 
    160                          
    161                         StatusBarIM.insertBefore( _statusJabber, StatusBarIM.firstChild ); 
    162                          
    163                         StatusBar.insertBefore( StatusBarIM, StatusBar.firstChild ); 
    164  
    165                         // Add event onclick element _statusJabber 
    166                         if( _preferencesIM[0] == "openWindowJabberit:true" ) 
    167                         { 
    168                                 configEvents( _statusJabber, 'onclick', function(){ rosterDiv(); }); 
    169                         } 
    170                         else 
    171                         { 
    172                                 configEvents( _statusJabber, 'onclick', function(){ TrophyIM.load(); }); 
    173                         } 
    174                 } 
    175         } 
    176  
    177         function addNewUser() 
    178         { 
    179                 addUser.newUser(); 
    180         } 
    181          
    182         function autoStatus() 
    183         { 
    184                 var _div_status = ( getElement('status_jabber_expresso') != null ) ?  getElement('status_jabber_expresso') : null; 
    185                  
    186                 if ( _autoStatus ) 
    187                         clearTimeout(_autoStatus); 
    188  
    189                 if ( _div_status != null ) 
    190                 { 
    191                         var _status = _div_status.style.backgroundImage; 
    192                                 _status = _status.substr(_status.lastIndexOf('/') + 1); 
    193                                 _status = _status.substr(0, _status.indexOf('.')); 
    194                                  
    195                         if( _status == "xa" && _div_status.getAttribute('autoStatus') ) 
    196                         { 
    197                                 if( getStatusMessage() != "") 
    198                                         TrophyIM.setPresence("available", getStatusMessage()); 
    199                                 else 
    200                                         TrophyIM.setPresence("available"); 
    201                                  
    202                                 _div_status.removeAttribute('autoStatus'); 
    203                                 loadscript.setStatusJabber("Disponível","available"); 
    204                         } 
    205                 } 
    206                  
    207                 var TimeStatus = _preferencesIM[2].split(':'); 
    208  
    209                 if( TimeStatus[1] ) 
    210                         _autoStatus = setTimeout( function(){ autoStatusHandler();}, parseInt(TimeStatus[1]) * _autoStatusTime ); 
    211                 else 
    212                         _autoStatus = setTimeout( function(){ autoStatusHandler();}, parseInt(_autoStatusTime)); 
    213         } 
    214          
    215         function autoStatusHandler() 
    216         { 
    217                 var _div_status = ( getElement('status_jabber_expresso') != null ) ?  getElement('status_jabber_expresso') : null; 
    218                  
    219                 if ( _div_status != null ) 
    220                 { 
    221                         var _status = _div_status.style.backgroundImage; 
    222                                 _status = _status.substr(_status.lastIndexOf('/') + 1); 
    223                                 _status = _status.substr(0, _status.indexOf('.')); 
    224                          
    225                         if( _status == "available" ) 
    226                         { 
    227                                 if(getStatusMessage() != "") 
    228                                         TrophyIM.setPresence("xa", getStatusMessage()); 
    229                                 else 
    230                                         TrophyIM.setPresence("xa"); 
    231  
    232                                 _div_status.setAttribute('autoStatus','true'); 
    233                                  
    234                                 loadscript.setStatusJabber("Não Disponível","xa"); 
    235                         } 
    236                 } 
    237         } 
    238  
    239         function clrAllContacts() 
    240         { 
    241                 getElement("JabberIMRoster").innerHTML = ""; 
    242         } 
    243          
    244         function configEvents(pObj, pEvent, pHandler) 
    245         { 
    246                 if ( typeof pObj == 'object' ) 
    247                 { 
    248                         if ( pEvent.substring(0, 2) == 'on' ) 
    249                                 pEvent = pEvent.substring(2, pEvent.length ); 
    250  
    251                         if ( arguments.length == 3 ) 
    252                         { 
    253                                 if ( pObj.addEventListener ) 
    254                                         pObj.addEventListener(pEvent, pHandler, false ); 
    255                                 else if ( pObj.attachEvent ) 
    256                                         pObj.attachEvent( 'on' + pEvent, pHandler ); 
    257                         } 
    258                         else if ( arguments.length == 4 ) 
    259                         { 
    260                                 if ( pObj.removeEventListener ) 
    261                                         pObj.removeEventListener( pEvent, pHandler, false ); 
    262                                 else if ( pObj.detachEvent ) 
    263                                         pObj.detachEvent( 'on' + pEvent, pHandler ); 
    264                         } 
    265                 } 
    266         } 
    267  
    268         function disabledNotificationNewUsers() 
    269         { 
    270                 var _notification       = getElement('notification_new_users_jabber') ; 
    271                 var _statusJabber       = getElement('status_jabber_expresso'); 
    272  
    273                 _notification.style.display = 'none'; 
    274                  
    275                 _statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/" + statusUserIM + ".gif') no-repeat"; 
    276                  
    277                 if( _timeOutNotification ) 
    278                         clearTimeout(_timeOutNotification ); 
    279                  
    280                 TrophyIM.controll.notificationNewUsers = 0; 
    281         } 
    282          
    283         function enabledNotificationNewUsers() 
    284         { 
    285                 var _notification       = getElement('notification_new_users_jabber') ; 
    286                 var _statusJabber       = getElement('status_jabber_expresso'); 
    287          
    288                 if( _notification && _statusJabber ) 
    289                 {        
    290                         if ( _notification.style.display == 'none' ) 
    291                         { 
    292                                 _notification.style.display = 'block'; 
    293                                  
    294                                 _statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/alert_mini.png') no-repeat"; 
    295                                  
    296                                 if( _timeOutNotification ) 
    297                                         clearTimeout(_timeOutNotification ); 
    298  
    299                                 _timeOutNotification = setTimeout( function(){ enabledNotificationNewUsers(); }, 2000 ); 
    300                         } 
    301                         else 
    302                         { 
    303                                 _notification.style.display = 'none'; 
    304                                  
    305                                 _statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/" + statusUserIM + ".gif') no-repeat"; 
    306                                  
    307                                 if( _timeOutNotification ) 
    308                                         clearTimeout(_timeOutNotification ); 
    309  
    310                                 _timeOutNotification = setTimeout( function(){ enabledNotificationNewUsers(); }, 800 ); 
    311                         } 
    312                 } 
    313         } 
    314  
    315         function fastMenu() 
    316         { 
    317                 if( arguments.length > 0 ) 
    318                 { 
    319                         var element = arguments[0]; 
    320  
    321                         if( showhidden == null ) 
    322                                 showhidden = new ShowHidden(300); 
    323  
    324                         var _options =  [ 
    325                                                 ['Adicionar Contato', 'loadscript.addContact();' ], 
    326                                                 ['Preferências', 'loadscript.preferences();'] 
    327                                         ]; 
    328  
    329                         if( im_chatroom == "false" )     
    330                         {        
    331                                 _options[2] = [ 'Sala(s) de Bate-Papo','loadscript.getListRooms();']; 
    332                         } 
    333  
    334                         var _itens = ""; 
    335                          
    336                         for( var i in _options ) 
    337                         { 
    338                                 if( _options[i].constructor == Function ) 
    339                                         continue; 
    340                                  
    341                                 _itens += '<img src="'+arrow_right.src+'"/>'; 
    342                                 _itens += '<span style="cursor:pointer; margin:3px;" onclick='+_options[i][1]+'>'; 
    343                                 _itens += _options[i][0] + '</span><br/>'; 
    344                         } 
    345                          
    346                         var _optionsItens = document.createElement("div"); 
    347                                 _optionsItens.id        = "fastMenu_Jabber";                             
    348                                 _optionsItens.style.marginTop   = "19px"; 
    349                                 _optionsItens.style.marginLeft  = "-8px"; 
    350                                 _optionsItens.className         = "x-menu"; 
    351                                 _optionsItens.style.zIndex      = '999999'; 
    352                                 _optionsItens.innerHTML         = _itens; 
    353                                 _optionsItens.onclick           = function(){ showhidden.hiddenObject(false); }; 
    354                                 _optionsItens.onmouseout        = function(){ showhidden.hiddenObject(false); }; 
    355                                 _optionsItens.onmouseover       = function(){ showhidden.hiddenObject(true); };  
     108            if( ( div_write_msg && StatusBarIM ) != null ) 
     109            {            
     110                div_write_msg.parentNode.insertBefore(StatusBarIM, div_write_msg); 
     111                StatusBarIM.style.paddingLeft = '33px'; 
     112                return; 
     113            } 
     114                 
     115            /**************************************************************************/ 
     116                 
     117            if ( !StatusBarIM ) 
     118            { 
     119                StatusBarIM = document.createElement('div'); 
     120                StatusBarIM.setAttribute('id', 'JabberMessenger'); 
     121            } 
     122                 
     123            if( StatusBar ) 
     124            { 
     125                StatusBar.style.paddingLeft = '33px'; 
     126                         
     127                var _div = document.createElement('div'); 
     128                _div.appendChild(StatusBar.parentNode.removeChild(StatusBar.previousSibling)); 
     129                         
     130                StatusBar.parentNode.insertBefore( _div, StatusBar); 
     131                         
     132                var _fastMenu = top.document.createElement('div'); 
     133                _fastMenu.setAttribute('id', 'fast_menu_jabber_expresso'); 
     134                _fastMenu.style.background              = 'no-repeat'; 
     135                _fastMenu.style.backgroundImage = 'url(' + arrow_down.src + ')'; 
     136                _fastMenu.style.float                   = 'left'; 
     137                _fastMenu.style.height                  = '15px'; 
     138                _fastMenu.style.left                    = '7px'; 
     139                _fastMenu.style.margin                  = '8 0 0 10px'; 
     140                _fastMenu.style.padding                 = '0px'; 
     141                _fastMenu.style.position                = 'absolute'; 
     142                _fastMenu.style.width                   = '15px'; 
     143                _fastMenu.style.cursor                  = 'pointer'; 
     144 
     145                StatusBarIM.insertBefore( _fastMenu, StatusBarIM.firstChild ); 
     146                         
     147                // Add event onclick element _fastMenu 
     148                configEvents( _fastMenu, 'onclick', function(){ 
     149                    fastMenu(_fastMenu); 
     150                }); 
     151 
     152                var _statusJabber = top.document.createElement('div'); 
     153                _statusJabber.setAttribute('id','status_jabber_expresso'); 
     154                _statusJabber.style.background          = 'no-repeat'; 
     155                _statusJabber.style.backgroundImage = 'url(' + add_user.src +')'; 
     156                _statusJabber.style.float                       = 'left'; 
     157                _statusJabber.style.height                      = '18px'; 
     158                _statusJabber.style.left                        = '19px'; 
     159                _statusJabber.style.margin                      = '0 0 0 10px'; 
     160                _statusJabber.style.padding                     = '0px'; 
     161                _statusJabber.style.position            = 'absolute'; 
     162                _statusJabber.style.width                       = '18px'; 
     163                _statusJabber.style.cursor                      = 'pointer'; 
     164                _statusJabber.style.zindex                      = '999999'; 
     165                         
     166                StatusBarIM.insertBefore( _statusJabber, StatusBarIM.firstChild ); 
     167                         
     168                StatusBar.insertBefore( StatusBarIM, StatusBar.firstChild ); 
     169 
     170                // Add event onclick element _statusJabber 
     171                if( _preferencesIM[0] == "openWindowJabberit:true" ) 
     172                { 
     173                    configEvents( _statusJabber, 'onclick', function(){ 
     174                        rosterDiv(); 
     175                    }); 
     176                } 
     177                else 
     178                { 
     179                    configEvents( _statusJabber, 'onclick', function(){ 
     180                        TrophyIM.load(); 
     181                    }); 
     182                } 
     183            } 
     184        } 
     185 
     186        function addNewUser() 
     187        { 
     188            addUser.newUser(); 
     189        } 
     190         
     191        function autoStatus() 
     192        { 
     193            var _div_status = ( getElement('status_jabber_expresso') != null ) ?  getElement('status_jabber_expresso') : null; 
     194                 
     195            if ( _autoStatus ) 
     196                clearTimeout(_autoStatus); 
     197 
     198            if ( _div_status != null ) 
     199            { 
     200                var _status = _div_status.style.backgroundImage; 
     201                _status = _status.substr(_status.lastIndexOf('/') + 1); 
     202                _status = _status.substr(0, _status.indexOf('.')); 
     203                                 
     204                if( _status == "xa" && _div_status.getAttribute('autoStatus') ) 
     205                { 
     206                    if( getStatusMessage() != "") 
     207                        TrophyIM.setPresence("available", getStatusMessage()); 
     208                    else 
     209                        TrophyIM.setPresence("available"); 
     210                                 
     211                    _div_status.removeAttribute('autoStatus'); 
     212                    loadscript.setStatusJabber("Disponível","available"); 
     213                } 
     214            } 
     215                 
     216            var TimeStatus = _preferencesIM[2].split(':'); 
     217 
     218            if( TimeStatus[1] ) 
     219                _autoStatus = setTimeout( function(){ 
     220                    autoStatusHandler(); 
     221                }, parseInt(TimeStatus[1]) * _autoStatusTime ); 
     222            else 
     223                _autoStatus = setTimeout( function(){ 
     224                    autoStatusHandler(); 
     225                }, parseInt(_autoStatusTime)); 
     226        } 
     227         
     228        function autoStatusHandler() 
     229        { 
     230            var _div_status = ( getElement('status_jabber_expresso') != null ) ?  getElement('status_jabber_expresso') : null; 
     231                 
     232            if ( _div_status != null ) 
     233            { 
     234                var _status = _div_status.style.backgroundImage; 
     235                _status = _status.substr(_status.lastIndexOf('/') + 1); 
     236                _status = _status.substr(0, _status.indexOf('.')); 
     237                         
     238                if( _status == "available" ) 
     239                { 
     240                    if(getStatusMessage() != "") 
     241                        TrophyIM.setPresence("xa", getStatusMessage()); 
     242                    else 
     243                        TrophyIM.setPresence("xa"); 
     244 
     245                    _div_status.setAttribute('autoStatus','true'); 
     246                                 
     247                    loadscript.setStatusJabber("Não Disponível","xa"); 
     248                } 
     249            } 
     250        } 
     251 
     252        function clrAllContacts() 
     253        { 
     254            getElement("JabberIMRoster").innerHTML = ""; 
     255        } 
     256         
     257        function configEvents(pObj, pEvent, pHandler) 
     258        { 
     259            if ( typeof pObj == 'object' ) 
     260            { 
     261                if ( pEvent.substring(0, 2) == 'on' ) 
     262                    pEvent = pEvent.substring(2, pEvent.length ); 
     263 
     264                if ( arguments.length == 3 ) 
     265                { 
     266                    if ( pObj.addEventListener ) 
     267                        pObj.addEventListener(pEvent, pHandler, false ); 
     268                    else if ( pObj.attachEvent ) 
     269                        pObj.attachEvent( 'on' + pEvent, pHandler ); 
     270                } 
     271                else if ( arguments.length == 4 ) 
     272                { 
     273                    if ( pObj.removeEventListener ) 
     274                        pObj.removeEventListener( pEvent, pHandler, false ); 
     275                    else if ( pObj.detachEvent ) 
     276                        pObj.detachEvent( 'on' + pEvent, pHandler ); 
     277                } 
     278            } 
     279        } 
     280 
     281        function disabledNotificationNewUsers() 
     282        { 
     283            var _notification   = getElement('notification_new_users_jabber') ; 
     284            var _statusJabber   = getElement('status_jabber_expresso'); 
     285 
     286            _notification.style.display = 'none'; 
     287                 
     288            _statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/" + statusUserIM + ".gif') no-repeat"; 
     289                 
     290            if( _timeOutNotification ) 
     291                clearTimeout(_timeOutNotification ); 
     292                 
     293            TrophyIM.controll.notificationNewUsers = 0; 
     294        } 
     295         
     296        function enabledNotificationNewUsers() 
     297        { 
     298            var _notification   = getElement('notification_new_users_jabber') ; 
     299            var _statusJabber   = getElement('status_jabber_expresso'); 
     300         
     301            if( _notification && _statusJabber ) 
     302            {    
     303                if ( _notification.style.display == 'none' ) 
     304                { 
     305                    _notification.style.display = 'block'; 
     306                                 
     307                    _statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/alert_mini.png') no-repeat"; 
     308                                 
     309                    if( _timeOutNotification ) 
     310                        clearTimeout(_timeOutNotification ); 
     311 
     312                    _timeOutNotification = setTimeout( function(){ 
     313                        enabledNotificationNewUsers(); 
     314                    }, 2000 ); 
     315                } 
     316                else 
     317                { 
     318                    _notification.style.display = 'none'; 
     319                                 
     320                    _statusJabber.style.background = "url('"+path_jabberit+"templates/default/images/" + statusUserIM + ".gif') no-repeat"; 
     321                                 
     322                    if( _timeOutNotification ) 
     323                        clearTimeout(_timeOutNotification ); 
     324 
     325                    _timeOutNotification = setTimeout( function(){ 
     326                        enabledNotificationNewUsers(); 
     327                    }, 800 ); 
     328                } 
     329            } 
     330        } 
     331 
     332        function fastMenu() 
     333        { 
     334            if( arguments.length > 0 ) 
     335            { 
     336                var element = arguments[0]; 
     337 
     338                if( showhidden == null ) 
     339                    showhidden = new ShowHidden(300); 
     340 
     341                var _options =  [ 
     342                ['Adicionar Contato', 'loadscript.addContact();' ], 
     343                ['Preferências', 'loadscript.preferences();'] 
     344                ]; 
     345 
     346                if( im_chatroom == "false" )     
     347                {        
     348                    _options[2] = [ 'Sala(s) de Bate-Papo','loadscript.getListRooms();']; 
     349                } 
     350 
     351                var _itens = ""; 
     352                         
     353                for( var i in _options ) 
     354                { 
     355                    if( _options[i].constructor == Function ) 
     356                        continue; 
     357                                 
     358                    _itens += '<img src="'+arrow_right.src+'"/>'; 
     359                    _itens += '<span style="cursor:pointer; margin:3px;" onclick='+_options[i][1]+'>'; 
     360                    _itens += _options[i][0] + '</span><br/>'; 
     361                } 
     362                         
     363                var _optionsItens = document.createElement("div"); 
     364                _optionsItens.id        = "fastMenu_Jabber";                             
     365                _optionsItens.style.marginTop   = "19px"; 
     366                _optionsItens.style.marginLeft  = "-8px"; 
     367                _optionsItens.className         = "x-menu"; 
     368                _optionsItens.style.zIndex      = '999999'; 
     369                _optionsItens.innerHTML         = _itens; 
     370                _optionsItens.onclick           = function(){ 
     371                    showhidden.hiddenObject(false); 
     372                }; 
     373                _optionsItens.onmouseout        = function(){ 
     374                    showhidden.hiddenObject(false); 
     375                }; 
     376                _optionsItens.onmouseover       = function(){ 
     377                    showhidden.hiddenObject(true); 
     378                };       
    356379                                                                                   
    357                                 showhidden.action('onmouseover', 'onmouseout', _optionsItens); 
    358                                  
    359                         element.parentNode.appendChild( _optionsItens ); 
    360                 } 
    361         } 
    362          
    363         function getElement( elementId ) 
    364         { 
    365                 return document.getElementById( elementId ); 
    366         } 
    367          
    368         function getIsIE() 
    369         { 
    370                 return SnifferBrowser.isCompatible('is_ie'); 
    371         } 
    372          
    373         function getPhotoUser( jid ) 
    374         { 
    375                 try 
    376                 { 
    377                         var _divPhoto = getElement( jid + '__photo' ); 
    378          
    379                         if( _divPhoto.style.backgroundImage.indexOf('photo.png') > 0 ) 
    380                         { 
    381                                 var _imgUser  = path_jabberit + 'inc/WebService.php?' + Date.parse( new Date ); 
    382                                         _imgUser += '&photo_ldap=' + jid; 
    383          
    384                                 _divPhoto.style.backgroundImage = 'url(' + _imgUser + ')'; 
    385                         } 
    386                 }catch(e){} 
    387         } 
    388          
    389         function getShowContactsOffline() 
    390         { 
    391                 if( _preferencesIM[3] ) 
    392                 { 
    393                         var showOffline = _preferencesIM[3].split(":"); 
    394                          
    395                         if( showOffline[1] === "true") 
    396                                 return true; 
    397                         else 
    398                                 return false; 
    399                 } 
    400                  
    401                 return true; 
    402         } 
    403          
    404         function getSmiles( String ) 
    405         { 
    406                 String = String.replace( /:\)|:-\)/g    , " <img src='"+path_jabberit+"templates/default/images/smiles/1.gif'/> "); 
    407                 String = String.replace( /:-D/g                 , " <img src='"+path_jabberit+"templates/default/images/smiles/2.gif'/> "); 
    408                 String = String.replace( /;-\)/g                , " <img src='"+path_jabberit+"templates/default/images/smiles/3.gif'/> "); 
    409                 String = String.replace( /=-O/g                 , " <img src='"+path_jabberit+"templates/default/images/smiles/4.gif'/> "); 
    410                 String = String.replace( /:P/g                  , " <img src='"+path_jabberit+"templates/default/images/smiles/5.gif'/> "); 
    411                 String = String.replace( /8-\)/g                , " <img src='"+path_jabberit+"templates/default/images/smiles/6.gif'/> "); 
    412                 String = String.replace( /\>:o/g                , " <img src='"+path_jabberit+"templates/default/images/smiles/7.gif'/> "); 
    413                 String = String.replace( /:-\$/g                , " <img src='"+path_jabberit+"templates/default/images/smiles/8.gif'/> "); 
    414                 String = String.replace( /:s|:-X/g              , " <img src='"+path_jabberit+"templates/default/images/smiles/9.gif'/> "); 
    415                 String = String.replace( /:-\(/g                , " <img src='"+path_jabberit+"templates/default/images/smiles/10.gif'/> "); 
    416                 String = String.replace( /:\'\(/g               , " <img src='"+path_jabberit+"templates/default/images/smiles/11.gif'/> "); 
    417                 String = String.replace( /:\|/g                 , " <img src='"+path_jabberit+"templates/default/images/smiles/12.gif'/> "); 
    418                 String = String.replace( /O:-\)/g               , " <img src='"+path_jabberit+"templates/default/images/smiles/13.gif'/> "); 
    419                 String = String.replace( /\*\*@#%/g             , " <img src='"+path_jabberit+"templates/default/images/smiles/14.gif'/> "); 
    420                 String = String.replace( /\(I\)/g               , " <img src='"+path_jabberit+"templates/default/images/smiles/15.gif'/> "); 
    421                 String = String.replace( /C28I/g                , " <img src='"+path_jabberit+"templates/default/images/smiles/16.gif'/> "); 
    422                 String = String.replace( /CS2A/g                , " <img src='"+path_jabberit+"templates/default/images/smiles/17.gif' style='width:42px;height:36px;'/> "); 
    423                 String = String.replace( /\(CzzzzI\)/g          , " <img src='"+path_jabberit+"templates/default/images/smiles/18.gif'/> ");                 
     380                showhidden.action('onmouseover', 'onmouseout', _optionsItens); 
     381                                 
     382                element.parentNode.appendChild( _optionsItens ); 
     383            } 
     384        } 
     385         
     386        function getElement( elementId ) 
     387        { 
     388            return document.getElementById( elementId ); 
     389        } 
     390         
     391        function getBrowserCompatible() 
     392        { 
     393            return SnifferBrowser.isCompatible('firefox3','firefox4'); 
     394        } 
     395         
     396        function getPhotoUser( jid ) 
     397        { 
     398            try 
     399            { 
     400                var _divPhoto = getElement( jid + '__photo' ); 
     401         
     402                if( _divPhoto.style.backgroundImage.indexOf('photo.png') > 0 ) 
     403                { 
     404                    var _imgUser  = path_jabberit + 'inc/WebService.php?' + Date.parse( new Date ); 
     405                    _imgUser += '&photo_ldap=' + jid; 
     406         
     407                    _divPhoto.style.backgroundImage = 'url(' + _imgUser + ')'; 
     408                } 
     409            }catch(e){} 
     410        } 
     411         
     412        function getShowContactsOffline() 
     413        { 
     414            if( _preferencesIM[3] ) 
     415            { 
     416                var showOffline = _preferencesIM[3].split(":"); 
     417                         
     418                if( showOffline[1] === "true") 
     419                    return true; 
     420                else 
     421                    return false; 
     422            } 
     423                 
     424            return true; 
     425        } 
     426         
     427        function getSmiles( String ) 
     428        { 
     429            String = String.replace( /:\)|:-\)/g        , " <img src='"+path_jabberit+"templates/default/images/smiles/1.gif'/> "); 
     430            String = String.replace( /:-D/g                     , " <img src='"+path_jabberit+"templates/default/images/smiles/2.gif'/> "); 
     431            String = String.replace( /;-\)/g            , " <img src='"+path_jabberit+"templates/default/images/smiles/3.gif'/> "); 
     432            String = String.replace( /=-O/g                     , " <img src='"+path_jabberit+"templates/default/images/smiles/4.gif'/> "); 
     433            String = String.replace( /:P/g                      , " <img src='"+path_jabberit+"templates/default/images/smiles/5.gif'/> "); 
     434            String = String.replace( /8-\)/g            , " <img src='"+path_jabberit+"templates/default/images/smiles/6.gif'/> "); 
     435            String = String.replace( /\>:o/g            , " <img src='"+path_jabberit+"templates/default/images/smiles/7.gif'/> "); 
     436            String = String.replace( /:-\$/g            , " <img src='"+path_jabberit+"templates/default/images/smiles/8.gif'/> "); 
     437            String = String.replace( /:s|:-X/g          , " <img src='"+path_jabberit+"templates/default/images/smiles/9.gif'/> "); 
     438            String = String.replace( /:-\(/g            , " <img src='"+path_jabberit+"templates/default/images/smiles/10.gif'/> "); 
     439            String = String.replace( /:\'\(/g           , " <img src='"+path_jabberit+"templates/default/images/smiles/11.gif'/> "); 
     440            String = String.replace( /:\|/g                     , " <img src='"+path_jabberit+"templates/default/images/smiles/12.gif'/> "); 
     441            String = String.replace( /O:-\)/g           , " <img src='"+path_jabberit+"templates/default/images/smiles/13.gif'/> "); 
     442            String = String.replace( /\*\*@#%/g         , " <img src='"+path_jabberit+"templates/default/images/smiles/14.gif'/> "); 
     443            String = String.replace( /\(I\)/g           , " <img src='"+path_jabberit+"templates/default/images/smiles/15.gif'/> "); 
     444            String = String.replace( /C28I/g            , " <img src='"+path_jabberit+"templates/default/images/smiles/16.gif'/> "); 
     445            String = String.replace( /CS2A/g            , " <img src='"+path_jabberit+"templates/default/images/smiles/17.gif' style='width:42px;height:36px;'/> "); 
     446            String = String.replace( /\(CzzzzI\)/g              , " <img src='"+path_jabberit+"templates/default/images/smiles/18.gif'/> ");                 
    424447  
    425                 return String; 
    426         } 
    427          
    428         function getStatusUserIM() 
    429         { 
    430                 return statusUserIM; 
    431         } 
    432          
    433         function getStatusMessage() 
    434         { 
    435                 return _statusMessage; 
    436         } 
    437          
    438         function getUserCurrent() 
    439         { 
    440                 return userCurrent; 
    441         } 
    442          
    443         function getZindex() 
    444         { 
    445                 return zIndex++; 
    446         } 
    447          
    448         function groupsHidden() 
    449         { 
    450                 if( arguments.length > 0 ) 
    451                 { 
    452                         var _element = arguments[0]; 
    453                                 _element.style.background = "url('"+path_jabberit+"templates/default/images/arrow_right.gif') no-repeat center left"; 
    454                                 _element.onclick = function(){ groupsVisible(_element);}; 
    455                                  
    456                                 // Hidden all 
    457                                 var _elementNext = _element.nextSibling; 
    458                                  
    459                                 while( _elementNext ) 
    460                                 {        
    461                                         if( _elementNext.nodeType == 1 ) 
    462                                                 _elementNext.style.display = "none"; 
     448            return String; 
     449        } 
     450         
     451        function getStatusUserIM() 
     452        { 
     453            return statusUserIM; 
     454        } 
     455         
     456        function getStatusMessage() 
     457        { 
     458            return _statusMessage; 
     459        } 
     460         
     461        function getUserCurrent() 
     462        { 
     463            return userCurrent; 
     464        } 
     465         
     466        function getZindex() 
     467        { 
     468            return zIndex++; 
     469        } 
     470         
     471        function groupsHidden() 
     472        { 
     473            if( arguments.length > 0 ) 
     474            { 
     475                var _element = arguments[0]; 
     476                _element.style.background = "url('"+path_jabberit+"templates/default/images/arrow_right.gif') no-repeat center left"; 
     477                _element.onclick = function(){ 
     478                    groupsVisible(_element); 
     479                }; 
     480                                 
     481                // Hidden all 
     482                var _elementNext = _element.nextSibling; 
     483                                 
     484                while( _elementNext ) 
     485                {        
     486                    if( _elementNext.nodeType == 1 ) 
     487                        _elementNext.style.display = "none"; 
    463488                                         
    464                                         _elementNext = _elementNext.nextSibling; 
    465                                 } 
    466                 } 
    467         } 
    468          
    469         function groupsVisible() 
    470         { 
    471                 if( arguments.length > 0 ) 
    472                 { 
    473                         var _element = arguments[0]; 
    474                                 _element.style.background = "url('"+path_jabberit+"templates/default/images/arrow_down.gif') no-repeat center left"; 
    475                                 _element.onclick = function(){ groupsHidden(_element);}; 
    476  
    477                                 // Display all 
    478                                 var _elementNext = _element.nextSibling; 
    479                                  
    480                                 while( _elementNext ) 
    481                                 {        
    482                                         if( _elementNext.nodeType == 1 && _elementNext.nodeName.toLowerCase() == "div" ) 
    483                                         { 
    484                                                 var is_off = _elementNext.style.backgroundImage.indexOf("unavailable");  
    485  
    486                                                 if( is_off > 0 && !getShowContactsOffline()) 
    487                                                 { 
    488                                                         _elementNext.style.display = "none"; 
    489                                                         getElement("span_show_" + _elementNext.id ).style.display = "none"; 
     489                    _elementNext = _elementNext.nextSibling; 
     490                } 
     491            } 
     492        } 
     493         
     494        function groupsVisible() 
     495        { 
     496            if( arguments.length > 0 ) 
     497            { 
     498                var _element = arguments[0]; 
     499                _element.style.background = "url('"+path_jabberit+"templates/default/images/arrow_down.gif') no-repeat center left"; 
     500                _element.onclick = function(){ 
     501                    groupsHidden(_element); 
     502                }; 
     503 
     504                // Display all 
     505                var _elementNext = _element.nextSibling; 
     506                                 
     507                while( _elementNext ) 
     508                {        
     509                    if( _elementNext.nodeType == 1 && _elementNext.nodeName.toLowerCase() == "div" ) 
     510                    { 
     511                        var is_off = _elementNext.style.backgroundImage.indexOf("unavailable");  
     512 
     513                        if( is_off > 0 && !getShowContactsOffline()) 
     514                        { 
     515                            _elementNext.style.display = "none"; 
     516                            getElement("span_show_" + _elementNext.id ).style.display = "none"; 
    490517                                                         
    491                                                 } 
    492                                                 else 
    493                                                 { 
    494                                                         _elementNext.style.display = "block"; 
    495                                                         getElement("span_show_" + _elementNext.id ).style.display = "block"; 
    496                                                 } 
    497                                         } 
    498  
    499                                         _elementNext = _elementNext.nextSibling; 
    500                                 } 
    501                 } 
    502         } 
    503          
    504         function keyPressSearch() 
    505         { 
    506                 if( arguments.length > 0 ) 
    507                 { 
    508                         var ev          = arguments[0]; 
    509                         var element     = arguments[1]; 
    510          
    511                         if ( ev.keyCode == 13 ) 
    512                                 if( element.value.length >= 3 ) 
    513                                         searchUser( element.value );     
    514                                 else 
    515                                         alert( i18n.YOUR_SEARCH_ARGUMENT_MUST_BE_LONGER_THAN_3_CHARACTERS + '.' ); 
    516                 } 
    517         } 
    518  
    519          
    520         function loginPage() 
    521         { 
    522                 var paramsLoginPage =  
    523                 { 
    524                         'username' : ((( Base64.decode(getUserCurrent().jid) )) ? Base64.decode(getUserCurrent().jid) : ""), 
    525                         'password' : ((( Base64.decode(getUserCurrent().password) )) ? Base64.decode(getUserCurrent().password) : "")  
    526                 } 
    527                  
    528                 var winLoginPage = 
    529                 {        
    530                          id_window              : "window_login_page", 
    531                          width                  : 260, 
    532                          height                 : 120, 
    533                          top                    : 100, 
    534                          left                   : 400, 
    535                          draggable              : true, 
    536                          visible                : "display", 
    537                          resizable              : true, 
    538                          zindex                 : zIndex++, 
    539                          title                  : "Expresso Messenger - Login", 
    540                          closeAction    : "remove", 
    541                          content                : Xtools.parse(Xtools.xml("login_page"), "loginPage.xsl", paramsLoginPage)       
    542                 }; 
    543  
    544                 _winBuild( winLoginPage ); 
    545         } 
    546  
    547         function loadScripts(pFiles) 
    548         { 
    549                 // Load JavaScript 
    550                 var loadJavaScript = function(pJs) 
    551                 { 
    552                         var newScript = document.createElement("script"); 
    553                                 newScript.setAttribute("type", "text/javascript"); 
    554                                 newScript.setAttribute("src", pJs ); 
    555                                  
    556                         return newScript; 
    557                 }; 
    558                  
    559                 // Load CSS 
    560                 var loadStyleSheet = function(pCss) 
    561                 { 
    562                         var newStyle = document.createElement("link"); 
    563                                 newStyle.setAttribute("rel", "stylesheet"); 
    564                                 newStyle.setAttribute("type", "text/css"); 
    565                                 newStyle.setAttribute("href", pCss); 
    566                                  
    567                         return newStyle; 
    568                 }; 
    569                  
    570                 for(var i = 0; i < pFiles.length; i++) 
    571                 { 
    572                         if( pFiles[i].indexOf(".js") > -1 ) 
    573                                 document.getElementsByTagName("head")[0].appendChild(loadJavaScript(pFiles[i])); 
    574                                  
    575                         if( pFiles[i].indexOf(".css") > -1 ) 
    576                                 document.getElementsByTagName("head")[0].appendChild(loadStyleSheet(pFiles[i])); 
    577                 } 
    578         } 
    579          
    580         function notificationNewMessage() 
    581         { 
    582                 var _doc                = document; 
    583                 var _id                 = arguments[0]; 
    584                 var _win_name   = _id.replace( /\W/g, '' );  
    585                  
    586                 if ( windowPOPUP( _id ) ) 
    587                 { 
    588                         _doc = windowPopUp[_win_name].document; 
    589                 } 
    590                  
    591                 var oldTitle    = _doc.title;  
    592                 var newTitle    = "## NOVA MENSAGEM ##";  
    593  
    594                 if( timeoutId == null ) 
    595                 { 
    596                         timeoutId = setInterval(function() 
    597                         { 
    598                                 _doc.title = ( _doc.title == newTitle ) ? oldTitle : newTitle; 
    599                         }, 1000); 
    600                          
    601                         configEvents( _doc, 'onclick', function() 
    602                         {  
    603                                 clearInterval(timeoutId); 
    604                                 _doc.title      = oldTitle; 
    605                                 timeoutId               = null; 
    606                         }); 
    607                          
    608                         configEvents( _doc, 'onkeypress', function() 
    609                         {  
    610                                 clearInterval(timeoutId); 
    611                                 _doc.title      = oldTitle; 
    612                                 timeoutId               = null; 
    613                         }); 
    614                 } 
    615         } 
    616  
    617         function optionsItensContact() 
    618         { 
    619                 if( arguments.length > 0 ) 
    620                 { 
    621                         var jid         = arguments[0]; 
    622                         var coord       = arguments[1]; 
    623                         var element = getElement('itenContact_' + jid ); 
    624                         var action      = ( element.getAttribute("subscription") === "not-in-roster" ) ? "Adicionar" : "Autorizar";      
    625                          
    626                         if( showhidden == null ) 
    627                                 showhidden = new ShowHidden(300); 
    628  
    629                         var _options = [ 
    630                                                 [ action , 'loadscript.setAutorization(\''+jid+'\')'], 
    631                                                 ['Remover' , 'loadscript.removeContact(\''+jid+'\')'], 
    632                                                 ['Renomear' , 'loadscript.renameContact(\''+jid+'\')'], 
    633                                                 ['Trocar grupo' , 'loadscript.renameGroup(\''+jid+'\')'] 
    634                                                    ]; 
    635  
    636                         var _itens = ""; 
    637                          
    638                         for( var i in _options ) 
    639                         { 
    640                                 if( typeof(_options[i]) == "object") 
    641                                 { 
    642                                         _itens += '<img src="'+arrow_right.src+'"/>'; 
    643                                         _itens += '<span style="cursor:pointer;margin:3px;font-weight:normal;" onclick='+_options[i][1]+'>'; 
    644                                         _itens += _options[i][0] + '</span><br/>'; 
    645                                 } 
    646                         } 
    647                          
    648                         var _optionsItens = document.createElement("div"); 
    649                                 _optionsItens.className         = "x-menu"; 
    650                                 _optionsItens.style.top         = coord.Y; 
    651                                 _optionsItens.style.left        = ( coord.X - element.offsetLeft ); 
    652                                 _optionsItens.style.zIndex      = getZindex(); 
    653                                 _optionsItens.innerHTML         = _itens;   
    654                                 _optionsItens.onclick           = function(){ showhidden.hiddenObject(false); }; 
    655                                 _optionsItens.onmouseout        = function(){ showhidden.hiddenObject(false); };         
    656                                 _optionsItens.onmouseover       = function(){ showhidden.hiddenObject(true); }; 
    657                                  
    658                                 showhidden.action('onmouseover', 'onmouseout', _optionsItens); 
    659                                  
    660                         window.document.body.appendChild(_optionsItens); 
    661                 } 
    662         } 
    663  
    664         function parse() 
    665         { 
    666                 if( arguments.length == 2 ) 
    667                         return Xtools.parse(Xtools.xml(arguments[0]), arguments[1] ); 
    668                  
    669                 if( arguments.length === 3 ) 
    670                         return Xtools.parse(Xtools.xml(arguments[0]), arguments[1], arguments[2] ); 
    671         } 
    672          
    673         function preferences() 
    674         { 
    675                 var paramPreferences = 
    676                 { 
    677                         'path'  : path, 
    678                         'lang1' : 'Suas Preferências', 
    679                         'lang2' : 'Conexão',     
    680                         'lang3' : 'Conectar Automaticamente o IM', 
    681                         'lang4' : 'Usuários OffLine', 
    682                         'lang5' : 'Exibir amigos Offline', 
    683                         'lang6' : 'Salvar', 
    684                         'lang7' : 'Cancelar', 
    685                         'lang8' : 'Janela de Contatos', 
    686                         'lang9' : 'Abrir janela como Pop-up', 
    687                         'lang10' : 'Ausente', 
    688                         'lang11' : 'Definir status de ausente depois de', 
    689                         'lang12' : 'minutos',    
    690                         'lang13' : 'Mostrar Contatos',   
    691                         'lang14' : 'Mostrar contatos desconectados', 
    692                         'langYes': 'Sim', 
    693                         'langNo' : 'Não'                                                                                            
    694                 }; 
    695                  
    696                  
    697                 var _win_preferences = 
    698                 {  
    699                                 id_window        : "jabberit_preferences", 
    700                                 width            : 430, 
    701                                 height           : 350, 
    702                                 top                      : 150, 
    703                                 left             : 100, 
    704                                 draggable        : true, 
    705                                 visible          : "display", 
    706                                 resizable        : true, 
    707                                 zindex           : zIndex++, 
    708                                 title            : 'Expresso Messenger - Preferências', 
    709                                 closeAction  : "remove", 
    710                                 content          : Xtools.parse(Xtools.xml('preferences'), 'preferences.xsl', paramPreferences) 
    711                 }; 
    712  
    713                 _winBuild(_win_preferences); 
    714                  
    715                  
    716                 var _pButtons = { 
    717                                 'lang1' : 'Salvar', 
    718                                 'lang2' : 'Fechar', 
    719                                 'onclickClose' : '_winBuild("jabberit_preferences","remove");', 
    720                                 'onclickSubmit' : 'javascript:loadscript.setPreferences();' 
    721                 };  
    722                  
    723                 document.getElementById('buttons_preferences_jabberit').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons); 
    724                  
    725                 // Element openWindowJabberit 
    726                 var value1                      = _preferencesIM[0].split(':'); 
    727                 var element1            = document.getElementById(value1[0]); 
    728                 var valueSelect1        = value1[1]; 
    729                  
    730                 for(var i = 0; i < element1.options.length; i++) 
    731                         if( element1.options[i].value == valueSelect1 ) 
    732                                 element1.options[i].selected = true; 
    733  
    734                 // Element openWindowJabberitPopUp 
    735                 var value2                      = _preferencesIM[1].split(':'); 
    736                          
    737                 // Element flagAwayIM 
    738                 var value3              = _preferencesIM[2].split(':'); 
    739                 var element3    = document.getElementById(value3[0]); 
    740                 element3.value  = value3[1]; 
    741                  
    742                 // Element showContactsOfflineJabberit 
    743                 var value4                      = _preferencesIM[3].split(':'); 
    744                 var element4            = document.getElementById(value4[0]); 
    745                 var valueSelect4        = value4[1]; 
    746                 for(var i = 0; i < element4.options.length; i++) 
    747                         if( element4.options[i].value == valueSelect4 ) 
    748                                 element4.options[i].selected = true; 
    749         } 
    750          
    751         function removeContact( jid ) 
    752         { 
    753                 TrophyIM.removeContact( jid ); 
    754         } 
    755          
    756         function removeElement( ) 
    757         { 
    758                 if( arguments.length > 0 ) 
    759                 { 
    760                         var _element = arguments[0]  
    761                          
    762                         if( _element != null ) 
    763                         { 
    764                                 _element.parentNode.removeChild( _element ); 
    765                         } 
    766                 } 
    767         } 
    768          
    769         function removeGroup() 
    770         { 
    771                 var _parent = arguments[0]; 
    772                  
    773                 if( _parent.childNodes.length <= 2 ) 
    774                         _parent.parentNode.removeChild(_parent); 
    775         } 
    776          
    777         function renameContact() 
    778         { 
    779                 if( arguments.length > 0 ) 
    780                 { 
    781                         var _jid        = arguments[0]; 
    782                          
    783                         TrophyIM.renameContact( _jid ); 
    784                 } 
    785         } 
    786          
    787         function renameGroup() 
    788         { 
    789                 if( arguments.length > 0 ) 
    790                 { 
    791                         var _jid        = arguments[0]; 
    792                          
    793                         TrophyIM.renameGroup( _jid ); 
    794                 } 
    795         } 
    796          
    797         function rosterDiv() 
    798         { 
    799                 var _rosterDiv = function() 
    800                 { 
    801  
    802                         var winRosterDiv =  
    803                         { 
    804                                  id_window              : "window_Roster_im", 
    805                                  width                  : 250, 
    806                                  height                 : 410, 
    807                                  top                    : 50, 
    808                                  left                   : -1500, 
    809                                  leftOld                : 50, 
    810                                  draggable              : true, 
    811                                  visible                : "display", 
    812                                  resizable              : true, 
    813                                  zindex                 : zIndex++, 
    814                                  title                  : "Expresso Messenger - Contatos", 
    815                                  closeAction    : "hidden", 
    816                                  content                : ""     
    817                         }; 
    818  
    819                         if( _preferencesIM[0] == "openWindowJabberit:false" ) 
    820                         { 
    821                                 winRosterDiv.left               = 50; 
    822                                 winRosterDiv.leftOld    = -1500; 
    823                         } 
    824                          
    825                         if( SnifferBrowser.isCompatible('ie8','firefox3','firefox4','epiphany2','iceweasel3') ) 
    826                         {        
    827                                 var _idUser     = Base64.decode(getUserCurrent().jid); 
    828                                  
    829                                 var paramListContact =  
    830                                 { 
    831                                         'idUser'        : _idUser, 
    832                                         'full_name'     : (( fullName.length < 25 ) ? fullName : ( fullName.substring( 0, 25) + "...")), 
    833                                         'path_jabberit' : path_jabberit, 
    834                                         'help_expresso' : help_expresso, 
    835                                         'zIndex_'               : zIndex++ 
    836                                 }; 
    837                  
    838                                 winRosterDiv.content = Xtools.parse(Xtools.xml("contacts_list"),"contactsList.xsl", paramListContact)    
    839                                  
    840                         } 
    841                         else 
    842                         { 
    843                                 var paramList =  
    844                                 { 
    845                                         'path' : path_phpgwapi 
    846                                 }; 
    847                                  
    848                                 winRosterDiv.width              = 280; 
    849                                 winRosterDiv.height             = 430; 
    850                                 winRosterDiv.content    = Xtools.parse( Xtools.xml("navigator"), path_phpgwapi + "templates/default/xsl/navigatorCompatible.xsl" , paramList); 
    851                         } 
    852                          
    853                         _winBuild( winRosterDiv );                               
    854  
    855                         // Photo User 
    856                         getPhotoUser(_idUser); 
    857                 } 
    858                  
    859                 setTimeout( function(){ _rosterDiv(); }, 200 ); 
    860         } 
    861  
    862         function searchUser() 
    863         { 
    864                 var _input      = getElement('search_user_jabber'); 
    865                  
    866                 if( _input.value.length >= 3 ) 
    867                         addUser.search(); 
    868                 else 
    869                         alert( i18n.YOUR_SEARCH_ARGUMENT_MUST_BE_LONGER_THAN_3_CHARACTERS + '.' ); 
    870         } 
    871          
    872         function setAutorization() 
    873         { 
    874                 var divItenContact = null; 
    875                  
    876                 if( arguments.length > 0 ) 
    877                 { 
    878                         var jidTo = arguments[0]; 
    879                  
    880                         if( getElement('itenContact_' + jidTo) ) 
    881                                 divItenContact = getElement('itenContact_' + jidTo ); 
    882                 } 
    883                  
    884         if( divItenContact ) 
    885         {        
    886                 var subscription = divItenContact.getAttribute('subscription'); 
    887  
    888                 switch(subscription) 
    889                 { 
    890                                 case 'from': 
     518                        } 
     519                        else 
     520                        { 
     521                            _elementNext.style.display = "block"; 
     522                            getElement("span_show_" + _elementNext.id ).style.display = "block"; 
     523                        } 
     524                    } 
     525 
     526                    _elementNext = _elementNext.nextSibling; 
     527                } 
     528            } 
     529        } 
     530         
     531        function keyPressSearch() 
     532        { 
     533            if( arguments.length > 0 ) 
     534            { 
     535                var ev          = arguments[0]; 
     536                var element     = arguments[1]; 
     537         
     538                if ( ev.keyCode == 13 ) 
     539                    if( element.value.length >= 3 ) 
     540                        searchUser( element.value );     
     541                    else 
     542                        alert( i18n.YOUR_SEARCH_ARGUMENT_MUST_BE_LONGER_THAN_3_CHARACTERS + '.' ); 
     543            } 
     544        } 
     545 
     546         
     547        function loginPage() 
     548        { 
     549            var paramsLoginPage =  
     550            { 
     551                'username' : ((( Base64.decode(getUserCurrent().jid) )) ? Base64.decode(getUserCurrent().jid) : ""), 
     552                'password' : ((( Base64.decode(getUserCurrent().password) )) ? Base64.decode(getUserCurrent().password) : "")  
     553            } 
     554                 
     555            var winLoginPage = 
     556            {    
     557                id_window               : "window_login_page", 
     558                width                   : 260, 
     559                height                  : 120, 
     560                top                     : 100, 
     561                left                    : 400, 
     562                draggable               : true, 
     563                visible         : "display", 
     564                resizable               : true, 
     565                zindex                  : zIndex++, 
     566                title                   : "Expresso Messenger - Login", 
     567                closeAction     : "remove", 
     568                content         : Xtools.parse(Xtools.xml("login_page"), "loginPage.xsl", paramsLoginPage)       
     569            }; 
     570 
     571            _winBuild( winLoginPage ); 
     572        } 
     573 
     574        function loadScripts(pFiles) 
     575        { 
     576            // Load JavaScript 
     577            var loadJavaScript = function(pJs) 
     578            { 
     579                var newScript = document.createElement("script"); 
     580                newScript.setAttribute("type", "text/javascript"); 
     581                newScript.setAttribute("src", pJs ); 
     582                                 
     583                return newScript; 
     584            }; 
     585                 
     586            // Load CSS 
     587            var loadStyleSheet = function(pCss) 
     588            { 
     589                var newStyle = document.createElement("link"); 
     590                newStyle.setAttribute("rel", "stylesheet"); 
     591                newStyle.setAttribute("type", "text/css"); 
     592                newStyle.setAttribute("href", pCss); 
     593                                 
     594                return newStyle; 
     595            }; 
     596                 
     597            for(var i = 0; i < pFiles.length; i++) 
     598            { 
     599                if( pFiles[i].indexOf(".js") > -1 ) 
     600                    document.getElementsByTagName("head")[0].appendChild(loadJavaScript(pFiles[i])); 
     601                                 
     602                if( pFiles[i].indexOf(".css") > -1 ) 
     603                    document.getElementsByTagName("head")[0].appendChild(loadStyleSheet(pFiles[i])); 
     604            } 
     605        } 
     606         
     607        function notificationNewMessage() 
     608        { 
     609            var _doc            = document; 
     610            var _id                     = arguments[0]; 
     611            var _win_name       = _id.replace( /\W/g, '' );  
     612                 
     613            if ( windowPOPUP( _id ) ) 
     614            { 
     615                _doc = windowPopUp[_win_name].document; 
     616            } 
     617                 
     618            var oldTitle        = _doc.title;  
     619            var newTitle        = "## NOVA MENSAGEM ##";  
     620 
     621            if( timeoutId == null ) 
     622            { 
     623                timeoutId = setInterval(function() 
     624                { 
     625                    _doc.title = ( _doc.title == newTitle ) ? oldTitle : newTitle; 
     626                }, 1000); 
     627                         
     628                configEvents( _doc, 'onclick', function() 
     629                {  
     630                    clearInterval(timeoutId); 
     631                    _doc.title  = oldTitle; 
     632                    timeoutId           = null; 
     633                }); 
     634                         
     635                configEvents( _doc, 'onkeypress', function() 
     636                {  
     637                    clearInterval(timeoutId); 
     638                    _doc.title  = oldTitle; 
     639                    timeoutId           = null; 
     640                }); 
     641            } 
     642        } 
     643 
     644        function optionsItensContact() 
     645        { 
     646            if( arguments.length > 0 ) 
     647            { 
     648                var jid         = arguments[0]; 
     649                var coord       = arguments[1]; 
     650                var element = getElement('itenContact_' + jid ); 
     651                var action      = ( element.getAttribute("subscription") === "not-in-roster" ) ? "Adicionar" : "Autorizar";      
     652                         
     653                if( showhidden == null ) 
     654                    showhidden = new ShowHidden(300); 
     655 
     656                var _options = [ 
     657                [ action , 'loadscript.setAutorization(\''+jid+'\')'], 
     658                ['Remover' , 'loadscript.removeContact(\''+jid+'\')'], 
     659                ['Renomear' , 'loadscript.renameContact(\''+jid+'\')'], 
     660                ['Trocar grupo' , 'loadscript.renameGroup(\''+jid+'\')'] 
     661                ]; 
     662 
     663                var _itens = ""; 
     664                         
     665                for( var i in _options ) 
     666                { 
     667                    if( typeof(_options[i]) == "object") 
     668                    { 
     669                        _itens += '<img src="'+arrow_right.src+'"/>'; 
     670                        _itens += '<span style="cursor:pointer;margin:3px;font-weight:normal;" onclick='+_options[i][1]+'>'; 
     671                        _itens += _options[i][0] + '</span><br/>'; 
     672                    } 
     673                } 
     674                         
     675                var _optionsItens = document.createElement("div"); 
     676                _optionsItens.className         = "x-menu"; 
     677                _optionsItens.style.top         = coord.Y; 
     678                _optionsItens.style.left        = ( coord.X - element.offsetLeft ); 
     679                _optionsItens.style.zIndex      = getZindex(); 
     680                _optionsItens.innerHTML         = _itens;   
     681                _optionsItens.onclick           = function(){ 
     682                    showhidden.hiddenObject(false); 
     683                }; 
     684                _optionsItens.onmouseout        = function(){ 
     685                    showhidden.hiddenObject(false); 
     686                };       
     687                _optionsItens.onmouseover       = function(){ 
     688                    showhidden.hiddenObject(true); 
     689                }; 
     690                                 
     691                showhidden.action('onmouseover', 'onmouseout', _optionsItens); 
     692                                 
     693                window.document.body.appendChild(_optionsItens); 
     694            } 
     695        } 
     696 
     697        function parse() 
     698        { 
     699            if( arguments.length == 2 ) 
     700                return Xtools.parse(Xtools.xml(arguments[0]), arguments[1] ); 
     701                 
     702            if( arguments.length === 3 ) 
     703                return Xtools.parse(Xtools.xml(arguments[0]), arguments[1], arguments[2] ); 
     704        } 
     705         
     706        function preferences() 
     707        { 
     708            var paramPreferences = 
     709            { 
     710                'path'  : path, 
     711                'lang1' : 'Suas Preferências', 
     712                'lang2' : 'Conexão',     
     713                'lang3' : 'Conectar Automaticamente o IM', 
     714                'lang4' : 'Usuários OffLine', 
     715                'lang5' : 'Exibir amigos Offline', 
     716                'lang6' : 'Salvar', 
     717                'lang7' : 'Cancelar', 
     718                'lang8' : 'Janela de Contatos', 
     719                'lang9' : 'Abrir janela como Pop-up', 
     720                'lang10' : 'Ausente', 
     721                'lang11' : 'Definir status de ausente depois de', 
     722                'lang12' : 'minutos',    
     723                'lang13' : 'Mostrar Contatos',   
     724                'lang14' : 'Mostrar contatos desconectados', 
     725                'langYes': 'Sim', 
     726                'langNo' : 'Não'                                                                                            
     727            }; 
     728                 
     729                 
     730            var _win_preferences = 
     731            {  
     732                id_window        : "jabberit_preferences", 
     733                width            : 430, 
     734                height           : 350, 
     735                top                      : 150, 
     736                left             : 100, 
     737                draggable        : true, 
     738                visible          : "display", 
     739                resizable        : true, 
     740                zindex           : zIndex++, 
     741                title            : 'Expresso Messenger - Preferências', 
     742                closeAction  : "remove", 
     743                content          : Xtools.parse(Xtools.xml('preferences'), 'preferences.xsl', paramPreferences) 
     744            }; 
     745 
     746            _winBuild(_win_preferences); 
     747                 
     748                 
     749            var _pButtons = { 
     750                'lang1' : 'Salvar', 
     751                'lang2' : 'Fechar', 
     752                'onclickClose' : '_winBuild("jabberit_preferences","remove");', 
     753                'onclickSubmit' : 'javascript:loadscript.setPreferences();' 
     754            };  
     755                 
     756            document.getElementById('buttons_preferences_jabberit').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons); 
     757                 
     758            // Element openWindowJabberit 
     759            var value1                  = _preferencesIM[0].split(':'); 
     760            var element1                = document.getElementById(value1[0]); 
     761            var valueSelect1    = value1[1]; 
     762                 
     763            for(var i = 0; i < element1.options.length; i++) 
     764                if( element1.options[i].value == valueSelect1 ) 
     765                    element1.options[i].selected = true; 
     766 
     767            // Element openWindowJabberitPopUp 
     768            var value2                  = _preferencesIM[1].split(':'); 
     769                         
     770            // Element flagAwayIM 
     771            var value3          = _preferencesIM[2].split(':'); 
     772            var element3        = document.getElementById(value3[0]); 
     773            element3.value      = value3[1]; 
     774                 
     775            // Element showContactsOfflineJabberit 
     776            var value4                  = _preferencesIM[3].split(':'); 
     777            var element4                = document.getElementById(value4[0]); 
     778            var valueSelect4    = value4[1]; 
     779            for(var i = 0; i < element4.options.length; i++) 
     780                if( element4.options[i].value == valueSelect4 ) 
     781                    element4.options[i].selected = true; 
     782        } 
     783         
     784        function removeContact( jid ) 
     785        { 
     786            TrophyIM.removeContact( jid ); 
     787        } 
     788         
     789        function removeElement( ) 
     790        { 
     791            if( arguments.length > 0 ) 
     792            { 
     793                var _element = arguments[0]  
     794                         
     795                if( _element != null ) 
     796                { 
     797                    _element.parentNode.removeChild( _element ); 
     798                } 
     799            } 
     800        } 
     801         
     802        function removeGroup() 
     803        { 
     804            var _parent = arguments[0]; 
     805                 
     806            if( _parent.childNodes.length <= 2 ) 
     807                _parent.parentNode.removeChild(_parent); 
     808        } 
     809         
     810        function renameContact() 
     811        { 
     812            if( arguments.length > 0 ) 
     813            { 
     814                var _jid        = arguments[0]; 
     815                         
     816                TrophyIM.renameContact( _jid ); 
     817            } 
     818        } 
     819         
     820        function renameGroup() 
     821        { 
     822            if( arguments.length > 0 ) 
     823            { 
     824                var _jid        = arguments[0]; 
     825                         
     826                TrophyIM.renameGroup( _jid ); 
     827            } 
     828        } 
     829         
     830        function rosterDiv() 
     831        { 
     832            var _rosterDiv = function() 
     833            { 
     834 
     835                var winRosterDiv =  
     836                { 
     837                    id_window           : "window_Roster_im", 
     838                    width                       : 250, 
     839                    height                      : 410, 
     840                    top                 : 50, 
     841                    left                        : -1500, 
     842                    leftOld             : 50, 
     843                    draggable           : true, 
     844                    visible             : "display", 
     845                    resizable           : true, 
     846                    zindex                      : zIndex++, 
     847                    title                       : "Expresso Messenger - Contatos", 
     848                    closeAction : "hidden", 
     849                    content             : ""     
     850                }; 
     851 
     852                if( _preferencesIM[0] == "openWindowJabberit:false" ) 
     853                { 
     854                    winRosterDiv.left           = 50; 
     855                    winRosterDiv.leftOld        = -1500; 
     856                } 
     857                         
     858                if( SnifferBrowser.isCompatible('chrome11','ie8','firefox3','firefox4','epiphany2','iceweasel3','safari') ) 
     859                {        
     860                    var _idUser = Base64.decode(getUserCurrent().jid); 
     861                                 
     862                    var paramListContact =  
     863                    { 
     864                        'idUser'        : _idUser, 
     865                        'full_name'     : (( fullName.length < 25 ) ? fullName : ( fullName.substring( 0, 25) + "...")), 
     866                        'path_jabberit' : path_jabberit, 
     867                        'help_expresso' : help_expresso, 
     868                        'zIndex_'               : zIndex++ 
     869                    }; 
     870                 
     871                    winRosterDiv.content = Xtools.parse(Xtools.xml("contacts_list"),"contactsList.xsl", paramListContact)        
     872                                 
     873                } 
     874                else 
     875                { 
     876                    var paramList =  
     877                    { 
     878                        'path' : path_phpgwapi 
     879                    }; 
     880                                 
     881                    winRosterDiv.width          = 280; 
     882                    winRosterDiv.height         = 430; 
     883                    winRosterDiv.content        = Xtools.parse( Xtools.xml("navigator"), path_phpgwapi + "templates/default/xsl/navigatorCompatible.xsl" , paramList); 
     884                } 
     885                         
     886                _winBuild( winRosterDiv );                               
     887 
     888                // Photo User 
     889                getPhotoUser(_idUser); 
     890            } 
     891                 
     892            setTimeout( function(){ 
     893                _rosterDiv(); 
     894            }, 200 ); 
     895        } 
     896 
     897        function searchUser() 
     898        { 
     899            var _input  = getElement('search_user_jabber'); 
     900                 
     901            if( _input.value.length >= 3 ) 
     902                addUser.search(); 
     903            else 
     904                alert( i18n.YOUR_SEARCH_ARGUMENT_MUST_BE_LONGER_THAN_3_CHARACTERS + '.' ); 
     905        } 
     906         
     907        function setAutorization() 
     908        { 
     909            var divItenContact = null; 
     910                 
     911            if( arguments.length > 0 ) 
     912            { 
     913                var jidTo = arguments[0]; 
     914                 
     915                if( getElement('itenContact_' + jidTo) ) 
     916                    divItenContact = getElement('itenContact_' + jidTo ); 
     917            } 
     918                 
     919            if( divItenContact ) 
     920            {    
     921                var subscription = divItenContact.getAttribute('subscription'); 
     922 
     923                switch(subscription) 
     924                { 
     925                    case 'from': 
    891926                                         
    892                                         TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid ), 'subscribe'); 
    893                                 break; 
    894  
    895                                 case 'subscribe' : 
     927                        TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid ), 'subscribe'); 
     928                        break; 
     929 
     930                    case 'subscribe' : 
    896931                                         
    897                                         TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid ), 'subscribed'); 
    898                                 break; 
     932                        TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid ), 'subscribed'); 
     933                        break; 
    899934                                 
    900                                 case 'none' :                                    
     935                    case 'none' :                                        
    901936                                 
    902                                 TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid ), 'subscribe'); 
    903                                 break; 
     937                        TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid ), 'subscribe'); 
     938                        break; 
    904939                                 
    905                         case 'to' :                              
     940                    case 'to' :                          
    906941                                 
    907                                 TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid ), 'subscribed');                               
    908                                 removeElement( getElement('itenContactNotification_' + jidTo ) );                                
    909                                 break; 
    910  
    911                         case 'not-in-roster': 
     942                        TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid ), 'subscribed');                               
     943                        removeElement( getElement('itenContactNotification_' + jidTo ) );                                
     944                        break; 
     945 
     946                    case 'not-in-roster': 
    912947                                         
    913                                 TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid), 'subscribed'); 
    914                                 addUser.add( jidTo ); 
    915                                         break; 
    916                 } 
    917         } 
    918         } 
    919          
    920         function setMessageStatus() 
    921         { 
    922                 if( arguments.length > 0 ) 
    923                 { 
    924                         var _element = arguments[0]; 
    925                         var _parent      = _element.parentNode;                  
    926  
    927                         if( _element.nodeName.toLowerCase() == "label") 
    928                         { 
    929                                 var _input                              = document.createElement("input");  
    930                                         _input.size                     = "35"; 
    931                                         _input.maxlength        = "35"; 
    932                                         _input.style.border = "0"; 
    933                                         _input.value            = _element.innerHTML; 
     948                        TrophyIM.setAutorization( jidTo, Base64.decode(this.getUserCurrent().jid), 'subscribed'); 
     949                        addUser.add( jidTo ); 
     950                        break; 
     951                } 
     952            } 
     953        } 
     954         
     955        function setMessageStatus() 
     956        { 
     957            if( arguments.length > 0 ) 
     958            { 
     959                var _element = arguments[0]; 
     960                var _parent      = _element.parentNode;                  
     961 
     962                if( _element.nodeName.toLowerCase() == "label") 
     963                { 
     964                    var _input                          = document.createElement("input");  
     965                    _input.size                 = "35"; 
     966                    _input.maxlength    = "35"; 
     967                    _input.style.border = "0"; 
     968                    _input.value                = _element.innerHTML; 
    934969                                         
    935                                 // OnkeyUp 
    936                                 configEvents( _input, "onkeyup", function(e) 
    937                                                 { 
    938                                                         if( e.keyCode == 13 ) loadscript.setMessageStatus(_input, _element); 
    939                                                 } 
    940                                 ); 
    941                                  
    942                                 // Onblur        
    943                             configEvents(_input, "onblur", function(){ loadscript.setMessageStatus(_input, _element)});          
     970                    // OnkeyUp 
     971                    configEvents( _input, "onkeyup", function(e) 
     972                    { 
     973                        if( e.keyCode == 13 ) loadscript.setMessageStatus(_input, _element); 
     974                    } 
     975                    ); 
     976                                 
     977                    // Onblur    
     978                    configEvents(_input, "onblur", function(){ 
     979                        loadscript.setMessageStatus(_input, _element) 
     980                        });              
    944981 
    945982                             
    946                                 if( _parent != null ) 
    947                                 {        
    948                                         // Remove label 
    949                                         if( _element != null ) 
    950                                                 _parent.removeChild( _element ); 
     983                    if( _parent != null ) 
     984                    {    
     985                        // Remove label 
     986                        if( _element != null ) 
     987                            _parent.removeChild( _element ); 
    951988                                                 
    952                                         // Add Input 
    953                                         if( _input != null )  
    954                                                 _parent.appendChild( _input ); 
    955                                 } 
    956  
    957                                 _input.focus(); 
    958                                 _input.select(); 
    959                         } 
    960                         else 
    961                         { 
    962                                 var _label              = arguments[1]; 
    963                                 _statusMessage  = _element.value.replace(/^\(+|\)+$/g,""); 
    964                                  
    965                                 if( ( _statusMessage = _statusMessage.replace(/^\s+|\s+$|^\n|\n$/g,"") ) != "") 
    966                                         _label.innerHTML = "( " + _statusMessage + " )"; 
    967                                 else 
    968                                         _label.innerHTML = "( " + i18n.TYPE_YOUR_MESSAGE_HERE_STATUS + " )"; 
    969                                  
    970                                 if( _parent != null ) 
    971                                 {        
    972                                         // Remove Input 
    973                                         if( _element != null ) 
    974                                                 _parent.removeChild( _element ); 
     989                        // Add Input 
     990                        if( _input != null )  
     991                            _parent.appendChild( _input ); 
     992                    } 
     993 
     994                    _input.focus(); 
     995                    _input.select(); 
     996                } 
     997                else 
     998                { 
     999                    var _label          = arguments[1]; 
     1000                    _statusMessage      = _element.value.replace(/^\(+|\)+$/g,""); 
     1001                                 
     1002                    if( ( _statusMessage = _statusMessage.replace(/^\s+|\s+$|^\n|\n$/g,"") ) != "") 
     1003                        _label.innerHTML = "( " + _statusMessage + " )"; 
     1004                    else 
     1005                        _label.innerHTML = "( " + i18n.TYPE_YOUR_MESSAGE_HERE_STATUS + " )"; 
     1006                                 
     1007                    if( _parent != null ) 
     1008                    {    
     1009                        // Remove Input 
     1010                        if( _element != null ) 
     1011                            _parent.removeChild( _element ); 
    9751012                                                 
    976                                         // Add Label 
    977                                         if( _label != null )  
    978                                                 _parent.appendChild( _label ); 
    979                                 } 
    980                                  
    981                                 // Send Status Message 
    982                                 _statusMessage = ( ( _statusMessage !=  i18n.TYPE_YOUR_MESSAGE_HERE_STATUS ) ? _statusMessage : "" );                            
    983                                  
    984                                 TrophyIM.setPresence("status", _statusMessage ); 
    985                         }        
    986                 } 
    987         } 
    988          
    989         function setPreferences() 
    990         { 
    991                 // Element openWindowJabberit 
    992                 var elementOpenW        = document.getElementById('openWindowJabberit'); 
    993                 var value                       = ''; 
    994                  
    995                 for(var i = 0 ; i < elementOpenW.options.length; i++) 
    996                         if( elementOpenW.options[i].selected == true) 
    997                         { 
    998                                 value = 'preferences1=openWindowJabberit:' + elementOpenW.options[i].value; 
    999                                 _preferencesIM[0] = 'openWindowJabberit:' + elementOpenW.options[i].value; 
    1000                         } 
    1001  
    1002                 // Element openWindowJabberitPopUp 
    1003                 value += '&preferences2=openWindowJabberitPopUp:false'; 
    1004                 _preferencesIM[1] = 'openWindowJabberitPopUp:false'; 
    1005                  
    1006                 // Element flagAwayIM 
    1007                 var elementFlagIM = document.getElementById('flagAwayIM'); 
    1008                  
    1009                 if( elementFlagIM.value.length > 0 && parseInt(elementFlagIM.value) > 0 ) 
    1010                 { 
    1011                         _preferencesIM[2] = 'flagAwayIM:' + elementFlagIM.value; 
    1012                         value += '&preferences3=flagAwayIM:' + elementFlagIM.value; 
    1013                 } 
    1014                 else 
    1015                 { 
    1016                         alert('Informe um valor igual ou maior que 1!'); 
    1017                         return false; 
    1018                 } 
    1019  
    1020                 // Element showContactsOfflineJabberit 
    1021                 var elementShowOffline  = document.getElementById('showContactsOfflineJabberit'); 
    1022                  
    1023                 for(var i = 0 ; i < elementShowOffline.options.length; i++) 
    1024                         if( elementShowOffline.options[i].selected == true) 
    1025                         { 
    1026                                 _preferencesIM[3] = 'showContactsOfflineJabberit:' + elementShowOffline.options[i].value; 
    1027                                 value += '&preferences4=showContactsOfflineJabberit:' + elementShowOffline.options[i].value; 
    1028                         } 
    1029                  
    1030                 // Save Preferences 
    1031                 conn.go('p.pf.setPreferences', 
    1032                                  function(data) 
    1033                                  { 
    1034                                         if( data == 'false' ) 
    1035                                         { 
    1036                                                 alert('Erro salvando suas preferências!'); 
    1037                                         } 
    1038  
    1039                                         _winBuild('jabberit_preferences', 'remove'); 
    1040                                  }, 
    1041                                  value); 
    1042         } 
    1043          
    1044         function setPresence() 
    1045         { 
    1046                 if( arguments.length > 0 ) 
    1047                 { 
    1048                         var element = arguments[0]; 
    1049                          
    1050                         if( showhidden == null ) 
    1051                                 showhidden = new ShowHidden(300); 
    1052                          
    1053                         var _status = [ 
    1054                                                ['Afastado', 'away', '<img src="'+path_jabberit+'templates/default/images/away.gif" />'], 
    1055                                                ['Disponível', 'available', '<img src="'+path_jabberit+'templates/default/images/available.gif" />'], 
    1056                                                ['Livre p/ Conversa', 'chat', '<img src="'+path_jabberit+'templates/default/images/chat.gif" />'], 
    1057                                                ['Não Disponível', 'xa', '<img src="'+path_jabberit+'templates/default/images/xa.gif" />'], 
    1058                                                ['Ocupado', 'dnd', '<img src="'+path_jabberit+'templates/default/images/dnd.gif" />'], 
    1059                                                ['Desconectado', 'unavailable', '<img src="'+path_jabberit+'templates/default/images/unavailable.gif" />'], 
    1060                                                ['Mensagem de Status...', 'status', '<img src="'+path_jabberit+'templates/default/images/message_normal.gif" />'],                                                
    1061                                           ]; 
    1062                          
    1063                         var _itens = ""; 
    1064                          
    1065                         for( var i in _status ) 
    1066                         { 
    1067                                 if( typeof( _status[i]) == "object" ) 
    1068                                 { 
    1069                                         _itens += '<span style="cursor:pointer;" onclick="TrophyIM.setPresence(\''+_status[i][1]+'\'); loadscript.setStatusJabber(\''+_status[i][0]+'\',\''+_status[i][1]+'\');">'; 
    1070                                         _itens += _status[i][2]+ "<span style='margin:3px;'>" + _status[i][0] + "</span></span><br/>"; 
    1071                                 } 
    1072                         } 
    1073                          
    1074                         var _statusItens = document.createElement("div"); 
    1075                                 _statusItens.style.marginTop    = "65px"; 
    1076                                 _statusItens.style.marginLeft   = "67px"; 
    1077                                 _statusItens.className                  = "x-menu"; 
    1078                                 _statusItens.style.zIndex               = '99999'; 
    1079                                 _statusItens.innerHTML                  = _itens;   
    1080                                 _statusItens.onclick                    = function(){ showhidden.hiddenObject(false); }; 
     1013                        // Add Label 
     1014                        if( _label != null )  
     1015                            _parent.appendChild( _label ); 
     1016                    } 
     1017                                 
     1018                    // Send Status Message 
     1019                    _statusMessage = ( ( _statusMessage !=  i18n.TYPE_YOUR_MESSAGE_HERE_STATUS ) ? _statusMessage : "" );                                
     1020                                 
     1021                    TrophyIM.setPresence("status", _statusMessage ); 
     1022                }        
     1023            } 
     1024        } 
     1025         
     1026        function setPreferences() 
     1027        { 
     1028            // Element openWindowJabberit 
     1029            var elementOpenW    = document.getElementById('openWindowJabberit'); 
     1030            var value                   = ''; 
     1031                 
     1032            for(var i = 0 ; i < elementOpenW.options.length; i++) 
     1033                if( elementOpenW.options[i].selected == true) 
     1034                { 
     1035                    value = 'preferences1=openWindowJabberit:' + elementOpenW.options[i].value; 
     1036                    _preferencesIM[0] = 'openWindowJabberit:' + elementOpenW.options[i].value; 
     1037                } 
     1038 
     1039            // Element openWindowJabberitPopUp 
     1040            value += '&preferences2=openWindowJabberitPopUp:false'; 
     1041            _preferencesIM[1] = 'openWindowJabberitPopUp:false'; 
     1042                 
     1043            // Element flagAwayIM 
     1044            var elementFlagIM = document.getElementById('flagAwayIM'); 
     1045                 
     1046            if( elementFlagIM.value.length > 0 && parseInt(elementFlagIM.value) > 0 ) 
     1047            { 
     1048                _preferencesIM[2] = 'flagAwayIM:' + elementFlagIM.value; 
     1049                value += '&preferences3=flagAwayIM:' + elementFlagIM.value; 
     1050            } 
     1051            else 
     1052            { 
     1053                alert('Informe um valor igual ou maior que 1!'); 
     1054                return false; 
     1055            } 
     1056 
     1057            // Element showContactsOfflineJabberit 
     1058            var elementShowOffline      = document.getElementById('showContactsOfflineJabberit'); 
     1059                 
     1060            for(var i = 0 ; i < elementShowOffline.options.length; i++) 
     1061                if( elementShowOffline.options[i].selected == true) 
     1062                { 
     1063                    _preferencesIM[3] = 'showContactsOfflineJabberit:' + elementShowOffline.options[i].value; 
     1064                    value += '&preferences4=showContactsOfflineJabberit:' + elementShowOffline.options[i].value; 
     1065                } 
     1066                 
     1067            // Save Preferences 
     1068            conn.go('p.pf.setPreferences', 
     1069                function(data) 
     1070                { 
     1071                    if( data == 'false' ) 
     1072                    { 
     1073                        alert('Erro salvando suas preferências!'); 
     1074                    } 
     1075 
     1076                    _winBuild('jabberit_preferences', 'remove'); 
     1077                }, 
     1078                value); 
     1079        } 
     1080         
     1081        function setPresence() 
     1082        { 
     1083            if( arguments.length > 0 ) 
     1084            { 
     1085                var element = arguments[0]; 
     1086                         
     1087                if( showhidden == null ) 
     1088                    showhidden = new ShowHidden(300); 
     1089                         
     1090                var _status = [ 
     1091                ['Afastado', 'away', '<img src="'+path_jabberit+'templates/default/images/away.gif" />'], 
     1092                ['Disponível', 'available', '<img src="'+path_jabberit+'templates/default/images/available.gif" />'], 
     1093                ['Livre p/ Conversa', 'chat', '<img src="'+path_jabberit+'templates/default/images/chat.gif" />'], 
     1094                ['Não Disponível', 'xa', '<img src="'+path_jabberit+'templates/default/images/xa.gif" />'], 
     1095                ['Ocupado', 'dnd', '<img src="'+path_jabberit+'templates/default/images/dnd.gif" />'], 
     1096                ['Desconectado', 'unavailable', '<img src="'+path_jabberit+'templates/default/images/unavailable.gif" />'], 
     1097                ['Mensagem de Status...', 'status', '<img src="'+path_jabberit+'templates/default/images/message_normal.gif" />'],                                               
     1098                ]; 
     1099                         
     1100                var _itens = ""; 
     1101                         
     1102                for( var i in _status ) 
     1103                { 
     1104                    if( typeof( _status[i]) == "object" ) 
     1105                    { 
     1106                        _itens += '<span style="cursor:pointer;" onclick="TrophyIM.setPresence(\''+_status[i][1]+'\'); loadscript.setStatusJabber(\''+_status[i][0]+'\',\''+_status[i][1]+'\');">'; 
     1107                        _itens += _status[i][2]+ "<span style='margin:3px;'>" + _status[i][0] + "</span></span><br/>"; 
     1108                    } 
     1109                } 
     1110                         
     1111                var _statusItens = document.createElement("div"); 
     1112                _statusItens.style.marginTop    = "65px"; 
     1113                _statusItens.style.marginLeft   = "67px"; 
     1114                _statusItens.className                  = "x-menu"; 
     1115                _statusItens.style.zIndex               = '99999'; 
     1116                _statusItens.innerHTML                  = _itens;   
     1117                _statusItens.onclick                    = function(){ 
     1118                    showhidden.hiddenObject(false); 
     1119                }; 
    10811120                                                                                   
    1082                                 showhidden.action('onmouseover', 'onmouseout', _statusItens); 
    1083                                  
    1084                         element.parentNode.onmouseout   = function(){ showhidden.hiddenObject(false); }; 
    1085                         element.parentNode.onmouseover  = function(){ showhidden.hiddenObject(true); }; 
    1086                         element.parentNode.appendChild(_statusItens); 
    1087                 } 
    1088         } 
    1089  
    1090         function setSelectEditable(element, top, left ) 
    1091         { 
    1092                 if( getElement('selectBox0') == null ) 
    1093                         selectEditable.create(element, top, left ); 
    1094         } 
    1095  
    1096         function setStatusJabber() 
    1097         { 
    1098                 if( arguments.length > 0 ) 
    1099                 { 
    1100                         if( arguments[1] != 'status' ) 
    1101                         { 
    1102                                 var _text       = arguments[0]; 
    1103                                 var _img        = statusUserIM = arguments[1]; 
    1104                                  
    1105                                 getElement('statusJabberText').innerHTML                = _text; 
    1106                                 getElement('statusJabberImg').style.background  = "url('"+path_jabberit+"templates/default/images/"+_img+".gif')"; 
    1107                                 getElement('status_jabber_expresso').style.background = "url('"+path_jabberit+"templates/default/images/"+_img+".gif') no-repeat"; 
    1108                         } 
    1109                 }        
    1110         } 
    1111  
    1112         function _setUserCurrent( _user ) 
    1113         { 
    1114                 userCurrent =  
    1115                 { 
    1116                         'jid'           : _user.jid.substring(11, _user.jid.length), 
    1117                         'password'      : _user.password.substring(11, _user.password.length) 
    1118                 }                
    1119         } 
    1120          
    1121         function setUserCurrent() 
    1122         { 
    1123                 if( getUserCurrent() == null ) 
    1124                 { 
    1125                         conn.go('p.ff.data_0', 
    1126                                                 function(_User) 
    1127                                                 { 
    1128                                                         conn.go('p.ff.data_1', 
    1129                                                                         function(_pass) 
    1130                                                                         { 
    1131                                                                                 _setUserCurrent( { jid : _User, password : _pass } ); 
    1132                                                                         }); 
    1133                                                 }); 
    1134                 } 
    1135         } 
    1136  
    1137         var _stylesheets = [ ]; 
    1138         var _links = document.getElementsByTagName( 'link' ); 
    1139          
    1140         for ( var i = 0; i < _links.length; i++ ) 
    1141                 if ( _links.item( i ).type && _links.item( i ).type.toLowerCase( ) == 'text/css' ) 
    1142                         _stylesheets[ _stylesheets.length ] = _links.item( i );   
    1143          
    1144         function windowPOPUP() 
    1145         { 
    1146                 var _id = arguments[0]; 
    1147                 var _win_name = _id.replace( /\W/g, '' );  
    1148  
    1149                 if ( arguments.length == 1 ) 
    1150                 { 
    1151                         if ( windowPopUp[_win_name] ) 
    1152                                 return true; 
    1153                         else 
    1154                                 return false; 
    1155                 } 
    1156                  
    1157                 if( arguments.length == 2 ) 
    1158                 {        
    1159                         if( !windowPopUp[_win_name] ) 
    1160                         { 
    1161                                 windowPopUp[_win_name] = window.open( '', _win_name + '__popup', 'height=355,width=380,top=50,left=50,toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,location=no,titlebar=no'); 
    1162                                 var tmp = windowPopUp[_win_name].document; 
    1163                                  
    1164                                 tmp.write('<html><head>'); 
    1165                                 tmp.write('</head><body>'); 
    1166                                 tmp.write('</body></html>'); 
    1167                                 tmp.close(); 
    1168                                  
    1169                                 for ( var i = 0; i < _stylesheets.length; i++ ) 
    1170                                         tmp.documentElement.getElementsByTagName( 'head' ).item(0).appendChild( _stylesheets[ i ].cloneNode( true ) ); 
    1171  
    1172                                 var divPOP = getElement( _id + "__popUp" ); 
    1173                                         divPOP.style.background = "url('"+path_jabberit+"templates/default/images/icon_down.png') no-repeat"; 
    1174                                         divPOP.innerHTML = "PopIn"; 
     1121                showhidden.action('onmouseover', 'onmouseout', _statusItens); 
     1122                                 
     1123                element.parentNode.onmouseout   = function(){ 
     1124                    showhidden.hiddenObject(false); 
     1125                }; 
     1126                element.parentNode.onmouseover  = function(){ 
     1127                    showhidden.hiddenObject(true); 
     1128                }; 
     1129                element.parentNode.appendChild(_statusItens); 
     1130            } 
     1131        } 
     1132 
     1133        function setSelectEditable(element, top, left ) 
     1134        { 
     1135            if( getElement('selectBox0') == null ) 
     1136                selectEditable.create(element, top, left ); 
     1137        } 
     1138 
     1139        function setStatusJabber() 
     1140        { 
     1141            if( arguments.length > 0 ) 
     1142            { 
     1143                if( arguments[1] != 'status' ) 
     1144                { 
     1145                    var _text   = arguments[0]; 
     1146                    var _img    = statusUserIM = arguments[1]; 
     1147                                 
     1148                    getElement('statusJabberText').innerHTML            = _text; 
     1149                    getElement('statusJabberImg').style.background      = "url('"+path_jabberit+"templates/default/images/"+_img+".gif')"; 
     1150                    getElement('status_jabber_expresso').style.background = "url('"+path_jabberit+"templates/default/images/"+_img+".gif') no-repeat"; 
     1151                } 
     1152            }    
     1153        } 
     1154 
     1155        function _setUserCurrent( _user ) 
     1156        { 
     1157            userCurrent =  
     1158            { 
     1159                'jid'           : _user.jid.substring(11, _user.jid.length), 
     1160                'password'      : _user.password.substring(11, _user.password.length) 
     1161            }            
     1162        } 
     1163         
     1164        function setUserCurrent() 
     1165        { 
     1166            if( getUserCurrent() == null ) 
     1167            { 
     1168                conn.go('p.ff.data_0', 
     1169                    function(_User) 
     1170                    { 
     1171                        conn.go('p.ff.data_1', 
     1172                            function(_pass) 
     1173                            { 
     1174                                _setUserCurrent( { 
     1175                                    jid : _User,  
     1176                                    password : _pass 
     1177                                } ); 
     1178                            }); 
     1179                    }); 
     1180            } 
     1181        } 
     1182 
     1183        var _stylesheets = [ ]; 
     1184        var _links = document.getElementsByTagName( 'link' ); 
     1185         
     1186        for ( var i = 0; i < _links.length; i++ ) 
     1187            if ( _links.item( i ).type && _links.item( i ).type.toLowerCase( ) == 'text/css' ) 
     1188                _stylesheets[ _stylesheets.length ] = _links.item( i );   
     1189         
     1190        function windowPOPUP() 
     1191        { 
     1192            var _id = arguments[0]; 
     1193            var _win_name = _id.replace( /\W/g, '' );  
     1194 
     1195            if ( arguments.length == 1 ) 
     1196            { 
     1197                if ( windowPopUp[_win_name] ) 
     1198                    return true; 
     1199                else 
     1200                    return false; 
     1201            } 
     1202                 
     1203            if( arguments.length == 2 ) 
     1204            {    
     1205                if( !windowPopUp[_win_name] ) 
     1206                { 
     1207                    windowPopUp[_win_name] = window.open( '', _win_name + '__popup', 'height=355,width=380,top=50,left=50,toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,location=no,titlebar=no'); 
     1208                    var tmp = windowPopUp[_win_name].document; 
     1209                                 
     1210                    tmp.write('<html><head>'); 
     1211                    tmp.write('</head><body>'); 
     1212                    tmp.write('</body></html>'); 
     1213                    tmp.close(); 
     1214                                 
     1215                    for ( var i = 0; i < _stylesheets.length; i++ ) 
     1216                        tmp.documentElement.getElementsByTagName( 'head' ).item(0).appendChild( _stylesheets[ i ].cloneNode( true ) ); 
     1217 
     1218                    var divPOP = getElement( _id + "__popUp" ); 
     1219                    divPOP.style.background = "url('"+path_jabberit+"templates/default/images/icon_down.png') no-repeat"; 
     1220                    divPOP.innerHTML = "PopIn"; 
    11751221                                         
    1176                                 function _close( ) 
    1177                                 { 
    1178                                         windowPopUp[_win_name].close(); 
    1179                                         configEvents( divPOP ,'onclick', _close, true ); 
    1180                                 } 
     1222                    function _close( ) 
     1223                    { 
     1224                        windowPopUp[_win_name].close(); 
     1225                        configEvents( divPOP ,'onclick', _close, true ); 
     1226                    } 
    11811227                                         
    1182                                 configEvents( divPOP ,'onclick', _close ); 
    1183  
    1184                                 var _content = tmp.documentElement.getElementsByTagName( 'body' ).item(0).appendChild( getElement(_id + '__chatBox' ).parentNode ); 
    1185  
    1186                                 _content.firstChild.scrollTop = _content.firstChild.scrollHeight; 
    1187  
    1188                                 configEvents( windowPopUp[_win_name] ,'onbeforeunload', function() 
    1189                                 { 
    1190                                         delete windowPopUp[_win_name]; 
    1191                                         divPOP.style.background = "url('"+path_jabberit+"templates/default/images/icon_up.png') no-repeat"; 
    1192                                         divPOP.innerHTML = "PopUp"; 
    1193                                         divPOP.onclick  = function(){ loadscript.windowPOPUP( _id , true ); }; 
    1194                                         _winBuild( 'window_chat_area_' + _id, "display" ).content( true ); 
    1195                                 }); 
    1196  
    1197                                 _winBuild( 'window_chat_area_' + _id, 'hidden' ); 
    1198                         } 
    1199                 } 
    1200         } 
    1201          
    1202         function windowNotificationNewUsers() 
    1203         { 
    1204                 var _users = Xtools.xml('notification_new_users'); 
    1205                  
    1206                 for( var user in TrophyIM.rosterObj.roster ) 
    1207                 { 
    1208                         if ( TrophyIM.rosterObj.roster[ user ].constructor == Function ) 
    1209                                 continue; 
    1210  
    1211                         if( TrophyIM.rosterObj.roster[ user ].contact.jid != Base64.decode( loadscript.getUserCurrent().jid) ) 
    1212                         { 
    1213                                 var _subscription = TrophyIM.rosterObj.roster[user].contact.subscription; 
    1214                                  
    1215                                 if ( _subscription == 'to' || _subscription == 'not-in-roster' ) 
    1216                                 { 
    1217                                         var _user       = _users.createElement('user'); 
    1218                                         var _jid        = _users.createElement('jid'); 
    1219                                         var _status     = _users.createElement('status'); 
    1220                                         _jid.appendChild( _users.createTextNode(TrophyIM.rosterObj.roster[user].contact.jid) ); 
    1221                                         _status.appendChild( _users.createTextNode( _subscription ) ); 
    1222                                         _user.appendChild( _jid ); 
    1223                                         _user.appendChild( _status ); 
    1224                                         _users.documentElement.appendChild( _user ); 
    1225                                 } 
    1226                         } 
    1227                 } 
    1228                  
    1229                 var paramsNotification =  
    1230                 { 
    1231                         'lang_1' : "Notificação",        
    1232                         'lang_2' : "O(s) usuário(s) abaixo pedem sua autorização.", 
    1233                         'lang_3' : "Autorizar", 
    1234                         'lang_4' : "Remover" 
    1235                 }; 
    1236                  
    1237                 var winNotification = 
    1238                 {        
    1239                          id_window              : "window_notification_new_users", 
    1240                          width                  : 400, 
    1241                          height                 : 300, 
    1242                          top                    : 100, 
    1243                          left                   : 400, 
    1244                          draggable              : true, 
    1245                          visible                : "display", 
    1246                          resizable              : true, 
    1247                          zindex                 : zIndex++, 
    1248                          title                  : "Expresso Messenger - Notificação de Novos Usuários", 
    1249                          closeAction    : "remove", 
    1250                          content                : Xtools.parse( _users , "notificationNewUsers.xsl", paramsNotification )        
    1251                 }; 
    1252  
    1253                 _winBuild( winNotification ); 
    1254         } 
    1255  
    1256         function createChatRooms() 
    1257         { 
    1258                 _winBuild("window_List_Rooms_jabberit_messenger","remove"); 
    1259                  
    1260                 var paramCreateChatRoom =  
    1261                 { 
    1262                         'lang_nameChatRoom'     : "Nome da Sala", 
    1263                         'lang_nickName'         : "Apelido" 
    1264                 }; 
    1265                  
    1266                 var winCreateChatRooms = 
    1267                 {        
    1268                          id_window              : "window_create_chat_rooms", 
    1269                          width                  : 360, 
    1270                          height                 : 160, 
    1271                          top                    : 100, 
    1272                          left                   : 410, 
    1273                          draggable              : true, 
    1274                          visible                : "display", 
    1275                          resizable              : true, 
    1276                          zindex                 : loadscript.getZIndex(), 
    1277                          title                  : "Expresso Messenger - Criar Sala de Bate Papo", 
    1278                          closeAction    : "remove", 
    1279                          content                : Xtools.parse( Xtools.xml("create_chat_room"), "createChatRoom.xsl", paramCreateChatRoom ) 
    1280                 }; 
    1281                  
    1282                 _winBuild( winCreateChatRooms ); 
    1283  
    1284                 var _pButtons = 
    1285                 { 
    1286                         'lang1'                 : 'Ingressar', 
    1287                         'lang2'                 : 'Fechar', 
    1288                         'onclickClose'  : '_winBuild("window_create_chat_rooms","remove");', 
    1289                         'onclickSubmit' : 'TrophyIM.createChatRooms(); _winBuild("window_create_chat_rooms","remove");' 
    1290                 };  
    1291  
    1292                 // Add Buttons 
    1293                 document.getElementById('buttons_createChatRoom').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons); 
    1294                  
    1295         } 
    1296          
    1297         function listRooms( element ) 
    1298         { 
    1299                 element = element.getElementsByTagName( 'item' ); 
    1300  
    1301                 var _roomsCount = 0; 
    1302                 var _xml                = Xtools.xml('listRooms'); 
    1303                 var _listRooms  = _xml.documentElement;  
    1304                  
    1305                 var show = function( ) 
    1306                 { 
    1307                         if ( _roomsCount != element.length ) 
    1308                                 return false; 
    1309                          
    1310                         var paramsListRooms =  
    1311                         { 
    1312                                 "path_jabberit" : path_jabberit  
    1313                         }; 
    1314                          
    1315                         var winListRooms = 
    1316                 {        
    1317                                  id_window              : "window_List_Rooms_jabberit_messenger", 
    1318                          width                  : 450, 
    1319                          height                 : 300, 
    1320                          top                    : 100, 
    1321                          left                   : 400, 
    1322                          draggable              : true, 
    1323                          visible                : "display", 
    1324                          resizable              : true, 
    1325                          zindex                 : loadscript.getZIndex(), 
    1326                          title                  : "Expresso Messenger - Salas de Bate Papo", 
    1327                          closeAction    : "remove", 
    1328                          content                : Xtools.parse( _xml, "listRooms.xsl", paramsListRooms ) 
    1329                 }; 
    1330                          
    1331                         _winBuild( winListRooms ); 
    1332                          
    1333                         var _pButtons = 
    1334                         { 
    1335                                 'lang1'                 : 'Criar Nova Sala', 
    1336                                 'lang2'                 : 'Fechar', 
    1337                                 'onclickClose'  : '_winBuild("window_List_Rooms_jabberit_messenger","remove");', 
    1338                                 'onclickSubmit' : 'loadscript.createChatRooms();' 
    1339                         };  
    1340  
    1341                         // Add Buttons 
    1342                         document.getElementById('buttons_addChatRoom').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons); 
    1343                 }; 
    1344  
    1345                 var _add_room = function( _room ) 
    1346         { 
    1347                         _roomsCount++; 
    1348  
    1349                         var _ROOM               = _xml.createElement('room');  
    1350                         var _JIDROOM    = _xml.createElement('jidRoom'); 
    1351                         var nameRoom    = _room.getAttribute( 'from' ); 
    1352  
    1353                         _ROOM.setAttribute( 'nameRoom', unescape((nameRoom.substring(0, nameRoom.indexOf("@"))).toUpperCase()) ); 
    1354                         _JIDROOM.appendChild( _xml.createTextNode(nameRoom) ); 
    1355                         _ROOM.appendChild( _JIDROOM ); 
    1356  
    1357                         // Get fields elements; 
    1358                         var _fields = _room.getElementsByTagName( 'field' ); 
    1359  
    1360                         for ( var f = 0; f < _fields.length; f++ ) 
    1361                         { 
    1362                                 if ( _fields[ f ].getAttribute( 'var' ) ) 
    1363                                 { 
    1364                                         if ( _fields[ f ].firstChild.hasChildNodes( ) && _fields[ f ].getAttribute( 'var' ) == 'muc#roominfo_description' ) 
    1365                                         { 
    1366                                                 var _description        = _xml.createElement("description"); 
    1367                                                         _description.appendChild( _xml.createTextNode( _fields[ f ].firstChild.firstChild.nodeValue ) ); 
    1368                                                         _ROOM.appendChild( _description ); 
    1369                                         } 
    1370  
    1371                                         if ( _fields[ f ].firstChild.hasChildNodes( ) && _fields[ f ].getAttribute( 'var' ) == 'muc#roominfo_occupants' ) 
    1372                                         { 
    1373                                                 var _occupants = _xml.createElement("occupants") 
    1374                                                         _occupants.appendChild( _xml.createTextNode( _fields[ f ].firstChild.firstChild.nodeValue) ); 
    1375                                                         _ROOM.appendChild( _occupants ); 
    1376                                         } 
    1377                                 } 
    1378                         } 
    1379  
    1380                         // Get feature elements; 
    1381                         var _feature = _room.getElementsByTagName( 'feature' ); 
    1382                          
    1383                         for( var f = 0 ; f < _feature.length; f++ ) 
    1384                         { 
    1385                                 if ( _feature[ f ].getAttribute( 'var' ) ) 
    1386                                 { 
    1387                                         if( _feature[ f ].getAttribute( 'var' ) == 'muc_unsecured' ) 
    1388                                         { 
    1389                                                 var _password = _xml.createElement("password"); 
    1390                                                         _password.appendChild( _xml.createTextNode("false") ); 
    1391                                                         _ROOM.appendChild( _password ); 
    1392                                         } 
    1393                                         else if( _feature[ f ].getAttribute( 'var' ) == 'muc_passwordprotected' ) 
    1394                                         { 
    1395                                                 var _password = _xml.createElement("password"); 
    1396                                                         _password.appendChild( _xml.createTextNode("true") ); 
    1397                                                         _ROOM.appendChild( _password ); 
    1398                                         }        
    1399                                 } 
    1400                         } 
    1401                          
    1402                         _listRooms.appendChild( _ROOM ); 
    1403                          
    1404                         show( ); 
    1405         }; 
    1406                  
    1407                 var _get_room_info = function( _room ) 
    1408                 { 
    1409                 TrophyIM.connection.sendIQ( 
    1410                                 $iq( { "to" : _room, "type" : "get" } ).c( "query",{xmlns: Strophe.NS.DISCO_INFO } ), 
    1411                                 _add_room, 
    1412                                 function( a ) 
    1413                                 { 
    1414                                         _roomsCount++; 
     1228                    configEvents( divPOP ,'onclick', _close ); 
     1229 
     1230                    var _content = tmp.documentElement.getElementsByTagName( 'body' ).item(0).appendChild( getElement(_id + '__chatBox' ).parentNode ); 
     1231 
     1232                    _content.firstChild.scrollTop = _content.firstChild.scrollHeight; 
     1233 
     1234                    configEvents( windowPopUp[_win_name] ,'onbeforeunload', function() 
     1235                    { 
     1236                        delete windowPopUp[_win_name]; 
     1237                        divPOP.style.background = "url('"+path_jabberit+"templates/default/images/icon_up.png') no-repeat"; 
     1238                        divPOP.innerHTML = "PopUp"; 
     1239                        divPOP.onclick  = function(){ 
     1240                            loadscript.windowPOPUP( _id , true ); 
     1241                        }; 
     1242                        _winBuild( 'window_chat_area_' + _id, "display" ).content( true ); 
     1243                    }); 
     1244 
     1245                    _winBuild( 'window_chat_area_' + _id, 'hidden' ); 
     1246                } 
     1247            } 
     1248        } 
     1249         
     1250        function windowNotificationNewUsers() 
     1251        { 
     1252            var _users = Xtools.xml('notification_new_users'); 
     1253                 
     1254            for( var user in TrophyIM.rosterObj.roster ) 
     1255            { 
     1256                if ( TrophyIM.rosterObj.roster[ user ].constructor == Function ) 
     1257                    continue; 
     1258 
     1259                if( TrophyIM.rosterObj.roster[ user ].contact.jid != Base64.decode( loadscript.getUserCurrent().jid) ) 
     1260                { 
     1261                    var _subscription = TrophyIM.rosterObj.roster[user].contact.subscription; 
     1262                                 
     1263                    if ( _subscription == 'to' || _subscription == 'not-in-roster' ) 
     1264                    { 
     1265                        var _user       = _users.createElement('user'); 
     1266                        var _jid        = _users.createElement('jid'); 
     1267                        var _status     = _users.createElement('status'); 
     1268                        _jid.appendChild( _users.createTextNode(TrophyIM.rosterObj.roster[user].contact.jid) ); 
     1269                        _status.appendChild( _users.createTextNode( _subscription ) ); 
     1270                        _user.appendChild( _jid ); 
     1271                        _user.appendChild( _status ); 
     1272                        _users.documentElement.appendChild( _user ); 
     1273                    } 
     1274                } 
     1275            } 
     1276                 
     1277            var paramsNotification =  
     1278            { 
     1279                'lang_1' : "Notificação",        
     1280                'lang_2' : "O(s) usuário(s) abaixo pedem sua autorização.", 
     1281                'lang_3' : "Autorizar", 
     1282                'lang_4' : "Remover" 
     1283            }; 
     1284                 
     1285            var winNotification = 
     1286            {    
     1287                id_window               : "window_notification_new_users", 
     1288                width                   : 400, 
     1289                height                  : 300, 
     1290                top                     : 100, 
     1291                left                    : 400, 
     1292                draggable               : true, 
     1293                visible         : "display", 
     1294                resizable               : true, 
     1295                zindex                  : zIndex++, 
     1296                title                   : "Expresso Messenger - Notificação de Novos Usuários", 
     1297                closeAction     : "remove", 
     1298                content         : Xtools.parse( _users , "notificationNewUsers.xsl", paramsNotification )        
     1299            }; 
     1300 
     1301            _winBuild( winNotification ); 
     1302        } 
     1303 
     1304        function createChatRooms() 
     1305        { 
     1306            _winBuild("window_List_Rooms_jabberit_messenger","remove"); 
     1307                 
     1308            var paramCreateChatRoom =  
     1309            { 
     1310                'lang_nameChatRoom'     : "Nome da Sala", 
     1311                'lang_nickName'         : "Apelido" 
     1312            }; 
     1313                 
     1314            var winCreateChatRooms = 
     1315            {    
     1316                id_window               : "window_create_chat_rooms", 
     1317                width                   : 360, 
     1318                height                  : 160, 
     1319                top                     : 100, 
     1320                left                    : 410, 
     1321                draggable               : true, 
     1322                visible         : "display", 
     1323                resizable               : true, 
     1324                zindex                  : loadscript.getZIndex(), 
     1325                title                   : "Expresso Messenger - Criar Sala de Bate Papo", 
     1326                closeAction     : "remove", 
     1327                content         : Xtools.parse( Xtools.xml("create_chat_room"), "createChatRoom.xsl", paramCreateChatRoom ) 
     1328            }; 
     1329                 
     1330            _winBuild( winCreateChatRooms ); 
     1331 
     1332            var _pButtons = 
     1333            { 
     1334                'lang1'                 : 'Ingressar', 
     1335                'lang2'                 : 'Fechar', 
     1336                'onclickClose'  : '_winBuild("window_create_chat_rooms","remove");', 
     1337                'onclickSubmit' : 'TrophyIM.createChatRooms(); _winBuild("window_create_chat_rooms","remove");' 
     1338            };  
     1339 
     1340            // Add Buttons 
     1341            document.getElementById('buttons_createChatRoom').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons); 
     1342                 
     1343        } 
     1344         
     1345        function listRooms( element ) 
     1346        { 
     1347            element = element.getElementsByTagName( 'item' ); 
     1348 
     1349            var _roomsCount     = 0; 
     1350            var _xml            = Xtools.xml('listRooms'); 
     1351            var _listRooms      = _xml.documentElement;  
     1352                 
     1353            var show = function( ) 
     1354            { 
     1355                if ( _roomsCount != element.length ) 
     1356                    return false; 
     1357                         
     1358                var paramsListRooms =  
     1359                { 
     1360                    "path_jabberit" : path_jabberit      
     1361                }; 
     1362                         
     1363                var winListRooms = 
     1364                {        
     1365                    id_window           : "window_List_Rooms_jabberit_messenger", 
     1366                    width                       : 450, 
     1367                    height                      : 300, 
     1368                    top                 : 100, 
     1369                    left                        : 400, 
     1370                    draggable           : true, 
     1371                    visible             : "display", 
     1372                    resizable           : true, 
     1373                    zindex                      : loadscript.getZIndex(), 
     1374                    title                       : "Expresso Messenger - Salas de Bate Papo", 
     1375                    closeAction : "remove", 
     1376                    content             : Xtools.parse( _xml, "listRooms.xsl", paramsListRooms ) 
     1377                }; 
     1378                         
     1379                _winBuild( winListRooms ); 
     1380                         
     1381                var _pButtons = 
     1382                { 
     1383                    'lang1'             : 'Criar Nova Sala', 
     1384                    'lang2'                     : 'Fechar', 
     1385                    'onclickClose'      : '_winBuild("window_List_Rooms_jabberit_messenger","remove");', 
     1386                    'onclickSubmit'     : 'loadscript.createChatRooms();' 
     1387                };  
     1388 
     1389                // Add Buttons 
     1390                document.getElementById('buttons_addChatRoom').innerHTML = Xtools.parse(Xtools.xml('buttons_main'), 'buttons.xsl', _pButtons); 
     1391            }; 
     1392 
     1393            var _add_room = function( _room ) 
     1394            { 
     1395                _roomsCount++; 
     1396 
     1397                var _ROOM               = _xml.createElement('room');  
     1398                var _JIDROOM    = _xml.createElement('jidRoom'); 
     1399                var nameRoom    = _room.getAttribute( 'from' ); 
     1400 
     1401                _ROOM.setAttribute( 'nameRoom', unescape((nameRoom.substring(0, nameRoom.indexOf("@"))).toUpperCase()) ); 
     1402                _JIDROOM.appendChild( _xml.createTextNode(nameRoom) ); 
     1403                _ROOM.appendChild( _JIDROOM ); 
     1404 
     1405                // Get fields elements; 
     1406                var _fields = _room.getElementsByTagName( 'field' ); 
     1407 
     1408                for ( var f = 0; f < _fields.length; f++ ) 
     1409                { 
     1410                    if ( _fields[ f ].getAttribute( 'var' ) ) 
     1411                    { 
     1412                        if ( _fields[ f ].firstChild.hasChildNodes( ) && _fields[ f ].getAttribute( 'var' ) == 'muc#roominfo_description' ) 
     1413                        { 
     1414                            var _description    = _xml.createElement("description"); 
     1415                            _description.appendChild( _xml.createTextNode( _fields[ f ].firstChild.firstChild.nodeValue ) ); 
     1416                            _ROOM.appendChild( _description ); 
     1417                        } 
     1418 
     1419                        if ( _fields[ f ].firstChild.hasChildNodes( ) && _fields[ f ].getAttribute( 'var' ) == 'muc#roominfo_occupants' ) 
     1420                        { 
     1421                            var _occupants = _xml.createElement("occupants") 
     1422                            _occupants.appendChild( _xml.createTextNode( _fields[ f ].firstChild.firstChild.nodeValue) ); 
     1423                            _ROOM.appendChild( _occupants ); 
     1424                        } 
     1425                    } 
     1426                } 
     1427 
     1428                // Get feature elements; 
     1429                var _feature = _room.getElementsByTagName( 'feature' ); 
     1430                         
     1431                for( var f = 0 ; f < _feature.length; f++ ) 
     1432                { 
     1433                    if ( _feature[ f ].getAttribute( 'var' ) ) 
     1434                    { 
     1435                        if( _feature[ f ].getAttribute( 'var' ) == 'muc_unsecured' ) 
     1436                        { 
     1437                            var _password = _xml.createElement("password"); 
     1438                            _password.appendChild( _xml.createTextNode("false") ); 
     1439                            _ROOM.appendChild( _password ); 
     1440                        } 
     1441                        else if( _feature[ f ].getAttribute( 'var' ) == 'muc_passwordprotected' ) 
     1442                        { 
     1443                            var _password = _xml.createElement("password"); 
     1444                            _password.appendChild( _xml.createTextNode("true") ); 
     1445                            _ROOM.appendChild( _password ); 
     1446                        }        
     1447                    } 
     1448                } 
     1449                         
     1450                _listRooms.appendChild( _ROOM ); 
     1451                         
     1452                show( ); 
     1453            }; 
     1454                 
     1455            var _get_room_info = function( _room ) 
     1456            { 
     1457                TrophyIM.connection.sendIQ( 
     1458                    $iq( { 
     1459                        "to" : _room,  
     1460                        "type" : "get" 
     1461                    } ).c( "query",{ 
     1462                        xmlns: Strophe.NS.DISCO_INFO 
     1463                    } ), 
     1464                    _add_room, 
     1465                    function( a ) 
     1466                    { 
     1467                        _roomsCount++; 
    14151468                                 
    1416                                         show( ); 
     1469                        show( ); 
    14171470                                         
    1418                                 }, 500 ); 
    1419                 }; 
    1420  
    1421                 if( element.length > 0 ) 
    1422                 { 
    1423                         for ( var i = 0; i < element.length; i++ ) 
    1424                         { 
    1425                                 _get_room_info( element[ i ].getAttribute( 'jid' ) ); 
    1426                         } 
    1427                 } 
    1428                 else 
    1429                 { 
    1430                         show(); 
    1431                 } 
    1432         } 
    1433          
    1434         function getListRooms() 
    1435         { 
    1436                 TrophyIM.getListRooms();         
    1437         } 
    1438          
    1439         function joinRoom( jidRoom, nameRoom ) 
    1440         { 
    1441                 var append_nick = function( room, nick ) 
    1442             { 
    1443                 var room_nick = room; 
     1471                    }, 500 ); 
     1472            }; 
     1473 
     1474            if( element.length > 0 ) 
     1475            { 
     1476                for ( var i = 0; i < element.length; i++ ) 
     1477                { 
     1478                    _get_room_info( element[ i ].getAttribute( 'jid' ) ); 
     1479                } 
     1480            } 
     1481            else 
     1482            { 
     1483                show(); 
     1484            } 
     1485        } 
     1486         
     1487        function getListRooms() 
     1488        { 
     1489            TrophyIM.getListRooms();     
     1490        } 
     1491         
     1492        function joinRoom( jidRoom, nameRoom ) 
     1493        { 
     1494            var append_nick = function( room, nick ) 
     1495            { 
     1496                var room_nick = room; 
    14441497                 
    1445                 if ( nick )  
    1446                 { 
    1447                     room_nick += "/" + nick;  
    1448                 } 
     1498                if ( nick )  
     1499                { 
     1500                    room_nick += "/" + nick;  
     1501                } 
    14491502                 
    1450                 return room_nick; 
    1451             } 
    1452                  
    1453             if( document.getElementById( 'window_chat_room_' + jidRoom + '__main' ) != null ) 
    1454             { 
    1455                 _winBuild('window_chat_room_' + jidRoom, 'display'); 
    1456             } 
    1457             else 
    1458             { 
    1459                     var nickName = Base64.decode( loadscript.getUserCurrent().jid ); 
    1460                         nickName = nickName.substring(0, nickName.indexOf('@')); 
     1503                return room_nick; 
     1504            } 
     1505                 
     1506            if( document.getElementById( 'window_chat_room_' + jidRoom + '__main' ) != null ) 
     1507            { 
     1508                _winBuild('window_chat_room_' + jidRoom, 'display'); 
     1509            } 
     1510            else 
     1511            { 
     1512                var nickName = Base64.decode( loadscript.getUserCurrent().jid ); 
     1513                nickName = nickName.substring(0, nickName.indexOf('@')); 
    14611514                     
    1462                     var _prompt = prompt("Deseja informar um Apelido ?", nickName ); 
     1515                var _prompt = prompt("Deseja informar um Apelido ?", nickName ); 
    14631516                     
    1464                     if( _prompt ) 
    1465                     {    
    1466                                 _prompt = _prompt.replace(/^\s+|\s+$|^\n|\n$/g,""); 
     1517                if( _prompt ) 
     1518                {        
     1519                    _prompt = _prompt.replace(/^\s+|\s+$|^\n|\n$/g,""); 
    14671520                             
    1468                             var room_nick       = append_nick( jidRoom, nickName ); 
     1521                    var room_nick       = append_nick( jidRoom, nickName ); 
    14691522                             
    1470                             var nickChat        = nickName.toString(); 
     1523                    var nickChat        = nickName.toString(); 
    14711524                                 
    1472                             if( _prompt && _prompt != "" ) 
    1473                             { 
    1474                                 nickChat                = _prompt.toString(); 
    1475                                 var room_nick   = append_nick( jidRoom, _prompt ); 
    1476                             } 
     1525                    if( _prompt && _prompt != "" ) 
     1526                    { 
     1527                        nickChat                = _prompt.toString(); 
     1528                        var room_nick   = append_nick( jidRoom, _prompt ); 
     1529                    } 
    14771530                             
    1478                             TrophyIM.makeChatRoom( jidRoom , nameRoom ); 
    1479  
    1480                             TrophyIM.activeChatRoom.name[ TrophyIM.activeChatRoom.name.length ] = room_nick;  
     1531                    TrophyIM.makeChatRoom( jidRoom , nameRoom ); 
     1532 
     1533                    TrophyIM.activeChatRoom.name[ TrophyIM.activeChatRoom.name.length ] = room_nick;  
    14811534                             
    1482                             TrophyIM.joinChatRoom( room_nick); 
     1535                    TrophyIM.joinChatRoom( room_nick); 
    14831536                          
    1484                             setTimeout(function() 
    1485                             { 
    1486                                 var _message    =  nickName.toUpperCase() + " entrou como : "  + nickChat; 
     1537                    setTimeout(function() 
     1538                    { 
     1539                        var _message    =  nickName.toUpperCase() + " entrou como : "  + nickChat; 
    14871540                                    
    1488                                     TrophyIM.sendMessageChatRoom( jidRoom , _message ); 
     1541                        TrophyIM.sendMessageChatRoom( jidRoom , _message ); 
    14891542                                     
    1490                             }, 500); 
     1543                    }, 500); 
    14911544                             
    1492                     } 
    1493             } 
     1545                } 
     1546            } 
    14941547             
    1495             _winBuild("window_List_Rooms_jabberit_messenger","remove"); 
    1496         } 
    1497          
    1498         function loadIM() 
    1499         { 
    1500                 if( arguments.length > 0 ) 
    1501                 { 
    1502                         var files = [ 
    1503                                                 path_jabberit + 'templates/default/css/button.css', 
    1504                                                 path_jabberit + 'templates/default/css/common.css', 
    1505                                                 path_jabberit + 'templates/default/css/selectEditableStyle.css', 
    1506                                                 path_jabberit + 'templates/default/css/' + theme_jabberit 
    1507                                     ]; 
    1508                         // FullName 
    1509                         fullName = arguments[0]; 
    1510                          
    1511                         // Preferences 
    1512                         _preferencesIM = arguments[1].split(";"); 
     1548            _winBuild("window_List_Rooms_jabberit_messenger","remove"); 
     1549        } 
     1550         
     1551        function loadIM() 
     1552        { 
     1553            if( arguments.length > 0 ) 
     1554            { 
     1555                var files = [ 
     1556                path_jabberit + 'templates/default/css/button.css', 
     1557                path_jabberit + 'templates/default/css/common.css', 
     1558                path_jabberit + 'templates/default/css/selectEditableStyle.css', 
     1559                path_jabberit + 'templates/default/css/' + theme_jabberit 
     1560                ]; 
     1561                // FullName 
     1562                fullName = arguments[0]; 
     1563                         
     1564                // Preferences 
     1565                _preferencesIM = arguments[1].split(";"); 
    15131566                         
    1514                         //Path Phpgwapi 
    1515                         path_phpgwapi = arguments[2]; 
     1567                //Path Phpgwapi 
     1568                path_phpgwapi = arguments[2]; 
    15161569                         
    1517                         if( !_preferencesIM[3] ) _preferencesIM[3] = "showContactsOfflineJabberit:true"; 
    1518                          
    1519                         loadScripts(files); 
    1520                          
    1521                         setTimeout(function() 
    1522                         { 
    1523                                 // Object Xtools         
    1524                                 if( Xtools == null ) 
    1525                                         Xtools = new xtools(path_jabberit); 
    1526                                  
    1527                                 // Object Conector 
    1528                                 if( conn == null ) 
    1529                                         conn = new AjaxConnector(path_jabberit); 
    1530                                  
    1531                                 // Object Add User 
    1532                                 if( addUser == null ) 
    1533                                         addUser = new addUserIM(Xtools, conn); 
    1534  
    1535                                  
    1536                                 // Object SelectEditable 
    1537                                 if( selectEditable == null ) 
    1538                                         selectEditable = new SelectEditable(); 
     1570                if( !_preferencesIM[3] ) _preferencesIM[3] = "showContactsOfflineJabberit:true"; 
     1571                         
     1572                loadScripts(files); 
     1573                         
     1574                setTimeout(function() 
     1575                { 
     1576                    // Object Xtools     
     1577                    if( Xtools == null ) 
     1578                        Xtools = new xtools(path_jabberit); 
     1579                                 
     1580                    // Object Conector 
     1581                    if( conn == null ) 
     1582                        conn = new AjaxConnector(path_jabberit); 
     1583                                 
     1584                    // Object Add User 
     1585                    if( addUser == null ) 
     1586                        addUser = new addUserIM(Xtools, conn); 
     1587 
     1588                                 
     1589                    // Object SelectEditable 
     1590                    if( selectEditable == null ) 
     1591                        selectEditable = new SelectEditable(); 
    15391592                                         
    1540                                 // Add Jabber in StatusBar; 
    1541                                 addIcon(); 
    1542                                  
    1543                                 // Auto Connect 
    1544                                 setTimeout(function() 
    1545                                 { 
    1546                                         if( _preferencesIM[0] === 'openWindowJabberit:true' ) 
    1547                                         { 
    1548                                                 if( SnifferBrowser.isCompatible('ie8','firefox3','firefox4','epiphany2','iceweasel3') ) 
    1549                                                         TrophyIM.load(); 
    1550                                         } 
     1593                    // Add Jabber in StatusBar; 
     1594                    addIcon(); 
     1595                                 
     1596                    // Auto Connect 
     1597                    setTimeout(function() 
     1598                    { 
     1599                        if( _preferencesIM[0] === 'openWindowJabberit:true' ) 
     1600                        { 
     1601                            if( SnifferBrowser.isCompatible('chrome11','ie8','firefox3','firefox4','epiphany2','iceweasel3','safari') ) 
     1602                                TrophyIM.load(); 
     1603                        } 
    15511604                                         
    1552                                 },1500); 
    1553                                  
    1554                                 // Auto Status 
    1555                                 autoStatus(); 
    1556                                 configEvents( document, 'onmousemove', autoStatus ); 
    1557                                 configEvents( document, 'onkeypress', autoStatus ); 
    1558                                  
    1559                         }, 2000); 
    1560                 } 
    1561         } 
    1562  
    1563         loadIM.prototype.adIcon                 = addIcon; 
    1564         loadIM.prototype.actionButton           = actionButton; 
    1565         loadIM.prototype.addContact             = addContact; 
    1566         loadIM.prototype.addNewUser             = addNewUser; 
    1567         loadIM.prototype.clrAllContacts         = clrAllContacts; 
    1568         loadIM.prototype.configEvents           = configEvents; 
    1569         loadIM.prototype.createChatRooms        = createChatRooms; 
    1570         loadIM.prototype.disabledNotificationNewUsers   = disabledNotificationNewUsers; 
    1571         loadIM.prototype.enabledNotificationNewUsers    = enabledNotificationNewUsers;   
    1572         loadIM.prototype.getListRooms           = getListRooms;  
    1573         loadIM.prototype.getIsIE                = getIsIE; 
    1574         loadIM.prototype.getPhotoUser           = getPhotoUser; 
    1575         loadIM.prototype.getSmiles              = getSmiles; 
    1576         loadIM.prototype.getStatusUserIM        = getStatusUserIM; 
    1577         loadIM.prototype.getStatusMessage       = getStatusMessage; 
    1578         loadIM.prototype.getShowContactsOffline = getShowContactsOffline; 
    1579         loadIM.prototype.getUserCurrent         = getUserCurrent; 
    1580         loadIM.prototype.getZIndex              = getZindex; 
    1581         loadIM.prototype.groupsHidden           = groupsHidden; 
    1582         loadIM.prototype.groupsVisible          = groupsVisible; 
    1583         loadIM.prototype.joinRoom               = joinRoom;      
    1584         loadIM.prototype.keyPressSearch         = keyPressSearch;        
    1585         loadIM.prototype.listRooms              = listRooms; 
    1586         loadIM.prototype.loginPage              = loginPage; 
    1587         loadIM.prototype.notification           = notificationNewMessage; 
    1588         loadIM.prototype.parse                  = parse; 
    1589         loadIM.prototype.preferences            = preferences; 
    1590         loadIM.prototype.searchUser             = searchUser 
    1591         loadIM.prototype.setAutorization        = setAutorization; 
    1592         loadIM.prototype.setMessageStatus       = setMessageStatus; 
    1593         loadIM.prototype.setPreferences         = setPreferences; 
    1594         loadIM.prototype.setPresence            = setPresence; 
    1595         loadIM.prototype.setStatusJabber        = setStatusJabber; 
    1596         loadIM.prototype.setSelectEditable      = setSelectEditable; 
    1597         loadIM.prototype.setUserCurrent         = setUserCurrent; 
    1598         loadIM.prototype.removeContact          = removeContact; 
    1599         loadIM.prototype.removeElement          = removeElement; 
    1600         loadIM.prototype.removeGroup            = removeGroup; 
    1601         loadIM.prototype.renameContact          = renameContact; 
    1602         loadIM.prototype.renameGroup            = renameGroup; 
    1603         loadIM.prototype.rosterDiv              = rosterDiv; 
    1604         loadIM.prototype.windowNotificationNewUsers  = windowNotificationNewUsers; 
    1605         loadIM.prototype.windowPOPUP            = windowPOPUP; 
    1606          
    1607         window.LoadIM = loadIM; 
    1608          
    1609         // Necessário para não ocasionar problema no ExpressoMail 
    1610         // quando os itens abaixo não são criados pelo próprio ExpressoMail 
    1611         if( SnifferBrowser.isCompatible('is_ie') ) 
    1612         { 
    1613                 configEvents( window, 'onload', function( ) 
    1614                 { 
    1615                         if ( ! document.getElementById( 'cc_msg_err_serialize_data_unknown' ) ) 
    1616                         { 
    1617                                 var fix = document.createElement('input'); 
    1618                                         fix.type        = 'hidden'; 
    1619                                         fix.id          = 'cc_msg_err_serialize_data_unknown'; 
    1620                                  
    1621                                         document.appendChild( fix ); 
    1622                         } 
    1623                         if ( ! window.showMessage ) 
    1624                                 window.showMessage = function(){}; 
    1625                 }); 
    1626         } 
    1627          
    1628 })(); 
     1605                    },1500); 
     1606                                 
     1607                    // Auto Status 
     1608                    autoStatus(); 
     1609                    configEvents( document, 'onmousemove', autoStatus ); 
     1610                    configEvents( document, 'onkeypress', autoStatus ); 
     1611                                 
     1612                }, 2000); 
     1613            } 
     1614        } 
     1615 
     1616        loadIM.prototype.adIcon                 = addIcon; 
     1617        loadIM.prototype.actionButton           = actionButton; 
     1618        loadIM.prototype.addContact             = addContact; 
     1619        loadIM.prototype.addNewUser             = addNewUser; 
     1620        loadIM.prototype.clrAllContacts         = clrAllContacts; 
     1621        loadIM.prototype.configEvents           = configEvents; 
     1622        loadIM.prototype.createChatRooms        = createChatRooms; 
     1623        loadIM.prototype.disabledNotificationNewUsers   = disabledNotificationNewUsers; 
     1624        loadIM.prototype.enabledNotificationNewUsers    = enabledNotificationNewUsers;   
     1625        loadIM.prototype.getListRooms           = getListRooms;  
     1626        loadIM.prototype.getBrowserCompatible   = getBrowserCompatible; 
     1627        loadIM.prototype.getPhotoUser           = getPhotoUser; 
     1628        loadIM.prototype.getSmiles              = getSmiles; 
     1629        loadIM.prototype.getStatusUserIM        = getStatusUserIM; 
     1630        loadIM.prototype.getStatusMessage       = getStatusMessage; 
     1631        loadIM.prototype.getShowContactsOffline = getShowContactsOffline; 
     1632        loadIM.prototype.getUserCurrent         = getUserCurrent; 
     1633        loadIM.prototype.getZIndex              = getZindex; 
     1634        loadIM.prototype.groupsHidden           = groupsHidden; 
     1635        loadIM.prototype.groupsVisible          = groupsVisible; 
     1636        loadIM.prototype.joinRoom               = joinRoom;      
     1637        loadIM.prototype.keyPressSearch         = keyPressSearch;        
     1638        loadIM.prototype.listRooms              = listRooms; 
     1639        loadIM.prototype.loginPage              = loginPage; 
     1640        loadIM.prototype.notification           = notificationNewMessage; 
     1641        loadIM.prototype.parse                  = parse; 
     1642        loadIM.prototype.preferences            = preferences; 
     1643        loadIM.prototype.searchUser             = searchUser 
     1644        loadIM.prototype.setAutorization        = setAutorization; 
     1645        loadIM.prototype.setMessageStatus       = setMessageStatus; 
     1646        loadIM.prototype.setPreferences         = setPreferences; 
     1647        loadIM.prototype.setPresence            = setPresence; 
     1648        loadIM.prototype.setStatusJabber        = setStatusJabber; 
     1649        loadIM.prototype.setSelectEditable      = setSelectEditable; 
     1650        loadIM.prototype.setUserCurrent         = setUserCurrent; 
     1651        loadIM.prototype.removeContact          = removeContact; 
     1652        loadIM.prototype.removeElement          = removeElement; 
     1653        loadIM.prototype.removeGroup            = removeGroup; 
     1654        loadIM.prototype.renameContact          = renameContact; 
     1655        loadIM.prototype.renameGroup            = renameGroup; 
     1656        loadIM.prototype.rosterDiv              = rosterDiv; 
     1657        loadIM.prototype.windowNotificationNewUsers  = windowNotificationNewUsers; 
     1658        loadIM.prototype.windowPOPUP            = windowPOPUP; 
     1659         
     1660        window.LoadIM = loadIM; 
     1661         
     1662        // Necessário para não ocasionar problema no ExpressoMail 
     1663        // quando os itens abaixo não são criados pelo próprio ExpressoMail 
     1664        if( SnifferBrowser.isCompatible('is_ie') ) 
     1665        { 
     1666            configEvents( window, 'onload', function( ) 
     1667            { 
     1668                if ( ! document.getElementById( 'cc_msg_err_serialize_data_unknown' ) ) 
     1669                { 
     1670                    var fix     = document.createElement('input'); 
     1671                    fix.type    = 'hidden'; 
     1672                    fix.id              = 'cc_msg_err_serialize_data_unknown'; 
     1673                                 
     1674                    document.appendChild( fix ); 
     1675                } 
     1676                if ( ! window.showMessage ) 
     1677                    window.showMessage = function(){}; 
     1678            }); 
     1679        } 
     1680         
     1681    })(); 
  • branches/2.2.0.1/jabberit_messenger/jmessenger/js/jscode/loadIM.mini.js

    r4453 r4496  
    8383function getElement(elementId) 
    8484{return document.getElementById(elementId);} 
    85 function getIsIE() 
    86 {return SnifferBrowser.isCompatible('is_ie');} 
     85function getBrowserCompatible() 
     86{return SnifferBrowser.isCompatible('firefox3','firefox4');} 
    8787function getPhotoUser(jid) 
    8888{try 
     
    180180{var winRosterDiv={id_window:"window_Roster_im",width:250,height:410,top:50,left:-1500,leftOld:50,draggable:true,visible:"display",resizable:true,zindex:zIndex++,title:"Expresso Messenger - Contatos",closeAction:"hidden",content:""};if(_preferencesIM[0]=="openWindowJabberit:false") 
    181181{winRosterDiv.left=50;winRosterDiv.leftOld=-1500;} 
    182 if(SnifferBrowser.isCompatible('ie8','firefox3','firefox4','epiphany2','iceweasel3')) 
     182if(SnifferBrowser.isCompatible('chrome11','ie8','firefox3','firefox4','epiphany2','iceweasel3','safari')) 
    183183{var _idUser=Base64.decode(getUserCurrent().jid);var paramListContact={'idUser':_idUser,'full_name':((fullName.length<25)?fullName:(fullName.substring(0,25)+"...")),'path_jabberit':path_jabberit,'help_expresso':help_expresso,'zIndex_':zIndex++};winRosterDiv.content=Xtools.parse(Xtools.xml("contacts_list"),"contactsList.xsl",paramListContact)} 
    184184else 
     
    322322selectEditable=new SelectEditable();addIcon();setTimeout(function() 
    323323{if(_preferencesIM[0]==='openWindowJabberit:true') 
    324 {if(SnifferBrowser.isCompatible('ie8','firefox3','firefox4','epiphany2','iceweasel3')) 
     324{if(SnifferBrowser.isCompatible('chrome11','ie8','firefox3','firefox4','epiphany2','iceweasel3','safari')) 
    325325TrophyIM.load();}},1500);autoStatus();configEvents(document,'onmousemove',autoStatus);configEvents(document,'onkeypress',autoStatus);},2000);}} 
    326 loadIM.prototype.adIcon=addIcon;loadIM.prototype.actionButton=actionButton;loadIM.prototype.addContact=addContact;loadIM.prototype.addNewUser=addNewUser;loadIM.prototype.clrAllContacts=clrAllContacts;loadIM.prototype.configEvents=configEvents;loadIM.prototype.createChatRooms=createChatRooms;loadIM.prototype.disabledNotificationNewUsers=disabledNotificationNewUsers;loadIM.prototype.enabledNotificationNewUsers=enabledNotificationNewUsers;loadIM.prototype.getListRooms=getListRooms;loadIM.prototype.getIsIE=getIsIE;loadIM.prototype.getPhotoUser=getPhotoUser;loadIM.prototype.getSmiles=getSmiles;loadIM.prototype.getStatusUserIM=getStatusUserIM;loadIM.prototype.getStatusMessage=getStatusMessage;loadIM.prototype.getShowContactsOffline=getShowContactsOffline;loadIM.prototype.getUserCurrent=getUserCurrent;loadIM.prototype.getZIndex=getZindex;loadIM.prototype.groupsHidden=groupsHidden;loadIM.prototype.groupsVisible=groupsVisible;loadIM.prototype.joinRoom=joinRoom;loadIM.prototype.keyPressSearch=keyPressSearch;loadIM.prototype.listRooms=listRooms;loadIM.prototype.loginPage=loginPage;loadIM.prototype.notification=notificationNewMessage;loadIM.prototype.parse=parse;loadIM.prototype.preferences=preferences;loadIM.prototype.searchUser=searchUser 
     326loadIM.prototype.adIcon=addIcon;loadIM.prototype.actionButton=actionButton;loadIM.prototype.addContact=addContact;loadIM.prototype.addNewUser=addNewUser;loadIM.prototype.clrAllContacts=clrAllContacts;loadIM.prototype.configEvents=configEvents;loadIM.prototype.createChatRooms=createChatRooms;loadIM.prototype.disabledNotificationNewUsers=disabledNotificationNewUsers;loadIM.prototype.enabledNotificationNewUsers=enabledNotificationNewUsers;loadIM.prototype.getListRooms=getListRooms;loadIM.prototype.getBrowserCompatible=getBrowserCompatible;loadIM.prototype.getPhotoUser=getPhotoUser;loadIM.prototype.getSmiles=getSmiles;loadIM.prototype.getStatusUserIM=getStatusUserIM;loadIM.prototype.getStatusMessage=getStatusMessage;loadIM.prototype.getShowContactsOffline=getShowContactsOffline;loadIM.prototype.getUserCurrent=getUserCurrent;loadIM.prototype.getZIndex=getZindex;loadIM.prototype.groupsHidden=groupsHidden;loadIM.prototype.groupsVisible=groupsVisible;loadIM.prototype.joinRoom=joinRoom;loadIM.prototype.keyPressSearch=keyPressSearch;loadIM.prototype.listRooms=listRooms;loadIM.prototype.loginPage=loginPage;loadIM.prototype.notification=notificationNewMessage;loadIM.prototype.parse=parse;loadIM.prototype.preferences=preferences;loadIM.prototype.searchUser=searchUser 
    327327loadIM.prototype.setAutorization=setAutorization;loadIM.prototype.setMessageStatus=setMessageStatus;loadIM.prototype.setPreferences=setPreferences;loadIM.prototype.setPresence=setPresence;loadIM.prototype.setStatusJabber=setStatusJabber;loadIM.prototype.setSelectEditable=setSelectEditable;loadIM.prototype.setUserCurrent=setUserCurrent;loadIM.prototype.removeContact=removeContact;loadIM.prototype.removeElement=removeElement;loadIM.prototype.removeGroup=removeGroup;loadIM.prototype.renameContact=renameContact;loadIM.prototype.renameGroup=renameGroup;loadIM.prototype.rosterDiv=rosterDiv;loadIM.prototype.windowNotificationNewUsers=windowNotificationNewUsers;loadIM.prototype.windowPOPUP=windowPOPUP;window.LoadIM=loadIM;if(SnifferBrowser.isCompatible('is_ie')) 
    328328{configEvents(window,'onload',function() 
  • branches/2.2.0.1/jabberit_messenger/jmessenger/js/trophyim.js

    r4453 r4496  
    1717                    this.processor = new XSLTProcessor(); 
    1818                    this.processor.importStylesheet(this.xmlRender( 
    19                     '<xsl:stylesheet version="1.0"\ 
     19                        '<xsl:stylesheet version="1.0"\ 
    2020                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\ 
    2121                    <xsl:output method="html" indent="yes"/><xsl:template\ 
     
    6868                } 
    6969                var renderObj = this.parser.parseFromString(xmlString, 
    70                 "application/xml"); 
     70                    "application/xml"); 
    7171            } catch(e) { 
    7272                alert("TrophyIM Error: Cannot create new html for page"); 
     
    8484     */ 
    8585    getHTML : function(page) 
    86         { 
     86    { 
    8787        return this.xmlParse(HTMLSnippets[page]); 
    8888    }, 
     
    9696     */ 
    9797    getScript : function(script) 
    98         { 
     98    { 
    9999        var newscript = document.createElement('script'); 
    100100        newscript.setAttribute('src', script); 
     
    112112                 
    113113 
    114         controll : {notificationNewUsers : 0},   
    115      
    116         /** AutoConnection 
     114    controll : { 
     115        notificationNewUsers : 0 
     116    },   
     117     
     118    /** AutoConnection 
    117119        *  
    118120        */       
    119121                 
    120         autoConnection : {connect : true}, 
    121  
    122         /** Active Chat Room 
     122    autoConnection : { 
     123        connect : true 
     124    }, 
     125 
     126    /** Active Chat Room 
    123127         *  
    124128         */ 
    125129         
    126         activeChatRoom : {name : []}, 
    127          
    128         /** Object: chatHistory 
     130    activeChatRoom : { 
     131        name : [] 
     132    }, 
     133         
     134    /** Object: chatHistory 
    129135    * 
    130136    *  Stores chat history (last 10 message) and current presence of active 
     
    132138    */ 
    133139         
    134         chatHistory : {}, 
    135          
    136         /** Constants: 
     140    chatHistory : {}, 
     141         
     142    /** Constants: 
    137143    * 
    138144    *    (Boolean) stale_roster - roster is stale and needs to be rewritten. 
    139145    */ 
    140146         
    141         constants : {stale_roster: false}, 
    142          
    143         /** PosWindow 
     147    constants : { 
     148        stale_roster: false 
     149    }, 
     150         
     151    /** PosWindow 
    144152         *  
    145153         */      
    146         posWindow : {left : 400, top : 100},     
    147                  
    148         /** StatusConnection 
     154    posWindow : { 
     155        left : 400,  
     156        top : 100 
     157    },   
     158                 
     159    /** StatusConnection 
    149160         *  
    150161         */ 
    151162 
    152         statusConn : {connected : false}, 
    153          
    154         /** TimeOut Render Roster 
     163    statusConn : { 
     164        connected : false 
     165    }, 
     166         
     167    /** TimeOut Render Roster 
    155168         *  
    156169         *  
    157170         */ 
    158171         
    159         _timeOut : {renderRoster : null}, 
    160          
    161          
    162         /** Remove Contact ( type = set ) 
     172    _timeOut : { 
     173        renderRoster : null 
     174    }, 
     175         
     176         
     177    /** Remove Contact ( type = set ) 
    163178         *  
    164179         *  
    165180         */ 
    166181         
    167         removeResult : {idResult : []}, 
    168          
    169      /** Function: setCookie 
     182    removeResult : { 
     183        idResult : [] 
     184    }, 
     185         
     186    /** Function: setCookie 
    170187     * 
    171188     *  Sets cookie name/value pair.  Date and path are auto-selected. 
     
    176193     */ 
    177194     
    178         setCookie : function(name, value) 
    179         { 
     195    setCookie : function(name, value) 
     196    { 
    180197        var expire = new Date(); 
    181198        expire.setDate(expire.getDate() + 365); 
     
    183200    }, 
    184201     
    185         /** Function: delCookie 
     202    /** Function: delCookie 
    186203     * 
    187204     *  Deletes cookie 
     
    191208     */ 
    192209     
    193         delCookie : function(name) 
    194         { 
     210    delCookie : function(name) 
     211    { 
    195212        var expire = new Date(); 
    196213        expire.setDate(expire.getDate() - 365); 
     
    199216    }, 
    200217     
    201         /** Function: getCookies 
     218    /** Function: getCookies 
    202219     * 
    203220     *  Retrieves all trophyim cookies into an indexed object.  Inteneded to be 
     
    208225     */ 
    209226     
    210         getCookies : function() 
    211         { 
     227    getCookies : function() 
     228    { 
    212229        var cObj = {}; 
    213230        var cookies = document.cookie.split(';'); 
     
    215232        for(var i = 0 ; i < cookies.length; i++ ) 
    216233        { 
    217                 while ( cookies[i].charAt(0) == ' ') 
     234            while ( cookies[i].charAt(0) == ' ') 
    218235            {  
    219236                cookies[i] = cookies[i].substring(1,cookies[i].length); 
     
    237254     */ 
    238255 
    239         load : function() 
    240         { 
    241         if( loadscript.getUserCurrent() == null ) 
    242         { 
    243                 loadscript.setUserCurrent();      
     256    load : function() 
     257    { 
     258        if( loadscript.getUserCurrent() == null ) 
     259        { 
     260            loadscript.setUserCurrent();          
    244261        }         
    245262 
    246         if ( !TrophyIM.statusConn.connected ) 
    247                 { 
    248                         TrophyIM.cookies = TrophyIM.getCookies(); 
    249  
    250                         //Wait a second to give scripts time to load 
    251                         setTimeout( "TrophyIM.showLogin()", 550 ); 
    252                 } 
    253                 else 
    254                 { 
    255                         loadscript.rosterDiv(); 
    256                 } 
    257    }, 
    258  
    259    /** Function: storeData 
     263        if ( !TrophyIM.statusConn.connected ) 
     264        { 
     265            TrophyIM.cookies = TrophyIM.getCookies(); 
     266 
     267            //Wait a second to give scripts time to load 
     268            setTimeout( "TrophyIM.showLogin()", 550 ); 
     269        } 
     270        else 
     271        { 
     272            loadscript.rosterDiv(); 
     273        } 
     274    }, 
     275 
     276    /** Function: storeData 
    260277     * 
    261278     *  Store all our data in the JSONStore, if it is active 
    262279     */ 
    263280      
    264    storeData : function() 
    265    { 
     281    storeData : function() 
     282    { 
    266283        if ( TrophyIM.connection && TrophyIM.connection.connected ) 
    267                 { 
     284        { 
    268285            TrophyIM.setCookie('trophyim_bosh_xid', TrophyIM.connection.jid + "|" + 
    269             TrophyIM.connection.sid + "|" +  TrophyIM.connection.rid); 
     286                TrophyIM.connection.sid + "|" +  TrophyIM.connection.rid); 
    270287            TrophyIM.rosterObj.save(); 
    271288        } 
     
    280297      
    281298    showLogin : function() 
    282         { 
     299    { 
    283300        /** 
    284301         *  
     
    288305                 */ 
    289306 
    290                 if ( typeof(JSON) != undefined && typeof(Strophe) != undefined ) 
    291         { 
    292                 TrophyIM.JSONStore = new TrophyIMJSONStore(); 
     307        if ( typeof(JSON) != undefined && typeof(Strophe) != undefined ) 
     308        { 
     309            TrophyIM.JSONStore = new TrophyIMJSONStore(); 
    293310                 
    294                         if ( TrophyIM.JSONStore.store_working && TrophyIM.cookies['trophyim_bosh_xid'] ) 
    295             { 
    296                 var xids = TrophyIM.cookies['trophyim_bosh_xid'].split("|"); 
     311            if ( TrophyIM.JSONStore.store_working && TrophyIM.cookies['trophyim_bosh_xid'] ) 
     312            { 
     313                var xids = TrophyIM.cookies['trophyim_bosh_xid'].split("|"); 
    297314                TrophyIM.delCookie('trophyim_bosh_xid'); 
    298315                TrophyIM.constants.stale_roster = true; 
    299316                         
    300                                 TrophyIM.connection                             = new Strophe.Connection(TROPHYIM_BOSH_SERVICE); 
     317                TrophyIM.connection                             = new Strophe.Connection(TROPHYIM_BOSH_SERVICE); 
    301318                TrophyIM.connection.rawInput    = TrophyIM.rawInput; 
    302319                TrophyIM.connection.rawOutput   = TrophyIM.rawOutput; 
     
    308325            else 
    309326            { 
    310                 // List Contact 
    311                                 loadscript.rosterDiv(); 
    312  
    313                                 // Get User Current; 
    314                                 var _getUserCurrent = null; 
    315                                         _getUserCurrent = loadscript.getUserCurrent(); 
     327                // List Contact 
     328                loadscript.rosterDiv(); 
     329 
     330                // Get User Current; 
     331                var _getUserCurrent = null; 
     332                _getUserCurrent = loadscript.getUserCurrent(); 
    316333                                 
    317                                 if( _getUserCurrent == null ) 
    318                                 {        
    319                                         setTimeout( "TrophyIM.showLogin()", 500 ); 
    320                                 } 
    321                                 else 
    322                                 { 
    323                                         TrophyIM.login( Base64.decode( _getUserCurrent.jid ), Base64.decode( _getUserCurrent.password )); 
    324                                 } 
     334                if( _getUserCurrent == null ) 
     335                {        
     336                    setTimeout( "TrophyIM.showLogin()", 500 ); 
     337                } 
     338                else 
     339                { 
     340                    TrophyIM.login( Base64.decode( _getUserCurrent.jid ), Base64.decode( _getUserCurrent.password )); 
     341                } 
    325342            } 
    326343        } 
    327344        else 
    328345        { 
    329                 setTimeout("TrophyIM.showLogin()", 500); 
    330         } 
    331     }, 
    332      
    333         /** Function: log 
     346            setTimeout("TrophyIM.showLogin()", 500); 
     347        } 
     348    }, 
     349     
     350    /** Function: log 
    334351     * 
    335352     *  This function logs the given message in the trophyimlog div 
     
    361378     */ 
    362379    rawInput : function (data) 
    363         { 
     380    { 
    364381        Strophe.debug("RECV: " + data); 
    365382    }, 
     
    370387     */ 
    371388    rawOutput : function (data) 
    372         { 
     389    { 
    373390        Strophe.debug("SEND: " + data); 
    374391    }, 
     
    382399     */ 
    383400    login : function() 
    384         { 
    385                 if ( TrophyIM.JSONStore.store_working ) 
    386                 {  
    387                    //In case they never logged out 
     401    { 
     402        if ( TrophyIM.JSONStore.store_working ) 
     403        {  
     404            //In case they never logged out 
    388405            TrophyIM.JSONStore.delData(['groups','roster', 'active_chat', 'chat_history']); 
    389406        } 
    390407 
    391                 TrophyIM.connection                             = new Strophe.Connection(TROPHYIM_BOSH_SERVICE); 
     408        TrophyIM.connection                             = new Strophe.Connection(TROPHYIM_BOSH_SERVICE); 
    392409        TrophyIM.connection.rawInput    = TrophyIM.rawInput; 
    393410        TrophyIM.connection.rawOutput   = TrophyIM.rawOutput; 
    394411        //Strophe.log                                   = TrophyIM.log; 
    395412         
    396                 if ( arguments.length > 0 ) 
    397                 { 
    398                         var barejid = arguments[0]; 
    399                         var password = arguments[1]; 
    400                          
    401                         TrophyIM.connection.connect( barejid + TROPHYIM_RESOURCE, password, TrophyIM.onConnect ); 
    402                 } 
    403                 else 
    404                 { 
    405                          
    406                         var barejid             = document.getElementById('trophyimjid').value 
    407                         var fulljid             = barejid + TROPHYIM_RESOURCE; 
    408                         var password    = document.getElementById('trophyimpass').value; 
    409                         var button              = document.getElementById('trophyimconnect'); 
    410                          
    411                         loadscript.setUserCurrent( barejid, password); 
    412                          
    413                         if ( button.value == 'connect' ) 
    414                         { 
    415                                 button.value = 'disconnect'; 
    416                                 //TrophyIM.connection.connect( fulljid , password, TrophyIM.onConnect ); 
     413        if ( arguments.length > 0 ) 
     414        { 
     415            var barejid = arguments[0]; 
     416            var password = arguments[1]; 
     417                         
     418            TrophyIM.connection.connect( barejid + TROPHYIM_RESOURCE, password, TrophyIM.onConnect ); 
     419        } 
     420        else 
     421        { 
     422                         
     423            var barejid         = document.getElementById('trophyimjid').value 
     424            var fulljid         = barejid + TROPHYIM_RESOURCE; 
     425            var password        = document.getElementById('trophyimpass').value; 
     426            var button          = document.getElementById('trophyimconnect'); 
     427                         
     428            loadscript.setUserCurrent( barejid, password); 
     429                         
     430            if ( button.value == 'connect' ) 
     431            { 
     432                button.value = 'disconnect'; 
     433                //TrophyIM.connection.connect( fulljid , password, TrophyIM.onConnect ); 
    417434                                 
    418                                 TrophyIM.login( barejid, password ); 
    419                                 _winBuild('window_login_page', 'remove'); 
    420                         } 
    421                 } 
    422  
    423                 TrophyIM.setCookie('trophyimjid', barejid); 
     435                TrophyIM.login( barejid, password ); 
     436                _winBuild('window_login_page', 'remove'); 
     437            } 
     438        } 
     439 
     440        TrophyIM.setCookie('trophyimjid', barejid); 
    424441    }, 
    425442         
     
    429446     */ 
    430447    logout : function() 
    431         { 
    432         TrophyIM.autoConnection.connect = false; 
     448    { 
     449        TrophyIM.autoConnection.connect = false; 
    433450         
    434         TrophyIM.delCookie('trophyim_bosh_xid'); 
     451        TrophyIM.delCookie('trophyim_bosh_xid'); 
    435452         
    436453        delete TrophyIM['cookies']['trophyim_bosh_xid']; 
     
    444461     */ 
    445462    onConnect : function(status) 
    446         { 
    447         var loading_gif = document.getElementById("JabberIMRosterLoadingGif"); 
    448                  
    449         if( status == Strophe.Status.CONNECTING ) 
    450                 { 
    451                 loading_gif.style.display = "block"; 
    452                 Strophe.info('Strophe is connecting.'); 
    453         } 
    454                  
    455                 if( status == Strophe.Status.CONNFAIL ) 
    456                 { 
    457                         TrophyIM.delCookie('trophyim_bosh_xid'); 
     463    { 
     464        var loading_gif = document.getElementById("JabberIMRosterLoadingGif"); 
     465                 
     466        if( status == Strophe.Status.CONNECTING ) 
     467        { 
     468            loading_gif.style.display = "block"; 
     469            Strophe.info('Strophe is connecting.'); 
     470        } 
     471                 
     472        if( status == Strophe.Status.CONNFAIL ) 
     473        { 
     474            TrophyIM.delCookie('trophyim_bosh_xid'); 
    458475            TrophyIM.statusConn.connected = false; 
    459476            loading_gif.style.display = "block"; 
    460477        } 
    461478                 
    462                 if( status == Strophe.Status.DISCONNECTING ) 
    463                 { 
    464                         TrophyIM.statusConn.connected = false; 
    465         } 
    466                  
    467                 if( status == Strophe.Status.DISCONNECTED ) 
    468                 { 
    469                         if( TrophyIM.autoConnection.connect ) 
    470                         { 
    471                                 loading_gif.style.display = "block"; 
     479        if( status == Strophe.Status.DISCONNECTING ) 
     480        { 
     481            TrophyIM.statusConn.connected = false; 
     482        } 
     483                 
     484        if( status == Strophe.Status.DISCONNECTED ) 
     485        { 
     486            if( TrophyIM.autoConnection.connect ) 
     487            { 
     488                loading_gif.style.display = "block"; 
    472489                                 
    473                                 TrophyIM.delCookie('trophyim_bosh_xid'); 
     490                TrophyIM.delCookie('trophyim_bosh_xid'); 
    474491                     
    475                     TrophyIM.statusConn.connected = false; 
     492                TrophyIM.statusConn.connected = false; 
    476493                     
    477                                 setTimeout(function() 
    478                                 { 
    479                             TrophyIM.showLogin(); 
     494                setTimeout(function() 
     495                { 
     496                    TrophyIM.showLogin(); 
    480497                             
    481                                 },10000); 
     498                },10000); 
    482499                                 
    483                     loadscript.clrAllContacts();         
     500                loadscript.clrAllContacts();     
    484501                     
    485                     loadscript.setStatusJabber(i18n.STATUS_ANAVAILABLE,"unavailable"); 
     502                loadscript.setStatusJabber(i18n.STATUS_ANAVAILABLE,"unavailable"); 
    486503                     
    487                     delete TrophyIM.rosterObj.roster; 
    488                     delete TrophyIM.rosterObj.groups; 
    489                         } 
    490         } 
    491                  
    492                 if( status == Strophe.Status.CONNECTED ) 
    493                 { 
    494                         loadscript.setStatusJabber(i18n.STATUS_AVAILABLE,'available'); 
    495                         TrophyIM.statusConn.connected = true; 
     504                delete TrophyIM.rosterObj.roster; 
     505                delete TrophyIM.rosterObj.groups; 
     506            } 
     507        } 
     508                 
     509        if( status == Strophe.Status.CONNECTED ) 
     510        { 
     511            loadscript.setStatusJabber(i18n.STATUS_AVAILABLE,'available'); 
     512            TrophyIM.statusConn.connected = true; 
    496513            TrophyIM.showClient(); 
    497514        } 
     
    504521     */ 
    505522    showClient : function() 
    506         { 
     523    { 
    507524        TrophyIM.setCookie('trophyim_bosh_xid', TrophyIM.connection.jid + "|" + 
    508         TrophyIM.connection.sid + "|" +  TrophyIM.connection.rid); 
     525            TrophyIM.connection.sid + "|" +  TrophyIM.connection.rid); 
    509526                 
    510527        TrophyIM.rosterObj = new TrophyIMRoster(); 
     
    514531        TrophyIM.connection.addHandler(TrophyIM.onMessage, null, 'message', null, null,  null); 
    515532         
    516                 //Get roster then announce presence. 
    517         TrophyIM.connection.send($iq({type: 'get', xmlns: Strophe.NS.CLIENT}).c('query', {xmlns: Strophe.NS.ROSTER}).tree()); 
     533        //Get roster then announce presence. 
     534        TrophyIM.connection.send($iq({ 
     535            type: 'get',  
     536            xmlns: Strophe.NS.CLIENT 
     537            }).c('query', { 
     538            xmlns: Strophe.NS.ROSTER 
     539            }).tree()); 
    518540        TrophyIM.connection.send($pres().tree()); 
    519                 setTimeout( TrophyIM.renderRoster, 1000); 
     541        setTimeout( TrophyIM.renderRoster, 1000); 
    520542    }, 
    521543         
     
    558580            var to = msg.getAttribute('to'); 
    559581            var id = msg.getAttribute('id'); 
    560             var reply = $iq({type: 'result', to: from, from: to, id: id}).c('query', 
    561             {name: "TrophyIM", version: TROPHYIM_VERSION, os: 
    562             "Javascript-capable browser"}); 
     582            var reply = $iq({ 
     583                type: 'result',  
     584                to: from,  
     585                from: to,  
     586                id: id 
     587            }).c('query', 
     588 
     589            { 
     590                name: "TrophyIM",  
     591                version: TROPHYIM_VERSION,  
     592                os: 
     593                "Javascript-capable browser" 
     594            }); 
    563595            TrophyIM.connection.send(reply.tree()); 
    564596        } 
     
    572604     
    573605    onRoster : function(msg) 
    574         { 
    575         var roster_items = msg.firstChild.getElementsByTagName('item'); 
    576                  
    577                 for (var i = 0; i < roster_items.length; i++) 
    578                 { 
    579                         with(roster_items[i]) 
    580                         { 
    581                                 var groups              = getElementsByTagName('group');         
    582                                 var group_array = []; 
     606    { 
     607        var roster_items = msg.firstChild.getElementsByTagName('item'); 
     608                 
     609        for (var i = 0; i < roster_items.length; i++) 
     610        { 
     611            with(roster_items[i]) 
     612            { 
     613                var groups              = getElementsByTagName('group');         
     614                var group_array = []; 
    583615                                 
    584                                 for( var g = 0 ; g < groups.length; g++ ) 
    585                                 { 
    586                                         if( groups[g].hasChildNodes() ) 
    587                                                 group_array[group_array.length] = groups[g].firstChild.nodeValue; 
    588                                 } 
    589  
    590                                 if( getAttribute('ask') && getAttribute('ask').toString() === "subscribe" )  
    591                                 { 
    592                                         if( getAttribute('subscription').toString() === "none" ) 
    593                                         { 
    594                                                 TrophyIM.rosterObj.addContact( getAttribute('jid'), getAttribute('ask'), getAttribute('name'), group_array ); 
    595                                         } 
     616                for( var g = 0 ; g < groups.length; g++ ) 
     617                { 
     618                    if( groups[g].hasChildNodes() ) 
     619                        group_array[group_array.length] = groups[g].firstChild.nodeValue; 
     620                } 
     621 
     622                if( getAttribute('ask') && getAttribute('ask').toString() === "subscribe" )  
     623                { 
     624                    if( getAttribute('subscription').toString() === "none" ) 
     625                    { 
     626                        TrophyIM.rosterObj.addContact( getAttribute('jid'), getAttribute('ask'), getAttribute('name'), group_array ); 
     627                    } 
    596628                                         
    597                                         if( getAttribute('subscription').toString() === "remove" ) 
    598                                         { 
    599                                                 TrophyIM.rosterObj.removeContact( getAttribute('jid').toString() ); 
    600                                         } 
    601                                 } 
    602                                 else 
    603                                 { 
    604                                         if( ( getAttribute('ask') == null && getAttribute('subscription').toString() === "remove" ) || getAttribute('subscription').toString() === "remove" ) 
    605                                         { 
    606                                                 TrophyIM.rosterObj.removeContact( getAttribute('jid').toString() ); 
    607                                         } 
    608                                         else 
    609                                         { 
    610                                                 TrophyIM.rosterObj.addContact( getAttribute('jid'), getAttribute('subscription'), getAttribute('name'), group_array ); 
    611                                         } 
    612                                 } 
    613                         } 
    614         } 
    615  
    616                 if ( msg.getAttribute('type') == 'set' ) 
    617                 { 
    618                         var _iq = $iq({type: 'reply', id: msg.getAttribute('id'), to: msg.getAttribute('from')}); 
    619                         TrophyIM.connection.send( _iq.tree()); 
    620         } 
    621  
    622                 return true; 
     629                    if( getAttribute('subscription').toString() === "remove" ) 
     630                    { 
     631                        TrophyIM.rosterObj.removeContact( getAttribute('jid').toString() ); 
     632                    } 
     633                } 
     634                else 
     635                { 
     636                    if( ( getAttribute('ask') == null && getAttribute('subscription').toString() === "remove" ) || getAttribute('subscription').toString() === "remove" ) 
     637                    { 
     638                        TrophyIM.rosterObj.removeContact( getAttribute('jid').toString() ); 
     639                    } 
     640                    else 
     641                    { 
     642                        TrophyIM.rosterObj.addContact( getAttribute('jid'), getAttribute('subscription'), getAttribute('name'), group_array ); 
     643                    } 
     644                } 
     645                } 
     646        } 
     647 
     648        if ( msg.getAttribute('type') == 'set' ) 
     649        { 
     650            var _iq = $iq({ 
     651                type: 'reply',  
     652                id: msg.getAttribute('id'),  
     653                to: msg.getAttribute('from') 
     654                }); 
     655            TrophyIM.connection.send( _iq.tree()); 
     656        } 
     657 
     658        return true; 
    623659    }, 
    624660     
     
    629665     
    630666    onPresence : function(msg) 
    631         { 
    632         // Get Presences ChatRoom 
    633         TrophyIM.onPresenceChatRoom( msg ); 
    634  
    635         var type                = msg.getAttribute('type') ? msg.getAttribute('type') : 'available'; 
     667    { 
     668        // Get Presences ChatRoom 
     669        TrophyIM.onPresenceChatRoom( msg ); 
     670 
     671        var type                = msg.getAttribute('type') ? msg.getAttribute('type') : 'available'; 
    636672        var show                = msg.getElementsByTagName('show').length ? Strophe.getText(msg.getElementsByTagName('show')[0]) : type; 
    637673        var status              = msg.getElementsByTagName('status').length ? Strophe.getText(msg.getElementsByTagName('status')[0]) : ''; 
    638674        var priority    = msg.getElementsByTagName('priority').length ? parseInt(Strophe.getText(msg.getElementsByTagName('priority')[0])) : 0; 
    639675 
    640         if( msg.getAttribute('from').toString().indexOf( TROPHYIM_CHATROOM ) < 0 ) 
    641         {        
    642                         var _from = Strophe.getBareJidFromJid( msg.getAttribute('from') ); 
    643                         var _flag = true; 
    644  
    645                 if( TrophyIM.removeResult.idResult.length > 0 ) 
    646                 { 
    647                         for( var i = 0 ; i < TrophyIM.removeResult.idResult.length; i++ ) 
    648                         { 
    649                                 if( TrophyIM.removeResult.idResult[i] == _from ) 
    650                                 { 
    651                                         _flag = false; 
     676        if( msg.getAttribute('from').toString().indexOf( TROPHYIM_CHATROOM ) < 0 ) 
     677        {        
     678            var _from = Strophe.getBareJidFromJid( msg.getAttribute('from') ); 
     679            var _flag = true; 
     680 
     681            if( TrophyIM.removeResult.idResult.length > 0 ) 
     682            { 
     683                for( var i = 0 ; i < TrophyIM.removeResult.idResult.length; i++ ) 
     684                { 
     685                    if( TrophyIM.removeResult.idResult[i] == _from ) 
     686                    { 
     687                        _flag = false; 
    652688                                         
    653                                         TrophyIM.removeResult.idResult.splice(i,1); 
     689                        TrophyIM.removeResult.idResult.splice(i,1); 
    654690                                         
    655                                         i--; 
     691                        i--; 
    656692                                         
    657                                         if( show.toLowerCase() === 'subscribe' ) 
    658                                                 _flag = true; 
    659                                 } 
    660                         } 
    661                 } 
     693                        if( show.toLowerCase() === 'subscribe' ) 
     694                            _flag = true; 
     695                    } 
     696                } 
     697            } 
    662698                 
    663                 if( _flag ) 
    664                         TrophyIM.rosterObj.setPresence( msg.getAttribute('from'), priority, show, status ); 
    665         } 
    666  
    667         return true; 
     699            if( _flag ) 
     700                TrophyIM.rosterObj.setPresence( msg.getAttribute('from'), priority, show, status ); 
     701        } 
     702 
     703        return true; 
    668704    }, 
    669705 
     
    717753                    if( xmlns.indexOf("http://jabber.org/protocol/muc#user") == 0 ) 
    718754                    { 
    719                             var _from   = xquery[i].parentNode.getAttribute('from'); 
    720                             var _to             = xquery[i].parentNode.getAttribute('to'); 
    721  
    722                             // Get NameChatRoom 
    723                             var nameChatRoom    = Strophe.getBareJidFromJid( _from ); 
    724  
    725                             // Get nickName 
    726                             var nickName                = Strophe.getResourceFromJid( _from ); 
    727  
    728                             // Get Type/Show 
    729                             var type    = ( xquery[i].parentNode.getAttribute('type') != null ) ? xquery[i].parentNode.getAttribute('type') : 'available' ; 
    730                             var show    = ( xquery[i].parentNode.firstChild.nodeName == "show" ) ? xquery[i].parentNode.firstChild.firstChild.nodeValue : type; 
    731  
    732                             var _idElement = nameChatRoom + "_UserChatRoom__" + nickName; 
    733  
    734                             var _UserChatRoom                                   = document.createElement("div"); 
    735                                     _UserChatRoom.id                            = _idElement; 
    736                                     _UserChatRoom.style.paddingLeft = '18px'; 
    737                                     _UserChatRoom.style.margin          = '3px 0px 0px 2px'; 
    738                                     _UserChatRoom.style.background      = 'url("'+path_jabberit+'templates/default/images/' + show + '.gif") no-repeat center left'; 
    739                                     _UserChatRoom.appendChild( document.createTextNode( nickName ) ); 
    740  
    741                             var nodeUser = document.getElementById( _idElement );        
    742  
    743                             if( nodeUser == null ) 
     755                        var _from       = xquery[i].parentNode.getAttribute('from'); 
     756                        var _to         = xquery[i].parentNode.getAttribute('to'); 
     757 
     758                        // Get NameChatRoom 
     759                        var nameChatRoom        = Strophe.getBareJidFromJid( _from ); 
     760 
     761                        // Get nickName 
     762                        var nickName            = Strophe.getResourceFromJid( _from ); 
     763 
     764                        // Get Type/Show 
     765                        var type        = ( xquery[i].parentNode.getAttribute('type') != null ) ? xquery[i].parentNode.getAttribute('type') : 'available' ; 
     766                        var show        = ( xquery[i].parentNode.firstChild.nodeName == "show" ) ? xquery[i].parentNode.firstChild.firstChild.nodeValue : type; 
     767 
     768                        var _idElement = nameChatRoom + "_UserChatRoom__" + nickName; 
     769 
     770                        var _UserChatRoom                                       = document.createElement("div"); 
     771                        _UserChatRoom.id                                = _idElement; 
     772                        _UserChatRoom.style.paddingLeft = '18px'; 
     773                        _UserChatRoom.style.margin              = '3px 0px 0px 2px'; 
     774                        _UserChatRoom.style.background  = 'url("'+path_jabberit+'templates/default/images/' + show + '.gif") no-repeat center left'; 
     775                        _UserChatRoom.appendChild( document.createTextNode( nickName ) ); 
     776 
     777                        var nodeUser = document.getElementById( _idElement );    
     778 
     779                        if( nodeUser == null ) 
     780                        { 
     781                            if( document.getElementById( nameChatRoom + '__roomChat__participants' ) != null ) 
    744782                            { 
    745                                     if( document.getElementById( nameChatRoom + '__roomChat__participants' ) != null ) 
    746                                     { 
    747                                             nameChatRoom = document.getElementById( nameChatRoom + '__roomChat__participants' ); 
    748                                             nameChatRoom.appendChild( _UserChatRoom ); 
    749                                     } 
    750                                     else 
    751                                     { 
    752                                             if( type != 'unavailable' ) 
    753                                             { 
    754                                                     TrophyIM.makeChatRoom( nameChatRoom, nameChatRoom.substring(0, nameChatRoom.indexOf('@'))); 
    755                                                     nameChatRoom = document.getElementById( nameChatRoom + '__roomChat__participants' ); 
    756                                                     nameChatRoom.appendChild( _UserChatRoom ); 
    757                                             } 
    758                                     } 
     783                                nameChatRoom = document.getElementById( nameChatRoom + '__roomChat__participants' ); 
     784                                nameChatRoom.appendChild( _UserChatRoom ); 
    759785                            } 
    760786                            else 
    761787                            { 
    762                                     if( type == 'unavailable' ) 
    763                                     { 
    764                                             nodeUser.parentNode.removeChild( nodeUser ); 
    765                                     } 
    766                                     else if( show ) 
    767                                     { 
    768                                             nodeUser.style.backgroundImage =  'url("'+path_jabberit+'templates/default/images/' + show + '.gif")'; 
    769                                     } 
     788                                if( type != 'unavailable' ) 
     789                                { 
     790                                    TrophyIM.makeChatRoom( nameChatRoom, nameChatRoom.substring(0, nameChatRoom.indexOf('@'))); 
     791                                    nameChatRoom = document.getElementById( nameChatRoom + '__roomChat__participants' ); 
     792                                    nameChatRoom.appendChild( _UserChatRoom ); 
     793                                } 
    770794                            } 
     795                        } 
     796                        else 
     797                        { 
     798                            if( type == 'unavailable' ) 
     799                            { 
     800                                nodeUser.parentNode.removeChild( nodeUser ); 
     801                            } 
     802                            else if( show ) 
     803                            { 
     804                                nodeUser.style.backgroundImage =  'url("'+path_jabberit+'templates/default/images/' + show + '.gif")'; 
     805                            } 
     806                        } 
    771807                    } 
    772808                } 
     
    782818    onMessage : function(msg) 
    783819    { 
    784         var checkTime = function(i) 
    785         { 
    786                 if ( i < 10 ) i= "0" + i; 
     820        var checkTime = function(i) 
     821        { 
     822            if ( i < 10 ) i= "0" + i; 
    787823                 
    788                 return i; 
    789         }; 
     824            return i; 
     825        }; 
    790826         
    791                 var messageDate = function( _date ) 
    792                 { 
    793                         var _dt = _date.substr( 0, _date.indexOf( 'T' ) ).split( '-' ); 
    794                         var _hr = _date.substr( _date.indexOf( 'T' ) + 1, _date.length - _date.indexOf( 'T' ) - 2 ).split( ':' ); 
    795                          
    796                         ( _date = new Date ).setTime( Date.UTC( _dt[0], _dt[1] - 1, _dt[2], _hr[0], _hr[1], _hr[2] ) ); 
    797  
    798                         return ( _date.toLocaleDateString( ).replace( /-/g, '/' ) + ' ' + _date.toLocaleTimeString( ) ); 
    799                 }; 
    800  
    801         var data        = new Date(); 
    802         var dtNow       = checkTime(data.getHours()) + ":" + checkTime(data.getMinutes()) + ":" + checkTime(data.getSeconds()); 
     827        var messageDate = function( _date ) 
     828        { 
     829            var _dt = _date.substr( 0, _date.indexOf( 'T' ) ).split( '-' ); 
     830            var _hr = _date.substr( _date.indexOf( 'T' ) + 1, _date.length - _date.indexOf( 'T' ) - 2 ).split( ':' ); 
     831                         
     832            ( _date = new Date ).setTime( Date.UTC( _dt[0], _dt[1] - 1, _dt[2], _hr[0], _hr[1], _hr[2] ) ); 
     833 
     834            return ( _date.toLocaleDateString( ).replace( /-/g, '/' ) + ' ' + _date.toLocaleTimeString( ) ); 
     835        }; 
     836 
     837        var data        = new Date(); 
     838        var dtNow       = checkTime(data.getHours()) + ":" + checkTime(data.getMinutes()) + ":" + checkTime(data.getSeconds()); 
    803839         
    804840        var from        = msg.getAttribute('from'); 
     
    808844        var stamp       = ( delay[0] != null ) ? "<font style='color:red;'>" + messageDate(delay[0].getAttribute('stamp')) + "</font>" :  dtNow; 
    809845 
    810                 var barejid             = Strophe.getBareJidFromJid(from); 
    811                 var jidChatRoom = Strophe.getResourceFromJid(from); 
    812                 var jid_lower   = barejid.toLowerCase(); 
    813                 var contact             = ""; 
    814                 var state               = ""; 
    815  
    816                 var chatBox     = document.getElementById(jid_lower + "__chatState"); 
    817                 var chatStateOnOff = null; 
    818                 var active      = msg.getElementsByTagName('active'); 
    819                  
    820                 contact = barejid.toLowerCase(); 
    821                 contact = contact.substring(0, contact.indexOf('@')); 
     846        var barejid             = Strophe.getBareJidFromJid(from); 
     847        var jidChatRoom = Strophe.getResourceFromJid(from); 
     848        var jid_lower   = barejid.toLowerCase(); 
     849        var contact             = ""; 
     850        var state               = ""; 
     851 
     852        var chatBox     = document.getElementById(jid_lower + "__chatState"); 
     853        var chatStateOnOff = null; 
     854        var active      = msg.getElementsByTagName('active'); 
     855                 
     856        contact = barejid.toLowerCase(); 
     857        contact = contact.substring(0, contact.indexOf('@')); 
    822858             
    823                 if( TrophyIM.rosterObj.roster[barejid] ) 
    824                 { 
    825                         if( TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name'] ) 
    826                         { 
    827                                 contact = TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name']; 
    828                         } 
    829                 } 
    830  
    831                 // Message with body are "content message", this means state active 
    832                 if ( elems.length > 0 ) 
    833                 { 
    834                         state = ""; 
    835                          
    836                         // Set notify chat state capability on when sender notify it themself 
    837                         chatStateOnOff = document.getElementById(jid_lower + "__chatStateOnOff"); 
    838                          
    839                         if (active.length > 0 & chatStateOnOff != null ) 
    840                         { 
    841                                 chatStateOnOff.value = 'on'; 
    842                         } 
    843  
    844                         // Get Message 
    845                         var _message    = document.createElement("div"); 
    846                         var _text               = Strophe.getText( elems[0] ); 
    847                          
    848                         // Events Javascript 
    849                         _text = _text.replace(/onblur/gi,"EVENT_DENY"); 
    850                          
    851                         _text = _text.replace(/onchange/gi,"EVENT_DENY"); 
    852                          
    853                         _text = _text.replace(/onclick/gi,"EVENT_DENY"); 
    854                          
    855                         _text = _text.replace(/ondblclick/gi,"EVENT_DENY"); 
    856                          
    857                         _text = _text.replace(/onerror/gi,"EVENT_DENY"); 
    858                          
    859                         _text = _text.replace(/onfocus/gi,"EVENT_DENY"); 
    860                          
    861                         _text = _text.replace(/onkeydown/gi,"EVENT_DENY"); 
    862                          
    863                         _text = _text.replace(/onkeypress/gi,"EVENT_DENY"); 
    864                          
    865                         _text = _text.replace(/onkeyup/gi,"EVENT_DENY"); 
    866                          
    867                         _text = _text.replace(/onmousedown/gi,"EVENT_DENY"); 
    868                          
    869                         _text = _text.replace(/onmousemove/gi,"EVENT_DENY"); 
    870                          
    871                         _text = _text.replace(/onmouseout/gi,"EVENT_DENY"); 
    872                          
    873                         _text = _text.replace(/onmouseover/gi,"EVENT_DENY"); 
    874                          
    875                         _text = _text.replace(/onmouseup/gi,"EVENT_DENY"); 
    876                          
    877                         _text = _text.replace(/onresize/gi,"EVENT_DENY"); 
    878                          
    879                         _text = _text.replace(/onselect/gi,"EVENT_DENY"); 
    880                          
    881                         _text = _text.replace(/onunload/gi,"EVENT_DENY"); 
    882                          
    883                         // Events CSS 
    884                         _text = _text.replace(/style/gi,"EVENT_DENY"); 
    885  
    886                         // Tags HTML 
    887                         _text = _text.replace(/img /gi,"IMG_DENY "); 
    888                          
    889                         _text = _text.replace(/script /gi,"SCRIPT_DENY "); 
    890                          
    891                         _text = _text.replace(/div /gi,"DIV_DENY "); 
    892                          
    893                         _text = _text.replace(/span /gi,"SPAN_DENY "); 
    894                          
    895                         _text = _text.replace(/iframe /gi,"IFRAME_DENY "); 
    896                          
    897                         _message.innerHTML = _text; 
    898                          
    899                         ////////// BEGIN XSS ////////////////////////////////////////////////// 
    900                         // Delete Tags <SCRIPT> 
    901                         var scripts = _message.getElementsByTagName('script_deny'); 
    902                         for (var i = 0; i < scripts.length; i++){_message.removeChild(scripts[i--]);} 
    903                         //////////////////////////////////////////////////// 
    904                          
    905                         // Delete Tags <IMG> 
    906                         var _imgSrc = _message.getElementsByTagName('img_deny'); 
    907                         for (var i = 0; i < _imgSrc.length; i++){_imgSrc[i].parentNode.removeChild( _imgSrc[i--] );} 
    908                         //////////////////////////////////////////////////// 
    909                          
    910                         // Delete Tags <DIV> 
    911                         var _Div = _message.getElementsByTagName('div_deny'); 
    912                         for (var i = 0; i < _Div.length; i++){_Div[i].parentNode.removeChild( _Div[i--] );} 
    913                         //////////////////////////////////////////////////// 
    914                          
    915                         // Delete Tags <SPAN> 
    916                         var _Span = _message.getElementsByTagName('span_deny'); 
    917                         for (var i = 0; i < _Span.length; i++){_Span[i].parentNode.removeChild( _Span[i--] );} 
    918                         //////////////////////////////////////////////////// 
    919  
    920                         // Delete Tags <IFRAME> 
    921                         var _Iframe = _message.getElementsByTagName('iframe_deny'); 
    922                         for (var i = 0; i < _Iframe.length; i++){_Iframe[i].parentNode.removeChild( _Iframe[i--] );} 
    923  
    924                         // Delete Tags <A HREF> 
    925                         var _aHref = _message.getElementsByTagName('a'); 
    926                         for (var i = 0; i < _aHref.length; i++){_aHref[i].parentNode.removeChild( _aHref[i--] );} 
    927                          
    928                         _message.innerHTML = _message.innerHTML.replace(/^\s+|\s+$|^\n|\n$/g, ""); 
    929                         ////////// END XSS ////////////////////////////////////////////////// 
    930                          
    931                         // Get Smiles 
    932                         _message.innerHTML = loadscript.getSmiles( _message.innerHTML ); 
    933  
    934                         if (type == 'chat' || type == 'normal') 
    935                         { 
    936                                 if ( _message.hasChildNodes() ) 
    937                                 { 
    938                                         var message =  
    939                                         { 
    940                                 contact : "[" + stamp + "] <font style='font-weight:bold; color:black;'>" + contact + "</font>", 
    941                                 msg             : "</br>" + _message.innerHTML 
    942                         }; 
     859        if( TrophyIM.rosterObj.roster[barejid] ) 
     860        { 
     861            if( TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name'] ) 
     862            { 
     863                contact = TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name']; 
     864            } 
     865        } 
     866 
     867        // Message with body are "content message", this means state active 
     868        if ( elems.length > 0 ) 
     869        { 
     870            state = ""; 
     871                         
     872            // Set notify chat state capability on when sender notify it themself 
     873            chatStateOnOff = document.getElementById(jid_lower + "__chatStateOnOff"); 
     874                         
     875            if (active.length > 0 & chatStateOnOff != null ) 
     876            { 
     877                chatStateOnOff.value = 'on'; 
     878            } 
     879 
     880            // Get Message 
     881            var _message        = document.createElement("div"); 
     882            var _text           = Strophe.getText( elems[0] ); 
     883                         
     884            // Events Javascript 
     885            _text = _text.replace(/onblur/gi,"EVENT_DENY"); 
     886                         
     887            _text = _text.replace(/onchange/gi,"EVENT_DENY"); 
     888                         
     889            _text = _text.replace(/onclick/gi,"EVENT_DENY"); 
     890                         
     891            _text = _text.replace(/ondblclick/gi,"EVENT_DENY"); 
     892                         
     893            _text = _text.replace(/onerror/gi,"EVENT_DENY"); 
     894                         
     895            _text = _text.replace(/onfocus/gi,"EVENT_DENY"); 
     896                         
     897            _text = _text.replace(/onkeydown/gi,"EVENT_DENY"); 
     898                         
     899            _text = _text.replace(/onkeypress/gi,"EVENT_DENY"); 
     900                         
     901            _text = _text.replace(/onkeyup/gi,"EVENT_DENY"); 
     902                         
     903            _text = _text.replace(/onmousedown/gi,"EVENT_DENY"); 
     904                         
     905            _text = _text.replace(/onmousemove/gi,"EVENT_DENY"); 
     906                         
     907            _text = _text.replace(/onmouseout/gi,"EVENT_DENY"); 
     908                         
     909            _text = _text.replace(/onmouseover/gi,"EVENT_DENY"); 
     910                         
     911            _text = _text.replace(/onmouseup/gi,"EVENT_DENY"); 
     912                         
     913            _text = _text.replace(/onresize/gi,"EVENT_DENY"); 
     914                         
     915            _text = _text.replace(/onselect/gi,"EVENT_DENY"); 
     916                         
     917            _text = _text.replace(/onunload/gi,"EVENT_DENY"); 
     918                         
     919            // Events CSS 
     920            _text = _text.replace(/style/gi,"EVENT_DENY"); 
     921 
     922            // Tags HTML 
     923            _text = _text.replace(/img /gi,"IMG_DENY "); 
     924                         
     925            _text = _text.replace(/script /gi,"SCRIPT_DENY "); 
     926                         
     927            _text = _text.replace(/div /gi,"DIV_DENY "); 
     928                         
     929            _text = _text.replace(/span /gi,"SPAN_DENY "); 
     930                         
     931            _text = _text.replace(/iframe /gi,"IFRAME_DENY "); 
     932                         
     933            _message.innerHTML = _text; 
     934                         
     935            ////////// BEGIN XSS ////////////////////////////////////////////////// 
     936            // Delete Tags <SCRIPT> 
     937            var scripts = _message.getElementsByTagName('script_deny'); 
     938            for (var i = 0; i < scripts.length; i++){ 
     939                _message.removeChild(scripts[i--]); 
     940            } 
     941            //////////////////////////////////////////////////// 
     942                         
     943            // Delete Tags <IMG> 
     944            var _imgSrc = _message.getElementsByTagName('img_deny'); 
     945            for (var i = 0; i < _imgSrc.length; i++){ 
     946                _imgSrc[i].parentNode.removeChild( _imgSrc[i--] ); 
     947            } 
     948            //////////////////////////////////////////////////// 
     949                         
     950            // Delete Tags <DIV> 
     951            var _Div = _message.getElementsByTagName('div_deny'); 
     952            for (var i = 0; i < _Div.length; i++){ 
     953                _Div[i].parentNode.removeChild( _Div[i--] ); 
     954            } 
     955            //////////////////////////////////////////////////// 
     956                         
     957            // Delete Tags <SPAN> 
     958            var _Span = _message.getElementsByTagName('span_deny'); 
     959            for (var i = 0; i < _Span.length; i++){ 
     960                _Span[i].parentNode.removeChild( _Span[i--] ); 
     961            } 
     962            //////////////////////////////////////////////////// 
     963 
     964            // Delete Tags <IFRAME> 
     965            var _Iframe = _message.getElementsByTagName('iframe_deny'); 
     966            for (var i = 0; i < _Iframe.length; i++){ 
     967                _Iframe[i].parentNode.removeChild( _Iframe[i--] ); 
     968            } 
     969 
     970            // Delete Tags <A HREF> 
     971            var _aHref = _message.getElementsByTagName('a'); 
     972            for (var i = 0; i < _aHref.length; i++){ 
     973                _aHref[i].parentNode.removeChild( _aHref[i--] ); 
     974            } 
     975                         
     976            _message.innerHTML = _message.innerHTML.replace(/^\s+|\s+$|^\n|\n$/g, ""); 
     977            ////////// END XSS ////////////////////////////////////////////////// 
     978                         
     979            // Get Smiles 
     980            _message.innerHTML = loadscript.getSmiles( _message.innerHTML ); 
     981 
     982            if (type == 'chat' || type == 'normal') 
     983            { 
     984                if ( _message.hasChildNodes() ) 
     985                { 
     986                    var message =  
     987                    { 
     988                        contact : "[" + stamp + "] <font style='font-weight:bold; color:black;'>" + contact + "</font>", 
     989                        msg             : "</br>" + _message.innerHTML 
     990                    }; 
    943991                                         
    944                                         TrophyIM.addMessage( TrophyIM.makeChat( from ), jid_lower, message ); 
    945                                 } 
    946                         } 
    947                         else if( type == 'groupchat') 
    948                         { 
    949                                 if ( _message.hasChildNodes() ) 
    950                                 { 
    951                                         var message =  
    952                                         { 
    953                                                 contact : "[" + stamp + "] <font style='font-weight:bold; color:black;'>" + jidChatRoom + "</font>", 
    954                                                 msg     : "</br>" + _message.innerHTML 
    955                                         }; 
    956  
    957                                         TrophyIM.addMessage( TrophyIM.makeChatRoom( barejid ), jid_lower, message ); 
    958                                 } 
    959                         } 
    960                 } 
    961                 // Message without body are "content message", this mean state is not active 
    962                 else 
    963                 { 
    964                         if( chatBox != null ) 
    965                                 state = TrophyIM.getChatState(msg);                      
    966                 } 
    967                  
    968                 // Clean chat status message some time later             
    969                 var clearChatState = function() 
    970                 { 
    971                         chatBox.innerHTML=''; 
    972                 } 
    973                  
    974                 if (chatBox != null) 
    975                 { 
    976                         var clearChatStateTimer;  
    977                          
    978                         chatBox.innerHTML = "<font style='font-weight:bold; color:grey; float:right;'>" + state + "</font>";  
    979                          
    980                         var _composing =  msg.getElementsByTagName('composing');  
    981                          
    982                         if ( _composing.length == 0 ) 
     992                    TrophyIM.addMessage( TrophyIM.makeChat( from ), jid_lower, message ); 
     993                } 
     994            } 
     995            else if( type == 'groupchat') 
     996            { 
     997                if ( _message.hasChildNodes() ) 
     998                { 
     999                    var message =  
     1000                    { 
     1001                        contact : "[" + stamp + "] <font style='font-weight:bold; color:black;'>" + jidChatRoom + "</font>", 
     1002                        msg     : "</br>" + _message.innerHTML 
     1003                    }; 
     1004 
     1005                    TrophyIM.addMessage( TrophyIM.makeChatRoom( barejid ), jid_lower, message ); 
     1006                } 
     1007            } 
     1008        } 
     1009        // Message without body are "content message", this mean state is not active 
     1010        else 
     1011        { 
     1012            if( chatBox != null ) 
     1013                state = TrophyIM.getChatState(msg);                      
     1014        } 
     1015                 
     1016        // Clean chat status message some time later             
     1017        var clearChatState = function() 
     1018        { 
     1019            chatBox.innerHTML=''; 
     1020        } 
     1021                 
     1022        if (chatBox != null) 
     1023        { 
     1024            var clearChatStateTimer;  
     1025                         
     1026            chatBox.innerHTML = "<font style='font-weight:bold; color:grey; float:right;'>" + state + "</font>";  
     1027                         
     1028            var _composing =  msg.getElementsByTagName('composing');  
     1029                         
     1030            if ( _composing.length == 0 ) 
    9831031                                 
    984                                 clearChatStateTimer = setTimeout(clearChatState, 2000);  
    985                         else  
    986                                 clearTimeout(clearChatStateTimer);                       
    987                 } 
    988  
    989                 return true; 
    990         }, 
    991  
    992         /** Function: getChatState 
     1032                clearChatStateTimer = setTimeout(clearChatState, 2000);  
     1033            else  
     1034                clearTimeout(clearChatStateTimer);                       
     1035        } 
     1036 
     1037        return true; 
     1038    }, 
     1039 
     1040    /** Function: getChatState 
    9931041         * 
    9941042         *  Parameters: 
     
    9961044         *    (string) jid - the jid of chat box to update the chat state to. 
    9971045         */ 
    998         getChatState : function(msg) 
    999         { 
    1000                 var     state =  msg.getElementsByTagName('inactive'); 
     1046    getChatState : function(msg) 
     1047    { 
     1048        var     state =  msg.getElementsByTagName('inactive'); 
    10011049                 
    1002                 if ( state.length > 0 ) 
    1003                 { 
    1004                 return i18n.INACTIVE; 
    1005                 } 
    1006                 else 
    1007                 { 
    1008                 state = msg.getElementsByTagName('gone'); 
     1050        if ( state.length > 0 ) 
     1051        { 
     1052            return i18n.INACTIVE; 
     1053        } 
     1054        else 
     1055        { 
     1056            state = msg.getElementsByTagName('gone'); 
    10091057            if ( state.length > 0 ) 
    10101058            { 
    1011                 return i18n.GONE; 
    1012                         } 
     1059                return i18n.GONE; 
     1060            } 
    10131061            else 
    10141062            { 
    1015                 state = msg.getElementsByTagName('composing');  
    1016                 if ( state.length > 0 ) 
    1017                 { 
    1018                         return i18n.COMPOSING; 
    1019                                 } 
    1020                 else 
    1021                 { 
    1022                         state =  msg.getElementsByTagName('paused'); 
    1023                         if ( state.length > 0 ) 
    1024                         { 
    1025                                 return i18n.PAUSED; 
    1026                                         } 
    1027                                 } 
    1028                         } 
    1029                 } 
    1030                  
    1031                 return ''; 
    1032         }, 
    1033  
    1034         /** Function: makeChat 
     1063                state = msg.getElementsByTagName('composing');  
     1064                if ( state.length > 0 ) 
     1065                { 
     1066                    return i18n.COMPOSING; 
     1067                } 
     1068                else 
     1069                { 
     1070                    state =  msg.getElementsByTagName('paused'); 
     1071                    if ( state.length > 0 ) 
     1072                    { 
     1073                        return i18n.PAUSED; 
     1074                    } 
     1075                } 
     1076            } 
     1077        } 
     1078                 
     1079        return ''; 
     1080    }, 
     1081 
     1082    /** Function: makeChat 
    10351083     * 
    10361084     *  Make sure chat window to given fulljid exists, switching chat context to 
     
    10401088    makeChat : function(fulljid) 
    10411089    { 
    1042         var barejid             = Strophe.getBareJidFromJid(fulljid); 
    1043         var titleWindow = ""; 
    1044  
    1045         var paramsChatBox = 
    1046         { 
    1047                         'enabledPopUp'  : ( ( loadscript.getIsIE() ) ? "none" : "block" ), 
    1048                         'idChatBox'     : barejid + "__chatBox", 
    1049                         'jidTo'                 : barejid, 
    1050                                 'path_jabberit' : path_jabberit 
    1051         }; 
    1052  
    1053         titleWindow = barejid.toLowerCase(); 
    1054                 titleWindow = titleWindow.substring(0, titleWindow.indexOf('@')); 
     1090        var barejid             = Strophe.getBareJidFromJid(fulljid); 
     1091        var titleWindow = ""; 
     1092 
     1093        var paramsChatBox = 
     1094        { 
     1095            'enabledPopUp'      : ( ( loadscript.getBrowserCompatible() ) ? "block" : "none" ), 
     1096            'idChatBox'         : barejid + "__chatBox", 
     1097            'jidTo'                     : barejid, 
     1098            'path_jabberit' : path_jabberit 
     1099        }; 
     1100 
     1101        titleWindow = barejid.toLowerCase(); 
     1102        titleWindow = titleWindow.substring(0, titleWindow.indexOf('@')); 
    10551103 
    10561104        if( TrophyIM.rosterObj.roster[barejid] ) 
     
    10581106            if( TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name'] ) 
    10591107            { 
    1060                 titleWindow = TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name']; 
     1108                titleWindow = TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name']; 
    10611109            } 
    10621110        } 
     
    10651113        TrophyIM.posWindow.top  = TrophyIM.posWindow.top + 10;  
    10661114        if( TrophyIM.posWindow.top > 200 ) 
    1067                 TrophyIM.posWindow.top  = 100; 
     1115            TrophyIM.posWindow.top      = 100; 
    10681116         
    10691117        // Position Left 
    10701118        TrophyIM.posWindow.left = TrophyIM.posWindow.left + 5; 
    10711119        if( TrophyIM.posWindow.left > 455 ) 
    1072                 TrophyIM.posWindow.left = 400; 
     1120            TrophyIM.posWindow.left     = 400; 
    10731121         
    10741122        var _content = document.createElement( 'div' ); 
     
    10791127        var _textarea           = _content.getElementsByTagName( 'textarea' ).item( 0 ); 
    10801128        var _send                       = _content.getElementsByTagName( 'input' ).item( 0 ); 
    1081                 var _chatStateOnOff     = _content.getElementsByTagName( 'input' ).item( 1 ); 
     1129        var _chatStateOnOff     = _content.getElementsByTagName( 'input' ).item( 1 ); 
    10821130 
    10831131        var _send_message = function( ) 
    10841132        { 
    1085                 if ( ! TrophyIM.sendMessage( barejid, _textarea.value ) ) 
    1086                         return false; 
    1087  
    1088                 // Add Message in chatBox; 
    1089                 TrophyIM.addMessage( _messages, barejid, { 
    1090                         contact : "<font style='font-weight:bold; color:red;'>" + i18n.ME + "</font>", 
    1091                         msg : "<br/>" + _textarea.value 
    1092                 } ); 
    1093  
    1094                 _textarea.value = ''; 
    1095                 _textarea.focus( ); 
     1133            if ( ! TrophyIM.sendMessage( barejid, _textarea.value ) ) 
     1134                return false; 
     1135 
     1136            // Add Message in chatBox; 
     1137            TrophyIM.addMessage( _messages, barejid, { 
     1138                contact : "<font style='font-weight:bold; color:red;'>" + i18n.ME + "</font>", 
     1139                msg : "<br/>" + _textarea.value 
     1140            } ); 
     1141 
     1142            _textarea.value = ''; 
     1143            _textarea.focus( ); 
    10961144        }; 
    10971145                 
    1098                 var composingTimer_ = 0; 
    1099                 var isComposing_ = 0; 
    1100                 var timeCounter; 
    1101  
    1102                 var setComposing = function( ) 
    1103                 { 
    1104                         var checkComposing = function() 
    1105                         { 
    1106                 if (!isComposing_) { 
    1107                         // User stopped composing 
    1108                         composingTimer_ = 0; 
    1109                         clearInterval(timeCounter); 
    1110                         TrophyIM.sendContentMessage(barejid, 'paused'); 
    1111                 } else { 
    1112                         TrophyIM.sendContentMessage(barejid, 'composing'); 
    1113                 } 
    1114                 isComposing_ = 0; // Reset composing 
    1115                 } 
    1116  
    1117                 if (!composingTimer_) { 
    1118                 /* User (re)starts composing */ 
    1119                 composingTimer_ = 1; 
    1120                 timeCounter = setInterval(checkComposing,4000); 
    1121                 } 
    1122                 isComposing_ = 1; 
    1123         }; 
     1146        var composingTimer_ = 0; 
     1147        var isComposing_ = 0; 
     1148        var timeCounter; 
     1149 
     1150        var setComposing = function( ) 
     1151        { 
     1152            var checkComposing = function() 
     1153            { 
     1154                if (!isComposing_) { 
     1155                    // User stopped composing 
     1156                    composingTimer_ = 0; 
     1157                    clearInterval(timeCounter); 
     1158                    TrophyIM.sendContentMessage(barejid, 'paused'); 
     1159                } else { 
     1160                    TrophyIM.sendContentMessage(barejid, 'composing'); 
     1161                } 
     1162                isComposing_ = 0; // Reset composing 
     1163            } 
     1164 
     1165            if (!composingTimer_) { 
     1166                /* User (re)starts composing */ 
     1167                composingTimer_ = 1; 
     1168                timeCounter = setInterval(checkComposing,4000); 
     1169            } 
     1170            isComposing_ = 1; 
     1171        }; 
    11241172 
    11251173        loadscript.configEvents( _send, 'onclick', _send_message ); 
    1126                 loadscript.configEvents( _textarea, 'onkeyup', function( e ) 
    1127                 { 
    1128                         if ( e.keyCode == 13 ){ 
    1129                                 _send_message( ); 
    1130                                 // User stopped composing 
    1131                 composingTimer_ = 0; 
    1132                 clearInterval(timeCounter); 
    1133                         }else{ 
    1134                                 if (_chatStateOnOff.value == 'on') 
    1135                                         setComposing(); 
    1136                         } 
    1137                 } );         
    1138  
    1139         var winChatBox =  
    1140         { 
    1141                          id_window              : "window_chat_area_" + barejid, 
    1142                          barejid                : barejid, 
    1143                          width                  : 387, 
    1144                          height                 : 375, 
    1145                         top                    : TrophyIM.posWindow.top, 
    1146                          left                   : TrophyIM.posWindow.left, 
    1147                         draggable              : true, 
    1148                         visible                : "display", 
    1149                         resizable              : true, 
    1150                          zindex                 : loadscript.getZIndex(), 
    1151                          title                  : titleWindow, 
    1152                          closeAction    : "hidden", 
    1153                         content                : _content       
    1154         } 
     1174        loadscript.configEvents( _textarea, 'onkeyup', function( e ) 
     1175        { 
     1176            if ( e.keyCode == 13 ){ 
     1177                _send_message( ); 
     1178                // User stopped composing 
     1179                composingTimer_ = 0; 
     1180                clearInterval(timeCounter); 
     1181            }else{ 
     1182                if (_chatStateOnOff.value == 'on') 
     1183                    setComposing(); 
     1184            } 
     1185        } );         
     1186 
     1187        var winChatBox =  
     1188        { 
     1189           id_window           : "window_chat_area_" + barejid, 
     1190           barejid             : barejid, 
     1191            width               : 387, 
     1192            height              : 375, 
     1193            top                 : TrophyIM.posWindow.top, 
     1194            left                : TrophyIM.posWindow.left, 
     1195            draggable           : true, 
     1196            visible             : "display", 
     1197            resizable           : true, 
     1198            zindex              : loadscript.getZIndex(), 
     1199            title               : titleWindow, 
     1200            closeAction         : "hidden", 
     1201            content             : _content       
     1202        } 
    11551203         
    1156                 _win = _winBuild(winChatBox); 
    1157  
    1158         // Notification New Message 
    1159         loadscript.notification(barejid); 
     1204        _win = _winBuild(winChatBox); 
     1205 
     1206        // Notification New Message 
     1207        loadscript.notification(barejid); 
    11601208         
    1161         // Photo User; 
    1162                 loadscript.getPhotoUser(barejid); 
     1209        // Photo User; 
     1210        loadscript.getPhotoUser(barejid); 
    11631211                 
    1164                 _textarea.focus( ); 
    1165                  
    1166                 return ( _messages = _win.content( ).firstChild ); 
    1167     }, 
    1168  
    1169         /** Function: makeChatRoom 
     1212        _textarea.focus( ); 
     1213         
     1214        _messages = _win.content( ).firstChild;  
     1215         
     1216        while ( _messages && _messages.nodeType !== 1 )  
     1217        {  
     1218            _messages = _messages.nextSibling;  
     1219        }  
     1220         
     1221        return ( _messages );          
     1222    }, 
     1223 
     1224    /** Function: makeChatRoom 
    11701225    * 
    11711226    * 
     
    11751230    makeChatRoom : function() 
    11761231    { 
    1177         var jidChatRoom = arguments[0]; 
    1178         var titleWindow = "ChatRoom - " + unescape(arguments[1]); 
     1232        var jidChatRoom = arguments[0]; 
     1233        var titleWindow = "ChatRoom - " + unescape(arguments[1]); 
    11791234         
    1180         var paramsChatRoom = 
    1181         { 
    1182                         'idChatRoom'    : jidChatRoom + "__roomChat", 
    1183                         'jidTo'                 : jidChatRoom, 
    1184                         'lang_Send'             : i18n.SEND, 
    1185                         'lang_Leave_ChatRoom' : i18n.LEAVE_CHATROOM, 
    1186                                 'path_jabberit' : path_jabberit 
    1187         }; 
    1188  
    1189         // Position Top 
     1235        var paramsChatRoom = 
     1236        { 
     1237            'idChatRoom'        : jidChatRoom + "__roomChat", 
     1238            'jidTo'                     : jidChatRoom, 
     1239            'lang_Send'         : i18n.SEND, 
     1240            'lang_Leave_ChatRoom' : i18n.LEAVE_CHATROOM, 
     1241            'path_jabberit' : path_jabberit 
     1242        }; 
     1243 
     1244        // Position Top 
    11901245        TrophyIM.posWindow.top  = TrophyIM.posWindow.top + 10;  
    11911246        if( TrophyIM.posWindow.top > 200 ) 
    1192                 TrophyIM.posWindow.top  = 100; 
     1247            TrophyIM.posWindow.top      = 100; 
    11931248         
    11941249        // Position Left 
    11951250        TrophyIM.posWindow.left = TrophyIM.posWindow.left + 5; 
    11961251        if( TrophyIM.posWindow.left > 455 ) 
    1197                 TrophyIM.posWindow.left = 400; 
     1252            TrophyIM.posWindow.left     = 400; 
    11981253 
    11991254        var _content = document.createElement( 'div' ); 
     
    12081263        var _send_message = function( ) 
    12091264        { 
    1210                 if ( ! TrophyIM.sendMessageChatRoom( jidChatRoom, _textarea.value ) ) 
    1211                         return false; 
     1265            if ( ! TrophyIM.sendMessageChatRoom( jidChatRoom, _textarea.value ) ) 
     1266                return false; 
    12121267                 
    1213                 _textarea.value = ''; 
     1268            _textarea.value = ''; 
    12141269                 
    1215                 _textarea.focus( ); 
     1270            _textarea.focus( ); 
    12161271        }; 
    12171272         
     
    12191274        loadscript.configEvents( _leaveChatRoom, 'onclick', function( ) 
    12201275        { 
    1221                 TrophyIM.leaveChatRoom( jidChatRoom ); 
     1276            TrophyIM.leaveChatRoom( jidChatRoom ); 
    12221277                 
    1223                 if( TrophyIM.activeChatRoom.name.length > 0 ) 
    1224                 { 
    1225                         for( var i = 0;  i < TrophyIM.activeChatRoom.name.length ; i++ ) 
    1226                         { 
    1227                                 if( TrophyIM.activeChatRoom.name[i].indexOf( jidChatRoom ) >= 0 ) 
    1228                                 { 
    1229                                         TrophyIM.activeChatRoom.name[i] = ""; 
    1230                                 } 
    1231                         } 
    1232                 } 
     1278            if( TrophyIM.activeChatRoom.name.length > 0 ) 
     1279            { 
     1280                for( var i = 0;  i < TrophyIM.activeChatRoom.name.length ; i++ ) 
     1281                { 
     1282                    if( TrophyIM.activeChatRoom.name[i].indexOf( jidChatRoom ) >= 0 ) 
     1283                    { 
     1284                        TrophyIM.activeChatRoom.name[i] = ""; 
     1285                    } 
     1286                } 
     1287            } 
    12331288                 
    1234                 setTimeout( function() 
    1235                 { 
    1236                         _winBuild("window_chat_room_" + jidChatRoom, "remove"); 
     1289            setTimeout( function() 
     1290            { 
     1291                _winBuild("window_chat_room_" + jidChatRoom, "remove"); 
    12371292                         
    1238                 }, 650 ); 
     1293            }, 650 ); 
    12391294                 
    12401295        }); 
    12411296         
    1242                 loadscript.configEvents( _textarea, 'onkeyup', function( e ) 
    1243                 { 
    1244                         if ( e.keyCode == 13 ) 
    1245                         { 
    1246                                 _send_message( ); 
    1247                         } 
    1248                 });         
     1297        loadscript.configEvents( _textarea, 'onkeyup', function( e ) 
     1298        { 
     1299            if ( e.keyCode == 13 ) 
     1300            { 
     1301                _send_message( ); 
     1302            } 
     1303        });         
    12491304         
    1250         var winChatRoom =  
    1251         { 
    1252                          id_window              : "window_chat_room_" + arguments[0], 
    1253                          barejid                : jidChatRoom, 
    1254                         width                  : 500, 
    1255                         height                 : 450, 
    1256                         top                    : TrophyIM.posWindow.top, 
    1257                         left                   : TrophyIM.posWindow.left, 
    1258                         draggable              : true, 
    1259                         visible                : "display", 
    1260                         resizable              : true, 
    1261                         zindex                 : loadscript.getZIndex(), 
    1262                         title                  : titleWindow, 
    1263                         closeAction    : "hidden", 
    1264                         content                : _content       
    1265         } 
     1305        var winChatRoom =  
     1306        { 
     1307           id_window           : "window_chat_room_" + arguments[0], 
     1308           barejid             : jidChatRoom, 
     1309            width                       : 500, 
     1310            height                      : 450, 
     1311            top                 : TrophyIM.posWindow.top, 
     1312            left                        : TrophyIM.posWindow.left, 
     1313            draggable           : true, 
     1314            visible             : "display", 
     1315            resizable           : true, 
     1316            zindex                      : loadscript.getZIndex(), 
     1317            title                       : titleWindow, 
     1318            closeAction : "hidden", 
     1319            content             : _content       
     1320        } 
    12661321         
    1267         _win = _winBuild(winChatRoom); 
     1322        _win = _winBuild(winChatRoom); 
    12681323         
    1269         return ( _messages = _win.content( ).firstChild ); 
     1324        _messages = _win.content( ).firstChild;  
     1325         
     1326        while ( _messages && _messages.nodeType !== 1 )  
     1327        {  
     1328            _messages = _messages.nextSibling;  
     1329        }  
     1330         
     1331        return ( _messages );          
     1332 
    12701333         
    12711334    }, 
    12721335     
    1273         /** Function addContacts 
     1336    /** Function addContacts 
    12741337         *  
    12751338         *  Parameters: 
     
    12801343         */ 
    12811344         
    1282         addContact : function( jidTo, name, group ) 
    1283         { 
    1284                 var _flag = true; 
    1285  
    1286                 if( TrophyIM.removeResult.idResult.length > 0 ) 
    1287                 { 
    1288                         for( var i = 0 ; i < TrophyIM.removeResult.idResult.length; i++ ) 
    1289                         { 
    1290                                 if( TrophyIM.removeResult.idResult[i] == jidTo ) 
    1291                                 { 
    1292                                         _flag = false; 
     1345    addContact : function( jidTo, name, group ) 
     1346    { 
     1347        var _flag = true; 
     1348 
     1349        if( TrophyIM.removeResult.idResult.length > 0 ) 
     1350        { 
     1351            for( var i = 0 ; i < TrophyIM.removeResult.idResult.length; i++ ) 
     1352            { 
     1353                if( TrophyIM.removeResult.idResult[i] == jidTo ) 
     1354                { 
     1355                    _flag = false; 
    12931356                                         
    1294                                         TrophyIM.removeResult.idResult.splice(i,1); 
     1357                    TrophyIM.removeResult.idResult.splice(i,1); 
    12951358                                         
    1296                                         i--; 
    1297                                 } 
    1298                         } 
    1299                 } 
    1300                  
    1301                 if( _flag ) 
    1302                 {        
    1303                 // Add Contact 
    1304                 var _id = TrophyIM.connection.getUniqueId('add');  
    1305                         var newContact = $iq({type: 'set', id: _id}); 
    1306                                 newContact = newContact.c('query').attrs({xmlns : 'jabber:iq:roster'}); 
    1307                                 newContact = newContact.c('item').attrs({jid: jidTo, name:name}); 
    1308                                 newContact = newContact.c('group').t(group).tree(); 
    1309          
    1310                         TrophyIM.connection.send(newContact); 
    1311                 } 
    1312         }, 
     1359                    i--; 
     1360                } 
     1361            } 
     1362        } 
     1363                 
     1364        if( _flag ) 
     1365        {        
     1366            // Add Contact 
     1367            var _id = TrophyIM.connection.getUniqueId('add');  
     1368            var newContact = $iq({ 
     1369                type: 'set',  
     1370                id: _id 
     1371            }); 
     1372            newContact = newContact.c('query').attrs({ 
     1373                xmlns : 'jabber:iq:roster' 
     1374            }); 
     1375            newContact = newContact.c('item').attrs({ 
     1376                jid: jidTo,  
     1377                name:name 
     1378            }); 
     1379            newContact = newContact.c('group').t(group).tree(); 
     1380         
     1381            TrophyIM.connection.send(newContact); 
     1382        } 
     1383    }, 
    13131384 
    13141385    /** Function: add 
     
    13211392    addMessage : function( chatBox, jid, msg ) 
    13221393    { 
    1323         // Get Smiles 
    1324         msg.msg = loadscript.getSmiles( msg.msg ); 
     1394        // Get Smiles 
     1395        msg.msg = loadscript.getSmiles( msg.msg ); 
    13251396  
    1326         var messageDiv  = document.createElement("div"); 
    1327                 messageDiv.style.margin = "3px 0px 1em 3px"; 
    1328         messageDiv.innerHTML    = msg.contact + " : " + msg.msg ; 
     1397        var messageDiv  = document.createElement("div"); 
     1398        messageDiv.style.margin = "3px 0px 1em 3px"; 
     1399        messageDiv.innerHTML    = msg.contact + " : " + msg.msg ; 
    13291400                 
    1330         chatBox.appendChild(messageDiv); 
    1331         chatBox.scrollTop = chatBox.scrollHeight; 
     1401        chatBox.appendChild(messageDiv); 
     1402        chatBox.scrollTop = chatBox.scrollHeight; 
    13321403    }, 
    13331404         
     
    13391410    renameContact : function( jid ) 
    13401411    { 
    1341         // Name 
    1342         var name                = TrophyIM.rosterObj.roster[jid].contact.name; 
    1343  
    1344                 if(( name = prompt(i18n.ASK_NEW_NAME_QUESTION + name + "!", name ))) 
    1345                         if(( name = name.replace(/^\s+|\s+$|^\n|\n$/g,"")) == "" ) 
    1346                                 name = ""; 
    1347  
    1348                 if( name == null || name == "") 
    1349                         name = ""; 
    1350                  
    1351         var jidTo = jid 
    1352         var name  = ( name ) ? name : TrophyIM.rosterObj.roster[jid].contact.name; 
    1353         var group = TrophyIM.rosterObj.roster[jid].contact.groups[0]; 
     1412        // Name 
     1413        var name                = TrophyIM.rosterObj.roster[jid].contact.name; 
     1414 
     1415        if(( name = prompt(i18n.ASK_NEW_NAME_QUESTION + name + "!", name ))) 
     1416            if(( name = name.replace(/^\s+|\s+$|^\n|\n$/g,"")) == "" ) 
     1417                name = ""; 
     1418 
     1419        if( name == null || name == "") 
     1420            name = ""; 
     1421                 
     1422        var jidTo = jid 
     1423        var name  = ( name ) ? name : TrophyIM.rosterObj.roster[jid].contact.name; 
     1424        var group = TrophyIM.rosterObj.roster[jid].contact.groups[0]; 
    13541425         
    1355         TrophyIM.addContact( jidTo, name, group ); 
     1426        TrophyIM.addContact( jidTo, name, group ); 
    13561427         
    1357         document.getElementById('itenContact_' + jid ).innerHTML = name; 
     1428        document.getElementById('itenContact_' + jid ).innerHTML = name; 
    13581429    }, 
    13591430     
     
    13651436    renameGroup : function( jid ) 
    13661437    { 
    1367         var group               = TrophyIM.rosterObj.roster[jid].contact.groups[0]; 
    1368         var presence    = TrophyIM.rosterObj.roster[jid].presence; 
     1438        var group               = TrophyIM.rosterObj.roster[jid].contact.groups[0]; 
     1439        var presence    = TrophyIM.rosterObj.roster[jid].presence; 
    13691440         
    13701441        // Group 
    13711442        if(( group = prompt( i18n.ASK_NEW_GROUP_QUESTION, group ))) 
    1372                 if(( group = group.replace(/^\s+|\s+$|^\n|\n$/g,"")) == "" ) 
    1373                         group = ""; 
     1443            if(( group = group.replace(/^\s+|\s+$|^\n|\n$/g,"")) == "" ) 
     1444                group = ""; 
    13741445 
    13751446        if( group == null || group == "") 
    1376                 group = ""; 
    1377  
    1378         var jidTo = TrophyIM.rosterObj.roster[jid].contact.jid; 
    1379         var name  = TrophyIM.rosterObj.roster[jid].contact.name; 
    1380                 var group = ( group ) ? group : TrophyIM.rosterObj.roster[jid].contact.groups[0]; 
    1381  
    1382                 TrophyIM.rosterObj.removeContact( jid ); 
    1383                  
    1384                 TrophyIM.addContact( jidTo, name, group ); 
     1447            group = ""; 
     1448 
     1449        var jidTo = TrophyIM.rosterObj.roster[jid].contact.jid; 
     1450        var name  = TrophyIM.rosterObj.roster[jid].contact.name; 
     1451        var group = ( group ) ? group : TrophyIM.rosterObj.roster[jid].contact.groups[0]; 
     1452 
     1453        TrophyIM.rosterObj.removeContact( jid ); 
     1454                 
     1455        TrophyIM.addContact( jidTo, name, group ); 
    13851456         
    1386                 document.getElementById("JabberIMRoster").innerHTML = ""; 
    1387                  
    1388         TrophyIM.renderRoster(); 
     1457        document.getElementById("JabberIMRoster").innerHTML = ""; 
     1458                 
     1459        TrophyIM.renderRoster(); 
    13891460         
    1390         setTimeout(function() 
    1391         { 
    1392                 for( var i in presence ) 
    1393                 { 
    1394                         if ( presence[ i ].constructor == Function ) 
    1395                                 continue; 
     1461        setTimeout(function() 
     1462        { 
     1463            for( var i in presence ) 
     1464            { 
     1465                if ( presence[ i ].constructor == Function ) 
     1466                    continue; 
    13961467                                 
    1397                         TrophyIM.rosterObj.setPresence( jid, presence[i].priority, presence[i].show, presence[i].status); 
    1398                 } 
    1399         },500); 
     1468                TrophyIM.rosterObj.setPresence( jid, presence[i].priority, presence[i].show, presence[i].status); 
     1469            } 
     1470        },500); 
    14001471    }, 
    14011472 
     
    14071478    createChatRooms : function() 
    14081479    { 
    1409         var nickName     = document.getElementById('nickName_chatRoom_jabberit').value; 
    1410         var nameChatRoom = document.getElementById('name_ChatRoom_jabberit').value;  
     1480        var nickName     = document.getElementById('nickName_chatRoom_jabberit').value; 
     1481        var nameChatRoom = document.getElementById('name_ChatRoom_jabberit').value;  
    14111482         
    1412         var _from       = Base64.decode( loadscript.getUserCurrent().jid ) + TROPHYIM_RESOURCE;  
     1483        var _from       = Base64.decode( loadscript.getUserCurrent().jid ) + TROPHYIM_RESOURCE;  
    14131484        var _to         = escape( nameChatRoom ) + "@" + TROPHYIM_CHATROOM + "/" + nickName ; 
    1414         var new_room    = $pres( {from: _from, to: _to} ).c( "x", {xmlns: Strophe.NS.MUC} ); 
    1415  
    1416         TrophyIM.activeChatRoom.name[ TrophyIM.activeChatRoom.name.length ] = _to;  
    1417                  
    1418         TrophyIM.connection.send( new_room.tree() ); 
     1485        var new_room    = $pres( { 
     1486            from: _from,  
     1487            to: _to 
     1488        } ).c( "x", { 
     1489            xmlns: Strophe.NS.MUC 
     1490            } ); 
     1491 
     1492        TrophyIM.activeChatRoom.name[ TrophyIM.activeChatRoom.name.length ] = _to;  
     1493                 
     1494        TrophyIM.connection.send( new_room.tree() ); 
    14191495    }, 
    14201496     
     
    14261502    joinChatRoom : function( roomName ) 
    14271503    { 
    1428         var presence = $pres( {from: TrophyIM.connection.jid, to: roomName} ).c("x",{xmlns: Strophe.NS.MUC}); 
     1504        var presence = $pres( { 
     1505            from: TrophyIM.connection.jid,  
     1506            to: roomName 
     1507        } ).c("x",{ 
     1508            xmlns: Strophe.NS.MUC 
     1509            }); 
    14291510         
    1430         TrophyIM.connection.send( presence ); 
     1511        TrophyIM.connection.send( presence ); 
    14311512    }, 
    14321513     
     
    14381519    leaveChatRoom : function( roomName ) 
    14391520    { 
    1440         var room_nick   = roomName; 
     1521        var room_nick   = roomName; 
    14411522         
    14421523        var presenceid  = TrophyIM.connection.getUniqueId(); 
    14431524         
    1444         var presence    = $pres( {type: "unavailable", id: presenceid, from: TrophyIM.connection.jid, to: room_nick} ).c("x",{xmlns: Strophe.NS.MUC}); 
     1525        var presence    = $pres( { 
     1526            type: "unavailable",  
     1527            id: presenceid,  
     1528            from: TrophyIM.connection.jid,  
     1529            to: room_nick 
     1530        } ).c("x",{ 
     1531            xmlns: Strophe.NS.MUC 
     1532            }); 
    14451533         
    14461534        TrophyIM.connection.send( presence );         
     
    14541542    getListRooms : function() 
    14551543    { 
    1456         if( TrophyIM.statusConn.connected ) 
    1457         { 
    1458                 var _error_return = function(element) 
    1459                 { 
    1460                         alert("ERRO : Tente novamente !"); 
    1461                 }; 
     1544        if( TrophyIM.statusConn.connected ) 
     1545        { 
     1546            var _error_return = function(element) 
     1547            { 
     1548                alert("ERRO : Tente novamente !"); 
     1549            }; 
    14621550                 
    1463                 var iq = $iq({to: TROPHYIM_CHATROOM, type: "get"}).c("query",{xmlns: Strophe.NS.DISCO_ITEMS});                   
     1551            var iq = $iq({ 
     1552                to: TROPHYIM_CHATROOM,  
     1553                type: "get" 
     1554            }).c("query",{ 
     1555                xmlns: Strophe.NS.DISCO_ITEMS 
     1556                });              
    14641557                         
    1465                 TrophyIM.connection.sendIQ( iq, loadscript.listRooms, _error_return, 500 ); 
    1466         } 
    1467         else 
    1468         { 
    1469                 alert( "ERRO : Sem conexão com o servidor " + TROPHYIM_CHATROOM ); 
    1470         } 
     1558            TrophyIM.connection.sendIQ( iq, loadscript.listRooms, _error_return, 500 ); 
     1559        } 
     1560        else 
     1561        { 
     1562            alert( "ERRO : Sem conexão com o servidor " + TROPHYIM_CHATROOM ); 
     1563        } 
    14711564    }, 
    14721565     
     
    14791572    removeContact : function( jidTo ) 
    14801573    { 
    1481         var divItenContact       = null; 
    1482  
    1483         if( ( divItenContact = document.getElementById('itenContact_' + jidTo ))) 
    1484         {        
    1485                 // Remove Contact 
    1486                 var _id = TrophyIM.connection.getUniqueId();     
     1574        var divItenContact       = null; 
     1575 
     1576        if( ( divItenContact = document.getElementById('itenContact_' + jidTo ))) 
     1577        {        
     1578            // Remove Contact 
     1579            var _id     = TrophyIM.connection.getUniqueId();     
    14871580                 
    1488                 // Controller Result 
    1489                 TrophyIM.removeResult.idResult[ TrophyIM.removeResult.idResult.length ] = jidTo; 
    1490  
    1491                 var delContact  = $iq({type: 'set', id: _id}) 
    1492                         delContact      = delContact.c('query').attrs({xmlns : 'jabber:iq:roster'}); 
    1493                         delContact      = delContact.c('item').attrs({jid: jidTo, subscription:'remove'}).tree(); 
    1494  
    1495                 TrophyIM.connection.send( delContact ); 
     1581            // Controller Result 
     1582            TrophyIM.removeResult.idResult[ TrophyIM.removeResult.idResult.length ] = jidTo; 
     1583 
     1584            var delContact      = $iq({ 
     1585                type: 'set',  
     1586                id: _id 
     1587            }) 
     1588            delContact  = delContact.c('query').attrs({ 
     1589                xmlns : 'jabber:iq:roster' 
     1590            }); 
     1591            delContact  = delContact.c('item').attrs({ 
     1592                jid: jidTo,  
     1593                subscription:'remove' 
     1594            }).tree(); 
     1595 
     1596            TrophyIM.connection.send( delContact ); 
    14961597                 
    1497                         loadscript.removeElement( document.getElementById('itenContactNotification_' + jidTo ) ); 
     1598            loadscript.removeElement( document.getElementById('itenContactNotification_' + jidTo ) ); 
    14981599                 
    1499                 var spanShow = document.getElementById('span_show_itenContact_' + jidTo ) 
    1500                         spanShow.parentNode.removeChild(spanShow); 
     1600            var spanShow = document.getElementById('span_show_itenContact_' + jidTo ) 
     1601            spanShow.parentNode.removeChild(spanShow); 
    15011602                 
    1502                 loadscript.removeGroup( divItenContact.parentNode ); 
     1603            loadscript.removeGroup( divItenContact.parentNode ); 
    15031604                 
    1504                 divItenContact.parentNode.removeChild(divItenContact); 
    1505         } 
     1605            divItenContact.parentNode.removeChild(divItenContact); 
     1606        } 
    15061607    }, 
    15071608     
     
    15121613     */ 
    15131614     
    1514         renderRoster : function() 
    1515         { 
    1516                 var roster_div = document.getElementById('JabberIMRoster'); 
    1517                  
    1518                 if( roster_div ) 
    1519                 { 
    1520                         var users = new Array(); 
    1521                          
    1522                         var loading_gif = document.getElementById("JabberIMRosterLoadingGif"); 
    1523                          
    1524                         if( loading_gif.style.display == "block" ) 
    1525                                 loading_gif.style.display = "none"; 
     1615    renderRoster : function() 
     1616    { 
     1617        var roster_div = document.getElementById('JabberIMRoster'); 
     1618                 
     1619        if( roster_div ) 
     1620        { 
     1621            var users = new Array(); 
     1622                         
     1623            var loading_gif = document.getElementById("JabberIMRosterLoadingGif"); 
     1624                         
     1625            if( loading_gif.style.display == "block" ) 
     1626                loading_gif.style.display = "none"; 
    15261627                                 
    1527                         for( var user in TrophyIM.rosterObj.roster ) 
    1528                         { 
    1529                                 if ( TrophyIM.rosterObj.roster[ user ].constructor == Function ) 
    1530                                         continue; 
    1531  
    1532                                 users[users.length] = TrophyIM.rosterObj.roster[user].contact.jid; 
    1533                         } 
    1534  
    1535                         users.sort(); 
    1536                          
    1537                         var groups              = new Array(); 
    1538                         var flagGeral   = false; 
    1539                          
    1540                         for (var group in TrophyIM.rosterObj.groups) 
    1541                         { 
    1542                                 if ( TrophyIM.rosterObj.groups[ group ].constructor == Function ) 
    1543                                         continue; 
     1628            for( var user in TrophyIM.rosterObj.roster ) 
     1629            { 
     1630                if ( TrophyIM.rosterObj.roster[ user ].constructor == Function ) 
     1631                    continue; 
     1632 
     1633                users[users.length] = TrophyIM.rosterObj.roster[user].contact.jid; 
     1634            } 
     1635 
     1636            users.sort(); 
     1637                         
     1638            var groups          = new Array(); 
     1639            var flagGeral       = false; 
     1640                         
     1641            for (var group in TrophyIM.rosterObj.groups) 
     1642            { 
     1643                if ( TrophyIM.rosterObj.groups[ group ].constructor == Function ) 
     1644                    continue; 
    15441645                                 
    1545                                 if( group ) 
    1546                                         groups[groups.length] = group; 
     1646                if( group ) 
     1647                    groups[groups.length] = group; 
    15471648                                 
    1548                                 if( group == "Geral" ) 
    1549                                         flagGeral = true; 
     1649                if( group == "Geral" ) 
     1650                    flagGeral = true; 
    15501651            } 
    15511652             
    1552                         if( !flagGeral && users.length > 0 ) 
    1553                                 groups[groups.length] = "Geral"; 
     1653            if( !flagGeral && users.length > 0 ) 
     1654                groups[groups.length] = "Geral"; 
    15541655                                 
    1555                         groups.sort(); 
    1556                          
    1557                         for ( var i = 0; i < groups.length; i++ ) 
    1558                         { 
    1559                                 TrophyIM.renderGroups( groups[i] , roster_div );         
    1560                         } 
    1561                          
    1562                         TrophyIM.renderItensGroup( users, roster_div ); 
    1563                 } 
    1564                          
    1565                 TrophyIM._timeOut.renderRoster = setTimeout("TrophyIM.renderRoster()", 1000 );           
    1566         }, 
     1656            groups.sort(); 
     1657                         
     1658            for ( var i = 0; i < groups.length; i++ ) 
     1659            { 
     1660                TrophyIM.renderGroups( groups[i] , roster_div );         
     1661            } 
     1662                         
     1663            TrophyIM.renderItensGroup( users, roster_div ); 
     1664        } 
     1665                         
     1666        TrophyIM._timeOut.renderRoster = setTimeout("TrophyIM.renderRoster()", 1000 );           
     1667    }, 
    15671668         
    15681669    /** Function: renderGroups 
     
    15711672     */ 
    15721673         
    1573         renderGroups: function( nameGroup, element ) 
    1574         { 
    1575                 var _addGroup = function() 
    1576                 { 
    1577                         var _nameGroup  = nameGroup; 
    1578                         var _element    = element; 
    1579  
    1580                         var paramsGroup =  
    1581                         { 
    1582                                 'nameGroup'     : _nameGroup, 
    1583                                 'path_jabberit' : path_jabberit 
    1584                         } 
    1585                          
    1586                         _element.innerHTML += loadscript.parse("group","groups.xsl", paramsGroup); 
    1587                 } 
    1588  
    1589                 if( !element.hasChildNodes() ) 
    1590                 { 
    1591                         _addGroup(); 
    1592                 } 
    1593                 else 
    1594                 { 
    1595                         var _NodeChild  = element.firstChild; 
    1596                         var flagAdd             = false; 
    1597                          
    1598                         while( _NodeChild ) 
    1599                         { 
    1600                                 if( _NodeChild.childNodes[0].nodeName.toLowerCase() === "span" ) 
    1601                                 { 
    1602                                         if( _NodeChild.childNodes[0].childNodes[0].nodeValue === nameGroup ) 
    1603                                         { 
    1604                                                 flagAdd = true; 
    1605                                         } 
    1606                                 } 
     1674    renderGroups: function( nameGroup, element ) 
     1675    { 
     1676        var _addGroup = function() 
     1677        { 
     1678            var _nameGroup      = nameGroup; 
     1679            var _element        = element; 
     1680 
     1681            var paramsGroup =  
     1682            { 
     1683                'nameGroup'     : _nameGroup, 
     1684                'path_jabberit' : path_jabberit 
     1685            } 
     1686                         
     1687            _element.innerHTML += loadscript.parse("group","groups.xsl", paramsGroup); 
     1688        } 
     1689 
     1690        if( !element.hasChildNodes() ) 
     1691        { 
     1692            _addGroup(); 
     1693        } 
     1694        else 
     1695        { 
     1696            var _NodeChild      = element.firstChild; 
     1697            var flagAdd         = false; 
     1698                         
     1699            while( _NodeChild ) 
     1700            { 
     1701                if( _NodeChild.childNodes[0].nodeName.toLowerCase() === "span" ) 
     1702                { 
     1703                    if( _NodeChild.childNodes[0].childNodes[0].nodeValue === nameGroup ) 
     1704                    { 
     1705                        flagAdd = true; 
     1706                    } 
     1707                } 
    16071708                                 
    1608                                 _NodeChild = _NodeChild.nextSibling; 
    1609                         } 
    1610  
    1611                         if( !flagAdd ) 
    1612                         { 
    1613                                 _addGroup(); 
    1614                         } 
    1615                 } 
    1616         }, 
     1709                _NodeChild = _NodeChild.nextSibling; 
     1710            } 
     1711 
     1712            if( !flagAdd ) 
     1713            { 
     1714                _addGroup(); 
     1715            } 
     1716        } 
     1717    }, 
    16171718 
    16181719    /** Function: renderItensGroup 
     
    16211722     */ 
    16221723 
    1623         renderItensGroup : function( users, element ) 
    1624         { 
    1625                 var addItem = function() 
    1626                 { 
    1627                         if( arguments.length > 0 ) 
    1628                         { 
    1629                                 // Get Arguments 
    1630                                 var objContact  = arguments[0]; 
    1631                                 var group               = arguments[1]; 
    1632                                 var element             = arguments[2]; 
    1633                                 var showOffline = loadscript.getShowContactsOffline(); 
     1724    renderItensGroup : function( users, element ) 
     1725    { 
     1726        var addItem = function() 
     1727        { 
     1728            if( arguments.length > 0 ) 
     1729            { 
     1730                // Get Arguments 
     1731                var objContact  = arguments[0]; 
     1732                var group               = arguments[1]; 
     1733                var element             = arguments[2]; 
     1734                var showOffline = loadscript.getShowContactsOffline(); 
    16341735                                 
    1635                                 // Presence e Status 
    1636                                 var presence            = "unavailable"; 
    1637                                 var status                      = ""; 
    1638                                 var statusColor         = "black"; 
    1639                                 var statusDisplay       = "none"; 
     1736                // Presence e Status 
     1737                var presence            = "unavailable"; 
     1738                var status                      = ""; 
     1739                var statusColor         = "black"; 
     1740                var statusDisplay       = "none"; 
    16401741                                 
    1641                                 var _resource   = ""; 
     1742                var _resource   = ""; 
    16421743                                 
    1643                                 // Set Presence  
    1644                                 var _presence = function(objContact) 
    1645                                 { 
    1646                                         if (objContact.presence) 
    1647                                         { 
    1648                                                 for (var resource in objContact.presence) 
    1649                                                 { 
    1650                                                         if ( objContact.presence[resource].constructor == Function ) 
    1651                                                                 continue; 
    1652  
    1653                                                         if( objContact.presence[resource].show != 'invisible' ) 
    1654                                                                 presence = objContact.presence[resource].show; 
    1655  
    1656                                                         if( objContact.contact.subscription != "both")  
    1657                                                                 presence = 'subscription'; 
     1744                // Set Presence  
     1745                var _presence = function(objContact) 
     1746                { 
     1747                    if (objContact.presence) 
     1748                    { 
     1749                        for (var resource in objContact.presence) 
     1750                        { 
     1751                            if ( objContact.presence[resource].constructor == Function ) 
     1752                                continue; 
     1753 
     1754                            if( objContact.presence[resource].show != 'invisible' ) 
     1755                                presence = objContact.presence[resource].show; 
     1756 
     1757                            if( objContact.contact.subscription != "both")  
     1758                                presence = 'subscription'; 
    16581759                                                         
    1659                                                         if( objContact.presence[resource].status ) 
    1660                                                         { 
    1661                                                                 status = " ( " + objContact.presence[resource].status + " ) "; 
    1662                                                                 statusDisplay   = "block"; 
    1663                                                         } 
    1664                                                 } 
    1665                                         } 
    1666                                 }; 
     1760                            if( objContact.presence[resource].status ) 
     1761                            { 
     1762                                status = " ( " + objContact.presence[resource].status + " ) "; 
     1763                                statusDisplay   = "block"; 
     1764                            } 
     1765                        } 
     1766                    } 
     1767                }; 
    16671768                                 
    1668                                 // Set Subscription 
    1669                                 var _subscription = function( objContact ) 
    1670                                 { 
    1671                                         if( objContact.contact.subscription != "both" ) 
    1672                                         { 
    1673                                                 switch( objContact.contact.subscription ) 
    1674                                                 { 
    1675                                                         case "none" : 
     1769                // Set Subscription 
     1770                var _subscription = function( objContact ) 
     1771                { 
     1772                    if( objContact.contact.subscription != "both" ) 
     1773                    { 
     1774                        switch( objContact.contact.subscription ) 
     1775                        { 
     1776                            case "none" : 
    16761777                                                                 
    1677                                                                 status          = " (( " + i18n.ASK_FOR_AUTH  + " )) "; 
    1678                                                                 statusColor     = "red"; 
    1679                                                                 break; 
    1680          
    1681                                                         case "to" : 
     1778                                status          = " (( " + i18n.ASK_FOR_AUTH  + " )) "; 
     1779                                statusColor     = "red"; 
     1780                                break; 
     1781         
     1782                            case "to" : 
    16821783                                                                 
    1683                                                                 status          = " (( " + i18n.CONTACT_ASK_FOR_AUTH  + " )) "; 
    1684                                                                 statusColor     = "orange"; 
    1685                                                                 break; 
    1686          
    1687                                                         case "from" : 
     1784                                status          = " (( " + i18n.CONTACT_ASK_FOR_AUTH  + " )) "; 
     1785                                statusColor     = "orange"; 
     1786                                break; 
     1787         
     1788                            case "from" : 
    16881789                                                                 
    1689                                                                 status          = " (( " + i18n.AUTHORIZED + " )) "; 
    1690                                                                 statusColor = "green"; 
    1691                                                                 break; 
     1790                                status          = " (( " + i18n.AUTHORIZED + " )) "; 
     1791                                statusColor = "green"; 
     1792                                break; 
    16921793                                                                 
    1693                                                         case "subscribe" : 
     1794                            case "subscribe" : 
    16941795                                                                 
    1695                                                                 status          = " (( " + i18n.AUTH_SENT  + " )) "; 
    1696                                                                 statusColor     = "red";         
    1697                                                                 break; 
    1698  
    1699                                                         case "not-in-roster" : 
     1796                                status          = " (( " + i18n.AUTH_SENT  + " )) "; 
     1797                                statusColor     = "red";         
     1798                                break; 
     1799 
     1800                            case "not-in-roster" : 
    17001801                                                                 
    1701                                                                 status          = " (( " + i18n.ASK_FOR_AUTH_QUESTION  + " )) "; 
    1702                                                                 statusColor     = "orange";      
    1703                                                                 break; 
     1802                                status          = " (( " + i18n.ASK_FOR_AUTH_QUESTION  + " )) "; 
     1803                                statusColor     = "orange";      
     1804                                break; 
    17041805                                                                 
    1705                                                         default : 
     1806                            default : 
    17061807                                                                 
    1707                                                                 break; 
    1708                                                 } 
    1709  
    1710                                                 statusDisplay = "block"; 
    1711                                         } 
    1712                                 }; 
    1713  
    1714                                 if( objContact.contact.subscription != "remove") 
    1715                                 { 
    1716                                         var itensJid    = document.getElementById( "itenContact_" + objContact.contact.jid ); 
     1808                                break; 
     1809                        } 
     1810 
     1811                        statusDisplay = "block"; 
     1812                    } 
     1813                }; 
     1814 
     1815                if( objContact.contact.subscription != "remove") 
     1816                { 
     1817                    var itensJid        = document.getElementById( "itenContact_" + objContact.contact.jid ); 
    17171818                                         
    1718                                         if( itensJid == null ) 
    1719                                         { 
    1720                                                 // Name 
    1721                                                 var nameContact = "";                                    
     1819                    if( itensJid == null ) 
     1820                    { 
     1821                        // Name 
     1822                        var nameContact = "";                                    
    17221823                                                 
    1723                                                 if ( objContact.contact.name )  
    1724                                                         nameContact = objContact.contact.name; 
    1725                                                 else 
    1726                                                 { 
    1727                                                         nameContact = objContact.contact.jid; 
    1728                                                         nameContact = nameContact.substring(0, nameContact.indexOf('@')); 
    1729                                                 } 
     1824                        if ( objContact.contact.name )  
     1825                            nameContact = objContact.contact.name; 
     1826                        else 
     1827                        { 
     1828                            nameContact = objContact.contact.jid; 
     1829                            nameContact = nameContact.substring(0, nameContact.indexOf('@')); 
     1830                        } 
    17301831                                                 
    1731                                                 // Get Presence 
    1732                                                 _presence(objContact); 
     1832                        // Get Presence 
     1833                        _presence(objContact); 
    17331834                                                 
    1734                                                 var paramsContact = 
    1735                                                 { 
    1736                                                         divDisplay              : "block",  
    1737                                                         id                              : 'itenContact_' + objContact.contact.jid , 
    1738                                                         jid                             : objContact.contact.jid, 
    1739                                                         nameContact     : nameContact, 
    1740                                                         path_jabberit   : path_jabberit, 
    1741                                                         presence                : presence, 
    1742                                                         spanDisplay             : statusDisplay, 
    1743                                                         status                  : status, 
    1744                                                         statusColor             : "black", 
    1745                                                         subscription    : objContact.contact.subscription, 
    1746                                                         resource                : _resource 
    1747                                                 } 
     1835                        var paramsContact = 
     1836                        { 
     1837                            divDisplay          : "block",  
     1838                            id                          : 'itenContact_' + objContact.contact.jid , 
     1839                            jid                         : objContact.contact.jid, 
     1840                            nameContact         : nameContact, 
     1841                            path_jabberit       : path_jabberit, 
     1842                            presence            : presence, 
     1843                            spanDisplay         : statusDisplay, 
     1844                            status                      : status, 
     1845                            statusColor         : "black", 
     1846                            subscription        : objContact.contact.subscription, 
     1847                            resource            : _resource 
     1848                        } 
    17481849                                                 
    1749                                                 // Get Authorization 
    1750                                                 _subscription( objContact ); 
     1850                        // Get Authorization 
     1851                        _subscription( objContact ); 
    17511852                                                 
    1752                                                 if( group != "") 
    1753                                                 { 
    1754                                                         var _NodeChild          = element.firstChild; 
     1853                        if( group != "") 
     1854                        { 
     1855                            var _NodeChild              = element.firstChild; 
    17551856                                                         
    1756                                                         while( _NodeChild ) 
    1757                                                         { 
    1758                                                                 if( _NodeChild.childNodes[0].nodeName.toLowerCase() === "span" ) 
    1759                                                                 { 
    1760                                                                         if( _NodeChild.childNodes[0].childNodes[0].nodeValue === group ) 
    1761                                                                         { 
    1762                                                                                 _NodeChild.innerHTML += loadscript.parse("itens_group", "itensGroup.xsl", paramsContact); 
    1763                                                                         } 
    1764                                                                 } 
    1765          
    1766                                                                 _NodeChild = _NodeChild.nextSibling; 
    1767                                                         } 
    1768                                                 }        
    1769                                         } 
    1770                                         else 
    1771                                         { 
    1772                                                 // Get Presence 
    1773                                                 _presence(objContact); 
    1774          
    1775                                                 var is_open = itensJid.parentNode.childNodes[0].style.backgroundImage;   
    1776                                                         is_open = is_open.indexOf("arrow_down.gif"); 
    1777          
    1778                                                 // Get Authorization 
    1779                                                 _subscription( objContact ); 
     1857                            while( _NodeChild ) 
     1858                            { 
     1859                                if( _NodeChild.childNodes[0].nodeName.toLowerCase() === "span" ) 
     1860                                { 
     1861                                    if( _NodeChild.childNodes[0].childNodes[0].nodeValue === group ) 
     1862                                    { 
     1863                                        _NodeChild.innerHTML += loadscript.parse("itens_group", "itensGroup.xsl", paramsContact); 
     1864                                    } 
     1865                                } 
     1866         
     1867                                _NodeChild = _NodeChild.nextSibling; 
     1868                            } 
     1869                        }        
     1870                    } 
     1871                    else 
     1872                    { 
     1873                        // Get Presence 
     1874                        _presence(objContact); 
     1875         
     1876                        var is_open = itensJid.parentNode.childNodes[0].style.backgroundImage;   
     1877                        is_open = is_open.indexOf("arrow_down.gif"); 
     1878         
     1879                        // Get Authorization 
     1880                        _subscription( objContact ); 
    17801881                                                 
    1781                                                 // Set subscription 
    1782                                                 itensJid.setAttribute('subscription', objContact.contact.subscription ); 
     1882                        // Set subscription 
     1883                        itensJid.setAttribute('subscription', objContact.contact.subscription ); 
    17831884                                                 
    1784                                                 with ( document.getElementById('span_show_' + 'itenContact_' + objContact.contact.jid ) ) 
    1785                                                 { 
    1786                                                         if( presence == "unavailable" && !showOffline ) 
    1787                                                         { 
    1788                                                                 style.display = "none"; 
    1789                                                         } 
    1790                                                         else 
    1791                                                         { 
    1792                                                                 if( is_open > 0 ) 
    1793                                                                 { 
    1794                                                                         style.display   = statusDisplay; 
    1795                                                                         style.color             = statusColor; 
    1796                                                                         innerHTML               = status; 
    1797                                                                 } 
    1798                                                         } 
    1799                                                 } 
     1885                        with ( document.getElementById('span_show_' + 'itenContact_' + objContact.contact.jid ) ) 
     1886                        { 
     1887                            if( presence == "unavailable" && !showOffline ) 
     1888                            { 
     1889                                style.display = "none"; 
     1890                            } 
     1891                            else 
     1892                            { 
     1893                                if( is_open > 0 ) 
     1894                                { 
     1895                                    style.display       = statusDisplay; 
     1896                                    style.color         = statusColor; 
     1897                                    innerHTML           = status; 
     1898                                } 
     1899                            } 
     1900                            } 
    18001901                                                 
    1801                                                 if( presence == "unavailable" && !showOffline ) 
    1802                                                 { 
    1803                                                         itensJid.style.display = "none"; 
    1804                                                 } 
    1805                                                 else 
    1806                                                 { 
    1807                                                         if( is_open > 0 ) 
    1808                                                         { 
    1809                                                                 itensJid.style.display = "block"; 
    1810                                                         } 
    1811                                                 } 
     1902                        if( presence == "unavailable" && !showOffline ) 
     1903                        { 
     1904                            itensJid.style.display = "none"; 
     1905                        } 
     1906                        else 
     1907                        { 
     1908                            if( is_open > 0 ) 
     1909                            { 
     1910                                itensJid.style.display = "block"; 
     1911                            } 
     1912                        } 
    18121913                                                 
    1813                                                 itensJid.style.background       = "url('"+path_jabberit+"templates/default/images/" + presence + ".gif') no-repeat center left"; 
    1814                                         } 
    1815          
    1816                                         // Contact OffLine 
    1817                                         if( !objContact.presence && !showOffline ) 
    1818                                         { 
    1819                                                 if( objContact.contact.subscription != "remove" ) 
    1820                                                 { 
    1821                                                         with ( document.getElementById('span_show_' + 'itenContact_' + objContact.contact.jid )) 
    1822                                                         { 
    1823                                                                 style.display   = "none"; 
    1824                                                         } 
    1825                  
    1826                                                         with ( document.getElementById('itenContact_' + objContact.contact.jid ) ) 
    1827                                                         { 
    1828                                                                 style.display   = "none"; 
    1829                                                         } 
    1830                                                 } 
    1831                                         } 
    1832                                 } 
    1833                         } 
    1834                 }; 
    1835                  
    1836                 var flag = false; 
    1837                  
    1838                 for( var i = 0 ; i < users.length; i++ ) 
    1839                 { 
    1840                         if( TrophyIM.rosterObj.roster[users[i]].contact.jid != Base64.decode( loadscript.getUserCurrent().jid) ) 
    1841                         { 
    1842                                 var _subscription = TrophyIM.rosterObj.roster[users[i]].contact.subscription; 
     1914                        itensJid.style.background       = "url('"+path_jabberit+"templates/default/images/" + presence + ".gif') no-repeat center left"; 
     1915                    } 
     1916         
     1917                    // Contact OffLine 
     1918                    if( !objContact.presence && !showOffline ) 
     1919                    { 
     1920                        if( objContact.contact.subscription != "remove" ) 
     1921                        { 
     1922                            with ( document.getElementById('span_show_' + 'itenContact_' + objContact.contact.jid )) 
     1923                            { 
     1924                                style.display   = "none"; 
     1925                                } 
     1926                 
     1927                            with ( document.getElementById('itenContact_' + objContact.contact.jid ) ) 
     1928                            { 
     1929                                style.display   = "none"; 
     1930                                } 
     1931                        } 
     1932                    } 
     1933                } 
     1934            } 
     1935        }; 
     1936                 
     1937        var flag = false; 
     1938                 
     1939        for( var i = 0 ; i < users.length; i++ ) 
     1940        { 
     1941            if( TrophyIM.rosterObj.roster[users[i]].contact.jid != Base64.decode( loadscript.getUserCurrent().jid) ) 
     1942            { 
     1943                var _subscription = TrophyIM.rosterObj.roster[users[i]].contact.subscription; 
    18431944                                 
    1844                                 if( _subscription === "to" ) 
    1845                                 { 
    1846                                         flag = true; 
    1847                                 } 
     1945                if( _subscription === "to" ) 
     1946                { 
     1947                    flag = true; 
     1948                } 
    18481949                                 
    1849                                 if(  _subscription === "not-in-roster") 
    1850                                 { 
    1851                                         flag = true; 
    1852                                 } 
     1950                if(  _subscription === "not-in-roster") 
     1951                { 
     1952                    flag = true; 
     1953                } 
    18531954                                 
    1854                                 if( TrophyIM.rosterObj.roster[users[i]].contact.groups ) 
    1855                                 { 
    1856                                         var groups = TrophyIM.rosterObj.roster[users[i]].contact.groups; 
     1955                if( TrophyIM.rosterObj.roster[users[i]].contact.groups ) 
     1956                { 
     1957                    var groups = TrophyIM.rosterObj.roster[users[i]].contact.groups; 
    18571958                                         
    1858                                         if( groups.length > 0 ) 
    1859                                         { 
    1860                                                 for( var j = 0; j < groups.length; j++ ) 
    1861                                                 { 
    1862                                                         addItem( TrophyIM.rosterObj.roster[users[i]], groups[j], element ); 
    1863                                                 } 
    1864                                         } 
    1865                                         else 
    1866                                         { 
    1867                                                 addItem( TrophyIM.rosterObj.roster[users[i]], "Geral", element ); 
    1868                                         } 
    1869                                 } 
    1870                                 else 
    1871                                 { 
    1872                                         addItem( TrophyIM.rosterObj.roster[users[i]], "Geral", element ); 
    1873                                 } 
    1874                         } 
    1875                 } 
    1876                  
    1877                 if( flag ) 
    1878                 { 
    1879                         if ( TrophyIM.controll.notificationNewUsers == 0 ) 
    1880                         { 
    1881                                 loadscript.enabledNotificationNewUsers(); 
    1882                                 TrophyIM.controll.notificationNewUsers++; 
    1883                         } 
    1884                 } 
    1885                 else 
    1886                 { 
    1887                         loadscript.disabledNotificationNewUsers(); 
    1888                         TrophyIM.controll.notificationNewUsers = 0; 
    1889                 } 
    1890         }, 
     1959                    if( groups.length > 0 ) 
     1960                    { 
     1961                        for( var j = 0; j < groups.length; j++ ) 
     1962                        { 
     1963                            addItem( TrophyIM.rosterObj.roster[users[i]], groups[j], element ); 
     1964                        } 
     1965                    } 
     1966                    else 
     1967                    { 
     1968                        addItem( TrophyIM.rosterObj.roster[users[i]], "Geral", element ); 
     1969                    } 
     1970                } 
     1971                else 
     1972                { 
     1973                    addItem( TrophyIM.rosterObj.roster[users[i]], "Geral", element ); 
     1974                } 
     1975            } 
     1976        } 
     1977                 
     1978        if( flag ) 
     1979        { 
     1980            if ( TrophyIM.controll.notificationNewUsers == 0 ) 
     1981            { 
     1982                loadscript.enabledNotificationNewUsers(); 
     1983                TrophyIM.controll.notificationNewUsers++; 
     1984            } 
     1985        } 
     1986        else 
     1987        { 
     1988            loadscript.disabledNotificationNewUsers(); 
     1989            TrophyIM.controll.notificationNewUsers = 0; 
     1990        } 
     1991    }, 
    18911992 
    18921993    /** Function: rosterClick 
     
    18951996     */ 
    18961997     
    1897         rosterClick : function(fulljid) 
    1898         { 
     1998    rosterClick : function(fulljid) 
     1999    { 
    18992000        TrophyIM.makeChat(fulljid); 
    19002001    }, 
    19012002 
    1902         /** Function SetAutorization 
     2003    /** Function SetAutorization 
    19032004         *  
    19042005         */ 
    19052006 
    1906         setAutorization : function( jidTo, jidFrom, _typeSubscription ) 
    1907         { 
    1908         var _id = TrophyIM.connection.getUniqueId(); 
     2007    setAutorization : function( jidTo, jidFrom, _typeSubscription ) 
     2008    { 
     2009        var _id = TrophyIM.connection.getUniqueId(); 
    19092010         
    1910         TrophyIM.connection.send($pres( ).attrs({from: jidFrom, to: jidTo, type: _typeSubscription, id: _id}).tree()); 
    1911         }, 
    1912  
    1913         /** Function: setPresence 
    1914      * 
    1915      */ 
    1916  
    1917         setPresence : function( _type ) 
    1918         { 
    1919                 var presence_chatRoom = ""; 
    1920                  
    1921                 if( _type != 'status') 
    1922                 { 
    1923                         if( _type == "unavailable" &&  TrophyIM.statusConn.connected ) 
    1924                         { 
    1925                                 var loading_gif = document.getElementById("JabberIMRosterLoadingGif"); 
     2011        TrophyIM.connection.send($pres( ).attrs({ 
     2012            from: jidFrom,  
     2013            to: jidTo,  
     2014            type: _typeSubscription,  
     2015            id: _id 
     2016        }).tree()); 
     2017    }, 
     2018 
     2019    /** Function: setPresence 
     2020     * 
     2021     */ 
     2022 
     2023    setPresence : function( _type ) 
     2024    { 
     2025        var presence_chatRoom = ""; 
     2026                 
     2027        if( _type != 'status') 
     2028        { 
     2029            if( _type == "unavailable" &&  TrophyIM.statusConn.connected ) 
     2030            { 
     2031                var loading_gif = document.getElementById("JabberIMRosterLoadingGif"); 
    19262032                                 
    1927                                 if( TrophyIM._timeOut.renderRoster != null ) 
    1928                                         clearTimeout(TrophyIM._timeOut.renderRoster); 
     2033                if( TrophyIM._timeOut.renderRoster != null ) 
     2034                    clearTimeout(TrophyIM._timeOut.renderRoster); 
    19292035                                 
    1930                                 if( TrophyIM.statusConn.connected ) 
    1931                                         TrophyIM.connection.send($pres({type : _type}).tree()); 
     2036                if( TrophyIM.statusConn.connected ) 
     2037                    TrophyIM.connection.send($pres({ 
     2038                        type : _type 
     2039                    }).tree()); 
    19322040                                 
    1933                                 for( var i = 0; i < TrophyIM.connection._requests.length; i++ ) 
    1934                         { 
    1935                                 if( TrophyIM.connection._requests[i] ) 
    1936                                         TrophyIM.connection._removeRequest(TrophyIM.connection._requests[i]); 
    1937                         } 
     2041                for( var i = 0; i < TrophyIM.connection._requests.length; i++ ) 
     2042                { 
     2043                    if( TrophyIM.connection._requests[i] ) 
     2044                        TrophyIM.connection._removeRequest(TrophyIM.connection._requests[i]); 
     2045                } 
    19382046                                 
    1939                                 TrophyIM.logout(); 
     2047                TrophyIM.logout(); 
    19402048                                 
    1941                         loadscript.clrAllContacts(); 
     2049                loadscript.clrAllContacts(); 
    19422050                         
    1943                         delete TrophyIM.rosterObj.roster; 
    1944                         delete TrophyIM.rosterObj.groups; 
     2051                delete TrophyIM.rosterObj.roster; 
     2052                delete TrophyIM.rosterObj.groups; 
    19452053                         
    1946                         setTimeout(function() 
    1947                         { 
    1948                                         if( loading_gif.style.display == "block" ) 
    1949                                                 loading_gif.style.display = "none"; 
    1950                         }, 1000); 
    1951                         } 
    1952                         else 
    1953                         { 
    1954                                 if( !TrophyIM.autoConnection.connect ) 
    1955                                 { 
    1956                                         TrophyIM.autoConnection.connect = true; 
    1957                                         TrophyIM.load(); 
    1958                                 } 
    1959                                 else 
    1960                                 { 
    1961                                         if( TrophyIM.statusConn.connected ) 
    1962                                         { 
    1963                                                 if( loadscript.getStatusMessage() != "" ) 
    1964                                                 { 
    1965                                                         var _presence = $pres( ); 
    1966                                                         _presence.node.appendChild( Strophe.xmlElement( 'show' ) ).appendChild( Strophe.xmlTextNode( _type ) ); 
    1967                                                         _presence.node.appendChild( Strophe.xmlElement( 'status' ) ).appendChild( Strophe.xmlTextNode( loadscript.getStatusMessage() )); 
     2054                setTimeout(function() 
     2055                { 
     2056                    if( loading_gif.style.display == "block" ) 
     2057                        loading_gif.style.display = "none"; 
     2058                }, 1000); 
     2059            } 
     2060            else 
     2061            { 
     2062                if( !TrophyIM.autoConnection.connect ) 
     2063                { 
     2064                    TrophyIM.autoConnection.connect = true; 
     2065                    TrophyIM.load(); 
     2066                } 
     2067                else 
     2068                { 
     2069                    if( TrophyIM.statusConn.connected ) 
     2070                    { 
     2071                        if( loadscript.getStatusMessage() != "" ) 
     2072                        { 
     2073                            var _presence = $pres( ); 
     2074                            _presence.node.appendChild( Strophe.xmlElement( 'show' ) ).appendChild( Strophe.xmlTextNode( _type ) ); 
     2075                            _presence.node.appendChild( Strophe.xmlElement( 'status' ) ).appendChild( Strophe.xmlTextNode( loadscript.getStatusMessage() )); 
    19682076                                                         
    1969                                                         TrophyIM.connection.send( _presence.tree() ); 
     2077                            TrophyIM.connection.send( _presence.tree() ); 
    19702078                                                         
    1971                                                         presence_chatRoom = _type; 
    1972                                                 } 
    1973                                                 else 
    1974                                                 { 
    1975                                                         TrophyIM.connection.send($pres( ).c('show').t(_type).tree()); 
     2079                            presence_chatRoom = _type; 
     2080                        } 
     2081                        else 
     2082                        { 
     2083                            TrophyIM.connection.send($pres( ).c('show').t(_type).tree()); 
    19762084                                                         
    1977                                                         presence_chatRoom = _type; 
    1978                                                 } 
    1979                                         } 
    1980                                 } 
    1981                         } 
    1982                 } 
    1983                 else 
    1984                 { 
    1985                         var _show       = "available"; 
    1986                         var _status     = ""; 
    1987                          
    1988                         if( arguments.length < 2 ) 
    1989                         { 
    1990                                 if( loadscript.getStatusMessage() != "" ) 
    1991                                         _status = prompt(i18n.TYPE_YOUR_MSG, loadscript.getStatusMessage()); 
    1992                                 else 
    1993                                         _status = prompt(i18n.TYPE_YOUR_MSG); 
     2085                            presence_chatRoom = _type; 
     2086                        } 
     2087                    } 
     2088                } 
     2089            } 
     2090        } 
     2091        else 
     2092        { 
     2093            var _show   = "available"; 
     2094            var _status = ""; 
     2095                         
     2096            if( arguments.length < 2 ) 
     2097            { 
     2098                if( loadscript.getStatusMessage() != "" ) 
     2099                    _status = prompt(i18n.TYPE_YOUR_MSG, loadscript.getStatusMessage()); 
     2100                else 
     2101                    _status = prompt(i18n.TYPE_YOUR_MSG); 
    19942102                                 
    1995                                 var _divStatus = document.getElementById("JabberIMStatusMessage"); 
     2103                var _divStatus = document.getElementById("JabberIMStatusMessage"); 
    19962104                                 
    1997                                 if( ( _status = _status.replace(/^\s+|\s+$|^\n|\n$/g,"") ) != "") 
    1998                                         _divStatus.firstChild.innerHTML = "( " + _status + " )"; 
    1999                         }  
    2000                         else 
    2001                         { 
    2002                                 _status = arguments[1]; 
    2003                         } 
    2004  
    2005                         for( var resource in TrophyIM.rosterObj.roster[Base64.decode(loadscript.getUserCurrent().jid)].presence ) 
    2006                         { 
    2007                         if ( TrophyIM.rosterObj.roster[Base64.decode(loadscript.getUserCurrent().jid)].presence[ resource ].constructor == Function ) 
    2008                                 continue; 
     2105                if( ( _status = _status.replace(/^\s+|\s+$|^\n|\n$/g,"") ) != "") 
     2106                    _divStatus.firstChild.innerHTML     = "( " + _status + " )"; 
     2107            }  
     2108            else 
     2109            { 
     2110                _status = arguments[1]; 
     2111            } 
     2112 
     2113            for( var resource in TrophyIM.rosterObj.roster[Base64.decode(loadscript.getUserCurrent().jid)].presence ) 
     2114            { 
     2115                if ( TrophyIM.rosterObj.roster[Base64.decode(loadscript.getUserCurrent().jid)].presence[ resource ].constructor == Function ) 
     2116                    continue; 
    20092117                         
    2010                                 if ( TROPHYIM_RESOURCE === ("/" + resource) ) 
    2011                                         _show = TrophyIM.rosterObj.roster[Base64.decode(loadscript.getUserCurrent().jid)].presence[resource].show; 
    2012                         } 
    2013  
    2014                         if ( TrophyIM.statusConn.connected ) 
    2015                         { 
    2016                                 var _presence = $pres( ); 
    2017                                 _presence.node.appendChild( Strophe.xmlElement( 'show' ) ).appendChild( Strophe.xmlTextNode( _show ) ); 
    2018                                 _presence.node.appendChild( Strophe.xmlElement( 'status' ) ).appendChild( Strophe.xmlTextNode( _status ) ); 
     2118                if ( TROPHYIM_RESOURCE === ("/" + resource) ) 
     2119                    _show = TrophyIM.rosterObj.roster[Base64.decode(loadscript.getUserCurrent().jid)].presence[resource].show; 
     2120            } 
     2121 
     2122            if ( TrophyIM.statusConn.connected ) 
     2123            { 
     2124                var _presence = $pres( ); 
     2125                _presence.node.appendChild( Strophe.xmlElement( 'show' ) ).appendChild( Strophe.xmlTextNode( _show ) ); 
     2126                _presence.node.appendChild( Strophe.xmlElement( 'status' ) ).appendChild( Strophe.xmlTextNode( _status ) ); 
    20192127                                 
    2020                                 TrophyIM.connection.send( _presence.tree() ); 
     2128                TrophyIM.connection.send( _presence.tree() ); 
    20212129                                 
    2022                                 presence_chatRoom = _show; 
    2023                         } 
    2024                 } 
    2025                  
    2026                 // Send Presence Chat Room 
    2027                 if( TrophyIM.activeChatRoom.name.length > 0 ) 
    2028                 { 
    2029                         for( i = 0; i < TrophyIM.activeChatRoom.name.length; i++ ) 
    2030                         { 
    2031                                 if( TrophyIM.activeChatRoom.name[i] != "" ) 
    2032                                         TrophyIM.connection.send($pres( {to : TrophyIM.activeChatRoom.name[i]} ).c('show').t( presence_chatRoom ) ); 
    2033                         } 
    2034                 } 
    2035  
    2036         }, 
    2037          
    2038         /** Function: sendMessage 
     2130                presence_chatRoom = _show; 
     2131            } 
     2132        } 
     2133                 
     2134        // Send Presence Chat Room 
     2135        if( TrophyIM.activeChatRoom.name.length > 0 ) 
     2136        { 
     2137            for( i = 0; i < TrophyIM.activeChatRoom.name.length; i++ ) 
     2138            { 
     2139                if( TrophyIM.activeChatRoom.name[i] != "" ) 
     2140                    TrophyIM.connection.send($pres( { 
     2141                        to : TrophyIM.activeChatRoom.name[i] 
     2142                        } ).c('show').t( presence_chatRoom ) ); 
     2143            } 
     2144        } 
     2145 
     2146    }, 
     2147         
     2148    /** Function: sendMessage 
    20392149     * 
    20402150     *  Send message from chat input to user 
     
    20432153    sendMessage : function() 
    20442154    { 
    2045                 if (arguments.length > 0) 
    2046                 { 
    2047                         var jidTo = arguments[0]; 
    2048                         var message_input = arguments[1]; 
    2049                          
    2050                          
    2051                         message_input = message_input.replace(/^\s+|\s+$|^\n|\n$/g, ""); 
    2052                          
    2053                         if (message_input != "") { 
    2054                          
    2055                                 // Send Message 
    2056                                 var newMessage = $msg({ 
    2057                                         to: jidTo, 
    2058                                         from: TrophyIM.connection.jid, 
    2059                                         type: 'chat' 
    2060                                 }); 
    2061                                 newMessage = newMessage.c('body').t(message_input); 
    2062                                 newMessage.up(); 
    2063                                 newMessage = newMessage.c('active').attrs({ 
    2064                                         xmlns: 'http://jabber.org/protocol/chatstates' 
    2065                                 }); 
    2066                                 // Send Message 
    2067                                 TrophyIM.connection.send(newMessage.tree()); 
     2155        if (arguments.length > 0) 
     2156        { 
     2157            var jidTo = arguments[0]; 
     2158            var message_input = arguments[1]; 
     2159                         
     2160                         
     2161            message_input = message_input.replace(/^\s+|\s+$|^\n|\n$/g, ""); 
     2162                         
     2163            if (message_input != "") { 
     2164                         
     2165                // Send Message 
     2166                var newMessage = $msg({ 
     2167                    to: jidTo, 
     2168                    from: TrophyIM.connection.jid, 
     2169                    type: 'chat' 
     2170                }); 
     2171                newMessage = newMessage.c('body').t(message_input); 
     2172                newMessage.up(); 
     2173                newMessage = newMessage.c('active').attrs({ 
     2174                    xmlns: 'http://jabber.org/protocol/chatstates' 
     2175                }); 
     2176                // Send Message 
     2177                TrophyIM.connection.send(newMessage.tree()); 
    20682178                                 
    2069                                 return true; 
    2070                         } 
    2071                 } 
    2072                  
    2073                 return false; 
    2074     }, 
    2075  
    2076         /** Function: sendMessage 
     2179                return true; 
     2180            } 
     2181        } 
     2182                 
     2183        return false; 
     2184    }, 
     2185 
     2186    /** Function: sendMessage 
    20772187    * 
    20782188    *  Send message to ChatRoom 
     
    20812191    sendMessageChatRoom : function( ) 
    20822192    { 
    2083         if( arguments.length > 0 )  
    2084         { 
    2085                 var room_nick   = arguments[0]; 
    2086                 var message             = arguments[1]; 
    2087                 var msgid               = TrophyIM.connection.getUniqueId(); 
    2088                 var msg                 = $msg({to: room_nick, type: "groupchat", id: msgid}).c("body",{xmlns: Strophe.NS.CLIENT}).t(message); 
     2193        if( arguments.length > 0 )  
     2194        { 
     2195            var room_nick       = arguments[0]; 
     2196            var message         = arguments[1]; 
     2197            var msgid           = TrophyIM.connection.getUniqueId(); 
     2198            var msg                     = $msg({ 
     2199                to: room_nick,  
     2200                type: "groupchat",  
     2201                id: msgid 
     2202            }).c("body",{ 
     2203                xmlns: Strophe.NS.CLIENT 
     2204                }).t(message); 
    20892205                 
    2090                 msg.up();//.c("x", {xmlns: "jabber:x:event"}).c("composing"); 
     2206            msg.up();//.c("x", {xmlns: "jabber:x:event"}).c("composing"); 
    20912207                 
    2092                 TrophyIM.connection.send(msg); 
     2208            TrophyIM.connection.send(msg); 
    20932209                 
    2094                 return true; 
    2095         } 
    2096     }, 
    2097      
    2098         /** Function: sendContentMessage 
     2210            return true; 
     2211        } 
     2212    }, 
     2213     
     2214    /** Function: sendContentMessage 
    20992215     * 
    21002216     *  Send a content message from chat input to user 
    21012217     */ 
    2102         sendContentMessage : function() 
    2103     { 
    2104       if( arguments.length > 0 ) 
    2105       { 
    2106          var jidTo = arguments[0]; 
    2107          var state = arguments[1]; 
    2108  
    2109          var newMessage = $msg({to: jidTo, from: TrophyIM.connection.jid, type: 'chat'}); 
    2110          newMessage = newMessage.c(state).attrs({xmlns : 'http://jabber.org/protocol/chatstates'}); 
    2111          // Send content message 
    2112          TrophyIM.connection.send(newMessage.tree()); 
    2113       } 
     2218    sendContentMessage : function() 
     2219    { 
     2220        if( arguments.length > 0 ) 
     2221        { 
     2222            var jidTo = arguments[0]; 
     2223            var state = arguments[1]; 
     2224 
     2225            var newMessage = $msg({ 
     2226                to: jidTo,  
     2227                from: TrophyIM.connection.jid,  
     2228                type: 'chat' 
     2229            }); 
     2230            newMessage = newMessage.c(state).attrs({ 
     2231                xmlns : 'http://jabber.org/protocol/chatstates' 
     2232            }); 
     2233            // Send content message 
     2234            TrophyIM.connection.send(newMessage.tree()); 
     2235        } 
    21142236    } 
    21152237}; 
     
    21312253     */ 
    21322254    if (TrophyIM.JSONStore.store_working) 
    2133         { 
     2255    { 
    21342256        var data = TrophyIM.JSONStore.getData(['roster', 'groups']); 
    21352257        this.roster = (data['roster'] != null) ? data['roster'] : {}; 
    21362258        this.groups = (data['groups'] != null) ? data['groups'] : {}; 
    21372259    } 
    2138         else 
    2139         { 
     2260    else 
     2261    { 
    21402262        this.roster = {}; 
    21412263        this.groups = {}; 
     
    21432265    this.changes = new Array(); 
    21442266     
    2145         if (TrophyIM.constants.stale_roster) 
    2146         { 
     2267    if (TrophyIM.constants.stale_roster) 
     2268    { 
    21472269        for (var jid in this.roster) 
    2148                 { 
    2149                         this.changes[this.changes.length] = jid; 
     2270        { 
     2271            this.changes[this.changes.length] = jid; 
    21502272        } 
    21512273    } 
    21522274 
    2153         /** Function: addChange 
     2275    /** Function: addChange 
    21542276         * 
    21552277         *  Adds given jid to this.changes, keeping this.changes sorted and 
     
    21602282         */ 
    21612283          
    2162         this.addChange = function(jid) 
    2163         { 
    2164                 for (var c = 0; c < this.changes.length; c++) 
    2165                 { 
    2166                         if (this.changes[c] == jid) 
    2167                         { 
    2168                                 return; 
    2169                         } 
    2170                 } 
    2171                  
    2172                 this.changes[this.changes.length] = jid; 
    2173                  
    2174                 this.changes.sort(); 
    2175         } 
     2284    this.addChange = function(jid) 
     2285    { 
     2286        for (var c = 0; c < this.changes.length; c++) 
     2287        { 
     2288            if (this.changes[c] == jid) 
     2289            { 
     2290                return; 
     2291            } 
     2292        } 
     2293                 
     2294        this.changes[this.changes.length] = jid; 
     2295                 
     2296        this.changes.sort(); 
     2297    } 
    21762298         
    21772299    /** Function: addContact 
     
    21862308     */ 
    21872309     
    2188         this.addContact = function(jid, subscription, name, groups ) 
    2189         { 
    2190                 if( subscription === "remove" ) 
    2191         { 
    2192                         this.removeContact(jid); 
    2193         } 
    2194         else 
    2195         { 
    2196                         var contact             = {jid:jid, subscription:subscription, name:name, groups:groups} 
    2197                 var jid_lower   = jid.toLowerCase(); 
    2198          
    2199                         if ( this.roster[jid_lower] ) 
    2200                         { 
    2201                     this.roster[jid_lower]['contact'] = contact; 
    2202                 } 
    2203                         else 
    2204                         { 
    2205                     this.roster[jid_lower] = {contact:contact}; 
    2206                 } 
    2207  
    2208                         groups = groups ? groups : ['']; 
     2310    this.addContact = function(jid, subscription, name, groups ) 
     2311    { 
     2312        if( subscription === "remove" ) 
     2313        { 
     2314            this.removeContact(jid); 
     2315        } 
     2316        else 
     2317        { 
     2318            var contact         = { 
     2319                jid:jid,  
     2320                subscription:subscription,  
     2321                name:name,  
     2322                groups:groups 
     2323            } 
     2324            var jid_lower       = jid.toLowerCase(); 
     2325         
     2326            if ( this.roster[jid_lower] ) 
     2327            { 
     2328                this.roster[jid_lower]['contact'] = contact; 
     2329            } 
     2330            else 
     2331            { 
     2332                this.roster[jid_lower] = { 
     2333                    contact:contact 
     2334                }; 
     2335            } 
     2336 
     2337            groups = groups ? groups : ['']; 
    22092338                 
    2210                         for ( var g = 0; g < groups.length; g++ ) 
    2211                         { 
    2212                                 if ( !this.groups[groups[g]] ) 
    2213                                 { 
    2214                         this.groups[groups[g]] = {}; 
    2215                     } 
     2339            for ( var g = 0; g < groups.length; g++ ) 
     2340            { 
     2341                if ( !this.groups[groups[g]] ) 
     2342                { 
     2343                    this.groups[groups[g]] = {}; 
     2344                } 
    22162345                     
    2217                                 this.groups[groups[g]][jid_lower] = jid_lower; 
    2218                 } 
    2219         } 
     2346                this.groups[groups[g]][jid_lower] = jid_lower; 
     2347            } 
     2348        } 
    22202349    } 
    22212350     
     
    22282357      
    22292358    this.getContact = function(jid) 
    2230         { 
     2359    { 
    22312360        if (this.roster[jid.toLowerCase()]) 
    2232                 { 
     2361        { 
    22332362            return this.roster[jid.toLowerCase()]['contact']; 
    22342363        } 
    22352364    } 
    22362365 
    2237    /** Function: getPresence 
     2366    /** Function: getPresence 
    22382367        * 
    22392368        *  Returns best presence for given jid as Array(resource, priority, show, 
     
    22432372        */ 
    22442373          
    2245         this.getPresence = function(fulljid) 
    2246         { 
    2247                 var jid = Strophe.getBareJidFromJid(fulljid); 
    2248                 var current = null; 
     2374    this.getPresence = function(fulljid) 
     2375    { 
     2376        var jid = Strophe.getBareJidFromJid(fulljid); 
     2377        var current = null; 
    22492378                     
    2250                 if (this.roster[jid.toLowerCase()] && this.roster[jid.toLowerCase()]['presence']) 
    2251                 { 
    2252                         for (var resource in this.roster[jid.toLowerCase()]['presence']) 
    2253                         { 
    2254                         if ( this.roster[jid.toLowerCase()]['presence'][ resource ].constructor == Function ) 
    2255                                 continue; 
     2379        if (this.roster[jid.toLowerCase()] && this.roster[jid.toLowerCase()]['presence']) 
     2380        { 
     2381            for (var resource in this.roster[jid.toLowerCase()]['presence']) 
     2382            { 
     2383                if ( this.roster[jid.toLowerCase()]['presence'][ resource ].constructor == Function ) 
     2384                    continue; 
    22562385                         
    2257                                 var presence = this.roster[jid.toLowerCase()]['presence'][resource]; 
    2258                                 if (current == null) 
    2259                                 { 
    2260                                         current = presence 
    2261                                 } 
    2262                                 else 
    2263                                 { 
    2264                                         if(presence['priority'] > current['priority'] && ((presence['show'] == "chat" 
    2265                                         || presence['show'] == "available") || (current['show'] != "chat" || 
    2266                                         current['show'] != "available"))) 
    2267                                         { 
    2268                                                 current = presence 
    2269                                         } 
    2270                                 } 
    2271                         } 
    2272                 } 
    2273                 return current; 
    2274         } 
    2275  
    2276         /** Function: groupHasChanges 
     2386                var presence = this.roster[jid.toLowerCase()]['presence'][resource]; 
     2387                if (current == null) 
     2388                { 
     2389                    current = presence 
     2390                } 
     2391                else 
     2392                { 
     2393                    if(presence['priority'] > current['priority'] && ((presence['show'] == "chat" 
     2394                        || presence['show'] == "available") || (current['show'] != "chat" || 
     2395                        current['show'] != "available"))) 
     2396                        { 
     2397                        current = presence 
     2398                    } 
     2399                } 
     2400            } 
     2401        } 
     2402        return current; 
     2403    } 
     2404 
     2405    /** Function: groupHasChanges 
    22772406         * 
    22782407         *  Returns true if current group has members in this.changes 
     
    22822411         */ 
    22832412          
    2284         this.groupHasChanges = function(group) 
    2285         { 
    2286                 for (var c = 0; c < this.changes.length; c++) 
    2287                 { 
    2288                         if (this.groups[group][this.changes[c]]) 
    2289                         { 
    2290                                 return true; 
    2291                         } 
    2292                 } 
    2293                 return false; 
    2294         } 
    2295          
    2296         /** Function removeContact 
     2413    this.groupHasChanges = function(group) 
     2414    { 
     2415        for (var c = 0; c < this.changes.length; c++) 
     2416        { 
     2417            if (this.groups[group][this.changes[c]]) 
     2418            { 
     2419                return true; 
     2420            } 
     2421        } 
     2422        return false; 
     2423    } 
     2424         
     2425    /** Function removeContact 
    22972426         * 
    22982427         * Parameters 
     
    23002429         */ 
    23012430          
    2302         this.removeContact = function(jid) 
    2303         { 
    2304                 if( this.roster[ jid ] ) 
    2305                 {  
    2306                         var groups = this.roster[ jid ].contact.groups; 
    2307                          
    2308                         if( groups ) 
    2309                         { 
    2310                                 for ( var i = 0; i < groups.length; i++ ) 
    2311                                 { 
    2312                                         delete this.groups[ groups[ i ] ][ jid ]; 
    2313                                 } 
    2314          
    2315                                 for ( var i = 0; i < groups.length; i++ ) 
    2316                                 { 
    2317                                         var contacts = 0; 
    2318                                         for ( var contact in this.groups[ groups[ i ] ] ) 
    2319                                         { 
    2320                                         if ( this.groups[ groups[ i ] ][ contact ].constructor == Function ) 
    2321                                                 continue; 
     2431    this.removeContact = function(jid) 
     2432    { 
     2433        if( this.roster[ jid ] ) 
     2434        {  
     2435            var groups = this.roster[ jid ].contact.groups; 
     2436                         
     2437            if( groups ) 
     2438            { 
     2439                for ( var i = 0; i < groups.length; i++ ) 
     2440                { 
     2441                    delete this.groups[ groups[ i ] ][ jid ]; 
     2442                } 
     2443         
     2444                for ( var i = 0; i < groups.length; i++ ) 
     2445                { 
     2446                    var contacts = 0; 
     2447                    for ( var contact in this.groups[ groups[ i ] ] ) 
     2448                    { 
     2449                        if ( this.groups[ groups[ i ] ][ contact ].constructor == Function ) 
     2450                            continue; 
    23222451                                         
    2323                                                 contacts++; 
    2324                                         } 
    2325                  
    2326                                         if ( ! contacts ) 
    2327                                                 delete this.groups[ groups[ i ] ]; 
    2328                                 } 
    2329                         } 
    2330          
    2331                         // Delete Object roster 
    2332                         if( this.roster[jid] ) 
    2333                                 delete this.roster[jid]; 
    2334                 } 
    2335         } 
     2452                        contacts++; 
     2453                    } 
     2454                 
     2455                    if ( ! contacts ) 
     2456                        delete this.groups[ groups[ i ] ]; 
     2457                } 
     2458            } 
     2459         
     2460            // Delete Object roster 
     2461            if( this.roster[jid] ) 
     2462                delete this.roster[jid]; 
     2463        } 
     2464    } 
    23362465          
    23372466    /** Function: setPresence 
     
    23462475     */ 
    23472476     
    2348         this.setPresence = function(fulljid, priority, show, status) 
    2349         { 
    2350                 var barejid             = Strophe.getBareJidFromJid(fulljid); 
     2477    this.setPresence = function(fulljid, priority, show, status) 
     2478    { 
     2479        var barejid             = Strophe.getBareJidFromJid(fulljid); 
    23512480        var resource    = Strophe.getResourceFromJid(fulljid); 
    23522481        var jid_lower   = barejid.toLowerCase(); 
    23532482         
    23542483        if( show !== 'unavailable' || show !== 'error' ) 
    2355                 { 
    2356                 if (!this.roster[jid_lower]) 
    2357                         { 
     2484        { 
     2485            if (!this.roster[jid_lower]) 
     2486            { 
    23582487                this.addContact( barejid, 'not-in-roster' ); 
    23592488            } 
    23602489             
    23612490            var presence = 
    2362                         { 
     2491            { 
    23632492                resource        : resource, 
    23642493                priority        : priority, 
     
    23672496            } 
    23682497             
    2369                         if (!this.roster[jid_lower]['presence']) 
    2370                         { 
     2498            if (!this.roster[jid_lower]['presence']) 
     2499            { 
    23712500                this.roster[jid_lower]['presence'] = {}; 
    23722501            } 
    23732502             
    23742503            this.roster[jid_lower]['presence'][resource] = presence;     
    2375                 } 
     2504        } 
    23762505    } 
    23772506 
    2378         /** Fuction: save 
     2507    /** Fuction: save 
    23792508         * 
    23802509         *  Saves roster data to JSON store 
    23812510         */ 
    23822511         
    2383         this.save = function() 
    2384         { 
    2385                 if (TrophyIM.JSONStore.store_working) 
    2386                 { 
    2387                         TrophyIM.JSONStore.setData({roster:this.roster, 
    2388                         groups:this.groups, active_chat:TrophyIM.activeChats['current'], 
    2389                         chat_history:TrophyIM.chatHistory}); 
    2390                 } 
    2391         } 
     2512    this.save = function() 
     2513    { 
     2514        if (TrophyIM.JSONStore.store_working) 
     2515        { 
     2516            TrophyIM.JSONStore.setData({ 
     2517                roster:this.roster, 
     2518                groups:this.groups,  
     2519                active_chat:TrophyIM.activeChats['current'], 
     2520                chat_history:TrophyIM.chatHistory 
     2521                }); 
     2522        } 
     2523    } 
    23922524 
    23932525} 
     
    24082540     *    (function) handler = what to set onreadystatechange to 
    24092541     */ 
    2410      this._newXHR = function (handler) { 
     2542    this._newXHR = function (handler) { 
    24112543        var xhr = null; 
    24122544        if (window.XMLHttpRequest) { 
    24132545            xhr = new XMLHttpRequest(); 
    24142546            if (xhr.overrideMimeType) { 
    2415             xhr.overrideMimeType("text/xml"); 
     2547                xhr.overrideMimeType("text/xml"); 
    24162548            } 
    24172549        } else if (window.ActiveXObject) { 
     
    24412573            } 
    24422574            xhr.setRequestHeader('Content-type', 
    2443             'application/x-www-form-urlencoded'); 
     2575                'application/x-www-form-urlencoded'); 
    24442576            xhr.setRequestHeader('Content-length', getdata.length); 
    24452577            xhr.send(getdata); 
     
    24502582                } catch(e) { 
    24512583                    Strophe.error("Could not parse JSONStore response" + 
    2452                     xhr.responseText); 
     2584                        xhr.responseText); 
    24532585                    return false; 
    24542586                } 
     
    24672599        if (typeof(obj) == "object") { 
    24682600            for (var i in obj) { 
    2469                         if ( obj[i].constructor == Function ) 
    2470                                 continue; 
     2601                if ( obj[i].constructor == Function ) 
     2602                    continue; 
    24712603                         
    24722604                if (i == '_empty_') { 
     
    25012633            } 
    25022634            xhr.setRequestHeader('Content-type', 
    2503             'application/x-www-form-urlencoded'); 
     2635                'application/x-www-form-urlencoded'); 
    25042636            xhr.setRequestHeader('Content-length', deldata.length); 
    25052637            xhr.send(deldata); 
     
    25302662    this.setData = function(vars) 
    25312663    { 
    2532         if ( typeof(TROPHYIM_JSON_STORE) != undefined ) 
     2664        if ( typeof(TROPHYIM_JSON_STORE) != undefined ) 
    25332665        { 
    25342666            var senddata = "set=" + JSON.stringify(vars); 
     
    25442676            } 
    25452677            xhr.setRequestHeader('Content-type', 
    2546             'application/x-www-form-urlencoded'); 
     2678                'application/x-www-form-urlencoded'); 
    25472679            xhr.setRequestHeader('Content-length', senddata.length); 
    25482680            xhr.send(senddata); 
    25492681            if (xhr.readyState == 4 && xhr.status == 200 && xhr.responseText == 
    2550             "OK") { 
     2682                "OK") { 
    25512683                return true; 
    25522684            } else { 
     
    25592691    var testData = true; 
    25602692     
    2561     if (this.setData({testData:testData})) { 
     2693    if (this.setData({ 
     2694        testData:testData 
     2695    })) { 
    25622696        var testResult = this.getData(['testData']); 
    25632697        if (testResult && testResult['testData'] == true) { 
     
    26012735                    for(var i = 0; i < node.attributes.length; i++) { 
    26022736                        newNode.setAttribute(node.attributes[i].nodeName, 
    2603                         node.getAttribute(node.attributes[i].nodeName)); 
     2737                            node.getAttribute(node.attributes[i].nodeName)); 
    26042738                    } 
    26052739                } 
    26062740                if (allChildren && node.childNodes && 
    2607                 node.childNodes.length > 0) { 
     2741                    node.childNodes.length > 0) { 
    26082742                    for (var i = 0; i < node.childNodes.length; i++) { 
    26092743                        newNode.appendChild(document.importNode( 
    2610                         node.childNodes[i], allChildren)); 
     2744                            node.childNodes[i], allChildren)); 
    26112745                    } 
    26122746                } 
     
    26312765window.onunload = function() 
    26322766{ 
    2633         if( oldonunload ) 
    2634         { 
     2767    if( oldonunload ) 
     2768    { 
    26352769        oldonunload(); 
    26362770    } 
    26372771         
    2638         TrophyIM.setPresence('unavailable'); 
     2772    TrophyIM.setPresence('unavailable'); 
    26392773} 
  • branches/2.2.0.1/jabberit_messenger/jmessenger/js/trophyim.mini.js

    r4453 r4496  
    171171{return i18n.PAUSED;}}}} 
    172172return'';},makeChat:function(fulljid) 
    173 {var barejid=Strophe.getBareJidFromJid(fulljid);var titleWindow="";var paramsChatBox={'enabledPopUp':((loadscript.getIsIE())?"none":"block"),'idChatBox':barejid+"__chatBox",'jidTo':barejid,'path_jabberit':path_jabberit};titleWindow=barejid.toLowerCase();titleWindow=titleWindow.substring(0,titleWindow.indexOf('@'));if(TrophyIM.rosterObj.roster[barejid]) 
     173{var barejid=Strophe.getBareJidFromJid(fulljid);var titleWindow="";var paramsChatBox={'enabledPopUp':((loadscript.getBrowserCompatible())?"block":"none"),'idChatBox':barejid+"__chatBox",'jidTo':barejid,'path_jabberit':path_jabberit};titleWindow=barejid.toLowerCase();titleWindow=titleWindow.substring(0,titleWindow.indexOf('@'));if(TrophyIM.rosterObj.roster[barejid]) 
    174174{if(TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name']) 
    175175{titleWindow=TrophyIM.rosterObj.roster[barejid.toLowerCase()]['contact']['name'];}} 
     
    186186{if(e.keyCode==13){_send_message();composingTimer_=0;clearInterval(timeCounter);}else{if(_chatStateOnOff.value=='on') 
    187187setComposing();}});var winChatBox={id_window:"window_chat_area_"+barejid,barejid:barejid,width:387,height:375,top:TrophyIM.posWindow.top,left:TrophyIM.posWindow.left,draggable:true,visible:"display",resizable:true,zindex:loadscript.getZIndex(),title:titleWindow,closeAction:"hidden",content:_content} 
    188 _win=_winBuild(winChatBox);loadscript.notification(barejid);loadscript.getPhotoUser(barejid);_textarea.focus();return(_messages=_win.content().firstChild);},makeChatRoom:function() 
     188_win=_winBuild(winChatBox);loadscript.notification(barejid);loadscript.getPhotoUser(barejid);_textarea.focus();_messages=_win.content().firstChild;while(_messages&&_messages.nodeType!==1) 
     189{_messages=_messages.nextSibling;} 
     190return(_messages);},makeChatRoom:function() 
    189191{var jidChatRoom=arguments[0];var titleWindow="ChatRoom - "+unescape(arguments[1]);var paramsChatRoom={'idChatRoom':jidChatRoom+"__roomChat",'jidTo':jidChatRoom,'lang_Send':i18n.SEND,'lang_Leave_ChatRoom':i18n.LEAVE_CHATROOM,'path_jabberit':path_jabberit};TrophyIM.posWindow.top=TrophyIM.posWindow.top+10;if(TrophyIM.posWindow.top>200) 
    190192TrophyIM.posWindow.top=100;TrophyIM.posWindow.left=TrophyIM.posWindow.left+5;if(TrophyIM.posWindow.left>455) 
     
    200202{if(e.keyCode==13) 
    201203{_send_message();}});var winChatRoom={id_window:"window_chat_room_"+arguments[0],barejid:jidChatRoom,width:500,height:450,top:TrophyIM.posWindow.top,left:TrophyIM.posWindow.left,draggable:true,visible:"display",resizable:true,zindex:loadscript.getZIndex(),title:titleWindow,closeAction:"hidden",content:_content} 
    202 _win=_winBuild(winChatRoom);return(_messages=_win.content().firstChild);},addContact:function(jidTo,name,group) 
     204_win=_winBuild(winChatRoom);_messages=_win.content().firstChild;while(_messages&&_messages.nodeType!==1) 
     205{_messages=_messages.nextSibling;} 
     206return(_messages);},addContact:function(jidTo,name,group) 
    203207{var _flag=true;if(TrophyIM.removeResult.idResult.length>0) 
    204208{for(var i=0;i<TrophyIM.removeResult.idResult.length;i++) 
Note: See TracChangeset for help on using the changeset viewer.