function newXML() {
    var A=null;
    try { // Try IE 6
        A=new ActiveXObject("Msxml2.XMLHTTP")
    } catch(e) {
        try { // Try older IE
            A=new ActiveXObject("Microsoft.XMLHTTP")
        } catch(oc) {
            A=null
        }
    }
    if (!A&&typeof XMLHttpRequest!="undefined") {
        // Otherwise, use XMLHttpRequest
        A=new XMLHttpRequest()
    }
    return A
}

function getChatButton(elem, url) {
    try{
        var req = newXML();
        if (req) {
            req.onreadystatechange = function() {
                if (req.readyState == 4 && req.status == 200){
                    elem.html( req.responseText );
                    
                }
            };
            req.open('GET', url, true);
            req.send('');
        }
    } catch(e) {
        debug(e);
    }
} 

$jq(document).ready(function(){
    if ($jq("#chat_container").length) {
        getChatButton($jq("#chat_container"), extchattool+"/xmlhttp-chatbutton-redesign.php");
    }

    if ($jq("#sidebar_chat_container").length) {
        getChatButton($jq("#sidebar_chat_container"), extchattool+"/xmlhttp-chatbutton-sidebar.php");
    }
});
