//general javascript

function erzXMLHttpRequestObject(){
  var resOb = null;
  try {
    resOb = new ActiveXObject("Microsoft.XMLHTTP");
  }
  catch(Error){
    try {
      resOb = new ActiveXObject("MSXML2.XMLHTTP");
    }
    catch(Error){
      try {
      resOb = new XMLHttpRequest();
      }
      catch(Error){
        alert("Erzeugung des XMLHttpRequest-Objekts nicht möglich. Die Funktionsweise dieser Webseite ist eventuell nicht einwandfrei.");
      }
    }
  }
  return resOb;
}
resOb = erzXMLHttpRequestObject();


//comment

function CommentAnswer(comment_id,comment_name) {
  document.getElementById('antwort').value = comment_id;
  document.getElementById('normal_link').style.display = 'block';
  document.getElementById('comment_heading').innerHTML = 'Auf Kommentar von ' + comment_name + ' antworten';
  document.location.href = '#comment_heading';
}

function CommentNormal() {
  document.getElementById('antwort').value = '';
  document.getElementById('normal_link').style.display = 'none';
  document.getElementById('comment_heading').innerHTML = 'Kommentar schreiben';
}


function commentReq(url) {
  name = '&name=' + escape(encodeURI(document.getElementById('name').value));
  mail = '&mail=' + escape(encodeURI(document.getElementById('mail').value));
  webs = '&webs=' + escape(encodeURI(document.getElementById('webs').value));
  text = '&nachricht=' + escape(encodeURI(document.getElementById('nachricht').value));
  rechnung = '&rechnung=' + escape(encodeURI(document.getElementById('rechnung').value));
  entry_id = '&id=' + escape(encodeURI(document.getElementById('entry_id').value));
  antwort = '&antwort=' + escape(encodeURI(document.getElementById('antwort').value));
  send = '&send=' + escape(encodeURI(document.getElementById('send').value));

  url = url + name + mail + webs + rechnung + text + entry_id + antwort + send + '&z=' + Math.random();
  resOb.open('get', url, true);
  resOb.onreadystatechange = commentRes();
  //Cachen verhindern
  resOb.setRequestHeader("Pragma", "no-cache");
  resOb.setRequestHeader("Cache-Control", "must-revalidate");
  resOb.setRequestHeader("If-Modified-Since", document.lastModified);
  resOb.send(null);
}

function commentRes() {
  return function() {
      if(resOb.readyState == 4){
          document.getElementById('comment').innerHTML = resOb.responseText;
      } else {
          document.getElementById('comment').innerHTML = '<div style="text-align: center;"><img src="/files/img/loading.gif" width="66" height="66" alt="Aktualisiere... / Loading..." /></div>';
      }
  }
}