function ajaxdo(data, page, method, div) {
  	if (window.ActiveXObject) {
		var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ;
  	}
  	else {
    		var XhrObj = new XMLHttpRequest();
  	}

  	var content = document.getElementById(div);

	XhrObj.open("POST", page);

	XhrObj.onreadystatechange = function() {
    		if (XhrObj.readyState == 4 && XhrObj.status == 200)
      		content.innerHTML = XhrObj.responseText ;
  	}   

  	XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  	XhrObj.send(data);
}

function refreshChat() {
	ajaxdo('','actions/showchat.php','POST','chatw');
	document.getElementById('chatw').scrollTop = 9999;
}

function addToChat() {
	ajaxdo('mess='+ document.getElementById("message").value +'&pseudo='+ document.getElementById("pseudo").value,'actions/addmessage.php','POST','chatw');
}

function sendtochat() {
	addToChat();
	document.getElementById('message').focus();
	document.getElementById('message').value='';
	document.getElementById('chatw').scrollTop=9999;
}