﻿// JScript 文件
//右击好友菜单
var MMpublicuin="";
function LeftFriendsWin(touin,tonick,id,todt)
{  

if(MMpublicuin!=touin )
{    
if( $("divuser"+touin)!=null )
{
$("divuser"+touin).className="jl_online_zu1";
if(MMpublicuin!="")
{
$("divuser"+MMpublicuin).className="jl_online_zu2";
}
}     
MMpublicuin=touin;
}
if(event.button==2 || event.button==0 )
{         
if($("Per_rightmenu")!=null)
{
Element.remove("Per_rightmenu");
}  
makeMenu(touin,tonick,id,todt);
document.oncontextmenu = showMenu;
}

}
//右击组菜单
function showfriend(id)
{  

if(event.button==1)
{  
if(document.getElementById("divfriends"+id).style.display=="none")
{
document.getElementById("divfriends"+id).style.display="";

$("imgicon"+id).src=imgurl+"image/online_5.gif";
}
else
{
document.getElementById("divfriends"+id).style.display="none";
$("imgicon"+id).src=imgurl+"image/online_9.gif";
}         
}
else if(event.button==2 || event.buuton==0)
{     
if($("rightmenu")!=null)
{
Element.remove("rightmenu");
}   
Per_makeMenu(id);
document.oncontextmenu=show_preMenu;
}
}
function changeStyle(obj, cmd)
{ 
if(obj) try {
var imgObj = obj.children(0).children(0);

if(cmd == 'on') {
obj.children(0).className = "ltdfocus";
obj.children(1).className = "mtdfocus";
obj.children(2).className = "rtdfocus";
if(imgObj)
{
if(imgObj.tagName.toUpperCase() == "IMG")
{
imgObj.style.left = "-1px";
imgObj.style.top = "-1px";
}
}
}
else if(cmd == 'out') {
obj.children(0).className = "ltdexit";
obj.children(1).className = "mtdexit";
obj.children(2).className = "rtdexit";
if(imgObj)
{
if(imgObj.tagName.toUpperCase() == "IMG")
{
imgObj.style.left = "0px";
imgObj.style.top = "0px";
}
}
}
}
catch (e) {}
}
function makeMenu(touin,tonick,id,todt)
{
var myMenu, item; 
myMenu = new contextMenu(); 
item = new contextItem("发送消息", "", "SendFriendsWin('"+touin+"','"+tonick+"','"+id+"','"+todt+"');", "menu");
myMenu.addItem(item); 
item = new contextItem("发送短信", "", "SendSms('"+touin+"')", "menu");
myMenu.addItem(item); 
item = new contextItem("发送传真", "", "SendFax('"+touin+"')", "menu");
myMenu.addItem(item); 
item = new contextItem("加入黑名单", "", "movefriends('"+touin+"','"+id+"','"+tonick+"','2','"+todt+"')", "menu");
myMenu.addItem(item); 
item = new contextItem("转移联系人", "", "movefriends('"+touin+"','"+id+"','"+tonick+"','0','"+todt+"')", "menu");
myMenu.addItem(item); 
if($("sharing"+touin) == null ||  $("sharing"+touin).innerHTML=="")
{
item = new contextItem("添加共享", "", "Sharingfriends('"+touin+"','"+id+"')", "menu");
myMenu.addItem(item);
}
else
{
item = new contextItem("取消共享", "", "deleteSharingfriends('"+touin+"','"+id+"')", "menu");
myMenu.addItem(item);
}
if( $("guanz"+touin) == null || $("guanz"+touin).innerHTML=="")
{ 
item = new contextItem("添加关注", "", "addguanzfriends('"+touin+"','"+id+"')", "menu");
myMenu.addItem(item); 
}
else
{
item = new contextItem("取消关注", "", "deleteguanzfriends('"+touin+"')", "menu");
myMenu.addItem(item); 
}   
item = new contextItem("", "", "", "separator");
myMenu.addItem(item); 
item = new contextItem("删除联系人", "", "deleteFriend('"+touin+"','"+id+"')", "menu");
myMenu.addItem(item); 
myMenu.show(this.document);
delete item;
delete myMenu;
}
function writeStyle()
{
var strStyle = ""; 
strStyle += "<STYLE type=text/css>";
strStyle += "TABLE {Font-FAMILY: \"Tahoma\",\"Verdana\",\"宋体\"; FONT-SIZE: 9pt}";
strStyle += ".mtdfocus {BACKGROUND-COLOR: #E0EAF3; BORDER-BOTTOM: #000000 1px solid; BORDER-TOP: #000000 1px solid; CURSOR: hand}";
strStyle += ".mtdexit {BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid}";
strStyle += ".ltdfocus {BACKGROUND-COLOR: #E0EAF3; BORDER-BOTTOM: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; CURSOR: hand}";
strStyle += ".ltdexit {BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #d0d0ce 1px solid; BORDER-TOP: #d0d0ce 1px solid; BORDER-LEFT: #d0d0ce 1px solid}";
strStyle += ".rtdfocus {BACKGROUND-COLOR: #E0EAF3; BORDER-BOTTOM: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; CURSOR: hand}";
strStyle += ".rtdexit {BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #ffffff 1px solid; BORDER-TOP: #000000 1px solid; BORDER-RIGHT: #ffffff 1px solid}";
strStyle += "</STYLE>"; 
document.write(strStyle);
}
function contextMenu()
{
this.items   = new Array();

this.addItem = function (item)
{
this.items[this.items.length] = item;
}

this.show = function (oDoc)
{
var strShow = "";
var i;
strShow = "<div id=\"rightmenu\" style=\"BACKGROUND-COLOR: #ffffff; BORDER: #7AA2D9 1px solid; LEFT: 0px; POSITION: absolute; TOP: 0px; VISIBILITY: hidden;   Z-INDEX:"+index+1+"\">";
strShow += "<table border=\"0\" height=\"";
strShow += this.items.length * 20;
strShow += "\" cellpadding=\"0\" cellspacing=\"0\">";
strShow += "<tr height=\"3\"><td bgcolor=\"#d0d0ce\" width=\"2\"></td><td>";
strShow += "<table border=\"0\" width=\"100%\" height=\"100%\" cellpadding=0 cellspacing=0 bgcolor=\"#ffffff\">";
strShow += "<tr><td bgcolor=\"#d0d0ce\" width=\"23\"></td><td></td></tr></table>";
strShow += "</td><td width=\"2\"></td></tr>";
strShow += "<tr><td bgcolor=\"#d0d0ce\"></td><td>";
strShow += "<table border=\"0\" width=\"100%\" height=\"100%\" cellpadding=3 cellspacing=0 bgcolor=\"#ffffff\">";
for(i=0; i<this.items.length; i++)
{    
strShow+=this.items[i].show(oDoc);
}
strShow += "</table></td><td></td></tr>";
strShow += "<tr height=\"3\"><td bgcolor=\"#d0d0ce\"></td><td>";
strShow += "<table border=\"0\" width=\"100%\" height=\"100%\" cellpadding=0 cellspacing=0 bgcolor=\"#ffffff\">";
strShow += "<tr><td bgcolor=\"#d0d0ce\" width=\"23\"></td><td></td></tr></table>";
strShow += "</td><td></td></tr>";
strShow += "</table></div>\n";
document.body.insertAdjacentHTML("beforeEnd",strShow);
//  oDoc.write(strShow);
}
}
function contextItem(text, icon, cmd, type)
{
this.text = text ? text : "";
this.icon = icon ? icon : "";
this.cmd = cmd ? cmd : "";
this.type = type ? type : "menu";

this.show = function (oDoc)
{
var strShow = "";  
if(this.type == "menu")
{
strShow += "<tr ";
strShow += "onmouseover=\"changeStyle(this, 'on');\" ";
strShow += "onmouseout=\"changeStyle(this, 'out');\" ";
strShow += "onclick=\"";
strShow += this.cmd;
strShow += "\">";
strShow += "<td class=\"ltdexit\" width=\"8\">";
if (this.icon == "")
strShow += "";
else {
strShow += "<img border=\"0\" src=\"";
strShow += this.icon;
strShow += "\" width=\"8\" height=\"16\" style=\"POSITION: relative\"></img>";
}
strShow += "<td class=\"mtdexit\">";
strShow += this.text;
strShow += "</td><td class=\"rtdexit\" width=\"5\"> </td></tr>";
}
else if (this.type == "separator")
{
strShow += "<tr><td class=\"ltdexit\"> </td>";
strShow += "<td class=\"mtdexit\" colspan=\"2\"><hr color=\"#000000\" size=\"1\"></td></tr>";
}
return strShow;
}
}
function showMenu()
{
var x, y, w, h, ox, oy; 
x = event.clientX;
y = event.clientY; 
var obj = document.getElementById("rightmenu");
if (obj == null)
{

return true; 
}
else
{

ox = document.body.clientWidth;
oy = document.body.clientHeight;

}
if(x < ox || y < oy)
{

obj.style.posLeft = x + document.body.scrollLeft;
obj.style.posTop = y + document.body.scrollTop;
obj.style.visibility = "visible";

return false;
}
else
{

w = obj.offsetWidth;
h = obj.offsetHeight;
obj.style.posLeft = x + document.body.scrollLeft;
obj.style.posTop = y + document.body.scrollTop;
obj.style.visibility = "visible";

}
if((x + w) > ox)
{

x = x - w;
}
if((y + h) > oy)
{

y = y - h; 
obj.style.posLeft = x + document.body.scrollLeft;
obj.style.posTop = y + document.body.scrollTop;
obj.style.visibility = "visible"; 

}
return false;
}
writeStyle();
document.onclick = hideMenu;
function hideMenu()
{  
if(event.button == 0)
{ 
var obj = document.getElementById("rightmenu");
if (obj != null) 
{
obj.style.visibility = "hidden";
obj.style.posLeft = 0;
obj.style.posTop = 0;
document.oncontextmenu = null;
Element.remove("rightmenu");
}
else
{
obj=$("Per_rightmenu");
if(obj!=null)
{
obj.style.visibility = "hidden";
obj.style.posLeft = 0;
obj.style.posTop = 0;
document.oncontextmenu = null;
Element.remove("Per_rightmenu");
}
else
{
return true;
}
}
}

}
var aaaa=0
//上级菜单
function Per_makeMenu(id)
{
var myMenu=null;
var item=null; 
myMenu = new Per_contextMenu(); 
item = new contextItem("添加联系人", "", "Displaymu()", "menu");
myMenu.addItem(item); 
if($("group"+id).innerHTML!="黑名单" && $("group"+id).innerHTML!="临时联系人")
{    
item = new contextItem("添加组", "", "CteateGroupdiv('"+id+"')", "menu");
myMenu.addItem(item); 
} 
if(aaaa!=0)
{
alert($("hidgroupid"+id).value); 
aaaa=1;
}
if($("hidgroupid"+id).value!="1" && $("hidgroupid"+id).value!="999" && $("hidgroupid"+id).value!="1000") 
{    
item = new contextItem("重命名", "", "UpdateGroupclick('"+id+"')", "menu");
myMenu.addItem(item); 
item = new contextItem("删除组", "", "DeleteGroup('"+id+"');", "menu");
myMenu.addItem(item); 
}  
myMenu.show(this.document); 
delete item;
delete myMenu;
}
//显示上级菜单
function show_preMenu()
{
var x, y, w, h, ox, oy; 
x = event.clientX;
y = event.clientY; 
var obj = document.getElementById("Per_rightmenu");
if (obj == null)
{
alert("1");
return true; 
}
else
{

ox = document.body.clientWidth;
oy = document.body.clientHeight;
}
if(x > ox || y > oy)
{

obj.style.posLeft = x + document.body.scrollLeft;
obj.style.posTop = y + document.body.scrollTop;
obj.style.visibility = "visible";
return false;
}
else
{

w = obj.offsetWidth;
h = obj.offsetHeight;
obj.style.posLeft = x + document.body.scrollLeft;
obj.style.posTop = y + document.body.scrollTop;
obj.style.visibility = "visible";
}
if((x + w) > ox)
{

x = x - w;
}
if((y + h) > oy)
{
y = y - h; 
obj.style.posLeft = x + document.body.scrollLeft;
obj.style.posTop = y + document.body.scrollTop;
obj.style.visibility = "visible"; 
}
return false;
}   
function Per_contextMenu()
{
this.items   = new Array();

this.addItem = function (item)
{
this.items[this.items.length] = item;
}

this.show = function (oDoc)
{
var strShow = "";
var i;
strShow = "<div id=\"Per_rightmenu\" style=\"BACKGROUND-COLOR: #ffffff; border:#1A77B7 1px solid; LEFT: 0px; POSITION: absolute; TOP: 0px; VISIBILITY: hidden; Z-INDEX: "+index+1+"\">";
strShow += "<table border=\"0\" height=\"";
strShow += this.items.length * 20;
strShow += "\" cellpadding=\"0\" cellspacing=\"0\">";
strShow += "<tr height=\"3\"><td bgcolor=\"#d0d0ce\" width=\"2\"></td><td>";
strShow += "<table border=\"0\" width=\"100%\" height=\"100%\" cellpadding=0 cellspacing=0 bgcolor=\"#ffffff\">";
strShow += "<tr><td bgcolor=\"#d0d0ce\" width=\"23\"></td><td></td></tr></table>";
strShow += "</td><td width=\"2\"></td></tr>";
strShow += "<tr><td bgcolor=\"#d0d0ce\"></td><td>";
strShow += "<table border=\"0\" width=\"100%\" height=\"100%\" cellpadding=3 cellspacing=0 bgcolor=\"#ffffff\">";
for(i=0; i<this.items.length; i++)
{    
strShow+=this.items[i].show(oDoc);
}
strShow += "</table></td><td></td></tr>";
strShow += "<tr height=\"3\"><td bgcolor=\"#d0d0ce\"></td><td>";
strShow += "<table border=\"0\" width=\"100%\" height=\"100%\" cellpadding=0 cellspacing=0 bgcolor=\"#ffffff\">";
strShow += "<tr><td bgcolor=\"#d0d0ce\" width=\"23\"></td><td></td></tr></table>";
strShow += "</td><td></td></tr>";
strShow += "</table></div>\n";
if($("Per_rightmenu")!=null)
{
Element.remove("Per_rightmenu");
}
document.body.insertAdjacentHTML("beforeEnd",strShow);
//  oDoc.write(strShow);
}
}