var xmlHttp;                        //用于保存XMLHttpRequest对象的全局变量
var refreshTime = 1000 * 10;         //自动刷新时间间隔，目前为2秒
var isRefreshing = false;           //是否处于自动刷新过程中
var id=-5;


//用于创建XMLHttpRequest对象
function createXmlHttp() {
    //根据window.XMLHttpRequest对象是否存在使用不同的创建方式
    if (window.XMLHttpRequest) {
       xmlHttp = new XMLHttpRequest();                  //FireFox、Opera等浏览器支持的创建方式
    } else {
       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");//IE浏览器支持的创建方式
    }
}

//获取最新价格var va;
var _start=0;
function getNewPrice() {
    //如果已在刷新过程中，直接返回，取消操作
  if (isRefreshing) {
        return;
   }
    isRefreshing = true;                            //设置刷新状态为true
    createXmlHttp();                                //创建XMLHttpRequest对象
    id=id+5;
    var landpubinfocount=document.getElementById("landpubinfocount");
    if(id>(landpubinfocount-5) && start==1){
    	id=-5;
    }
    xmlHttp.open("post", "index.do?method=getLandpubinfo&timestamp="+new Date().getTime()+"&startid="+id+"&start="+_start, true);  //发送GET请求
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    xmlHttp.onreadystatechange = writePrice;        //设置回调函数
    xmlHttp.send(null);
    va = setInterval("getNewPrice()", refreshTime);
}

//将最新价格写入页面
function writePrice() {
    if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
        isRefreshing = false;                       //获取成功，设置刷新状态为false-
       
        
        //将获得的价格遍历写入页面
        document.getElementById("landpubinfo_content").innerHTML = xmlHttp.responseText;
        _start = 1;
    }
}
//初始化获取最新价格，并设置定时获取函数调用
function landpubinfo_time() {
		getNewPrice();
		
}
//停止函数调用
function closeLand(){
	clearInterval(va);
}

