var http_threads = 20;
var http_request = new Array(http_threads);
var http_parent = new Array(http_threads);
for(var i=0;i<http_threads;i++) {
	http_request[i] = false;
	http_parent[i] = false;
}

function start_ajax(par) {
	var http_current = false;
	//#while(isNaN(Number(http_current))) {
		//setTimeout("null",500);
		http_current = next_ajax();
	//}
	http_request[http_current] = false;
	http_parent[http_current] = par;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request[http_current] = new XMLHttpRequest();
		if (http_request[http_current].overrideMimeType) {
			http_request[http_current].overrideMimeType('text/xml');
			// See note below about this line
		}
	}
	else if (window.ActiveXObject) { // IE
		try {
			http_request[http_current] = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request[http_current] = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request[http_current]) {
		alert('Browser inkompatibel!');
		return false;
	}
	else {
		return http_current;
	}
}

function next_ajax() {
	var i = 0;
	while(http_request[i] != false && i < http_threads) {
		i++;
	}
	if(http_request[i] != false) {
		return false;
	}
	else {
		return i;
	}
}

function reset_ajax(i) {
	http_request[i] = false;
	http_parent[i] = false;
}
