var theRequest = false;
var theCallback = "";
var theCallbackAdd = "";
var theLastAjax = ""
var txtA = "";
var txtB = "";
var txtR = "";

function admiAjax(lien, args, oncomp)
{
	if (dei('loading_bar') != null)	dei('loading_bar').style.visibility = "visible";
	var myAjax = new Ajax.Request ( lien,
	{
		method: 'post', 
		evalScripts: true,
		postBody: args,
		onComplete: function(transport)
		{
			var TabMyResult, TabMyResult2;

			theCallbackAdd = "";
			theLastAjax = transport.responseText;
			
			TabMyResult  = theLastAjax.split(/<script id=["']js_add["'] type=["']text\/javascript["']>/);
			if (TabMyResult.length > 1)	TabMyResult2 	= TabMyResult[1].split("</script>");
			if (TabMyResult2!= null && TabMyResult2.length > 1)	theCallbackAdd += TabMyResult2[0];

			TabMyResult  = theLastAjax.split(/<script type=["']text\/javascript["']>/);
			if (TabMyResult.length > 1)	TabMyResult2 	= TabMyResult[1].split("</script>");
			if (TabMyResult2!= null && TabMyResult2.length > 1)	theCallbackAdd += TabMyResult2[0];
			
			if(theCallback != "") 		{ eval(theCallback);}
			if(theCallbackAdd != "") 	{ eval(theCallbackAdd);}
						
			if (oncomp != null)
			{
				eval(oncomp);
			}
		},
		onFailure: function(transport)
		{
			if (oncomp != null)
			{
				eval(oncomp);
			}
		}
		
	});	
}

/*
function admiAjax(page, args)
	{
	if (dei('loading_bar') != null)	dei('loading_bar').style.visibility = "visible";
		
	theRequest = false;

	//alert("Requete = "+page);

	if(window.XMLHttpRequest)
		{
		theRequest = new XMLHttpRequest();
		if(theRequest.overrideMimeType)
			{
			theRequest.overrideMimeType('text/xml');
			}
		}
	else if(window.ActiveXObject)
		{
		try
			{
			theRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try
				{
				theRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
		
	if(!theRequest)
		{
		alert('Error: could not create XMLHTTP object.');
		return false;
		}

	theRequest.onreadystatechange = admiAjaxResult;
	theRequest.open('GET', page, true);
	theRequest.send(null);
	
	return admiAjaxResult;
	}

function admiAjaxResult()
	{
	if(theRequest.readyState == 4)
		{
		if(theRequest.status == 200)
			{
			var TabMyResult, TabMyResult2;
			
			theLastAjax = theRequest.responseText;
			theCallbackAdd = "";
			
			TabMyResult  = theLastAjax.split(/<script id=["']js_add["'] type=["']text\/javascript["']>/);
			if (TabMyResult.length > 1)	TabMyResult2 	= TabMyResult[1].split("</script>");
			if (TabMyResult2!= null && TabMyResult2.length > 1)	theCallbackAdd += TabMyResult2[0];

			TabMyResult  = theLastAjax.split(/<script type=["']text\/javascript["']>/);
			if (TabMyResult.length > 1)	TabMyResult2 	= TabMyResult[1].split("</script>");
			if (TabMyResult2!= null && TabMyResult2.length > 1)	theCallbackAdd += TabMyResult2[0];
								
			if (dei('loading_bar') != null)	dei('loading_bar').style.visibility = "hidden";
			
			if(theCallback != "") 		{ eval(theCallback);}
			if(theCallbackAdd != "") 	{ eval(theCallbackAdd);}
			
			//alert(theCallback);
			
			return theLastAjax;
			}
		}
	}
*/