
function createAjaxObject()
{
	var xmlObject;
	
	try{xmlObject=new XMLHttpRequest();}
	catch (e)
	{
		// Internet Explorer
		
		try{xmlObject=new ActiveXObject("Msxml2.XMLHTTP");}
		catch (e)
		{
			try{xmlObject=new ActiveXObject("Microsoft.XMLHTTP");}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	if(xmlObject){return xmlObject;}
	else{xmlObject = null; return false;}
 }
 
 function sendAjaxGetResponse(submitMethod,url)
 {
 	return processXMLState(sendAjax(submitMethod,url,false));
 }
 
 function sendAjaxWithCallBack(submitMethod,url,aFunction)
 {
 	var xmlObject = sendAjax(submitMethod,url,true);
 	if(aFunction)
 	{
 		xmlObject.onreadystatechange = function(){aFunction(xmlObject);};
 	}
	
 }
 
 function sendAjax(submitMethod,url,async)
 {
 	if(async !== false && empty(async)){async = true;}
 	var xmlObject = createAjaxObject();
 	
 	if(xmlObject)
 	{
		xmlObject.open(submitMethod, url, async);
		xmlObject.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlObject.send(null);
		return xmlObject;
	}
	xmlObject = null;
 }

function processXMLState(xmlObject)
{
	
	if (xmlObject.readyState == 4) 
	{
        	if(xmlObject.status == 200) {return xmlObject.responseText;} 
		else{alert('There was a problem retrieving the XML data: ' + xmlObject.responseText);}
		xmlObject = null;
    	}
    	
}

function ajaxWithWaitingScreen(xmlObject,submitMethod,url,aFunction,element,state)
{
	if(state==1)
	{
		if(typeof(xmlObject.responseText)!="unknown" && xmlObject.readyState == 4 && xmlObject.status == 200)
    		{
			document.getElementById(element).innerHTML = "";
			if(!empty(aFunction)){aFunction(xmlObject);}
			
		}
	}
	else
	{
		document.getElementById(element).innerHTML = "<img src=\"skins/default/images/ajax-loader.gif\">";
		sendAjaxWithCallBack(submitMethod,url,function(xmlObject){ajaxWithWaitingScreen(xmlObject,null,null,aFunction,element,1);});	
		
	}
	xmlObject = null;
}