var path = "";
 
 function init(id)
 {
 		path = document.getElementById("path").value;
	//document.getElementById("trend_iframe").src=''+path+'/spaceTrend.html?space=other&userId='+id;
}
//加载信息数量
function showMessage(id)
{
	var str = "<img src='"+path+"/common/images/ajax/waitting_1.gif' style='margin-top:3px;'/> 数据载入中，请稍后... ";
	document.getElementById("userMessage").innerHTML = str;
	XMLHttp.sendReq('post', ''+path+'/ajax/businessSpaceAjax.html?operationType=getMessage&path='+path+'&bzuid='+id, '', showMessageAjax);
}
 function showMessageAjax(http_request)
{
  /*是否成功请求*/
  if(http_request.responseText!="")
  {
	 var results=http_request.responseXML;
	 var roots=results.documentElement;
	 var message=roots.getAttribute("message");
	 document.getElementById("userMessage").innerHTML=message;
  }	 
}


 function showHideBox(rex,id)
{
	var button=document.getElementById(rex+"_button");
	var box=document.getElementById(rex+"_box");
	if(rex=="company")
	{
		if(box.style.display!="none")
		{
			button.src=""+path+"/common/images/zhankai.gif";
			box.style.display="none";
		}
		else if(box.style.display=="none")
		{
			button.src=""+path+"/common/images/bihe.gif";
			box.style.display="block";		
			
			if(jsTrim(box.innerHTML)=='')
			{
				XMLHttp.sendReq('post', ''+path+'/ajax/businessSpaceAjax.html?operationType=getCompanyData&userId='+id, '', showCompanyInfo);
				box.innerHTML='&nbsp;&nbsp;<img src="<%=path%>/common/images/ajax/waitting_1.gif"/>&nbsp;读取数据中... ...';
			}
		}
	}
	else if(box.style.display!="none")
	{
		button.src=""+path+"/common/images/zhankai.gif";
		box.style.display="none";
	}
	else if(box.style.display=="none")
	{
		button.src=""+path+"/common/images/bihe.gif";
		box.style.display="block";
	}
}
 
/*-------------------AJAX回调-------------------*/
function showCompanyInfo(http_request)
{
  /*是否成功请求*/
  if(http_request.responseText!="")
  {
	 var results=http_request.responseXML;
	 var roots=results.documentElement;
	 var ajaxMessage=roots.getAttribute("ajaxMessage");
	 if(ajaxMessage=="success")
	 {
	 	var table=roots.getAttribute("companyTable");
	 	var params=table.split("_");
	 	var html='';
	 	var scal = "";
	 	var companyTime = "";
	 	html+='';
		html+='<div ><div class="businessInfo"><ul><li class="InfoTitle">公司名称</li><li class="accoutrightmiddle12" id="titleResult">'+params[0]+'&nbsp;</li><li class="accoutrightmiddle13"></li></ul></div>';
		html+='<div class="businessInfo"><ul><li class="InfoTitle">公司网站</li><li id="websiteResult">'+params[1]+'</li></ul></div>';
		if(params[2] == "1"){
			scal = "1-49人";
		}else if(params[2] == "2"){
			scal = "50-99人";
		}else if(params[2] == "3"){
			scal = "100-499人";
		}else if(params[2] == "4"){
			scal = "500-999人";
		}else if(params[2] == "5"){
			scal = "1000人以上";
		}
		if(params[3] != "0" ){
			companyTime = params[3].substring(0,10);
		}
		html+='<div class="businessInfo"><ul><li class="InfoTitle">公司规模</li><li id="scalResult">'+scal+'</li></ul></div>';
		html+='<div class="businessInfo"><ul><li class="InfoTitle">注册时间</li><li id="timeResult">'+companyTime+'</li></ul></div>';
		html+='<div class="businessInfo"><ul><li class="InfoTitle">公司地址</li><li id="companyaddressResult">'+params[4]+'</li></ul></div>';
		html+='<div class="businessInfo"><ul><li class="InfoTitle">注册号</li><li id="numberResult">'+params[5]+'</li></ul></div>';
		html+='<div class="businessInfo"><ul><li class="InfoTitle">注册资本</li><li id="capitalResult">'+params[6]+' 万元</li></ul></div>';
		html+='<div class="businessInfo"><ul><li class="InfoTitle">所属行业</li><li id="companyindustryResult">'+params[7]+'</li></ul></div>';
		html+='<div class="businessInfo"><ul><li class="InfoTitle">法人代表</li><li id="personResult">'+params[8]+'</li></ul></div></div>';
		html+='<div class="businessInfo"><ul><li class="InfoTitle">公司介绍</li><li class="accoutrightmiddle12" id="infoResult">'+params[10]+'&nbsp;</li><li class="accoutrightmiddle13"></li></ul></div>';
		document.getElementById("company_box").innerHTML=html;
		
	 }
  }
}
	  
function copyUrlLink()
{
	getScreenByStatus("jsAddScreenCopy","copy","","","","","");
	var link = document.getElementById("text").value;
	copyToClipboard(link);
}
  
  function sentMessage(memberId,sentId)
{
	if (sentId =='' || sentId == 'null')
	{
		getScreenByStatus("jsAddScreenNologin","noLogin","","","","","");
		showScreen("ifrNoLogins","ScreenNoLogins","waitBoxNoLogins",'','','');
		return null;
	}
	window.location.href=''+path+'/s/writeNews.html?userId='+memberId;
}
 
function friendIsLogin(memberId,sentId)
{
	if (sentId =='' || sentId == 'null')
	{
		getScreenByStatus("jsAddScreenNologin","noLogin","","","","","");
		showScreen("ifrNoLogins","ScreenNoLogins","waitBoxNoLogins",'','','');
		return null;
	}
	window.location.href=''+path+'/s/writeNews.html?type=present&userId='+memberId;
}
  
 
//生日祝福
function showSentDiv(userId)
{
	XMLHttp.sendReq('post', ''+path+'/ajax/brithdayRemindAjax.html?operationType=countBirthday&userId='+userId, '', sentBirthdayRemindWishAjax);
}
function sentBirthdayRemindWish()
{
	var userId = document.getElementById("userId").value;
	var content =  document.getElementById("content").value;
	var arrImage = document.getElementsByName("radioImage");
	var image = "";
	var id = "0";
	for(var i=0;i<arrImage.length;i++)
	{
		if(arrImage[i].checked)
		{
			image = arrImage[i].value;
		}
	}
	if(jsTrim(content)=="")
	{
		getScreenByStatus("jsAddScreenInfo","info","","","","","");
		showScreen("","ScreenInForss","promptBoxInForss",null,260,20);
		document.getElementById("p_content").innerHTML="请填写祝福话语！";
		return null;
	}
	else
	{
		XMLHttp.sendReq('post', ''+path+'/ajax/brithdayRemindAjax.html?operationType=addBrithdayWash&id='+id+'&userId='+userId+'&image='+image+'&content='+encodeURI(content), '', sentBirthdayRemindWishAjax);
		document.getElementById("saveOneTabIndexSetMessage").innerHTML="<img src='"+path+"/common/images/loading_animation_liferay.gif' style='margin-top:3px;'/>正在发送祝福，请稍后...";
		document.getElementById("uploadSubmit").disabled=true;
	}
}
	
	function sentBirthdayRemindWishAjax(http_request)
{
	if (http_request.responseText != "")
	 {
		var results = http_request.responseXML;
		var roots = results.documentElement;
		var ajaxMessage=roots.getAttribute("ajaxMessage");
		if(ajaxMessage == "nosession")
		{
			hideScreen('ifrBrithday','ScreenBrithday','waitBoxBrithday');
			showScreen("ifr","Screen","waitBoxNoLogins",'','','');
		}
		else if(ajaxMessage == "sentSuccess")
		{
			hideScreen('ifrBrithday','ScreenBrithday','waitBoxBrithday');
			getScreenByStatus("jsAddScreenInfo","info","","","","","");
			showScreen("","ScreenInForss","promptBoxInForss",null,260,20);
			document.getElementById("p_content").innerHTML="发送成功！";
			document.getElementById("saveOneTabIndexSetMessage").innerHTML="";
			document.getElementById("uploadSubmit").disabled=false;
		}
		else if(ajaxMessage == "issentSuccess")
		{
			getScreenByStatus("jsAddScreenInfo","info","","","","","");
			showScreen("","ScreenInForss","promptBoxInForss",null,260,20);
			document.getElementById("p_content").innerHTML="您已经向该好友发送过祝福";
		}
		else if(ajaxMessage == "nosentSuccess")
		{
			getScreenByStatus("jsAddScreenBrithday","sentBrithday","","","","","");
			showScreen("ifrBrithday","ScreenBrithday","waitBoxBrithday",'','','');
			document.getElementById("userId").value=roots.getAttribute("userId");
			document.getElementById("content").value = "";
		}
		else if(ajaxMessage == "isover")
		{
			getScreenByStatus("jsAddScreenInfo","info","","","","","");
			showScreen("","ScreenInForss","promptBoxInForss",null,260,20);
			document.getElementById("p_content").innerHTML="该好友生日已过去";
		}
	 }
}

//截取时间字段
function formatDatesB(str)
{
   return str.length >10 ? str.substring(5,10) : str;
}

function updateVisitCount(id)
{
	XMLHttp.sendReq('post', ''+path+'/ajax/businessSpaceAjax.html?operationType=getVisitCount&bzuid='+id, '', reloadVisitCount);
}   

function reloadVisitCount(http_request)
{
	/*是否成功请求*/
    if(http_request.responseText!="")
    {
		 var results=http_request.responseXML;
		 var roots=results.documentElement;
		 var ajaxMessage=roots.getAttribute("ajaxMessage");
		 if(ajaxMessage=="success")
		 {
		 	var vcEl=document.getElementById("visitCount");
		 	var visitCount=roots.getAttribute("visitCount");
		 	vcEl.innerHTML=visitCount;
		 }
	}
}

 //关闭设置框
	function closePublic(){
		document.getElementById('diaryScreen').style.display='none';
	}
	//浏览时先判断
	function isAllow(id)
	{
		document.getElementById("groupIdAllow").value=id;
		XMLHttp.sendReq('post', ''+path+'/ajax/artAjax.html?operatorType=isAllow&groupId='+id+'&permission=', '', isAllowCallBack);
	}
    
    	
	function isAllowCallBack(http_request){
	   if(http_request.responseText!="")
	   {
	   		var id=document.getElementById("groupIdAllow").value;
			var results=http_request.responseXML;
			var roots=results.documentElement;
			var change =roots.getAttribute("ajaxMessage");
			if(change == "nosession")
			{
			 getScreenByStatus("jsAddScreenNologin","noLogin","","","","","");
			 showScreen("ifrNoLogins","ScreenNoLogins","waitBoxNoLogins",'','','');
			}
			else if(change == 'ok')
			{
				location.href=""+path+"/lookGroupIndex.html?groupId="+id;
			}
			else if(change == 'no')
			{
				var width=469;
				document.getElementById("photoMessageDiv").innerHTML="您非本商社成员，不能浏览该商社！";
				var Element = document.getElementById('diaryScreen');
				var left=(""+((getPageSize()[0]-width)/2)).split(".")[0]+'px';
    			Element.style.left=left;
    			Element.style.top=document.documentElement.scrollTop+168+"px";
    			Element.style.display='block';
	    		return false;
			}
		}
	} 


function getMyJoinServer(id)
{
	XMLHttp.sendReq('post', ''+path+'/ajax/businessSpaceAjax.html?operationType=getMyJoinServer&bzuid='+id, '', getMyJoinServerResult);
}   
function getMyJoinServerResult(http_request)
{
	/*是否成功请求*/
    if(http_request.responseText!="")
    {
		 var results=http_request.responseXML;
		 var roots=results.documentElement;
		 var ajaxMessage=roots.getAttribute("ajaxMessage");
		 var lookCity="bj";
		 if(document.getElementById("obj").value!=null && document.getElementById("obj3").value!=null && document.getElementById("obj3").value!='')lookCity=document.getElementById("obj3").value;
		 if(ajaxMessage=="success")
		 {
		 	var syServerDiv=document.getElementById("syServer");
		 	var shServerDiv=document.getElementById("shServer");
		 	var myJoinSyServer=roots.getAttribute("myJoinSyServer");
		 	var myJoinSyServerId=roots.getAttribute("myJoinSyServerId");
		 	if(myJoinSyServer=='')myJoinSyServer="<a href='"+path+"/"+lookCity+"/memberList/1' target='_blank'>暂末加入</a>";
		 	else myJoinSyServer="<a href='"+path+"/"+lookCity+"/memberList/1/"+myJoinSyServerId+"' target='_blank'>"+myJoinSyServer+"</a>";
		 	var myJoinShServer=roots.getAttribute("myJoinShServer");
		 	var myJoinShServerId=roots.getAttribute("myJoinShServerId");
		 	if(myJoinShServer=='')myJoinShServer="<a href='"+path+"/"+lookCity+"/memberList/2' target='_blank'>暂末加入</a>";
		 	else myJoinShServer="<a href='"+path+"/"+lookCity+"/memberList/2/"+myJoinShServerId+"' target='_blank'>"+myJoinShServer+"</a>";
		 	syServerDiv.innerHTML=myJoinSyServer;
		 	shServerDiv.innerHTML=myJoinShServer;
		 }
	}
}	
function getUserTrend(pageNo,type)
{
	var str = "<div>&nbsp;&nbsp;<img src='"+path+"/common/images/ajax/waitting_1.gif'/>&nbsp;读取数据中... ...</div>";
	document.getElementById("showTrendDiv").innerHTML=str;
	XMLHttp.sendReq('post', ''+path+'/ajax/businessSpaceAjax.html?operationType=getUserTrend'+type+'&pageNo='+pageNo, '', getUserTrendResult);
} 
function getUserTrendResult(http_request)
{
	/*是否成功请求*/
    if(http_request.responseText!="")
    {
		 var results=http_request.responseXML;
		 var roots=results.documentElement;
		 var ajaxMessage=roots.getAttribute("ajaxMessage");
		 var message=roots.getAttribute("message");
		 if(ajaxMessage=="success")
		 {
		 	document.getElementById("showTrendDiv").innerHTML=message;
		 }
	}
}

 function changeApproveClass(id,cName)
 {	
 	document.getElementById(id).className=cName;
 
 }
 function showBackColor(id)
 {
 	document.getElementById(id).className='my_addfr2';
 }
  function hideBackColor(id)
 {
 	document.getElementById(id).className='my_addfr1';
 }