	/******************表单内容编码******************/

function getRequestBody(oForm){
    var aParams=new Array();
    for (var i=0;i<oForm.elements.length;i++){   
        var sParam=encodeURIComponent(oForm.elements[i].name);
        sParam+="=";
        sParam+=encodeURIComponent(oForm.elements[i].value);
        if(oForm.elements[i].name!="sub"){aParams.push(sParam);}
		
		if(oForm.elements[i].name=="isOpen"){aParams.push(sParam);}
//		if(oForm.elements[i].name=="Contents"){aParams.push(sParam);}
//		if(oForm.elements[i].name=="onLine"){aParams.push(sParam);}
    }
	
    return aParams.join("&");
}
	
	function PostMessage()
	{
		//alert("PostMessage");
		//document.getElementById("status").style.height="21px";
		var oForm=document.getElementById("userpanel");
		var sBody=getRequestBody(oForm);
		//alert(sBody);
		var xmlobj;
		xmlobj=createxmlhttp();
		xmlobj.open("post","handle.asp?action=save",true);
		xmlobj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		xmlobj.onreadystatechange=function(){
				if (xmlobj.readyState==4){
					if(xmlobj.status==200){   
						//alert("success");
						//alert(xmlobj.responseText);
						document.getElementById("message").value="";
						
						reload();
						//设置isSee的值为1,用于读取信息时不再加载历史记录
						//document.getElementById("isSee").value="1";
					}
				}else{
					//alert("发送信息失败！");
				}
		};
		xmlobj.send(sBody);	
	}
	/********************刷新在线用户********************/

	function online(){
				//alert("online");
		var xmlobj;
		xmlobj=createxmlhttp();	
		xmlobj.open("get","handle.asp?action=online",true);
		xmlobj.onreadystatechange=function(){
				if (xmlobj.readyState==4){
					if (xmlobj.status==200){                   
						//alert(xmlobj.responseText);
						
						document.getElementById("onLine").value="";
						
						var lists=xmlobj.responseText.split(";");
						//alert(lists.length);
						for(var i=0;i<lists.length-1;i++)
						{
							if (i>0){
							var online=document.getElementById("onLine");
							var div=document.createElement("div");
							div.innerHTML="<br/>";
							online.appendChild(div);
							}
							//alert(lists[i]);
							addLink(lists[i]);	
							
						}
						
					}
				}
		};
		xmlobj.send(null);		
	
	}	
	

	 
	
	/**
		动态创建链接到textArea在线列表
	**/
	function addLink(params){
		var online=document.getElementById("onLine");
		if (online==null){
			return;
		}
        if(params==""){
			return;
		}

			
		var arr=params.split(",");
		
		var id=arr[0];
		var text=arr[1];
		var param=arr[2];		

		var oLink=document.createElement("a");
		oLink.id=id;
		oLink.href="#";
		oLink.innerHTML=text+"<br/>";
		oLink.attachEvent("onclick",say(id,param,text));

		online.appendChild(oLink);
	}	
	
	
	say=function(id,param,text)
	{	return function(){
			SayTo(id,param,text);
		}
	}	
	/********************刷新记录********************/
	var history;
	history="";

	function reload(){
		//alert("reload");
		var xmlobj;
		xmlobj=createxmlhttp();
		/**
			修改日期：20080630
			修改人：mikel
			修改内容：传递isSee给刷新信息，用于读取由提示信息页面跳转过来查询未读记录的信息
		**/
		var isSee=document.getElementById("isSee").value;
		//alert(isSee);
		//alert("handle.asp?action=fetch&isSee="+isSee);
		xmlobj.open("get","handle.asp?action=fetch&isSee="+isSee,true);
		xmlobj.onreadystatechange=function(){
				if (xmlobj.readyState==4){
					if (xmlobj.status==200){                   
						//alert(history);
						//alert(xmlobj.responseText);
						//alert(document.getElementById("Contents"));

						var contents=document.getElementById("Contents");
						document.getElementById("Contents").value="";
						//showContent(xmlobj.responseText);
						
						var dvs=document.createElement("ds");
						//如果为查看提示信息，赋值给history变量
						if (isSee=="2")
						{							
							document.getElementById("isSee").value="1";
							history=xmlobj.responseText;
							dvs.innerHTML=xmlobj.responseText;
						}else if(isSee=="1")
						{
							//alert(history);
							//正常页面，将history内容添加到尾部显示
								dvs.innerHTML=xmlobj.responseText+history;
						}
						contents.appendChild(dvs);

						//document.getElementById("Contents").value=xmlobj.responseText;
					}
				}
		};
		xmlobj.send(null);
		

		//online();
		//document.getElementById("message").focus();

		setTimeout("reload()",3000);
		setTimeout("online()",8000);
	}	
	
	
	//选择单位
	function SayTo(lid,linkname,text){
		//alert(document.getElementById(lid).innerText);
		//alert("Sayto:"+lid+linkname);
		
		//alert(navigator.appName);
		/**if (navigator.appName == "Microsoft Internet Explorer"){
			document.getElementById("sayto").value=document.getElementById(lid).innerText;
		}else{
			document.getElementById("sayto").value=document.getElementById(lid).text;
		}**/
		document.getElementById("sayto").value=text;

		document.getElementById("saytoname").value=linkname;
		document.getElementById("saytoId").value=lid;
		//alert(lid+linkname);
		//document.getElementById("message").focus();
	}
	
	tosee=function(lid,linkname,text,url)
	{
		return function(){
			SayToSee(lid,linkname,text,url);
		}
	}
	//
	function SayToSee(lid,linkname,text,url)
	{
		//alert(lid);
		SayTo(lid,linkname,text);
		//window.open(url);
		//return false;
		
	}
	
	//设置选中的radio值
	function selectItem(i)
	{
		document.getElementById("select").value=i;		
	}
	
	//window.onload=reload();
	//setTimeout("online()",10000);