﻿// JScript 文件
var request;
function createRequest() {
  try {
    request = new XMLHttpRequest();
  } catch (trymicrosoft) {
    try {
      request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (othermicrosoft) {
      try {
        request = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (failed) {
        request = false;
      }
    }
  }
  if (!request)
    alert("Error initializing XMLHttpRequest!");
}
//*******
//第一个请求
//*******
function getCustomerInfo(page,perpage,classid) {
  createRequest();
  var url='newslist.html?Page='+page+'&classid='+classid+'&perpage='+perpage;
  request.open("GET",url,true);
  request.onreadystatechange=updatepage;
  request.send(null);
}
function updatepage(){
    if(request.readyState==4){
        if(request.status==200){
           printmsg();//处理服务器端返回的信息.
           
        }
    }
    else{
  document.getElementById("bgdiv").style.width = document.body.offsetWidth + "px";
  document.getElementById("bgdiv").style.height = document.body.offsetHeight + "px"; 
  document.getElementById("listmsg").style.left=(document.documentElement.clientWidth/2-100)+"px";
  document.getElementById("listmsg").style.top=(document.body.scrollTop+document.documentElement.clientHeight/2-15)+"px";
  document.getElementById("listmsg").style.display="block";
  document.getElementById("bgdiv").style.display="block";
    }
}

function printmsg(){
    var xml=request.responseXML;   
    var date=new Date();                             //获得数据
if(xml==null)return;

var root=xml.documentElement;
if(root)                                                //如果存在

{
    document.getElementById("listmsg").style.display="none";
     document.getElementById("bgdiv").style.display="none";
   //遍历每条数据，添加到mydiv
     var list=document.getElementById("mydiv");
     var s="<table border='0' width='98%' cellpadding='2' cellspacing='0' align='center'>";
     for(var i=0;i<root.childNodes.length;i++)//遍历行
     {
        var rootlist=root.childNodes[i];
            var s1="";
            s1+="<tr><td class='wentitle'><a class='b' href='n"+rootlist.childNodes[0].firstChild.nodeValue+".html'>";
            if(rootlist.childNodes[4].firstChild.nodeValue!=0)
            {
            s1+="<font color='"+rootlist.childNodes[4].firstChild.nodeValue+"'>"+rootlist.childNodes[1].firstChild.nodeValue+"</font>";
            }
            else
            {
            s1+=rootlist.childNodes[1].firstChild.nodeValue;
            }
            s1+="</a>&nbsp;|&nbsp;"+rootlist.childNodes[3].firstChild.nodeValue+"</td></tr>";
            s1+="<tr><td class='wenfont'>"+rootlist.childNodes[2].firstChild.nodeValue+"</td></tr>";
            s1+="<tr><td class='wentitle'>Click for more:<a class='red' href='n"+rootlist.childNodes[0].firstChild.nodeValue+".html'>http://www.focus-apartment.com/n"+rootlist.childNodes[0].firstChild.nodeValue+".html</a></td></tr>";
            s1+="<tr><td height='20' class='line'></td></tr>";

        s+=s1
 
     }
        list.innerHTML=s+"</table>"; 
    
}


}
