/**
 * Bridge XMLHTTP to XMLHttpRequest in pre-7.0 Internet Explorers
 */
if( typeof XMLHttpRequest == "undefined" ) XMLHttpRequest = function()
{ try{ return new ActiveXObject("Msxml2.XMLHTTP.6.0") }catch(e){}
  try{ return new ActiveXObject("Msxml2.XMLHTTP.3.0") }catch(e){}
  try{ return new ActiveXObject("Msxml2.XMLHTTP") }catch(e){}
  try{ return new ActiveXObject("Microsoft.XMLHTTP") }catch(e){}
  throw new Error("This browser does not support XMLHttpRequest or XMLHTTP.")
};

/* send an email.

   Construct an email message, then pass the data
   to email.asp which uses CDO to send the email, email.php, or,
   in a Unix environment, to cgiemail
*/
function sendemail(to,from,subject,message,OKresponse,lang)
{ var url
  switch (lang)
  { case "cgi": url = "/cgi-bin/cgiemail/emailtemplate.txt"; break;
    case "asp": url = "/email.asp"; break;
    case "php": url = "/email.php"; break;
    default: alert("no language defined"); return false;
  }
  var postdata = "to=" + to + "&from=" + from + "&subject=" + subject + "&message=" + escape(message)
  var oReq = new XMLHttpRequest
  oReq.open("POST",url,false)
  oReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  oReq.send(postdata)
//alert(oReq.statusText + "\n" + oReq.responseText)

  if (oReq.statusText != "OK")
  { alert(oReq.statusText) }
  else if (oReq.responseText == "OK"  || oReq.statusText.substr(0,35) == "<HEAD><TITLE>Success</TITLE></HEAD>")
  { alert(OKresponse) }
  else
  { alert(oReq.responseText) }
  return true
}
