
var ImFriend={};$(window).unload(function(){window.opener.location.reload()});$(document).ready(function(){ImFriend.NameCards={};ImFriend.IsRoom=false});$(window).load(function(){ImFriend.czd=$("#dl_Group");ImFriend.ofo=$("#dl_Rooms");ImFriend.ako=$("#divcexrList");ImFriend.pba=$("#groupName");ImFriend.chl=$("#selectedCount");ImFriend.omw=$("#moveFriend");ImFriend.$deleteFriend=$("#deleteFriend");ImFriend.GroupFriendCounts=new Array();var m="/WebServices/WebIM/WebIM.asmx/GetFriendMange";$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:m,data:"{}",dataType:'json',beforeSend:function(a){},complete:function(a,b){},error:function(a){var b=JSON2.stringify(a);if(b.length>600)b=b.substr(0,600);alert("读取好友分组失败。详情："+b);return false},success:function(e){e=hmy(e);if(ymr(e)){art.VLdialog.alert("读取好友分组时失败。",function(){},14,"提示");return false}
if(!ymr(e)){ImFriend.dsh=e.DeptId;ImFriend.poq=e.UserId;ImFriend.PositionList=e.PositionList;ImFriend.DeptList=e.DeptList;ImFriend.LinkGroups=e.LinkGroups;ImFriend.GroupId=e.GroupId;ImFriend.MyRooms=e.MyRooms;ImFriend.yrh(ImFriend.GroupId);if(ImFriend.mmv()>0)ImFriend.zgk(ImFriend.mmv(),e.NameCards);ImFriend.GroupFriendCounts=e.GroupFriendCounts;ImFriend.fhf(ImFriend.mmv());var f=new nzy();for(var i=0;i<e.LinkGroups.length;i++){var v=e.LinkGroups[i].GroupId;var t=e.LinkGroups[i].GroupName;if(i==0){ImFriend.yrh(v);ImFriend.GroupName=t;ImFriend.pba.html(t)}
var g=ImFriend.cvc(v);f.append("<li onmousedown=\"javascript:ImFriend.qlx(this);\" val=\""+v+"\" txt=\""+t+"\" class=\"bg2_hover\">");f.append("<a class=\"\"  href=\"javascript:void(0);\"  >");f.append(""+t+"("+g+")");f.append("</a>");f.append("</li>")}
var h=ImFriend.czd.find("#ul_GroupList");h.html(f.toString());h.children(":first").addClass("current");if(!ymr(e.MyRooms)){var f=new nzy();for(var i=0;i<e.MyRooms.length;i++){var v=e.MyRooms[i].RoomId;var t=e.MyRooms[i].RoomName;var g=e.MyRooms[i].LgrCount;ImFriend.obn(v,g,true);f.append("<li onmousedown=\"javascript:ImFriend.qfr(this);\" val=\""+v+"\" txt=\""+t+"\" class=\"bg2_hover\">");f.append("<a class=\"\"  href=\"javascript:void(0);\"  >");f.append(""+t+"("+g+")");f.append("</a>");f.append("</li>")}
var h=$("#ul_RoomList");h.html(f.toString())}
var j=new nzy();for(var k=0;k<ImFriend.LinkGroups.length;k++){j.append("<div  class=\"js-component-menuitem nui-menu-item\"  val=\""+ImFriend.LinkGroups[k].GroupId+"\"  ><a  href=\"javascript:void(0);\" class=\"nui-menu-item-link\">");j.append("<span   class=\"nui-menu-item-text\">"+ImFriend.LinkGroups[k].GroupName+"</span>");j.append("</a></div>")}
var l=$("#ul_GroupItem");l.html(j.toString());l.children().unbind("click").bind("click",function(){var b=parseInt($(this).attr("val"),10);var c=ImFriend.mmv();if(c==b){art.VLdialog.tips("目标分组和当前分组是同一个分组，请选择移到不同的分组。",3);return false}
var d=new Array();ImFriend.ako.children("[groupid="+c+"][isRoom="+(ImFriend.IsRoom?"1":"0")+"]").children(".selected").each(function(){var a={"UserId":parseInt($(this).attr("val"),10),"UserName":$(this).attr("txt")};d.push(a)});ImFriend.agz(c,b,d)})}}})});ImFriend.qlx=function(a){var b=$(a);var c=new Array();var d=new Array();var e=b.attr("val");var f=b.attr("txt");ImFriend.pba.html(f);c.push(b.attr("val"));d.push(f);ImFriend.GroupId=parseInt(e,10);ImFriend.GroupName=f;ImFriend.RoomId=-1;ImFriend.RoomName=null;ImFriend.IsRoom=false;b.parent().children().removeClass("current");b.addClass("current");ImFriend.fhf(ImFriend.mmv());ImFriend.pmz(ImFriend.mmv());$("#ul_RoomList").children(".current").removeClass("current")};ImFriend.qfr=function(a){var b=$(a);var c=new Array();var d=new Array();var e=b.attr("val");var f=b.attr("txt");ImFriend.pba.html(f);c.push(b.attr("val"));d.push(f);ImFriend.RoomId=parseInt(e,10);ImFriend.RoomName=f;ImFriend.IsRoom=true;ImFriend.GroupId=-1;ImFriend.GroupName=null;b.parent().children().removeClass("current");b.addClass("current");ImFriend.fhf(ImFriend.RoomId,true);ImFriend.pmz(ImFriend.RoomId,true);$("#ul_GroupList").children(".current").removeClass("current")};ImFriend.cvc=function(a){if(ymr(ImFriend.GroupFriendCounts))return 0;for(var i=0;i<ImFriend.GroupFriendCounts.length;i++){if(ImFriend.GroupFriendCounts[i].IsRoom==undefined)ImFriend.GroupFriendCounts[i].IsRoom=false;if(ImFriend.GroupFriendCounts[i].V1==a&&ImFriend.GroupFriendCounts[i].IsRoom==ImFriend.IsRoom){if(ymr(ImFriend.GroupFriendCounts[i].V2)){ImFriend.GroupFriendCounts[i].V2=0;return 0}else return ImFriend.GroupFriendCounts[i].V2;break}}
var b={V1:a,V2:0,IsRoom:ImFriend.IsRoom};ImFriend.GroupFriendCounts.push(b);return 0};ImFriend.obn=function(a,b,c){if(ymr(b)||isNaN(b))return false;if(c==undefined)c=ImFriend.IsRoom;if(ymr(ImFriend.GroupFriendCounts))ImFriend.GroupFriendCounts=new Array();var d=null;for(var i=0;i<ImFriend.GroupFriendCounts.length;i++){if(ImFriend.GroupFriendCounts[i].V1==a&&ImFriend.GroupFriendCounts[i].IsRoom==c){d=ImFriend.GroupFriendCounts[i];break}}
if(ymr(d)){d={V1:a,V2:0,IsRoom:c};ImFriend.GroupFriendCounts.push(d)}
if(ymr(d.V2)||isNaN(d.V2))d.V2=0;else d.V2=d.V2+b;var e=ImFriend.czd.find("ul").children("[val="+a+"]");if(ImFriend.IsRoom)e=ImFriend.ofo.find("ul").children("[val="+a+"]");if(e.find("a").length>0){e=e.find("a");var f=e.text().split("(");var g=f[0];e.text(g+"("+d.V2+")")}
return true};ImFriend.fhf=function(c,d){if(ImFriend.nbz(c)!=undefined){ImFriend.tuy(c);return}
var e="/WebServices/WebIM/WebIM.asmx/GetFriendNameCard";var f={"groupId":c};if(d){e="/WebServices/WebIM/WebIM.asmx/gmxNameCard";f={"roomId":c}}
$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:e,data:JSON2.stringify(f),dataType:'json',beforeSend:function(a){},complete:function(a,b){},error:function(a){var b=JSON2.stringify(a);if(b.length>600)b=b.substr(0,600);alert("读取树节点失败。详情："+b);return false},success:function(a){a=hmy(a);if(!ymr(a)&&c==ImFriend.dsh){for(var i=0;i<a.length;i++){if(a[i].UserId==ImFriend.poq){a.splice(i,1);break}}}
if(ymr(a))ImFriend.zgk(c,new Array());else ImFriend.zgk(c,a);ImFriend.tuy(c)}})};ImFriend.agz=function(m,n,o){if(ImFriend.IsRoom){art.VLdialog.tips("讨论组不支持移动成员。",3);return false}
var p={"groupId":n,"friends":o};var q="/WebServices/WebIM/WebIM.asmx/agz";$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:q,data:JSON2.stringify(p),dataType:'json',beforeSend:function(a){},complete:function(a,b){},error:function(a){var b=JSON2.stringify(a);if(b.length>600)b=b.substr(0,600);alert("读取树节点失败。详情："+b);return false},success:function(a){a=hmy(a);if(a!=true){art.VLdialog.alert("修改分组时失败。",function(){},14,"提示");return false}
var b=ImFriend.GroupId;var c=new Array();var d=ImFriend.ako.children("[groupid="+n+"][isRoom="+(ImFriend.IsRoom?"1":"0")+"]");var e=ImFriend.ako.children("[groupid="+b+"][isRoom="+(ImFriend.IsRoom?"1":"0")+"]");var f=ImFriend.nbz(b);var g=ImFriend.nbz(n);for(var k=0;k<o.length;k++){for(var j=0;j<f.length;j++){if(f[j].UserId==o[k].UserId){var h=f.splice(j,1);if(!ymr(g)){g.concat(h)}
if(!ymr(d)&&d.length>0){if(d.children("[val]").length<1)d.html("");d.append(e.children("[val='"+o[k].UserId+"']"))}
if(e.children("[val='"+o[k].UserId+"']").length>0){e.children("[val='"+o[k].UserId+"']").remove()}
break}}}
if(!ymr(d)&&d.length>0)d.children().removeClass("selected");if(!ymr(e)&&e.length>0)e.children().removeClass("selected");if(ymr(f))ImFriend.zgk(n,f);if(ymr(g))ImFriend.zgk(n,g);art.VLdialog.tips("移动成功！",2);var i=$.browser.msie?"mouseenter":"mouseover";var l=$.browser.msie?"mouseleave":"mouseout";ImFriend.omw.removeClass("W_btn_a_red").addClass("W_btn_b_disable");ImFriend.$deleteFriend.removeClass("W_btn_a_red").addClass("W_btn_b_disable");ImFriend.omw.unbind(i).unbind(l).unbind("click");ImFriend.obn(b,0-o.length);ImFriend.obn(n,o.length)}})};ImFriend.tuy=function(f){ImFriend.ako.children().hide();var g=ImFriend.ako.children("[groupId="+f+"][isRoom="+(ImFriend.IsRoom?"1":"0")+"]");if(ymr(g)||g.length<1){g=$("  <div isuserlist=\"1\" groupId=\""+f+"\" isRoom=\""+(ImFriend.IsRoom?"1":"0")+"\" class =\"clearfix\"></div>");ImFriend.ako.append(g);g.html(ImFriend.bsk(f));g.children("div").unbind("click").bind("click",function(){if(parseInt($(this).attr("isAdded"),10)==1)art.VLdialog.tips("Ta已是您的好友。",1);else{var a=parseInt($(this).attr("val"),10);var b=$.trim($(this).attr("txt"));if(isNaN(a)||ymr(a))return false;if(ImFriend.IsRoom&&ImFriend.znd(ImFriend.RoomId,a)){art.VLdialog.tips("Ta是创建者，不允许删除。",2);return false}
if($(this).hasClass("selected"))$(this).removeClass("selected");else $(this).addClass("selected");var c=g.children("div.selected").length;ImFriend.chl.html(c);ImFriend.omw=$("#moveFriend");ImFriend.$deleteFriend=$("#deleteFriend");if(c>0){ImFriend.omw.removeClass("W_btn_b_disable").addClass("W_btn_a_red");ImFriend.$deleteFriend.removeClass("W_btn_b_disable").addClass("W_btn_a_red");oro(ImFriend.omw,null,1)}else{var d=$.browser.msie?"mouseenter":"mouseover";var e=$.browser.msie?"mouseleave":"mouseout";ImFriend.omw.removeClass("W_btn_a_red").addClass("W_btn_b_disable");ImFriend.$deleteFriend.removeClass("W_btn_a_red").addClass("W_btn_b_disable");ImFriend.omw.unbind(d).unbind(e).unbind("click")}}})}
g.show()};ImFriend.pmz=function(a){var b=ImFriend.ako.children("[groupId="+a+"][isRoom="+(ImFriend.IsRoom?"1":"0")+"]");var c=b.children("div.selected").length;ImFriend.chl.html(c);if(ymr(ImFriend.omw))ImFriend.omw=$("#moveFriend");if(ymr(ImFriend.$deleteFriend))ImFriend.$deleteFriend=$("#deleteFriend");if(ymr(ImFriend.$groupOperateTool))ImFriend.$groupOperateTool=$("#groupOperateTool");if(ymr(ImFriend.$aAddFriend))ImFriend.$aAddFriend=$("#aAddFriend");if(ymr(ImFriend.$divToolbar))ImFriend.$divToolbar=$("#divToolbar");if(c>0){ImFriend.omw.removeClass("W_btn_b_disable").addClass("W_btn_a_red");ImFriend.$deleteFriend.removeClass("W_btn_b_disable").addClass("W_btn_a_red");oro(ImFriend.omw,null,1)}else{var d=$.browser.msie?"mouseenter":"mouseover";var e=$.browser.msie?"mouseleave":"mouseout";ImFriend.omw.removeClass("W_btn_a_red").addClass("W_btn_b_disable");ImFriend.$deleteFriend.removeClass("W_btn_a_red").addClass("W_btn_b_disable");ImFriend.omw.unbind(d).unbind(e).unbind("click")}
if(ImFriend.IsRoom){ImFriend.omw.hide();ImFriend.$aAddFriend.find("span").text("+ 添加成员");ImFriend.$deleteFriend.find("span").text("删除成员");ImFriend.$groupOperateTool.find("a[btntype=1]").find("span").text("编辑讨论组名称");ImFriend.$groupOperateTool.find("a[btntype=2]").find("span").text("删除讨论组");if(ImFriend.znd(ImFriend.RoomId)){ImFriend.$divToolbar.show();ImFriend.$groupOperateTool.show()}else{ImFriend.$divToolbar.hide();ImFriend.$groupOperateTool.hide();art.VLdialog.tips("您不是创建者，仅允许查看成员。",2)}}else{ImFriend.omw.show();ImFriend.$aAddFriend.find("span").text("+ 添加好友");ImFriend.$deleteFriend.find("span").text("删除好友");ImFriend.$groupOperateTool.show().find("a[btntype=1]").find("span").text("编辑分组名称");ImFriend.$groupOperateTool.find("a[btntype=2]").find("span").text("删除分组");ImFriend.$divToolbar.show()}};ImFriend.bsk=function(a){ImFriend.GroupId=a;var b=ImFriend.nbz(a);var c=new nzy();var d=0;for(var i=0;i<b.length;i++){var e=b[i].UserId;var f=b[i].UserName;var g=b[i].DeptId;var h=b[i].PositionId;var j="";var l="";for(var k=0;k<ImFriend.DeptList.length;k++){if(ImFriend.DeptList[k].DeptId==g){j=ImFriend.DeptList[k].DeptName;break}}
for(var k=0;k<ImFriend.PositionList.length;k++){if(ImFriend.PositionList[k].PositionId==h){l=ImFriend.PositionList[k].PositionName;break}}
var m='<div class="userlist" val="'+e+'" txt="'+f+'" style="display:inline;" title="点击选择">'+'<div class="content clearfix"  style="display:inline;">'+'<div class="user_list">'+'<dl class="name clearfix">'+'<dt><a  href="javascript:void(0);"><img class="picborder_r" src="'+jbc(e,1)+'" /></a></dt>'+'<dd>'+'<ul class="userdata ">'+'<li class=\"clearfix\" >'+'<a  class=\"uname\" nm=\"1\"  href="javascript:void(0);">'+f+'</a>'+'</li>'+'<li style="margin-top:15px;" dn=1>'+j+'</li><li pn=1>'+l+'</li>'+'</ul>'+'</dd>'+'</dl>'+'</div>'+'   </div><span class="ico-gs-ok"></span>'+'</div>';c.append(m);d++}
if(d<1){if(ImFriend.IsRoom)c.append("<p style=\"line-height: 190px; text-align: left;margin-left:230px; color: #999;\" class=\"j-no-result\">此讨论组下没有成员，请<a href=\"javascript:void(0);\"  onclick=\"javascript:ImFriend.niv(this);\"  style=\"margin-left:3px;\" btntype=\"1\" class=\"\"><span>添加成员</span></a></p>");else c.append("<p style=\"line-height: 190px; text-align: left;margin-left:230px; color: #999;\" class=\"j-no-result\">此分组下没有好友，请<a href=\"javascript:void(0);\"  onclick=\"javascript:ImFriend.niv(this);\"  style=\"margin-left:3px;\" btntype=\"1\" class=\"\"><span>添加好友</span></a></p>")}
return c.toString()};ImFriend.niv=function(){var b="590px";var c="520px";var d=ImFriend.GroupId;var f="/MyApp/WebIM/AddFriend.html?groupId="+d;var g="添加好友";if(ImFriend.IsRoom){d=ImFriend.RoomId;f="/MyApp/WebIM/Room.html?roomId="+d;g="添加成员"}
var h=art.VLdialog.open(f,{id:'dlg_addfriend',title:g,fixed:true,width:b,height:c,zIndex:'99999',background:'#0c2136',lock:true,top:'47.2%',duration:0,opacity:0.2,button:[{name:'确  认',title:"确  认",width:'250px',height:'20px',callback:function(){var a=null;try{a=this.iframe.contentWindow;if(ymr(a)){alert("这是IE");a=this.iframe}}catch(e){alert("这是IE");a=this.iframe}
if(ymr(a)){alert("这是IE")}
if(ImFriend.IsRoom)a.IMRoom.xjh();else a.sbr();return false},focus:true},{name:'关  闭',width:'250px',height:'20px',callback:function(){var a=this.iframe.contentWindow;window.location.reload();return true},focus:false}]},true)};ImFriend.zog=function(){var g=ImFriend.GroupId;var h=null;var j="组名称";var k=$("#divGroupEdit");if(ImFriend.IsRoom){j="讨论组名称";g=ImFriend.RoomId;if(isNaN(g)||g==""){art.VLdialog.tips("请先在左边点击讨论组。",1);return false}
if(!ymr(ImFriend.MyRooms)){for(var i=0;i<ImFriend.MyRooms.length;i++){if(ImFriend.MyRooms[i].RoomId==g){h=ImFriend.MyRooms[i].RoomName;break}}}
k.find("label").html("讨论组名称")}else{if(isNaN(g)||g==""){art.VLdialog.tips("请先在左边点击好友分组。",1);return false}
if(!ymr(ImFriend.LinkGroups)){for(var i=0;i<ImFriend.LinkGroups.length;i++){if(ImFriend.LinkGroups[i].GroupId==g){h=ImFriend.LinkGroups[i].GroupName;break}}}
k.find("label").html("组名称")}
$("#d2035_ModuleTypeName").val(h);art.VLdialog({content:k.get(0),ok:function(){var c=ImFriend.GroupId;var d=$.trim($("#d2035_ModuleTypeName").val());if(ymr(d)){art.VLdialog.tips("请输入"+j+"。",1);return false}
if(!ymr(ImFriend.LinkGroups)){for(var i=0;i<ImFriend.LinkGroups.length;i++){if(ImFriend.LinkGroups[i].GroupId!=c&&$.trim(ImFriend.LinkGroups[i].GroupName.toLowerCase())==$.trim(d.toLowerCase())){art.VLdialog.tips("此"+j+"已存在。",1);return false}}}
if(Dcx.Utility.hmv(d)>12){art.VLdialog.tips("不能超过6个字符。",1);return false}
var e={"groupId":c,"groupName":d};var f="/WebServices/WebIM/WebIM.asmx/zog";if(ImFriend.IsRoom){e={"roomId":c,"roomName":d};f="/WebServices/WebIM/WebIM.asmx/UpdateRoomName"}
$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:f,async:false,data:JSON2.stringify(e),dataType:'json',beforeSend:function(a){},complete:function(a,b){},error:function(a){var b=JSON2.stringify(a);if(b.length>600)b=b.substr(0,600);alert("修改"+j+"时失败。详情："+b);return false},success:function(a){a=hmy(a);if((ImFriend.IsRoom&&!a.IsOK)||(!ImFriend.IsRoom&&a!=true)){art.VLdialog.alert("修改"+j+"时失败。"+(ImFriend.IsRoom?"详情："+a.ErrorMsg:""),function(){},14,"提示");return false}
var b=null;if(ImFriend.IsRoom)b=ImFriend.ofo.find("ul");else b=ImFriend.czd.find("ul");b.children("[val="+c+"]").find("a").text(d+"("+ImFriend.cvc(c)+")");art.VLdialog.tips("修改成功！",2);if(ImFriend.IsRoom){if(!ymr(ImFriend.MyRooms)){for(var i=0;i<ImFriend.MyRooms.length;i++){if(ImFriend.MyRooms[i].RoomId==c){ImFriend.MyRooms[i].RoomName=d;break}}}}else{if(!ymr(ImFriend.LinkGroups)){for(var i=0;i<ImFriend.LinkGroups.length;i++){if(ImFriend.LinkGroups[i].GroupId==c){ImFriend.LinkGroups[i].GroupName=d;break}}}}}})},close:function(){}})};ImFriend.azd=function(){var f=ImFriend.mmv();var g=ImFriend.IsRoom;if(isNaN(f)||f==""){art.VLdialog.tips("请先在左边点击好友分组。",1);return false}
if(ImFriend.IsRoom){if(!ImFriend.znd(f)){art.VLdialog.tips("您不是讨论组的创建者，没有权限删除。",4);return false}
art.VLdialog.confirm('确定要删除讨论组吗？',function(){var c=ImFriend.mmv();var d={"roomId":c};var e="/WebServices/WebIM/WebIM.asmx/DeleteRoom";$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:e,async:false,data:JSON2.stringify(d),dataType:'json',beforeSend:function(a){},complete:function(a,b){},error:function(a){var b=JSON2.stringify(a);if(b.length>600)b=b.substr(0,600);alert("删除讨论组时失败。详情："+b);return false},success:function(a){a=hmy(a);if(a.IsOK!=true){art.VLdialog.alert("删除讨论组时失败。详情："+a.ErrorMsg,function(){},14,"提示");return false}
ImFriend.ofo.find("ul").children("[val="+c+"]").remove();if(!ymr(ImFriend.MyRooms)){for(var i=0;i<ImFriend.MyRooms.length;i++){if(ImFriend.MyRooms[i].RoomId==c){ImFriend.MyRooms.splice(i,1);break}}}
art.VLdialog.tips('删除成功');var b=ImFriend.ako.children("[groupId="+c+"][isRoom="+(ImFriend.IsRoom?"1":"0")+"]");if(!ymr(b)&&b.length>0)b.remove();ImFriend.zgk(c,null)}})},function(){art.VLdialog.tips('你取消了删除')});return true}
if(!ymr(ImFriend.nbz(f))&&ImFriend.nbz(f).length>0){art.VLdialog.tips("当前组还有好友，不允许删除。",2);return false}
var h=ImFriend.ako.children("[groupId="+f+"][isRoom="+(ImFriend.IsRoom?"1":"0")+"]");if(!ymr(h)&&h.length>0&&h.children("[val]").length>0){art.VLdialog.tips("当前组还有好友，不允许删除。",2);return false}
art.VLdialog.confirm('确定要删除分组吗？',function(){var c=ImFriend.GroupId;var d={"groupId":c};var e="/WebServices/WebIM/WebIM.asmx/azd";$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:e,async:false,data:JSON2.stringify(d),dataType:'json',beforeSend:function(a){},complete:function(a,b){},error:function(a){var b=JSON2.stringify(a);if(b.length>600)b=b.substr(0,600);alert("删除组时失败。详情："+b);return false},success:function(a){a=hmy(a);if(a!=true){art.VLdialog.alert("删除组时失败。",function(){},14,"提示");return false}
ImFriend.czd.find("ul").children("[val="+c+"]").remove();if(!ymr(ImFriend.LinkGroups)){for(var i=0;i<ImFriend.LinkGroups.length;i++){if(ImFriend.LinkGroups[i].GroupId==c){ImFriend.LinkGroups.splice(i,1);break}}}
art.VLdialog.tips('删除成功');var b=ImFriend.ako.children("[groupId="+c+"][isRoom="+(ImFriend.IsRoom?"1":"0")+"]");if(!ymr(b)&&b.length>0)b.remove();ImFriend.zgk(c,null)}})},function(){art.VLdialog.tips('你取消了删除')})};ImFriend.meo=function(g,h){$("#d2035_ModuleTypeName").val("");art.VLdialog({content:$("#divGroupEdit").get(0),ok:function(){var d=$.trim($("#d2035_ModuleTypeName").val());if(ymr(d)){art.VLdialog.tips("请输入组名称。",1);return false}
if(!ymr(ImFriend.LinkGroups)){for(var i=0;i<ImFriend.LinkGroups.length;i++){if($.trim(ImFriend.LinkGroups[i].GroupName.toLowerCase())==$.trim(d.toLowerCase())){art.VLdialog.tips("此组名称已存在。",1);return false}}}
if(Dcx.Utility.hmv(d)>12){art.VLdialog.tips("不能超过6个字符。",1);return false}
var e={"groupName":d};var f="/WebServices/WebIM/WebIM.asmx/meo";$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:f,async:false,data:JSON2.stringify(e),dataType:'json',beforeSend:function(a){},complete:function(a,b){},error:function(a){var b=JSON2.stringify(a);if(b.length>600)b=b.substr(0,600);alert("创建组时失败。详情："+b);return false},success:function(a){a=hmy(a);if(ymr(a)){art.VLdialog.alert("创建组时失败。",function(){},14,"提示");return false}
if(ymr(ImFriend.LinkGroups))ImFriend.LinkGroups=new Array();ImFriend.LinkGroups.push(a);var b=new nzy();var v=a.GroupId;var t=d;b.append("<li onmousedown=\"javascript:ImFriend.qlx(this);\" val=\""+v+"\" txt=\""+t+"\" class=\"bg2_hover\">");b.append("<a class=\"\"  href=\"javascript:void(0);\"  >");b.append(""+t+"(0)");b.append("</a>");b.append("</li>");var c=ImFriend.czd.find("ul");c.append(b.toString());art.VLdialog.tips("创建成功。",2)}})},close:function(){}})};ImFriend.ykz=function(h){if($(h).hasClass("W_btn_b_disable")){return false}
var i=new Array();var l=ImFriend.mmv();var m=ImFriend.IsRoom?"成员":"好友";var n=ImFriend.ako.children("[groupId="+l+"][isRoom="+(ImFriend.IsRoom?"1":"0")+"]");if(ymr(n)||n.length<1){art.VLdialog.tips('请点击'+(ImFriend.IsRoom?"讨论组":"好友分组")+'。');return false}
var o=n.children("div.selected");o.each(function(){var a={"UserId":parseInt($(this).attr("val"),10),"UserName":$(this).attr("txt")};if(!ymr(a.UserName)&&!isNaN(a.UserId))i.push(a)});if(i.length<1){art.VLdialog.tips('请选择要删除的'+m+'。');return false}
var l=ImFriend.mmv();var p=ImFriend.IsRoom;if(isNaN(l)||l==""){art.VLdialog.tips("请先在左边点击"+(ImFriend.IsRoom?"讨论组":"好友分组")+"。",1);return false}
art.VLdialog.confirm('确定要删除'+m+'吗？',function(){var f={"friends":i};var g="/WebServices/WebIM/WebIM.asmx/ykz";if(ImFriend.IsRoom){f={"roomId":l,"roomLgr":i};g="/WebServices/WebIM/WebIM.asmx/DeleteRoomLgr"}
$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:g,async:false,data:JSON2.stringify(f),dataType:'json',beforeSend:function(a){},complete:function(a,b){},error:function(a){var b=JSON2.stringify(a);if(b.length>600)b=b.substr(0,600);alert("删除"+m+"时失败。详情："+b);return false},success:function(a){a=hmy(a);if((ImFriend.IsRoom&&!a.IsOK)||(!ImFriend.IsRoom&&a!=true)){art.VLdialog.alert("删除"+m+"时失败。"+(ImFriend.IsRoom?"详情："+a.ErrorMsg:""),function(){},14,"提示");return false}
var b=ImFriend.mmv();var c=ImFriend.ako.children("[groupid="+b+"][isRoom="+(ImFriend.IsRoom?"1":"0")+"]");var d=ImFriend.nbz(b);for(var k=0;k<i.length;k++){for(var j=0;j<d.length;j++){if(d[j].UserId==i[k].UserId){var e=d.splice(j,1);if(!ymr(c)&&c.length>0)c.children("[val='"+i[k].UserId+"']").remove();break}}}
ImFriend.obn(b,0-i.length);if(!ymr(c)&&c.length>0)c.children().removeClass("selected");if(ymr(d))ImFriend.zgk(b,d);art.VLdialog.tips('删除成功',2)}})},function(){art.VLdialog.tips('你取消了删除')})};ImFriend.nbz=function(a){if(ImFriend.IsRoom)return ImFriend.NameCards["R"+a];else return ImFriend.NameCards["G"+a]};ImFriend.zgk=function(a,b){if(ImFriend.IsRoom)ImFriend.NameCards["R"+a]=b;else ImFriend.NameCards["G"+a]=b};ImFriend.mmv=function(){if(ImFriend.IsRoom)return ImFriend.RoomId;else return ImFriend.GroupId};ImFriend.yrh=function(a){if(ImFriend.IsRoom)ImFriend.RoomId=a;else ImFriend.GroupId=a};ImFriend.nxs=function(a){if(ymr(a)||isNaN(a))a=ImFriend.mmv();if(ImFriend.IsRoom){if(!ymr(ImFriend.MyRooms)){for(var i=0;i<ImFriend.MyRooms.length;i++){if(ImFriend.MyRooms[i].RoomId==a){return ImFriend.MyRooms[i]}}}}else{if(!ymr(ImFriend.LinkGroups)){for(var i=0;i<ImFriend.LinkGroups.length;i++){if(ImFriend.LinkGroups[i].GroupId==a){return ImFriend.LinkGroups[i]}}}}
return null};ImFriend.znd=function(a,b){if(ymr(a))a=ImFriend.RoomId;if(ymr(b))b=ImFriend.poq;if(!ymr(ImFriend.MyRooms)){for(var i=0;i<ImFriend.MyRooms.length;i++){if(ImFriend.MyRooms[i].RoomId==a){if(ImFriend.MyRooms[i].CreatorId==b)return true;return false}}}
return false};