/*
											NE PAS MODIFIER LE CODE SUIVANT !!!!!!
*/




/*_________________________________________________________________________________________*/
/*                             				 OBJET SYNCHRONIZATEUR						   */
/*_________________________________________________________________________________________*/
function Synchronizator(){
 
this.fcts         = new Array();/* fonctions a executées*/
this._reponseAjax = new Array();/* TABLEAU DES REPONSES AJAX*/

 this.caller = function(){
    if (this.fcts.length >0){
	  
	   if ( this.fcts[0][0].toString().toLowerCase().indexOf('__ajax__') != -1 ){
	     this.fcts[0][0].apply( this, this.fcts[0] ) ;
		 this.fcts.shift();
       }else{
	     this.fcts[0][0].call( this, this.fcts[0][1] ) ;
		 this.fcts.shift();
		 this.caller();
       }
	  
	} // >0
 }
 
  this.pusher = function(){
   var cpt = this.fcts.length;
   this.fcts[cpt] = this.pusher.arguments ;
   var callback_func = this.pusher.arguments[this.pusher.arguments.length-1];
        if (callback_func != null) {
	    	 var indice = this.pusher.arguments[1];
			 this._reponseAjax[indice]="";
	         this.pusher(callback_func, indice, null);
		}
 }
 
 this.getSize     = function(){ return (this.fcts.length); }
 this.init        = function(){this.fcts = new Array();this._reponseAjax = new Array();}
 this.getResponse = function(){return (this._reponseAjax[this.getResponse.arguments[0]]);}
 this.clear       = function(){this.init()};

}// fin Object


/*_________________________________________________________________________________________*/
/*                             				  FONCTION AJAX								   */
/*_________________________________________________________________________________________*/


/*
 Ajout champ _adnTime dans uri pour empecher mise en cache de la requete
*/
function updateUri(uri){

var sep = "?";
var p = uri.indexOf(sep);
   if (p != -1) sep="&";
return uri+sep+"_adnTime="+(new Date()).getTime();
}

/*

*/

function __AJAX__(func,idRequest, method, uri, synchro, postDATA){ 
uri = updateUri(uri);
var xmlHTTP = (window.ActiveXObject) ? new ActiveXObject("MICROSOFT.XMLHTTP") : new XMLHttpRequest();//OBJET HTTPRequest
 if (xmlHTTP){
   
               xmlHTTP.onreadystatechange = function(){
			    if ( (xmlHTTP.readyState==4) && (xmlHTTP.status==200) ){
			   	    synchro._reponseAjax[idRequest] = xmlHTTP.responseText ;
				    synchro.caller();
        		}// fin if
   }// fin fn() event

xmlHTTP.open(method,uri,true);
if (method.toLowerCase() == "post")
 xmlHTTP.setRequestHeader('Content-type','application/x-www-form-urlencoded');  
else
 postDATA = null;
 
xmlHTTP.send(postDATA); 
 }
} // fin fn() Ajax


/*  VARIABLES GLOBALES  */

var sync = new Synchronizator();



