var getplayer=function(fname){return'<embed style="position:absolute;top:-100000px" width="0" height="0" type="application/x-shockwave-flash" swliveconnect="true" allowscriptaccess="sameDomain" menu="false" flashvars="sFile='+in_path+"static/pack/chat/player/"+fname+".mp3?"+Math.random()+'" src="'+in_path+'static/pack/chat/player/sound.swf" />';};var createAjax=function(){var xhr=null;try{xhr=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{xhr=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){xhr=new XMLHttpRequest();}}
return xhr;};var ajax=function(conf){var type=conf.type;var url=conf.url;var data=conf.data;var dataType=conf.dataType;var success=conf.success;if(type==null){type="get";}
if(dataType==null){dataType="text";}
var xhr=createAjax();xhr.open(type,url,true);if(type=="GET"||type=="get"){xhr.send(null);}else{if(type=="POST"||type=="post"){xhr.setRequestHeader("content-type","application/x-www-form-urlencoded");xhr.send(data);}}
xhr.onreadystatechange=function(){if(xhr.readyState==4&&xhr.status==200){if(dataType=="text"||dataType=="TEXT"){if(success!=null){success(xhr.responseText);}}else{if(dataType=="xml"||dataType=="XML"){if(success!=null){success(xhr.responseXML);}}else{if(dataType=="json"||dataType=="JSON"){if(success!=null){success(eval("("+xhr.responseText+")"));}}}}}else{if(xhr.readyState==4&&xhr.status!=200){}}};};(function(){lib={press:function(_type,_id,_class){var key=navigator.appName=="Netscape"?event.which:window.event.keyCode;if(_type=="send"&&key==13){listenMsg.send();}else if(_type=="value"&&key==27){var val=_id=="_img"?"[img]"+$("#_img").val()+"[/img]":"[flash]"+$("#_flash").val()+"[/flash]";$("#textarea").val($("#textarea").val()+val);$("#textarea").focus();$("."+_class).hide();}},doodle:function(){$.layer({type:1,title:"涂鸦板",area:["auto","auto"],page:{html:'<embed src="'+in_path+'source/pack/doodle/image/doodle.swf" width="438" height="304" wmode="transparent" type="application/x-shockwave-flash"></embed>'}});},invisible:function(_id){ajax({type:"get",url:in_path+"source/user/feed/ajax.php?ac=invisible&id="+_id,dataType:"text",success:function(data){if(data=="return_1"){layer.msg("请先登录用户中心！",3,11);}else if(data=="return_2"){$("#list_reload").click();if(_id>0){$("#set_invisible").attr("title","我要在线");$("#set_invisible").attr("onclick","lib.invisible(0)");layer.tips("已切换到隐身状态！","#set_invisible",{style:["background-color:#99C521;color:#fff","#99C521"],maxWidth:185,time:1});}else{$("#set_invisible").attr("title","我要隐身");$("#set_invisible").attr("onclick","lib.invisible(1)");layer.tips("已切换到在线状态！","#set_invisible",{style:["background-color:#FF8901;color:#fff","#FF8901"],maxWidth:185,time:1});}}else{layer.msg("内部出现错误，请稍后再试！",3,8);}}});},shake:function(_size,_time,_id,_speed){$(".close_btn").html("<span>"+getplayer("shake")+"</span>");var len=_size,c=_time,step=0,shake=$("#"+_id),off=shake.offset();this.step=0;timer=setInterval(function(){var set=lib.pos();shake.offset({top:off.top+set.y*len,left:off.left+set.x*len});if(step++>=c){shake.offset({top:off.top,left:off.left});clearInterval(timer);}},_speed);},pos:function(){this.step=this.step?this.step:0;this.step=this.step==4?0:this.step;var set={0:{x:0,y:-1},1:{x:-1,y:0},2:{x:0,y:1},3:{x:1,y:0}};return set[this.step++];}},pop={lockother:function(_id){ajax({type:"get",url:in_path+"source/plugin/webim/source/pop.php?ac=lock&uid="+_id,dataType:"text",success:function(data){if(data=="return_1"){layer.msg("请先登录管理中心！",3,11);}else if(data=="return_2"){layer.msg("请先登录用户中心！",3,11);}else if(data=="return_3"){layer.msg("用户不存在或已被管理员锁定！",3,11);}else if(data=="return_4"){layer.msg("您不能锁定自己！",3,8);}else if(data=="return_5"){layer.msg("恭喜，锁定用户成功！",3,1);setTimeout("$('#list_reload').click();",3e3);}else{layer.msg("内部出现错误，请稍后再试！",3,8);}}});},addfriend:function(name){if($("#groupid").val()<1){$("#groupid").focus();return;}
ajax({type:"get",url:in_path+"source/user/friend/ajax.php?ac=insert&name="+escape(name)+"&msg="+escape($("#message").val())+"&gid="+$("#groupid").val(),dataType:"text",success:function(data){if(data=="return_1"){layer.msg("请先登录用户中心！",3,11);}else if(data=="return_2"){layer.msg("用户不存在或已被管理员锁定！",3,11);}else if(data=="return_3"){layer.msg("分组不存在或已被删除！",3,11);}else if(data=="return_4"){layer.msg("您不能添加自己为好友！",3,8);}else if(data=="return_5"){layer.msg("您不能选择别人的分组！",3,7);}else if(data=="return_6"){layer.closeAll();layer.msg("恭喜，加为好友成功！",3,1);setTimeout("$('#list_reload').click();",3e3);}else{layer.msg("内部出现错误，请稍后再试！",3,8);}}});},changefriend:function(_id){if($("#groupid").val()<1){$("#groupid").focus();return;}
ajax({type:"get",url:in_path+"source/user/friend/ajax.php?ac=change&fid="+_id+"&gid="+$("#groupid").val(),dataType:"text",success:function(data){if(data=="return_1"){layer.msg("请先登录用户中心！",3,11);}else if(data=="return_2"){layer.msg("好友不存在或已被删除！",3,11);}else if(data=="return_3"){layer.msg("分组不存在或已被删除！",3,11);}else if(data=="return_4"){layer.msg("您不能移动别人的好友！",3,7);}else if(data=="return_5"){layer.msg("您不能选择别人的分组！",3,7);}else if(data=="return_6"){layer.closeAll();layer.msg("恭喜，好友分组成功！",3,1);setTimeout("$('#list_reload').click();",3e3);}else{layer.msg("内部出现错误，请稍后再试！",3,8);}}});},delfriend:function(_id){ajax({type:"get",url:in_path+"source/user/friend/ajax.php?ac=f_del&id="+_id,dataType:"text",success:function(data){if(data=="return_1"){layer.msg("请先登录用户中心！",3,11);}else if(data=="return_2"){layer.msg("好友不存在或已被删除！",3,11);}else if(data=="return_3"){layer.msg("您不能删除别人的好友！",3,7);}else if(data=="return_4"){layer.msg("恭喜，删除好友成功！",3,1);setTimeout("$('#list_reload').click();",3e3);}else{layer.msg("内部出现错误，请稍后再试！",3,8);}}});},addgroup:function(title){ajax({type:"get",url:in_path+"source/user/friend/ajax.php?ac=add&title="+escape(title),dataType:"text",success:function(data){if(data=="return_1"){layer.msg("请先登录用户中心！",3,11);}else if(data=="return_2"){layer.msg("您已经新建过该分组，请更换分组名称！",3,8);}else if(data=="return_3"){layer.msg("恭喜，新增分组成功！",3,1);setTimeout("$('#list_reload').click();",3e3);}else{layer.msg("内部出现错误，请稍后再试！",3,8);}}});},edigroup:function(_id,_title){ajax({type:"get",url:in_path+"source/user/friend/ajax.php?ac=edi&id="+_id+"&title="+escape(_title),dataType:"text",success:function(data){if(data=="return_1"){layer.msg("请先登录用户中心！",3,11);}else if(data=="return_2"){layer.msg("分组不存在或已被删除！",3,11);}else if(data=="return_3"){layer.msg("您不能修改别人的分组！",3,7);}else if(data=="return_4"){layer.msg("您已经新建过该分组，请更换分组名称！",3,8);}else if(data=="return_5"){layer.msg("恭喜，修改分组成功！",3,1);setTimeout("$('#list_reload').click();",3e3);}else{layer.msg("内部出现错误，请稍后再试！",3,8);}}});},delgroup:function(_id){ajax({type:"get",url:in_path+"source/user/friend/ajax.php?ac=del&id="+_id,dataType:"text",success:function(data){if(data=="return_1"){layer.msg("请先登录用户中心！",3,11);}else if(data=="return_2"){layer.msg("分组不存在或已被删除！",3,11);}else if(data=="return_3"){layer.msg("您不能删除别人的分组！",3,7);}else if(data=="return_4"){layer.msg("恭喜，删除分组成功！",3,1);setTimeout("$('#list_reload').click();",3e3);}else{layer.msg("内部出现错误，请稍后再试！",3,8);}}});},confirm:function(_type,_id){$.layer({shade:[0],area:["auto","auto"],dialog:{msg:_type!=="friend"?_type=="group"?"将同时清空分组中的好友，确认继续？":"确认要通过锁定来踢出该用户？":"确认要删除该好友吗？",btns:2,type:4,btn:["确认","取消"],yes:function(){_type!=="friend"?_type=="group"?pop.delgroup(_id):pop.lockother(_id):pop.delfriend(_id);},no:function(){layer.msg("已取消操作",1,0);}}});},add:function(title){ajax({type:"get",url:in_path+"source/plugin/webim/source/pop.php?ac=group",dataType:"text",success:function(data){$.layer({type:1,title:"添加“"+title+"”为好友",page:{html:'<form method="get" onsubmit="pop.addfriend(\''+title+'\');return false;" class="c_form"><table cellspacing="0" cellpadding="0" class="formtable"><tr><th style="width:4em;">附言:</th><td><input type="text" id="message" class="t_input"  /></td></tr><tr><th style="width:4em;">分组:</th><td>'+data+'</td></tr><tr><th style="width:4em;"></th><td><input type="submit" value="确定" class="submit" /></td></tr></table></form>'}});}});},move:function(title,fid){ajax({type:"get",url:in_path+"source/plugin/webim/source/pop.php?ac=group",dataType:"text",success:function(data){$.layer({type:1,title:"移动“"+title+"”到分组",page:{html:'<form method="get" onsubmit="pop.changefriend('+fid+');return false;" class="c_form"><table cellspacing="0" cellpadding="0" class="formtable"><tr><th style="width:4em;">分组:</th><td>'+data+'</td></tr><tr><th style="width:4em;"></th><td><input type="submit" value="确定" class="submit" /></td></tr></table></form>'}});}});}};})();