function createRequestObject() {
var obj;
    try {
      // For Internet Explorer.
      obj = new ActiveXObject('Microsoft.XMLHTTP');
    }
    catch(e) {
      try {
        // Gecko-based browsers, Safari, and Opera.
        obj = new XMLHttpRequest();
      }
      catch (e) {
        // Browser supports Javascript but not XMLHttpRequest.
        obj = false;
      }
    }
    return obj;
}

var http = createRequestObject();

function sndReq(cat_id) {
    var buster=Math.floor(Math.random()*10001);
    http.open('get', '/f/forums/rpc.php?cat_id='+cat_id+'&n='+buster+';');
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function handleResponse() {
    if(http.readyState == 4){
        var response = http.responseText;
        var commands = new Array();
        var update = new Array();

        if(response.indexOf('\n' != -1))
             commands = response.split('\n');

        for (var n = 0; n < commands.length; n++)
        {
            if(commands[n].indexOf('|' != -1)) {
                update = commands[n].split('|');
                if(update[0]=='changeHTML')
                    if (document.getElementById(update[1]) != null)
                        document.getElementById(update[1]).innerHTML = update[2];
                if(update[0]=='state')
                        if (document.getElementById(update[1]) != null){
                            var state = update[2]=='disabled'?true:false;
                            document.getElementById(update[1]).disabled=state;
                            }
                if(update[0]=='changeClass')
                        if (document.getElementById(update[1]) != null)
                            document.getElementById(update[1]).className=update[2];
            }
        }
    }
}