﻿function CreateXmlHttp()
{
   //非IE浏览器创建XmlHttpRequest对象
    if(window.XmlHttpRequest)
    {
     xmlhttp=new XmlHttpRequest();
    }
    //IE浏览器创建XmlHttpRequest对象
     if(window.ActiveXObject)
    {
    try
    {
     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");     
    }
    catch(e)
    {
    try{
     xmlhttp=new ActiveXObject("msxml2.XMLHTTP");
     }
     catch(ex){}
    }
    }
}

function PlShow(artid)
{
	CreateXmlHttp();
	if(!xmlhttp)
	{alert("创建xmlhttp对象异常！");
	return false;
	}
	var url="../tool/PL.aspx?ID="+artid;
    xmlhttp.open("POST",url,true);
    xmlhttp.onreadystatechange=function()
    {
		if(xmlhttp.readyState==1)//表示正在加载
		{
			
			$("PlShow").innerHTML="正在加载中...";
		}
		if(xmlhttp.readyState==4)
		{
           
			if(xmlhttp.status==200)
			{
				var stext=xmlhttp.responseText;
				if(stext.length>0)
					$("PlShow").innerHTML=stext;
				else
					$("PlShow").innerHTML="暂无评论";
			}      
		} 
   }
	xmlhttp.send();
}

function PlAdd(artid)
{
if($("PL_NAME").value!="" && $("PL_CONTENT").value!="")
{
	CreateXmlHttp();
	if(!xmlhttp)
	{alert("创建xmlhttp对象异常！");
	return false;
	}
	var name=encodeURIComponent($("PL_NAME").value);
	var content=encodeURIComponent($("PL_CONTENT").value);
	var url="../tool/PL.aspx?ID="+artid+"&NAME="+name+"&CONTENT="+content;
    xmlhttp.open("POST",url,true);
    xmlhttp.onreadystatechange=function()
    {
		if(xmlhttp.readyState==4)
		{
           
			if(xmlhttp.status==200)
			{
				var stext=xmlhttp.responseText;
				if(stext!="0")
				{
					PlShow(artid);
					$("PL_NAME").value="";
					$("PL_CONTENT").value="";
				}
				else
					$("PL_CONTENT").value="您的输入有误";
			}      
		} 
   }
	xmlhttp.send();
}
	else
		alert('请填写完整再提交。');
}
function ShowArticle(artid)
{
	CreateXmlHttp();
	if(!xmlhttp)
	{alert("创建xmlhttp对象异常！");
	return false;
	}
	var url="../tool/PL.aspx?ArtId="+artid;
    xmlhttp.open("POST",url,true);
    xmlhttp.onreadystatechange=function()
    {
		if(xmlhttp.readyState==4)
		{
           
			if(xmlhttp.status==200)
			{
				var stext=xmlhttp.responseText;
			}      
		} 
   }
	xmlhttp.send();
}


function $(name1)
{
	return document.getElementById(name1);
}