function toAjax(objectName, dataToSend) {

//alert(objectName + ':' + dataToSend);

//alert('toAjax');

   if (typeof XMLHttpRequest != "undefined") {
       xmlhttp = new XMLHttpRequest();
   } else if (window.ActiveXObject) {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   }

	xmlhttp.open("POST","/ajax/" + objectName + ".asp",true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.onreadystatechange = function()
	  {
	  if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    {
	    fromAjax();
	    }
	  } ;
	xmlhttp.send(dataToSend);
	
	document.body.style.cursor = 'wait';
	
	return false;
}

function fromAjax() {

//alert('fromAjax');

//alert(xmlhttp.responseText);

	var handlers = xmlhttp.responseXML.getElementsByTagName("Handler");
	var handler;
	var data;
	var i;
	var container;

//alert(handlers.length);
	for (i=0;i<=handlers.length-1;i=i+1) {
		container = handlers[i].getElementsByTagName("Container")[0].childNodes[0].nodeValue;
		if (container == 'javascript') {
			eval(handlers[i].getElementsByTagName("Data")[0].childNodes[0].nodeValue)
		} else {
//alert(container);
			container = document.getElementById(container);
//alert(container != null);
//alert(container.id + '\n\r' + handlers[i].getElementsByTagName("Data")[0].childNodes[0].nodeValue);
			if (container != null) {
				container.innerHTML = handlers[i].getElementsByTagName("Data")[0].childNodes[0].nodeValue;
			}
		}
	}
	
	document.body.style.cursor = 'default';

//alert(handler);

}

function toAjax2(objectName, dataToSend) {

//alert(objectName + ':' + dataToSend);

//alert('toAjax2');

   if (typeof XMLHttpRequest != "undefined") {
       xmlhttp2 = new XMLHttpRequest();
   } else if (window.ActiveXObject) {
       xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP");
   }

	xmlhttp2.open("POST","/ajax/" + objectName + ".asp",true);
	xmlhttp2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp2.onreadystatechange = function()
	  {
	  if (xmlhttp2.readyState==4 && xmlhttp2.status==200)
	    {
	    fromAjax2();
	    }
	  } ;
	xmlhttp2.send(dataToSend);
	
	return false;
}

function fromAjax2() {

//alert('fromAjax');

//alert(xmlhttp2.responseText);

	var handlers = xmlhttp2.responseXML.getElementsByTagName("Handler");
	var handler;
	var data;
	var i;
	var container;

	for (i=0;i<=handlers.length-1;i=i+1) {
		container = handlers[i].getElementsByTagName("Container")[0].childNodes[0].nodeValue;
		if (container == 'javascript') {
			eval(handlers[i].getElementsByTagName("Data")[0].childNodes[0].nodeValue)
		} else {
//alert(container);
			container = document.getElementById(container);
//alert(container != null);
//alert(container.id + '\n\r' + handlers[i].getElementsByTagName("Data")[0].childNodes[0].nodeValue);
			if (container != null) {
				container.innerHTML = handlers[i].getElementsByTagName("Data")[0].childNodes[0].nodeValue;
			}
		}
	}

//alert(handler);

}


