//  ====================================
//========================================
function AdminMod_loader()
{
    this.PROGRESS='progress';
    this.COMPLETE='complete';
    
    this._infoLoader={};
    this._infoEvent={};
//  ------------------------------------
//----------------------------------------
    this.AdminMod_Com=function()
    {
        this._infoLoader['asynchrone']=true;
    }
//  ------------------------------------
//----------------------------------------
    this.set_asynchrone=function(pBol)
    {
        this._infoLoader['asynchrone']=pBol;
    }
//  ------------------------------------
//----------------------------------------
    this.set_loading_infos=function(pParent,pLoading)
    {
        this._infoLoader['loading']=pParent.document.createElement('div');
        if(typeof(pTbLiens)=='string')
            this._infoLoader['loading'].innerHTML=pLoading
        else
            this._infoLoader['loading'].appendChild(pLoading);
    }
//  ------------------------------------
//----------------------------------------
    this.load=function(pFile,pSend,pMethod)
    {
        this._infoLoader['file']=pFile;
        if(typeof(pTbLiens)=='string')
            this._infoLoader['send']=pSend;
        else if(pSend)
        {
            var t="";
            
            for (var ind in pSend)
            {
                t+=ind+'='+pSend[ind]+'&';
            }
            t=t.substr(0,t.length-1);
            this._infoLoader['send']=t;
        }
        this._infoLoader['methode']=pMethod;
        this._load()
    }
//  ------------------------------------
//----------------------------------------
    this._load=function()
    {
	
        var url=this._infoLoader['file'];
        var method=this._infoLoader['methode'];
        if(!method)
            method='get';
        
        var send=this._infoLoader['send'];
        
         var httpRequest = false;

        if (window.XMLHttpRequest) {
            httpRequest = new XMLHttpRequest();
            /*if (httpRequest.overrideMimeType) {
                httpRequest.overrideMimeType('text/xml');
            }*/
        }
        else if (window.ActiveXObject) {
            try {
                httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e) {
                try {
                    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch (e) {}
            }
        }

        if (!httpRequest) {
            alert('Abandon :( Impossible de créer une instance XMLHTTP');
            return false;
        }
        var thisClass=this;
        httpRequest.onreadystatechange = function() { thisClass._progress(httpRequest); };
        if(method=='get')
            url+='?'+send;
        httpRequest.open(method, url, this._infoLoader['asynchrone']);
        httpRequest.send(send);
    }
//  ------------------------------------
//----------------------------------------
    this.addEvent=function(pEvent,pFunction,pParam,pObjet)
    {
        this._infoEvent[pEvent]=[pFunction,pParam,pObjet];
    }
//  ------------------------------------
//----------------------------------------
    this._progress=function(evt)
    {
        this._infoLoader['event']='progress';
        this._infoLoader['httpRequest']=evt;
        
        
        if (evt.readyState == 4) 
            this._complete(evt);
        else if(this._infoEvent['progress'])
        {
            this._infoLoader['param']=this._infoEvent['progress'][1];
            if(this._infoEvent['progress'][2])
                this._infoEvent['progress'][2][this._infoEvent['progress'][0]](this._infoLoader)
            else
                this._infoEvent['progress'][0](this._infoLoader)
        }       
        
    }
//  ------------------------------------
//----------------------------------------
    this._complete=function()
    {
        this._infoLoader['event']='complete';
        try 
            {this._infoLoader['xml']=this._infoLoader['httpRequest'].responseXML;}
        catch (e) 
            {this._infoLoader['xml']=null};
         
        this._infoLoader['data']=this._infoLoader['httpRequest'].responseText;
        
        if(this._infoEvent['complete'])
        {
            this._infoLoader['param']=this._infoEvent['complete'][1];
            if(this._infoEvent['complete'][2])
                this._infoEvent['complete'][2][this._infoEvent['complete'][0]](this._infoLoader)
            else
                this._infoEvent['complete'][0](this._infoLoader)
        } 
    }

//  ------------------------------------
//----------------------------------------
    this.AdminMod_Com();
}

//  ====================================
//========================================
function AdminMod_com()
{
    this.PREGRESS='pregress';
    this.COMPLETE='complete';
    this.COMPLETEALL='complete_all';
    
    
}