var xmlHttp

function postRating(nuts, filmID)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Your browser does not support the XMLHttpRequest object.")
		return
	}
	var url="/includes/rateomatic/_postRating.php"
	url=url+"?nuts="+nuts
	url=url+"&filmID="+filmID
	xmlHttp.onreadystatechange=stateChanged
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChanged()
{
  if (xmlHttp.readyState == 0)
  {
	document.getElementById("rateTextBox").innerHTML = "<p>Search in progress...</p>"; //loading
  }
  else if(xmlHttp.readyState == 1)
  {
	document.getElementById("rateTextBox").innerHTML = "<p>Search in progress...</p>"; //loaded
  }
  else if(xmlHttp.readyState == 2)
  {
	document.getElementById("rateTextBox").innerHTML = "<p>Search in progress...</p>"; //interactive
  }
  else if(xmlHttp.readyState == 3)
  {
	document.getElementById("rateTextBox").innerHTML = "<p>Loading data...</p>";
  }
  else if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
  {
	postRatingData = xmlHttp.responseText.split("\n");
	document.getElementById("rateTextBox").innerHTML=postRatingData[0];
	document.getElementById("rateomatic").className=postRatingData[1];
  }
}

function GetXmlHttpObject()
{
  var objXMLHttp=null
  
  try {
    objXMLHttp = new ActiveXObject("Msxml2.XMLHTTP"); //later IE
  } catch (e) {
  try {
    objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP"); //earlier IE
  } catch (e) {
  objXMLHttp = null;
  }
  }
  
  if (objXMLHttp==null)
  {
    objXMLHttp=new XMLHttpRequest() //IE7, Firefox, Safari
  }
  return objXMLHttp
}