// global flag
var isIE = false;

// global request and XML document objects
var req;

// retrieve XML document (reusable generic function);
// parameter is URL string (relative or complete) to
// an .xml file whose Content-Type is a valid XML
// type, such as text/xml; XML source must be from
// same domain as HTML file
function loadDoc(url,sync) {
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
     //   req.open("GET", url, true);
		req.open("GET", url , sync);
        req.onreadystatechange = processReqChange;
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
    //        req.open("GET", url, true);
			req.open("GET", url , sync);
            req.onreadystatechange = processReqChange;
            req.send();
        }
    }
}

// handle onreadystatechange event of req object
function processReqChange() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
				document.getElementById('data').innerHTML=req.responseText;
         } else {
				var url=document.getElementById('hidden_data').innerHTML;
				loadDoc(url,true);
         }
    }
}

function UrlEncode(str){
	/*********qiushuiwuhen(2002-9-16)********/
	var i,c,p,q,ret="",strSpecial="!\"#$%&'()*+,/:;<=>?@[\]^`{|}~%";
	for(i=0;i<str.length;i++){
		if(str.charCodeAt(i)>=0x4e00){
			var p=strGB.indexOf(str.charAt(i));
			if(p>=0){
				q=p%94;
				p=(p-q)/94;
				ret+=("%"+(0xB0+p).toString(16)+"%"+(0xA1+q).toString(16)).toUpperCase();
			}
		}
		else{
			c=str.charAt(i);
			if(c==" ")
				ret+="+";
			else if(strSpecial.indexOf(c)!=-1)
				ret+="%"+str.charCodeAt(i).toString(16);
			else
				ret+=c;
		}
	}
	return ret;
}
