//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;
pass1 = document.getElementById("pass1").value;
pass2 = document.getElementById("pass2").value;
email = document.getElementById("email").value;
protect = document.getElementById("protect").value;
params="pass1="+pass1+"&pass2="+pass2+"&email="+email+"&protect="+protect+"&hide=pd";
//len = name.length;
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0 )
  {
    xmlHttp.open("POST", "pdp.php");  
    xmlHttp.onreadystatechange = handleServerResponse;
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send(params);
	document.getElementById("pass1").value='';
	document.getElementById("pass2").value='';
	document.getElementById("email").value='';
	
  }
process1();
}

function process0()
{
var len; var params; 
  // proceed only if the xmlHttp object isn't busy
//thetext = document.frm.thetext.value;
pass1 = document.getElementById("pass1").value;
email = document.getElementById("email").value;
params="pass1="+pass1+"&email="+email+"&hide=od";
//len = name.length;
  if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0 )
  {
    xmlHttp.open("POST", "pdp.php");  
    xmlHttp.onreadystatechange = handleServerResponse;
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.send(params);
	document.getElementById("pass1").value='';
	document.getElementById("email").value='';
	
  }

}

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="70" 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);
    }
  }

}

function processpd()
{
document.getElementById("tilo").innerHTML='<h6>email<br><input type="text" id="email" name="email" class="button"></h6>								<h6>пароль<br><input  type="password" id="pass1" name="pass1"  class="button"></h6><h6>повторити<br><input  type="password" id="pass2" name="pass2"  class="button"></h6><h6><span id="captcha" /></span><br><input type="text" id="protect"  name="protect"  class="button" ></h6><br><br><h6><input type="button" onclick="process();"  value="відіслати" class="button" ></h6>';
process1();
}

function processod()
{
document.getElementById("tilo").innerHTML='<h6>email<br><input type="text" name="email" class="button"></h6>                                <h6>пароль<br><input  type="password" name="pass1"  class="button"></h6><br><br><h6><input type="button" onclick="process0();"  value="відіслати" class="button" ></h6>';
}