// JavaScript Document

var http = false;
if(navigator.appName == "Microsoft Internet Explorer") {
  http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
   http = new XMLHttpRequest();
}
var connecting = true;//只允许单线连接
function GET_Page(thisid, thisurl, thisdata) {
	if(connecting){
		connecting = false;
		document.getElementById(thisid).innerHTML = "<img src='Images/loading.gif'>";
//		alert(Url_with_number(thisurl) + thisdata);
		http.open("GET", Url_with_number(thisurl) + thisdata, true);
		http.onreadystatechange=function() {
			if(http.readyState == 4 && http.status == 200){
				document.getElementById(thisid).innerHTML = http.responseText;
				connecting = true;
			}
		}
		http.send(null);
	}
	else{
		alert(document.getElementById('connection_busy').innerHTML);
	}
}
//POST获取结果
function POST_Page(thisid, thisurl, thisdata){
	if(connecting){
		connecting = false;
		document.getElementById(thisid).innerHTML = "<img src='Images/loading.gif' width=12 height=12>";
		http.open("POST", Url_with_number(thisurl), true);
		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http.setRequestHeader("Content-length", thisdata.length);
		http.setRequestHeader("Connection", "close");
		http.onreadystatechange=function(){
			if(http.readyState == 4 && http.status == 200) {
				document.getElementById(thisid).innerHTML = http.responseText;
				connecting = true;
			}
		}
		http.send(thisdata);
	}
	else{
		alert(document.getElementById('connection_busy').innerHTML);
	}
}
function Url_with_number(url){
	return url + '&link_number=' + Math.round(Math.random()*1000000000000) + '&';
}
function Get_Value(id){
	return document.getElementById(id).value;
}
