//-------------------------------------------------------------------------
function getXMLHttpRequest() {   // 返回一个XMLHttpRequest对象
    var userAgent = navigator.userAgent.toLowerCase();
    var isMozillaCompatible = (document.all   // document不为空
            && !userAgent.match(/opera/)  // 不是opera浏览器
            && !navigator.appVersion.match(/mac/i))  // ？不是mac浏览器？
            ? true : false;

    return (isMozillaCompatible) ? new ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest()
}
//-------------------------------------------------------------------------
function checkOlineState() {
    var xmlRequest = getXMLHttpRequest();
    xmlRequest.open('GET', "/init?state&"+ Math.random(), false);
    xmlRequest.send(null);
    return xmlRequest.responseText.toUpperCase() == "TRUE";
}
//-------------------------------------------------------------------------
function checkIDExists(userid) {
    var xmlRequest = getXMLHttpRequest();
    xmlRequest.open('GET', "/init?hasid=" + userid + "&" +Math.random(), false);
    xmlRequest.send(null);
    return xmlRequest.responseText.toUpperCase() == "TRUE";
}
//--------------------------------------------------------------------------

function send(userid, msg) {
    if(msg=='') {
        alert('must be input text!');
        return;
    }
    var now = new Date();
    var Y=now.getFullYear();
    var M=now.getMonth()+1;
    var D=now.getDate();
    
    
    client.newMessage(userid, "A","a", msg ,processSend);
    messagearea.innerHTML += "<br>" + userid + ":" + Y+"-" + M +"-" + D + " " + now.getHours() + ":" + now.getMinutes()   +"<br>" + msg + "<br>";
}

function processSend(s){
   statusbar.innerText = s;
}
