var xmlreqs = new Array();
var theDiv;
  
function CXMLReq(type, xmlhttp, theDiv) 
{
	this.type = type;
	this.xmlhttp = xmlhttp;
	this.theDiv = theDiv;
}





function xmlreqGET(url, theDiv) 
{
	var xmlhttp = false;
	var theDiv = theDiv;
	
	//alert('theUrl: ' + url);
	//alert('theDiv: ' + theDiv);
	
	if (window.XMLHttpRequest) 
	{      // Mozilla, etc.
		xmlhttp = new XMLHttpRequest();
		xmlhttp.onreadystatechange = xmlhttpChange;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	} 
	else if (window.ActiveXObject) 
	{      // IE
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		if (xmlhttp) 
		{
			xmlhttp.onreadystatechange = xmlhttpChange;
			xmlhttp.open("GET",url,true);
			xmlhttp.send();
		}
	}
	
	var xmlreq = new CXMLReq('', xmlhttp, theDiv);
	
	xmlreqs.push(xmlreq);
	
}

  
function xmlhttpChange() 
{
	if (typeof(window['xmlreqs']) == "undefined") return;
	
	for (var i=0; i < xmlreqs.length; i++) 
	{
		if (xmlreqs[i].xmlhttp.readyState == 4) 
		{
			//alert('status: ' + xmlreqs[i].xmlhttp.status);
			if (xmlreqs[i].xmlhttp.status == 200 || xmlreqs[i].xmlhttp.status == 304) 
			{
				// 200 OK
				handle_response(xmlreqs[i].theDiv, xmlreqs[i].xmlhttp);
				xmlreqs.splice(i,1); i--;
			} 
			else 
			{
				// error
				// alert('error' + xmlreqs[i]);
				xmlreqs.splice(i,1); i--;
			}
		}
	}
}





function handle_response(theDiv, xmlhttp)
{
  //alert(theDiv);
  var thisResponse = xmlhttp.responseText;
  document.getElementById(theDiv).innerHTML = thisResponse;
}
