
function addmember() {  // This function does the AJAX request
divid="txtHint";
 if ( document.getElementById("password").value==document.getElementById("confirmpw").value ){
	 if(document.getElementById("username").value!="" && document.getElementById("confirmpw").value!="" && document.getElementById("password").value!="" && document.getElementById("email").value!="" && document.getElementById("name").value!=""&& document.getElementById("phone").value!="" && document.getElementById("postcode").value!="" ){
		 if(document.getElementById("username").value.length>1){
  //  Set our destination PHP page "ajaxpost.php"…
  http.open("POST", "addmember.php", true);
  http.onreadystatechange = getHttpRes;

  // Make our POST parameters string…
  var params = "&name="+encodeURI(document.getElementById("name").value)+
	"&phone="+encodeURI(document.getElementById("phone").value)+
	"&mobile="+encodeURI(document.getElementById("mobile").value)+
	"&email="+encodeURI(document.getElementById("email").value)+
	"&company="+encodeURI(document.getElementById("company").value)+
	"&address="+encodeURI(document.getElementById("address").value)+
	"&address1="+encodeURI(document.getElementById("address1").value)+
	"&city="+encodeURI(document.getElementById("city").value)+
	"&postcode="+encodeURI(document.getElementById("postcode").value)+
	"&username="+encodeURI(document.getElementById("username").value)+
	"&password="+encodeURI(document.getElementById("password").value);
	

  // Set our POST header correctly…
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");

  // Send the parms data…
  http.send(params);
 // setTimeout('sendmail()', 3000);
 //sendmail();
		 }
		 else{
			 alert('Your user name is too short');
		 }
  	 }
	 else{
		 alert('Some required fields are empty');
 
	 }
 }
 else{
	alert('Your password and the confirmed password dont match!');
 }


}


function checkusername() {  // This function does the AJAX request
divid="usernamechk";
  //  Set our destination PHP page "ajaxpost.php"…
  http.open("POST", "checkmember.php", true);
  http.onreadystatechange = getHttpRes;

  // Make our POST parameters string…
  var params = "&username="+encodeURI(document.getElementById("username").value);
	

  // Set our POST header correctly…
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");

  // Send the parms data…
  http.send(params);
  

}

function sendcontact() {  // This function does the AJAX request
divid="usernamechk";
if( document.getElementById("name").value!="" && document.getElementById("email").value!="" && document.getElementById("phone").value!="" && document.getElementById("comment").value!=""){
   
   
  //  Set our destination PHP page "ajaxpost.php"…
  http.open("POST", "sendcontact.php", true);
  http.onreadystatechange = getHttpRes;

  // Make our POST parameters string…
  var params = "&name="+encodeURI(document.getElementById("name").value)+
  "&email="+encodeURI(document.getElementById("email").value)+
  "&comment="+encodeURI(document.getElementById("comment").value)+
  "&phone="+encodeURI(document.getElementById("phone").value);
	

  // Set our POST header correctly…
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");

  // Send the parms data…
  http.send(params);
   }
   else{
	alert ('Some fields are empty! Please fill in the entire form.');   
   }

}
function resetpw() {  // This function does the AJAX request
divid="usernamechk";
  //  Set our destination PHP page "ajaxpost.php"…
  http.open("POST", "resetpw.php", true);
  http.onreadystatechange = getHttpRes;

  // Make our POST parameters string…
  var params = "&username="+encodeURI(document.getElementById("username").value)+"&postcode="+encodeURI(document.getElementById("postcode").value);
	

  // Set our POST header correctly…
  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");

  // Send the parms data…
  http.send(params);
  

}

function getHttpRes( ) {
  if (http.readyState == 4 && http.status == 200) { 
    res = http.responseText;  // These following lines get the response and update the page
	
    document.getElementById(divid).innerHTML =res;

   
						
							//	document.getElementById('usernamechk').innerHTML = res;  
								  
							 
   // document.getElementById('cell2').innerHTML = res;
   //history.go(0)
  }
}


function getXHTTP( ) {
  var xhttp;
   try {   // The following "try" blocks get the XMLHTTP object for various browsers…
      xhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e2) {
 		 // This block handles Mozilla/Firefox browsers...
	    try {
	      xhttp = new XMLHttpRequest();
	    } catch (e3) {
	      xhttp = false;
	    }
      }
    }
  return xhttp; // Return the XMLHTTP object
}




var http = getXHTTP(); // This executes when the page first loads.
var divid="";
