source: companies/celepar/jabberit_messenger/js/load.js @ 763

Revision 763, 26.0 KB checked in by niltonneto, 15 years ago (diff)

Importação inicial do Expresso da Celepar

Line 
1(function()
2{
3        var _autoStatusTime = 60000; // 1 minuto
4        var _autoStatus;
5        var _conn   = new JITConnector(path_jabberit);
6        var _xtools = new JITXTools(path_jabberit);
7        var _showhidden = new ShowHidden(300);
8        var myWindow      = '';
9        var flagMouseOver = '';
10        var flagOpenIM    = '';
11        var flagOpenPopup = '';
12        var flagAwayIM    = '';
13        var itensSubMenu  = [];
14   
15        // Sniffer Browser
16        var agt=navigator.userAgent.toLowerCase();
17    var is_major = parseInt(navigator.appVersion);
18    var is_minor = parseFloat(navigator.appVersion);   
19    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
20                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
21                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
22    var is_gecko = (agt.indexOf('gecko') != -1);
23    var is_gecko1_5 = (agt.indexOf('firefox/1.5') != -1 || agt.indexOf('firefox/2') != -1 || agt.indexOf('iceweasel/2') != -1);
24    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
25    var is_ie3    = (is_ie && (is_major < 4));
26    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
27    var is_ie4up  = (is_ie && (is_major >= 4));
28    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
29    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
30    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
31    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
32    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
33    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);   
34    var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
35
36        if ( !(document.getElementById('jabberit_messenger_content')) )
37        {
38                var _jabberit_content = document.createElement('div');
39                _jabberit_content.setAttribute('id', 'jabberit_messenger_content');
40                _jabberit_content = document.body.appendChild(_jabberit_content);
41        }
42
43        var _window = new JITWindows(_xtools, _jabberit_content);
44        var _ldap       = new JITLdap( _conn, _xtools, _window );
45
46        function addContacts()
47        {
48                _ldap.add(myWindow);
49        }
50
51        function addIcon()
52        {
53               
54                var StatusBar = document.getElementById('divStatusBar');
55
56                /**
57                 * @quando estiver habilitada a opção fora de escritório nos filtros.
58                 */
59               
60                if( div_write_msg = document.getElementById('em_div_write_msg') )
61                {               
62                        var StatusBarIM = document.getElementById('JabberMessenger');
63                        div_write_msg.parentNode.insertBefore(StatusBarIM, div_write_msg);
64                        StatusBarIM.style.paddingLeft = '33px';
65                        return;                 
66                }
67               
68                if( StatusBar )
69                {
70                        StatusBar.style.paddingLeft = '33px';
71                       
72                        var _div = document.createElement('div');
73                        _div.appendChild(StatusBar.parentNode.removeChild(StatusBar.previousSibling));
74                        StatusBar.parentNode.insertBefore(_div,StatusBar);
75                       
76                        var divJabber = document.createElement('div');
77                                divJabber.setAttribute('id', 'JabberMessenger');
78                       
79                        var _status = top.document.createElement('div');
80                                _status.setAttribute('id', 'jabberit_login');
81                                _status.style.background = 'no-repeat';
82                                _status.style.backgroundImage = 'url(' + jabberit_group_open.src + ')';
83                                _status.style.float = 'left';
84                                _status.style.height = '15px';
85                                _status.style.left = '7px';
86                                _status.style.margin = '8 0 0 10px';
87                                _status.style.padding = '0px';
88                                _status.style.position = 'absolute';
89                                _status.style.width = '15px';
90                                _status.style.cursor = 'pointer';
91
92                        divJabber.insertBefore(_status,divJabber.firstChild);
93
94                        var _menu;
95                                _menu = top.document.createElement('div');
96                                _menu.setAttribute('id','fast_menu_jabberit');
97                                _menu.style.backgroundColor = 'cecece';
98                                _menu.style.border = '1px dashed #000';
99                                _menu.style.display = 'none';
100                                _menu.style.margin = '20px 5px 0px -15px';
101                                _menu.style.position = 'absolute';
102                                _menu.style.zIndex = '99999';
103                                _menu.onmouseout = function(){ _showhidden.hiddenObject(false); };
104                                _menu.onmouseover = function(){ _showhidden.hiddenObject(true); };
105                               
106                        divJabber.insertBefore(_menu, divJabber.firstChild);
107
108                        var _menu_div = top.document.createElement('div');
109                                _menu_div.setAttribute('id','status_Jabber_Expresso');
110                                _menu_div.style.background = 'no-repeat';
111                                _menu_div.style.backgroundImage = 'url(' + jabberit_add_user.src + ')';
112                                _menu_div.style.float = 'left';
113                                _menu_div.style.height = '18px';
114                                _menu_div.style.left = '19px';
115                                _menu_div.style.margin = '0 0 0 10px';
116                                _menu_div.style.padding = '0px';
117                                _menu_div.style.position = 'absolute';
118                                _menu_div.style.width = '18px';
119                                _menu_div.style.cursor = 'pointer';
120                                _menu_div.style.zindex = '99999999';
121                       
122                        statusJabberExpresso = _menu_div;
123                       
124                        divJabber.insertBefore(_menu_div, divJabber.firstChild);
125                        StatusBar.insertBefore(divJabber, StatusBar.firstChild);                       
126                       
127                        configEvents(_menu_div,'onclick',showWindow);
128
129                        configEvents(
130                                _status,
131                                'onclick',
132                                function()
133                                {
134                                        var _options = [
135                                                ['Add Contacts',addContacts],
136                                                ['Help',helpJabberit],
137                                                ['Preferences', preferences],
138                                                ['Change Status', subMenuChangeStatus]
139                                        ];
140
141                                        var _style_text = 'cursor: pointer; padding:2px 2px 2px 15px; border-bottom:1px solid #dedede; background: no-repeat url(' + jabberit_group_close.src + ');';                                   
142
143                                        var _xml = _xtools.xml('menu');
144                                        var _option;
145                                        var _item;
146                                        var _action;
147                                        var _style;
148
149                                        for ( var i in _options )
150                                        {
151                                                _option = _xml.createElement('option');
152
153                                                _item = _xml.createElement('item');
154                                                _item.appendChild(_xml.createTextNode(jabberitGetLang(_options[i][0])));
155                                               
156                                                _style = _xml.createElement('style');
157                                                _style.appendChild(_xml.createTextNode(_style_text));
158
159                                                _option.appendChild(_item);
160                                                _option.appendChild(_style);
161
162                                                _xml.documentElement.appendChild(_option);
163                                        }
164
165                                        _menu.innerHTML = _xtools.parse(_xml, 'options.xsl');
166                                        _showhidden.action('onmouseover', 'onmouseout', _menu);
167
168                                        _item = _menu.firstChild;
169
170                                        for ( var i in _options )
171                                        {
172                                                _item.childNodes[i].setAttribute('presence', _options[i]);
173                                                configEvents(
174                                                        _item.childNodes[i],
175                                                        'onclick',
176                                                        _options[i][1]
177                                                );
178                                        }
179                                });
180                }
181        }
182
183        function autoStatus()
184        {
185               
186                if ( _autoStatus )
187                        clearTimeout(_autoStatus);
188
189                var _div_status = document.getElementById('status_Jabber_Expresso');
190                if ( _div_status )
191                {
192                        var _status = _div_status.style.backgroundImage;
193                        _status = _status.substr(_status.lastIndexOf('/') + 1);
194                        _status = _status.substr(0, _status.indexOf('.'));
195                        if ( _status == 'xa' && _div_status.getAttribute('autoStatus') )
196                        {
197                                _div_status.removeAttribute('autoStatus');
198                                changeStatusJava("2");
199                        }
200                }
201
202                var TimeStatus = flagAwayIM.split(':');
203
204                if( TimeStatus[1] )
205                        _autoStatus = setTimeout(autoStatusHandler, parseInt(TimeStatus[1])*_autoStatusTime);
206                else
207                        _autoStatus = setTimeout(autoStatusHandler, parseInt(_autoStatusTime));
208        }
209
210        function autoStatusHandler()
211        {
212                var _div_status = document.getElementById('status_Jabber_Expresso');
213                if ( _div_status )
214                {
215                        var _status = _div_status.style.backgroundImage;
216                        _status = _status.substr(_status.lastIndexOf('/') + 1);
217                        _status = _status.substr(0, _status.indexOf('.'));
218                        if ( _status == 'available' )
219                        {
220                                _div_status.setAttribute('autoStatus','true');
221                                changeStatusJava("5");
222                        }
223                }
224        }
225
226        function changeLabel()
227        {
228                if( arguments.length > 0 )
229                {
230                        var element = arguments[0].parentNode.parentNode.firstChild;
231
232                        if(arguments[0].checked)
233                                element.innerHTML = "<span style='color:red;'>Digite o Email .: </span>";
234                        else
235                                element.innerHTML = "Nome do Contato .: ";
236                }
237        }
238
239        function changeStatusJava()
240        {
241                if(arguments.length > 0 )
242                {
243                        try
244                        {
245                                var status      = arguments[0];
246                                var msg         = ( arguments[1] ) ? arguments[1] : "";
247                       
248                                // If Layer;
249                                if( elementIframe = document.getElementById('iframe_applet_jabberit') )
250                                {
251                                        if( !is_ie )
252                                                elementIframe.contentDocument.applets[0].changeStatusfromExpresso(status, msg);
253                                        else
254                                                elementIframe.contentWindow.document.applets[0].changeStatusfromExpresso(status, msg);
255                                }
256                                else // If Pop-Up
257                                {
258                                        myWindow.document.applets[0].changeStatusfromExpresso(status, msg);
259                                }
260                               
261                        }
262                        catch(e)
263                        {
264                                if( confirm('Deseja conectar o IM ?') )
265                                        showWindow();
266                        }
267                }               
268        }
269
270        function configEvents(pObj, pEvent, pHandler)
271        {
272                if ( typeof pObj == 'object' )
273                {
274                        if ( pEvent.substring(0, 2) == 'on' )
275                                pEvent = pEvent.substring(2, pEvent.length);
276
277                        if ( pObj.addEventListener )
278                                pObj.addEventListener(pEvent, pHandler, false);
279                        else if ( pObj.attachEvent )
280                                pObj.attachEvent('on' + pEvent, pHandler);
281                }
282        }
283
284        function closeWindow()
285        {
286                myWindow = '';
287        }
288
289        function getElementStatus()
290        {
291                return document.getElementById('status_Jabber_Expresso');
292        }
293
294        function getPreferences()
295        {
296                if( flagOpenIM == '' )
297                {
298                        _conn.go("$this.db_im.getPreferences",
299                                                function(data)
300                                                {
301                                                        var autoConnect = '';
302                                                        flagOpenIM = data;
303
304                                                        if( data.indexOf(';') != -1)
305                                                        {
306                                                                var temp = data.split(';');
307                                                                autoConnect = flagOpenIM = temp[0];
308                                                               
309                                                                // Open as Pop-Up
310                                                                flagOpenPopup = 'openWindowJabberitPopUp:false';
311                                                               
312                                                                if( temp[1] )
313                                                                {
314                                                                        if( temp[1] == 'openWindowJabberitPopUp:true' || temp[1] == 'openWindowJabberitPopUp:false')
315                                                                                flagOpenPopup = temp[1];
316                                                                }
317                                                               
318                                                                // Away
319                                                                flagAwayIM = 'flagAwayIM:5';
320                                                               
321                                                                if( temp[2] )
322                                                                {
323                                                                        flagAwayIM = temp[2];
324                                                                }
325                                                        }
326                                                        else
327                                                        {
328                                                                autoConnect = flagOpenIM;
329                                                        }
330                                                       
331                                                        if( autoConnect == 'openWindowJabberit:true' )
332                                                        {
333                                                                setTimeout('loadscript.showW();', 2500);
334                                                        }
335                                                });
336                }
337
338        }
339
340        function helpJabberit()
341        {
342                var myWindowHelp = window.open( path_jabberit + 'help.php', 'HelpjabberIM', 'width=800,height=495,top=50,left=50,scrollbars=yes');
343        }
344
345        function keyPressSearch()
346        {
347                var ev = arguments[0];
348                var element = arguments[1];
349
350                if ( ev.keyCode == 13 )
351                        if( element.value.length >= 4 )
352                                _ldap.search( element.value ); 
353                        else
354                                alert(jabberitGetLang('Your search argument must be longer than 4 characters.'));
355        }
356
357        function openPopup()
358        {
359                var widPopup = '220';
360
361                if( is_ie )
362                        widPopup = '250';
363
364                try{
365
366                        if(!myWindow )
367                        {       
368                                myWindow = window.open('','JabberIM','width='+widPopup+',height=400,top=50,left=50,toolbar=0,menubar=0,resizable=0,scrollbars=0,status=0,location=0,titlebar=0');
369                                myWindow.close();
370                                myWindow = window.open(path_jabberit + 'client.php','JabberIM','width='+widPopup+',height=400,top=50,left=50,toolbar=0,menubar=0,resizable=0,scrollbars=0,status=0,location=0,titlebar=0');
371                                myWindow.blur();
372                                configEvents(myWindow,'onbeforeunload', closeWindow );
373                        }
374                        else
375                        {
376                                for( var i = 15 ; i > 0 ; i-- )
377                                {
378                                        myWindow.moveBy(i,0); myWindow.moveBy(-i,0);
379                                }
380                                myWindow.focus();
381                        }
382                }
383                catch(e)
384                {
385                        delete myWindow;
386                        myWindow = window.open(path_jabberit + 'client.php','JabberIM','width='+widPopup+',height=400,top=50,left=50,toolbar=0,menubar=0,resizable=0,scrollbars=0,status=0,location=0,titlebar=0');
387                        myWindow.blur();
388                        configEvents(myWindow,'onbeforeunload', closeWindow );
389                }
390        }
391
392        function openWindow()
393        {
394                var _win_contacts = _window.load('jabberit_contacts');
395
396                var flagOpenAux = '';
397               
398                if( flagOpenIM.indexOf(';') != -1 )
399                {
400                        var aux = flagOpenIM.split(';');
401                        flagOpenAux = aux[0];
402                }
403                else
404                        flagOpenAux = flagOpenIM;
405
406                if( flagOpenAux == 'openWindowJabberit:false' )
407                {
408                        if( !is_ie )
409                                _win_contacts.size(220,400);
410                        else   
411                                _win_contacts.size(250,400);
412                }                                       
413                else
414                {
415                        if( !is_ie )
416                        {
417                                _win_contacts.size(1,1);
418                                _win_contacts.wm.style.visibility = 'hidden';
419                        }
420                        else
421                        {
422                                _win_contacts.size(0,0);
423                        }
424                }
425
426                _win_contacts.bc.style.display = "none";
427                _win_contacts.bx.style.display = "none";
428
429                if( _win_contacts.bz.removeEventListener )
430                        _win_contacts.bz.removeEventListener('click',_win_contacts.button, false);
431                else
432                        _win_contacts.bz.detachEvent('onclick',_win_contacts.button);
433
434                configEvents(
435                        _win_contacts.bz,
436                        "onclick",
437                        function()
438                        {
439                                _win_contacts.size(1,1);
440                                _win_contacts.wm.style.visibility = 'hidden';
441                                _win_contacts.position(50,50);
442                                _win_contacts.title('');
443                        }
444                );
445
446                var _params = {'path' : path_jabberit};
447                _win_contacts.content(_xtools.parse(_xtools.xml('contacts_jabberit'), 'contacts_jabberit.xsl', _params));
448
449                if( flagOpenAux == 'openWindowJabberit:false' )
450                {
451                        if( !is_ie )
452                        {
453                                _win_contacts.wm.style.visibility = "visible";
454                                _win_contacts.size(220,400);
455                                _win_contacts.title('.:: Expresso - JMessenger ::.');
456                        }
457                        else
458                        {
459                                _win_contacts.size(250,400);
460                                _win_contacts.title('.:: Expresso - JMessenger ::.');
461                        }
462                        _win_contacts.position(50,50);
463                }
464                else
465                {
466                        if( !is_ie )
467                                _win_contacts.wm.style.visibility = "hidden";
468                }
469        }
470
471        function openWindowParticipantsExternal()
472        {
473                if( arguments.length > 0)
474                {
475                        var element = arguments[0];
476                        var orgPartExternal = externalParticipantsJabberit.split(",");
477                       
478                        var _splash = top.document.createElement('span');
479                                _splash.setAttribute('id','fast_splash_jabberit');
480                                _splash.style.backgroundColor = 'dedede';
481                                _splash.style.position = 'absolute';
482                                _splash.style.display = 'block';
483                                _splash.style.width = '200px';
484                                _splash.style.height = 'auto';
485                                _splash.style.margin = ( !is_ie ) ? '0px 5px 0px 130px' : '20px 0px 0px 0px';
486                                _splash.style.zIndex = '99999';
487                                _splash.style.border = '2px outset #000';
488                                _splash.onmouseout = function(){ _showhidden.hiddenObject(false); };
489                                _splash.onmouseover = function(){ _showhidden.hiddenObject(true); };
490                       
491                                for(var i = 0; i < orgPartExternal.length; i++)
492                                        _splash.innerHTML += '<div style="margin:5px;border-bottom:1px dashed #000;cursor:default !important;">' + (i + 1) + " - " + orgPartExternal[i] + '</div>';     
493                               
494                        _showhidden.action('onmouseover', 'onmouseout', _splash);
495                        element.appendChild(_splash);
496                }
497        }
498
499        function preferences()
500        {
501                if( !(_window.get('jabberit_preferences')) )
502                {
503                        var _win_preferences = _window.load('jabberit_preferences');
504                                _win_preferences.size(400,310);                         
505                                _win_preferences.position(150,100);
506                                _win_preferences.title('.:: Expresso - JMessenger '+jabberitGetLang('Preferences')+'::.');
507                                _win_preferences.bc.style.display = "none";
508                                _win_preferences.bx.style.display = "none";
509                                _win_preferences.wc.style.padding = "5px";                                                             
510
511                        if( _win_preferences.bz.removeEventListener )
512                                _win_preferences.bz.removeEventListener('click',_win_preferences.button, false);
513                        else
514                                _win_preferences.bz.detachEvent('onclick',_win_preferences.button);
515                               
516                        configEvents(
517                                _win_preferences.bz,
518                                "onclick",
519                                function()
520                                {
521                                        _win_preferences.size(1,1);
522                                        _win_preferences.wm.style.visibility = 'hidden';
523                                        _win_preferences.position(50,50);
524                                        _win_preferences.title('');
525                                });
526
527                        var _params = {'path'  : path_jabberit,
528                                                   'lang1' : jabberitGetLang('Your Preferences'),
529                                                   'lang2' : jabberitGetLang('Connection'),     
530                                                   'lang3' : jabberitGetLang('Enable Auto Login IM'),
531                                                   'lang4' : jabberitGetLang('Users OffLine'),
532                                                   'lang5' : jabberitGetLang('Show friends Offline'),
533                                                   'lang6' : jabberitGetLang('Save'),
534                                                   'lang7' : jabberitGetLang('Cancel'),
535                                                   'lang8' : jabberitGetLang('Window'),
536                                                   'lang9' : jabberitGetLang('Open as Pop-Up Window'),
537                                                   'lang10' : jabberitGetLang('Away Presence'),
538                                                   'lang11' : jabberitGetLang('Set status to away after'),
539                                                   'lang12' : jabberitGetLang('minutes'),                                                 
540                                                   'langYes': jabberitGetLang('Yes'),
541                                                   'langNo' : jabberitGetLang('No')                                                                                       
542                                                  };
543                        _win_preferences.content(_xtools.parse(_xtools.xml('preferences_jabberit'), 'preferences_jabberit.xsl', _params));
544                        _win_preferences.wc.lastChild.lastChild.onclick = _win_preferences.close;
545                }
546                else
547                {
548                        var _win_preferences = _window.get('jabberit_preferences');
549                        _win_preferences.wm.style.visibility = "visible";
550                        _win_preferences.position(150,100);                                                     
551                        _win_preferences.title('.:: Expresso - JMessenger '+jabberitGetLang('Preferences')+'::.');
552                        _win_preferences.size(320,250);
553                }
554               
555                // Element openWindowJabberit
556                var value1 = flagOpenIM.split(':');
557                var element1 = document.getElementById(value1[0]);
558                var valueSelect1 = value1[1];
559               
560                for(var i = 0; i < element1.options.length; i++)
561                        if( element1.options[i].value == valueSelect1 )
562                                element1.options[i].selected = true;
563
564               
565                // Element openWindowJabberitPopUp
566                var value2 = flagOpenPopup.split(':');
567                var element2 = document.getElementById(value2[0]);
568                var valueSelect2 = value2[1];
569                       
570                for(var i = 0; i < element2.options.length; i++)
571                        if( element2.options[i].value == valueSelect2 )
572                                element2.options[i].selected = true;
573                               
574                // Element flagAwayIM
575                var value3 = flagAwayIM.split(':');
576                var element3 = document.getElementById(value3[0]);
577                element3.value = value3[1];
578               
579        }
580
581        function searchUser()
582        {
583                var element = arguments[0].previousSibling;
584               
585                if( element.value.length >= 4 )
586                        _ldap.search( element.value ); 
587                else
588                        alert(jabberitGetLang('Your search argument must be longer than 4 characters.'));
589        }
590
591        function setItensStatusMenu()
592        {
593                if( arguments.length > 0 )
594                {
595                        var key = parseInt(arguments[0].substring(0, arguments[0].indexOf('-')));
596                        var value = arguments[0].substring(arguments[0].indexOf('-') + 1 );
597                       
598                        itensSubMenu[key] = value.toString();   
599                }
600        }
601       
602        function setPreferences()
603        {
604                // Element openWindowJabberit
605                var elementOpenW = document.getElementById('openWindowJabberit');
606                var value = '';
607                var flagReload = false;
608               
609                for(var i = 0 ; i < elementOpenW.options.length; i++)
610                        if( elementOpenW.options[i].selected == true)
611                        {
612                                value = 'preferences1=openWindowJabberit:' + elementOpenW.options[i].value;
613                                flagOpenIM = 'openWindowJabberit:' + elementOpenW.options[i].value;
614                        }
615
616                // Element openWindowJabberitPopUp
617                var elementOpenPop = document.getElementById('openWindowJabberitPopUp');       
618
619                for(var i = 0; i < elementOpenPop.options.length; i++ )
620                        if( elementOpenPop.options[i].selected ==  true )
621                        {
622                                value += '&preferences2=openWindowJabberitPopUp:' + elementOpenPop.options[i].value;
623                               
624                                if( flagOpenPopup != 'openWindowJabberitPopUp:' + elementOpenPop.options[i].value)
625                                        flagReload = true;
626                                       
627                                flagOpenPopup = 'openWindowJabberitPopUp:' + elementOpenPop.options[i].value;
628                        }
629               
630                // Element flagAwayIM
631                var elementFlagIM = document.getElementById('flagAwayIM');
632               
633                if( elementFlagIM.value.length > 0 && parseInt(elementFlagIM.value) > 0 )
634                {
635                        flagAwayIM = 'flagAwayIM:' + elementFlagIM.value;
636                        value += '&preferences3=flagAwayIM:' + elementFlagIM.value;
637                }
638                else
639                {
640                        alert(jabberitGetLang('Enter a value greater than or equal to 1!'));
641                        return false;
642                }
643
644                _conn.go('$this.db_im.setPreferences',
645                                 function(data)
646                                 {
647                                        if(data == 'true')
648                                        {
649                                                if( flagReload )
650                                                {
651                                                        window.location.reload();
652                                                        myWindow.close();                                                       
653                                                }
654                                        }
655                                        else{ alert(jabberitGetLang('Error saving your preferences!')); }
656                                                                               
657                                        var _win_preferences = _window.get('jabberit_preferences');
658                                                _win_preferences.close();
659                                 },
660                                 value);
661        }
662       
663        function showDiv()
664        {
665                var _element = ( myWindow ) ? myWindow.document.body.firstChild : null ;
666                if( _element != null )
667                        _element.style.visibility = 'visible';
668        }
669
670        function showWindow()
671        {
672                var _win_contacts = _window.get('jabberit_contacts');
673               
674                if( flagOpenPopup === 'openWindowJabberitPopUp:true' )
675                {
676                        openPopup();                                   
677                }
678                else
679                {
680                        if ( _win_contacts )
681                        {       
682                                _win_contacts.wm.style.visibility = "visible";
683                                _win_contacts.title('.:: Expresso - JMessenger ::.');
684       
685                                if( !is_ie )
686                                        _win_contacts.size(220,400);
687                                else
688                                        _win_contacts.size(250,400);
689       
690                                _win_contacts.position(60,60);
691                        }
692                        else
693                                openWindow();
694                }
695        }
696
697        function subMenuChangeStatus()
698        {
699                if(document.getElementById('subMenu_Change_Status_JabberIt') == null )
700                {
701                        var _itens  = [
702                                                                ['Online', 'loadscript.subMnChStIt("2",this);', 'available_jabberit.src','jabberit_group_close_black.src'],
703                                                                ['Free For Chat', 'loadscript.subMnChStIt("1",this);', 'chat_jabberit.src','jabberit_group_close_black.src'],
704                                                                ['Xa', 'loadscript.subMnChStIt("3",this);','xa_jabberit.src','jabberit_group_close_black.src'],
705                                                                ['Dnd', 'loadscript.subMnChStIt("4",this);','dnd_jabberit.src','jabberit_group_close_black.src'],
706                                                                ['Away', 'loadscript.subMnChStIt("5",this);','away_jabberit.src','jabberit_group_close_black.src'],
707                                                                ['Invisible', 'loadscript.subMnChStIt("6",this);','invisible_jabberit.src']
708                                                  ];
709       
710                        var _itensMenu = "<dl style='margin:2px 2px !important;font-size:8pt !important;background: #cecece;color: #000;'>";
711                       
712                        for(var i in _itens)
713                        {
714                                _itensMenu += '<dt onmouseover="elementOnMouseOver(this);" onmouseout="elementOnMouseOut(this, false);" style="cursor: pointer;';
715                                if ( i != _itens.length - 1 )
716                                        _itensMenu += 'border-bottom:1px solid #dedede;';
717                                _itensMenu += '">';
718
719                                _itensMenu += "<div ";
720                                if( _itens[i][3] )
721                                        _itensMenu += "style='background: url(" + eval(_itens[i][3]) + ") no-repeat center right'";
722                                _itensMenu += "onclick="+_itens[i][1] +"><img src='" + eval(_itens[i][2]) + "' style='margin-right:3px;'/>" + jabberitGetLang(_itens[i][0]) + "</div></dt>";
723                        }
724
725                        _itensMenu += "</dl>";
726       
727                        var _subMenu_div = document.createElement("div");
728                                _subMenu_div.setAttribute('id','subMenu_Change_Status_JabberIt');
729                                _subMenu_div.style.margin = '-10px 5px 0px 0px';
730                                _subMenu_div.style.background = '#cecece';
731                                _subMenu_div.style.border = '1px dashed #000';
732                                _subMenu_div.style.float = 'left';
733                                _subMenu_div.style.position = 'absolute';
734                                _subMenu_div.style.left = '55px';
735                                _subMenu_div.style.width = ( is_ie ) ? '160px': '140px';;
736                                _subMenu_div.style.zindex = '99999';
737                                _subMenu_div.innerHTML = _itensMenu;
738       
739                        var elementParent = document.getElementById('fast_menu_jabberit');
740                        elementParent.appendChild(_subMenu_div);
741                }
742        }
743       
744        function subMenuChangeStatusItens()
745        {
746                if( arguments.length > 0 )
747                {
748                        var status      = arguments[0];
749                        var element     = arguments[1];
750                        var msg         = "";
751
752                        if( itensSubMenu.length > 0 )
753                        {
754                                var string = "";
755                                for( var i = 0; i < itensSubMenu.length ; i++ )
756                                {
757                                        if( itensSubMenu[i] != undefined )
758                                        {
759                                                string = itensSubMenu[i].substring(1);
760                                                string = string.substring(0, string.indexOf("]")).toString();
761
762                                                if( string != "" )
763                                                {
764                                                        if( status == i )
765                                                        {
766                                                                if ( ! ( string.indexOf( ',' ) < 0 ) )
767                                                                {
768                                                                        var phases = string.split(',');
769                                                                        var _itensMenu = "<dl style='padding:1px !important; margin:2px 2px !important;font-size:8pt !important;background: #cecece;color: #000;'>";
770                                                                        for ( var m = 0; m < phases.length; m++ )
771                                                                        {
772                                                                                _itensMenu += "<dt onmouseover='elementOnMouseOver(this);' onmouseout='elementOnMouseOut(this, false);' style='cursor: pointer;border-bottom:1px solid #dedede;'>";
773                                                                                _itensMenu += "<div onclick='loadscript.chgStatusJava(\""+i+"\", \""+phases[m]+"\")'><img src='" + jabberit_group_close.src + "' style='margin-right:3px;'/>" + phases[m] + "</div></dt>";     
774                                                                        }
775                                                                        _itensMenu += "</dl>";
776                                                                }
777                                                                else
778                                                                {
779                                                                        var _itensMenu  = "<dl style='padding:1px !important; margin:2px 2px !important;font-size:8pt !important;background: #cecece;color: #000;'>";
780                                                                                _itensMenu += "<dt onmouseover='elementOnMouseOver(this);' onmouseout='elementOnMouseOut(this, false);' style='cursor: pointer;'>";                                                             
781                                                                                _itensMenu += "<div onclick='loadscript.chgStatusJava(\""+i+"\", \""+string+"\");'><img src='" + jabberit_group_close.src + "' style='margin-right:3px;'/>" + string + "</div></dt>";
782                                                                                _itensMenu += "</dl>";
783                                                                }
784                                                        }
785
786                                                        for( var j = 0 ; j < 6 ; j++ )
787                                                        {
788                                                                if( document.getElementById('ItemSubMenuJabberd_' + j) != null )
789                                                                {
790                                                                        var ElementItem = document.getElementById('ItemSubMenuJabberd_' + j);
791                                                                                ElementItem.parentNode.removeChild(ElementItem);
792                                                                }
793                                                        }
794                                                }
795                                        }
796                                }
797                               
798                                if( _itensMenu )
799                                {
800                                        var _subMenuItem_div = document.createElement("div");
801                                        _subMenuItem_div.setAttribute('id','ItemSubMenuJabberd_' + status);
802                                        _subMenuItem_div.style.margin = ( is_ie ) ? '-3px 5px 0px 0px' : '-20px 5px 0px 0px';
803                                        _subMenuItem_div.style.background = '#cecece';
804                                        _subMenuItem_div.style.border = '1px dashed #000';
805                                        _subMenuItem_div.style.float = 'left';
806                                        _subMenuItem_div.style.position = 'absolute';
807                                        _subMenuItem_div.style.left = ( is_ie ) ? '157px' : '140px';
808                                        _subMenuItem_div.style.width = ( is_ie ) ? '180px': '160px';
809                                        _subMenuItem_div.style.zindex = '99999';
810                                        _subMenuItem_div.innerHTML = _itensMenu;
811                                       
812                                        element.appendChild( _subMenuItem_div );
813                                }else
814                                        changeStatusJava(status,"");
815                        }
816                }
817        }
818
819        function Load()
820        {
821                addIcon();
822                getPreferences();
823               
824                // AutoStatus Away             
825                autoStatus();
826                configEvents(document, 'onmousemove', autoStatus);
827                configEvents(document, 'onkeypress', autoStatus);
828        }
829
830        Load.prototype.adIcon                   = addIcon;
831        Load.prototype.autoStatusIM             = autoStatus;
832        Load.prototype.chgStatusJava    = changeStatusJava;
833        Load.prototype.closeW                   = closeWindow;
834        Load.prototype.cLabel                   = changeLabel;
835        Load.prototype.getElement               = getElementStatus;
836        Load.prototype.keyPress                 = keyPressSearch;
837        Load.prototype.openWinParExt    = openWindowParticipantsExternal;
838        Load.prototype.search                   = searchUser;
839        Load.prototype.setItensStatus   = setItensStatusMenu;
840        Load.prototype.setPrefe                 = setPreferences;
841        Load.prototype.show                             = showDiv;
842        Load.prototype.showW                    = showWindow;
843        Load.prototype.subMnChStIt              = subMenuChangeStatusItens;
844       
845        window.loadscript = new Load;
846
847})();
848
849// Functions OnMouseOver e OnMouseOut
850
851function elementOnMouseOut()
852{
853        if( arguments.length > 0 )
854        {
855                var _element = arguments[0];
856                        _element.style.backgroundColor = '';
857                        _element.style.border = '';
858                        if( !arguments[1] )
859                                _element.style.borderBottom = '1px solid #dedede';
860        }
861}
862
863function elementOnMouseOver()
864{
865        if( arguments.length > 0 )
866        {
867                var _element = arguments[0];
868                        _element.style.backgroundColor = 'white';
869                        _element.style.border = '1px solid black';
870        }
871}
872
Note: See TracBrowser for help on using the repository browser.