// HOW TO USE THIS CODE IN A WEB PAGE:
// new ajaxObj('myscript.php', 'myTestElement', 'Loading! Please wait...');

function ajaxObj(url, elmnts, loadingMsg)
{
	this.obj = new Object();
	this.url = url;
	this.loadInto = elmnts;
	if(loadingMsg)
	{
		if(typeof(this.loadInto) != 'object')
		{
      		document.getElementById(this.loadInto).innerHTML = loadingMsg;
		}
		else
		{
      			for(i in this.loadInto)
      			{
      			document.getElementById(this.loadInto[i]).innerHTML = loadingMsg;
      			}
		}
	}
	this.init();
} 

ajaxObj.prototype.create = function()
{
	try
   {
   	xmlHttp = new XMLHttpRequest();
   }
   catch(e)
   {
   	try
      {
      	xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch(e)
      {
      	try
        	{
         	xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        	}
      	catch(e)
        	{
        		return false;
        	}
      }
   } 
	
	this.obj = xmlHttp;
}

ajaxObj.prototype.handle = function()
{
	var o = this.obj;
	var into = this.loadInto;
	
	o.onreadystatechange = function()
   {
   	if(o.readyState == 4)
      {
      	if(typeof(into) != 'object')
      		document.getElementById(into).innerHTML = o.responseText;
      	else
      	{
      		temp = o.responseText.split("@@");
      		
      		for(i in into)
      		{
      			document.getElementById(into[i]).innerHTML = temp[i];
      		}
      	}
      }
	}
}

ajaxObj.prototype.send = function()
{
   this.obj.open('GET', this.url, true);
   this.obj.send(null);
}

ajaxObj.prototype.init = function()
{
	this.obj = null;
	
	this.create();
	
	this.handle();
	
	this.send();
}

