function comment_show_form() {
  var el = document.getElementById("add_comment_button");
  var form = document.getElementById("add_comment_form");
  el.style.display = "none";
  form.style.display = "block";
}
function comment_hide_form() {
  var el = document.getElementById("add_comment_button");
  var form = document.getElementById("add_comment_form");
  el.style.display = "block";
  form.style.display = "none";
}

function comment_submit() {
  var hippo = document.getElementById("hippo");
  var elephant = document.getElementById("elephant");
  var giraffe = document.getElementById("giraffe");
  var lion = document.getElementById("lion");

  if (lion.value.length < 10)
    return alert("Please avoid posting short comments.");

  comment_hide_form();

  var xhr = new sack();
  xhr.vars = {
    hippo: [ hippo.value ],
    elephant: [ elephant.value ],
    giraffe: [ giraffe.value ],
    lion: [ lion.value ]
  };
  xhr.requestFile = "post_comment";
  xhr.onCompletion = comment_receive;
  xhr.runAJAX();
}

function comment_receive() {
  var cl = document.getElementById("comments");
  if (cl.innerHTML.length < 20)
    cl.innerHTML = this.response;
  else
    cl.innerHTML += this.response;
}

