var im_win = {
chat_pJid : null,
_imWindowTemplate : null,
xslWin : false,
photo : false,
"load" : function()
{
try
{
var backFantom = func.newEl('div');
func.confEl(backFantom, 'id', 'backFantom');
func.confEl(backFantom, 'style', 'position:absolute;top:0px;left:0px;width:100%;height:100%;z-Index:-1;');
var menu_contato = func.newEl('div');
func.confEl(menu_contato, 'id', 'menu_contato');
func.confEl(menu_contato, 'class', 'menu_im');
func.confEl(menu_contato, 'style', 'position:absolute;z-index:99999');
var emotions = func.newEl('div');
func.confEl(emotions, 'id', 'shared_emotions');
func.confEl(emotions, 'class', 'emotionFrame');
func.confEl(emotions, 'style', 'position:absolute;padding:1px;left:350px;visibility:hidden;top:0px');
var font_name = func.newEl('div');
func.confEl(font_name, 'id', 'shared_fontName');
func.confEl(font_name, 'class', 'statusMenu');
func.confEl(font_name, 'style', 'position:absolute;visibility:hidden;padding:1px;left:400px;top:0px');
var font_size = func.newEl('div');
func.confEl(font_size, 'id', 'shared_fontSize');
func.confEl(font_size, 'class', 'statusMenu');
func.confEl(font_size, 'style', 'position:absolute;visibility:hidden;padding:1px;left:400px;top:0px');
var font_color = func.newEl('div');
func.confEl(font_color, 'id', 'shared_fontColor');
func.confEl(font_color, 'class', 'statusMenu');
func.confEl(font_color, 'style', 'position:absolute;visibility:hidden;padding:1px;left:400px;top:0px');
var font_style = func.newEl('div');
func.confEl(font_style, 'id', 'shared_fontStyle');
func.confEl(font_style, 'class', 'statusMenu');
func.confEl(font_style, 'style', 'position:absolute;visibility:hidden;padding:1px;left:400px;top:0px');
func.insEl(backFantom, menu_contato, emotions, font_name, font_size, font_color, font_style, false);
emotions.innerHTML = Templates.emotions();
font_name.innerHTML = Templates.font_name();
font_size.innerHTML = Templates.font_size();
font_color.innerHTML = Templates.font_color();
/*font_style.innerHTML = Templates.font_style();*/
var pId = 'contacts';
var main_menu_all = func.newEl('div');
func.confEl(main_menu_all, 'style', 'margin: 3px;');
var main_menu_head = func.newEl('div');
func.confEl(main_menu_head, 'id', pId + '_im_window_body_inner_head');
func.confEl(main_menu_head, 'style', 'margin: 0px 0px 3px 0px; border: 1px solid #809aa9; display: block;');
var main_menu_vcard = func.newEl('div');
func.confEl(main_menu_vcard, 'id', 'im_vcard_contacts');
func.confEl(main_menu_vcard, 'style', 'display: none;');
var main_menu_body = func.newEl('div');
func.confEl(main_menu_body, 'id', 'div_contacts');
func.confEl(main_menu_body, 'style', 'border: 1px solid #809aa9;');
main_menu_body.innerHTML = 'Nenhum Contato';
func.insEl(main_menu_head, main_menu_vcard, main_menu_body, main_menu_all);
var main_menu_head_picture = func.newEl('img');
func.confEl(main_menu_head_picture, 'id', pId + '_avatar');
func.confEl(main_menu_head_picture, 'src', img_photo.src);
func.confEl(main_menu_head_picture, 'style', 'float: left; height: 65px; margin: 2px; width: 49px;');
var main_menu_head_name_lable = func.newEl('span');
func.confEl(main_menu_head_name_lable,'style','margin: 3px;');
main_menu_head_name_lable.innerHTML = IM.get_lang('Nickname');
var br1 = func.newEl('br');
var main_menu_head_name = func.newEl('span');
func.confEl(main_menu_head_name, 'id', 'span_nickname');
func.confEl(main_menu_head_name, 'style', 'margin-left: 5px;');
var main_menu_head_name_txt = document.createTextNode("your nickname");
func.insEl(main_menu_head_name_txt, main_menu_head_name);
var br2 = func.newEl('br');
var br3 = func.newEl('br');
func.insEl(main_menu_head_picture, main_menu_head_name_lable, br1, main_menu_head_name, br2, br3, main_menu_head);
var main_menu_head_div = func.newEl("div");
func.confEl(main_menu_head_div,'id','menu_preferences');
func.confEl(main_menu_head_div,'class','menu_im');
func.confEl(main_menu_head_div,'style','float: left;cursor:pointer');
func.insEl(main_menu_head_div, false);
var params = [];
params['body'] = main_menu_all;
params['close'] = true;
params['height'] = 270;
params['left'] = 10;
params['id'] = pId;
params['maximize'] = true;
params['style'] = 'visibility:hidden';
params['title'] = 'Expresso Messenger';
params['top'] = 10;
params['width'] = 210;
this.build(params);
this.config(pId);
this.windowMinimize(pId + '_im');
main_menu_head.innerHTML += '';
var br3 = func.newEl('br');
func.confEl(br3, 'style', 'clear: both');
var div_ie = func.newEl('div');
func.insEl(br3, div_ie, main_menu_head);
main_menu_head_pref_img = func.newEl('img');
func.confEl(main_menu_head_pref_img, 'src', img_group_close.src);
func.confEl(main_menu_head_pref_img, 'id', 'img_pref');
main_menu_head_pref_txt = document.createTextNode(IM.get_lang('Options'));
func.insEl(main_menu_head_pref_img, main_menu_head_pref_txt, 'span_menu_pref');
}
catch(e)
{
alert("load\n\n" + e + "\n\n" + e.description)
}
},
"config" : function(pId)
{
try
{
ADD_DHTML("backFantom"+NO_DRAG);
ADD_DHTML("shared_fontStyle"+NO_DRAG);
ADD_DHTML("shared_fontColor"+NO_DRAG);
ADD_DHTML("shared_fontSize"+NO_DRAG);
ADD_DHTML("shared_fontName"+NO_DRAG);
ADD_DHTML("shared_emotions"+NO_DRAG);
ADD_DHTML(pId+"_im_window_body_inner"+NO_DRAG);
ADD_DHTML(pId+"_im_window"+NO_DRAG);
ADD_DHTML(pId+"_im_window_master"+NO_DRAG);
ADD_DHTML(pId+"_im_window_fantom"+NO_DRAG);
ADD_DHTML(pId+"_im_window_movable"+CURSOR_MOVE);
ADD_DHTML(pId+"_im_window_resize"+CURSOR_NW_RESIZE);
dd.elements.backFantom.setOpacity(0);
document.getElementById("backFantom").style.zIndex = -1;
dd.elements.contacts_im_window_resize.moveTo(dd.elements.contacts_im_window.x+dd.elements.contacts_im_window.w-dd.elements.contacts_im_window_resize.w-2, dd.elements.contacts_im_window.y+dd.elements.contacts_im_window.h-dd.elements.contacts_im_window_resize.h-2);
dd.elements.contacts_im_window_movable.moveTo(dd.elements.contacts_im_window.x, dd.elements.contacts_im_window.y);
dd.elements.contacts_im_window_movable.setOpacity(0);
dd.elements.contacts_im_window_resize.setOpacity(1);
dd.elements.contacts_im_window_resize.moveTo(dd.elements.contacts_im_window_fantom.x+dd.elements.contacts_im_window_fantom.w-dd.elements.contacts_im_window_resize.w-2, dd.elements.contacts_im_window_fantom.y+dd.elements.contacts_im_window_fantom.h-dd.elements.contacts_im_window_resize.h-2);
var contacts_im_window = new Object();
contacts_im_window.x = dd.elements.contacts_im_window_master.x;
contacts_im_window.y = dd.elements.contacts_im_window_master.y;
contacts_im_window.w = dd.elements.contacts_im_window_master.w;
contacts_im_window.h = dd.elements.contacts_im_window_master.h;
contacts_im_window.state = WINDOW_STATE_REGULAR;
windowItems[pId] = contacts_im_window;
}
catch(e)
{
alert("config\n\n" + e + "\n\n" + e.description)
}
},
"build" : function()
{
var pBody = '';
var pClose = true;
var pHeight = 360;
var pId = false;
var pLeft = NaN;
var pMaximize = true;
var pMinimize = true;
var pStyle = '';
var pTitle = '';
var pTop = NaN;
var pWidth = 250;
for ( var i = 0; i < arguments.length; i++ )
{
for ( var n in arguments[i] )
if ( !func.isUndefined(arguments[i][n]) )
switch ( n )
{
case 'body' : pBody = arguments[i][n]; break;
case 'close' : pClose = arguments[i][n]; break;
case 'height' : pHeight = arguments[i][n]; break;
case 'id' : pId = arguments[i][n]; break;
case 'left' : pLeft = arguments[i][n]; break;
case 'maximize': pMaximize = arguments[i][n]; break;
case 'minimize': pMinimize = arguments[i][n]; break;
case 'style' : pStyle = arguments[i][n]; break;
case 'title' : pTitle = arguments[i][n]; break;
case 'top' : pTop = arguments[i][n]; break;
case 'width' : pWidth = arguments[i][n]; break;
}
}
if ( !pId || pHeight < 60 || pWidth < 100 )
return false;
if ( isNaN(pLeft) )
if ( windowItems[pId] )
pLeft = windowItems[pId].x;
else
pLeft = Math.floor(Math.random()*(dd.getWndH()-100));
if ( isNaN(pTop) )
if ( windowItems[pId] )
pTop = windowItems[pId].y;
else
pTop = Math.floor(Math.random()*(dd.getWndW()-pHeight-480))
if ( windowItems[pId] )
{
pHeight = dd.elements[pId + "_im_window_body_inner"].h;
pWidth = dd.elements[pId + "_im_window_body_inner"].w;
}
if ( !this.xslWin ) this.xslWin = XMLTools.load(im_path + 'xsl/window.xsl?' + Date.parse(new Date));
_xmlDoc = '';
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, this.xslWin);
document.getElementsByTagName('body').item(0).appendChild(a);
switch ( typeof pBody )
{
case 'object' :
func.insEl(pBody, pId + '_im_window_body_inner');
break;
case 'string' :
func.byId(pId + '_im_window_body_inner').innerHTML = pBody;
}
RoundedTop('div#' + pId + '_im_window_master', '', '#cbdae4');
this.windowMaximizeZ(pId);
},
"hideAllChatSelections" : function()
{
this.hideEmotionSelection();
this.hideFontNameSelection();
this.hideFontSizeSelection();
this.hideFontColorSelection();
this.hideFontStyleSelection();
},
"hideWindowItem" : function(pId)
{
try
{
dd.elements[pId + "_im_window"].hide();
dd.elements[pId + "_im_window_master"].hide();
dd.elements[pId + "_im_window_fantom"].hide();
dd.elements[pId + "_im_window_resize"].hide();
dd.elements[pId + "_im_window_movable"].hide();
if ( (name_document = document.getElementById(pId + '_divEdita')) )
{
name_document.innerHTML = '';
var contact = func.byId(pId);
var _status = IM.vcard_contacts[contact.getAttribute('nuncontact')].online
contact.firstChild.src = ( _status == parseInt(1) ) ? img_online.src : img_offline.src;
}
}
catch(e)
{}
},
"incZ" : function()
{
zValue += 5;
return zValue;
},
"drag" : function()
{
try
{
var objName = dd.obj.name;
i = objName.indexOf("_");
objName = objName.substr(0,i);
this.incZ();
document.getElementById(objName + "_im_window_fantom").style.zIndex = zValue;
dd.elements[objName + "_im_window_fantom"].setOpacity(0.5);
document.getElementById(objName + "_im_window_fantom").className = "im_window_fantom";
var posX = dd.obj.x;
var posY = dd.obj.y;
if ( posX < 0 )
posX = 0;
if ( posY < 0 )
posY = 0;
dd.elements[objName + "_im_window_resize"].setOpacity(0);
if ( dd.obj.name == (objName + "_im_window_resize") )
{
windowState = WINDOW_STATE_REGULAR;
// check if the re-size goes out of the screen
if ( posX > ( dd.getWndW() - 15 ) )
posX = dd.getWndW()-15;
if ( posY > ( dd.getWndH() - 13 ) )
posY = dd.getWndH()-13;
// everything is fine, let's change the size of all required objects
var newW = posX-dd.elements[objName + "_im_window_fantom"].x+15;
var newH = posY-dd.elements[objName + "_im_window_fantom"].y+15;
if ( newW < 100) newW = 100;
if ( newH < 100) newH = 100;
dd.elements[objName + "_im_window_fantom"].resizeTo(newW, newH);
if( document.getElementById(objName + "_chatMessages"))
{
func.confEl(document.getElementById(objName + "_chatMessages"),"style","width:" + (newW - 105) +";height:" + (newH - 150) +";margin: 2px 0px 2px 2px; overflow:auto;");
func.confEl(document.getElementById(objName + '_edita'),"style","width:" + (newW - 105) + ";height: 50px;margin: 3px 1px 0px 2px;float: left;");
}
dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-2, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-2);
var windowItem = windowItems[objName];
windowItem.state = WINDOW_STATE_REGULAR;
}
else
{
if ( posX > ( dd.getWndW() - dd.elements[objName + "_im_window_master"].w ) )
posX = dd.getWndW() - dd.elements[objName + "_im_window_master"].w;
if ( posY > ( dd.getWndH() - dd.elements[objName + "_im_window_master"].h ) )
posY = dd.getWndH() - dd.elements[objName + "_im_window_master"].h;
dd.elements[objName + "_im_window_fantom"].moveTo(posX, posY);
}
}
catch(e)
{
}
},
"drop" : function()
{
try
{
document.getElementById("backFantom").style.zIndex = -1;
var objName = dd.obj.name;
i = objName.indexOf("_");
objName = objName.substr(0,i);
var posX = dd.obj.x;
var posY = dd.obj.y;
if ( posX < 0 )
posX = 0;
if ( posY < 0 )
posY = 0;
if ( posX > ( dd.getWndW() - dd.elements[objName + "_im_window_master"].w ) )
posX = dd.getWndW() - dd.elements[objName + "_im_window_master"].w;
if ( posY > ( dd.getWndH() - dd.elements[objName + "_im_window_master"].h ) )
posY = dd.getWndH() - dd.elements[objName + "_im_window_master"].h;
dd.elements[objName + "_im_window_resize"].setOpacity(1);
if ( dd.obj.name == (objName + "_im_window_resize") )
{
var newW = dd.obj.x-dd.elements[objName + "_im_window_fantom"].x+17;
var newH = dd.obj.y-dd.elements[objName + "_im_window_fantom"].y+17;
if ( newW < 100) newW = 100;
if ( newH < 100) newH = 100;
var winW = dd.elements[objName + "_im_window_master"].w - dd.elements[objName + "_im_window"].w;
var winH = dd.elements[objName + "_im_window_master"].h - dd.elements[objName + "_im_window"].h;
dd.elements[objName + "_im_window_fantom"].resizeTo(newW, newH);
dd.elements[objName + "_im_window_master"].resizeTo(newW, newH);
var bodyW = dd.elements[objName + "_im_window"].w - dd.elements[objName + "_im_window_body_inner"].w;
var bodyH = dd.elements[objName + "_im_window"].h - dd.elements[objName + "_im_window_body_inner"].h;
dd.elements[objName + "_im_window"].resizeTo(newW - winW, newH - winH);
bodyW = dd.elements[objName + "_im_window"].w - bodyW;
bodyH = dd.elements[objName + "_im_window"].h - bodyH;
dd.elements[objName + "_im_window_body_inner"].resizeTo(bodyW, bodyH);
dd.elements[objName + "_im_window_movable"].resizeTo(newW-55, 25);
dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-2, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-2);
}
else
{
dd.elements[objName + "_im_window_fantom"].moveTo(posX, posY);
dd.elements[objName + "_im_window_master"].moveTo(posX, posY);
dd.elements[objName + "_im_window"].moveTo(posX, (posY+4));
dd.elements[objName + "_im_window_movable"].moveTo(posX, posY);
dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-3, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-3);
}
this.windowMaximizeZ(objName);
dd.elements[objName + "_im_window_fantom"].setOpacity(0);
var windowItem = windowItems[objName];
if ( windowItem != null )
{
windowItem.x = dd.elements[objName + "_im_window_master"].x;
windowItem.y = dd.elements[objName + "_im_window_master"].y;
windowItem.w = dd.elements[objName + "_im_window_master"].w;
windowItem.h = dd.elements[objName + "_im_window_master"].h;
}
}catch(e){}
},
"pick" : function()
{
document.getElementById("backFantom").style.zIndex = zValue;
this.hideAllChatSelections();
var objName = dd.obj.name;
i = objName.indexOf("_im");
objName = objName.substr(0,i);
ACTIVE_OBJECTID = objName;
},
"showWindowItem" : function(pId)
{
/*
* Não tire esta linha
* Isso deve estar aqui para a janela 'oculta'
* não 'piscar' na tela no momento que é criada.
*/
func.byId(pId + '_im_window_body_inner').style.overflow = 'auto';
if ( (name_document = document.getElementById(pId + '_divEdita')) )
{
name_document.innerHTML = '';
name_document = document.getElementById(pId + '_edita');
name_document.contentWindow.document.write('
');
name_document.contentWindow.document.close();
name_document.contentWindow.document.designMode = "On";
func.attachEvent(name_document.contentWindow.document, 'keypress', im_win.getText);
func.attachEvent(name_document.contentWindow.document, 'keyup', im_win.clearText);
name_document.contentWindow.focus();
}
dd.elements[pId + "_im_window_master"].show();
dd.elements[pId + "_im_window"].show();
dd.elements[pId + "_im_window_fantom"].show();
dd.elements[pId + "_im_window_resize"].show();
dd.elements[pId + "_im_window_movable"].show();
},
"windowMaximizeZ" : function(objName)
{
try
{
this.incZ();
document.getElementById(objName + "_im_window_fantom").style.zIndex = zValue-3;
document.getElementById(objName + "_im_window_master").style.zIndex = zValue-2;
document.getElementById(objName + "_im_window").style.zIndex = zValue-1;
document.getElementById(objName + "_im_window_body_inner").style.zIndex = zValue-1;
document.getElementById(objName + "_im_window_resize").style.zIndex = zValue;
document.getElementById(objName + "_im_window_movable").style.zIndex = zValue;
if ( dd.elements[objName + "_im_window_movable"] )
dd.elements[objName + "_im_window_movable"].z = zValue+1;
}catch(e){}
},
"windowMinimize" : function(objName)
{
with(objName)
objName = substr(0, indexOf('_im'));
this.hideWindowItem(objName);
windowItem = windowItems[objName];
if ( windowItem != null )
{
windowItem.state = WINDOW_STATE_MINIMIZED;
}
},
"windowMaximizeRestore" : function(objName)
{
with(objName)
objName = substr(0, indexOf('_im'));
this.hideAllChatSelections();
windowItem = windowItems[objName];
if ( windowItem != null )
{
var bodyW = dd.elements[objName + "_im_window"].w - dd.elements[objName + "_im_window_body_inner"].w;
var bodyH = dd.elements[objName + "_im_window"].h - dd.elements[objName + "_im_window_body_inner"].h;
if ( windowItem.state==WINDOW_STATE_REGULAR )
{
windowItem.x = dd.elements[objName + "_im_window_master"].x;
windowItem.y = dd.elements[objName + "_im_window_master"].y;
windowItem.w = dd.elements[objName + "_im_window_master"].w;
windowItem.h = dd.elements[objName + "_im_window_master"].h;
var bodyX = dd.elements[objName + "_im_window_body_inner"].x + dd.elements[objName + "_im_window"].x;
var bodyY = dd.elements[objName + "_im_window_body_inner"].y + dd.elements[objName + "_im_window"].y;
dd.elements[objName + "_im_window_fantom"].moveTo(0, 0);
dd.elements[objName + "_im_window_master"].moveTo(0, 0);
dd.elements[objName + "_im_window"].moveTo(0, 4);
dd.elements[objName + "_im_window_fantom"].resizeTo(dd.getWndW(), dd.getWndH());
dd.elements[objName + "_im_window_master"].resizeTo(dd.getWndW(), dd.getWndH());
dd.elements[objName + "_im_window"].resizeTo(dd.getWndW(), dd.getWndH() - 5);
dd.elements[objName + "_im_window_body_inner"].resizeTo(dd.getWndW() - bodyW, dd.getWndH() - bodyH - 5);
dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-2, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-2);
windowItem.state = WINDOW_STATE_MAXIMIZED;
window.status = objName + "'s Z: " + document.getElementById(objName+"_im_window").style.zIndex;
}
else
{
dd.elements[objName + "_im_window_fantom"].resizeTo(windowItem.w, windowItem.h);
dd.elements[objName + "_im_window_master"].resizeTo(windowItem.w, windowItem.h);
dd.elements[objName + "_im_window"].resizeTo(windowItem.w, windowItem.h - 5);
dd.elements[objName + "_im_window_body_inner"].resizeTo(windowItem.w - bodyW, windowItem.h - bodyH - 5);
dd.elements[objName + "_im_window_fantom"].moveTo(windowItem.x, windowItem.y);
dd.elements[objName + "_im_window_master"].moveTo(windowItem.x, windowItem.y);
dd.elements[objName + "_im_window_resize"].moveTo(dd.elements[objName + "_im_window_fantom"].x+dd.elements[objName + "_im_window_fantom"].w-dd.elements[objName + "_im_window_resize"].w-2, dd.elements[objName + "_im_window_fantom"].y+dd.elements[objName + "_im_window_fantom"].h-dd.elements[objName + "_im_window_resize"].h-2);
windowItem.state = WINDOW_STATE_REGULAR;
}
dd.elements[objName + "_im_window_movable"].moveTo(dd.elements[objName + "_im_window"].x, dd.elements[objName + "_im_window"].y);
dd.elements[objName + "_im_window_movable"].resizeTo(dd.elements[objName + "_im_window"].w-55, 25);
this.showWindowItem(objName);
this.windowMaximizeZ(objName);
}
if( !this.photo )
{
setTimeout('im_win.get_photo_ldap(\"user@user\")',1000 );
this.photo = true;
}
},
"create_window" : function()
{
pId = arguments[0]['id'];
if ( document.getElementById(pId + '_im_window'))
{
this.windowMaximizeZ(pId);
this.showWindowItem(pId);
}
else
{
this.build(arguments[0]);
ADD_DHTML(pId + "_im_window_body_inner"+NO_DRAG);
ADD_DHTML(pId + "_im_window"+NO_DRAG);
ADD_DHTML(pId + "_im_window_master"+NO_DRAG);
ADD_DHTML(pId + "_im_window_fantom"+NO_DRAG);
ADD_DHTML(pId + "_im_window_movable"+CURSOR_MOVE);
ADD_DHTML(pId + "_im_window_resize"+CURSOR_NW_RESIZE);
dd.elements[pId + "_im_window_movable"].moveTo(dd.elements[pId + "_im_window"].x, dd.elements[pId + "_im_window"].y);
dd.elements[pId + "_im_window_movable"].resizeTo(dd.elements[pId + "_im_window"].w-20, 25);
dd.elements[pId + "_im_window_movable"].setOpacity(0);
dd.elements[pId + "_im_window_resize"].setOpacity(1);
dd.elements[pId + "_im_window_resize"].moveTo(dd.elements[pId + "_im_window"].x+dd.elements[pId + "_im_window"].w-dd.elements[pId + "_im_window_resize"].w-2, dd.elements[pId + "_im_window"].y+dd.elements[pId + "_im_window"].h-dd.elements[pId + "_im_window_resize"].h-2);
dd.elements[pId + "_im_window_resize"].moveTo(dd.elements[pId + "_im_window_fantom"].x+dd.elements[pId + "_im_window_fantom"].w-dd.elements[pId + "_im_window_resize"].w-2, dd.elements[pId + "_im_window_fantom"].y+dd.elements[pId + "_im_window_fantom"].h-dd.elements[pId + "_im_window_resize"].h-2);
var windowItem = new Object();
windowItem.x = dd.elements[pId + "_im_window_master"].x;
windowItem.y = dd.elements[pId + "_im_window_master"].y;
windowItem.w = dd.elements[pId + "_im_window_master"].w;
windowItem.h = dd.elements[pId + "_im_window_master"].h;
windowItem.state = WINDOW_STATE_MINIMIZED;
windowItems[pId] = windowItem;
title = (arguments[0]['title']) ? arguments[0]['title'] : arguments[0]['id'];
this.windowMinimize(pId + '_im');
this.windowMaximizeRestore(pId + '_im');
}
},
"open_chat" : function(pId)
{
if ( !func.byId(pId + '_im_window') )
{
text = '';
text += '';
text += '';
text += '
';
text += '
![Display Picture Display Picture](' + im_path + 'templates/default/images/photo.png)
';
text += '
';
text += '
';
text += '
';
text += '
';
text += '';
text += ' - ';
text += '
';
text += ' ';
text += ' - |
';
text += ' - ';
text += ' '+IM.get_lang('Font')+'';
text += '
';
text += ' - |
';
text += ' - ';
text += ' '+IM.get_lang('Size')+'';
text += '
';
text += ' - |
';
text += ' - ';
text += ' '+IM.get_lang('Color')+'';
text += '
';
text += ' - |
';
text += ' - ';
text += ' '+IM.get_lang('Style')+'';
text += '
';
text += '
';
text += '';
text += '
';
text += '
';
var params = [];
params['body'] = text;
params['height'] = 225;
params['id'] = pId;
params['maximize'] = false;
params['minimize'] = false;
params['title'] = pId;
params['width'] = 320;
this.create_window(params);
// Photo Ldap;
this.get_photo_ldap(pId);
name_document = document.getElementById(pId + '_edita');
name_document.contentWindow.document.write('');
name_document.contentWindow.document.close();
name_document.contentWindow.document.designMode = "On";
func.attachEvent(name_document.contentWindow.document, 'keypress', im_win.getText);
func.attachEvent(name_document.contentWindow.document, 'keyup', im_win.clearText);
name_document.contentWindow.focus();
var status = func.byId(pId + '_im_window');
status.firstChild.style.background = 'url('+func.byId(pId).firstChild.src+')';
}
else
{
this.showWindowItem(pId);
}
},
"get_photo_ldap" : function(IdLdap)
{
var uid_ldap = IdLdap.substr(0,IdLdap.indexOf('@'));
var handler_photo_ldap = function(_XMLdata)
{
var data = _XMLdata.getElementsByTagName('retorno').item(0);
data = eval(data.firstChild.nodeValue);
if(data)
{
IdLdap = ( IdLdap == 'user@user' ) ? 'contacts' : IdLdap;
if( document.getElementById(IdLdap + "_avatar") != null ){
var ph_img = document.getElementById(IdLdap + "_avatar");
ph_img.src = (im_path + "inc/class.ldap_im.inc.php?user="+uid_ldap) ? im_path + "inc/class.ldap_im.inc.php?user="+uid_ldap : img_photo.src ;
}
}
}
XMLTools.__RETURN_MODE__ = 'XML';
XMLTools.request('$this.ldap_im.photo_ldap','POST',handler_photo_ldap,'uid='+uid_ldap);
},
"windowClose" : function(objName)
{
with(objName)
objName = substr(0, indexOf('_im'));
this.hideWindowItem(objName);
this.hideAllChatSelections();
var windowItem = windowItems[objName];
if ( windowItem != null )
windowItem.state = WINDOW_STATE_CLOSED;
if ( objName != 'contacts' )
{
var win = document.getElementById(objName + '_im_window_master');
var resize = document.getElementById(objName + '_im_window_resize');
var fantom = document.getElementById(objName + '_im_window_fantom');
var movable = document.getElementById(objName + '_im_window_movable');
win.parentNode.removeChild(win);
resize.parentNode.removeChild(resize);
fantom.parentNode.removeChild(fantom);
movable.parentNode.removeChild(movable);
//delete windowItem;
}
},
"hideEmotionSelection" : function()
{
emotionsDiv = document.getElementById("shared_emotions");
if ( isEmotionSelectionVisible )
{
emotionsDiv.style.visibility = "hidden";
isEmotionSelectionVisible = false;
}
},
"highlightie5" : function (e)
{
if ( e.className == "emotionItem" )
e.className = "emotionItem-sel";
else if ( e.className == "menuitems" )
e.className = "menuitems-sel";
},
"lowlightie5" : function(e)
{
if ( e.className == "emotionItem-sel" )
e.className = "emotionItem";
else if ( e.className == "menuitems-sel" )
e.className = "menuitems";
},
"addEmotion" : function(emotion)
{
var n_document = document.getElementById(this.chat_pJid + '_edita');
var edita = n_document.contentWindow.document.getElementsByTagName('body').item(0);
edita.innerHTML += IM.emotions_icons(emotion);
this.hideEmotionSelection();
},
"showEmotionSelection" : function(objName)
{
this.chat_pJid = objName;
activeChatWindowId = objName;
var emotionsDiv = document.getElementById("shared_emotions");
if(!isEmotionSelectionVisible)
{
this.hideAllChatSelections();
chatObj = dd.elements[objName + "_im_window"];
x = chatObj.x + 6;
y = chatObj.y + chatObj.h - 200;
dd.elements.shared_emotions.moveTo(x,y);
this.incZ();
document.getElementById("shared_emotions").style.zIndex = zValue;
emotionsDiv.style.visibility = "visible";
isEmotionSelectionVisible = true;
}
else
{
this.hideAllChatSelections();
}
},
"showFontNameSelection" : function(objName)
{
this.chat_pJid = objName;
activeChatWindowId = objName;
var objDiv = document.getElementById("shared_fontName");
if(!isFontNameSelectionVisible)
{
this.hideAllChatSelections();
chatObj = dd.elements[objName + "_im_window"];
x = chatObj.x + 85;
y = chatObj.y + chatObj.h - 185;
dd.elements.shared_fontName.moveTo(x,y);
this.incZ();
document.getElementById("shared_fontName").style.zIndex = zValue;
objDiv.style.visibility = "visible";
isFontNameSelectionVisible = true;
}
else
{
this.hideAllChatSelections();
}
},
"hideFontNameSelection" : function()
{
var objDiv = document.getElementById("shared_fontName");
if ( isFontNameSelectionVisible )
{
objDiv.style.visibility = "hidden";
isFontNameSelectionVisible = false;
}
},
"showFontSizeSelection" : function(objName)
{
this.chat_pJid = objName;
activeChatWindowId = objName;
var objDiv = document.getElementById("shared_fontSize");
if ( !isFontSizeSelectionVisible )
{
this.hideAllChatSelections();
chatObj = dd.elements[objName + "_im_window"];
x = chatObj.x + 154;
y = chatObj.y + chatObj.h - 200;
dd.elements.shared_fontSize.moveTo(x,y);
this.incZ();
document.getElementById("shared_fontSize").style.zIndex = zValue;
objDiv.style.visibility = "visible";
isFontSizeSelectionVisible = true;
}
else
{
this.hideAllChatSelections();
}
},
"hideFontSizeSelection" : function()
{
var objDiv = document.getElementById("shared_fontSize");
if ( isFontSizeSelectionVisible )
{
objDiv.style.visibility = "hidden";
isFontSizeSelectionVisible = false;
}
},
"showFontColorSelection" : function(objName)
{
this.chat_pJid = objName;
activeChatWindowId = objName;
var objDiv = document.getElementById("shared_fontColor");
if ( !isFontColorSelectionVisible )
{
this.hideAllChatSelections();
chatObj = dd.elements[objName + "_im_window"];
x = chatObj.x + 191;
y = chatObj.y + chatObj.h - 200;
dd.elements.shared_fontColor.moveTo(x,y);
this.incZ();
document.getElementById("shared_fontColor").style.zIndex = zValue;
objDiv.style.visibility = "visible";
isFontColorSelectionVisible = true;
}
else
{
this.hideAllChatSelections();
}
},
"showFontStyleSelection" : function(objName)
{
this.chat_pJid = objName;
activeChatWindowId = objName;
var objDiv = document.getElementById("shared_fontStyle");
if ( !isFontStyleSelectionVisible )
{
this.hideAllChatSelections();
chatObj = dd.elements[objName + "_im_window"];
x = chatObj.x + 234;
y = chatObj.y + chatObj.h - 181;
dd.elements.shared_fontStyle.moveTo(x,y);
this.incZ();
document.getElementById("shared_fontStyle").style.zIndex = zValue;
objDiv.style.visibility = "visible";
isFontStyleSelectionVisible = true;
}
else
{
this.hideAllChatSelections();
}
},
"hideFontColorSelection" : function()
{
var objDiv = document.getElementById("shared_fontColor");
if ( isFontColorSelectionVisible )
{
objDiv.style.visibility = "hidden";
isFontColorSelectionVisible = false;
}
},
"hideFontStyleSelection" : function()
{
var objDiv = document.getElementById("shared_fontStyle");
if ( isFontStyleSelectionVisible )
{
objDiv.style.visibility = "hidden";
isFontStyleSelectionVisible = false;
}
},
"newMessageNotification" : function()
{
if ( !focusFlag )
{
if ( document.title=="......................" )
document.title = IM.get_lang("New Message!");
else
document.title = "......................";
this.Mod_Notification();
if ( newMessageTimer )
clearTimeout(newMessageTimer);
newMessageTimer = setTimeout("im_win.newMessageNotification()", 1000);
}
else
{
if ( newMessageTimer ) clearTimeout(newMessageTimer);
}
},
"Mod_Notification" : function()
{
// Aviso Normal
if(eval(IM_Preferences.LoadPreferences('rd_nm')))
{
}
// Aviso Chato
if(eval(IM_Preferences.LoadPreferences('rd_ch')))
{
if(self.moveBy)
{
for(i=10;i>0;i--)
{
self.moveBy(i,0);
self.moveBy(-i,0);
}
}
}
},
"getText" : function(e)
{
if ( !focusFlag ) windowFocus();
evt = e.keyCode;
pId = ( e.srcElement ) ? e.srcElement.id : e.target.getElementsByTagName('body').item(0).id;
pId = pId.replace('_at_', '@').replace(/_dot_/g, '.')
IM.composingMessage(pId);
switch ( evt )
{
case 13 :
if ( !e.shiftKey )
IM.sendMessage(pId);
return false;
break;
case 27 :
im_win.windowClose(pId + '_im');
break;
}
},
"clearText" : function(e)
{
if ( !focusFlag ) windowFocus();
evt = e.keyCode;
_text = ( e.srcElement ) ? e.srcElement.id : e.target.getElementsByTagName('body').item(0);
switch ( evt )
{
case 13 :
//if ( !e.shiftKey )
_text.innerHTML = '';
return false;
break;
}
}
}
function my_DragFunc()
{
im_win.drag();
}
function my_DropFunc()
{
im_win.drop();
}
function my_PickFunc()
{
im_win.pick();
}
function selectDiv(obj) {
obj.className = "sel-small";
}
function unselectDiv(obj) {
obj.className = "des-small";
}
function getElementsBySelector(selector)
{
var i;
var s=[];
var selid="";
var selclass="";
var tag=selector;
var objlist=[];
if ( selector.indexOf(" ") > 0 )
{//descendant selector like "tag#id tag"
s=selector.split(" ");
var fs=s[0].split("#");
if ( fs.length == 1 )
return(objlist);
return(document.getElementById(fs[1]).getElementsByTagName(s[1]));
}
if ( selector.indexOf("#") > 0 )
{//id selector like "tag#id"
s=selector.split("#");
tag=s[0];
selid=s[1];
}
if ( selid != "" )
{
objlist.push(document.getElementById(selid));
return(objlist);
}
if ( selector.indexOf(".") > 0 )
{//class selector like "tag.class"
s=selector.split(".");
tag=s[0];
selclass=s[1];
}
var v = document.getElementsByTagName(tag); // tag selector like "tag"
if ( selclass == "" )
return(v);
for ( i = 0; i < v.length; i++ )
if ( v[i].className ==selclass )
objlist.push(v[i]);
return(objlist);
}
function AddTop(el,bk,color,size)
{
try
{
var i;
var d=document.createElement("b");
var cn="_r";
var lim=4;
if(size && size=="small"){ cn="_rs"; lim=2}
d.className="_rtop";
d.style.backgroundColor=bk;
for(i=1;i<=lim;i++)
{
var x=document.createElement("b");
x.className=cn + i;
x.style.backgroundColor=color;
d.appendChild(x);
}
el.insertBefore(d,el.firstChild);
}
catch(e)
{}
}
function RoundedTop(selector,bk,color,size){
var i;
var v=getElementsBySelector(selector);
for(i=0;i