(function() { var _conn = new JITConnector(path_jabberit); var _xtools = new JITXTools(path_jabberit); var _showhidden = new ShowHidden(1500); var myWindow = ''; var flagMouseOver = ''; var flagOpenIM = ''; // Sniffer Browser var agt=navigator.userAgent.toLowerCase(); var is_major = parseInt(navigator.appVersion); var is_minor = parseFloat(navigator.appVersion); var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)); var is_gecko = (agt.indexOf('gecko') != -1); var is_gecko1_5 = (agt.indexOf('firefox/1.5') != -1 || agt.indexOf('firefox/2') != -1 || agt.indexOf('iceweasel/2') != -1); var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)); var is_ie3 = (is_ie && (is_major < 4)); var is_ie4 = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) ); var is_ie4up = (is_ie && (is_major >= 4)); var is_ie5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) ); var is_ie5_5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1)); var is_ie5up = (is_ie && !is_ie3 && !is_ie4); var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5); var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) ); var is_ie6up = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5); var is_win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) ); if ( !(document.getElementById('jabberit_messenger_content')) ) { var _jabberit_content = document.createElement('div'); _jabberit_content.setAttribute('id', 'jabberit_messenger_content'); _jabberit_content = document.body.appendChild(_jabberit_content); } var _window = new JITWindows(_xtools, _jabberit_content); var _ldap = new JITLdap( _conn, _xtools, _window); function addIcon() { /** * Criada o elemento(div) jabberWriteMsg, dentro da função write_msg do módulo expressoMail1_2, * quando estiver habilitada a opção fora de escritório nos filtros. */ if(document.getElementById('jabberWriteMsg')) var StatusBar = document.getElementById('jabberWriteMsg'); else var StatusBar = document.getElementById('divStatusBar'); if(StatusBar) { if( StatusBar.id != 'jabberWriteMsg' ) { var _div = document.createElement('div'); _div.appendChild(StatusBar.parentNode.removeChild(StatusBar.previousSibling)); StatusBar.parentNode.insertBefore(_div,StatusBar); } StatusBar.style.paddingLeft = '33px'; var divJabber = document.createElement('div'); divJabber.setAttribute('id', 'JabberMessenger'); var _status = top.document.createElement('div'); _status.setAttribute('id', 'jabberit_login'); _status.style.background = 'no-repeat'; _status.style.backgroundImage = 'url(' + jabberit_group_open.src + ')'; _status.style.float = 'left'; _status.style.height = '15px'; _status.style.left = '7px'; _status.style.margin = '8 0 0 10px'; _status.style.padding = '0px'; _status.style.position = 'absolute'; _status.style.width = '15px'; _status.style.cursor = 'pointer'; divJabber.insertBefore(_status,divJabber.firstChild); var _menu; _menu = top.document.createElement('span'); _menu.setAttribute('id','fast_menu_jabberit'); _menu.style.backgroundColor = 'cecece'; _menu.style.display = 'none'; _menu.style.margin = '20px 5px 0px -15px'; _menu.style.position = 'absolute'; _menu.style.zIndex = '99999'; _menu.style.border = '1px dashed #000'; divJabber.insertBefore(_menu, divJabber.firstChild); var _menu_div = top.document.createElement('div'); _menu_div.style.background = 'no-repeat'; _menu_div.style.backgroundImage = 'url(' + jabberit_add_user.src + ')'; _menu_div.style.float = 'left'; _menu_div.style.height = '18px'; _menu_div.style.left = '19px'; _menu_div.style.margin = '0 0 0 10px'; _menu_div.style.padding = '0px'; _menu_div.style.position = 'absolute'; _menu_div.style.width = '18px'; _menu_div.style.cursor = 'pointer'; _menu_div.style.zindex = '99999999'; divJabber.insertBefore(_menu_div, divJabber.firstChild); StatusBar.insertBefore(divJabber, StatusBar.firstChild); configEvents(_menu_div,'onclick',showWindow); configEvents( _status, 'onclick', function() { var _options = [ ['Add Contacts',addContacts], ['Help',helpJabberit], ['Preferences', preferences] ]; var _style_text = 'cursor: pointer; padding:2px 2px 2px 15px; background: no-repeat url(' + jabberit_group_close.src + ');'; var _xml = _xtools.xml('menu'); var _option; var _item; var _action; var _style; for ( var i in _options ) { _option = _xml.createElement('option'); _item = _xml.createElement('item'); _item.appendChild(_xml.createTextNode(jabberitGetLang(_options[i][0]))); _style = _xml.createElement('style'); _style.appendChild(_xml.createTextNode(_style_text)); _option.appendChild(_item); _option.appendChild(_style); _xml.documentElement.appendChild(_option); } _menu.innerHTML = _xtools.parse(_xml, 'options.xsl'); _showhidden.action('onmouseover', 'onmouseout', _menu); _item = _menu.firstChild; for ( var i in _options ) { _item.childNodes[i].setAttribute('presence', _options[i]); configEvents( _item.childNodes[i], 'onclick', _options[i][1] ); } } ); } } function addContacts() { _ldap.add(); } function configEvents(pObj, pEvent, pHandler) { if ( typeof pObj == 'object' ) { if ( pEvent.substring(0, 2) == 'on' ) pEvent = pEvent.substring(2, pEvent.length); if ( pObj.addEventListener ) pObj.addEventListener(pEvent, pHandler, false); else if ( pObj.attachEvent ) pObj.attachEvent('on' + pEvent, pHandler); } } function closeWindow() { myWindow = ''; } function getFocus() { var pNewWindow = myWindow; for( var i = 15 ; i > 0 ; i-- ) { pNewWindow.moveBy(i,0); pNewWindow.moveBy(-i,0); } pNewWindow.focus(); } function helpJabberit() { var myWindowHelp = window.open( path_jabberit + 'help.php', 'HelpjabberIM', 'width=800,height=495,top=50,left=50,scrollbars=yes'); } function keyPressSearch() { var ev = arguments[0]; var element = arguments[1]; if ( ev.keyCode == 13 ) if( element.value.length >= 4 ) _ldap.search( element.value ); else alert(jabberitGetLang('Your search argument must be longer than 4 characters.')); } function openPopup() { try{ if( ! myWindow ) { myWindow = window.open( path_jabberit + 'client.php', 'JabberIM', 'width=215,height=400,top=50,left=50,toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,location=no'); myWindow.blur(); configEvents(myWindow,'onbeforeunload', closeWindow ); }else myWindow.focus(); } catch(e) { delete myWindow; myWindow = window.open( path_jabberit + 'client.php', 'JabberIM', 'width=215,height=400,top=50,left=50,toolbar=no,menubar=no,resizable=no,scrollbars=no,status=no,location=no'); myWindow.blur(); configEvents(myWindow,'onbeforeunload', closeWindow ); } } function openWindow() { var _win_contacts = _window.load('jabberit_contacts'); if( flagOpenIM == 'openWindowJabberit:false' ) { _win_contacts.size(215,400); } else _win_contacts.size(1,1); _win_contacts.position(50,50); _win_contacts.bc.style.display = "none"; _win_contacts.bx.style.display = "none"; if( _win_contacts.bz.removeEventListener ) _win_contacts.bz.removeEventListener('click',_win_contacts.button, false); else _win_contacts.bz.detachEvent('onclick',_win_contacts.button); configEvents( _win_contacts.bz, "onclick", function() { _win_contacts.size(1,1); _win_contacts.wm.style.visibility = 'hidden'; _win_contacts.position(50,50); _win_contacts.title(''); } ); var _params = {'path' : path_jabberit}; _win_contacts.content(_xtools.parse(_xtools.xml('contacts_jabberit'), 'contacts_jabberit.xsl', _params)); if( flagOpenIM == 'openWindowJabberit:false' ) { _win_contacts.wm.style.visibility = "visible"; _win_contacts.title('.:: Expresso - JMessenger ::.'); } else _win_contacts.wm.style.visibility = "hidden"; } function getPreferences() { if( flagOpenIM == '' ) { _conn.go("$this.db_im.getPreferences", function(data) { flagOpenIM = data; if(flagOpenIM == 'openWindowJabberit:true') { setTimeout('loadscript.showW();', 2000); } }); } } function preferences() { if( !(_window.get('jabberit_preferences')) ) { var _win_preferences = _window.load('jabberit_preferences'); _win_preferences.size(300,250); _win_preferences.position(150,100); _win_preferences.title('.:: Expresso - JMessenger '+jabberitGetLang('Preferences')+'::.'); _win_preferences.bc.style.display = "none"; _win_preferences.bx.style.display = "none"; _win_preferences.wc.style.padding = "5px"; if( _win_preferences.bz.removeEventListener ) _win_preferences.bz.removeEventListener('click',_win_preferences.button, false); else _win_preferences.bz.detachEvent('onclick',_win_preferences.button); configEvents( _win_preferences.bz, "onclick", function() { _win_preferences.size(1,1); _win_preferences.wm.style.visibility = 'hidden'; _win_preferences.position(50,50); _win_preferences.title(''); }); var _params = {'path' : path_jabberit, 'lang1' : jabberitGetLang('Your Preferences'), 'lang2' : 'Conectar o IM Automaticamente', 'lang3' : jabberitGetLang('Save'), 'lang4' : jabberitGetLang('Cancel') }; _win_preferences.content(_xtools.parse(_xtools.xml('preferences_jabberit'), 'preferences_jabberit.xsl', _params)); _win_preferences.wc.lastChild.lastChild.onclick = _win_preferences.close; } else { var _win_preferences = _window.get('jabberit_preferences'); _win_preferences.wm.style.visibility = "visible"; _win_preferences.position(150,100); _win_preferences.title('.:: Expresso - JMessenger '+jabberitGetLang('Preferences')+'::.'); _win_preferences.size(300,250); } var value = flagOpenIM.split(':'); var elementSelect = document.getElementById(value[0]); var valueSelect = value[1]; // Preenchendo a Select for(var i = 0; i < elementSelect.options.length; i++) if( elementSelect.options[i].value == valueSelect ) elementSelect.options[i].selected = true; } function searchUser() { var element = arguments[0].previousSibling; if( element.value.length >= 4 ) _ldap.search( element.value ); else alert(jabberitGetLang('Your search argument must be longer than 4 characters.')); } function setPreferences() { var element = document.getElementById('openWindowJabberit'); for(var i = 0 ; i < element.options.length; i++) if( element.options[i].selected == true) var value = element.options[i].value; _conn.go('$this.db_im.setPreferences', function(data) { if(data == 'true') { flagOpenIM = 'openWindowJabberit:' + value; alert(jabberitGetLang('Preferences saved with success!')); } else alert(jabberitGetLang('Error saving your preferences!')); var _win_preferences = _window.get('jabberit_preferences'); _win_preferences.close(); }, 'preferences=openWindowJabberit:' + value); } function showDiv() { var _element = ( myWindow ) ? myWindow.document.body.firstChild : null ; if( _element != null ) _element.style.visibility = 'visible'; } function showWindow() { var _win_contacts = _window.get('jabberit_contacts'); if( !is_ie ) { if ( _win_contacts ) { _win_contacts.wm.style.visibility = "visible"; _win_contacts.title('.:: Expresso - JMessenger ::.'); _win_contacts.size(215,400); } else openWindow(); } else openPopup(); } function Load() { addIcon(); getPreferences(); } Load.prototype.keyPress = keyPressSearch; Load.prototype.search = searchUser; Load.prototype.show = showDiv; Load.prototype.showW = showWindow; Load.prototype.setPrefe = setPreferences; Load.prototype.closeW = closeWindow; Load.prototype.adIcon = addIcon; window.loadscript = new Load; })();