//mail + captcha
// stores the reference to the XMLHttpRequest object
var xmlHttp = createXmlHttpRequestObject(); 
var captHttp = createXmlHttpRequestObject(); 
// retrieves the XMLHttpRequest object
function createXmlHttpRequestObject() 
{	
  // will store the reference to the XMLHttpRequest object
  var xmlHttp;
  // if running Internet Explorer
  if(window.ActiveXObject)
  {
    try
    {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e) 
    {
      xmlHttp = false;
    }
  }
  // if running Mozilla or other browsers
  else
  {
    try 
    {
      xmlHttp = new XMLHttpRequest();
    }
    catch (e) 
    {
      xmlHttp = false;
    }
  }
  // return the created object or display an error message
  if (!xmlHttp)
 
    alert("Error creating the XMLHttpRequest object.");
  else 
    return xmlHttp;
}

// make asynchronous HTTP request using the XMLHttpRequest object 
function process()
{
var len; var params; 
  // proceed only if the xmlHttp object isn't busy
thetext = document.frm.thetext.value;
hide = document.getElementById("hide").value;
meno = document.getElementById("meno").value;
email = document.getElementById("email").value;
subj = document.getElementById("subj").value;
protect = document.getElementById("protect").value;
params="hide="+hide+"&thetext="+thetext+"&meno="+meno+"&email="+email+"&subj="+subj+"&protect="+protect;
//len = name.length;
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0 )
  {
    xmlHttp.open("POST", "ajaxmail.php");  
    xmlHttp.onreadystatechange = handleServerResponse;
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send(params);
	thetext = document.frm.thetext.value='';
	document.getElementById("meno").value='';
	document.getElementById("email").value='';
	document.getElementById("subj").value='';
  }
process1();
}

function process1()
{
 var myDate=new Date();
 var cparams=myDate.getTime();
  if (captHttp.readyState == 4 || captHttp.readyState == 0 )
  {
    captHttp.open("POST", "ajaxcaptcha.php");  
    captHttp.onreadystatechange = handleServerResponse1;
	captHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    captHttp.send(cparams);
	document.getElementById("protect").value='';
  }

}


function handleServerResponse() 
{
  // move forward only if the transaction has completed
  if (xmlHttp.readyState == 4) 
  {
    // status of 200 indicates the transaction completed successfully
    if (xmlHttp.status == 200) 
    {
      xmlResponse = xmlHttp.responseText;
	  
      document.getElementById("Message").innerHTML =  xmlResponse ;
    } 
    // a HTTP status different than 200 signals an error
    else 
    {
      alert("There was a problem accessing the server: " + xmlHttp.statusText);
    }
  }
  else
  {
  document.getElementById("Message").innerHTML =  '<img src="image/rasp.gif" width="50" height="5"><img src="image/by.gif">' ;
  } 
}

function handleServerResponse1() 
{
  if (captHttp.readyState == 4) 
  {
    if (captHttp.status == 200) 
    {
     captchaxml = captHttp.responseText;
	  
      document.getElementById("captcha").innerHTML =  captchaxml ;
    } 
    else 
    {
      alert("There was a problem accessing the server ajaxcaptcha: " + captHttp.statusText);
    }
  }

}

