var ajax_request_list = new Array ();

Function.prototype.bind = function(object) {
    var method = this
    return function() {
        return method.apply(object, arguments) 
    }
}
function show_faq(url, container, base_url) {
    if (document.getElementById) {
        /*if (typeof container != 'object')
            container = document.getElementById (container);*/
        
        try {
          request = new XMLHttpRequest();
        } catch (trymicrosoft) {
          try {
            request = new ActiveXObject("Msxml2.XMLHTTP");
          } catch (othermicrosoft) {
            try {
              request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (failed) {
              request = false;
            }
          }
        }
        
        if (request) {
            request.open("GET", url, true);
            request.onreadystatechange = updatePage.bind(request);
            
            ajax_request_list[ajax_request_list.length] = [request, url, container, base_url];
            document.getElementById (container).innerHTML = 'пожалуйста подождите';
            document.getElementById (container).className = "loading";
            
            request.send(null);

            return false;
        }
    }
    return true;
    
}
function updatePage() {
    if (this.readyState == 4) {
    
    
        
        for (i=0; i<ajax_request_list.length; i++) {
            if (ajax_request_list[i][0] == this) {

                container = document.getElementById(ajax_request_list[i][2]);
                requested_url = ajax_request_list[i][3];
                
                for (j=i; j<ajax_request_list.length-1; j++)
                    ajax_request_list[j] = ajax_request_list[j+1];
                
                ajax_request_list.pop ();
                break;
            }
        }
        
        if (this.status == 200) {
            try {
                container.innerHTML = this.responseText;
                container.className = "";
            } catch (failed) {
                document.location = requested_url;
            }
        }
        else {
            document.location = requested_url;
        }
    }
}
