var xmlHttp;
var addNew;
function GetXmlHttpObject(handler)
{
var objXmlHttp=null
if (navigator.userAgent.indexOf("MSIE")>=0)
{
var strName="Msxml2.XMLHTTP"
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.XMLHTTP"
}
try
{
objXmlHttp=new ActiveXObject(strName)
objXmlHttp.onreadystatechange=handler
return objXmlHttp
}
catch(e)
{
alert("Error. Scripting for ActiveX might be disabled")
return
}
}
else
{
objXmlHttp=new XMLHttpRequest()
objXmlHttp.onload=handler
objXmlHttp.onerror=handler
return objXmlHttp
}
}
/* 显示留言 */
function showre(id,no)
{ document.getElementById("list").innerHTML = "";
var url = "/Ping.asp?id="+id+"&page="+no;
xmlHttp=GetXmlHttpObject(showlist)
xmlHttp.open("GET", url , true)
xmlHttp.send(null)
}
function showlist()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
document.getElementById("list").innerHTML = ""
xmlAuthor = xmlHttp.responseXML.getElementsByTagName("Author")
xmlContent = xmlHttp.responseXML.getElementsByTagName("Content")
xmlNoI = xmlHttp.responseXML.getElementsByTagName("NoI")
xmlIP = xmlHttp.responseXML.getElementsByTagName("IP")
xmlreContent = xmlHttp.responseXML.getElementsByTagName("reContent")
//输出评论
for (i=0;i< xmlContent.length;i++) {
var Content = xmlContent[i].firstChild.data;
var div = document.createElement("DIV");
div.id = i;
if (Content == "没有评论") {
//alert(1)
div.innerHTML = "
暂时还没有评论
"
}
else {
var Author = xmlAuthor[i].firstChild.data;
var PostTime = xmlAuthor[i].getAttribute('PostTime');
var ID = xmlNoI[i].firstChild.data;
var IP = xmlIP[i].firstChild.data;
var reContent = xmlreContent[i].firstChild.data;
div.innerHTML = ""+ID+" 楼:
"+Author+"
发表于 "+PostTime+"
"+Content+"
"+reContent+"
"
}
document.getElementById("list").appendChild(div);
}
//输出分页信息
P_Nums = xmlHttp.responseXML.getElementsByTagName("data")[0].getAttribute('P_Nums');
if (P_Nums>1) {
var page = xmlHttp.responseXML.getElementsByTagName("data")[0].getAttribute('page');
var ID = xmlHttp.responseXML.getElementsByTagName("data")[0].getAttribute('ID');
var D_Nums = xmlHttp.responseXML.getElementsByTagName("data")[0].getAttribute('D_Nums');
var l1 = " "+D_Nums+" "+page+"/"+P_Nums+" "
l1 = (page>1)?l1+"<< ":l1;
var l2 = "";
for (var i =1;i<=P_Nums;i++) {
l2 += (i == page)?""+i+"":""+i+""
}
l2 = (page == P_Nums)?l2:l2+">> "
document.getElementById("MultiPage").innerHTML = l1+l2;
}
}
}
/* 发送留言 */
function AddNew() {
document.getElementById("sendGuest").disabled = true;
var Author = escape(document.getElementById("memAuthor").value);
var Content = escape(document.getElementById("memContent").value);
var ArticleID = escape(document.getElementById("ArticleID").value);
if (Author == "" || Content == "") {
alert("请填写完整!");
document.getElementById("sendGuest").disabled = false;
return false;
}
addNew = GetXmlHttpObject(sendGuest);
var GuestInfo = "Author="+Author+"&ArticleID="+ArticleID+"&Content="+Content;
addNew.open("POST","/AddNew.asp",false);
addNew.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
addNew.send(GuestInfo);
}
function sendGuest() {
if (addNew.readyState==4 || addNew.readyState=="complete") {
alert(unescape(addNew.responseText));
document.getElementById("sendGuest").disabled = false;
//document.getElementById("memAuthor").value = "";
document.getElementById("memContent").value = "";
showre(document.getElementById("ArticleID").value,1);
}
}
function reSet() {
document.getElementById("memAuthor").value = "";
document.getElementById("memContent").value = "";
}