var xmlhttp = new XMLHttpRequest();

function cool(val_post)
{
xmlhttp=GetXmlHttpObject();

if (xmlhttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  }

xmlhttp.onreadystatechange = stateChanged;
xmlhttp.open('POST', 'cool.php'+'?'+Math.random(), true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.setRequestHeader("Content-length", val_post.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.send(val_post);

}

function stateChanged()
{
if (xmlhttp.readyState==4)
{
	
//	var container = document.getElementById("center");
//	container.innerHTML = xmlhttp.responseText;


function so_clearInnerHTML(obj) {
	// so long as obj has children, remove them
	while(obj.firstChild) obj.removeChild(obj.firstChild);
}
// call your function to remove all the children from your element
so_clearInnerHTML(document.getElementById("center"));
// update the contents of the element with a new node

var newdiv = document.createElement("div");newdiv.innerHTML = xmlhttp.responseText;

document.getElementById("center").appendChild(newdiv);





// document.getElementById("center").removeChild(document.getElementById("center").firstChild);

// var newdiv = document.createElement("div");
// newdiv.innerHTML = xmlhttp.responseText;
// var container = document.getElementById("center");
 
// container.appendChild(newdiv);
// document.getElementById("center").innerHTML=xmlhttp.responseText;
}
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}