var xmlHttp;

function getContent(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }
var url="/_includes/ajax.php?q="+str;
whichOut = str;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function quickFeedback(str,qid,qresult,qorig,right,nooftimes)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }
var url="/_includes/ajax.php?q="+str+"&qid="+qid+"&qresult="+qresult+"&qorig="+qorig+"&right="+right+"&nooftimes="+nooftimes;
whichOut = str;
isRight = right;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
   if (whichOut == "popular") {
 document.getElementById("popularContent").innerHTML=xmlHttp.responseText;
   }
   else if (whichOut == "latest") {
 document.getElementById("latestContent").innerHTML=xmlHttp.responseText;
   }
   else if (whichOut == "userStats") {
 document.getElementById("statsDiv").innerHTML=xmlHttp.responseText;
   }
   else if (whichOut == "quickFeedback" && isRight == "yes") {
 document.getElementById("quickFeedbackContainer").innerHTML=xmlHttp.responseText;
   }
   else if (whichOut == "quickFeedback" && isRight == "no") {
 document.getElementById("results").innerHTML=xmlHttp.responseText;
   }
 } 
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}