function insertComment(article_id)
{
  var comment_form = "<hr><form name='commentform' method='get' action='functions.php'>";
  comment_form += "<table width='80%' height='133' border='0'>";
  comment_form += "<tr> ";
  comment_form += "<td height='20'>Name: ";
  comment_form += "<input type='text' name='name'></td>";
  comment_form += "<input type='hidden' name='update_id' value='" + article_id + "'></td>";
  comment_form += "</tr>";
  comment_form += "<tr> ";
  comment_form += "<td><p>";
  comment_form += "<textarea name='comment' id='textArea_comment" + article_id + "' cols='50' rows='5'></textarea>";
  comment_form += "</p>";
  comment_form += "<p><a href='#' onClick='javascript:postComment(" + article_id + ")'>Kommentar posten</a></p></td>";
  comment_form += "</tr>";
  comment_form += "</table>";
  comment_form += "</form><hr> ";
  
  var div = "comment" + article_id;
  
  document.getElementById( div ).innerHTML = comment_form;
}

function postComment(article_id)
{
  var str_replaced = document.getElementById("textArea_comment" + article_id).value;
  str_replaced = str_replaced.replace(/\n/g, "<br />");
  str_replaced = str_replaced.replace(/&/g, "");
  str_replaced = str_replaced.replace(/>/g, "");
  str_replaced = str_replaced.replace(/"/g, "'");
  
  document.getElementById("textArea_comment" + article_id).value = str_replaced;
  document.commentform.submit();
}

function replaceString(str_to_replace)
{
  var str_replaced = str_to_replace;
  str_replaced = str_replaced.replace(/\n/g, "<br />");
  str_replaced = str_replaced.replace(/\r/g, "<br />");
  return str_replaced;
}

function showComments(article_id, comment_datum, comment_author, comment_text)
{
  if (comment_text.length < 1)
    return false;
  var comment_form = "<hr>";
  
  var article_id_part = article_id.split("##");
  var comment_datum_part = comment_datum.split("##");
  var comment_author_part = comment_author.split("##");
  var comment_text_part = comment_text.split("##");
  
  for (var i = 1; i <= article_id_part.length - 1; i++)
  {
    comment_form += (article_id_part.length - i) + ". Kommentar von '" + comment_author_part[i] + "' (" + comment_datum_part[i] + "):<br />";
    comment_form += "<i>" + comment_text_part[i] + "</i>";
    comment_form +="<hr>";
  };
  var div = "comment" + article_id_part[1];

  document.getElementById(div).innerHTML = comment_form;
  return true;
}

function countDownload(beitrag_id, download_id)
{
 var fenster = window.open("functions.php?download_id=" + download_id + "&article_id=" + beitrag_id);
 fenster.close();
}


