//判断用户是否有来自专家的加好友请求
var xml_Http;
function newAddFrdMsg(){
		 if (window.ActiveXObject) {
      xml_Http = new ActiveXObject("Microsoft.XMLHTTP");
     }else if (window.XMLHttpRequest) {
      xml_Http = new XMLHttpRequest();                
  }
  if (!xml_Http) { // 异常，创建对象实例失败
	window.alert("不能创建XMLHttpRequest对象实例.");
	return false;
  }
		var url = "/newAddFrdMsg.do";
    	xml_Http.open("POST", url, true);
    	xml_Http.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
    	xml_Http.onreadystatechange = addFrdMsgCallback;
    	xml_Http.send(null);	
	}
	function addFrdMsgCallback(){
		if (xml_Http.readyState == 4){
		  if (xml_Http.status == 200){
		    var flag=xml_Http.responseXML.getElementsByTagName("flag")[0].firstChild.data; 
		    if(flag!=0){
		  	var msgTitle=xml_Http.responseXML.getElementsByTagName("src")[0].firstChild.data; 
		  	msgTitle ='<img src="http://www.huimg.cn/wikispace/images/news.gif" width="14" height="14" border="0"/>&nbsp&nbsp'+msgTitle; 
		  	var msgId=xml_Http.responseXML.getElementsByTagName("msgId")[0].firstChild.data; 
		  }
		  	if(flag==1){
		  		//打开浮窗提示用户有消息
		  		getIncomMsg(msgTitle,msgId);
		  		}
		  }
		}
		}
		var _xml_Http;
function loadNewestUser(){
if (window.ActiveXObject) {
      _xml_Http = new ActiveXObject("Microsoft.XMLHTTP");
     }else if (window.XMLHttpRequest) {
      _xml_Http = new XMLHttpRequest();                
  }
  if (!_xml_Http) { // 异常，创建对象实例失败
	window.alert("不能创建XMLHttpRequest对象实例.");
	return false;
  }
		var url = "/newestUser.do?Action=show";
    	_xml_Http.open("POST", url, true);
    	_xml_Http.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
    	_xml_Http.onreadystatechange = newestUserCallback;
    	_xml_Http.send(null);	
		}
function 	newestUserCallback(){
		var returnMsg="<a href='/auditingIndex.do'><font color='red'>站务工作室</font></a>&nbsp&nbsp";
		//var returnMsg="";
		if (_xml_Http.readyState == 4){
		  if (_xml_Http.status == 200){
		  	var expert=_xml_Http.responseXML.getElementsByTagName("expert")[0].firstChild.data; 
		  	returnMsg = "";
		  	returnMsg +=expert+"&nbsp&nbsp";
		  	var size=_xml_Http.responseXML.getElementsByTagName("size")[0].firstChild.data; 
		  	if(size>0){
		  	   var user=_xml_Http.responseXML.getElementsByTagName("newuser")[0].firstChild.data; 
		  	   returnMsg +=user;
		      }else if(size==0){
		      	var msg="没有新注册用户";
		      	}
		      	
		  }
		}
		var tdObj=document.getElementById("expertStr");
		tdObj.innerHTML=returnMsg;
}
	//检验用户是否被其他站务加为好友
	var _xmlHttp;
	function checkState(userIdEn){
		 if (window.ActiveXObject) {
      _xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  else if (window.XMLHttpRequest) {
      _xmlHttp = new XMLHttpRequest();                
  }
  if (!_xmlHttp) { // 异常，创建对象实例失败
	window.alert("不能创建XMLHttpRequest对象实例.");
	return false;
  }
		var url = "/newestUser.do?Action=add&useriden="+userIdEn;
    	_xmlHttp.open("POST", url, true);
    	_xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
    	_xmlHttp.onreadystatechange = newestUserCheckCallback;
    	_xmlHttp.send(null);		
		}

function 	newestUserCheckCallback(){
		if (_xmlHttp.readyState == 4){
		  if (_xmlHttp.status == 200){
		  	var flag=_xmlHttp.responseXML.getElementsByTagName("flag")[0].firstChild.data; 
		  	var userIdEn=_xmlHttp.responseXML.getElementsByTagName("IdEn")[0].firstChild.data; 
		  	if(flag==0){//已被其他站务加为好友
		  		alert("该用户已经被其他站务加为好友!");
		  		loadNewestUser();
		  		setInterval("loadNewestUser()",30000);
		  		//setInterval("newAddFrdMsg()",30000);
		  		return ;
		  		}else{
		  			window.location.target="_blank";
		  			window.location.href="/userinfo.do?userid="+userIdEn+"&clickType=1";//1表示要打开加好友的页面
		  		//	window.open("/userinfo.do?userid="+userIdEn+"&clickType=1");
		  			}
		}
		}
	}
