function getXmlHttp(){
  var xmlhttp;
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      xmlhttp = false;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}
var xmlHttp = getXmlHttp()

// make asynchronous HTTP request using the XMLHttpRequest object 
function like(id, score)
{
  // proceed only if the xmlHttp object isn't busy
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
  {
    // retrieve the name typed by the user on the form
    document.getElementById("score"+id).innerHTML = '';
	 

    // execute the quickstart.php page from the server
   
    xmlHttp.open("GET", "/xml/like.php?comment_id=" + id + "&score=" + score, true);  
	
    // define the method to handle server responses
    xmlHttp.onreadystatechange = handleServerResponseLike;
    // make the server request
    xmlHttp.send(null);
  }
}
function handleServerResponseLike() 
{
  // move forward only if the transaction has completed
  if (xmlHttp.readyState == 4) 
  {
    // status of 200 indicates the transaction completed successfully
    if (xmlHttp.status == 200) 
    {
      // extract the XML retrieved from the server
     var xmlResponse = xmlHttp.responseXML;
  // obtain the XML's document element
  xmlRoot = xmlResponse.documentElement;  
  // obtain arrays with book titles and ISBNs 
 
  score = xmlRoot.getElementsByTagName("score");
  pls = xmlRoot.getElementsByTagName("pls");
  mns = xmlRoot.getElementsByTagName("mns");
  comment_id = xmlRoot.getElementsByTagName("comment_id");
   // generate HTML output
  document.getElementById("minus"+comment_id.item(0).firstChild.data).innerHTML  = mns.item(0).firstChild.data;
    document.getElementById("plus"+comment_id.item(0).firstChild.data).innerHTML  = pls.item(0).firstChild.data;
   
   document.getElementById("score"+comment_id.item(0).firstChild.data).innerHTML  = score.item(0).firstChild.data;
    } 
    // a HTTP status different than 200 signals an error
    else 
    {
      alert("There was a problem accessing the server: " + xmlHttp.statusText);
    }
  }
}


