
//实现鼠标移动效果的类
function mouseMoveStyle(){   
	this.divName="";
	this.mouseOutClass="";
	this.mouseOverClass="";	
	this.start=function(){
		var objs=document.getElementsByName(this.divName);
		for (var i=0; i<objs.length;i++){
			objs[i].outClass=this.mouseOutClass;
			objs[i].overClass=this.mouseOverClass;
			objs[i].onmouseover=function(){
				this.className=this.overClass;
			}			
			objs[i].onmouseout=function(){
				this.className=this.outClass;
			}
		}
	}
}
function addFriend(){ //添加当前博主作为自己的好友.
	if (isMy==1){
		alert("您不能加自己为好友");
		return;	
	}
	if (userID=="-1"){
		alert("您还没有登录,不能加好友");
		return;	
	}
	
	var objResponse=new JHttpResponse();
	objResponse.write("myID",userID);
	if (isBunch==1){
		 objResponse.write("fID",cUserID);
	}else{
		 objResponse.write("fID",homeUserID);
	}	 
    var out=objAjax.getText("post","./homeServer.aspx?type=addFriend",objResponse,null);
	switch (out){
	    case "1":alert("好友添加成功 ");break;
		case "2":
		 	if (isBunch){
			 	alert(cUserName+" 用户已经在您的好友列表中");
			}else{
			 	alert(homeUserName+" 用户已经在您的好友列表中");
			}
			 break; 
		case "0":alert("没有找到指定的用户");break;
		default:alert(erStr(out));break;
	 }
}
function selectFile(obj){  //选择文件.	
	var vrr=openUpfile(1,"../system/");
	if (vrr!=null){
		vrr=vrr.split(c1)
		var textObj=obj.previousSibling;
		vrr=vrr[0];
		vrr=vrr.replace("../../","../");
		textObj.value=vrr;
	}
}

function createBunch(){  //创建群
	if (userID=="-1"){
		alert("匿名用户不能创建群");
		return;
	}
	var v=new validate();
	v.form=$("form1");
	if (!v.start()){
		return;
	}
	var buName=$("bName").value;
	var buPhoto=$("bPhoto").value;
	var buNote=$("bNote").value;	
	var objResponse=new JHttpResponse();
	objResponse.write("buName",buName);
	objResponse.write("buPhoto",buPhoto);
	objResponse.write("buNote",buNote);
	objResponse.write("uid",userID);
	objResponse.write("uName",userName);
    var out=objAjax.getText("post","./homeServer.aspx?type=createBunch",objResponse,null);
	if (isNaN(out)){
		  alert(erStr(out));
		return; 
	}	
	switch (out){
		case "-3":alert("匿名用户不能创建群");break;
		case "-2":alert("不能创建重名的群");break;
	    default:alert("群创建成功");location.href="./index.aspx?useType="+out;break;
	}
}
function addBunch(){  //加入某群
	if (userID=="-1"){
		alert("匿名用户不能加入群")
		return;
	}	
	var objResponse=new JHttpResponse();
	objResponse.write("uID",userID);
	objResponse.write("bID",homeUserID);
    var out=objAjax.getText("post","./homeServer.aspx?type=addBunch",objResponse,null);
    switch (out){
	     case "1":alert("加入群成功, 正在等待群主审核");break;
		 case "0":alert("群不存在,或用户不存在");break;
		 case "-3":alert("匿名用户不能加入群");break;
		 case "2":alert("不能重复加入一个群");break;
		 default:alert(erStr(out));break;
	 }	
}
function toIndex(){
	if (isBunch==1){		
		  location.href="index.aspx?useType="+homeUserID;
	}else{
		  location.href="index.aspx?user="+homeUserName;
	}
}
function goMyIndex(){ //返回我的主页
	 location.href="index.aspx?user="+userName;
}
function  ApproveBunch(id,aType){ //批准一个用户加入群
	 var objResponse=new JHttpResponse();
	 objResponse.write("ID",id);
	 if (aType==1){
  	   var out=objAjax.getText("post","./homeServer.aspx?type=ApproveBunch",objResponse,null);
	 }else{
  	   var out=objAjax.getText("post","./homeServer.aspx?type=ReturnBunch",objResponse,null);
	 }
	 if (isNaN(out)){
		 alert(erStr(out));
		 return;
	 }
	 switch (out){
	       case "-1":alert("您没有权限完成此操作");return;
	       case "-2":alert("您已经成功批准用户加入群");break;
		   case "-3":alert("您已经删除了用户加入群的申请");break;
	 }
	 $("aUserList"+id).removeNode(true);
}
function delMyFriend(id){  //删除好友
	if (!window.confirm("您要删除好友,是否继续")){
		return;
	}
	var objResponse=new JHttpResponse();
	objResponse.write("ID",id);
	var out=objAjax.getText("post","./homeServer.aspx?type=delFriend",objResponse,null);
	  switch (out){
		   case "1":break;
		   case "0":alert("没有找到你有这个好友");return;break;			
		   default:alert(erStr(out));return;break;
	}
    $("myFriend"+id).removeNode(true);
}
function delMyBunch(id){
	if (!window.confirm("您要解散这个群,是否继续")){
		return;
	}	
	var objResponse=new JHttpResponse();
	objResponse.write("ID",id);
	var out=objAjax.getText("post","./homeServer.aspx?type=delBunch",objResponse,null);
	switch (out){
	   case "1":	break;
	   case "0":alert("没有找到指定的群,或您不是这个群的群主,未能删除群");return;break;
	   default:alert(erStr(out));return;break;
	}
	$("delBunch"+id).removeNode(true);
}
function logoutBunch(id){
	if (!window.confirm("您要退出这个群,是否继续")){
		return;
	}	
	var objResponse=new JHttpResponse();
	objResponse.write("ID",id);
	var out=objAjax.getText("post","./homeServer.aspx?type=logoutBunch",objResponse,null);
	switch (out){
	    case "1":		   	break;
	    case "0":alert("您不在此群中,或是您是此群的群主,退出群操作失败");return;break;
		default:alert(erStr(out));return;break;
	}
	$("logoutDiv"+id).removeNode(true);
}
function  homeMsg(){
       location.href="listInMsg.aspx";
}
function selectAll(){
	var objs=	document.getElementsByTagName("input");
	for (var i=0;i<objs.length;i++){
		if (objs[i].type=="checkbox"){
			objs[i].checked=true;
		}
	}
}
function selectReverse(){
	var objs=	document.getElementsByTagName("input");
	for (var i=0;i<objs.length;i++){
		if (objs[i].type=="checkbox"){
			if (objs[i].checked==true){
				objs[i].checked=false;
			}else{
				objs[i].checked=true;
			}
		}
	}
}
function setupUser(){
    var user=urlPar("user");
    if(user==null||user==""){
        var useType=urlPar("useType");
        if(useType!=""||useType!=null){
            location.href="./setup.aspx?useType="+useType;
        }else{
           alert("参数错误");
        }
    }else{
        location.href="./setup.aspx?user="+user;
    }
}
function userInfo(){
	if (isBunch=="0"){	  
	  location.href="./userinfo.aspx?user="+homeUserName;
	}
}
//注销登录
function homelogout(){
	var objAjax=new JAjax();
	var out=objAjax.getText("get","../system/user/userlogin.aspx?type=logout",null,null);
	location.href="../";
}
//检测自己的新短信.
function testMail(){
	var objAjax=new JAjax();
     var out=objAjax.getText("get","./homeServer.aspx?type=readNewMail",null,null);
	 if (isNaN(out)){
		out==""; 
	 }
	 if (out!="0"){
		 $("myNewMsg").innerHTML="<a href='listInMsg.aspx'>您有"+out+"条新短消息</a>";
		 $("myNewMsg").style.display="";
	 }else{
		 $("myNewMsg").style.display="none";
	 }
	setTimeout("testMail()",120000);
}
function readOnlineFriend(){
	var uList="";
	var objs=document.getElementsByName("myFriendList");
	for (var i=0;i<objs.length;i++){
		uList+=objs[i].alt+",";
		objs[i].alt=objs[i].alt+"当前不在线";
	}
	if (uList==""){
	   return;
	}	
	var objResponse=new JHttpResponse();
	objResponse.write("uList",uList);
	var out=objAjax.getText("post","./homeServer.aspx?type=readOnlineFriend",objResponse,null);
	out=comminute(out,c1,c2);
	for (var i=0;i<out.length-1;i++){
	        var obj=$("myFriendDiv"+out[i][0]);		  
		    var f=obj.style.styleFloat;
		    obj.style.cssText="float:"+f+";";		  
		    obj.url=out[i][1];
		    var title="";
		    if (out[i][2]!=""){
		       title=out[i][2];
		    }else{
			      title=out[i][1];
		    }
		    if (title.indexOf("type")!=-1){
			      title="";
  		  	     obj.title=title;
		    }else{
		  	     obj.title="当前位置:\n"+title;
		    }
		    img=obj.getElementsByTagName("img");
		    img[0].alt=obj.title;
		    img[0].style.cursor="hand";
		    obj.onclick=function(){
		    if (this.url.indexOf("type")!=-1){
			    return;
		    }
		    window.open(this.url);
		}
	}
}

function delMenuRequestContent(tab,tabid,menuid,userid){  
    if(tab==null||tabid==null||menuid==null||userid==null){
          alert("参数错误");
          return;
    }
    if(confirm("你确认要删除当前的内容吗")){
        var objResponse=new JHttpResponse();
        objResponse.write("tab",tab);
        objResponse.write("tabid",tabid);
        objResponse.write("userid",userid);
        objResponse.write("menuid",menuid);
        var out=objAjax.getText("post","./publicUpdate.aspx?type=delete",objResponse,null);
        switch(out){
          case "ok":alert("删除成功");window.location.href=window.location.href;break;
          default:alert(out);break;
        }
    }
}
function sel(obj){
      if($(obj).checked){
        $("showDivJF").style.display="block";
        $("intType").checked="";
      }
      else{
        $("showDivJF").style.display="none";
        $("intType").checked="checked";
      }
}
function previewCss(className){	
	var useType=urlPar("useType");
	if (isNaN(useType)){
		useType='';
	}
	location.href="?useType="+useType+"&tempClass="+className;
}
function applicationCss(className){	 
	 if (isMy==0){
		 alert("您只能修改自己的主页和群的模板")
		 return;
	}
	 var objResponse=new JHttpResponse();
	 objResponse.write("className",className);
	 if (isBunch=="1"){
	     var out=objAjax.getText("post","./homeServer.aspx?type=applicationCss&useType="+homeUserID,objResponse,null);
	 }else{
	     var out=objAjax.getText("post","./homeServer.aspx?type=applicationCss&user="+userName,objResponse,null);
	 }
	 if (out==""){
		 location.reload();
	 }else{
		 alert(erStr(out));
	 }
}