function IM()
{
this.vcards = false;
this.statusvcard = false;
this.UsersNot = [];
this.userPrefe = false;
this.count_Vcard = 0;
this._listen = "";
this.custom_message = "";
this.timeout_composing = "";
}
IM.prototype.load_im = function()
{
this.listen();
this.requireContacts();
this.atalho();
var handler_Status = function(XmlData)
{
var data = XmlData.getElementsByTagName('retorno').item(0);
data = data.firstChild.nodeValue;
if( data )
{
if(data == 'available' || data == 'xa')
awayFlag = true;
statusFlag = data;
setTimeout('IM.ImgStatus("'+data+'")',4000);
}
};
XMLTools.request('$this.Ujabber.MyPresence', 'GET', handler_Status);
};
IM.prototype.listen = function()
{
var _this = this;
var handler = function(XMLdata)
{
try
{
var data = XMLdata.documentElement;
if ( data.hasChildNodes() )
{
data = data.firstChild;
if ( data.nodeType == 3 && data.nodeValue == 'disconnected' )
{
document.getElementById('div_contacts').innerHTML = ''+_this.get_lang("Re-connect Expresso Messenger ?")+'';
_this.ImgStatus('unavailable');
statusFlag = 'unavailable';
clearTimeout(_awayTimer);
return false;
}
}
if( !_this.userPrefe )
{
if(window.IM_Preferences)
IM_Preferences.GetYourPreferences();
}
_this.getContacts(XMLdata);
_this.getPresence(XMLdata);
_this.getComposing(XMLdata);
_this.getMessages(XMLdata);
_this.getVcard(XMLdata);
if(!_this.vcards)
{
_this.Vcard();
_this.vcards = true;
}
}catch(e){}
_this._listen = setTimeout('IM.listen()', 3000);
};
XMLTools.__RETURN_MODE__ = 'XML';
XMLTools.request('$this.Ujabber.listen', 'GET', handler);
};
IM.prototype.reconnect = function()
{
var _this = this;
var handler_reconnect = function(XMLdata)
{
if ( XMLdata.documentElement.firstChild.nodeValue == 'true' )
{
document.getElementById('div_contacts').innerHTML = '
';
document.getElementById('div_contacts').innerHTML += '
' + _this.get_lang("Wait a moment !!") + ' ';
setTimeout('IM.load_im()',2000);
_this.count_Vcard = 0;
_this.ImgStatus('available');
statusFlag = 'available';
_awayTimer = setTimeout("IM.setAway()", parseInt(IM_Preferences.im_timer_xa) * 60000 );
}else{
document.getElementById('div_contacts').innerHTML = ''+_this.get_lang("Re-connect Expresso Messenger ?")+'';
_this.ImgStatus('unavailable');
statusFlag = 'unavailable';
return false;
}
};
XMLTools.__RETURN_MODE__ = 'XML';
XMLTools.request('$this.Ujabber.reconnect', 'GET', handler_reconnect);
};
/*
* Contacts
*/
IM.prototype.requireContacts = function()
{
var handler = function(data)
{
};
XMLTools.request('$this.Ujabber.requireContacts', 'GET', handler);
};
IM.prototype.getContacts = function(data)
{
try
{
if ( data.getElementsByTagName('contacts').length > 0 )
{
var node = data.documentElement.firstChild;
while ( node.nodeName != 'contacts' )
node = node.nextSibling;
var div = document.getElementById("div_contacts");
var xsl = XMLTools.load(im_path + 'xsl/contacts.xsl?' + Date.parse(new Date));
var img = document.createElement('img');
img.id = 'img_all_groups';
img.src = img_group_open.src;
img.onclick = function(){IM.visible_group("all_groups")};
var a = document.createElement('div');
a.innerHTML = XMLTools.transform(node, xsl);
div.innerHTML = '';
div.appendChild(img);
div.appendChild(document.createTextNode(this.get_lang('List of Contacts')));
div.appendChild(a);
var group = func.byId("all_groups").firstChild;
while ( group )
{
var contact = group.firstChild.nextSibling;
while ( contact = contact.nextSibling )
{
var img = func.newEl('img');
img.src = img_unavailable.src;
func.insElB(img, func.byId(contact.id).firstChild);
}
try
{
var img = document.createElement('img');
img.src = img_group_open.src;
img.id = "img_" + group.id;
var el_parent = group;
el_parent.insertBefore(img,el_parent.firstChild);
} catch(e){}
group = group.nextSibling;
}
}
}catch(e){}
};
/*
* Visible / Unvisible
*/
IM.prototype.visible_group = function(el)
{
var _this = this;
var divParent = document.getElementById(el);
divParent.style.display = "none";
var img = document.getElementById("img_" + el);
img.onclick = function(){_this.unvisible_group(el)};
img.src = img_group_close.src;
}
IM.prototype.unvisible_group = function(el)
{
var _this = this;
var div = document.getElementById(el);
div.style.display = "";
var img = document.getElementById("img_" + el);
img.onclick = function(){_this.visible_group(el)};
img.src = img_group_open.src;
}
/*
* Presence
*/
IM.prototype.getPresence = function(data)
{
try
{
var presence = data.documentElement.firstChild;
var _this = this;
while ( presence )
{
if ( presence.nodeName != 'presence' )
{
presence = presence.nextSibling;
continue;
}
var from = presence.getAttribute('from');
var type = presence.getAttribute('type');
if ( presence.hasChildNodes() )
var status_message = presence.firstChild.nodeValue;
else
var status_message = false;
if( from )
{
switch ( type )
{
case 'subscribe' :
if ( !func.byId(from) )
_this.UsersNot[_this.UsersNot.length] = from;
else
{
Subscription.subscribed(from);
this.setStatus(statusFlag);
}
break;
case 'subscribed' :
//
break;
case 'unsubscribe' :
Subscription.unsubscribe(from);
type = 'unavailable';
func.byId(from).firstChild.src = eval('img_' + type + '.src');
break;
case 'unsubscribed' :
Subscription.unsubscribed(from);
type = 'unavailable';
func.byId(from).firstChild.src = eval('img_' + type + '.src');
break;
default :
if ( func.byId(from) )
{
func.byId(from).firstChild.src = eval('img_' + type + '.src');
var status;
if ( (status = func.byId(from + '_im_window')) )
{
status.firstChild.style.background = 'url('+func.byId(from).firstChild.src+')';
status = func.byId(from + '_im_window_message');
if( status_message && status_message != "available" )
status.innerHTML = from.substr(0, from.indexOf('@')) + ' : ' + status_message;
else
status.innerHTML = '';
}
if( document.getElementById('status_message_' + from) == null)
{
var lbl = document.createElement('label');
lbl.id = 'status_message_' + from;
if(!status_message)
lbl.innerHTML = "";
else
if( status_message != "available" )
lbl.innerHTML = "
( " + status_message + " )";
func.byId(from).appendChild(lbl);
}else{
var lbl = document.getElementById('status_message_' + from);
if(!status_message)
lbl.innerHTML = "";
else
if( status_message != "available" )
lbl.innerHTML = "
( " + status_message + " )";
}
}
}
}
if( _this.UsersNot.length > 0 )
Templates.Users_Not_Auth(_this.UsersNot);
presence = presence.nextSibling;
}
_this.Contacts_Offline();
}catch(e){}
};
/*
* Contatos - Offline
*/
IM.prototype.Contacts_Offline = function()
{
var offline = true;
if(IM.userPrefe)
offline = eval(IM_Preferences.LoadPreferences('ch_offline'));
else
offline = eval(IM_Preferences.LoadPreferences('ch_offline'));
var group = func.byId("all_groups").firstChild;
while ( group )
{
var contact = group.firstChild;
while ( contact )
{
if(contact.tagName == "DIV")
{
var childF = contact.firstChild;
if( childF.src == img_unavailable.src && !offline)
func.byId(contact.id).style.display = "none";
else
func.byId(contact.id).style.display = "block";
}
contact = contact.nextSibling;
}
group = group.nextSibling;
}
}
/*
* Get / Send - Messages
*/
IM.prototype.getMessages = function(data)
{
try
{
data = data.documentElement;
if ( data.childNodes.length > 0 )
{
var message = data.firstChild;
while ( message )
{
if ( message.tagName == 'messages' )
{
var from = message.getAttribute('from');
with ( from )
from = substr(0, indexOf('/'))
if( document.getElementById('vcard_' + from) != null)
{
var vcards = IM_Preferences.vCardLoad(from);
var nickname = vcards.substr(vcards.indexOf('NICKNAME'),vcards.length);
nickname = nickname.substr(0,nickname.indexOf('|'));
nickname = nickname.substr(nickname.indexOf(':') + 1 , nickname.length);
nickname = ( func.trim(nickname) != "" ) ? nickname : from ;
}
else
var nickname = from;
if(nickname.indexOf('@') != -1)
nickname = nickname.substr(0,nickname.indexOf('@'));
var win = document.getElementById(from + '_chatMessages');
if ( !win )
{
im_win.open_chat(from);
win = document.getElementById(from + '_chatMessages');
}
var el = message.firstChild;
while ( el )
{
var xsl = XMLTools.load(im_path + 'xsl/message.xsl?' + Date.parse(new Date));
var next = el.nextSibling;
var label = document.createElement('strong');
label.appendChild(document.createTextNode(nickname));
win.appendChild(label);
win.appendChild(document.createElement('br'));
var msg = XMLTools.transform(el, xsl);
win.innerHTML += this.emotions_icons(msg);
win.appendChild(document.createElement('br'));
win.appendChild(document.createElement('br'));
win.scrollTop = win.scrollHeight;
im_win.newMessageNotification();
el = next;
}
}
if ( (composing = func.byId(from + '_composing')) )
if ( composing.style.display = 'block' )
composing.style.display = 'none';
message = message.nextSibling;
}
}
}catch(e){}
}
IM.prototype.sendMessage = function (pJID)
{
var _this = this;
var name_document = document.getElementById(pJID + '_edita');
var envio = name_document.contentWindow.document.getElementsByTagName('body').item(0);
var imgs = envio.getElementsByTagName('img');
var cod;
var emotion_regexp;
for ( i = imgs.length - 1; i > -1; i--)
{
if ( (cod = imgs[i].getAttribute('emotion')) )
{
emotion_regexp = new RegExp(']*?emotion="' + cod_emotions[cod][1] + '"[^>]*?>', "i");
envio.innerHTML = envio.innerHTML.replace(emotion_regexp, cod);
}
else
imgs[i].parentNode.removeChild(imgs[i]);
}
envio.innerHTML = func.trim(envio.innerHTML);
envio.innerHTML = envio.innerHTML.replace(/ | +/gi, ' ');
envio.innerHTML = envio.innerHTML.replace(/
]*>/gi, '
');
if ( envio.innerHTML != "" )
{
var message_text = "";
message_text += envio.innerHTML + "
";
message_text = message_text.replace(/ | +/gi, ' ');
message_text = message_text.replace(/
]*>/gi, '
');
envio.innerHTML = '';
var message_element = document.getElementById(pJID + '_chatMessages');
var nickname = "me ";
if( IM_Preferences.jid )
{
var vcards = IM_Preferences.vCardLoad(IM_Preferences.jid);
nickname = vcards.substr(vcards.indexOf('NICKNAME'),vcards.length);
nickname = nickname.substr(0,nickname.indexOf('|'));
nickname = nickname.substr(nickname.indexOf(':') + 1 , nickname.length);
nickname = (func.trim(nickname) != "") ? nickname : IM_Preferences.jid;
if(nickname.indexOf('@') != -1)
nickname = nickname.substr(0,nickname.indexOf('@'));
}
message_element.innerHTML += '' + nickname + ' ';
message_element.innerHTML += ' ' + _this.get_lang('speak') + ':
';
message_element.innerHTML += this.emotions_icons(message_text) + '
';
message_element.scrollTop = message_element.scrollHeight;
var handler_sendMessage = function(data)
{
var data = func.interface(data);
if(!data)
alert(data);
}
XMLTools.request('$this.Ujabber.SendMessage','POST',handler_sendMessage,"to="+pJID+"&body="+escape(message_text));
}
};
/*
* Composing / GetComposing / Paused Message
*/
IM.prototype.getComposing = function(data)
{
if ( data.hasChildNodes() )
{
var node = data.documentElement.firstChild;
while ( node )
{
var composing;
if ( node.nodeName == 'composing' )
if ( (composing = func.byId(node.getAttribute('from') + '_composing')) )
if ( composing.style.display = 'none' )
composing.style.display = 'block';
if ( node.nodeName == 'paused' )
if ( (composing = func.byId(node.getAttribute('from') + '_composing')) )
if ( composing.style.display = 'block' )
composing.style.display = 'none';
node = node.nextSibling;
}
}
};
IM.prototype.composingMessage = function(pId)
{
if( IM.timeout_composing )
{
clearTimeout(IM.timeout_composing);
IM.timeout_composing = eval('setTimeout("IM.pausedMessage(\'' + pId + '\')",2000)');
}
else
{
IM.timeout_composing = eval('setTimeout("IM.pausedMessage(\'' + pId + '\')",2000)');
var handler_composingMessage = function(data)
{
};
XMLTools.request('$this.Ujabber.composingMessage', 'POST', handler_composingMessage,"to="+pId);
}
};
IM.prototype.pausedMessage = function(pId)
{
clearTimeout(IM.timeout_composing);
IM.timeout_composing = "";
var handler_pausedMessage = function(data)
{
};
XMLTools.request('$this.Ujabber.pausedMessage','POST',handler_pausedMessage,"to="+pId);
};
/*
* Get_lang
*/
IM.prototype.get_lang = function(_key, _arg1, _arg2, _arg3, _arg4)
{
var _value = "";
if ( !lang_im[_key.toLowerCase()] )
return _key + "*";
_value = lang_im[_key.toLowerCase()];
if ( _arg1 || _arg2 ||_arg3 || _arg4 )
{
for (j = 1; j <= 4; j++ )
if( eval("_arg"+j) )
{
var regExp = new RegExp("%" + j + "");
_value = _value.replace(regExp, eval("_arg"+j));
}
}
return _value;
};
IM.prototype.getWinContactsState = function()
{
try
{
var win_state = false;
win_state = ( windowItems['contacts'].state == WINDOW_STATE_REGULAR ) ? true : false;
win_state = ( win_state ) ? win_state : ( windowItems['contacts'].state == WINDOW_STATE_MAXIMIZED ) ? true : false;
return win_state;
}catch(e){}
};
IM.prototype.showContacts = function()
{
if ( this.getWinContactsState() )
im_win.windowClose('contacts_im');
else
{
im_win.windowMaximizeRestore('contacts_im');
}
};
/*
* Smiles
*/
IM.prototype.emotions_icons = function(pEmotion)
{
var emotion_regexp;
for ( i in cod_emotions )
{
try
{
emotion_regexp = new RegExp(cod_emotions[i][1], 'gi');
if ( emotion_regexp.test(pEmotion) )
{
var image = eval('smile_' + cod_emotions[i][0] + '.src.substr(smile_' +cod_emotions[i][0] + '.src.indexOf(im_path))');
emotion_regexp = new RegExp(cod_emotions[i][1], 'gi');
pEmotion = pEmotion.replace(emotion_regexp, '');
}
}catch(e){}
}
return pEmotion;
}
IM.prototype.atalho = function()
{
if ( (local = func.byId('user_info')) && !(func.byId('myStatus')) )
{
var aux = new Array();
var _mix = func.newEl('a', 'a', 'img', 'img', 'dl');
var fast_menu_link = _mix[0];
var contacts_link = _mix[1];
var fast_menu_image = _mix[2];
var contacts_image = _mix[3];
var im_fast_menu = _mix[4];
fast_menu_link.onclick = function(){IM.showFastMenu();};
contacts_link.onclick = function(){IM.showContacts();};
aux['fast_menu_image'] = new Array();
aux['fast_menu_image']['element'] = fast_menu_image;
aux['fast_menu_image']['style'] = 'width:9px;height:9px';
aux['fast_menu_image']['src'] = im_path + 'templates/default/images/menuarwopen.gif';
aux['im_fast_menu'] = new Array();
aux['im_fast_menu']['element'] = im_fast_menu;
aux['im_fast_menu']['id'] = 'fast_menu_im';
aux['im_fast_menu']['class'] = 'menu_im';
aux['contacts_image'] = new Array();
aux['contacts_image']['element'] = contacts_image;
aux['contacts_image']['id'] = 'myStatus';
aux['contacts_image']['src'] = eval('img_' + statusFlag + '.src');
aux['contacts_image']['style'] = 'width:15px;height:15px';
func.confEl(aux);
func.insEl(fast_menu_image, fast_menu_link);
func.insEl(contacts_image, contacts_link);
func.insElB(fast_menu_link, contacts_link, im_fast_menu, document.createTextNode(' '), local.firstChild);
}
else
setTimeout('IM.atalho()', 5000);
};
/*
* Vcard
*/
IM.prototype.Vcard = function()
{
var _this = this;
//if( _this.count_Vcard < 4)
if( _this.count_Vcard < 15)
{
var handler_getVcard = function(_XMLdata)
{
var data = _XMLdata.getElementsByTagName('retorno').item(0);
data = eval(data.firstChild.nodeValue);
if(!data)
setTimeout("IM.Vcard()",2000);
_this.count_Vcard++;
};
XMLTools.request('$this.Ujabber.Vcard','GET',handler_getVcard);
}else{
var handler_getVcardUser = function(XMLdata)
{
};
XMLTools.request('$this.Ujabber.VcardUser','GET',handler_getVcardUser);
}
};
IM.prototype.getVcard = function(data)
{
var _this = this;
try
{
if ( data.getElementsByTagName('vcard').length > 0 && !_this.statusvcard )
{
var div = document.getElementById("im_vcard_contacts");
var xsl = XMLTools.load(im_path + 'xsl/vcard_contacts.xsl?' + Date.parse(new Date));
_this.statusvcard = true;
div.innerHTML = "";
div.innerHTML += XMLTools.transform(data, xsl);
IM_Preferences.vCardInit();
}
}catch(e){}
};
IM.prototype.open_chat = function(pJID)
{
im_win.open_chat(pJID);
};
IM.prototype.action_button = function(pEv, pJid)
{
try
{
if ( pEv.button > 1 )
{
var posx = 0;
var posy = 0;
if (pEv.pageX || pEv.pageY)
{
posx = pEv.pageX;
posy = pEv.pageY;
}
else if (pEv.clientX || pEv.clientY)
{
posx = pEv.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
posy = pEv.clientY + document.body.scrollTop + document.documentElement.scrollTop;
}
this.menu_button_right(pJid, posx, posy);
document.oncontextmenu = new Function("return false");
}
else
if ( func.byId(pJid).firstChild.src != img_unavailable.src )
this.open_chat(pJid);
}catch(e){}
};
IM.prototype.menu_button_right = function(pElement, pX, pY)
{
var form_menu_button_right = ''+
'- ' + IM.get_lang('Nick') + ''+
'
- ' + IM.get_lang('Group') + ''+
'
- ' + IM.get_lang('Delete') + ''+
'
- ' + IM.get_lang('(Re)-requisitar Autorização') + '' +
'
- ' + IM.get_lang('See Info') + ''+
'
';
im_menu_action.menu('menu_contato', form_menu_button_right);
func.byId('menu_contato').style.top = pY-10;
func.byId('menu_contato').style.left = pX-10;
func.byId('menu_contato').style.zIndex = zValue + 10;
};
/*
* Menu
*/
IM.prototype.menu_preferences = function()
{
var posx = 0;
var posy = 0;
var pEv = arguments[0];
if (pEv.pageX || pEv.pageY)
{
posx = pEv.pageX;
posy = pEv.pageY;
}
else if (pEv.clientX || pEv.clientY)
{
posx = pEv.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
posy = pEv.clientY + document.body.scrollTop + document.documentElement.scrollTop;
}
var p_element = document.getElementById(arguments[1]);
var _xmlDoc = "";
var _this = this;
_xmlDoc = '';
im_menu_action.menu(p_element.id,parse_XmlXsl(_xmlDoc,'menu_preferences.xsl'));
func.byId(p_element).style.top = posy;
func.byId(p_element).style.left = posx;
func.byId(p_element).style.zIndex = zValue + 10;
_this.Load_Images_menu();
}
IM.prototype.Load_Images_menu = function(Element)
{
try
{
var group = document.getElementById("dl_im_menu_preferences");
var Child = group.childNodes;
for(var i = 0; i < Child.length; i++)
{
var img = document.createElement('img');
img.src = img_menu.src;
Child[i].firstChild.insertBefore(img, Child[i].firstChild.firstChild);
}
}catch(e){}
}
/*
* Função Provisória - By AlC
*/
function parse_XmlXsl(_xmlDoc, form_xsl)
{
var xslWin = false;
if ( !xslWin ) xslWin = XMLTools.load(im_path + 'xsl/' + form_xsl + '?' + Date.parse(new Date));
a = document.createElement('div');
if (window.ActiveXObject)
{
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.loadXML(_xmlDoc);
}
else
{
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(_xmlDoc, "text/xml");
}
a.innerHTML = XMLTools.transform(xmlDoc, xslWin);
return a;
}
IM.prototype.showFastMenu = function()
{
var _dt = func.newEl('dt', 'dt', 'dt', 'dt', 'dt');
var _a = func.newEl('a', 'a', 'a', 'a', 'a');
for ( var i in _dt )
{
if ( typeof _dt[i] == 'function' )
continue;
eval('var option' + (parseInt(i)+1) + ' = _dt[' + i + '];');
eval('var option' + (parseInt(i)+1) + '_link = _a[' + i + '];');
}
var _img = func.newEl('img', 'img', 'img', 'img','img');
for ( var i in _img )
{
if ( typeof _dt[i] == 'function' )
continue;
eval('var option' + (parseInt(i)+1) + '_image = _img[' + i + '];');
}
option1_link.onclick = function(){statusFlag = 'available'; IM.setStatus('available');};
option2_link.onclick = function(){statusFlag = 'xa'; awayFlag = false; IM.setStatus('xa');};
option3_link.onclick = function(){statusFlag = 'dnd'; IM.setStatus('dnd');};
option4_link.onclick = function(){statusFlag = 'unavailable'; IM.setStatus('unavailable');};
option5_link.onclick = function(){IM.setStatus('custom')};
func.confEl(option1_image, 'src', img_available.src);
func.confEl(option1_image, 'style', 'width:16px;height:16px;cursor:pointer;');
func.confEl(option2_image, 'src', img_xa.src);
func.confEl(option2_image, 'style', 'width:16px;height:16px;cursor:pointer;');
func.confEl(option3_image, 'src', img_dnd.src);
func.confEl(option3_image, 'style', 'width:16px;height:16px;cursor:pointer;');
func.confEl(option4_image, 'src', img_unavailable.src);
func.confEl(option4_image, 'style', 'width:16px;height:16px;cursor:pointer;');
func.confEl(option5_image, 'src', img_edit.src);
func.confEl(option5_image, 'style', 'width:16px;height:16px;cursor:pointer;');
func.insEl(option1_image, IM.get_lang('online'), option1_link);
func.confEl(option1_link, 'style','cursor:pointer;');
func.insEl(option1_link, option1);
func.insEl(option2_image, IM.get_lang('away'), option2_link);
func.confEl(option2_link, 'style','cursor:pointer;');
func.insEl(option2_link, option2);
func.insEl(option3_image, IM.get_lang('busy'), option3_link);
func.confEl(option3_link, 'style','cursor:pointer;');
func.insEl(option3_link, option3);
func.insEl(option4_image, IM.get_lang('offline'), option4_link);
func.confEl(option4_link, 'style','cursor:pointer;');
func.insEl(option4_link, option4);
func.insEl(option5_image, IM.get_lang('Custom message...'), option5_link);
func.confEl(option5_link, 'style','cursor:pointer;');
func.insEl(option5_link, option5);
im_menu_action.menu('fast_menu_im', option1, option2, option3, option4, option5);
};
IM.prototype.setStatus = function(pStatus)
{
try
{
var handler = function()
{
};
if ( func.byId('fast_menu_im').style.display == 'block' )
im_menu_action.menu('fast_menu_im', null);
if ( pStatus == 'custom' )
{
pStatus = prompt('Personalize seu Status : ', this.custom_message);
pStatus = 'show=' + statusFlag + '&status=' + pStatus;
}
else
{
if ( pStatus == 'unavailable' )
{
this.ImgStatus(pStatus);
pStatus = 'type=' + pStatus;
}
else
{
try
{
this.ImgStatus(pStatus);
pStatus = 'show=' + pStatus;
}catch(e){}
}
}
XMLTools.request('$this.Ujabber.setPresence', 'POST', handler, pStatus);
}catch(e){}
};
IM.prototype.ImgStatus = function(pStatus)
{
var myStatus;
if ( (myStatus = func.byId('myStatus')) )
myStatus.src = eval('img_' + pStatus + '.src');
};
IM.prototype.setAway = function()
{
if(statusFlag != 'dnd' && statusFlag != 'unavailable')
{
if ( awayFlag )
{
this.setStatus('available');
statusFlag = 'available';
awayFlag = false;
}
else
{
this.setStatus('xa');
statusFlag = 'xa';
awayFlag = true;
}
}
};
IM.prototype.infoContact = function(pUid)
{
try
{
var info = false;
var div_allg = document.getElementById('all_groups');
var elements = div_allg.firstChild;
while ( elements )
{
var childs = elements.firstChild;
while( childs )
{
if(childs.tagName == "DIV" && childs.id.indexOf(pUid) === 0 )
{
info = {'jid':childs.id, 'src':childs.firstChild.src};
break;
}
childs = childs.nextSibling;
}
if ( !info )
elements = elements.nextSibling;
else
break;
}
return info;
}catch(e){return false;}
};
var IM = new IM();