//validat n process signup form
function valsignupform() {
	password =	document.form3.password.value;
	email = document.form3.email.value;
	dob3 = document.form3.dob3.value;
	email_len = email.length;
	dot = email.indexOf('.');
	at = email.indexOf('@');
	dot_at = dot - at;
	if((email.indexOf('.') == -1 || email.indexOf('@') == 0 || email.indexOf('@') == -1 || dot_at < 3 || (dot == (email_len - 1))) && email != ''){
		alert('Please enter a valid email address.');
	}
	else if(isNaN(dob3) || dob3.length != 4 || dob3 < 1904 || dob3 > 2005 ){
		alert('Please provide a valid year of birth.');
	}
	else if (document.form3.fname.value=="" || document.form3.email.value=="" || document.form3.username.value==""){
		window.alert("Please fill all the fields with asteriks");
	}
	else if(document.form3.password.value!=document.form3.cpassword.value) {
		window.alert("The passwords you provided do not match");
	}
	else if(password.length<6) {
	window.alert("Your password must contain atleast 6 characters");
	}
	else {
		processsignup();
	}
	return true;
}
//end signup validation
//get the complete url and asign it to a form feild form3.chkurlname
function purlsignupform(){
	var fname=document.form3.fname.value;
	var sex=document.form3.sex.value;
	var email=document.form3.email.value;
	var dob1=document.form3.dob1.value;
	var dob2=document.form3.dob2.value;
	var dob3=document.form3.dob3.value;
	var username=document.form3.username.value;
	var password=document.form3.password.value;
if(document.form3.fname.value!=""){
		document.form3.chkurlname.value="formprocessord.php?fname="+fname+"&sex="+sex+"&email="+email+"&dob1="+dob1+"&dob2="+dob2+"&dob3="+dob3+"&username="+username+"&password="+password;
	}
	else{
		document.form3.chkurlname.value="";
	}
}
//async begins
function getXMLHTTPRequestsignup(){
	
	try{
		req = new XMLHttpRequest();
	} catch(err1){
		
		try{
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(err2) {
			
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(err3) {
				reg = false;
			}
		}
	}
	return req;
	
}

var httpsignup = getXMLHTTPRequestsignup();

//display signup on home page or direct to the signup home page
function showsignup(){
		try{
		var myurl = "signup.html";
		httpsignup.open("GET", myurl, true);
		httpsignup.onreadystatechange = useHttpResponsesignup;
		httpsignup.send(null);
		}
		catch(errr){location='signupf.php';}
}


function useHttpResponsesignup(){
	if(httpsignup.readyState == 4){
		if(httpsignup.status==200){
			try{
			
			var mytextsignup=httpsignup.responseText;
				document.getElementById('fpage').innerHTML=mytextsignup;
			}
	catch(err4){location="signupf.php";}
		}
	}
	else{
		try{
	
		document.getElementById('fpage').innerHTML='<img src="images/bsyrnd.gif" title="Please wait while the list is retreived...." />';
		}
		catch(rr4){location="signupf.php";}
	}
}

var httpsmsme = getXMLHTTPRequestsignup();

//registere new phone for sms
function showsmsme(){
		var phone = document.getElementById('phone').value;
		var myurl = "sms/smsme.php?phone="+phone;
		var phonel = phone.length;
		if(phone == "" || phonel != 11 || (isNaN(phone))){
			alert('Please enter a valid mobile number');
		}
		else{
			httpsmsme.open("GET", myurl, true);
			httpsmsme.onreadystatechange = useHttpResponsesmsme;
			httpsmsme.send(null);
		}
}


function useHttpResponsesmsme(){
	if(httpsmsme.readyState == 4){
		if(httpsmsme.status==200){
			
			var mytextsmsme=httpsmsme.responseText;
				document.getElementById('newbar').innerHTML=mytextsmsme;
		}
	}
	else{
	
		document.getElementById('newbar').innerHTML='<img src="images/bsyrnd.gif" title="Please wait while the list is retreived...." /><br><font color="red">Registering Number..</font>';
	}
}
function hidesmsme(){
	document.getElementById('newbar').style.visibility = 'hidden';
}
//async ends
