var XmlHttpPool = 
{ 
    m_MaxPoolLength : 10, 
    m_XmlHttpPool : [], 
     
    requestObject : function() 
    { 
        var xmlhttp = null; 
        var pool = this.m_XmlHttpPool; 
        for ( var i=0 ; i < pool.length ; ++i ) 
        { 
            if ( pool[i].readyState == 4 || pool[i].readyState == 0 ) 
            { 
                xmlhttp = pool[i]; 
                break; 
            } 
        } 
        if ( xmlhttp == null ) 
        { 
            return this.extendPool(); 
        } 
        return xmlhttp; 
    }, 
     
    extendPool : function() 
    { 
        if ( this.m_XmlHttpPool.length < this.m_MaxPoolLength ) 
        { 
            var xmlhttp = null; 
            try 
            { 
                xmlhttp = new ActiveXObject('MSXML2.XMLHTTP'); 
            } 
            catch(e) 
            { 
                try 
                { 
                    xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); 
                } 
                catch(e2) 
				{
					try {
						xmlhttp = new XMLHttpRequest;
					}
					catch(e3) {}
				} 
            } 
            if ( xmlhttp ) 
            { 
                this.m_XmlHttpPool.push(xmlhttp); 
            } 
            return xmlhttp; 
        } 
    }, 
     
    GetRemoteData : function(url, callback) 
    { 
        this.receiveRemoteData(url, callback, 'GET', null); 
    }, 
     
    PostRemoteData : function(url, callback, data) 
    { 
        this.receiveRemoteData(url, callback, 'POST', data); 
    }, 
     
    receiveRemoteData : function(url, callback, httpmethod, data) 
    { 
        var xmlhttp = this.requestObject(); 
        if ( !xmlhttp ) 
        { 
            return null; 
        } 
        xmlhttp.open(httpmethod, url, true); 
        xmlhttp.onreadystatechange = function() 
        { 
            if ( xmlhttp.readyState == 4 || xmlhttp.readyState == 'complete' ) 
            { 
                callback(xmlhttp.responseText); 
            } 
        }; 
        xmlhttp.send(data); 
    },
    CancelAll : function()  
    {  
        var extendPool = this.extendPool;  
        this.extendPool = function()  
        {  
            return null;  
        }  
        for ( var i=0 ; i < this.m_XmlHttpPool.length ; ++i )  
        {  
            this.m_XmlHttpPool[i].abort();  
        }  
        this.extendPool = extendPool;  
    }  
}; 