function chat_visibility(which) {
  document.getElementById('public_chat').style.display ='none';
  document.getElementById('coven_chat').style.display ='none';
  document.getElementById('mod_chat').style.display ='none';
  document.getElementById('public_tab').style.backgroundColor ='#dddddd';
  document.getElementById('coven_tab').style.backgroundColor = '#dddddd';
  document.getElementById('mod_tab').style.backgroundColor ='#dddddd';
  document.getElementById(which + '_chat').style.display = 'inline';
  document.getElementById(which + '_tab').style.backgroundColor ='#ffffff';
}

function chattertalk(ta, evt, chan, u,t,r) {
  var charCode = (evt.which) ? evt.which : evt.keyCode;
  if (charCode==13) {
    if (req2) {
      return false;
    }
    if (window.XMLHttpRequest) {
      try {
        req2 = new XMLHttpRequest();
      } catch (e) {
        req2 = false;
      }
    } else if (window.ActiveXObject) {
      // For Internet Explorer on Windows
      try {
        req2 = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          req2 = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
          req2 = false;
        }
      }
    }
    req2.open("POST", r+"/chatter/gateway.adp", true);
    req2.onreadystatechange = sendStateChange;
    req2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    var encoded = "";
    encoded = "u="+u+"&t="+t+"&c="+escape(chan)+"&m="+escape(ta.value);
    req2.send(encoded);

    ta.value='';
    return false;
  }
  return true;
}

function sendStateChange() {
  if (req2.readyState != 4) {
    return;
  }
  req2 = null;
}

