﻿var _CallBack;
/*var busy = false;*/
        function SendAjaxRequest()
        {
        
            var command="";
            for(j=0;j<SendAjaxRequest.arguments.length;j++)
                command+=SendAjaxRequest.arguments[j].toString()+"\n";
            document.forms[0].action = window.location.toString();
           /*
			if (busy)
			{
			   RebuildedRequestArgs = "";
			   for(j=0;j<SendAjaxRequest.arguments.length;j++)
			   {
					RebuildedRequest+="\"" + SendAjaxRequest.arguments[j].toString() + "\"";
					if(j<SendAjaxRequest.arguments.length-1)
					{	
						RebuildedRequest+=",";
					}
				}
				setTimeout("SendAjaxRequest("+RebuildedRequest+")",1000);
				
			}
			else
			{
				busy = true;*/
				eval(_CallBack);  
			/*}*/
        }
        
        function error(errorText)
        {
            alert("Erreur AJAX : " + errorText);
        }

        function process(result,context)
        {
			busy = false;
            var resultTab = result.split("\n");
            var ResultCommand=resultTab[0]+"(";
            for(j=1;j<resultTab.length;j++)
            {
                ResultCommand+="'"+resultTab[j].replace(/'/g,"\\'")+"',";
            }
            ResultCommand = ResultCommand.substring(0,ResultCommand.length-1);
            ResultCommand+=")";

            try
            {
            eval(ResultCommand);    
            }
            catch(ex)
            {
            alert("Erreur AJAX : la fonction JS '"+resultTab[0]+"' n'a pas pu s'executer correctement.\nIl est possible qu'elle n'existe pas ou qu'elle contienne une erreur\n["+ex+"]");
            }
        }
