var xhttp = false;


function createXMLHttpRequest() {
  if (window.ActiveXObject) {
    try {
      // IE 6 and higher
      xhttp = new ActiveXObject("MSXML2.XMLHTTP");
    } catch (e) {
      try {
        // IE 5
        xhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        xhttp=false;
      }
    }
  }
  else if (window.XMLHttpRequest) {
    try {
      // Mozilla, Opera, Safari ...
      xhttp = new XMLHttpRequest();
      if(xhttp.overrideMimeType)
        xhttp.overrideMimeType('text/html');
    } catch (e) {
      xhttp=false;
    }
  }
}



function sendRequest(link) {
  if (!xhttp) {
    alert("An Error occured when trying to initialize XMLHttpRequest!");
    return; // exit
  }

  xhttp.open("GET","getcontent.php?page="+link+"&"+Math.random(),true);
  xhttp.setRequestHeader("Content-type","text/html");
  xhttp.onreadystatechange=replaceContent;
  xhttp.send(null);
}

function sendRequest(link, user, target) {
  if (!xhttp) {
    alert("An Error occured when trying to initialize XMLHttpRequest!");
    return; // exit
  }

  xhttp.open("GET","getcontent.php?page="+link+"&user="+user+"&target="+target+"&"+Math.random(),true);
  xhttp.setRequestHeader("Content-type","text/html");
  xhttp.onreadystatechange=replaceContent;
  xhttp.send(null);
}

function init() {
  createXMLHttpRequest();
}



function replaceContent() {
  if (xhttp.readyState==4 && xhttp.status==200) {
    var content = document.getElementById("text");
    var newContent = "<p>"+xhttp.responseText+"</p>";
    content.innerHTML = newContent;

  }
}




window.onload=init;



