function emInfoContact()
{
this.email = "";
this.timeout = null;
this.timeout_hide = null;
this._mousemove = document.onmousemove;
this.td;
this.createCard();
}
emInfoContact.prototype.createCard = function(){
var pic= new Image();
pic.src="./templates/default/images/card.gif";
card = document.createElement("DIV");
card.id = "card_cc";
card.style.display = "none";
card.style.width = "244px";
card.style.backgroundImage = "url("+pic.src+")";
card.style.height = "134px";
card.style.position = "absolute";
card.innerHTML = "
";
document.body.appendChild(card);
}
emInfoContact.prototype.begin = function(td, email){
var card = Element("card_cc");
if(_this.td != td){
this.email = email;
this.td = td;
clearTimeout(this.timeout);
this.timeout = setTimeout("InfoContact.search('"+email+"')",1000);
}
}
emInfoContact.prototype.label = function (text){
InfoContact.hide();
var div_label = Element("div_label");
if(!div_label) {
div_label = document.createElement("DIV");
div_label.id = "div_label";
div_label.style.padding = "2px";
div_label.style.display = "none";
div_label.style.position = "absolute";
div_label.style.border = "1px solid black";
div_label.style.backgroundColor="#FFFFDC";
document.body.appendChild(div_label);
}
div_label.innerHTML = text;
div_label.style.top = findPosY(this.td) + 20 - Element("divScrollMain").scrollTop;
div_label.style.left = findPosX(this.td) + 20;
div_label.style.display = '';
setTimeout("InfoContact.hide()",1000);
}
emInfoContact.prototype.show = function (data){
var _this = this;
var card = Element("card_cc");
//if(card.style.display != '')
{
card.style.left = findPosX(this.td) + 20;
var y = findPosY(this.td) + 20 - Element("divScrollMain").scrollTop;
var w_height = is_ie ? document.body.clientHeight + document.body.scrollTop : window.innerHeight + window.pageYOffset;
if(y + 160 > w_height)
card.style.top = y - 160;
else
card.style.top = y;
card.style.display = '';
var cn = data.cn;
if(cn && cn.toString().length > 35)
cn = cn.toString().substring(0,30) + "...";
Element("card_cc_td").innerHTML = ""+
" | "+
" "+get_lang("Sender's Information")+""+
_this.verifyIM(data.uid,data.email)+
" "+(data.telefone ? data.telefone : get_lang("None") )+""+
" |
"+
""+cn+""+
" "+data.email+""+
" |
";
this.timeout_hide = setTimeout("InfoContact.hide()",1000);
}
}
emInfoContact.prototype.search = function (email){
var _this = this;
var ldapSearched = false;
var handler_search = function(data){
if(data != null){
_this.show(data);
}
else if(!ldapSearched) {
ldapSearched = true;
cExecute ("$this.ldap_functions.getUserByEmail&email="+email, handler_search);
}
else
_this.label(email);
}
if(findPosX(_this.td) == 0) {
_this.hide();
return;
}
handler_search();
//cExecute ("$this.db_functions.getUserByEmail&email="+email, handler_search);
}
emInfoContact.prototype.hide = function(){
this.email = "";
clearTimeout(this.timeout);
if(Element("div_label"))
Element("div_label").style.display = 'none';
if(Element("card_cc"))
Element("card_cc").style.display = "none";
}
emInfoContact.prototype.sendMail = function(name, email){
Element("msg_number").value = "\""+ name+"\" <"+email+">";
InfoContact.hide();
new_message("new","null");
}
emInfoContact.prototype.openChat = function(event, email){
IM.action_button(event, '1', email ,false);
}
emInfoContact.prototype.verifyPermissionIM = function(uid, domain, email){
var handler_verifyPermissionIM = function(data){
if(!data){
alert("Esse usuário ("+uid+") não possui o módulo Expresso IM habilitado");
}
else
Preferences.updateLoad(''+uid+"@"+domain+'');
}
IM.UserPermission(uid,handler_verifyPermissionIM);
}
emInfoContact.prototype.verifyIM = function(uid, email){
if(!window.IM)
return "
";
if(!IM.array_users || !IM.array_users.length)
return "
";
var status = "Not Registered";
var subscription = "";
var _return = "";
var jid = "";
var array_jid = null;
for(i = 1; i <= IM.array_users.length; i++){
if(!IM.array_users[i] || !IM.array_users[i].jid)
continue;
jid = IM.array_users[i].jid;
array_jid = jid.split("@");
if(array_jid[0] == uid){
status = IM.array_users[i].online;
subscription = IM.array_users[i].subscription;
break;
}
else
jid = uid +"@"+array_jid[1];
}
if(subscription == 'both') {
if(status == 1) {
_return = "
";
_return += ""+get_lang("User connected")+"
";
}
else if(status == 0) {
_return = "
";
_return += ""+get_lang("User not connected")+"
";
}
}
else if(array_jid != null){
_return = "
";
if(subscription == 'from')
_return += ""+ get_lang("User didn't allow you")+"
";
else if(subscription == 'to') {
_return += ""+ get_lang("You didn't allow")+"
";
}
else
_return += "" + get_lang("User not registered")+"
";
}
return _return;
}
/* Build the Object */
var emInfoContact;
InfoContact = new emInfoContact();