var xmlHttpReq;
if(typeof XMLHttpRequest != 'undefined') 
{
  try 
  {
    xmlHttpReq = new XMLHttpRequest();
  } 
  catch(e) 
  {
	  try {
	    xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
	  } catch (e) {
	  try {
	    xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	    xmlHttpReq = false;
	  }
	 }
  }
}
else
{
  try {
	  xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	try {
	  xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (E) {
	  xmlHttpReq = false;
	}
  }
}

var data = sendRequest("POST", "include/paging-functions.php", "sender=sendRequest&type=new_comments");

function reloadNewComments()
{
  document.getElementById('comments').innerHTML = data;
  data = sendRequest("POST", "include/paging-functions.php", "sender=sendRequest&type=new_comments");
}

function getComments(page, mode, cid)
{
	document.getElementById('comments').innerHTML = sendRequest("POST", "include/paging-functions.php", "sender=sendRequest&type=comments&page=" + page + "&mode=" + mode + "&cid=" + cid);
}

function sendRequest(getOrPost, page, params)
{
  var strResult;
  if(getOrPost.toUpperCase() == "POST")
  {
    xmlHttpReq.open("POST", page, false);
    xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttpReq.send(params);
  }
  else
  {
    xmlHttpReq.open("GET", page + "?" + params, false);
    xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttpReq.send(null);
  }
  strResult = xmlHttpReq.responseText;
  return strResult;
}