﻿// 根据对象id获取对象
function getObject(objectId){
    if(document.getElementById && document.getElementById(objectId))   // W3C DOM
        return document.getElementById(objectId);
    else if (document.all && document.all(objectId))   // MSIE 4 DOM
        return document.all(objectId);
    else if (document.layers && document.layers[objectId]) // NN 4 DOM.. note: this won't find nested layers
        return document.layers[objectId];
    else
        return false;
}

// 获取内容
function processRequestChange(xmlHttp,divID)
{
    if (xmlHttp.readyState == 4){
        if (window.location.href.indexOf("http")==-1 || xmlHttp.status == 200){
            reweb(divID,xmlHttp.responseText);
            xmlHttp = null;
        }
    }
}

function reweb(divID,newsstring){
//<![CDATA[
    var responsecont = getObject(divID);
    responsecont.innerHTML = newsstring;
//]]>
}

function CreateXMLHttpRequest(){
   // Initialize Mozilla XMLHttpRequest object
   if (window.XMLHttpRequest){
       xmlHttp = new XMLHttpRequest();
   } 
   // Initialize for IE/Windows ActiveX version
   else if (window.ActiveXObject) {
       try{
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
	   } 
       catch (e){
			try{
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){newsstring = "<div class='loading'></div>";}
       }
   }
   return xmlHttp
}

function ajaxload(aurl,adiv){
	try
	{	
		var loadstatustext="<div style='width:100%;'><br>　　读取数据，请稍侯……</div>";
		var xmlHttp = CreateXMLHttpRequest();   
		getObject(adiv).innerHTML = loadstatustext;
		xmlHttp.onreadystatechange = function(){processRequestChange(xmlHttp, adiv)}
		xmlHttp.open("GET", aurl, true);
		xmlHttp.setRequestHeader("If-Modified-Since","0");
		xmlHttp.send(null); 
	}
	catch(e)
	{
		alert(e);
	}
}