/**
 * 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, or,
   in Unix environment, to cgiemail
*/
function sendemail(to,from,subject,message,OKresponse)
{ 
  var url = "/email.asp"
//var url = "/cgi-bin/cgiemail/emailtemplate.txt

  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.responseText.substr(0,35) == "<HEAD><TITLE>Success</TITLE></HEAD>")
  { alert(OKresponse) }
  else
  { alert(oReq.responseText) }
  return true
}
