function sendmail() {
  var data = "to=" + escape(document.getElementById("mailto").value) +
    "&fromname=" + escape(document.getElementById("mailfromname").value) +
    "&fromaddr=" + escape(document.getElementById("mailfromaddr").value) +
    "&comment=" + escape(document.getElementById("mailcomment").value) +
    "&num=" + num + "&title=" + escape(title);
  sendHttpReq(true, "emailstrip.php", data, handleResponse);
  document.getElementById("mailsend").disabled = true;
  document.getElementById("mailsend").value = "Sending...";
}

function handleResponse(xmlhttp) {
  if (xmlhttp.readyState == 4) {
    document.getElementById("previewtext").innerHTML =
      ( (xmlhttp.status == 200) ? xmlhttp.responseText : "Error " + xmlhttp.status + " occurred!" ) +
      "<br /><br /><a href=\"javascript:flipForm();\">Close this panel</a>";
    document.getElementById("mailsend").style.display = "none";
    document.getElementById("mailedit").value = "Send to another friend";
  }
}

function mouse(obj, over) {
  obj.style.background = (over == 1) ? "#c9d6ff" : "#aac2ff";
}

function toggleDiv(id, visible) {
  document.getElementById(id).style.display = (visible) ? "block" : "none";
}

function autoToggleDiv(id) {
  toggleDiv(id, document.getElementById(id).style.display == 'none');
}

function flipForm() {
  toggleDiv('emailform', document.getElementById('emailform').style.display == "none");
}

function editmail() {
  toggleDiv("emailpreview", false);
  toggleDiv("emailfields", true);
}