var req = new Array();
var tgt = new Array();
var reqPtr = -1;
var maxPtr = 4;

function isFunction(a) {return typeof a == 'function';}

function getURL(url, target) {
	reqPtr++;	if (reqPtr > maxPtr) reqPtr = 0;
  if (window.XMLHttpRequest) {
    req[reqPtr] = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req[reqPtr] = new ActiveXObject("Microsoft.XMLHTTP");
  }
	tgt[reqPtr] = target;
  if (req[reqPtr] != undefined) {
    req[reqPtr].onreadystatechange = function() {getDone();};
    req[reqPtr].open("GET", url + "&rnd=" + Math.random(), true);
    req[reqPtr].send("");
  }
}

function getDone() {
	for (rPtr = 0; rPtr <= maxPtr; rPtr++)
	{
  if ((req[rPtr] != undefined) && (req[rPtr] != null) && (req[rPtr].readyState == 4)) {
    if (req[rPtr].status == 200) {
	  if (isFunction(tgt[rPtr])) 
	  	{respText = req[rPtr].responseText; req[rPtr] = null; tgt[rPtr](respText);}
	  else
        document.getElementById(tgt[rPtr]).innerHTML = req[rPtr].responseText;
    } else {
	  if (isFunction(tgt[rPtr]))
	    tgt[rPtr]("error:"+req[rPtr].statusText);
	  else
        document.getElementById(tgt[rPtr]).innerHTML="error:\n"+req[rPtr].statusText;
    }
		req[rPtr] = null; tgt[rPtr] = null;
  }
	}
}


function parseAjaxReturnString(str, delimiter){
	myArray = new Array();
	i = 0;
	while(str.indexOf(delimiter)>0)
	{
		pos = str.indexOf(delimiter);
		myArray[i] = str.substr(0, pos);
		str = str.substr(pos + 1);
		i = i + 1;
	}
	myArray[i] = str;
	return myArray;
}